Listing 9

Text File:

    TOOBIG  Value cannot be larger then %d
    BADNAME The name %s is not defined
    PUNT    Unknown error, aborting

Sample output of special program:

    header1:
           enum errkind { TOOBIG, BADNAME, PUNT };
    header2:
           char *errstring[] = {
                  "Value cannot be larger then %d",
                  "The name %s is not defined",
                  "Unknown error, aborting",
                  };

Sample Usage:

                         /* ANSI prototype */
    extern void error(enum errkind, char*);
    error(TOOBIG, (char*)MAX);
    error(BADNAME, str);
    error(PUNT, 0); /* the 0 is ignored in this case */

The error() function is a small printf-like function
which is very easy to write.