int main(int argc, const char *argv[]) { struct cmdlineInfo cmdline; int eof; /* No more images in input */ unsigned int imageSeq; /* Sequence of current image in input file. First = 0 */ pm_proginit(&argc, argv); parseCommandLine(argc, argv, &cmdline); eof = FALSE; for (imageSeq = 0; !eof; ++imageSeq) { if (isMemberOfUintSet(&cmdline.imageSeqList, imageSeq)) { pm_message("Extracting Image #%u", imageSeq); extractOneImage(stdin, stdout); } else extractOneImage(stdin, NULL); pnm_nextimage(stdin, &eof); } failIfUnpickedImages(&cmdline.imageSeqList, imageSeq); destroyCmdline(&cmdline); pm_close(stdin); pm_close(stdout); return 0; }
int main(int argc, char *argv[]) { struct cmdlineInfo cmdline; FILE * ifP; bool eof; /* No more images in input */ unsigned int imageSeq; /* Sequence of current image in input file. First = 0 */ pnm_init(&argc, argv); parseCommandLine(argc, argv, &cmdline); ifP = pm_openr(cmdline.inputFileName); eof = FALSE; for (imageSeq = 0; !eof; ++imageSeq) { FILE * ofP; const char * outputFileName; /* malloc'ed */ computeOutputName(cmdline.outputFilePattern, cmdline.padname, imageSeq, &outputFileName); pm_message("WRITING %s", outputFileName); ofP = pm_openw(outputFileName); extractOneImage(ifP, ofP); pm_close(ofP); strfree(outputFileName); pnm_nextimage(ifP, &eof); } pm_close(ifP); return 0; }