Esempio n. 1
0
int suppl_log_find_list(suppl_log_list_t *list
	, suppl_log_csptr_t str)
{	suppl_log_list_t *act;
	int flg, ch;

	assert(list);

	flg = 0;

	if(str && (act = list->suppl_l_nxt) != 0) do {
		if((ch = suppl_log_match_item(act, str)) != 0)
			flg = ch;
	} while((act = act->suppl_l_nxt) != 0);

	return flg;
}
Esempio n. 2
0
void suppl_log_chg_list_(FLAG *flag
	, suppl_log_list_t *list
	, suppl_log_sptr_t *str)
{	suppl_log_sptr_t p, q;
	suppl_log_list_t *act, *prv;
	int flg;

	assert(flag);
	assert(list);
	assert(str);
	assert(*str);

	if(*(p = *str) == NUL || *p == ';')		/* Nothing to do */
		return;

	if(!*flag) {				/* Must create a local copy */
		suppl_log_dup_list(list);
		*flag = 1;
	}

	/* Now append the new entries */
	chkHeap
	do {
		switch(flg = *p) {
		case '+': case '-':
			++p;
			break;
		default:
			flg = '+';				/* default to "enabled" */
			break;
		}
		if((q = strpbrk(p, ";,")) == 0)	/* advance to end of name */
			q = strend(p);
		if(q == p) {				/* default specified */
			suppl_log_del_list_(list);
			list->suppl_l_name[0] = flg;
		}
		else {
			act = list;
			while((act = (prv = act)->suppl_l_nxt) != 0) {
				if(suppl_log_match_item(act, p)) {
					/* remove the current item from the list */
					chkHeap
					prv->suppl_l_nxt = act->suppl_l_nxt;
					free(act);
					chkHeap
					act = prv;
				}
			}

			/* Append a new item */
			assert(prv);
			prv->suppl_l_nxt = suppl_log_mkf_item(flg, p, (size_t)(q - p));
		}

		chkHeap
		p = q;
	} while(*p++ == ',');

	*str = p - 1;
	chkHeap
}