Ejemplo n.º 1
0
static void debug_set(mrp_console_t *c, void *user_data,
                      int argc, char **argv)
{
    int i;

    MRP_UNUSED(c);
    MRP_UNUSED(user_data);

    for (i = 2; i < argc; i++)
        mrp_debug_set_config(argv[i]);
}
Ejemplo n.º 2
0
static void parse_cmdline(client_t *c, int argc, char **argv)
{
#   define OPTIONS "N:C:d:RFgh"
    struct option options[] = {
        { "name"      , required_argument, NULL, 'N' },
        { "class"     , required_argument, NULL, 'C' },
        { "debug"     , required_argument, NULL, 'd' },
        { "register"  , no_argument      , NULL, 'R' },
        { "focus"     , optional_argument, NULL, 'F' },
        { "glib"      , no_argument      , NULL, 'g' },
        { "help"      , no_argument      , NULL, 'h' },
        { NULL, 0, NULL, 0 }
    };

    int opt;

    while ((opt = getopt_long(argc, argv, OPTIONS, options, NULL)) != -1) {
        switch (opt) {
        case 'N':
            c->app_name = optarg;
            break;

        case 'C':
            c->app_class = optarg;
            break;

        case 'd':
            mrp_debug_set_config(optarg);
            mrp_debug_enable(TRUE);
            break;

        case 'R':
            c->autoregister = TRUE;
            break;

        case 'F':
            c->autofocus = optarg ? optarg : "shared";
            break;

        case 'g':
            c->glib = TRUE;
            break;

        case 'h':
            print_usage(argv[0], -1, "");
            exit(0);
            break;

        default:
            print_usage(argv[0], EINVAL, "invalid option '%c'", opt);
        }
    }
}
Ejemplo n.º 3
0
void parse_cmdline(int argc, char **argv)
{
#   define OPTIONS "l:t:vd:nh"
    struct option options[] = {
        { "log-level" , required_argument, NULL, 'l' },
        { "log-target", required_argument, NULL, 't' },
        { "verbose"   , optional_argument, NULL, 'v' },
        { "debug"     , required_argument, NULL, 'd' },
        { "non-framed", no_argument      , NULL, 'n' },
        { "help"      , no_argument      , NULL, 'h' },
        { NULL, 0, NULL, 0 }
    };

    int opt;

    config_set_defaults();

    while ((opt = getopt_long(argc, argv, OPTIONS, options, NULL)) != -1) {
        switch (opt) {
        case 'v':
            ctx.log_mask <<= 1;
            ctx.log_mask  |= 1;
            break;

        case 'l':
            ctx.log_mask = mrp_log_parse_levels(optarg);
            if (ctx.log_mask < 0)
                print_usage(argv[0], EINVAL, "invalid log level '%s'", optarg);
            break;

        case 't':
            ctx.log_target = mrp_log_parse_target(optarg);
            if (!ctx.log_target)
                print_usage(argv[0], EINVAL, "invalid log target '%s'", optarg);
            break;

        case 'd':
            ctx.log_mask |= MRP_LOG_MASK_DEBUG;
            mrp_debug_set_config(optarg);
            mrp_debug_enable(TRUE);
            break;

        case'n':
            ctx.framed = FALSE;
            break;

        case 'h':
            print_usage(argv[0], -1, "");
            exit(0);
            break;

        case '?':
            if (opterr)
                print_usage(argv[0], EINVAL, "");
            break;

        default:
            print_usage(argv[0], EINVAL, "invalid option '%c'", opt);
        }
    }
}
Ejemplo n.º 4
0
int parse_cmdline(test_config_t *cfg, int argc, char **argv)
{
#ifdef PULSE_ENABLED
#   define PULSE_OPTION "p"
#else
#   define PULSE_OPTION ""
#endif
#ifdef ECORE_ENABLED
#   define ECORE_OPTION "e"
#else
#   define ECORE_OPTION ""
#endif
#ifdef GLIB_ENABLED
#    define GLIB_OPTION "g"
#else
#    define GLIB_OPTION ""
#endif
#ifdef QT_ENABLED
#    define QT_OPTION "q"
#else
#    define QT_OPTION ""
#endif


#   define OPTIONS "r:i:t:s:I:T:S:M:l:w:W:o:vd:h" \
        PULSE_OPTION""ECORE_OPTION""GLIB_OPTION""QT_OPTION
    struct option options[] = {
        { "runtime"     , required_argument, NULL, 'r' },
        { "ios"         , required_argument, NULL, 'i' },
        { "timers"      , required_argument, NULL, 't' },
        { "signals"     , required_argument, NULL, 's' },
        { "glib-ios"    , required_argument, NULL, 'I' },
        { "glib-timers" , required_argument, NULL, 'T' },
        { "dbus-signals", required_argument, NULL, 'S' },
        { "dbus-methods", required_argument, NULL, 'M' },
#ifdef PULSE_ENABLED
        { "pulse"       , no_argument      , NULL, 'p' },
#endif
#ifdef ECORE_ENABLED
        { "ecore"       , no_argument      , NULL, 'e' },
#endif
#ifdef GLIB_ENABLED
        { "glib"        , no_argument      , NULL, 'g' },
#endif
#ifdef QT_ENABLED
        { "qt"          , no_argument      , NULL, 'q' },
#endif
        { "wakeup-lpf"  , required_argument, NULL, 'w' },
        { "wakeup-force", required_argument, NULL, 'W' },
        { "log-level"   , required_argument, NULL, 'l' },
        { "log-target"  , required_argument, NULL, 'o' },
        { "verbose"     , optional_argument, NULL, 'v' },
        { "debug"       , required_argument, NULL, 'd' },
        { "help"        , no_argument      , NULL, 'h' },
        { NULL, 0, NULL, 0 }
    };
    char *end;
    int   opt;

    config_set_defaults(cfg);

    while ((opt = getopt_long(argc, argv, OPTIONS, options, NULL)) != -1) {
        switch (opt) {
        case 'r':
            cfg->runtime = (int)strtoul(optarg, &end, 10);
            if (end && *end)
                print_usage(argv[0], EINVAL,
                            "invalid runtime length '%s'.", optarg);
            break;

        case 'i':
            cfg->nio = (int)strtoul(optarg, &end, 10);
            if (end && *end)
                print_usage(argv[0], EINVAL,
                            "invalid number of I/O watches '%s'.", optarg);
            break;

        case 't':
            cfg->ntimer = (int)strtoul(optarg, &end, 10);
            if (end && *end)
                print_usage(argv[0], EINVAL,
                            "invalid number of timers '%s'.", optarg);
            break;

        case 's':
            cfg->nsignal = (int)strtoul(optarg, &end, 10);
            if (end && *end)
                print_usage(argv[0], EINVAL,
                            "invalid number of signals '%s'.", optarg);
            break;

        case 'I':
            cfg->ngio = (int)strtoul(optarg, &end, 10);
            if (end && *end)
                print_usage(argv[0], EINVAL,
                            "invalid number of glib I/O watches '%s'.", optarg);
            break;

        case 'T':
            cfg->ngtimer = (int)strtoul(optarg, &end, 10);
            if (end && *end)
                print_usage(argv[0], EINVAL,
                            "invalid number of glib timers '%s'.", optarg);
            break;

        case 'S':
            cfg->ndbus_signal = (int)strtoul(optarg, &end, 10);
            if (end && *end)
                print_usage(argv[0], EINVAL,
                            "invalid number of DBUS signals '%s'.", optarg);
            break;

        case 'M':
            cfg->ndbus_method = (int)strtoul(optarg, &end, 10);
            if (end && *end)
                print_usage(argv[0], EINVAL,
                            "invalid number of DBUS methods '%s'.", optarg);
            break;

#ifdef PULSE_ENABLED
        case 'p':
            cfg->mainloop_type = MAINLOOP_PULSE;
            break;
#endif

#ifdef ECORE_ENABLED
        case 'e':
            cfg->mainloop_type = MAINLOOP_ECORE;
            break;
#endif

#ifdef GLIB_ENABLED
        case 'g':
            cfg->mainloop_type = MAINLOOP_GLIB;
            break;
#endif

#ifdef QT_ENABLED
        case 'q':
            cfg->mainloop_type = MAINLOOP_QT;
            break;
#endif

        case 'w':
            cfg->wlpf = (int)strtoul(optarg, &end, 10);
            if (end && *end)
                print_usage(argv[0], EINVAL,
                            "invalid wakeup low-pass filter limit '%s'.",
                            optarg);
            break;

        case 'W':
            cfg->wfrc = (int)strtoul(optarg, &end, 10);
            if (end && *end)
                print_usage(argv[0], EINVAL,
                            "invalid wakeup force trigger limit '%s'.",
                            optarg);
            break;

        case 'v':
            cfg->log_mask <<= 1;
            cfg->log_mask  |= 1;
            break;

        case 'l':
            cfg->log_mask = mrp_log_parse_levels(optarg);
            if (cfg->log_mask < 0)
                print_usage(argv[0], EINVAL, "invalid log level '%s'", optarg);
            break;

        case 'o':
            cfg->log_target = mrp_log_parse_target(optarg);
            if (!cfg->log_target)
                print_usage(argv[0], EINVAL, "invalid log target '%s'", optarg);
            break;

        case 'd':
            cfg->log_mask |= MRP_LOG_MASK_DEBUG;
            mrp_debug_set_config(optarg);
            mrp_debug_enable(TRUE);
            break;

        case 'h':
            print_usage(argv[0], -1, "");
            exit(0);
            break;

        default:
            print_usage(argv[0], EINVAL, "invalid option '%c'", opt);
        }
    }

    return TRUE;
}
Ejemplo n.º 5
0
static void parse_cmdline(ripncode_t *r, int argc, char **argv, char **envp)
{
#   define OPTIONS "d:c:t:f:m:L:T:v::d:nh"

    struct option options[] = {
        { "device"           , required_argument, NULL, 'd' },
        { "driver"           , required_argument, NULL, 'c' },
        { "tracks"           , required_argument, NULL, 't' },
        { "format"           , required_argument, NULL, 'f' },
        { "metadata"         , required_argument, NULL, 'm' },
        { "log-level"        , required_argument, NULL, 'L' },
        { "log-target"       , required_argument, NULL, 'T' },
        { "verbose"          , optional_argument, NULL, 'v' },
        { "debug"            , required_argument, NULL, 'd' },
        { "dry-run"          , no_argument      , NULL, 'n' },
        { "help"             , no_argument      , NULL, 'h' },
        { NULL , 0, NULL, 0 }
    };

    int opt, help;

    MRP_UNUSED(envp);

    help = FALSE;

    while ((opt = getopt_long(argc, argv, OPTIONS, options, NULL)) != -1) {
        switch (opt) {
        case 'D':
            r->device = optarg;
            if (access(r->device, R_OK) < 0)
                ripncode_fatal(r, "can't access '%s' (%d: %s).", r->device,
                               errno, strerror(errno));
            break;

        case 'c':
            r->driver = optarg;
            break;

        case 't':
            r->rip = optarg;
            parse_tracks(r);
            break;

        case 'f':
            r->format = optarg;
            break;

        case 'm':
            r->metadata = optarg;
            if (access(r->metadata, R_OK) < 0)
                ripncode_fatal(r, "can't access '%s' (%d: %s).", r->metadata,
                               errno, strerror(errno));
            break;

        case 'L':
            r->log_mask = mrp_log_parse_levels(optarg);
            mrp_log_set_mask(r->log_mask);
            break;

        case 'v':
            r->log_mask <<= 1;
            r->log_mask  |= 1;
            mrp_log_set_mask(r->log_mask);
            break;

        case 'T':
            r->log_target = optarg;
            mrp_log_set_target(r->log_target);
            break;

        case 'd':
            r->log_mask |= MRP_LOG_MASK_DEBUG;
            mrp_log_set_mask(r->log_mask);
            mrp_debug_set_config(optarg);
            mrp_debug_enable(TRUE);
            break;

        case 'n':
            r->dryrun = 1;
            break;

        case 'h':
            help++;
            break;

        default:
            print_usage(r, EINVAL, "invalid option '%c'", opt);
        }
    }

    if (help) {
        print_usage(r, -1, "");
        exit(0);
    }
}