Lines Matching +full:1 +full:ac
96 * Returns 0 if successful, 1 if empty command, errx() in case of errors.
108 int ch, ac;
118 return 1; /* need at least one argument */
126 char *arg = oldav[1]; /* The string is the first arg. */
128 int copy = 0; /* 1 if we need to copy, 0 otherwise */
148 return 1;
152 * processing, this is just the number of blanks plus 1.
154 for (i = 0, ac = 1; i < l; i++)
156 ac++;
165 ac++; /* add 1 for the program name */
166 av_size = (ac+1) * sizeof(char *) + l + 1;
167 av = safe_calloc(av_size, 1);
174 av_p = (char *)&av[ac+1];
175 for (ac = 1, i = j = 0; i < l; i++) {
176 if (strchr(WHITESP, arg[i]) != NULL || i == l-1) {
177 if (i == l-1)
180 av[ac] = av_p;
183 ac++;
184 j = i + 1;
204 av_size = (oldac+1) * sizeof(char *) + l + oldac;
205 av = safe_calloc(av_size, 1);
211 av_p = (char *)&av[oldac+1];
212 for (first = i = ac = 1, l = 0; i < oldac; i++) {
217 if (arg[k-1] != ',' || i == oldac-1) {
219 av[ac] = av_p;
225 ac++;
227 first = i+1;
237 av[ac] = NULL;
244 if (is_ipfw() && ac >= 2 &&
245 !strcmp(av[1], "sysctl")) {
249 if (ac != 3) {
261 if (s[1] == '\0') {
266 i = strtol(s+1, NULL, 0);
276 optind = optreset = 1; /* restart getopt() */
278 while ((ch = getopt(ac, av, "abcdDefhinNp:qs:STtvx")) != -1)
281 do_acct = 1;
285 g_co.comment_only = 1;
286 g_co.do_compact = 1;
290 g_co.do_compact = 1;
294 g_co.do_dynamic = 1;
306 g_co.do_force = 1;
315 g_co.do_value_as_ip = 1;
319 g_co.test_only = 1;
323 g_co.do_resolv = 1;
332 g_co.do_quiet = 1;
340 g_co.show_sets = 1;
352 g_co.verbose = 1;
356 g_co.debug_only = 1;
361 return 1;
364 while ((ch = getopt(ac, av, "hns:v")) != -1)
373 g_co.test_only = 1;
381 g_co.verbose = 1;
386 return 1;
391 ac -= optind;
400 if (ac > 1 && isdigit(*av[0])) {
403 av[0] = av[1];
404 av[1] = p;
414 g_co.do_nat = 1;
416 g_co.do_pipe = 1;
424 if (ac > 1 && isdigit(av[1][0])) {
425 g_co.use_set = strtonum(av[1], 0, resvd_set_number,
429 "invalid set number %s\n", av[1]);
430 ac -= 2; av += 2; g_co.use_set++;
435 ac--;
445 if ((g_co.do_pipe || g_co.do_nat) && ac > 1 && isdigit(*av[0])) {
448 av[0] = av[1];
449 av[1] = p;
460 ipfw_show_nat(ac, av);
462 ipfw_config_pipe(ac, av);
464 ipfw_config_nat(ac, av);
468 ipfw_table_handler(ac, av);
470 ipfw_sysctl_handler(av, 1);
474 try_next = 1;
481 ipfw_nat64clat_handler(ac, av);
483 ipfw_nat64stl_handler(ac, av);
485 ipfw_nat64lsn_handler(ac, av);
487 ipfw_nptv6_handler(ac, av);
491 ipfw_zero(ac, av, 0 /* IP_FW_ZERO */);
493 ipfw_zero(ac, av, 1 /* IP_FW_RESETLOG */);
496 ipfw_list(ac, av, do_acct);
498 ipfw_list(ac, av, 1 /* show counters */);
500 ipfw_table_handler(ac, av);
502 ipfw_internal_handler(ac, av);
514 ipfw_readfile(int ac, char *av[])
520 const char *filename = av[ac-1]; /* file to read */
526 while ((c = getopt(ac, av, "cfNnp:qS")) != -1) {
529 g_co.do_compact = 1;
533 g_co.do_force = 1;
537 g_co.do_resolv = 1;
541 g_co.test_only = 1;
552 * - advance av by optind-1 to skip arguments
554 * - decrease ac by optind, to remove the args
558 * - set optind=ac to let getopt() terminate.
560 if (optind == ac)
563 av[ac-1] = NULL;
564 av += optind - 1;
565 ac -= optind;
566 optind = ac;
570 g_co.do_quiet = 1;
574 g_co.show_sets = 1;
583 while ((c = getopt(ac, av, "nq")) != -1) {
586 g_co.test_only = 1;
590 g_co.do_quiet = 1;
600 if (cmd == NULL && ac != optind + 1)
601 errx(EX_USAGE, "extraneous filename arguments %s", av[ac-1]);
609 if (pipe(pipedes) == -1)
613 if (preproc == -1)
621 if (dup2(fileno(f), 0) == -1
622 || dup2(pipedes[1], 1) == -1)
625 close(pipedes[1]);
631 close(pipedes[1]);
650 args[1] = buf;
657 if (waitpid(preproc, &status, 0) == -1)
671 main(int ac, char *av[])
683 return 1;
698 if (ac > 1 && av[ac - 1][0] == '/') {
699 if (access(av[ac - 1], R_OK) == 0)
700 ipfw_readfile(ac, av);
702 err(EX_USAGE, "pathname: %s", av[ac - 1]);
704 if (ipfw_main(ac, av)) {