Ejemplo n.º 1
0
static boolean_t
keysource_prop_parser(char *prop_value, key_format_t *format,
    key_locator_t *locator, char **uri)
{
	int len;
	int prop_len;
	char *s = prop_value;

	*format = KEY_FORMAT_NONE;
	*locator = KEY_LOCATOR_NONE;

	if (!prop_value)
		return (B_FALSE);

	prop_len = strlen(prop_value);
	if (prop_len > ZFS_MAXPROPLEN)
		return (B_FALSE);

	for (len = 0; len < prop_len; len++)
		if (s[len] == ',')
			break;

	/* If we are at the end of the key property, there is a problem */
	if (len == prop_len)
		return (B_FALSE);

	if (!parse_format(format, s, len))
		return (B_FALSE);

	s = s + len + 1;
	len = prop_len - len - 1;

	return (parse_locator(locator, s, len, uri));
}
Ejemplo n.º 2
0
/* this is the externally visible function used by extra_opts */
np_arg_list* np_get_defaults(const char *locator, const char *default_section){
	FILE *inifile=NULL;
	np_arg_list *defaults=NULL;
	np_ini_info i;

	parse_locator(locator, default_section, &i);
	/* if a file was specified or if we're using the default file */
	if(i.file != NULL && strlen(i.file) > 0){
		if(strcmp(i.file, "-")==0){
			inifile=stdin;
		} else {
			inifile=fopen(i.file, "r");
		}
		if(inifile==NULL) die(STATE_UNKNOWN, _("Can't read config file"));
		if(read_defaults(inifile, i.stanza, &defaults)==FALSE)
			die(STATE_UNKNOWN, _("Invalid section '%s' in config file '%s'\n"), i.stanza, i.file);

		free(i.file);
		if(inifile!=stdin) fclose(inifile);
	}
	free(i.stanza);
	return defaults;
}