void parse_force(const char *value, bool set) { const char *comma; size_t l; const struct forceinfo *fip; if (strcmp(value, "help") == 0) { printf(_( "%s forcing options - control behaviour when problems found:\n" " warn but continue: --force-<thing>,<thing>,...\n" " stop with error: --refuse-<thing>,<thing>,... | --no-force-<thing>,...\n" " Forcing things:\n"), dpkg_get_progname()); for (fip = forceinfos; fip->name; fip++) if ((enum force_flags)fip->flag == FORCE_ALL || (fip->flag & force_mask) == fip->flag) print_forceinfo(fip); printf(_( "\n" "WARNING - use of options marked [!] can seriously damage your installation.\n" "Forcing options marked [*] are enabled by default.\n")); m_output(stdout, _("<standard output>")); printf(_( "\n" "Currently enabled options:\n" " %s\n"), get_force_string()); exit(0); } for (;;) { comma = strchrnul(value, ','); l = (size_t)(comma - value); for (fip = forceinfos; fip->name; fip++) if (strncmp(fip->name, value, l) == 0 && strlen(fip->name) == l) break; if (!fip->name) { badusage(_("unknown force/refuse option '%.*s'"), (int)min(l, 250), value); } else if (fip->flag) { if (set) set_force(fip->flag); else reset_force(fip->flag); } else { warning(_("obsolete force/refuse option '%s'"), fip->name); } if (*comma == '\0') break; value = ++comma; } }
static void set_force(const struct cmdinfo *cip, const char *value) { const char *comma; size_t l; const struct forceinfo *fip; if (strcmp(value, "help") == 0) { printf(_( "%s forcing options - control behaviour when problems found:\n" " warn but continue: --force-<thing>,<thing>,...\n" " stop with error: --refuse-<thing>,<thing>,... | --no-force-<thing>,...\n" " Forcing things:\n"), DPKG); for (fip = forceinfos; fip->name; fip++) print_forceinfo(fip); printf(_( "\n" "WARNING - use of options marked [!] can seriously damage your installation.\n" "Forcing options marked [*] are enabled by default.\n")); m_output(stdout, _("<standard output>")); exit(0); } for (;;) { comma= strchr(value,','); l = comma ? (size_t)(comma - value) : strlen(value); for (fip=forceinfos; fip->name; fip++) if (strncmp(fip->name, value, l) == 0 && strlen(fip->name) == l) break; if (!fip->name) { badusage(_("unknown force/refuse option '%.*s'"), (int)min(l, 250), value); } else if (strcmp(fip->name, "all") == 0) { for (fip = forceinfos; fip->name; fip++) if (fip->opt) *fip->opt = cip->arg_int; } else if (fip->opt) { *fip->opt = cip->arg_int; } else { warning(_("obsolete force/refuse option '%s'"), fip->name); } if (!comma) break; value= ++comma; } }