[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
This is very similar to the for-each main procedure (see section 7.6.7 for-each: perform function on each argument).
The difference is that the callout procedure is passed a read-only
FILE*
pointer and a pointer to the file name:
extern int my_handler( FILE* in_fp, const char* pz_file_name ); |
res = my_handler( stdin, "stdin" ); exit( res ); |
If there are command line operands, then each operand is processed as follows:
const char* pzF = *(argv++); FILE* fp = fopen( pzF, "r" ); if (fp == NULL) { fprintf( stderr, "prog-name fs ERROR: %d (%s) opening %s\n", errno, strerror( errno ), pzF ); return EXIT_FAILURE; } res |= my_handler( fp, pzF ); fclose( fp ); |