Example #1
0
void sparser (BB *btree, char fl, int N, char *idx_path) {
	Qlist *query = qlist_create();
	int i=0;
	unsigned int ch;
	char *word = (char*)malloc(sizeof(char)*80);
	int state = INIT;
	int numb_query = 0;
	int count_word = 0;
	while ((ch = getchar())!=EOF) {
		if (i>80) {
// 			printf ("I'm here\n");
 			char *tmp = (char *)realloc(word, 10000);
			word = tmp;
 		}
 		if (state == INIT) {
			if (ch == '\n') {
				word[i++] = '\0';
				if (!(isspace(word[0]) || word[0]=='\0' || ispoint(word[0]))) {
					qlist_insert(query,word,i);
					memset(word,0,i);
					count_word++;
					numb_query++;
				}
				i=0;
				query_find(btree,query,count_word,fl,numb_query,N);
// 				qlist_prn(query);
				qlist_clear(query);
				state = INIT;
				count_word=0;
				continue;
			}
			if (isalnum(ch)) {
				state = SB;
				word[i] = tolower(ch);
				i++;
				continue;
			}
			else {
				state = INIT;
				continue;
			}
		}
		if (state == LF) {
			word[i++] = '\0';
			qlist_insert(query,word,i);
			memset(word,0,i);
			i=0;
			count_word++;
			numb_query++;
			query_find(btree,query,count_word,fl,numb_query,N);
// 			qlist_prn(query);
			qlist_clear(query);
			state = INIT;
			count_word=0;
		}
		if (state == SB) {
			if (isalnum(ch) || ch =='\'' || ch == '-') {
				word[i++]=tolower(ch);
				continue;
			}
			if (ch == '\n') {
				word[i++] = '\0';
				qlist_insert(query,word,i);
				memset(word,0,i);
				i=0;
				count_word++;
				numb_query++;
				query_find(btree,query,count_word,fl,numb_query,N);
// 				qlist_prn(query);
				qlist_clear(query);
				state = INIT;
				count_word=0;
				continue;
			}
			else {
				word[i] = '\0'; i++;
				qlist_insert(query,word,i);
				memset(word,0,i);
				i=0;
				state = INIT;
				count_word++;
			}
		}
	}
	
	printf ("searching queries have finished\n");
	
}
Example #2
0
/**
 * qlist->free(): Free qlist_t.
 *
 * @param list  qlist_t container pointer.
 */
void qlist_free(qlist_t *list) {
    qlist_clear(list);
    Q_MUTEX_DESTROY(list->qmutex);

    free(list);
}
static void qlist_set(t_qlist *x, t_symbol *s, int ac, t_atom *av)
{
    qlist_clear(x);
    qlist_add(x, s, ac, av);
}