Sergi Vladykin 2fa40dd436
Zig CC cross-compilation support for Windows on Linux host. (#128)
Zig CC cross-compilation support for Windows on Linux host
2023-12-21 10:50:39 +03:00
..
2022-02-05 00:11:52 +03:00
2023-06-06 20:26:34 +03:00
2023-06-06 20:26:34 +03:00

URI Parser

Overview

  • URI parser but not a full-featured one. It just splits parts of a url.
  • Internally, it does a single allocation but each part is represented as null
    terminated string, so it plays nicely with C string functions.

Usage

#include "sc_uri.h"

#include <stdio.h>


int main(int argc, char *argv[])
{
    struct sc_uri *uri;
    uri = sc_uri_create("http://user:pass@any.com:8042/over/there?name=jane#doe");
    printf("%s \n", uri->str);       // prints "http://user:pass@any.com:8042/over/there?name=jane#doe"
    printf("%s \n", uri->scheme);    // prints "http"
    printf("%s \n", uri->host);      // prints "any.com"
    printf("%s \n", uri->userinfo);  // prints "user:pass"
    printf("%s \n", uri->port);      // prints "8042"
    printf("%s \n", uri->path);      // prints "/over/there"
    printf("%s \n", uri->query);     // prints "name=jane"
    printf("%s \n", uri->fragment);  // prints "doe"

    sc_uri_destroy(uri);

    return 0;
}