Example #1
0
static gboolean
parse_goption_arg (const gchar * opt,
    const gchar * arg, gpointer data, GError ** err)
{
  static const struct
  {
    const gchar *opt;
    int val;
  } options[] = {
    {
    "--gst-version", ARG_VERSION}, {
    "--gst-fatal-warnings", ARG_FATAL_WARNINGS},
#ifndef GST_DISABLE_GST_DEBUG
    {
    "--gst-debug-level", ARG_DEBUG_LEVEL}, {
    "--gst-debug", ARG_DEBUG}, {
    "--gst-debug-disable", ARG_DEBUG_DISABLE}, {
    "--gst-debug-no-color", ARG_DEBUG_NO_COLOR}, {
    "--gst-debug-color-mode", ARG_DEBUG_COLOR_MODE}, {
    "--gst-debug-help", ARG_DEBUG_HELP},
#endif
    {
    "--gst-plugin-spew", ARG_PLUGIN_SPEW}, {
    "--gst-plugin-path", ARG_PLUGIN_PATH}, {
    "--gst-plugin-load", ARG_PLUGIN_LOAD}, {
    "--gst-disable-segtrap", ARG_SEGTRAP_DISABLE}, {
    "--gst-disable-registry-update", ARG_REGISTRY_UPDATE_DISABLE}, {
    "--gst-disable-registry-fork", ARG_REGISTRY_FORK_DISABLE}, {
    NULL}
  };
  gint val = 0, n;

  for (n = 0; options[n].opt; n++) {
    if (!strcmp (opt, options[n].opt)) {
      val = options[n].val;
      break;
    }
  }

  return parse_one_option (val, arg, err);
}
Example #2
0
/* Replace options with subset of Lustre-specific options, and
   fill in mount flags */
