This example_uri page provides an example of librnr support for Uniform Resource Identifier (URI) parsing.
Example main():
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <stdarg.h>
#define SAFESTR(s) ((s) != NULL? s: "")
static char *
strip(
char *s)
{
size_t n;
char *t;
while( *s && isspace((int)*s))
{
s++;
}
if( *s == '\0' )
{
return s;
}
n = strlen(s);
t = s + n - 1;
while( (t > s) && isspace((int)*t))
{
t--;
}
t++;
*t = '\0';
return s;
}
int main(
int argc,
char *argv[])
{
char buf[256];
char *sCmd;
char *sUri;
printf("Uniform Resource Indentifier Example.\n");
printf(" (enter 'quit' to quit programe)\n\n");
for(;;)
{
printf("enter uri> ");
if( !fgets(buf, (int)sizeof(buf), stdin) )
{
break;
}
if( (*sCmd == '\0') || (*sCmd == '\n') )
{
continue;
}
else if( !strcmp(sCmd, "quit") )
{
break;
}
else
{
printf("UriParseNew() ->\n");
printf("{\n");
printf("}\n");
printf(
"UriStrNew() -> \"%s\"\n",
SAFESTR(sUri));
delete(sUri);
printf("UriDelete() -> deleted\n");
}
}
return 0;
}