#include "def.h"
extern FILE *fpbtree;
extern int sqCount;	/* statistics: # of successf. queries asked */
extern int uqCount;	/* # of unsuccessf. queries */

ss_search(key, flag)
char    *key;
int     flag;
{

	int ss_treesearch();
	//POSTINGSPTR pptr;
	int count;

    /* Print an error message if strlen(key) > MAXWORDSIZE */
    if (strlen(key) > MAXWORDSIZE) {
        printf ("ERROR in \"search\":  Length of key Exceeds Maximum Allowed\n");
        printf (" and key May Be Truncated\n");
    }
    //if( iscommon(key) ) {
        //printf("\"%s\" is a common word - no searching is done\n",key);
        //return;
    //}
    if( check_word(key) == FALSE ) {
        return;
    }
    /* turn to lower case, for uniformity */
    strtolow(key);

    count = ss_treesearch(ROOT,key);
	//if( pptr == NONEXISTENT) {
	if( count == 0) {
        printf("key \"%s\": not found\n", key);
        uqCount++;
    } else {
		printf("\"%s\" is in %d words\n", key, count);
	}
	//else {
        //if(flag) {
			//int i = 0;
			//for(i = 0; i < ppts.count; i++) {
				//getpostings(vector_get(&ppts,i));
			//}
			////getpostings(pptr);
            //sqCount++;
        //} else {
            //printf("Found the key!\n");
        //}
    //}
	//vector_free(&ppts);

}
