Exemple #1
0
int yylval_token (int symbol) {
   int offset = scan_offset - yyleng;
   char *lexeme = inserthash(&stringset, yytext);
   yylval = new_astree (symbol, filename_stack.last_filenr,
                        scan_linenr, offset, lexeme);
   addtokens(yylval);
   add_hashstack( identstack, lexeme);
   return symbol;
}
Exemple #2
0
int main() {
    Hash htable;
    Avl key;

    assert(mkhash(&htable, 5) == 0);

    inserthash(&htable, &key);

    Avl *a = lookuphash(&htable, &key);

    printf("%p\n", a);
}
int main(int argc,char* argv[]) 
{ 
   
	//wget() for validating URL --without proxy--
	if(!system("wget --spider argv[1]"))
    printf("Valid URL\n");
    else
    printf("Invalid URL\n");
    
  struct hash h[HASH_size]; 
  
		  for(int i=0;i<HASH_size;i++)
			{
			h[i].head1=NULL;
			h[i].tail1=NULL;
			h[i].countlinks=0;
			}
	
	int links=0;
	int *totallinks=&links;
	
 for(int k=0;k<174;k++)
	{ 
	int counter=k;
	 if(counter==0)
	getpage(argv[1]);
	else
	{
	struct node *t=head;
		while(counter!=1)
		{
		t=t->next;
		counter--;
		}
		getpage(t->u.str);
	}
	//to get the size of file in which wget gets the html code

	struct stat st; //variable which will count length of file.

	printf(" file exits if 0 and do not exists if not equal to 0::%d\n", stat("/home/prince/study/crawler/files/temp.txt",&st));

	long int file_size=st.st_size;

	printf(" size of file is %ld\n",file_size);

	//allocating size to filevalistr
	char *filevalistr=(char *)malloc(sizeof(char)*(file_size+1));

	//copying html file data into filevalistr
	int i=0;

	FILE *fptr=fopen("/home/prince/study/crawler/files/temp.txt","r");

	if(fptr == NULL)
	{
	printf("file not found\n");
	exit(1);
	}

	char ch;
	ch=getc(fptr);

	while(ch != EOF)
	{
		filevalistr[i++]=ch;
		ch=getc(fptr);
	}

	//filevalistr[i++]='\0';
	fclose(fptr);
	
 	char p[50]={0};
   // printf("hey p is%s\n",p);
    int fileno=k;
    createpathforfile(p,fileno);
    fptr=fopen(p,"w");
    fprintf(fptr,"%s",filevalistr);
	//finalsize mein finalstring k andar jitni rows store hai unka size hai
	int finalsize;
	int *ptr=&finalsize;


	//printf("filevali str is \n %s\n",filevalistr);
	char **finalstorestr=extracturls(filevalistr,ptr);

	//printfinalstore(finalsize,finalstorestr);
	
	int key;
	
	for(int i=0;i<finalsize;i++)
	{
	key=hash(finalstorestr[i]);
	inserthash(h,key,finalstorestr[i],3,totallinks);
	}
	
}
printlist();
printf("total no of links are %d\n",*totallinks);

}