Browse Source

parse_url() is void.

tags/v0.9.3
Michael Brown 19 years ago
parent
commit
044b20385b
1 changed files with 8 additions and 1 deletions
  1. 8
    1
      src/core/url.c

+ 8
- 1
src/core/url.c View File

8
  *
8
  *
9
  *   [protocol://[host][:port]/]path/to/file
9
  *   [protocol://[host][:port]/]path/to/file
10
  *
10
  *
11
- * We return true for success, 0 for failure (e.g. unknown protocol).
12
  * The URL string will be modified by having NULs inserted after
11
  * The URL string will be modified by having NULs inserted after
13
  * "protocol", "host" and "port".  The original URL can be
12
  * "protocol", "host" and "port".  The original URL can be
14
  * reconstructed by calling unparse_url.
13
  * reconstructed by calling unparse_url.
17
 void parse_url ( struct url_info *info, char *url ) {
16
 void parse_url ( struct url_info *info, char *url ) {
18
 	char *p;
17
 	char *p;
19
 
18
 
19
+	DBG ( "URL parsing \"%s\"\n", url );
20
+
20
 	/* Zero the structure */
21
 	/* Zero the structure */
21
 	memset ( info, 0, sizeof ( *info ) );
22
 	memset ( info, 0, sizeof ( *info ) );
22
 
23
 
44
 			}
45
 			}
45
 		}
46
 		}
46
 		info->file = p;
47
 		info->file = p;
48
+		DBG ( "URL protocol \"%s\" host \"%s\" port \"%s\" "
49
+		      "file \"%s\"\n", info->protocol, info->host,
50
+		      info->port ? info->port : "(NONE)", info->file );
47
 		return;
51
 		return;
48
 	}
52
 	}
49
 
53
 
50
 	/* URL has no explicit protocol; is just a filename */
54
 	/* URL has no explicit protocol; is just a filename */
51
 	info->file = url;
55
 	info->file = url;
56
+	DBG ( "URL file \"%s\"\n", info->file );
52
 }
57
 }
53
 
58
 
54
 /*
59
 /*
63
 			info->port[-1] = ':';
68
 			info->port[-1] = ':';
64
 		}
69
 		}
65
 		info->host[-3] = ':';
70
 		info->host[-3] = ':';
71
+		DBG ( "URL reconstructed \"%s\"\n", info->protocol );
66
 		return info->protocol;
72
 		return info->protocol;
67
 	} else {
73
 	} else {
68
 		/* URL had no protocol; was just a filename */
74
 		/* URL had no protocol; was just a filename */
75
+		DBG ( "URL reconstructed \"%s\"\n", info->file );
69
 		return info->file;
76
 		return info->file;
70
 	}
77
 	}
71
 }
78
 }

Loading…
Cancel
Save