Пример #1
0
/*
 * Insert the path in the list.
 * If there is already an element with the same key then
 * the *second* one is ignored (return 0).  If the key is
 * not found then the path is added to the end of the list
 * and 1 is returned.
 */
static int
pinsert(path *p0, qelem *q0)
{
	qelem *q;

	if (p0->p_argc == 0)
		return (0);

	for (q = q0->q_forw; q != q0; q = q->q_forw) {
		path *p = (path *)q;
		if (strcmp(p->p_key, p0->p_key) == 0)
			return (0);
	}
	ins_que(&p0->p_q, q0->q_back);
	return (1);
}
Пример #2
0
/*
 * Discard all currently held path structures on q0.
 * and add all the ones on xq.
 */
static void preplace(qelem *q0, qelem *xq)
{
	/*
	 * While the list is not empty,
	 * take the first element off the list
	 * and free it.
	 */
	while (q0->q_forw != q0) {
		qelem *q = q0->q_forw;
		rem_que(q);
		pfree((path *) q);
	}
	while (xq->q_forw != xq) {
		qelem *q = xq->q_forw;
		rem_que(q);
		ins_que(q, q0);
	}
}
Пример #3
0
/*
 * Find a map, or create one if it does not exist
 */
mnt_map *
mapc_find(char *map, char *opt)
{
	mnt_map *m;

	/*
	 * Search the list of known maps to see if
	 * it has already been loaded.  If it is found
	 * then return a duplicate reference to it.
	 * Otherwise make a new map as required and
	 * add it to the list of maps
	 */
	ITER(m, mnt_map, &map_list_head)
		if (STREQ(m->map_name, map))
			return mapc_dup(m);

	m = mapc_create(map, opt);
	ins_que(&m->hdr, &map_list_head);
	return m;
}