int chattr_main(int argc UNUSED_PARAM, char **argv) { struct globals g; char *arg; memset(&g, 0, sizeof(g)); /* parse the args */ while ((arg = *++argv)) { /* take care of -R and -v <version> */ if (arg[0] == '-' && (arg[1] == 'R' || arg[1] == 'v') && !arg[2] ) { if (arg[1] == 'R') { g.recursive = 1; continue; } /* arg[1] == 'v' */ if (!*++argv) bb_show_usage(); g.version = xatoul(*argv); g.flags |= OPT_SET_VER; continue; } if (!decode_arg(arg, &g)) break; } /* run sanity checks on all the arguments given us */ if (!*argv) bb_show_usage(); if ((g.flags & OPT_SET) && (g.flags & (OPT_ADD|OPT_REM))) bb_error_msg_and_die("= is incompatible with - and +"); if (g.rf & g.af) bb_error_msg_and_die("can't set and unset a flag"); if (!g.flags) bb_error_msg_and_die("must use '-v', =, - or +"); /* now run chattr on all the files passed to us */ do change_attributes(*argv, &g); while (*++argv); return EXIT_SUCCESS; }
int main (int argc, char ** argv) { int i, j; int end_arg = 0; #ifdef ENABLE_NLS setlocale(LC_MESSAGES, ""); bindtextdomain(NLS_CAT_NAME, LOCALEDIR); textdomain(NLS_CAT_NAME); #endif if (argc && *argv) program_name = *argv; i = 1; while (i < argc && !end_arg) { if (decode_arg (&i, argc, argv) == EOF) end_arg = 1; else i++; } if (i >= argc) usage (); if (set && (add || rem)) { fprintf (stderr, _("= is incompatible with - and +\n")); exit (1); } if ((rf & af) != 0) { fprintf (stderr, "Can't both set and unset same flag.\n"); exit (1); } if (!(add || rem || set || set_version)) { fprintf (stderr, _("Must use '-v', =, - or +\n")); exit (1); } if (verbose) fprintf (stderr, "chattr %s (%s)\n", E2FSPROGS_VERSION, E2FSPROGS_DATE); for (j = i; j < argc; j++) change_attributes (argv[j]); exit(0); }
static void canonicalize_values(struct thread *thread, obj_t *old_sp, obj_t *vals) { int supplied = thread->sp - vals; int wants = decode_arg(thread); int fixed; bool restp; int i; fixed = wants >> 1; restp = wants & 1; if (supplied <= fixed) { if (old_sp != vals) for (i = 0; i < supplied; i++) *old_sp++ = *vals++; else { i = supplied; old_sp += supplied; } while (i < fixed) { *old_sp++ = obj_False; i++; } if (restp) *old_sp++ = make_vector(0, NULL); } else { if (old_sp != vals) for (i = 0; i < fixed; i++) *old_sp++ = *vals++; else vals += fixed; if (restp) *old_sp++ = make_vector(supplied - fixed, vals); } thread->sp = old_sp; }
static void op_pop_value(int byte, struct thread *thread) { pop_value(thread, decode_arg(thread)); }
static void op_push_function(int byte, struct thread *thread) { push_function(thread, decode_arg(thread)); }
static void op_call(int byte, struct thread *thread) { int nargs = decode_arg(thread); thread->pc++; invoke(thread, nargs); }
static void op_call_tail(int byte, struct thread *thread) { call_tail(thread, decode_arg(thread)); }
static void op_pop_local(int byte, struct thread *thread) { pop_local(thread, decode_arg(thread)); }
static void op_push_constant(int byte, struct thread *thread) { push_constant(thread, decode_arg(thread)); }