#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <stddef.h>

int main(int argc,char *argv[])
{
char req[128];
char *http_ptr;
char buff1[256];
char buff2[256];
char buff3[256];
int i=0;
char *pt;

	if(argc!=2)
	{
	perror("wrong arguments\n"); 
        exit(0);
        }
            /** Check for http word in the string **/        
            if (strncmp("http://",argv[1],7)==0||strncmp("HTTP://",argv[1],7)==0) 
            { 
	    	printf("http is there\n"); 
                http_ptr=strchr(argv[1],'/');
            	http_ptr=http_ptr+2; 
	        while(*http_ptr!='\0')  
            	{
                buff1[i++]=*http_ptr;  
          	http_ptr++;
            	} 
                buff1[i]='\0';
            	printf("Buffer1 is %s\n",buff1);
            }   

            else
		printf("NO http\n");
                //printf("%s\n",argv[1]);
                i=0; 
             

            /** Extract file and FQDN from buff1 now **/
                 
                  

		/** extract file name from the input line **/
		pt=strrchr(buff1,'/');
 	            if(pt!=NULL)
        	    {	
               		pt=pt+1;
                	while(*pt!='\0')
                	{
			buff2[i++]=*pt;
                	pt++; 
			}
			buff2[i]='\0';
                	printf("Buffer2 is %s\n",buff2);	
                    }
		    else
		       {	
		       printf("No file specified\n"); 		
		       exit (0);
		       }		
	    
		/** Extract FQDN from the input line **/
		i=0;
		while(buff1[i]!='/')
		{
		buff3[i++]=buff1[i];
		}
		buff3[i]='\0';
		printf("Buffer3 is %s\n",buff3);
	        	
} 
