示例#1
0
void displayStrings(List* l)
{
	list_start(l);
	while (list_hasNext(l))
		printf("%s", (char*)list_next(l));
	printf("\n");
}
示例#2
0
void displayIntegers(List* l)
{
	list_start(l);
	while (list_hasNext(l))
		printf("%d ", *((int*)list_next(l)));
	printf("\n");
}
示例#3
0
void p2p_cron_announce(ITEM * ti)
{
	ITEM *item = NULL;
	ITEM *t_new = NULL;
	int j = 0;
	TID *tid = list_value(ti);
	LOOKUP *l = tid->lookup;
	NODE_L *n = NULL;

	info(_log, NULL, "Start announcing after querying %lu nodes",
	     list_size(l->list));

	item = list_start(l->list);
	while (item != NULL && j < 8) {
		n = list_value(item);

		if (n->token_size != 0) {
			t_new = tdb_put(P2P_ANNOUNCE_ENGAGE);
			send_announce_request(&n->c_addr, tdb_tid(t_new),
					      l->target, n->token,
					      n->token_size);
			j++;
		}

		item = list_next(item);
	}
}
示例#4
0
void p2p_cron_find(UCHAR * target)
{
	ITEM *item_b = NULL;
	BUCK *b = NULL;
	ITEM *item_n = NULL;
	UDP_NODE *n = NULL;
	unsigned long int j = 0;
	ITEM *ti = NULL;

	if ((item_b = bckt_find_any_match(_main->nbhd->bucket, target)) == NULL) {
		return;
	} else {
		b = list_value(item_b);
	}

	j = 0;
	item_n = list_start(b->nodes);
	while (item_n != NULL && j < 8) {
		n = list_value(item_n);

		if (_main->p2p->time_now.tv_sec > n->time_find) {

			ti = tdb_put(P2P_FIND_NODE);
			send_find_node_request(&n->c_addr, target, tdb_tid(ti));
			time_add_5_min_approx(&n->time_find);
		}

		item_n = list_next(item_n);
		j++;
	}
}
示例#5
0
文件: list.c 项目: stevedonovan/llib
static Iterator *list_iterable(const void *o) {
    ListIterator* liter = obj_new(ListIterator,NULL);
    liter->li = list_start((List*)o);
    liter->next = iter_list_next;
    liter->nextpair = NULL;
    liter->len = list_size((List*)o);
    return (Iterator*)liter;
}
示例#6
0
文件: List.c 项目: kr094/c
void list_free(list_t list) {
	list_start(list);

	while(list_next(list))
		node_free(list->curr->prev);

	free(list);
	list = NULL;
}
示例#7
0
文件: List.c 项目: kr094/c
node_t list_seek(list_t list, int index) {
	int i;
	if(index < 0)
		return NULL;

	list_start(list);
	for(i = 1; i != index; list_next(list), i++);

	return list_peek(list);
}
示例#8
0
void p2p_cron_ping(void)
{
	ITEM *item_b = NULL;
	BUCK *b = NULL;
	ITEM *item_n = NULL;
	UDP_NODE *n = NULL;
	ITEM *ti = NULL;
	unsigned long int j = 0;

	/* Cycle through all the buckets */
	item_b = list_start(_main->nbhd->bucket);
	while (item_b != NULL) {
		b = list_value(item_b);

		/* Cycle through all the nodes */
		j = 0;
		item_n = list_start(b->nodes);
		while (item_n != NULL) {
			n = list_value(item_n);

			/* It's time for pinging */
			if (_main->p2p->time_now.tv_sec > n->time_ping) {

				/* Ping the first 8 nodes. Ignore the rest. */
				if (j < 8) {
					ti = tdb_put(P2P_PING);
					send_ping(&n->c_addr, tdb_tid(ti));
					nbhd_pinged(n->id);
				} else {
					nbhd_pinged(n->id);
				}
			}

			item_n = list_next(item_n);
			j++;
		}

		item_b = list_next(item_b);
	}
}
示例#9
0
void p2p_error(BEN * packet, IP * from)
{
	BEN *e = NULL;
	BEN *code = NULL;
	BEN *msg = NULL;
	ITEM *i = NULL;

#if 0
	BEN *t = NULL;
	/* Transaction ID */
	t = ben_dict_search_str(packet, "t");
	if (!ben_is_str(t)) {
		info(_log, from, "Missing transaction ID from");
		return;
	}
	if (ben_str_i(t) != TID_SIZE) {
		info(_log, from, "Broken transaction ID from");
		return;
	}
#endif

	/* The error */
	e = ben_dict_search_str(packet, "e");
	if (!ben_is_list(e)) {
		info(_log, from, "Missing or broken error message from");
		return;
	}

	/* Error code */
	i = list_start(e->v.l);
	code = list_value(i);
	if (!ben_is_int(code)) {
		info(_log, from, "Broken error code from");
		return;
	}

	/* Error message */
	i = list_stop(e->v.l);
	msg = list_value(i);
	if (!ben_is_str(msg)) {
		info(_log, from, "Broken error message from");
		return;
	}
	if (ben_str_i(msg) > 100) {
		info(_log, from, "Error message too big from");
		return;
	}

	/* Notification */
	info(_log, from, "ERROR %li: \"%s\" from", code->v.i, ben_str_s(msg));
}
示例#10
0
void ben_free_r(BEN * node)
{
	ITEM *item = NULL;

	if (node == NULL) {
		return;
	}

	switch (node->t) {
	case BEN_DICT:
		if (node->v.d != NULL) {
			item = list_start(node->v.d);
			while (item != NULL) {
				item = ben_free_item(node, item);
			}

			list_free(node->v.d);
		}
		break;

	case BEN_LIST:
		if (node->v.l != NULL) {
			item = list_start(node->v.l);
			while (item != NULL) {
				item = ben_free_item(node, item);
			}

			list_free(node->v.l);
		}
		break;
	case BEN_STR:
		if (node->v.s != NULL) {
			str_free(node->v.s);
		}
		break;
	}
}
示例#11
0
void p2p_cron_lookup_all(void)
{
	ITEM *i = list_start(_main->identity);
	ID *identity = NULL;

	while (i != NULL) {
		identity = list_value(i);

		if (_main->p2p->time_now.tv_sec > identity->time_announce_host) {
			p2p_cron_lookup(identity->host_id, P2P_ANNOUNCE_START);
			time_add_5_min_approx(&identity->time_announce_host);
		}

		i = list_next(i);
	}
}
示例#12
0
void cache_renew( time_t now ) {
	ITEM *item = NULL;
	CACHE *cache = NULL;

	item = list_start( _main->cache->list );
	while( item != NULL ) {

		/* Lookup target on my own every 5 minutes */
		cache = list_value( item );
		if( now > cache->renew ) {
			p2p_localhost_lookup_remote( cache->target, NULL );
			time_add_5_min_approx( &cache->renew );
		}

		item = list_next( item );
	}
}
示例#13
0
void cache_expire( time_t now ) {
	ITEM *item = NULL;
	ITEM *next = NULL;
	CACHE *cache = NULL;

	item = list_start( _main->cache->list );
	while( item != NULL ) {
		next = list_next( item );

		/* 30 minutes without activity. Kill it. */
		cache = list_value( item );
		if( now > cache->lifetime ) {
			cache_del( item );
		}

		item = next;
	}
}
示例#14
0
void mime_hash( void ) {
	ITEM *item = NULL;
	struct obj_mime *tuple = NULL;
	
	if( list_size( _main->mime->list ) < 1 ) {
		return;
	}

	/* Create hash */
	_main->mime->hash = hash_init( list_size( _main->mime->list ) + 10 );

	/* Hash list */
	item = list_start( _main->mime->list );
	while( item != NULL ) {
		tuple = item->val;
		hash_put( _main->mime->hash, (UCHAR *)tuple->key, strlen( tuple->key), tuple->val );
		item = list_next( item );
	}
}
示例#15
0
BEN *ben_dict_search_key(BEN * node, BEN * key)
{
	ITEM *item = NULL;
	BEN *thiskey = NULL;
	TUPLE *tuple = NULL;

	/* Tests */
	if (node == NULL) {
		return NULL;
	}
	if (node->t != BEN_DICT) {
		return NULL;
	}
	if (key == NULL) {
		return NULL;
	}
	if (key->t != BEN_STR) {
		return NULL;
	}
	if (node->v.d == NULL) {
		return NULL;
	}
	if (node->v.d->item == NULL) {
		return NULL;
	}

	item = list_start(node->v.d);

	do {
		tuple = list_value(item);
		thiskey = tuple->key;
		if (thiskey->v.s->i == key->v.s->i &&
		    memcmp(thiskey->v.s->s, key->v.s->s, key->v.s->i) == 0) {
			return tuple->val;
		}
		item = list_next(item);

	} while (item != NULL);

	return NULL;
}
示例#16
0
int encode(flatcc_builder_t *B, void *buffer, size_t *size)
{
    int i, veclen = 3;
    void *buffer_ok;

    flatcc_builder_reset(B);

    C(start_as_root(B));
    C(list_start(B, 0));
    for (i = 0; i < veclen; ++i) {
        /*
         * By using push_start instead of push_create we can construct
         * the sibling field (of Bar type) in-place on the stack,
         * otherwise we would need to create a temporary Bar struct.
         */
        C(list_push_start(B));
        FooBar(sibling_create(B,
                0xABADCAFEABADCAFE + i, 10000 + i, '@' + i, 1000000 + i,
                123456 + i, 3.14159f + i, 10000 + i));
        FooBar(name_create_str(B, "Hello, World!"));
        FooBar(rating_add(B, 3.1415432432445543543 + i));
        FooBar(postfix_add(B, '!' + i));
        C(list_push_end(B));
    }
    C(list_end(B));
    C(location_create_str(B, "https://www.example.com/myurl/"));
    C(fruit_add(B, Enum(Bananas)));
    C(initialized_add(B, True));
    C(end_as_root(B));

    /*
     * This only works with the default emitter and only if the buffer
     * is larger enough. Otherwise use whatever custom operation the
     * emitter provides.
     */
    buffer_ok = flatcc_builder_copy_buffer(B, buffer, *size);
    *size = flatcc_builder_get_buffer_size(B);
    return !buffer_ok;
}
示例#17
0
文件: tox.c 项目: Boerde/uTox
void tox_settingschanged(void)
{
    //free everything
    tox_connected = 0;
    list_freeall();

    list_dropdown_clear(&dropdown_audio_in);
    list_dropdown_clear(&dropdown_audio_out);
    list_dropdown_clear(&dropdown_video);

    tox_thread_init = 0;

    toxaudio_postmessage(AUDIO_KILL, 0, 0, NULL);
    toxvideo_postmessage(VIDEO_KILL, 0, 0, NULL);
    toxav_postmessage(TOXAV_KILL, 0, 0, NULL);

    tox_postmessage(0, 1, 0, NULL);

    while(!tox_thread_init) {
        yieldcpu(1);
    }

    list_start();
}
示例#18
0
文件: List.c 项目: kr094/c
void list_printall(list_t list) {
	list_start(list);
	list_print(list);
}
示例#19
0
文件: list.c 项目: stevedonovan/llib
/// insert data at the start of the list.
ListIter list_insert_front(List *ls, void *data) {
    return list_insert(ls,list_start(ls),data);
}
示例#20
0
void p2p_get_peers_get_values(BEN * values, UCHAR * node_id, ITEM * ti,
			      BEN * token, IP * from)
{

	UCHAR nodes_compact_list[IP_SIZE_META_PAIR8];
	UCHAR *p = nodes_compact_list;
	LOOKUP *l = tdb_ldb(ti);
	int nodes_compact_size = 0;
	BEN *val = NULL;
	ITEM *item = NULL;
	long int j = 0;
	char hex[HEX_LEN];

	if (l == NULL) {
		return;
	}

	ldb_update(l, node_id, token, from);

	/* Extract values and create a nodes_compact_list */
	item = list_start(values->v.l);
	while (item != NULL && j < 8) {
		val = list_value(item);

		if (!ben_is_str(val) || ben_str_i(val) != IP_SIZE_META_PAIR) {
			info(_log, from, "Values list broken from ");
			return;
		}

		memcpy(p, ben_str_s(val), ben_str_i(val));
		nodes_compact_size += IP_SIZE_META_PAIR;
		p += IP_SIZE_META_PAIR;

		item = list_next(item);
		j++;
	}

	if (nodes_compact_size <= 0) {
		return;
	}

	hex_hash_encode(hex, l->target);
	info(_log, from, "Found %s at", hex);

	/*
	 * Random lookups are not initiated by a client.
	 * Periodic announces are not initiated by a client either.
	 * And I do not want to cache random lookups.
	 */
	if (!l->send_response_to_initiator) {
		return;
	}

	/* Merge responses to the cache */
	cache_put(l->target, nodes_compact_list, nodes_compact_size);

	/* Do not send more than one DNS response to a client.
	 * The client is happy after getting the first response anyway.
	 */
	if (ldb_number_of_dns_responses(l) >= 1) {
		return;
	}

	/* Get the merged compact list from the cache. */
	nodes_compact_size = cache_compact_list(nodes_compact_list, l->target);
	if (nodes_compact_size <= 0) {
		return;
	}

	/* Send the result back via DNS */
	r_success(&l->c_addr, &l->msg, nodes_compact_list, nodes_compact_size);
}
示例#21
0
void exampleList()
{
	// Use pooling for efficiency, if you don't want to use pooling
	// then comment out this line.
	pool_list(16);

	List* L = newList();

	list_add(L, "a");
	list_add(L, "b");
	list_add(L, "c");
	list_add(L, "d");
	list_add(L, "e");
	list_add(L, "f");
	
	// Display the current list
	displayStrings(L);		//ABCDEF

	// Remove first item
	list_removeFirst(L);
	displayStrings(L);		//BCDEF
	
	// Add first item back
	list_addFirst(L, "a");
	displayStrings(L);

	list_clear(L);
	if (list_isEmpty(L))
		printf("List was cleared.\n");

	// Add some strings and remove all that begin with -
	int nums[] = {1, 2, 3, 4, 6, 7, 8};
	int x;
	for (x = 0; x < 7; x++)
		list_add(L, &nums[x]);

	displayIntegers(L);

	list_start(L);
	while (list_hasNext(L))
	{
		// get does not move the current node
		x = *((int*)list_peek(L));
		if (x % 2 == 0)
			// remove will remove the node from the list altogether and
			// return the data removed.
			list_remove(L);
		else
			// next will just goto the next node and return the data.
			list_next(L);
	}
	
	// Print out the odd numbers
	displayIntegers(L);

	// Try removing all while traversing
	list_start(L);
	while (list_hasNext(L))
		list_remove(L);
	
	displayIntegers(L);

	if (L->first == NULL && L->last == NULL && L->size == 0)
		printf("All cleaned up!\n");

	// Traverse through an array of strings and find any that start
	// with . and after it add 0 and add one before it that is -
	list_add(L, ".1");
	list_add(L, " two ");
	list_add(L, ".3");
	list_add(L, " four ");
	list_add(L, ".5");

	displayStrings(L);
	
	list_start(L);
	char* c;
	while (list_hasNext(L))
	{	
		c = (char*)list_peek(L);

		if (c[0] == '.')
		{
			list_insertBefore(L, "-");
			list_insertAfter(L, "0");
		}

		list_next(L);
	}
	displayStrings(L);

	char* first = (char*)L->first->data;
	char* last = (char*)L->last->data;
	if (first[0] == '-' && last[0] == '+')
		printf("Insertions correct.\n");

	// This will clear the list of any nodes and pool them and then free
	// the list itself from memory
	list_free(L);
	
	// If you're not using pooling this can be commented out. This will
	// free all pooled nodes from memory. Always call this at the end 
	// of using any List.
	unpool_list();
}
示例#22
0
LONG ben_enc_size(BEN * node)
{
	ITEM *item = NULL;
	TUPLE *tuple = NULL;
	char buf[BUF_SIZE];
	LONG size = 0;

	if (node == NULL) {
		return size;
	}

	switch (node->t) {
	case BEN_DICT:
		size += 2;	/* de */

		if (node->v.d == NULL) {
			return size;
		}

		if (node->v.d->item == NULL) {
			return size;
		}

		item = list_start(node->v.d);
		do {
			tuple = list_value(item);

			if (tuple->key != NULL && tuple->val != NULL) {
				size += ben_enc_size(tuple->key);
				size += ben_enc_size(tuple->val);
			}

			item = list_next(item);

		} while (item != NULL);

		break;

	case BEN_LIST:
		size += 2;	/* le */

		if (node->v.l == NULL) {
			return size;
		}

		if (node->v.l->item == NULL) {
			return size;
		}

		item = list_start(node->v.l);
		do {
			if (item->val != NULL) {
				size += ben_enc_size(item->val);
			}
			item = list_next(item);

		} while (item != NULL);

		break;

	case BEN_INT:
		snprintf(buf, BUF_SIZE, "i%lie", node->v.i);
		size += strlen(buf);
		break;

	case BEN_STR:
		snprintf(buf, BUF_SIZE, "%li:", node->v.s->i);
		size += strlen(buf) + node->v.s->i;
		break;

	}

	return size;
}
示例#23
0
UCHAR *ben_enc_rec(BEN * node, UCHAR * p)
{
	ITEM *item = NULL;
	TUPLE *tuple = NULL;
	char buf[BUF_SIZE];
	LONG len = 0;

	if (node == NULL || p == NULL) {
		return NULL;
	}

	switch (node->t) {
	case BEN_DICT:
		*p++ = 'd';

		if (node->v.d != NULL && node->v.d->item != NULL) {
			item = list_start(node->v.d);
			do {
				tuple = list_value(item);

				if (tuple->key != NULL && tuple->val != NULL) {
					if ((p =
					     ben_enc_rec(tuple->key,
							 p)) == NULL) {
						return NULL;
					}

					if ((p =
					     ben_enc_rec(tuple->val,
							 p)) == NULL) {
						return NULL;
					}
				}

				item = list_next(item);

			} while (item != NULL);
		}

		*p++ = 'e';
		break;

	case BEN_LIST:
		*p++ = 'l';

		if (node->v.l != NULL && node->v.l->item != NULL) {
			item = list_start(node->v.l);
			do {
				if ((p = ben_enc_rec(item->val, p)) == NULL) {
					return NULL;
				}

				item = list_next(item);

			} while (item != NULL);
		}

		*p++ = 'e';
		break;

	case BEN_INT:
		snprintf(buf, BUF_SIZE, "i%lie", node->v.i);
		len = strlen(buf);
		memcpy(p, buf, len);
		p += len;
		break;

	case BEN_STR:
		/* Meta */
		snprintf(buf, BUF_SIZE, "%li:", node->v.s->i);
		len = strlen(buf);
		memcpy(p, buf, len);
		p += len;
		/* Data */
		if (node->v.s->i > 0) {
			memcpy(p, node->v.s->s, node->v.s->i);
			p += node->v.s->i;
		}
		break;

	}

	return p;
}
示例#24
0
/*Main function pass command line arg for each of the files to parse*/
int main ( int argc, char *argv[] ) {
	int i;
	linkedlist *wlist = NULL;
	file_str *filestr;
	FILE *fp;
	char *linebuf;
	unsigned int buflen;
	char *word;
	word_str *wordstr;
	int linenum;
	int *linenump;

	if(argc <= 1)
	{
		printf("Sorry no files were given!");
		return(-1);
	}


	/*iterate through the files*/
	for(i=1;i<argc;i++)
	{
		linenum = 0;
		fp = fopen(argv[i],"r");
		if(fp == NULL)
		{
			printf("Bad filename detected\n");
			return(-1);
		}
		/*reading each line*/
		while(!feof(fp))
		{
			linenum++;
			/*allocate some mem for the line read*/
			buflen = BUFLEN;
			linebuf = (char*)malloc(sizeof(char)*buflen);
			if(linebuf == NULL)
			{
				printf("Could not allocate mem to read line from file!\n");
				return(-1);
			}
			fgets(linebuf,sizeof(char)*BUFLEN,fp);
			/*if there was not enough buffer length tack
			 *on some more and read more of the file
			 */

			while(1)
			{
				if(!(feof(fp)||(linebuf[strlen(linebuf)-1]=='\n')))
				{
					buflen += BUFLEN-1;
					linebuf = (char*)realloc(linebuf,sizeof(char)*buflen);
					if(linebuf == NULL)
					{
						/*The line was too long to read
						 *With some refactoring this operation could be split
						 *into multiple parsing.  Issue is insuring a word is not
						 *cut off
						 */
						printf("Could not allocate mem to read line from file!\n");
						return(-1);
					}
				}else{
					break;
				}
				if(fgets(&linebuf[buflen-BUFLEN],sizeof(char)*BUFLEN,fp)==NULL)
				{
					/*we reached eof and no data was read make sure that word
					 *is cleared nice
					 */
					word[0]='\n';
				}
			}
			/*break up the line into words based on delimeter string*/
			word = strtok(linebuf, WORDDEL);
			while(word != NULL &&!feof(fp))
			{
				/*see if the line was blank, skip it*/
				if(linebuf[0]=='\n')
					break;
				/*we dont want the 'word' and 'word\n' to be different*/
				if(word[strlen(word)-1]=='\n')
				{
					word[strlen(word)-1] = '\0';
				}
				/*record information about the file*/

				filestr = (file_str*)malloc(sizeof(file_str));
				if(filestr == NULL)
				{
					printf("Could not allocate mem to hold list for file name!\n");
					return(-1);
				}
				filestr->filename=(char*)malloc(sizeof(char)*strlen(argv[i]));
				if(filestr->filename == NULL)
				{
					printf("Could not allocate mem to store file name!\n");
					return(-1);
				}
				strcpy(filestr->filename,argv[i]);
				linenump = (int*)malloc(sizeof(int));
				*linenump = linenum;
				filestr->lines = list_start((void*)linenump);
				/*record information about the word*/
				wordstr = (word_str*)malloc(sizeof(word_str));
				if(wordstr == NULL)
				{
					printf("Could not allocate mem for word list storage!\n");
					return(-1);
				}
				wordstr->word = (char*)malloc(sizeof(char)*strlen(word));
				if(wordstr->word == NULL)
				{
					printf("Could not allocate mem to store word!\n");
					return(-1);
				}
				strcpy(wordstr->word,word);
				/*create the linked list of files for the word*/
				wordstr->files = list_start(filestr);
				/*Add the word to the linkedlist, determine if the list is new*/
				if(wlist==NULL)
					wlist = list_start(wordstr);
				else
					wlist = list_add(wlist,wordstr);
				/*clear out the word*/
				word = strtok(NULL, WORDDEL);
			}
			/*free all of the memmory that was allocated for the line*/
			free(linebuf);
		}
		/*close the file for the next file*/
		fclose(fp);
	}
	/*sort all of the words*/
	wlist = mergesort(wlist,wordcmp);
	/*combine the file linkedlists for dup words*/
	wlist = mergelist(wlist,wordcmp,wordmergepost);
	/*Desplay formated index*/
	display(wlist);
	return (0);
}
示例#25
0
文件: search.c 项目: dank101/net-2
dsEnqError srch_start()
{
  struct ds_search_arg search_arg;
  struct ds_search_result result;
  struct DSError          error;
  dsEnqError return_error;
  extern Filter make_filter();
  DN curr_rdn;

  if (*mvalue == '\0') {
    return list_start();
  }

  if (get_default_service (&search_arg.sra_common) != 0) {
    return nothingfound;
  }

  search_arg.sra_common.ca_servicecontrol.svc_options = SVC_OPT_PREFERCHAIN;

  curr_rdn = search_arg.sra_baseobject = (*base_path != 'T'?
					  str2dn (base_path):
					  NULLDN);

  search_arg.sra_eis.eis_allattributes = FALSE;
  search_arg.sra_eis.eis_infotypes = EIS_ATTRIBUTETYPESONLY;
  search_arg.sra_eis.eis_select = 0;
  search_arg.sra_searchaliases = TRUE;

  search_arg.sra_subset = SRA_ONELEVEL;
  while (curr_rdn != NULLDN) {
    if (!strcmp(curr_rdn->dn_rdn->rdn_at->oa_ot.ot_stroid, 
		"2.5.4.10")) {
      search_arg.sra_subset = SRA_WHOLESUBTREE;
      break;
    }
    curr_rdn = curr_rdn->dn_parent;
  }

  if ((search_arg.sra_filter = make_filter(filt_arr[typeindx])) == NULLFILTER)
    return duaerror;

#ifndef NO_STATS
  LLOG (log_stat, LLOG_NOTICE, ("search +%s, extent %d, val %s",
                                base_path,search_arg.sra_subset, mvalue));
#endif

  if(ds_search (&search_arg, &error, &result) != DS_OK) {
    /* deal with error */
    free_seq(dnseq);
    dnseq = NULLDS;
    dn_number = 0;
    log_ds_error(&error);
    ds_error_free(&error);
    switch (error.dse_type) {
    case DSE_LOCALERROR:
      return_error = duaerror;
      break;
    case DSE_REMOTEERROR:
      return_error = localdsaerror;
      break;
    case DSE_ATTRIBUTEERROR:
      return_error = attributerror;
      break;
    case DSE_REFERRAL:
    case DSE_DSAREFERRAL:
      return_error = remotedsaerror;
      break;
    case DSE_SECURITYERROR:
      return_error = security;
      break;
    case DSE_NAMEERROR:
      return_error = namerror;
      break;
    case DSE_SERVICEERROR:
      return_error = serviceerror;
      break;
    default:
      return_error = localdsaerror;
      break;
    }
  } else {
    correlate_search_results (&result);
    dn_number = 0;

    if (result.CSR_entries != NULLENTRYINFO) {
      register EntryInfo *ptr;

      return_error = Okay;
      free_seq(dnseq);
      dnseq = NULLDS;
      dn_number = 0;

      for (ptr = result.CSR_entries;
           ptr != NULLENTRYINFO; 
	   ptr = ptr->ent_next){
        dn_number++;
        dn2buf((caddr_t) ptr->ent_dn, goto_path);
        add_seq(&dnseq, goto_path);
      }

      if (dn_number) dnseq = SortList(dnseq);
    } else if (result.CSR_limitproblem == LSR_NOLIMITPROBLEM) {
      free_seq(dnseq);
      dnseq = NULLDS;
      dn_number = 0;
      return_error = nothingfound;
    }

    if(result.CSR_limitproblem != LSR_NOLIMITPROBLEM) {
      switch (result.CSR_limitproblem) {
      case LSR_TIMELIMITEXCEEDED:
	if (dn_number > 0) return_error = timelimit_w_partial;
	else {
	  free_seq(dnseq);
	  dnseq = NULLDS;
	  return_error = timelimit;
	}
	break;
      case LSR_SIZELIMITEXCEEDED:
	return_error = listsizelimit;
	break;
      case LSR_ADMINSIZEEXCEEDED:
	if (dn_number > 0) return_error = adminlimit_w_partial;
	else {
	  free_seq(dnseq);
	  dnseq = NULLDS;
	  return_error = adminlimit;
	}
	break;
      }
      entryinfo_free(result.CSR_entries, 0);
    }
  }
  entry_number = dn_number;
  filter_free(search_arg.sra_filter);
  dn_free(search_arg.sra_baseobject);
  ds_error_free(&error);
  return return_error;
}