Exemple #1
0
unsigned long get_confitemcount(unsigned char citem) {
    char *item = (char*)callocm(CONF_MAX_ITEMLEN, sizeof(char));
    unsigned long x = 0, y = 0;
    
    for(x = 0;config_line(item, x) != NULL;x++) {
        if(item[0] == citem) y++;
    }
    
    freem(item);
    return y;
}
Exemple #2
0
unsigned long get_confitem(char ***buf, unsigned char citem) {
    char *item = (char*)callocm(CONF_MAX_ITEMLEN, sizeof(char));
    unsigned long i = 0, n = 0, count = 0, itemlen = 0;
    
    count = get_confitemcount(citem);
    if(!count)
        return 0;
    
    *buf = (char**)mallocm(count*sizeof(char*));
    
    for(i = 0;config_line(item, i) != NULL;i++) {
        if(item[0] == citem) {
            itemlen = strlen(item)+1;
            if(itemlen > CONF_MAX_ITEMLEN)
                itemlen =  CONF_MAX_ITEMLEN;
            buf[0][n] = (char*)callocm(itemlen, sizeof(char));
            xstrcpy(buf[0][n++], item, CONF_MAX_ITEMLEN);
        }
    }
    
    freem(item);    
    return n;
}
Exemple #3
0
retvalue tracking_parse(struct distribution *d, struct configiterator *iter) {
	enum trackingflags { tf_keep, tf_all, tf_minimal,
		tf_includechanges, tf_includebyhand, tf_includelogs,
		tf_keepsources,
		tf_needsources, tf_embargoalls,
		tf_COUNT /* must be last */
	};
	static const struct constant trackingflags[] = {
		{"keep",	tf_keep},
		{"all",		tf_all},
		{"minimal",	tf_minimal},
		{"includechanges",	tf_includechanges},
		{"includelogs",		tf_includelogs},
		{"includebyhand",	tf_includebyhand},
		{"keepsources",		tf_keepsources},
		{"needsources",		tf_needsources},
		{"embargoalls",		tf_embargoalls},
		{NULL,		-1}
	};
	bool flags[tf_COUNT];
	retvalue r;
	int modecount;

	assert (d->tracking == dt_NONE);
	memset(flags, 0, sizeof(flags));
	r = config_getflags(iter, "Tracking", trackingflags, flags,
			IGNORABLE(unknownfield), "");
	assert (r != RET_NOTHING);
	if (RET_WAS_ERROR(r))
		return r;
	modecount = flags[tf_keep]?1:0 + flags[tf_minimal]?1:0 + flags[tf_all]?1:0;
	if (modecount > 1) {
		fprintf(stderr,
"Error parsing config file %s, line %u:\n"
"Only one of 'keep','all' or 'minimal' can be in one Tracking header.\n",
			config_filename(iter), config_line(iter));
		return RET_ERROR;
	}
	if (modecount < 1) {
		fprintf(stderr,
"Error parsing config file %s, line %u, column %u:\n"
"Tracking mode ('keep','all' or 'minimal') expected.\n",
			config_filename(iter), config_line(iter),
			config_column(iter));
		return RET_ERROR;
	}
	if (flags[tf_keep])
		d->tracking = dt_KEEP;
	else if (flags[tf_minimal])
		d->tracking = dt_MINIMAL;
	else
		d->tracking = dt_ALL;

	d->trackingoptions.includechanges = flags[tf_includechanges];
	d->trackingoptions.includebyhand = flags[tf_includebyhand];
	d->trackingoptions.includelogs = flags[tf_includelogs];
	d->trackingoptions.keepsources = flags[tf_keepsources];
	d->trackingoptions.needsources = flags[tf_needsources];
	if (flags[tf_needsources])
		fprintf(stderr,
"Warning parsing config file %s, line %u:\n"
"'needsources' ignored as not yet supported.\n",
			config_filename(iter), config_line(iter));
	d->trackingoptions.embargoalls = flags[tf_embargoalls];
	if (flags[tf_embargoalls])
		fprintf(stderr,
"Warning parsing config file %s, line %u:\n"
"'embargoall' ignored as not yet supported.\n",
			config_filename(iter), config_line(iter));
	return RET_OK;
}