ast_comparator/test/playground/proxy.c
/*
 * parse_uri - URI parser
 * 
 * Given a URI from an HTTP proxy GET request (i.e., a URL), extract
 * the host name, path name, and port.  The memory for hostname and
 * pathname must already be allocated and should be at least MAXLINE
 * bytes. Return -1 if there are any problems.
 */
URI parser

Given a URI from an HTTP proxy GET request , extract
the host name, path name, and port.  The memory for hostname and
pathname must already be allocated and should be at least MAXLINE
bytes. Return -1 if there are any problems.
URI parser Given a URI from an HTTP proxy GET request extract the host name path name and port . The memory for hostname and pathname must already be allocated and should be at least MAXLINE bytes . Return - 1 if there are any problems .
int parse_uri(char *uri, char *hostname, char *pathname, int *port)
{
    char *hostbegin;
    char *hostend;
    char *pathbegin;
    int len;
    hostbegin = uri + 7;
    hostend = strpbrk(hostbegin, " :/\r\n\0");
    len = hostend - hostbegin;
    strncpy(hostname, hostbegin, len);
    hostname[len] = '\0';
    return 0;
}
int parse_uri ( char * uri , char * hostname , char * pathname , int * port ) { char * hostbegin ; char * hostend ; char * pathbegin ; int len ; hostbegin = uri + 7 ; hostend = strpbrk ( hostbegin , " \r \n \0 " ) ; len = hostend - hostbegin ; strncpy ( hostname , hostbegin , len ) ; hostname [ len ] = ' \0 ' ; return 0 ; }
parse_uri - URI parser
parse_uri - URI parser
/*  if (strncasecmp(uri, "http://", 7) != 0) {
	hostname[0] = '\0';
	return -1;
    }
   */ /*  *port = 80; 
    if (*hostend == ':')   
	*port = atoi(hostend + 1);
    
    pathbegin = strchr(hostbegin, '/');
    if (pathbegin == NULL) {
	pathname[0] = '\0';
    }
    else {
	pathbegin++;	
	strcpy(pathname, pathbegin);
    }
*/