コード例 #1
0
/* Get list of "local equivalent" realms.  Meaning the list of realms
 * where [email protected] is considered the same user as [email protected]
 * If not specified, default to upper-case of local domain name */
struct conf_list *get_local_realms(void)
{
	static struct conf_list *local_realms = NULL;
	if (local_realms) return local_realms;

	local_realms = conf_get_list("General", "Local-Realms");
	if (local_realms == NULL) {
		struct conf_list_node *node;

		local_realms = malloc(sizeof *local_realms);
		if (local_realms == NULL)
			return NULL;
		local_realms->cnt = 0;
		TAILQ_INIT(&local_realms->fields);

		node = calloc(1, sizeof *node);
		if (node == NULL)
			return NULL;

		node->field = calloc(1, NFS4_MAX_DOMAIN_LEN);
		if (node->field == NULL) {
			free(node);
			return NULL;
		}

		nfs4_get_default_domain(NULL, node->field, NFS4_MAX_DOMAIN_LEN);
		toupper_str(node->field);

		TAILQ_INSERT_TAIL(&local_realms->fields, node, link);
		local_realms->cnt++;
	}
	return local_realms;
}
コード例 #2
0
int type_of_instrument_enum(string str_type_of_inst) {
    toupper_str(str_type_of_inst);
    //Case insensitive
    if (str_type_of_inst == "HIGH-GAIN")
        return 0;
    if (str_type_of_inst == "LOW-GAIN")
        return 1;
    if (str_type_of_inst == "ACCELEROMETER")
        return 2;
    return -1;
}
コード例 #3
0
int type_of_band_enum(string str_type_of_band) {
    
    str_type_of_band = toupper_str_C(str_type_of_band);
    toupper_str(str_type_of_band);
    
    if (str_type_of_band == "LONG-PERIOD")
        return 0;
    if (str_type_of_band == "SHORT-PERIOD")
        return 1;
    if (str_type_of_band == "BROADBAND")
        return 2;
    return -1;
}
コード例 #4
0
bool isok_Orientation(string str){
    // Orientation: Case insensitive: a one to three characters combination.
    // Each character can be any of the following two options (alphabetic or
    // numeric, but not a combination of both):
    // N, E, or Z (one, two or three chars)
    // 1, 2, or 3 (one, two or three chars)
    
    toupper_str(str);
    size_t n = str.size();
    if (!isdigit(str[0]))
    {
        for (size_t i = 0; i < n; i++)
            if (!(str[i] == 'N' || str[i] == 'E' || str[i] == 'Z'))
                return false;
    }
    else
    {
        for (size_t i = 0; i < n; i++)
            if (!(str[i] == '1' || str[i] == '2' || str[i] == '3'))
                return false;
    }
    
    return true;
}
コード例 #5
0
ファイル: libnfsidmap.c プロジェクト: ystk/debian-libnfsidmap
int nfs4_init_name_mapping(char *conffile)
{
	int ret = -ENOENT;
	char *method;
	int dflt = 0;
	struct conf_list *nfs4_methods, *gss_methods;

	/* XXX: need to be able to reload configurations... */
	if (nfs4_plugins) /* already succesfully initialized */
		return 0;
	if (conffile)
		conf_path = conffile;
	else
		conf_path = PATH_IDMAPDCONF;
	conf_init();
	default_domain = conf_get_str("General", "Domain");
	if (default_domain == NULL) {
		dflt = 1;
		ret = domain_from_dns(&default_domain);
		if (ret) {
			IDMAP_LOG(1, ("libnfsidmap: Unable to determine "
				  "the NFSv4 domain; Using '%s' as the NFSv4 domain "
				  "which means UIDs will be mapped to the 'Nobody-User' "
				  "user defined in %s\n", 
				  IDMAPD_DEFAULT_DOMAIN, PATH_IDMAPDCONF));
			default_domain = IDMAPD_DEFAULT_DOMAIN;
		}
	}
	IDMAP_LOG(1, ("libnfsidmap: using%s domain: %s\n",
		(dflt ? " (default)" : ""), default_domain));

	/* Get list of "local equivalent" realms.  Meaning the list of realms
	 * where [email protected] is considered the same user as [email protected]
	 * If not specified, default to upper-case of local domain name */
	local_realms = conf_get_list("General", "Local-Realms");
	if (local_realms == NULL) {
		struct conf_list_node *node;

		local_realms = malloc(sizeof *local_realms);
		if (local_realms == NULL)
			return -ENOMEM;
		local_realms->cnt = 0;
		TAILQ_INIT(&local_realms->fields);

		node = calloc(1, sizeof *node);
		if (node == NULL)
			return -ENOMEM;
		node->field = strdup(get_default_domain());
		if (node->field == NULL)
			return -ENOMEM;
		toupper_str(node->field);

		TAILQ_INSERT_TAIL(&local_realms->fields, node, link);
		local_realms->cnt++;
	}

	nfs4_methods = conf_get_list("Translation", "Method");
	if (nfs4_methods) {
		IDMAP_LOG(1, ("libnfsidmap: processing 'Method' list\n"));
		if (load_plugins(nfs4_methods, &nfs4_plugins) == -1)
			return -ENOENT;
	} else {
		struct conf_list list;
		struct conf_list_node node;

		TAILQ_INIT(&list.fields);
		list.cnt = 1;
		node.field = "nsswitch";
		TAILQ_INSERT_TAIL (&list.fields, &node, link);

		if (load_plugins(&list, &nfs4_plugins) == -1)
			return -ENOENT;
	}

	gss_methods = conf_get_list("Translation", "GSS-Methods");
	if (gss_methods) {
		IDMAP_LOG(1, ("libnfsidmap: processing 'GSS-Methods' list\n"));
		if (load_plugins(gss_methods, &gss_plugins) == -1)
			goto out;
	}
	ret = 0;
out:
	if (ret) {
		if (nfs4_plugins)
			unload_plugins(nfs4_plugins);
		if (gss_plugins)
			unload_plugins(gss_plugins);
		nfs4_plugins = gss_plugins = NULL;
	}

	return ret ? -ENOENT: 0;
}