int cmd_push(int argc, const char **argv, const char *prefix) { int flags = 0; int tags = 0; int rc; const char *repo = NULL; /* default repository */ struct option options[] = { OPT__VERBOSITY(&verbosity), OPT_STRING( 0 , "repo", &repo, N_("repository"), N_("repository")), OPT_BIT( 0 , "all", &flags, N_("push all refs"), TRANSPORT_PUSH_ALL), OPT_BIT( 0 , "mirror", &flags, N_("mirror all refs"), (TRANSPORT_PUSH_MIRROR|TRANSPORT_PUSH_FORCE)), OPT_BOOL( 0, "delete", &deleterefs, N_("delete refs")), OPT_BOOL( 0 , "tags", &tags, N_("push tags (can't be used with --all or --mirror)")), OPT_BIT('n' , "dry-run", &flags, N_("dry run"), TRANSPORT_PUSH_DRY_RUN), OPT_BIT( 0, "porcelain", &flags, N_("machine-readable output"), TRANSPORT_PUSH_PORCELAIN), OPT_BIT('f', "force", &flags, N_("force updates"), TRANSPORT_PUSH_FORCE), { OPTION_CALLBACK, 0, CAS_OPT_NAME, &cas, N_("refname>:<expect"), N_("require old value of ref to be at this value"), PARSE_OPT_OPTARG, parseopt_push_cas_option }, { OPTION_CALLBACK, 0, "recurse-submodules", &flags, N_("check"), N_("control recursive pushing of submodules"), PARSE_OPT_OPTARG, option_parse_recurse_submodules }, OPT_BOOL( 0 , "thin", &thin, N_("use thin pack")), OPT_STRING( 0 , "receive-pack", &receivepack, "receive-pack", N_("receive pack program")), OPT_STRING( 0 , "exec", &receivepack, "receive-pack", N_("receive pack program")), OPT_BIT('u', "set-upstream", &flags, N_("set upstream for git pull/status"), TRANSPORT_PUSH_SET_UPSTREAM), OPT_BOOL(0, "progress", &progress, N_("force progress reporting")), OPT_BIT(0, "prune", &flags, N_("prune locally removed refs"), TRANSPORT_PUSH_PRUNE), OPT_BIT(0, "no-verify", &flags, N_("bypass pre-push hook"), TRANSPORT_PUSH_NO_HOOK), OPT_BIT(0, "follow-tags", &flags, N_("push missing but relevant tags"), TRANSPORT_PUSH_FOLLOW_TAGS), OPT_END() }; packet_trace_identity("push"); git_config(git_default_config, NULL); argc = parse_options(argc, argv, prefix, options, push_usage, 0); if (deleterefs && (tags || (flags & (TRANSPORT_PUSH_ALL | TRANSPORT_PUSH_MIRROR)))) die(_("--delete is incompatible with --all, --mirror and --tags")); if (deleterefs && argc < 2) die(_("--delete doesn't make sense without any refs")); if (tags) add_refspec("refs/tags/*"); if (argc > 0) { repo = argv[0]; set_refspecs(argv + 1, argc - 1, repo); } rc = do_push(repo, flags); if (rc == -1) usage_with_options(push_usage, options); else return rc; }
"perf diff [<options>] [old_file] [new_file]", }; static const struct option options[] = { OPT_BOOLEAN('v', "verbose", &verbose, "be more verbose (show symbol address, etc)"), OPT_BOOLEAN('m', "displacement", &show_displacement, "Show position displacement relative to baseline"), OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace, "dump raw trace in ASCII"), OPT_BOOLEAN('f', "force", &force, "don't complain, do it"), OPT_BOOLEAN('m', "modules", &symbol_conf.use_modules, "load module symbols - WARNING: use only with -k and LIVE kernel"), OPT_BOOLEAN('P', "full-paths", &event_ops.full_paths, "Don't shorten the pathnames taking into account the cwd"), OPT_STRING('d', "dsos", &symbol_conf.dso_list_str, "dso[,dso...]", "only consider symbols in these dsos"), OPT_STRING('C', "comms", &symbol_conf.comm_list_str, "comm[,comm...]", "only consider symbols in these comms"), OPT_STRING('S', "symbols", &symbol_conf.sym_list_str, "symbol[,symbol...]", "only consider these symbols"), OPT_STRING('s', "sort", &sort_order, "key[,key2...]", "sort by key(s): pid, comm, dso, symbol, parent"), OPT_STRING('t', "field-separator", &symbol_conf.field_sep, "separator", "separator for columns, no spaces will be added between " "columns '.' is reserved."), OPT_END() }; int cmd_diff(int argc, const char **argv, const char *prefix __used) { sort_order = diff__default_sort_order;
#include <string.h> #include <signal.h> static bool all; static pid_t instance_pid; static const char *instance_name; static const char * const stop_usage[] = { "kvm stop [--all] [-n name] [-p pid]", NULL }; static const struct option stop_options[] = { OPT_GROUP("General options:"), OPT_BOOLEAN('a', "all", &all, "Stop all instances"), OPT_STRING('n', "name", &instance_name, "name", "Instance name"), OPT_INTEGER('p', "pid", &instance_pid, "Instance pid"), OPT_END() }; static void parse_stop_options(int argc, const char **argv) { while (argc != 0) { argc = parse_options(argc, argv, stop_options, stop_usage, PARSE_OPT_STOP_AT_NON_OPTION); if (argc != 0) kvm_stop_help(); } } void kvm_stop_help(void)
int cmd_commit(int argc, const char **argv, const char *prefix) { static struct wt_status s; static struct option builtin_commit_options[] = { OPT__QUIET(&quiet, N_("suppress summary after successful commit")), OPT__VERBOSE(&verbose, N_("show diff in commit message template")), OPT_GROUP(N_("Commit message options")), OPT_FILENAME('F', "file", &logfile, N_("read message from file")), OPT_STRING(0, "author", &force_author, N_("author"), N_("override author for commit")), OPT_STRING(0, "date", &force_date, N_("date"), N_("override date for commit")), OPT_CALLBACK('m', "message", &message, N_("message"), N_("commit message"), opt_parse_m), OPT_STRING('c', "reedit-message", &edit_message, N_("commit"), N_("reuse and edit message from specified commit")), OPT_STRING('C', "reuse-message", &use_message, N_("commit"), N_("reuse message from specified commit")), OPT_STRING(0, "fixup", &fixup_message, N_("commit"), N_("use autosquash formatted message to fixup specified commit")), OPT_STRING(0, "squash", &squash_message, N_("commit"), N_("use autosquash formatted message to squash specified commit")), OPT_BOOLEAN(0, "reset-author", &renew_authorship, N_("the commit is authored by me now (used with -C/-c/--amend)")), OPT_BOOLEAN('s', "signoff", &signoff, N_("add Signed-off-by:")), OPT_FILENAME('t', "template", &template_file, N_("use specified template file")), OPT_BOOL('e', "edit", &edit_flag, N_("force edit of commit")), OPT_STRING(0, "cleanup", &cleanup_arg, N_("default"), N_("how to strip spaces and #comments from message")), OPT_BOOLEAN(0, "status", &include_status, N_("include status in commit message template")), { OPTION_STRING, 'S', "gpg-sign", &sign_commit, N_("key id"), N_("GPG sign commit"), PARSE_OPT_OPTARG, NULL, (intptr_t) "" }, /* end commit message options */ OPT_GROUP(N_("Commit contents options")), OPT_BOOLEAN('a', "all", &all, N_("commit all changed files")), OPT_BOOLEAN('i', "include", &also, N_("add specified files to index for commit")), OPT_BOOLEAN(0, "interactive", &interactive, N_("interactively add files")), OPT_BOOLEAN('p', "patch", &patch_interactive, N_("interactively add changes")), OPT_BOOLEAN('o', "only", &only, N_("commit only specified files")), OPT_BOOLEAN('n', "no-verify", &no_verify, N_("bypass pre-commit hook")), OPT_BOOLEAN(0, "dry-run", &dry_run, N_("show what would be committed")), OPT_SET_INT(0, "short", &status_format, N_("show status concisely"), STATUS_FORMAT_SHORT), OPT_BOOLEAN(0, "branch", &s.show_branch, N_("show branch information")), OPT_SET_INT(0, "porcelain", &status_format, N_("machine-readable output"), STATUS_FORMAT_PORCELAIN), OPT_SET_INT(0, "long", &status_format, N_("show status in long format (default)"), STATUS_FORMAT_LONG), OPT_BOOLEAN('z', "null", &s.null_termination, N_("terminate entries with NUL")), OPT_BOOLEAN(0, "amend", &amend, N_("amend previous commit")), OPT_BOOLEAN(0, "no-post-rewrite", &no_post_rewrite, N_("bypass post-rewrite hook")), { OPTION_STRING, 'u', "untracked-files", &untracked_files_arg, N_("mode"), N_("show untracked files, optional modes: all, normal, no. (Default: all)"), PARSE_OPT_OPTARG, NULL, (intptr_t)"all" }, /* end commit contents options */ { OPTION_BOOLEAN, 0, "allow-empty", &allow_empty, NULL, N_("ok to record an empty change"), PARSE_OPT_NOARG | PARSE_OPT_HIDDEN }, { OPTION_BOOLEAN, 0, "allow-empty-message", &allow_empty_message, NULL, N_("ok to record a change with an empty message"), PARSE_OPT_NOARG | PARSE_OPT_HIDDEN }, OPT_END() }; struct strbuf sb = STRBUF_INIT; struct strbuf author_ident = STRBUF_INIT; const char *index_file, *reflog_msg; char *nl, *p; unsigned char sha1[20]; struct ref_lock *ref_lock; struct commit_list *parents = NULL, **pptr = &parents; struct stat statbuf; int allow_fast_forward = 1; struct commit *current_head = NULL; struct commit_extra_header *extra = NULL; if (argc == 2 && !strcmp(argv[1], "-h")) usage_with_options(builtin_commit_usage, builtin_commit_options); wt_status_prepare(&s); gitmodules_config(); git_config(git_commit_config, &s); determine_whence(&s); s.colopts = 0; if (get_sha1("HEAD", sha1)) current_head = NULL; else { current_head = lookup_commit_or_die(sha1, "HEAD"); if (!current_head || parse_commit(current_head)) die(_("could not parse HEAD commit")); } argc = parse_and_validate_options(argc, argv, builtin_commit_options, builtin_commit_usage, prefix, current_head, &s); if (dry_run) return dry_run_commit(argc, argv, prefix, current_head, &s); index_file = prepare_index(argc, argv, prefix, current_head, 0); /* Set up everything for writing the commit object. This includes running hooks, writing the trees, and interacting with the user. */ if (!prepare_to_commit(index_file, prefix, current_head, &s, &author_ident)) { rollback_index_files(); return 1; } /* Determine parents */ reflog_msg = getenv("GIT_REFLOG_ACTION"); if (!current_head) { if (!reflog_msg) reflog_msg = "commit (initial)"; } else if (amend) { struct commit_list *c; if (!reflog_msg) reflog_msg = "commit (amend)"; for (c = current_head->parents; c; c = c->next) pptr = &commit_list_insert(c->item, pptr)->next; } else if (whence == FROM_MERGE) { struct strbuf m = STRBUF_INIT; FILE *fp; if (!reflog_msg) reflog_msg = "commit (merge)"; pptr = &commit_list_insert(current_head, pptr)->next; fp = fopen(git_path("MERGE_HEAD"), "r"); if (fp == NULL) die_errno(_("could not open '%s' for reading"), git_path("MERGE_HEAD")); while (strbuf_getline(&m, fp, '\n') != EOF) { struct commit *parent; parent = get_merge_parent(m.buf); if (!parent) die(_("Corrupt MERGE_HEAD file (%s)"), m.buf); pptr = &commit_list_insert(parent, pptr)->next; } fclose(fp); strbuf_release(&m); if (!stat(git_path("MERGE_MODE"), &statbuf)) { if (strbuf_read_file(&sb, git_path("MERGE_MODE"), 0) < 0) die_errno(_("could not read MERGE_MODE")); if (!strcmp(sb.buf, "no-ff")) allow_fast_forward = 0; } if (allow_fast_forward) parents = reduce_heads(parents); } else { if (!reflog_msg) reflog_msg = (whence == FROM_CHERRY_PICK) ? "commit (cherry-pick)" : "commit"; pptr = &commit_list_insert(current_head, pptr)->next; } /* Finally, get the commit message */ strbuf_reset(&sb); if (strbuf_read_file(&sb, git_path(commit_editmsg), 0) < 0) { int saved_errno = errno; rollback_index_files(); die(_("could not read commit message: %s"), strerror(saved_errno)); } /* Truncate the message just before the diff, if any. */ if (verbose) { p = strstr(sb.buf, "\ndiff --git "); if (p != NULL) strbuf_setlen(&sb, p - sb.buf + 1); } if (cleanup_mode != CLEANUP_NONE) stripspace(&sb, cleanup_mode == CLEANUP_ALL); if (template_untouched(&sb) && !allow_empty_message) { rollback_index_files(); fprintf(stderr, _("Aborting commit; you did not edit the message.\n")); exit(1); } if (message_is_empty(&sb) && !allow_empty_message) { rollback_index_files(); fprintf(stderr, _("Aborting commit due to empty commit message.\n")); exit(1); } if (amend) { const char *exclude_gpgsig[2] = { "gpgsig", NULL }; extra = read_commit_extra_headers(current_head, exclude_gpgsig); } else { struct commit_extra_header **tail = &extra; append_merge_tag_headers(parents, &tail); } if (commit_tree_extended(&sb, active_cache_tree->sha1, parents, sha1, author_ident.buf, sign_commit, extra)) { rollback_index_files(); die(_("failed to write commit object")); } strbuf_release(&author_ident); free_commit_extra_headers(extra); ref_lock = lock_any_ref_for_update("HEAD", !current_head ? NULL : current_head->object.sha1, 0); nl = strchr(sb.buf, '\n'); if (nl) strbuf_setlen(&sb, nl + 1 - sb.buf); else strbuf_addch(&sb, '\n'); strbuf_insert(&sb, 0, reflog_msg, strlen(reflog_msg)); strbuf_insert(&sb, strlen(reflog_msg), ": ", 2); if (!ref_lock) { rollback_index_files(); die(_("cannot lock HEAD ref")); } if (write_ref_sha1(ref_lock, sha1, sb.buf) < 0) { rollback_index_files(); die(_("cannot update HEAD ref")); } unlink(git_path("CHERRY_PICK_HEAD")); unlink(git_path("REVERT_HEAD")); unlink(git_path("MERGE_HEAD")); unlink(git_path("MERGE_MSG")); unlink(git_path("MERGE_MODE")); unlink(git_path("SQUASH_MSG")); if (commit_index_files()) die (_("Repository has been updated, but unable to write\n" "new_index file. Check that disk is not full or quota is\n" "not exceeded, and then \"git reset HEAD\" to recover.")); rerere(0); run_hook(get_index_file(), "post-commit", NULL); if (amend && !no_post_rewrite) { struct notes_rewrite_cfg *cfg; cfg = init_copy_notes_for_rewrite("amend"); if (cfg) { /* we are amending, so current_head is not NULL */ copy_note_for_rewrite(cfg, current_head->object.sha1, sha1); finish_copy_notes_for_rewrite(cfg); } run_rewrite_hook(current_head->object.sha1, sha1); } if (!quiet) print_summary(prefix, sha1, !current_head); return 0; }
struct params p; }; static struct global_info *g = NULL; static int parse_cpus_opt(const struct option *opt, const char *arg, int unset); static int parse_nodes_opt(const struct option *opt, const char *arg, int unset); struct params p0; static const struct option options[] = { OPT_INTEGER('p', "nr_proc" , &p0.nr_proc, "number of processes"), OPT_INTEGER('t', "nr_threads" , &p0.nr_threads, "number of threads per process"), OPT_STRING('G', "mb_global" , &p0.mb_global_str, "MB", "global memory (MBs)"), OPT_STRING('P', "mb_proc" , &p0.mb_proc_str, "MB", "process memory (MBs)"), OPT_STRING('L', "mb_proc_locked", &p0.mb_proc_locked_str,"MB", "process serialized/locked memory access (MBs), <= process_memory"), OPT_STRING('T', "mb_thread" , &p0.mb_thread_str, "MB", "thread memory (MBs)"), OPT_UINTEGER('l', "nr_loops" , &p0.nr_loops, "max number of loops to run"), OPT_UINTEGER('s', "nr_secs" , &p0.nr_secs, "max number of seconds to run"), OPT_UINTEGER('u', "usleep" , &p0.sleep_usecs, "usecs to sleep per loop iteration"), OPT_BOOLEAN('R', "data_reads" , &p0.data_reads, "access the data via writes (can be mixed with -W)"), OPT_BOOLEAN('W', "data_writes" , &p0.data_writes, "access the data via writes (can be mixed with -R)"), OPT_BOOLEAN('B', "data_backwards", &p0.data_backwards, "access the data backwards as well"), OPT_BOOLEAN('Z', "data_zero_memset", &p0.data_zero_memset,"access the data via glibc bzero only"), OPT_BOOLEAN('r', "data_rand_walk", &p0.data_rand_walk, "access the data with random (32bit LFSR) walk"),
#include "dvbin.h" #include "dvb_tune.h" #define MAX_CHANNELS 8 #define CHANNEL_LINE_LEN 256 #define min(a, b) ((a) <= (b) ? (a) : (b)) //TODO: CAMBIARE list_ptr e da globale a per_priv #define OPT_BASE_STRUCT struct dvb_params /// URL definition static const m_option_t stream_params[] = { OPT_STRING("prog", cfg_prog, 0), OPT_INTRANGE("card", cfg_card, 0, 1, 4), {0} }; const struct m_sub_options stream_dvb_conf = { .opts = (const m_option_t[]) { OPT_STRING("prog", cfg_prog, 0), OPT_INTRANGE("card", cfg_card, 0, 1, 4), OPT_INTRANGE("timeout", cfg_timeout, 0, 1, 30), {0} }, .size = sizeof(struct dvb_params), .defaults = &(const struct dvb_params){ .cfg_prog = "", .cfg_card = 1,
int toc_bias; int toc_offset; int no_skip; char *device; int span[2]; } cdda_priv; static cdda_priv cdda_dflts = { .search_overlap = -1, }; #define OPT_BASE_STRUCT cdda_priv static const m_option_t cdda_params_fields[] = { OPT_INTPAIR("span", span, 0), OPT_INTRANGE("speed", speed, 0, 1, 100), OPT_STRING("device", device, 0), {0} }; /// We keep these options but now they set the defaults const m_option_t cdda_opts[] = { {"speed", &cdda_dflts.speed, CONF_TYPE_INT, M_OPT_RANGE, 1, 100, NULL}, {"paranoia", &cdda_dflts.paranoia_mode, CONF_TYPE_INT, M_OPT_RANGE, 0, 2, NULL}, {"generic-dev", &cdda_dflts.generic_dev, CONF_TYPE_STRING, 0, 0, 0, NULL}, {"sector-size", &cdda_dflts.sector_size, CONF_TYPE_INT, M_OPT_RANGE, 1, 100, NULL}, {"overlap", &cdda_dflts.search_overlap, CONF_TYPE_INT, M_OPT_RANGE, 0, 75, NULL}, {"toc-bias", &cdda_dflts.toc_bias, CONF_TYPE_INT, 0, 0, 0, NULL}, {"toc-offset", &cdda_dflts.toc_offset, CONF_TYPE_INT, 0, 0, 0, NULL},
int main(int argc, char **argv) { abrt_init(argv); /* I18n */ setlocale(LC_ALL, ""); #if ENABLE_NLS bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); #endif /* Can't keep these strings/structs static: _() doesn't support that */ const char *program_usage_string = _( "& [-v] [-d DIR] [-m MESSAGEID] [-F FMTFILE] [-p NONE|ESSENTIAL|FULL] [-s SYSLOGID]\n" "\n" "Reports problem information into systemd journal.\n" "\n" "The tool reads problem directory DIR and sends its details\n" "into systemd journal as a message. If MESSAGEID is defined, the tool\n" "creates a catalog message as well.\n" ); enum { OPT_v = 1 << 0, OPT_d = 1 << 1, OPT_m = 1 << 2, OPT_F = 1 << 3, OPT_p = 1 << 4, OPT_s = 1 << 5, OPT_D = 1 << 6, }; const char *dump_dir_name = "."; const char *message_id = NULL; const char *fmt_file = NULL; const char *dump = NULL; const char *syslog_id = NULL; /* Keep enum above and order of options below in sync! */ struct options program_options[] = { OPT__VERBOSE(&g_verbose), OPT_STRING('d', NULL , &dump_dir_name, "DIR" , _("Problem directory")), OPT_STRING('m', "message-id" , &message_id, "STR" , _("Catalog message id")), OPT_STRING('F', NULL , &fmt_file , "FILE" , _("Formatting file for catalog message")), OPT_STRING('p', "dump" , &dump , "STR" , _("Dump problem dir into systemd journal fields")), OPT_STRING('s', "syslog-id" , &syslog_id , "STR" , _("Define SYSLOG_IDENTIFIER systemd journal field")), OPT_BOOL( 'D', NULL , NULL , _("Debug")), OPT_END() }; unsigned opts = parse_opts(argc, argv, program_options, program_usage_string); unsigned dump_opt = DUMP_NONE; if (opts & OPT_p) { if (dump && strcmp(dump, "NONE") == 0) /* PASS */; else if (dump && strcmp(dump, "ESSENTIAL") == 0) dump_opt = DUMP_ESSENTIAL; else if (dump && strcmp(dump, "FULL") == 0) dump_opt = DUMP_FULL; else { error_msg("Parameter --dump takes NONE|ESSENTIAL|FULL values"); show_usage_and_die(program_usage_string, program_options); } } export_abrt_envvars(0); problem_data_t *problem_data = create_problem_data_for_reporting(dump_dir_name); if (!problem_data) xfunc_die(); /* create_problem_data_for_reporting already emitted error msg */ problem_formatter_t *pf = problem_formatter_new(); if (fmt_file) { if (problem_formatter_load_file(pf, fmt_file)) error_msg_and_die("Invalid format file: %s", fmt_file); } else { if (problem_formatter_load_string(pf, PROBLEM_REPORT_DEFAULT_TEMPLATE)) error_msg_and_die("BUG: Invalid default problem report format string"); } problem_report_settings_t report_settings = problem_formatter_get_settings(pf); report_settings.prs_shortbt_max_frames = 5; report_settings.prs_shortbt_max_text_size = 0; /* always short bt */ problem_formatter_set_settings(pf, report_settings); /* Modify problem_data to meet reporter's needs */ /* We want to have only binary name in problem report assigned to executable element */ const char *exe = problem_data_get_content_or_NULL(problem_data, FILENAME_EXECUTABLE); char *binary_name = NULL; if (exe) binary_name = strrchr(exe, '/') + 1; if (binary_name) problem_data_add_text_noteditable(problem_data, BINARY_NAME, binary_name); /* crash_function element is neeeded by systemd journal messages, save ??, if it doesn't exist */ const char *crash_function = problem_data_get_content_or_NULL(problem_data, FILENAME_CRASH_FUNCTION); if (!crash_function) problem_data_add_text_noteditable(problem_data, "crash_function", "??"); /* Add SYSLOG_IDENTIFIER into problem data */ if (syslog_id || (syslog_id = getenv("REPORTER_JOURNAL_SYSLOG_ID"))) problem_data_add_text_noteditable(problem_data, SYSLOG_ID, syslog_id); /* Add MESSAGE_ID into problem data */ if (message_id) problem_data_add_text_noteditable(problem_data, MESSAGE_ID, message_id); /* Generating of problem report */ problem_report_t *pr = NULL; if (problem_formatter_generate_report(pf, problem_data, &pr)) error_msg_and_die("Failed to format bug report from problem data"); /* Debug */ if (opts & OPT_D) { log("Message: %s\n" "\n" "%s" "\n" , problem_report_get_summary(pr) , problem_report_get_description(pr) ); problem_data_free(problem_data); problem_report_free(pr); problem_formatter_free(pf); return 0; } msg_content_t *msg_c = create_journal_message(problem_data, pr, dump_opt); /* post journal message */ sd_journal_sendv(msg_content_get_data(msg_c), msg_content_get_size(msg_c)); msg_content_free(msg_c); problem_data_free(problem_data); problem_formatter_free(pf); problem_report_free(pr); return 0; }
#define ACTION_SET (1<<11) #define ACTION_SET_ALL (1<<12) #define ACTION_GET_COLOR (1<<13) #define ACTION_GET_COLORBOOL (1<<14) #define TYPE_BOOL (1<<0) #define TYPE_INT (1<<1) #define TYPE_BOOL_OR_INT (1<<2) #define TYPE_PATH (1<<3) static struct option builtin_config_options[] = { OPT_GROUP("Config file location"), OPT_BOOLEAN(0, "global", &use_global_config, "use global config file"), OPT_BOOLEAN(0, "system", &use_system_config, "use system config file"), OPT_BOOLEAN(0, "local", &use_local_config, "use repository config file"), OPT_STRING('f', "file", &given_config_file, "file", "use given config file"), OPT_GROUP("Action"), OPT_BIT(0, "get", &actions, "get value: name [value-regex]", ACTION_GET), OPT_BIT(0, "get-all", &actions, "get all values: key [value-regex]", ACTION_GET_ALL), OPT_BIT(0, "get-regexp", &actions, "get values for regexp: name-regex [value-regex]", ACTION_GET_REGEXP), OPT_BIT(0, "replace-all", &actions, "replace all matching variables: name value [value_regex]", ACTION_REPLACE_ALL), OPT_BIT(0, "add", &actions, "adds a new variable: name value", ACTION_ADD), OPT_BIT(0, "unset", &actions, "removes a variable: name [value-regex]", ACTION_UNSET), OPT_BIT(0, "unset-all", &actions, "removes all matches: name [value-regex]", ACTION_UNSET_ALL), OPT_BIT(0, "rename-section", &actions, "rename section: old-name new-name", ACTION_RENAME_SECTION), OPT_BIT(0, "remove-section", &actions, "remove a section: name", ACTION_REMOVE_SECTION), OPT_BIT('l', "list", &actions, "list all", ACTION_LIST), OPT_BIT('e', "edit", &actions, "opens an editor", ACTION_EDIT), OPT_STRING(0, "get-color", &get_color_slot, "slot", "find the color configured: [default]"), OPT_STRING(0, "get-colorbool", &get_colorbool_slot, "slot", "find the color setting: [stdout-is-tty]"), OPT_GROUP("Type"),
int cmd_describe(int argc, const char **argv, const char *prefix) { int contains = 0; struct option options[] = { OPT_BOOLEAN(0, "contains", &contains, N_("find the tag that comes after the commit")), OPT_BOOLEAN(0, "debug", &debug, N_("debug search strategy on stderr")), OPT_BOOLEAN(0, "all", &all, N_("use any ref")), OPT_BOOLEAN(0, "tags", &tags, N_("use any tag, even unannotated")), OPT_BOOLEAN(0, "long", &longformat, N_("always use long format")), OPT__ABBREV(&abbrev), OPT_SET_INT(0, "exact-match", &max_candidates, N_("only output exact matches"), 0), OPT_INTEGER(0, "candidates", &max_candidates, N_("consider <n> most recent tags (default: 10)")), OPT_STRING(0, "match", &pattern, N_("pattern"), N_("only consider tags matching <pattern>")), OPT_BOOLEAN(0, "always", &always, N_("show abbreviated commit object as fallback")), {OPTION_STRING, 0, "dirty", &dirty, N_("mark"), N_("append <mark> on dirty working tree (default: \"-dirty\")"), PARSE_OPT_OPTARG, NULL, (intptr_t) "-dirty"}, OPT_END(), }; git_config(git_default_config, NULL); argc = parse_options(argc, argv, prefix, options, describe_usage, 0); if (abbrev < 0) abbrev = DEFAULT_ABBREV; if (max_candidates < 0) max_candidates = 0; else if (max_candidates > MAX_TAGS) max_candidates = MAX_TAGS; save_commit_buffer = 0; if (longformat && abbrev == 0) die(_("--long is incompatible with --abbrev=0")); if (contains) { const char **args = xmalloc((7 + argc) * sizeof(char *)); int i = 0; args[i++] = "name-rev"; args[i++] = "--name-only"; args[i++] = "--no-undefined"; if (always) args[i++] = "--always"; if (!all) { args[i++] = "--tags"; if (pattern) { char *s = xmalloc(strlen("--refs=refs/tags/") + strlen(pattern) + 1); sprintf(s, "--refs=refs/tags/%s", pattern); args[i++] = s; } } memcpy(args + i, argv, argc * sizeof(char *)); args[i + argc] = NULL; return cmd_name_rev(i + argc, args, prefix); } init_hash(&names); for_each_rawref(get_name, NULL); if (!names.nr && !always) die(_("No names found, cannot describe anything.")); if (argc == 0) { if (dirty) { static struct lock_file index_lock; int fd; read_cache_preload(NULL); refresh_index(&the_index, REFRESH_QUIET|REFRESH_UNMERGED, NULL, NULL, NULL); fd = hold_locked_index(&index_lock, 0); if (0 <= fd) update_index_if_able(&the_index, &index_lock); if (!cmd_diff_index(ARRAY_SIZE(diff_index_args) - 1, diff_index_args, prefix)) dirty = NULL; } describe("HEAD", 1); } else if (dirty) { die(_("--dirty is incompatible with committishes")); } else { while (argc-- > 0) { describe(*argv++, argc == 0); } } return 0; }
int main(int argc, char **argv) { abrt_init(argv); const char *dump_dir_name = "."; /* Can't keep these strings/structs static: _() doesn't support that */ const char *program_usage_string = _( "\b [-v] -d DIR\n" "\n" "Calculates and saves UUID and DUPHASH of python crash dumps" ); enum { OPT_v = 1 << 0, OPT_d = 1 << 1, }; /* Keep enum above and order of options below in sync! */ struct options program_options[] = { OPT__VERBOSE(&g_verbose), OPT_STRING('d', NULL, &dump_dir_name, "DIR", _("Dump directory")), OPT_END() }; /*unsigned opts =*/ parse_opts(argc, argv, program_options, program_usage_string); export_abrt_envvars(0); struct dump_dir *dd = dd_opendir(dump_dir_name, /*flags:*/ 0); if (!dd) return 1; char *bt = dd_load_text(dd, FILENAME_BACKTRACE); /* Hash 1st line of backtrace and save it as UUID and DUPHASH */ /* "example.py:1:<module>:ZeroDivisionError: integer division or modulo by zero" */ unsigned char hash_bytes[SHA1_RESULT_LEN]; sha1_ctx_t sha1ctx; sha1_begin(&sha1ctx); const char *bt_end = strchrnul(bt, '\n'); sha1_hash(&sha1ctx, bt, bt_end - bt); sha1_end(&sha1ctx, hash_bytes); free(bt); char hash_str[SHA1_RESULT_LEN*2 + 1]; unsigned len = SHA1_RESULT_LEN; unsigned char *s = hash_bytes; char *d = hash_str; while (len) { *d++ = "0123456789abcdef"[*s >> 4]; *d++ = "0123456789abcdef"[*s & 0xf]; s++; len--; } *d = '\0'; dd_save_text(dd, FILENAME_UUID, hash_str); dd_save_text(dd, FILENAME_DUPHASH, hash_str); dd_close(dd); return 0; }
static int add(int ac, const char **av, const char *prefix) { struct add_opts opts; const char *new_branch_force = NULL; char *path; const char *branch; const char *opt_track = NULL; struct option options[] = { OPT__FORCE(&opts.force, N_("checkout <branch> even if already checked out in other worktree"), PARSE_OPT_NOCOMPLETE), OPT_STRING('b', NULL, &opts.new_branch, N_("branch"), N_("create a new branch")), OPT_STRING('B', NULL, &new_branch_force, N_("branch"), N_("create or reset a branch")), OPT_BOOL(0, "detach", &opts.detach, N_("detach HEAD at named commit")), OPT_BOOL(0, "checkout", &opts.checkout, N_("populate the new working tree")), OPT_BOOL(0, "lock", &opts.keep_locked, N_("keep the new working tree locked")), OPT_PASSTHRU(0, "track", &opt_track, NULL, N_("set up tracking mode (see git-branch(1))"), PARSE_OPT_NOARG | PARSE_OPT_OPTARG), OPT_BOOL(0, "guess-remote", &guess_remote, N_("try to match the new branch name with a remote-tracking branch")), OPT_END() }; memset(&opts, 0, sizeof(opts)); opts.checkout = 1; ac = parse_options(ac, av, prefix, options, worktree_usage, 0); if (!!opts.detach + !!opts.new_branch + !!new_branch_force > 1) die(_("-b, -B, and --detach are mutually exclusive")); if (ac < 1 || ac > 2) usage_with_options(worktree_usage, options); path = prefix_filename(prefix, av[0]); branch = ac < 2 ? "HEAD" : av[1]; if (!strcmp(branch, "-")) branch = "@{-1}"; opts.force_new_branch = !!new_branch_force; if (opts.force_new_branch) { struct strbuf symref = STRBUF_INIT; opts.new_branch = new_branch_force; if (!opts.force && !strbuf_check_branch_ref(&symref, opts.new_branch) && ref_exists(symref.buf)) die_if_checked_out(symref.buf, 0); strbuf_release(&symref); } if (ac < 2 && !opts.new_branch && !opts.detach) { int n; const char *s = worktree_basename(path, &n); opts.new_branch = xstrndup(s, n); if (guess_remote) { struct object_id oid; const char *remote = unique_tracking_name(opts.new_branch, &oid); if (remote) branch = remote; } } if (ac == 2 && !opts.new_branch && !opts.detach) { struct object_id oid; struct commit *commit; const char *remote; commit = lookup_commit_reference_by_name(branch); if (!commit) { remote = unique_tracking_name(branch, &oid); if (remote) { opts.new_branch = branch; branch = remote; } } } if (opts.new_branch) { struct child_process cp = CHILD_PROCESS_INIT; cp.git_cmd = 1; argv_array_push(&cp.args, "branch"); if (opts.force_new_branch) argv_array_push(&cp.args, "--force"); argv_array_push(&cp.args, opts.new_branch); argv_array_push(&cp.args, branch); if (opt_track) argv_array_push(&cp.args, opt_track); if (run_command(&cp)) return -1; branch = opts.new_branch; } else if (opt_track) { die(_("--[no-]track can only be used if a new branch is created")); } UNLEAK(path); UNLEAK(opts); return add_worktree(path, branch, &opts); }
#include <sys/time.h> #include <errno.h> #define K 1024 static const char *length_str = "1MB"; static const char *routine = "default"; static int iterations = 1; static bool use_cycle; static int cycle_fd; static bool only_prefault; static bool no_prefault; static const struct option options[] = { OPT_STRING('l', "length", &length_str, "1MB", "Specify length of memory to set. " "Available units: B, KB, MB, GB and TB (upper and lower)"), OPT_STRING('r', "routine", &routine, "default", "Specify routine to set"), OPT_INTEGER('i', "iterations", &iterations, "repeat memset() invocation this number of times"), OPT_BOOLEAN('c', "cycle", &use_cycle, "Use cycles event instead of gettimeofday() for measuring"), OPT_BOOLEAN('o', "only-prefault", &only_prefault, "Show only the result with page faults before memset()"), OPT_BOOLEAN('n', "no-prefault", &no_prefault, "Show only the result without page faults before memset()"), OPT_END() }; typedef void *(*memset_t)(void *, int, size_t);
#define DVDREAD_VERSION LIBDVDREAD_VERSION(0,9,0) #else #define DVDREAD_VERSION LIBDVDREAD_VERSION(0,8,0) #endif #endif static const dvd_priv_t stream_priv_dflts = { .cfg_title = 0, }; #define OPT_BASE_STRUCT dvd_priv_t /// URL definition static const m_option_t stream_opts_fields[] = { OPT_INTRANGE("title", cfg_title, 0, 0, 99), OPT_STRING("device", cfg_device, 0), {0} }; int dvd_chapter_from_cell(dvd_priv_t* dvd,int title,int cell) { pgc_t * cur_pgc; ptt_info_t* ptt; int chapter = cell; int pgc_id,pgn; if(title < 0 || cell < 0){ return 0; } /* for most DVD's chapter == cell */ /* but there are more complecated cases... */ if(chapter >= dvd->vmg_file->tt_srpt->title[title].nr_of_ptts) {
int cmd_buildid_cache(int argc, const char **argv) { struct strlist *list; struct str_node *pos; int ret = 0; int ns_id = -1; bool force = false; char const *add_name_list_str = NULL, *remove_name_list_str = NULL, *purge_name_list_str = NULL, *missing_filename = NULL, *update_name_list_str = NULL, *kcore_filename = NULL; char sbuf[STRERR_BUFSIZE]; struct perf_data data = { .mode = PERF_DATA_MODE_READ, }; struct perf_session *session = NULL; struct nsinfo *nsi = NULL; const struct option buildid_cache_options[] = { OPT_STRING('a', "add", &add_name_list_str, "file list", "file(s) to add"), OPT_STRING('k', "kcore", &kcore_filename, "file", "kcore file to add"), OPT_STRING('r', "remove", &remove_name_list_str, "file list", "file(s) to remove"), OPT_STRING('p', "purge", &purge_name_list_str, "path list", "path(s) to remove (remove old caches too)"), OPT_STRING('M', "missing", &missing_filename, "file", "to find missing build ids in the cache"), OPT_BOOLEAN('f', "force", &force, "don't complain, do it"), OPT_STRING('u', "update", &update_name_list_str, "file list", "file(s) to update"), OPT_INCR('v', "verbose", &verbose, "be more verbose"), OPT_INTEGER(0, "target-ns", &ns_id, "target pid for namespace context"), OPT_END() }; const char * const buildid_cache_usage[] = { "perf buildid-cache [<options>]", NULL }; argc = parse_options(argc, argv, buildid_cache_options, buildid_cache_usage, 0); if (argc || (!add_name_list_str && !kcore_filename && !remove_name_list_str && !purge_name_list_str && !missing_filename && !update_name_list_str)) usage_with_options(buildid_cache_usage, buildid_cache_options); if (ns_id > 0) nsi = nsinfo__new(ns_id); if (missing_filename) { data.file.path = missing_filename; data.force = force; session = perf_session__new(&data, false, NULL); if (session == NULL) return -1; } if (symbol__init(session ? &session->header.env : NULL) < 0) goto out; setup_pager(); if (add_name_list_str) { list = strlist__new(add_name_list_str, NULL); if (list) { strlist__for_each_entry(pos, list) if (build_id_cache__add_file(pos->s, nsi)) { if (errno == EEXIST) { pr_debug("%s already in the cache\n", pos->s); continue; } pr_warning("Couldn't add %s: %s\n", pos->s, str_error_r(errno, sbuf, sizeof(sbuf))); } strlist__delete(list); } } if (remove_name_list_str) { list = strlist__new(remove_name_list_str, NULL); if (list) { strlist__for_each_entry(pos, list) if (build_id_cache__remove_file(pos->s, nsi)) { if (errno == ENOENT) { pr_debug("%s wasn't in the cache\n", pos->s); continue; } pr_warning("Couldn't remove %s: %s\n", pos->s, str_error_r(errno, sbuf, sizeof(sbuf))); } strlist__delete(list); } } if (purge_name_list_str) { list = strlist__new(purge_name_list_str, NULL); if (list) { strlist__for_each_entry(pos, list) if (build_id_cache__purge_path(pos->s, nsi)) { if (errno == ENOENT) { pr_debug("%s wasn't in the cache\n", pos->s); continue; } pr_warning("Couldn't remove %s: %s\n", pos->s, str_error_r(errno, sbuf, sizeof(sbuf))); } strlist__delete(list); } } if (missing_filename) ret = build_id_cache__fprintf_missing(session, stdout); if (update_name_list_str) { list = strlist__new(update_name_list_str, NULL); if (list) { strlist__for_each_entry(pos, list) if (build_id_cache__update_file(pos->s, nsi)) { if (errno == ENOENT) { pr_debug("%s wasn't in the cache\n", pos->s); continue; } pr_warning("Couldn't update %s: %s\n", pos->s, str_error_r(errno, sbuf, sizeof(sbuf))); } strlist__delete(list); } } if (kcore_filename && build_id_cache__add_kcore(kcore_filename, force)) pr_warning("Couldn't add %s\n", kcore_filename); out: perf_session__delete(session); nsinfo__zput(nsi); return ret; }
#ifdef CONFIG_TV static const m_option_t tvscan_conf[]={ {"autostart", &stream_tv_defaults.scan, CONF_TYPE_FLAG, 0, 0, 1, NULL}, {"threshold", &stream_tv_defaults.scan_threshold, CONF_TYPE_INT, CONF_RANGE, 1, 100, NULL}, {"period", &stream_tv_defaults.scan_period, CONF_TYPE_FLOAT, CONF_RANGE, 0.1, 2.0, NULL}, {NULL, NULL, 0, 0, 0, 0, NULL} }; #endif #define OPT_BASE_STRUCT struct MPOpts extern const struct m_sub_options image_writer_conf; static const m_option_t screenshot_conf[] = { OPT_SUBSTRUCT("", screenshot_image_opts, image_writer_conf, 0), OPT_STRING("template", screenshot_template, 0), {0}, }; extern const m_option_t lavc_decode_opts_conf[]; extern const m_option_t ad_lavc_decode_opts_conf[]; extern const m_option_t mp_input_opts[]; const m_option_t mp_opts[] = { // handled in command line pre-parser (parser-mpcmd.c) {"v", NULL, CONF_TYPE_STORE, CONF_GLOBAL | CONF_NOCFG, 0, 0, NULL}, // handled in command line parser (parser-mpcmd.c) {"playlist", NULL, CONF_TYPE_STRING, CONF_NOCFG | M_OPT_MIN, 1, 0, NULL}, {"shuffle", NULL, CONF_TYPE_FLAG, CONF_NOCFG, 0, 0, NULL},
static int copy(int argc, const char **argv, const char *prefix) { int retval = 0, force = 0, from_stdin = 0; const unsigned char *from_note, *note; const char *object_ref; unsigned char object[20], from_obj[20]; struct notes_tree *t; const char *rewrite_cmd = NULL; struct option options[] = { OPT_BOOLEAN('f', "force", &force, "replace existing notes"), OPT_BOOLEAN(0, "stdin", &from_stdin, "read objects from stdin"), OPT_STRING(0, "for-rewrite", &rewrite_cmd, "command", "load rewriting config for <command> (implies " "--stdin)"), OPT_END() }; argc = parse_options(argc, argv, prefix, options, git_notes_copy_usage, 0); if (from_stdin || rewrite_cmd) { if (argc) { error("too many parameters"); usage_with_options(git_notes_copy_usage, options); } else { return notes_copy_from_stdin(force, rewrite_cmd); } } if (argc < 2) { error("too few parameters"); usage_with_options(git_notes_copy_usage, options); } if (2 < argc) { error("too many parameters"); usage_with_options(git_notes_copy_usage, options); } if (get_sha1(argv[0], from_obj)) die("Failed to resolve '%s' as a valid ref.", argv[0]); object_ref = 1 < argc ? argv[1] : "HEAD"; if (get_sha1(object_ref, object)) die("Failed to resolve '%s' as a valid ref.", object_ref); t = init_notes_check("copy"); note = get_note(t, object); if (note) { if (!force) { retval = error("Cannot copy notes. Found existing " "notes for object %s. Use '-f' to " "overwrite existing notes", sha1_to_hex(object)); goto out; } fprintf(stderr, "Overwriting existing notes for object %s\n", sha1_to_hex(object)); } from_note = get_note(t, from_obj); if (!from_note) { retval = error("Missing notes on source object %s. Cannot " "copy.", sha1_to_hex(from_obj)); goto out; } add_note(t, object, from_note, combine_notes_overwrite); commit_notes(t, "Notes added by 'git notes copy'"); out: free_notes(t); return retval; }
int cmd_for_each_ref(int argc, const char **argv, const char *prefix) { int i; const char *format = "%(objectname) %(objecttype)\t%(refname)"; struct ref_sorting *sorting = NULL, **sorting_tail = &sorting; int maxcount = 0, quote_style = 0; struct ref_array array; struct ref_filter filter; struct option opts[] = { OPT_BIT('s', "shell", "e_style, N_("quote placeholders suitably for shells"), QUOTE_SHELL), OPT_BIT('p', "perl", "e_style, N_("quote placeholders suitably for perl"), QUOTE_PERL), OPT_BIT(0 , "python", "e_style, N_("quote placeholders suitably for python"), QUOTE_PYTHON), OPT_BIT(0 , "tcl", "e_style, N_("quote placeholders suitably for Tcl"), QUOTE_TCL), OPT_GROUP(""), OPT_INTEGER( 0 , "count", &maxcount, N_("show only <n> matched refs")), OPT_STRING( 0 , "format", &format, N_("format"), N_("format to use for the output")), OPT_CALLBACK(0 , "sort", sorting_tail, N_("key"), N_("field name to sort on"), &parse_opt_ref_sorting), OPT_CALLBACK(0, "points-at", &filter.points_at, N_("object"), N_("print only refs which points at the given object"), parse_opt_object_name), OPT_MERGED(&filter, N_("print only refs that are merged")), OPT_NO_MERGED(&filter, N_("print only refs that are not merged")), OPT_CONTAINS(&filter.with_commit, N_("print only refs which contain the commit")), OPT_END(), }; memset(&array, 0, sizeof(array)); memset(&filter, 0, sizeof(filter)); parse_options(argc, argv, prefix, opts, for_each_ref_usage, 0); if (maxcount < 0) { error("invalid --count argument: `%d'", maxcount); usage_with_options(for_each_ref_usage, opts); } if (HAS_MULTI_BITS(quote_style)) { error("more than one quoting style?"); usage_with_options(for_each_ref_usage, opts); } if (verify_ref_format(format)) usage_with_options(for_each_ref_usage, opts); if (!sorting) sorting = ref_default_sorting(); /* for warn_ambiguous_refs */ git_config(git_default_config, NULL); filter.name_patterns = argv; filter.match_as_path = 1; filter_refs(&array, &filter, FILTER_REFS_ALL | FILTER_REFS_INCLUDE_BROKEN); ref_array_sort(sorting, &array); if (!maxcount || array.nr < maxcount) maxcount = array.nr; for (i = 0; i < maxcount; i++) show_ref_array_item(array.items[i], format, quote_style); ref_array_clear(&array); return 0; }
static int parse_archive_args(int argc, const char **argv, const struct archiver **ar, struct archiver_args *args, const char *name_hint, int is_remote) { const char *format = NULL; const char *base = NULL; const char *remote = NULL; const char *exec = NULL; const char *output = NULL; int compression_level = -1; int verbose = 0; int i; int list = 0; int worktree_attributes = 0; struct option opts[] = { OPT_GROUP(""), OPT_STRING(0, "format", &format, N_("fmt"), N_("archive format")), OPT_STRING(0, "prefix", &base, N_("prefix"), N_("prepend prefix to each pathname in the archive")), OPT_STRING('o', "output", &output, N_("file"), N_("write the archive to this file")), OPT_BOOL(0, "worktree-attributes", &worktree_attributes, N_("read .gitattributes in working directory")), OPT__VERBOSE(&verbose, N_("report archived files on stderr")), OPT__COMPR('0', &compression_level, N_("store only"), 0), OPT__COMPR('1', &compression_level, N_("compress faster"), 1), OPT__COMPR_HIDDEN('2', &compression_level, 2), OPT__COMPR_HIDDEN('3', &compression_level, 3), OPT__COMPR_HIDDEN('4', &compression_level, 4), OPT__COMPR_HIDDEN('5', &compression_level, 5), OPT__COMPR_HIDDEN('6', &compression_level, 6), OPT__COMPR_HIDDEN('7', &compression_level, 7), OPT__COMPR_HIDDEN('8', &compression_level, 8), OPT__COMPR('9', &compression_level, N_("compress better"), 9), OPT_GROUP(""), OPT_BOOL('l', "list", &list, N_("list supported archive formats")), OPT_GROUP(""), OPT_STRING(0, "remote", &remote, N_("repo"), N_("retrieve the archive from remote repository <repo>")), OPT_STRING(0, "exec", &exec, N_("command"), N_("path to the remote git-upload-archive command")), OPT_END() }; argc = parse_options(argc, argv, NULL, opts, archive_usage, 0); if (remote) die(_("Unexpected option --remote")); if (exec) die(_("Option --exec can only be used together with --remote")); if (output) die(_("Unexpected option --output")); if (!base) base = ""; if (list) { for (i = 0; i < nr_archivers; i++) if (!is_remote || archivers[i]->flags & ARCHIVER_REMOTE) printf("%s\n", archivers[i]->name); exit(0); } if (!format && name_hint) format = archive_format_from_filename(name_hint); if (!format) format = "tar"; /* We need at least one parameter -- tree-ish */ if (argc < 1) usage_with_options(archive_usage, opts); *ar = lookup_archiver(format); if (!*ar || (is_remote && !((*ar)->flags & ARCHIVER_REMOTE))) die(_("Unknown archive format '%s'"), format); args->compression_level = Z_DEFAULT_COMPRESSION; if (compression_level != -1) { if ((*ar)->flags & ARCHIVER_WANT_COMPRESSION_LEVELS) args->compression_level = compression_level; else { die(_("Argument not supported for format '%s': -%d"), format, compression_level); } } args->verbose = verbose; args->base = base; args->baselen = strlen(base); args->worktree_attributes = worktree_attributes; return argc; }
static int run_sequencer(int argc, const char **argv, struct replay_opts *opts) { const char * const * usage_str = revert_or_cherry_pick_usage(opts); const char *me = action_name(opts); int cmd = 0; struct option base_options[] = { OPT_CMDMODE(0, "quit", &cmd, N_("end revert or cherry-pick sequence"), 'q'), OPT_CMDMODE(0, "continue", &cmd, N_("resume revert or cherry-pick sequence"), 'c'), OPT_CMDMODE(0, "abort", &cmd, N_("cancel revert or cherry-pick sequence"), 'a'), OPT_BOOL('n', "no-commit", &opts->no_commit, N_("don't automatically commit")), OPT_BOOL('e', "edit", &opts->edit, N_("edit the commit message")), OPT_NOOP_NOARG('r', NULL), OPT_BOOL('s', "signoff", &opts->signoff, N_("add Signed-off-by:")), OPT_CALLBACK('m', "mainline", opts, N_("parent-number"), N_("select mainline parent"), option_parse_m), OPT_RERERE_AUTOUPDATE(&opts->allow_rerere_auto), OPT_STRING(0, "strategy", &opts->strategy, N_("strategy"), N_("merge strategy")), OPT_CALLBACK('X', "strategy-option", &opts, N_("option"), N_("option for merge strategy"), option_parse_x), { OPTION_STRING, 'S', "gpg-sign", &opts->gpg_sign, N_("key-id"), N_("GPG sign commit"), PARSE_OPT_OPTARG, NULL, (intptr_t) "" }, OPT_END() }; struct option *options = base_options; if (opts->action == REPLAY_PICK) { struct option cp_extra[] = { OPT_BOOL('x', NULL, &opts->record_origin, N_("append commit name")), OPT_BOOL(0, "ff", &opts->allow_ff, N_("allow fast-forward")), OPT_BOOL(0, "allow-empty", &opts->allow_empty, N_("preserve initially empty commits")), OPT_BOOL(0, "allow-empty-message", &opts->allow_empty_message, N_("allow commits with empty messages")), OPT_BOOL(0, "keep-redundant-commits", &opts->keep_redundant_commits, N_("keep redundant, empty commits")), OPT_END(), }; options = parse_options_concat(options, cp_extra); } argc = parse_options(argc, argv, NULL, options, usage_str, PARSE_OPT_KEEP_ARGV0 | PARSE_OPT_KEEP_UNKNOWN); /* implies allow_empty */ if (opts->keep_redundant_commits) opts->allow_empty = 1; /* Check for incompatible command line arguments */ if (cmd) { char *this_operation; if (cmd == 'q') this_operation = "--quit"; else if (cmd == 'c') this_operation = "--continue"; else { assert(cmd == 'a'); this_operation = "--abort"; } verify_opt_compatible(me, this_operation, "--no-commit", opts->no_commit, "--signoff", opts->signoff, "--mainline", opts->mainline, "--strategy", opts->strategy ? 1 : 0, "--strategy-option", opts->xopts ? 1 : 0, "-x", opts->record_origin, "--ff", opts->allow_ff, "--rerere-autoupdate", opts->allow_rerere_auto == RERERE_AUTOUPDATE, "--no-rerere-autoupdate", opts->allow_rerere_auto == RERERE_NOAUTOUPDATE, NULL); } if (opts->allow_ff) verify_opt_compatible(me, "--ff", "--signoff", opts->signoff, "--no-commit", opts->no_commit, "-x", opts->record_origin, "--edit", opts->edit, NULL); if (cmd) { opts->revs = NULL; } else { struct setup_revision_opt s_r_opt; opts->revs = xmalloc(sizeof(*opts->revs)); init_revisions(opts->revs, NULL); opts->revs->no_walk = REVISION_WALK_NO_WALK_UNSORTED; if (argc < 2) usage_with_options(usage_str, options); if (!strcmp(argv[1], "-")) argv[1] = "@{-1}"; memset(&s_r_opt, 0, sizeof(s_r_opt)); s_r_opt.assume_dashdash = 1; argc = setup_revisions(argc, argv, opts->revs, &s_r_opt); } if (argc > 1) usage_with_options(usage_str, options); /* These option values will be free()d */ opts->gpg_sign = xstrdup_or_null(opts->gpg_sign); opts->strategy = xstrdup_or_null(opts->strategy); if (cmd == 'q') return sequencer_remove_state(opts); if (cmd == 'c') return sequencer_continue(opts); if (cmd == 'a') return sequencer_rollback(opts); return sequencer_pick_revisions(opts); }
#include <libelf.h> static const char *input_name; static bool force; static bool show_kernel; static bool with_hits; static const char * const buildid_list_usage[] = { "perf buildid-list [<options>]", NULL }; static const struct option options[] = { OPT_BOOLEAN('H', "with-hits", &with_hits, "Show only DSOs with hits"), OPT_STRING('i', "input", &input_name, "file", "input file name"), OPT_BOOLEAN('f', "force", &force, "don't complain, do it"), OPT_BOOLEAN('k', "kernel", &show_kernel, "Show current kernel build id"), OPT_INCR('v', "verbose", &verbose, "be more verbose"), OPT_END() }; static int sysfs__fprintf_build_id(FILE *fp) { u8 kallsyms_build_id[BUILD_ID_SIZE]; char sbuild_id[BUILD_ID_SIZE * 2 + 1]; if (sysfs__read_build_id("/sys/kernel/notes", kallsyms_build_id, sizeof(kallsyms_build_id)) != 0) return -1;
static int parse_archive_args(int argc, const char **argv, const struct archiver **ar, struct archiver_args *args) { const char *format = "tar"; const char *base = NULL; const char *remote = NULL; const char *exec = NULL; int compression_level = -1; int verbose = 0; int i; int list = 0; struct option opts[] = { OPT_GROUP(""), OPT_STRING(0, "format", &format, "fmt", "archive format"), OPT_STRING(0, "prefix", &base, "prefix", "prepend prefix to each pathname in the archive"), OPT__VERBOSE(&verbose), OPT__COMPR('0', &compression_level, "store only", 0), OPT__COMPR('1', &compression_level, "compress faster", 1), OPT__COMPR_HIDDEN('2', &compression_level, 2), OPT__COMPR_HIDDEN('3', &compression_level, 3), OPT__COMPR_HIDDEN('4', &compression_level, 4), OPT__COMPR_HIDDEN('5', &compression_level, 5), OPT__COMPR_HIDDEN('6', &compression_level, 6), OPT__COMPR_HIDDEN('7', &compression_level, 7), OPT__COMPR_HIDDEN('8', &compression_level, 8), OPT__COMPR('9', &compression_level, "compress better", 9), OPT_GROUP(""), OPT_BOOLEAN('l', "list", &list, "list supported archive formats"), OPT_GROUP(""), OPT_STRING(0, "remote", &remote, "repo", "retrieve the archive from remote repository <repo>"), OPT_STRING(0, "exec", &exec, "cmd", "path to the remote git-upload-archive command"), OPT_END() }; argc = parse_options(argc, argv, opts, archive_usage, 0); if (remote) die("Unexpected option --remote"); if (exec) die("Option --exec can only be used together with --remote"); if (!base) base = ""; if (list) { for (i = 0; i < ARRAY_SIZE(archivers); i++) printf("%s\n", archivers[i].name); exit(0); } /* We need at least one parameter -- tree-ish */ if (argc < 1) usage_with_options(archive_usage, opts); *ar = lookup_archiver(format); if (!*ar) die("Unknown archive format '%s'", format); args->compression_level = Z_DEFAULT_COMPRESSION; if (compression_level != -1) { if ((*ar)->flags & USES_ZLIB_COMPRESSION) args->compression_level = compression_level; else { die("Argument not supported for format '%s': -%d", format, compression_level); } } args->verbose = verbose; args->base = base; args->baselen = strlen(base); return argc; }
int main(int argc, char **argv) { const char *prefix = "prefix/"; const char *usage[] = { "test-parse-options <options>", NULL }; struct option options[] = { OPT_BOOL(0, "yes", &boolean, "get a boolean"), OPT_BOOL('D', "no-doubt", &boolean, "begins with 'no-'"), { OPTION_SET_INT, 'B', "no-fear", &boolean, NULL, "be brave", PARSE_OPT_NOARG | PARSE_OPT_NONEG, NULL, 1 }, OPT_COUNTUP('b', "boolean", &boolean, "increment by one"), OPT_BIT('4', "or4", &boolean, "bitwise-or boolean with ...0100", 4), OPT_NEGBIT(0, "neg-or4", &boolean, "same as --no-or4", 4), OPT_GROUP(""), OPT_INTEGER('i', "integer", &integer, "get a integer"), OPT_INTEGER('j', NULL, &integer, "get a integer, too"), OPT_SET_INT(0, "set23", &integer, "set integer to 23", 23), OPT_DATE('t', NULL, ×tamp, "get timestamp of <time>"), OPT_CALLBACK('L', "length", &integer, "str", "get length of <str>", length_callback), OPT_FILENAME('F', "file", &file, "set file to <file>"), OPT_GROUP("String options"), OPT_STRING('s', "string", &string, "string", "get a string"), OPT_STRING(0, "string2", &string, "str", "get another string"), OPT_STRING(0, "st", &string, "st", "get another string (pervert ordering)"), OPT_STRING('o', NULL, &string, "str", "get another string"), OPT_NOOP_NOARG(0, "obsolete"), OPT_STRING_LIST(0, "list", &list, "str", "add str to list"), OPT_GROUP("Magic arguments"), OPT_ARGUMENT("quux", "means --quux"), OPT_NUMBER_CALLBACK(&integer, "set integer to NUM", number_callback), { OPTION_COUNTUP, '+', NULL, &boolean, NULL, "same as -b", PARSE_OPT_NOARG | PARSE_OPT_NONEG | PARSE_OPT_NODASH }, { OPTION_COUNTUP, 0, "ambiguous", &ambiguous, NULL, "positive ambiguity", PARSE_OPT_NOARG | PARSE_OPT_NONEG }, { OPTION_COUNTUP, 0, "no-ambiguous", &ambiguous, NULL, "negative ambiguity", PARSE_OPT_NOARG | PARSE_OPT_NONEG }, OPT_GROUP("Standard options"), OPT__ABBREV(&abbrev), OPT__VERBOSE(&verbose, "be verbose"), OPT__DRY_RUN(&dry_run, "dry run"), OPT__QUIET(&quiet, "be quiet"), OPT_END(), }; int i; argc = parse_options(argc, (const char **)argv, prefix, options, usage, 0); printf("boolean: %d\n", boolean); printf("integer: %u\n", integer); printf("timestamp: %lu\n", timestamp); printf("string: %s\n", string ? string : "(not set)"); printf("abbrev: %d\n", abbrev); printf("verbose: %d\n", verbose); printf("quiet: %s\n", quiet ? "yes" : "no"); printf("dry run: %s\n", dry_run ? "yes" : "no"); printf("file: %s\n", file ? file : "(not set)"); for (i = 0; i < list.nr; i++) printf("list: %s\n", list.items[i].string); for (i = 0; i < argc; i++) printf("arg %02d: %s\n", i, argv[i]); return 0; }
int cmd_list(int argc, const char **argv) { const struct option options[] = { OPT_STRING('b', "bus", ¶m.bus, "bus-id", "filter by bus"), OPT_STRING('r', "region", ¶m.region, "region-id", "filter by region"), OPT_BOOLEAN('B', "buses", &list.buses, "include bus info"), OPT_BOOLEAN('D', "dimms", &list.dimms, "include dimm info"), OPT_BOOLEAN('R', "regions", &list.regions, "include region info"), OPT_BOOLEAN('N', "namespaces", &list.namespaces, "include namespace info (default)"), OPT_BOOLEAN('i', "idle", &list.idle, "include idle devices"), OPT_END(), }; const char * const u[] = { "ndctl list [<options>]", NULL }; struct json_object *jnamespaces = NULL; struct json_object *jregions = NULL; struct json_object *jdimms = NULL; struct json_object *jbuses = NULL; struct ndctl_ctx *ctx; struct ndctl_bus *bus; int i, rc; argc = parse_options(argc, argv, options, u, 0); for (i = 0; i < argc; i++) error("unknown parameter \"%s\"\n", argv[i]); if (argc) usage_with_options(u, options); rc = ndctl_new(&ctx); if (rc < 0) return rc; ndctl_bus_foreach(ctx, bus) { struct json_object *jbus = NULL; struct ndctl_region *region; struct ndctl_dimm *dimm; if (!util_bus_filter(bus, param.bus)) continue; if (list.buses) { if (!jbuses) { jbuses = json_object_new_array(); if (!jbuses) { fail("\n"); continue; } } jbus = util_bus_to_json(bus); if (!jbus) { fail("\n"); continue; } json_object_array_add(jbuses, jbus); } ndctl_dimm_foreach(bus, dimm) { struct json_object *jdimm; /* are we emitting dimms? */ if (!list.dimms) break; if (!list.idle && !ndctl_dimm_is_enabled(dimm)) continue; if (!jdimms) { jdimms = json_object_new_array(); if (!jdimms) { fail("\n"); continue; } if (jbus) json_object_object_add(jbus, "dimms", jdimms); } jdimm = util_dimm_to_json(dimm); if (!jdimm) { fail("\n"); continue; } /* * Without a bus we are collecting dimms anonymously * across the platform. */ json_object_array_add(jdimms, jdimm); } ndctl_region_foreach(bus, region) { struct json_object *jregion; if (!util_region_filter(region, param.region)) continue; if (!list.regions) { jnamespaces = list_namespaces(region, jbus, jnamespaces, true); continue; } if (!list.idle && !ndctl_region_is_enabled(region)) continue; if (!jregions) { jregions = json_object_new_array(); if (!jregions) { fail("\n"); continue; } if (jbus) json_object_object_add(jbus, "regions", jregions); } jregion = region_to_json(region); if (!jregion) { fail("\n"); continue; } /* * Without a bus we are collecting regions anonymously * across the platform. */ json_object_array_add(jregions, jregion); } if (jbuses) { jdimms = NULL; jregions = NULL; jnamespaces = NULL; } } if (jbuses) display_array(jbuses); else if ((!!jdimms + !!jregions + !!jnamespaces) > 1) { struct json_object *jplatform = json_object_new_object(); if (!jplatform) { fail("\n"); return -ENOMEM; } if (jdimms) json_object_object_add(jplatform, "dimms", jdimms); if (jregions) json_object_object_add(jplatform, "regions", jregions); if (jnamespaces) json_object_object_add(jplatform, "namespaces", jnamespaces); printf("%s\n", json_object_to_json_string_ext(jplatform, jflag)); json_object_put(jplatform); } else if (jdimms) display_array(jdimms); else if (jregions) display_array(jregions); else if (jnamespaces) display_array(jnamespaces); if (did_fail) return -ENOMEM; return 0; }
{ OPTION_BOOLEAN, 0, "naked", &option_bare, NULL, N_("create a bare repository"), PARSE_OPT_NOARG | PARSE_OPT_HIDDEN }, OPT_BOOLEAN(0, "mirror", &option_mirror, N_("create a mirror repository (implies bare)")), OPT_BOOL('l', "local", &option_local, N_("to clone from a local repository")), OPT_BOOLEAN(0, "no-hardlinks", &option_no_hardlinks, N_("don't use local hardlinks, always copy")), OPT_BOOLEAN('s', "shared", &option_shared, N_("setup as shared repository")), OPT_BOOLEAN(0, "recursive", &option_recursive, N_("initialize submodules in the clone")), OPT_BOOLEAN(0, "recurse-submodules", &option_recursive, N_("initialize submodules in the clone")), OPT_STRING(0, "template", &option_template, N_("template-directory"), N_("directory from which templates will be used")), OPT_CALLBACK(0 , "reference", &option_reference, N_("repo"), N_("reference repository"), &opt_parse_reference), OPT_STRING('o', "origin", &option_origin, N_("name"), N_("use <name> instead of 'origin' to track upstream")), OPT_STRING('b', "branch", &option_branch, N_("branch"), N_("checkout <branch> instead of the remote's HEAD")), OPT_STRING('u', "upload-pack", &option_upload_pack, N_("path"), N_("path to git-upload-pack on the remote")), OPT_STRING(0, "depth", &option_depth, N_("depth"), N_("create a shallow clone of that depth")), OPT_BOOL(0, "single-branch", &option_single_branch, N_("clone only one branch, HEAD or --branch")), OPT_STRING(0, "separate-git-dir", &real_git_dir, N_("gitdir"), N_("separate git dir from working tree")), OPT_STRING_LIST('c', "config", &option_config, N_("key=value"),
int cmd_name_rev(int argc, const char **argv, const char *prefix) { struct object_array revs = OBJECT_ARRAY_INIT; int all = 0, transform_stdin = 0, allow_undefined = 1, always = 0, peel_tag = 0; struct name_ref_data data = { 0, 0, NULL }; struct option opts[] = { OPT_BOOL(0, "name-only", &data.name_only, N_("print only names (no SHA-1)")), OPT_BOOL(0, "tags", &data.tags_only, N_("only use tags to name the commits")), OPT_STRING(0, "refs", &data.ref_filter, N_("pattern"), N_("only use refs matching <pattern>")), OPT_GROUP(""), OPT_BOOL(0, "all", &all, N_("list all commits reachable from all refs")), OPT_BOOL(0, "stdin", &transform_stdin, N_("read from stdin")), OPT_BOOL(0, "undefined", &allow_undefined, N_("allow to print `undefined` names (default)")), OPT_BOOL(0, "always", &always, N_("show abbreviated commit object as fallback")), { /* A Hidden OPT_BOOL */ OPTION_SET_INT, 0, "peel-tag", &peel_tag, NULL, N_("dereference tags in the input (internal use)"), PARSE_OPT_NOARG | PARSE_OPT_HIDDEN, NULL, 1, }, OPT_END(), }; git_config(git_default_config, NULL); argc = parse_options(argc, argv, prefix, opts, name_rev_usage, 0); if (all + transform_stdin + !!argc > 1) { error("Specify either a list, or --all, not both!"); usage_with_options(name_rev_usage, opts); } if (all || transform_stdin) cutoff = 0; for (; argc; argc--, argv++) { unsigned char sha1[20]; struct object *object; struct commit *commit; if (get_sha1(*argv, sha1)) { fprintf(stderr, "Could not get sha1 for %s. Skipping.\n", *argv); continue; } commit = NULL; object = parse_object(sha1); if (object) { struct object *peeled = deref_tag(object, *argv, 0); if (peeled && peeled->type == OBJ_COMMIT) commit = (struct commit *)peeled; } if (!object) { fprintf(stderr, "Could not get object for %s. Skipping.\n", *argv); continue; } if (commit) { if (cutoff > commit->date) cutoff = commit->date; } if (peel_tag) { if (!commit) { fprintf(stderr, "Could not get commit for %s. Skipping.\n", *argv); continue; } object = (struct object *)commit; } add_object_array(object, *argv, &revs); } if (cutoff) cutoff = cutoff - CUTOFF_DATE_SLOP; for_each_ref(name_ref, &data); if (transform_stdin) { char buffer[2048]; while (!feof(stdin)) { char *p = fgets(buffer, sizeof(buffer), stdin); if (!p) break; name_rev_line(p, &data); } } else if (all) { int i, max; max = get_max_object_index(); for (i = 0; i < max; i++) { struct object *obj = get_indexed_object(i); if (!obj || obj->type != OBJ_COMMIT) continue; show_name(obj, NULL, always, allow_undefined, data.name_only); } } else { int i; for (i = 0; i < revs.nr; i++) show_name(revs.objects[i].item, revs.objects[i].name, always, allow_undefined, data.name_only); } return 0; }
int main(int argc, char **argv) { abrt_init(argv); enum { OPT_v = 1 << 0, OPT_d = 1 << 1, OPT_g = 1 << 2, OPT_b = 1 << 3, OPT_u = 1 << 4, OPT_r = 1 << 5, }; const char *bugs = NULL, *release = NULL, *dump_dir_path = "."; /* Keep enum above and order of options below in sync! */ struct options program_options[] = { OPT__VERBOSE(&g_verbose), OPT__DUMP_DIR(&dump_dir_path), OPT_GROUP(""), OPT_STRING('b', "bugs", &bugs, "ID1[,ID2,...]" , _("List of bug ids")), OPT_STRING('u', "url", &bodhi_url, "URL", _("Specify a bodhi server url")), OPT_OPTSTRING('r', "release", &release, "RELEASE", _("Specify a release")), OPT_END() }; const char *program_usage_string = _( "& [-v] [-r[RELEASE]] (-b ID1[,ID2,...] | PKG-NAME) [PKG-NAME]... \n" "\n" "Search for updates on bodhi server" ); unsigned opts = parse_opts(argc, argv, program_options, program_usage_string); if (!bugs && !argv[optind]) show_usage_and_die(program_usage_string, program_options); struct strbuf *query = strbuf_new(); if (bugs) query = strbuf_append_strf(query, "bugs=%s&", bugs); if (opts & OPT_r) { if (release) { query = strbuf_append_strf(query, "release=%s&", release); } else { struct dump_dir *dd = dd_opendir(dump_dir_path, DD_OPEN_READONLY); if (!dd) xfunc_die(); problem_data_t *problem_data = create_problem_data_from_dump_dir(dd); dd_close(dd); if (!problem_data) xfunc_die(); /* create_problem_data_for_reporting already emitted error msg */ char *product, *version; map_string_t *osinfo = new_map_string(); problem_data_get_osinfo(problem_data, osinfo); parse_osinfo_for_rhts(osinfo, &product, &version); query = strbuf_append_strf(query, "release=f%s&", version); free(product); free(version); free_map_string(osinfo); } } if (argv[optind]) { char *escaped = g_uri_escape_string(argv[optind], NULL, 0); query = strbuf_append_strf(query, "package=%s&", escaped); free(escaped); } if (query->buf[query->len - 1] == '&') query->buf[query->len - 1] = '\0'; log(_("Searching for updates")); GHashTable *update_hash_tbl = bodhi_query_list(query->buf, release); strbuf_free(query); if (!update_hash_tbl || !g_hash_table_size(update_hash_tbl)) { log(_("No updates for this package found")); /*if (update_hash_tbl) g_hash_table_unref(update_hash_tbl);*/ return 0; } GHashTableIter iter; char *name; struct bodhi *b; struct strbuf *q = strbuf_new(); g_hash_table_iter_init(&iter, update_hash_tbl); while (g_hash_table_iter_next(&iter, (void **) &name, (void **) &b)) { char *installed_pkg_nvr = rpm_get_nvr_by_pkg_name(name); if (installed_pkg_nvr && rpmvercmp(installed_pkg_nvr, b->nvr) >= 0) { log_info("Update %s is older or same as local version %s, skipping", b->nvr, installed_pkg_nvr); free(installed_pkg_nvr); continue; } free(installed_pkg_nvr); strbuf_append_strf(q, " %s", b->nvr); } /*g_hash_table_unref(update_hash_tbl);*/ if (!q->len) { /*strbuf_free(q);*/ log(_("Local version of the package is newer than available updates")); return 0; } /* Message is split into text and command in order to make * translator's job easier */ /* We suggest the command which is most likely to exist on user's system, * and which is familiar to the largest population of users. * There are other tools (pkcon et al) which might be somewhat more * convenient (for example, they might be usable from non-root), but they * might be not present on the system, may evolve or be superseded, * while yum is unlikely to do so. */ strbuf_prepend_str(q, "yum update --enablerepo=fedora --enablerepo=updates-testing"); char *msg = xasprintf(_("An update exists which might fix your problem. " "You can install it by running: %s. " "Do you want to continue with reporting the bug?"), q->buf ); /*strbuf_free(q);*/ return !ask_yes_no(msg); }
vf->query_format = query_format; vf->control = control; vf->uninit = uninit; p->max_requests = p->cfg_maxrequests; if (p->max_requests < 0) p->max_requests = av_cpu_count(); MP_VERBOSE(vf, "using %d concurrent requests.\n", p->max_requests); int maxbuffer = p->cfg_maxbuffer * p->max_requests; p->buffered = talloc_array(vf, struct mp_image *, maxbuffer); p->requested = talloc_zero_array(vf, struct mp_image *, p->max_requests); return 1; } #define OPT_BASE_STRUCT struct vf_priv_s static const m_option_t vf_opts_fields[] = { OPT_STRING("file", cfg_file, M_OPT_FILE), OPT_INTRANGE("buffered-frames", cfg_maxbuffer, 0, 1, 9999, OPTDEF_INT(4)), OPT_CHOICE_OR_INT("concurrent-frames", cfg_maxrequests, 0, 1, 99, ({"auto", -1}), OPTDEF_INT(-1)), {0} }; #if HAVE_VAPOURSYNTH #include <VSScript.h> static int drv_vss_init(struct vf_instance *vf) { if (!vsscript_init()) { MP_FATAL(vf, "Could not initialize VapourSynth scripting.\n"); return -1;
"record events on existing pid"), OPT_INTEGER('r', "realtime", &realtime_prio, "collect data with this RT SCHED_FIFO priority"), OPT_BOOLEAN('R', "raw-samples", &raw_samples, "collect raw sample records from all opened counters"), OPT_BOOLEAN('a', "all-cpus", &system_wide, "system-wide collection from all CPUs"), OPT_BOOLEAN('A', "append", &append_file, "append to the output file to do incremental profiling"), OPT_INTEGER('C', "profile_cpu", &profile_cpu, "CPU to profile on"), OPT_BOOLEAN('f', "force", &force, "overwrite existing data file"), OPT_LONG('c', "count", &default_interval, "event period to sample"), OPT_STRING('o', "output", &output_name, "file", "output file name"), OPT_BOOLEAN('i', "inherit", &inherit, "child tasks inherit counters"), OPT_INTEGER('F', "freq", &freq, "profile at this frequency"), OPT_INTEGER('m', "mmap-pages", &mmap_pages, "number of mmap data pages"), OPT_BOOLEAN('g', "call-graph", &call_graph, "do call-graph (stack chain/backtrace) recording"), OPT_BOOLEAN('v', "verbose", &verbose, "be more verbose (show counter open errors, etc)"), OPT_BOOLEAN('s', "stat", &inherit_stat, "per thread counts"), OPT_BOOLEAN('d', "data", &sample_address, "Sample addresses"), OPT_BOOLEAN('n', "no-samples", &no_samples,
int main_phantom(int argc, char* argv[]) { bool kspace = false; bool d3 = false; int sens = 0; int osens = -1; int xdim = -1; bool out_sens = false; bool tecirc = false; bool circ = false; const char* traj = NULL; long dims[DIMS] = { [0 ... DIMS - 1] = 1 }; dims[0] = 128; dims[1] = 128; dims[2] = 1; const struct opt_s opts[] = { OPT_INT('s', &sens, "nc", "nc sensitivities"), OPT_INT('S', &osens, "", "Output nc sensitivities"), OPT_SET('k', &kspace, "k-space"), OPT_STRING('t', &traj, "file", "trajectory"), OPT_SET('c', &circ, "()"), OPT_SET('m', &tecirc, "()"), OPT_INT('x', &xdim, "n", "dimensions in y and z"), OPT_SET('3', &d3, "3D"), }; cmdline(&argc, argv, 1, 1, usage_str, help_str, ARRAY_SIZE(opts), opts); num_init(); if (tecirc) { circ = true; dims[TE_DIM] = 32; } if (-1 != osens) { out_sens = true; sens = osens; } if (-1 != xdim) dims[0] = dims[1] = xdim; if (d3) dims[2] = dims[0]; long sdims[DIMS]; complex float* samples = NULL; if (NULL != traj) { samples = load_cfl(traj, DIMS, sdims); dims[0] = 1; dims[1] = sdims[1]; dims[2] = sdims[2]; } if (sens) dims[3] = sens; complex float* out = create_cfl(argv[1], DIMS, dims); if (out_sens) { assert(NULL == traj); assert(!kspace); calc_sens(dims, out); } else if (circ) { assert(NULL == traj); if (1 < dims[TE_DIM]) { assert(!d3); calc_moving_circ(dims, out, kspace); } else { (d3 ? calc_circ3d : calc_circ)(dims, out, kspace); // calc_ring(dims, out, kspace); } } else { //assert(1 == dims[COIL_DIM]); if (NULL == samples) { (d3 ? calc_phantom3d : calc_phantom)(dims, out, kspace); } else { dims[0] = 3; (d3 ? calc_phantom3d_noncart : calc_phantom_noncart)(dims, out, samples); dims[0] = 1; } } if (NULL != traj) free((void*)traj); if (NULL != samples) unmap_cfl(3, sdims, samples); unmap_cfl(DIMS, dims, out); return 0; }