|
|
DataMuseum.dkPresents historical artifacts from the history of: DKUUG/EUUG Conference tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about DKUUG/EUUG Conference tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: E T
Length: 2249 (0x8c9)
Types: TextFile
Names: »EXAMPLE«
└─⟦a0efdde77⟧ Bits:30001252 EUUGD11 Tape, 1987 Spring Conference Helsinki
└─⟦this⟧ »EUUGD11/euug-87hel/sec1/mkprog/EXAMPLE«
The following program was generated by
mkprog -h -n junk -o 'ab$c#'
Comments were added manually to explain some of the design decisions in
mkprog.
This is junk.h:
#include <stdio.h>
#include <ctype.h> /* I use ctype so often I prefer to always include it */
typedef enum {false=0, true=1} bool;
char *progname; /* for error messages */
bool a_flag; /* bools, then */
int c_val; /* ints, and finally */
char *b_string; /* char pointers */
This is junk.c:
#include "junk.h"
main(argc, argv)
int argc;
char *argv[];
{
extern int optind; /* for getopt(3) */
extern int opterr;
extern char *optarg;
int c; /* for switch */
int i; /* for looping aver file names */
bool used_stdin = false; /* so as not to use stdin twice */
FILE *fp, *efopen();
opterr = 1; /* for getopt again, might well be 0 */
progname = argv[0];
c_val = 0; /* initialize explicitly so that you will */
b_string = (char *) 0; /* know where to put default vaules */
while ((c = getopt(argc, argv, "ac:b:")) != EOF)
switch(c) {
case 'a':
a_flag = true;
break;
case 'c':
c_val = atoi(optarg);
break;
case 'b':
b_string = optarg;
break;
case '?':
usage();
break;
}
argc -= optind; /* reset argc and argv after dealing with */
argv += optind; /* options */
for (i = 0; i < argc; i++) { /* loop over files names checking */
/* access first */
if (strcmp(argv[i], "-") == 0) {
if (used_stdin) {
fprintf(stderr, "standard input used twice\n");
exit(1);
}
else {
used_stdin = true;
}
}
#ifdef unix
else if (access(argv[i], 4) == -1) { /* check access */
fprintf(stderr, "%s: cannot access %s: ", progname, argv[i]);
perror("");
exit(1);
}
#endif unix
}
fp = stdin;
i = 0;
do { /* now loop over file names doing program */
if (argc > 0)
fp = efopen(argv[i], "r"); /* efopen will exit */
/* on failure */
do_junk(fp); /* this does the real work */
(void) fclose(fp); /* remember to close files! */
} while (++i < argc);
exit(0);
}
usage()
{
fprintf(stderr, "Usage: %s [ -a ] [ -c c_val ] [ -b b_string ] [ file ... ]\n", progname);
exit(1);
}