|
|
researchv10 Norman
#include <stdio.h>
char *strchr();
main(argc, argv)
int argc;
char **argv;
{
extern int optind;
extern char *optarg;
register int c;
int errflg = 0;
char tmpstr[4];
char outstr[5120];
char *goarg;
if(argc < 2) {
fputs("usage: getopt legal-args $*\n", stderr);
exit(2);
}
goarg = argv[1];
argv[1] = argv[0];
argv++;
argc--;
while((c=getopt(argc, argv, goarg)) != EOF) {
if(c=='?') {
errflg++;
continue;
}
tmpstr[0] = '-';
tmpstr[1] = c;
tmpstr[2] = ' ';
tmpstr[3] = '\0';
strcat(outstr, tmpstr);
if(*(strchr(goarg, c)+1) == ':') {
strcat(outstr, optarg);
strcat(outstr, " ");
}
}
if(errflg) {
exit(2);
}
strcat(outstr, "-- ");
while(optind < argc) {
strcat(outstr, argv[optind++]);
strcat(outstr, " ");
}
printf("%s\n", outstr);
exit(0);
}
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.