static void parse_args(int argc, char **argv, void (**test_func)(Display*, GLXDrawable)) { int i; /* Count of parsed args, excluding -auto. */ int num_parsed_args = 0; for (i = 1; i < argc; ++i) { const char *arg = argv[i]; if (!strncmp(arg, "-auto", 5)) { piglit_automatic = 1; } else if (!strncmp(arg, "--bad-drawable", 14)) { ++num_parsed_args; *test_func = query_bad_drawable; } else if (!strncmp(arg, "--attr=GLX_WIDTH", 16)) { ++num_parsed_args; *test_func = query_width; } else if (!strncmp(arg, "--attr=GLX_HEIGHT", 17)) { ++num_parsed_args; *test_func = query_height; } else { /* Unrecognized argument. */ usage_error(); } } if (num_parsed_args != 1) { usage_error(); } }
/* ------------------------------------------------------------------------ @NAME : bt_set_stringopts @INPUT : metatype options @OUTPUT : @RETURNS : @DESCRIPTION: Sets the string-processing options for a particular entry metatype. Used later on by bt_parse_* to determine just how to post-process each particular entry. @GLOBALS : StringOptions @CREATED : 1997/08/24, GPW @MODIFIED : -------------------------------------------------------------------------- */ void bt_set_stringopts (bt_metatype metatype, ushort options) { if (metatype < BTE_REGULAR || metatype > BTE_MACRODEF) usage_error ("bt_set_stringopts: illegal metatype"); if (options & ~BTO_STRINGMASK) usage_error ("bt_set_stringopts: illegal options " "(must only set string option bits"); StringOptions[metatype] = options; }
gboolean flatpak_builtin_document_unexport (int argc, char **argv, GCancellable *cancellable, GError **error) { g_autoptr(GOptionContext) context = NULL; g_autoptr(GDBusConnection) session_bus = NULL; XdpDbusDocuments *documents; const char *file; g_autofree char *doc_id = NULL; context = g_option_context_new (_("FILE - Unexport a file to apps")); g_option_context_set_translation_domain (context, GETTEXT_PACKAGE); if (!flatpak_option_context_parse (context, options, &argc, &argv, FLATPAK_BUILTIN_FLAG_NO_DIR, NULL, cancellable, error)) return FALSE; if (argc < 2) return usage_error (context, _("FILE must be specified"), error); if (argc > 2) return usage_error (context, _("Too many arguments"), error); file = argv[1]; session_bus = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, error); if (session_bus == NULL) return FALSE; documents = xdp_dbus_documents_proxy_new_sync (session_bus, 0, "org.freedesktop.portal.Documents", "/org/freedesktop/portal/documents", NULL, error); if (documents == NULL) return FALSE; if (!xdp_dbus_documents_call_lookup_sync (documents, file, &doc_id, NULL, error)) return FALSE; if (strcmp (doc_id, "") == 0) { g_print (_("Not exported\n")); return TRUE; } if (!xdp_dbus_documents_call_delete_sync (documents, doc_id, NULL, error)) return FALSE; return TRUE; }
void impl::app::process_options(void) { assert(inited()); std::string optstr; #if defined(HAVE_GNU_GETOPT) optstr += '+'; // Turn on POSIX behavior. #endif optstr += ':'; { options_set opts = options(); for (options_set::const_iterator iter = opts.begin(); iter != opts.end(); iter++) { const option& opt = (*iter); optstr += opt.m_character; if (!opt.m_argument.empty()) optstr += ':'; } } int ch; const int old_opterr = ::opterr; ::opterr = 0; while ((ch = ::getopt(m_argc, m_argv, optstr.c_str())) != -1) { switch (ch) { case 'h': m_hflag = true; break; case ':': throw usage_error("Option -%c requires an argument.", ::optopt); case '?': throw usage_error("Unknown option -%c.", ::optopt); default: process_option(ch, ::optarg); } } m_argc -= ::optind; m_argv += ::optind; // Clear getopt state just in case the test wants to use it. opterr = old_opterr; optind = 1; #if defined(HAVE_OPTRESET) optreset = 1; #endif }
gboolean xdg_app_builtin_build_export (int argc, char **argv, GCancellable *cancellable, GError **error) { gboolean ret = FALSE; g_autoptr(GOptionContext) context = NULL; g_autoptr(GFile) base = NULL; g_autoptr(GFile) files = NULL; g_autoptr(GFile) metadata = NULL; g_autoptr(GFile) export = NULL; g_autoptr(GFile) repofile = NULL; g_autoptr(GFile) arg = NULL; g_autoptr(GFile) root = NULL; g_autoptr(OstreeRepo) repo = NULL; const char *location; const char *directory; const char *branch; g_autofree char *arch = NULL; g_autofree char *full_branch = NULL; g_autofree char *app_id = NULL; g_autofree char *parent = NULL; g_autofree char *commit_checksum = NULL; g_autofree char *metadata_contents = NULL; g_autofree char *format_size = NULL; g_autoptr(OstreeMutableTree) mtree = NULL; g_autoptr(GKeyFile) metakey = NULL; gsize metadata_size; g_autofree char *subject = NULL; g_autofree char *body = NULL; OstreeRepoTransactionStats stats; OstreeRepoCommitModifier *modifier = NULL; context = g_option_context_new ("LOCATION DIRECTORY [BRANCH] - Create a repository from a build directory"); if (!xdg_app_option_context_parse (context, options, &argc, &argv, XDG_APP_BUILTIN_FLAG_NO_DIR, NULL, cancellable, error)) goto out; if (argc < 3) { usage_error (context, "LOCATION and DIRECTORY must be specified", error); goto out; } location = argv[1]; directory = argv[2]; if (argc >= 4) branch = argv[3]; else branch = "master"; if (!xdg_app_is_valid_branch (branch)) { xdg_app_fail (error, "'%s' is not a valid branch name", branch); goto out; } base = g_file_new_for_commandline_arg (directory); files = g_file_get_child (base, "files"); metadata = g_file_get_child (base, "metadata"); export = g_file_get_child (base, "export");
gboolean flatpak_builtin_document_list (int argc, char **argv, GCancellable *cancellable, GError **error) { g_autoptr(GOptionContext) context = NULL; const char *app_id = NULL; g_autofree char *col_help = NULL; g_autofree Column *columns = NULL; context = g_option_context_new (_("[APPID] - List exported files")); g_option_context_set_translation_domain (context, GETTEXT_PACKAGE); col_help = column_help (all_columns); g_option_context_set_description (context, col_help); if (!flatpak_option_context_parse (context, options, &argc, &argv, FLATPAK_BUILTIN_FLAG_NO_DIR, NULL, cancellable, error)) return FALSE; if (argc > 2) return usage_error (context, _("Too many arguments"), error); if (argc == 2) app_id = argv[1]; columns = handle_column_args (all_columns, FALSE, opt_cols, error); if (columns == NULL) return FALSE; return print_documents (app_id, columns, cancellable, error); }
gboolean flatpak_builtin_ps (int argc, char **argv, GCancellable *cancellable, GError **error) { g_autoptr(GOptionContext) context = NULL; g_autofree char *col_help = NULL; g_autofree Column *columns = NULL; context = g_option_context_new (_(" - Enumerate running sandboxes")); g_option_context_set_translation_domain (context, GETTEXT_PACKAGE); col_help = column_help (all_columns); g_option_context_set_description (context, col_help); if (!flatpak_option_context_parse (context, options, &argc, &argv, FLATPAK_BUILTIN_FLAG_NO_DIR, NULL, cancellable, error)) return FALSE; if (argc > 1) { usage_error (context, _("Extra arguments given"), error); return FALSE; } columns = handle_column_args (all_columns, FALSE, opt_cols, error); if (columns == NULL) return FALSE; return enumerate_instances (columns, error); }
gboolean flatpak_builtin_delete_remote (int argc, char **argv, GCancellable *cancellable, GError **error) { g_autoptr(GOptionContext) context = NULL; g_autoptr(FlatpakDir) dir = NULL; const char *remote_name; context = g_option_context_new ("NAME - Delete a remote repository"); g_option_context_add_main_entries (context, delete_options, NULL); if (!flatpak_option_context_parse (context, NULL, &argc, &argv, 0, &dir, cancellable, error)) return FALSE; if (argc < 2) return usage_error (context, "NAME must be specified", error); remote_name = argv[1]; if (!flatpak_dir_remove_remote (dir, opt_force, remote_name, cancellable, error)) return FALSE; return TRUE; }
void symex_parse_optionst::get_command_line_options(optionst &options) { if(config.set(cmdline)) { usage_error(); exit(1); } if(cmdline.isset("debug-level")) options.set_option("debug-level", cmdline.get_value("debug-level")); if(cmdline.isset("unwindset")) options.set_option("unwindset", cmdline.get_value("unwindset")); // all checks supported by goto_check GOTO_CHECK_PARSE_OPTIONS(cmdline, options); // check assertions if(cmdline.isset("no-assertions")) options.set_option("assertions", false); else options.set_option("assertions", true); // use assumptions if(cmdline.isset("no-assumptions")) options.set_option("assumptions", false); else options.set_option("assumptions", true); // magic error label if(cmdline.isset("error-label")) options.set_option("error-label", cmdline.get_values("error-label")); }
static atf_error_t handle_tcarg(const char *tcarg, char **tcname, enum tc_part *tcpart) { atf_error_t err; err = atf_no_error(); *tcname = strdup(tcarg); if (*tcname == NULL) { err = atf_no_memory_error(); goto out; } char *delim = strchr(*tcname, ':'); if (delim != NULL) { *delim = '\0'; delim++; if (strcmp(delim, "body") == 0) { *tcpart = BODY; } else if (strcmp(delim, "cleanup") == 0) { *tcpart = CLEANUP; } else { err = usage_error("Invalid test case part `%s'", delim); goto out; } } out: return err; }
static void output_property(bool* first, char sep, const char* format, const char* name, const char* value) { if (*first) *first = false; else xputc(sep, xstdout); char c; bool escaped = false; while ((c = *format++)) { if (escaped) { if (c == '%') { xputc('%', xstdout); } else if (c == 'n') { xputs(name, xstdout); } else if (c == 'v' && value) { xputs(value, xstdout); } else { usage_error("incorrect format string \"%s\"", format-2); } escaped = false; } else { if (c == '%') { escaped = true; } else { xputc(c, xstdout); } } } }
static void parse_args(int *argc, char **argv, const char ***selected_subtests, size_t *num_selected_subtests) { *selected_subtests = NULL; *num_selected_subtests = 0; prog_name = basename(argv[0]); if (*argc == 1) { return; } if (streq(argv[1], "-h") || streq(argv[1], "--help")) { print_usage(); exit(0); } /* Strip common piglit args. */ piglit_strip_arg(argc, argv, "-fbo"); piglit_strip_arg(argc, argv, "-auto"); piglit_parse_subtest_args(argc, argv, subtests, selected_subtests, num_selected_subtests); if (*argc > 1) { piglit_loge("unrecognized option: %s", argv[1]); usage_error(); } }
gboolean install_bundle (FlatpakDir *dir, GOptionContext *context, int argc, char **argv, GCancellable *cancellable, GError **error) { g_autoptr(GFile) file = NULL; const char *filename; g_autoptr(GBytes) gpg_data = NULL; if (argc < 2) return usage_error (context, "bundle filename must be specified", error); filename = argv[1]; file = g_file_new_for_commandline_arg (filename); if (opt_gpg_file != NULL) { /* Override gpg_data from file */ gpg_data = read_gpg_data (cancellable, error); if (gpg_data == NULL) return FALSE; } if (!flatpak_dir_install_bundle (dir, file, gpg_data, NULL, cancellable, error)) return FALSE; return TRUE; }
bool finalize(char *hdrs, sendip_data *headers[], sendip_data *data, sendip_data *pack) { if(hdrs[strlen(hdrs)-1] != 'u') { usage_error("Warning: RIPng should be contained in a UDP packet\n"); } return TRUE; }
int main (int argc, char* argv[]) { unsigned gpio; if (argc < 3) { usage_error(); exit(EXIT_FAILURE); } }
static atf_error_t run_tc(const atf_tp_t *tp, struct params *p, int *exitcode) { atf_error_t err; err = atf_no_error(); if (!atf_tp_has_tc(tp, p->m_tcname)) { err = usage_error("Unknown test case `%s'", p->m_tcname); goto out; } if (!atf_env_has("__RUNNING_INSIDE_ATF_RUN") || strcmp(atf_env_get( "__RUNNING_INSIDE_ATF_RUN"), "internal-yes-value") != 0) { print_warning("Running test cases outside of kyua(1) is unsupported"); print_warning("No isolation nor timeout control is being applied; you " "may get unexpected failures; see atf-test-case(4)"); } switch (p->m_tcpart) { case BODY: err = atf_tp_run(tp, p->m_tcname, atf_fs_path_cstring(&p->m_resfile)); if (atf_is_error(err)) { /* TODO: Handle error */ *exitcode = EXIT_FAILURE; atf_error_free(err); } else { *exitcode = EXIT_SUCCESS; } break; case CLEANUP: err = atf_tp_cleanup(tp, p->m_tcname); if (atf_is_error(err)) { /* TODO: Handle error */ *exitcode = EXIT_FAILURE; atf_error_free(err); } else { *exitcode = EXIT_SUCCESS; } break; default: UNREACHABLE; } INV(!atf_is_error(err)); out: return err; }
int main(int argc, char **argv) { GLenum internal_format = 0; EGLDisplay dpy; EGLContext ctx; bool ok; /* Strip common piglit args. */ piglit_strip_arg(&argc, argv, "-fbo"); piglit_strip_arg(&argc, argv, "-auto"); if (argc == 2) { if (streq(argv[1], "GL_RGBA")) { internal_format = GL_RGBA; } else if (streq(argv[1], "GL_DEPTH_COMPONENT24")) { internal_format = GL_DEPTH_COMPONENT24; } } if (internal_format == 0) usage_error(); dpy = create_display(); ctx = create_context(dpy); ok = eglMakeCurrent(dpy, EGL_NO_SURFACE, EGL_NO_SURFACE, ctx); if (!ok) { piglit_loge("failed to make context current without surface"); piglit_report_result(PIGLIT_FAIL); } piglit_dispatch_default_init(PIGLIT_DISPATCH_ES2); if (!piglit_is_extension_supported("GL_OES_EGL_image")) { piglit_loge("context does not support GL_OES_EGL_image"); piglit_report_result(PIGLIT_SKIP); } switch (internal_format) { case GL_RGBA: test_rgba(dpy, ctx); break; case GL_DEPTH_COMPONENT24: test_depth24(dpy, ctx); break; default: break; } /* unreachable */ abort(); }
/* ------------------------------------------------------------------------ @NAME : bt_postprocess_field() @INPUT : @OUTPUT : @RETURNS : @DESCRIPTION: Postprocesses all the strings in a single "field = value" assignment subtree. Just checks that 'field' does indeed point to an BTAST_FIELD node (presumably the parent of a list of simple values), downcases the field name, and calls bt_postprocess_value() on the value. @GLOBALS : @CALLS : @CALLERS : @CREATED : 1997/08/25, GPW @MODIFIED : -------------------------------------------------------------------------- */ char * bt_postprocess_field (AST * field, btshort options, boolean replace) { if (field == NULL) return NULL; if (field->nodetype != BTAST_FIELD) usage_error ("bt_postprocess_field: invalid AST node (not a field)"); strlwr (field->text); /* downcase field name */ return bt_postprocess_value (field->down, options, replace); } /* bt_postprocess_field() */
int main(int argc, char *argv[]) { char* endptr; sysop = _sysop; syserrm = _syserrm; syserrc = _syserrc; check_plugin = _check_plugin; #if ENABLE_SEM do_inter_lock_init = _do_inter_lock_init; do_inter_lock_reset = _do_inter_lock_reset; do_inter_lock = _do_inter_lock; do_inter_unlock = _do_inter_unlock; #endif /*------------------------ get host name */ if (gethostname((char*)hostname,255) == -1) dm_error(errno, "gethostname"); /*------------------------ parse arguments */ if (argc != 2) usage_error(0); switch (serverport = strtol(argv[1], &endptr, 0)) { case LONG_MAX: case LONG_MIN: if (errno) usage_error(errno); } if (! *(argv[1]) || *endptr) usage_error(errno); serverport += getportoffset(); initfds(); /*------------- make server socket and listen on it ----------------- Note: all communication errors that can only be due to faulty code (rather than an external condition) are reported through 'error' and thus lead to termination of this process. */ run_dnode_mill(); }
/* ------------------------------------------------------------------------ @NAME : bt_parse_entry_s() @INPUT : entry_text - string containing the entire entry to parse, or NULL meaning we're done, please cleanup options - standard btparse options bitmap line - current line number (if that makes any sense) -- passed to the parser to set zzline, so that lexical and syntax errors are properly localized @OUTPUT : *top - newly-allocated AST for the entry (or NULL if entry_text was NULL, ie. at EOF) @RETURNS : 1 with *top set to AST for entry on successful read/parse 1 with *top==NULL if entry_text was NULL, ie. at EOF 0 if any serious errors seen in input (*top is still set to the AST, but only for as much of the input as we were able to parse) (A "serious" error is a lexical or syntax error; "trivial" errors such as warnings and notifications count as "success" for the purposes of this function's return value.) @DESCRIPTION: Parses a BibTeX entry contained in a string. @GLOBALS : @CALLS : ANTLR @CREATED : 1997/01/18, GPW (from code in bt_parse_entry()) @MODIFIED : -------------------------------------------------------------------------- */ AST * bt_parse_entry_s (char * entry_text, char * filename, int line, ushort options, boolean * status) { AST * entry_ast = NULL; static int * err_counts = NULL; if (options & BTO_STRINGMASK) /* any string options set? */ { usage_error ("bt_parse_entry_s: illegal options " "(string options not allowed"); } InputFilename = filename; err_counts = bt_get_error_counts (err_counts); if (entry_text == NULL) /* signal to clean up */ { finish_parse (&err_counts); if (status) *status = TRUE; return NULL; } zzast_sp = ZZAST_STACKSIZE; /* workaround apparent pccts bug */ start_parse (NULL, entry_text, line); entry (&entry_ast); /* enter the parser */ ++zzasp; /* why is this done? */ if (entry_ast == NULL) /* can happen with very bad input */ { if (status) *status = FALSE; return entry_ast; } #if DEBUG dump_ast ("bt_parse_entry_s: single entry, after parsing:\n", entry_ast); #endif bt_postprocess_entry (entry_ast, StringOptions[entry_ast->metatype] | options); #if DEBUG dump_ast ("bt_parse_entry_s: single entry, after post-processing:\n", entry_ast); #endif if (status) *status = parse_status (err_counts); return entry_ast; } /* bt_parse_entry_s () */
/* ------------------------------------------------------------------------ @NAME : bt_entry_set_key () @INPUT : entry new_key @OUTPUT : entry->down->text @RETURNS : @DESCRIPTION: Changes the key of a regular entry to 'new_key'. If 'entry' is not a regular entry, or if it doesn't already have a child node holding an entry key, bombs via 'usage_error()'. Otherwise a duplicate of 'new_key' is copied into the entry AST (so the caller can free that string without worry). @CALLS : bt_set_text () @CREATED : 1999/11/25, GPW (from Stephane Genaud) @MODIFIED : -------------------------------------------------------------------------- */ void bt_entry_set_key (AST * entry, char * new_key) { if (entry->metatype == BTE_REGULAR && entry->down && entry->down->nodetype == BTAST_KEY) { bt_set_text (entry->down, new_key); } else { usage_error ("can't set entry key -- not a regular entry, " "or doesn't have a key already"); } }
int main(int argc, char **argv) { prog_name = argv[0]; piglit_strip_arg(&argc, argv, "-auto"); piglit_strip_arg(&argc, argv, "-fbo"); if (argc != 2) usage_error(); if (strcmp(argv[1], "1") == 0) { test_1(); } else if (strcmp(argv[1], "2") == 0) { test_2(); } else if (strcmp(argv[1], "3") == 0) { test_3(); } else { usage_error(); } abort(); }
int main(int argc, char *argv[]) { cfs_status_init(); if (argc != 3) { usage_error(); } const char *dir_name = argv[1]; const char *dbfile = argv[2]; DIR *dh = opendir(dir_name); if (!dh) { perror("unable to open dir"); exit(-1); } memdb = memdb_open(dbfile); struct dirent *de; time_t ctime = time(NULL); while((de = readdir(dh))) { if (de->d_type != DT_REG) { continue; } char *cdata = NULL; gsize clen = 0; char *fn = g_strdup_printf("%s/%s", dir_name, de->d_name); if (g_file_get_contents(fn, &cdata, &clen, NULL)) { //printf("FOUND %ld %s\n", clen, fn); if (memdb_create(memdb, de->d_name, 0, ctime) != 0) { fprintf(stderr, "memdb_create '%s' failed\n", de->d_name); exit(-1); } if (memdb_write(memdb, de->d_name, 0, ctime, cdata, clen, 0, 1) != clen) { fprintf(stderr, "memdb_write '%s' failed\n", de->d_name); exit(-1); } } g_free(fn); } memdb_close(memdb); closedir(dh); }
int main(int argc, char **argv) { progname = argv[0]; piglit_strip_arg(&argc, argv, "-auto"); if (argc != 2) usage_error(); if (strcmp(argv[1], "gl") == 0) { try_debug_flag(EGL_OPENGL_API, EGL_OPENGL_BIT); } else if (strcmp(argv[1], "gles1") == 0) { try_debug_flag(EGL_OPENGL_ES_API, EGL_OPENGL_ES_BIT); } else if (strcmp(argv[1], "gles2") == 0) { try_debug_flag(EGL_OPENGL_ES_API, EGL_OPENGL_ES2_BIT); } else if (strcmp(argv[1], "gles3") == 0) { try_debug_flag(EGL_OPENGL_ES_API, EGL_OPENGL_ES3_BIT_KHR); } else { usage_error(); } abort(); return EXIT_FAILURE; }
gboolean flatpak_builtin_uninstall (int argc, char **argv, GCancellable *cancellable, GError **error) { g_autoptr(GOptionContext) context = NULL; g_autoptr(FlatpakDir) dir = NULL; const char *name = NULL; const char *branch = NULL; g_autofree char *ref = NULL; gboolean is_app; FlatpakHelperUninstallFlags flags = 0; context = g_option_context_new ("APP [BRANCH] - Uninstall an application"); if (!flatpak_option_context_parse (context, options, &argc, &argv, 0, &dir, cancellable, error)) return FALSE; if (argc < 2) return usage_error (context, "APP must be specified", error); name = argv[1]; if (argc > 2) branch = argv[2]; if (!opt_app && !opt_runtime) opt_app = opt_runtime = TRUE; ref = flatpak_dir_find_installed_ref (dir, name, branch, opt_arch, opt_app, opt_runtime, &is_app, error); if (ref == NULL) return FALSE; /* TODO: when removing runtimes, look for apps that use it, require --force */ if (opt_keep_ref) flags |= FLATPAK_HELPER_UNINSTALL_FLAGS_KEEP_REF; if (opt_force_remove) flags |= FLATPAK_HELPER_UNINSTALL_FLAGS_FORCE_REMOVE; if (!flatpak_dir_uninstall (dir, ref, flags, cancellable, error)) return FALSE; return TRUE; }
bool tan_parseoptionst::check_and_set_options() { if (config.set(cmdline)) { usage_error(); return true; } if(cmdline.isset("version")) { std::cout << TAN_VERSION << std::endl; return true; } int verbosity=6; if(cmdline.isset("v")) verbosity=atoi(cmdline.getval("v")); set_verbosity(verbosity); if(cmdline.args.size()==0) { error("Please provide an input file."); return 1; } else if (cmdline.args.size()>1) { error("Multiple input files not supported."); return 1; } std::string engine="cta"; if(cmdline.isset("engine")) engine=cmdline.getval("engine"); if(cmdline.isset("no-loop-slicing") && engine!="direct" && engine!="bre") warning("Warning: --no-loop-slicing is only available " "with the following engines: bre, direct."); if(cmdline.isset("unranked-method")) { std::string u_mode=cmdline.getval("unranked-method"); if(u_mode!="none" && u_mode!="precondition" && u_mode!="bmc-precondition" && u_mode!="cegar" && u_mode!="bmc") warning("Warning: unknown unranked-method."); } return false; }
static atf_error_t run_tc(const atf_tp_t *tp, struct params *p, int *exitcode) { atf_error_t err; err = atf_no_error(); if (!atf_tp_has_tc(tp, p->m_tcname)) { err = usage_error("Unknown test case `%s'", p->m_tcname); goto out; } switch (p->m_tcpart) { case BODY: err = atf_tp_run(tp, p->m_tcname, atf_fs_path_cstring(&p->m_resfile)); if (atf_is_error(err)) { /* TODO: Handle error */ *exitcode = EXIT_FAILURE; atf_error_free(err); } else { *exitcode = EXIT_SUCCESS; } break; case CLEANUP: err = atf_tp_cleanup(tp, p->m_tcname); if (atf_is_error(err)) { /* TODO: Handle error */ *exitcode = EXIT_FAILURE; atf_error_free(err); } else { *exitcode = EXIT_SUCCESS; } break; default: UNREACHABLE; } INV(!atf_is_error(err)); out: return err; }
/// invoke main modules int mmcc_parse_optionst::doit() { if(cmdline.isset("version")) { std::cout << CBMC_VERSION << '\n'; return 0; } try { if(cmdline.args.size()==1) { std::ifstream in(cmdline.args[0].c_str()); if(!in) { std::cerr << "failed to open `" << cmdline.args[0] << "'\n"; return 2; } return convert(in, cmdline.args[0]); } else if(cmdline.args.size()==0) { return convert(std::cin, "stdin"); } else { usage_error(); return 1; } } catch(const char *error) { std::cerr << error << '\n'; return 10; } catch(const std::string error) { std::cerr << error << '\n'; return 10; } return 0; }
int parseoptions_baset::main() { if(parse_result) { usage_error(); return EX_USAGE; } if(cmdline.isset('?') || cmdline.isset('h') || cmdline.isset("help")) { help(); return EX_OK; } // install signal catcher install_signal_catcher(); return doit(); }
gboolean xdg_app_builtin_dump_runtime (int argc, char **argv, GCancellable *cancellable, GError **error) { g_autoptr(GOptionContext) context = NULL; g_autoptr(XdgAppDir) dir = NULL; const char *runtime; const char *branch = "master"; g_autofree char *ref = NULL; OstreeRepo *repo; g_autofree char *commit = NULL; g_autoptr(GFile) root = NULL; context = g_option_context_new ("RUNTIME BRANCH - Make branch of application current"); if (!xdg_app_option_context_parse (context, options, &argc, &argv, 0, &dir, cancellable, error)) return FALSE; if (argc < 3) return usage_error (context, "RUNTIME and BRANCH must be specified", error); runtime = argv[1]; branch = argv[2]; if (!xdg_app_is_valid_name (runtime)) return xdg_app_fail (error, "'%s' is not a valid name", runtime); if (!xdg_app_is_valid_branch (branch)) return xdg_app_fail (error, "'%s' is not a valid branch name", branch); ref = xdg_app_build_runtime_ref (runtime, branch, opt_arch); repo = xdg_app_dir_get_repo (dir); if (!ostree_repo_read_commit (repo, ref, &root, &commit, cancellable, error)) return FALSE; #ifdef HAVE_LIBARCHIVE return dump_runtime (root, cancellable, error); #else return xdg_app_fail (error, "Build without libarchive"); #endif }