- int vecp, n = 1;
- char *cp, buf[BUFSIZ], **argp;
- char **arguments, *vec[MAXARGS];
- struct stat st;
-
-#ifndef lint
- int distsw = 0;
-#endif
-
- /*
- ** Make sure these are defined. In particular, we need
- ** vec[1] to be NULL, in case "arg" is NULL below. It
- ** doesn't matter what is the value of vec[0], but we
- ** set it to NULL, to help catch "off-by-one" errors.
- */
- vec[0] = NULL;
- vec[1] = NULL;
-
- /*
- ** Temporarily copy arg to vec, since the brkstring() call in
- ** getarguments() will wipe it out before it is merged in.
- ** Also, we skip the first element of vec, since getarguments()
- ** skips it. Then we count the number of arguments
- ** copied. The value of "n" will be one greater than
- ** this in order to simulate the standard argc/argv.
- */
- if (arg) {
- char **bp;
-
- copyip(arg, vec+1, MAXARGS-1);
- bp = vec+1;
- while (*bp++)
- n++;
- }
-
- /*
- ** Merge any arguments from command line (now in vec)
- ** and arguments from profile.
- */
- arguments = getarguments(sp, n, vec, 1);
- argp = arguments;
-
- debugsw = 0;
- forwsw = 1;
- inplace = 1;
-
- altmsg = NULL;
- annotext = NULL;
- distfile = NULL;
-
- vecp = 1; /* we'll get the zero'th element later */
- vec[vecp++] = "-library";
- vec[vecp++] = getcpy(toabsdir("+"));
-
- while ((cp = *argp++)) {
- if (*cp == '-') {
- switch (smatch(++cp, sendswitches)) {
- case AMBIGSW:
- ambigsw(cp, sendswitches);
- return;
- case UNKWNSW:
- advise(NULL, "-%s unknown\n", cp);
- return;
-
- case SHELPSW:
- snprintf(buf, sizeof(buf),
- "%s [switches]", sp);
- print_help(buf, sendswitches, 1);
- return;
- case SVERSIONSW:
- print_version(invo_name);
- return;
-
- case SPSHSW:
- pushed++;
- continue;
- case NSPSHSW:
- pushed = 0;
- continue;