
URI Split does nothing more than split an URI string. It does that by searching the string for key characters like : and / in the URI. Once identified its parts (protocol, hostname, port, etc) URI Split fills in a struct with that information so you can retrieve the URI parts without parsing it again.
Installing URI Split it's really simple.
While URI Split was being (or is being) coded, I kept one single word in mind: simplicity. I was tired of the search for a library that was easy to use and small at the same time. I realized that if such library existed it was really hard to find, so I made it myself.
Here's a sample code:
#include <stdio.h>
#include <stdlib.h>
#include "urisplit.h"
int main(int argc, char ** argv) {
if (argc < 2) return 0;
struct spluri * inuri;
char * string;
inuri = urisplit(argv[1]);
uriset(inuri, &inuri->username, "newusername");
string = urijoin(inuri);
printf("username: %s\n", inuri->username);
printf("password: %s\n", inuri->password);
printf("host: %s\n", inuri->host);
printf("port: %s\n", inuri->port);
printf("path: %s\n", inuri->path);
printf("proto: %s\n", inuri->proto);
printf("\nuri: %s\n", string);
free(string);
urifree(inuri);
return 0;
}
Now we must compile it:
gcc uri.c -o uri -lurisplit