|
|
@ -7,6 +7,7 @@ struct URL_s {
|
|
|
|
char* hostname;
|
|
|
|
char* hostname;
|
|
|
|
char* port;
|
|
|
|
char* port;
|
|
|
|
char* filepath;
|
|
|
|
char* filepath;
|
|
|
|
|
|
|
|
char* url_str;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
char* get_schema(URL* url) {
|
|
|
|
char* get_schema(URL* url) {
|
|
|
@ -26,11 +27,15 @@ char* get_filepath(URL* url) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
char* url_to_str(URL* url) {
|
|
|
|
|
|
|
|
return url->url_str;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
URL* new_url(char* url_str) {
|
|
|
|
URL* new_url(char* url_str) {
|
|
|
|
char* url_dup = strdup(url_str);
|
|
|
|
|
|
|
|
URL* url = malloc(sizeof(struct URL_s));
|
|
|
|
URL* url = malloc(sizeof(struct URL_s));
|
|
|
|
|
|
|
|
url->url_str = strdup(url_str);
|
|
|
|
|
|
|
|
|
|
|
|
url->schema = strtok(url_dup,":");
|
|
|
|
url->schema = strtok(url->url_str,":");
|
|
|
|
|
|
|
|
|
|
|
|
url->hostname = strtok(NULL,"/");
|
|
|
|
url->hostname = strtok(NULL,"/");
|
|
|
|
|
|
|
|
|
|
|
|