adjfdpos man page on DragonFly

Man page or keyword search:  
man Server   44335 pages
apropos Keyword Search (all sections)
Output format
DragonFly logo
[printable version]

sf_file(3)		 BSD Library Functions Manual		    sf_file(3)

NAME
     initfdpos, initFILEpos, adjfdpos, adjFILEpos — file positions indicator
     handling

SYNOPSIS
     #include <stdio.h>
     #include <strfunc.h>

     int
     initfdpos(const char *fname, int stream, const char *ext);

     int
     initFILEpos(const char *fname, FILE *stream, const char *ext);

     int
     adjfdpos(int stream, int posfd, int doSync);

     int
     adjFILEpos(FILE *stream, int posfd, int doSync);

DESCRIPTION
     Those functions are used to maintain a file positions indicator between
     the program sessions. This is often needed when a process is being parsed
     a log file and tries to save current position within this log to start
     from this point later.

     int initfdpos(const char *fname, int stream, const char *ext) creates a
     position indicator file "<fname>.<ext>", and returns its file descriptor.
     If the position file is already exists, then it advances stream's posi‐
     tion according to the information derived from that file.	initfdpos also
     checks the file size and inode changes in order to be robust in situa‐
     tions when file shrinked or replaced.

     int initFILEpos() is almost the same except that it takes a FILE * argu‐
     ment instead of plain file descriptor.

     Both functions returns position file descriptor, or -1 in case of fail‐
     ure.

     int adjfdpos(int stream, int posfd, int doSync) and adFILEdpos() writes
     the current position within the file referenced by stream into the posfd.
     If doSync is not zero, it also does fsync(2).

     Return values: 0 (Success) or -1 in case of any errors.

EXAMPLE
     void main() {
	     int posfd;
	     FILE *logfile;
	     char buf[1042];

	     logfile = fopen("file.log", "r");
	     if(!logfile)
		     exit(EX_NOINPUT);

	     while(fgets(buf, sizeof(buf), logfile)) {
		     /* Do something ... */

		     adjFILEpos(logfile, posfd, 0);
	     };

	     /* Force data to be flushed on disk. */
	     adjFILEpos(logfile, posfd, 1);
	     fclose(logfile);
	     close(posfd);
     };

SEE ALSO
     strfunc(3).

AUTHORS
     Lev Walkin <vlm@lionet.info>

BSD			       December 4, 2000				   BSD
[top]

List of man pages available for DragonFly

Copyright (c) for man pages and the logo by the respective OS vendor.

For those who want to learn more, the polarhome community provides shell access and support.

[legal] [privacy] [GNU] [policy] [cookies] [netiquette] [sponsors] [FAQ]
Tweet
Polarhome, production since 1999.
Member of Polarhome portal.
Based on Fawad Halim's script.
....................................................................
Vote for polarhome
Free Shell Accounts :: the biggest list on the net