コード例 #1
0
ファイル: daemon.c プロジェクト: sanyaade-mobiledev/murphy
static void setup_logging(mrp_context_t *ctx)
{
    const char *target;

    target = mrp_log_parse_target(ctx->log_target);

    if (!target)
        mrp_log_error("invalid log target '%s'", ctx->log_target);
    else
        mrp_log_set_target(target);
}
コード例 #2
0
ファイル: fragbuf-test.c プロジェクト: 01org/murphy
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);
        }
    }
}
コード例 #3
0
ファイル: mainloop-test.c プロジェクト: 01org/murphy
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;
}
コード例 #4
0
ファイル: dbus-test.c プロジェクト: sanyaade-mobiledev/murphy
int parse_cmdline(context_t *ctx, int argc, char **argv)
{
#   define OPTIONS "sab:l:t:vdh"
    struct option options[] = {
        { "server"    , no_argument      , NULL, 's' },
        { "bus"       , required_argument, NULL, 'b' },
        { "all-pongs" , no_argument      , NULL, 'a' },
        { "log-level" , required_argument, NULL, 'l' },
        { "log-target", required_argument, NULL, 't' },
        { "verbose"   , optional_argument, NULL, 'v' },
        { "debug"     , no_argument      , NULL, 'd' },
        { "help"      , no_argument      , NULL, 'h' },
        { NULL, 0, NULL, 0 }
    };

    int  opt, debug;

    debug = FALSE;
    config_set_defaults(ctx);

    while ((opt = getopt_long(argc, argv, OPTIONS, options, NULL)) != -1) {
        switch (opt) {
        case 's':
            ctx->server = TRUE;
            break;

        case 'b':
            ctx->busaddr = optarg;
            break;

        case 'a':
            ctx->all_pongs = TRUE;
            break;

        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':
            debug = TRUE;
            break;

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

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

    if (debug)
        ctx->log_mask |= MRP_LOG_MASK_DEBUG;

    return TRUE;
}