int parse_options(struct mount_opts *mop, char *orig_options, int *flagp)
{
        char *options, *opt, *nextopt, *arg, *val;

        options = calloc(strlen(orig_options) + 1, 1);
        *flagp = 0;
        nextopt = orig_options;
        while ((opt = strsep(&nextopt, ","))) {
                if (!*opt)
                        /* empty option */
                        continue;

                /* Handle retries in a slightly different
                 * manner */
                arg = opt;
                val = strchr(opt, '=');
                /* please note that some ldiskfs mount options are also in the form
                 * of param=value. We should pay attention not to remove those
                 * mount options, see bug 22097. */
                if (val && strncmp(arg, "md_stripe_cache_size", 20) == 0) {
			mop->mo_md_stripe_cache_size = atoi(val + 1);
                } else if (val && strncmp(arg, "retry", 5) == 0) {
			mop->mo_retry = atoi(val + 1);
			if (mop->mo_retry > MAX_RETRIES)
				mop->mo_retry = MAX_RETRIES;
			else if (mop->mo_retry < 0)
				mop->mo_retry = 0;
                } else if (val && strncmp(arg, "mgssec", 6) == 0) {
                        append_option(options, opt);
		} else if (strncmp(arg, "nosvc", 5) == 0) {
			mop->mo_nosvc = 1;
			append_option(options, opt);
		} else if (strcmp(opt, "force") == 0) {
			/* XXX special check for 'force' option */
			++mop->mo_force;
			printf("force: %d\n", mop->mo_force);
		} else if (parse_one_option(opt, flagp) == 0) {
			/* pass this on as an option */
			append_option(options, opt);
		}
	}
#ifdef MS_STRICTATIME
#if LUSTRE_VERSION_CODE > OBD_OCD_VERSION(3, 2, 53, 0)
	/*
	 * LU-1783
	 * In the future when upstream fixes land in all supported kernels
	 * we should stop forcing MS_STRICTATIME in lustre mounts.
	 * We override the kernel level default of MS_RELATIME for now
	 * due to a kernel vfs level bug in atime updates that fails
	 * to reset timestamps from the future.
	 */
#warn "remove MS_STRICTATIME override if kernel updates atime from the future"
#endif
	/* set strictatime to default if NOATIME or RELATIME
	   not given explicit */
	if (!(*flagp & (MS_NOATIME | MS_RELATIME)))
		*flagp |= MS_STRICTATIME;
#endif
	strcpy(orig_options, options);
	free(options);

	return 0;
}
Example #3
0
File: file.c Project: aunoor/xl2tpd
int parse_config (FILE * f)
{
    /* Read in the configuration file handed to us */
    /* FIXME: I should check for incompatible options */
    int context = 0;
    char buf[1024]; 
    char *s, *d, *t;
    int linenum = 0;
    int def = 0;
    int in_comment = 0;
    int has_lf;
    void *data = NULL;
    struct lns *tl;
    struct lac *tc;
    while (!feof (f))
    {
        if (NULL == fgets (buf, sizeof (buf), f))
        {
            /* Error or EOL */
            break;
        }
        /* Watch for continuation comments. */
        has_lf = buf[strlen(buf) - 1] == '\n';
        if (in_comment)
        {
            in_comment = !has_lf;
            continue;
        }
        linenum++;
        s = buf;
        /* Strip comments */
        while (*s && *s != ';')
            s++;
        if (*s == ';' && !has_lf)
            in_comment = 1;
        *s = 0;
        s = buf;
        if (!strlen (buf))
            continue;
        while ((*s < 33) && *s)
            s++;                /* Skip over beginning white space */
        t = s + strlen (s);
        while ((t >= s) && (*t < 33))
            *(t--) = 0;         /* Ditch trailing white space */
        if (!strlen (s))
            continue;
        if (s[0] == '[')
        {
            /* We've got a context description */
            if (!(t = strchr (s, ']')))
            {
                l2tp_log (LOG_CRIT, "parse_config: line %d: No closing bracket\n",
                     linenum);
                return -1;
            }
            t[0] = 0;
            s++;
            if ((d = strchr (s, ' ')))
            {
                /* There's a parameter */
                d[0] = 0;
                d++;
            }
            if (d && !strcasecmp (d, "default"))
                def = CONTEXT_DEFAULT;
            else
                def = 0;
            if (!strcasecmp (s, "global"))
            {
                context = CONTEXT_GLOBAL;
#ifdef DEBUG_FILE
                l2tp_log (LOG_DEBUG,
                     "parse_config: global context descriptor %s\n",
                     d ? d : "");
#endif
                data = &gconfig;
            }
            else if (!strcasecmp (s, "lns"))
            {
                context = CONTEXT_LNS;
                if (def)
                {
                    if (!deflns)
                    {
                        deflns = new_lns ();
                        strncpy (deflns->entname, "default",
                                 sizeof (deflns->entname));
                    }
                    data = deflns;
                    continue;
                }
                data = NULL;
                tl = lnslist;
                if (d)
                {
                    while (tl)
                    {
                        if (!strcasecmp (d, tl->entname))
                            break;
                        tl = tl->next;
                    }
                    if (tl)
                        data = tl;
                }
                if (!data)
                {
                    data = new_lns ();
                    if (!data)
                        return -1;
                    ((struct lns *) data)->next = lnslist;
                    lnslist = (struct lns *) data;
                }
                if (d)
                    strncpy (((struct lns *) data)->entname,
                             d, sizeof (((struct lns *) data)->entname));
#ifdef DEBUG_FILE
                l2tp_log (LOG_DEBUG, "parse_config: lns context descriptor %s\n",
                     d ? d : "");
#endif
            }
            else if (!strcasecmp (s, "lac"))
            {
                context = CONTEXT_LAC;
                if (def)
                {
                    if (!deflac)
                    {
                        deflac = new_lac ();
                        strncpy (deflac->entname, "default",
                                 sizeof (deflac->entname));
                    }
                    data = deflac;
                    continue;
                }
                data = NULL;
                tc = laclist;
                if (d)
                {
                    while (tc)
                    {
                        if (!strcasecmp (d, tc->entname))
                            break;
                        tc = tc->next;
                    }
                    if (tc)
                        data = tc;
                }
                if (!data)
                {
                    data = new_lac ();
                    if (!data)
                        return -1;
                    ((struct lac *) data)->next = laclist;
                    laclist = (struct lac *) data;
                }
                if (d)
                    strncpy (((struct lac *) data)->entname,
                             d, sizeof (((struct lac *) data)->entname));
#ifdef DEBUG_FILE
                l2tp_log (LOG_DEBUG, "parse_config: lac context descriptor %s\n",
                     d ? d : "");
#endif
            }
            else
            {
                l2tp_log (LOG_WARNING,
                     "parse_config: line %d: unknown context '%s'\n", linenum,
                     s);
                return -1;
            }
        }
        else
        {
            if (!context)
            {
                l2tp_log (LOG_WARNING,
                     "parse_config: line %d: data '%s' occurs with no context\n",
                     linenum, s);
                return -1;
            }
            if (!(t = strchr (s, '=')))
            {
                l2tp_log (LOG_WARNING, "parse_config: line %d: line too long or no '=' in data\n",
                     linenum);
                return -1;
            }
            d = t;
            d--;
            t++;
            while ((d >= s) && (*d < 33))
                d--;
            d++;
            *d = 0;
            while (*t && (*t < 33))
                t++;
#ifdef DEBUG_FILE
            l2tp_log (LOG_DEBUG, "parse_config: field is %s, value is %s\n", s, t);
#endif
            /* Okay, bit twiddling is done.  Let's handle this */
            
            switch (parse_one_option (s, t, context | def, data))
            {
            case -1:
                l2tp_log (LOG_WARNING, "parse_config: line %d: %s", linenum,
                             filerr);
                return -1;
            case -2:
                l2tp_log (LOG_CRIT, "parse_config: line %d: Unknown field '%s'\n",
                     linenum, s);
                return -1;
            }            
        }
    }
    return 0;
}