Example #1
0
int
main(int argc, const char * argv[]) {

    struct cmdlineInfo cmdline;
    FILE * ifP;
    struct script * scriptP;
    int eof;

    pm_proginit(&argc, argv);

    parseCommandLine(argc, argv, &cmdline);

    verbose = cmdline.verbose;

    ifP = pm_openr(cmdline.inputFilename);

    getScript(cmdline, &scriptP);

    eof = FALSE;
    while (!eof) {
        doOneImage(ifP, scriptP);
        ppm_nextimage(ifP, &eof);
    }

    freeScript(scriptP);

    pm_close(ifP);

    /* If the program failed, it previously aborted with nonzero completion
       code, via various function calls.
    */
    return 0;
}
Example #2
0
static void
describeOneFile(const char * const name,
                FILE *       const fileP,
                bool         const allimages,
                bool         const justCount,
                bool         const wantComments) {
/*----------------------------------------------------------------------------
   Describe one image stream (file).  Its name, for purposes of display,
   is 'name'.  The file is open as *fileP and positioned to the beginning.

   'allimages' means report on every image in the stream and read all of
   every image from it, as opposed to reading just the header of the first
   image and reporting just on that.

   'justCount' means don't tell anything about the stream except how
   many images are in it.  Pretty useless without 'allimages'.

   'wantComments' means to show the comments from the image header.
   Meaningless with 'justCount'.
-----------------------------------------------------------------------------*/
    unsigned int imageDoneCount;
        /* Number of images we've processed so far */
    bool eof;
    
    eof = FALSE;
    imageDoneCount = 0;

    while (!eof && (imageDoneCount < 1 || allimages)) {
        doOneImage(name, imageDoneCount, fileP,
                   allimages, justCount, wantComments,
                   &eof);
        ++imageDoneCount;
    }
    if (justCount)
        printf("%s:\t%u images\n", name, imageDoneCount);
}