void url_split(char *proto, int proto_size,

               char *hostname, int hostname_size,

               int *port_ptr,

               char *path, int path_size,

               const char *url)

{

    const char *p;

    char *q;

    int port;



    port = -1;



    p = url;

    q = proto;

    while (*p != ':' && *p != '\0') {

        if ((q - proto) < proto_size - 1)

            *q++ = *p;

        p++;

    }

    if (proto_size > 0)

        *q = '\0';

    if (*p == '\0') {

        if (proto_size > 0)

            proto[0] = '\0';

        if (hostname_size > 0)

            hostname[0] = '\0';

        p = url;

    } else {

        p++;

        if (*p == '/')

            p++;

        if (*p == '/')

            p++;

        q = hostname;

        while (*p != ':' && *p != '/' && *p != '?' && *p != '\0') {

            if ((q - hostname) < hostname_size - 1)

                *q++ = *p;

            p++;

        }

        if (hostname_size > 0)

            *q = '\0';

        if (*p == ':') {

            p++;

            port = strtoul(p, (char **)&p, 10);

        }

    }

    if (port_ptr)

        *port_ptr = port;

    pstrcpy(path, path_size, p);

}

void url_split(char *proto, int proto_size,

               char *hostname, int hostname_size,

               int *port_ptr,

               char *path, int path_size,

               const char *url)

{

    const char *p;

    char *q;

    int port;



    port = -1;



    p = url;

    q = proto;

    while (*p != ':' && *p != '\0') {

        if ((q - proto) < proto_size - 1)

            *q++ = *p;

        p++;

    }

    if (proto_size > 0)

        *q = '\0';

    if (*p == '\0') {

        if (proto_size > 0)

            proto[0] = '\0';

        if (hostname_size > 0)

            hostname[0] = '\0';

        p = url;

    } else {

        p++;

        if (*p == '/')

            p++;

        if (*p == '/')

            p++;

        q = hostname;

        while (*p != ':' && *p != '/' && *p != '?' && *p != '\0') {

            if ((q - hostname) < hostname_size - 1)

                *q++ = *p;

            p++;

        }

        if (hostname_size > 0)

            *q = '\0';

        if (*p == ':') {

            p++;

            port = strtoul(p, (char **)&p, 10);

        }

    }

    if (port_ptr)

        *port_ptr = port;

    pstrcpy(path, path_size, p);

}

void FUNC_0(char *VAR_0, int VAR_1,

               char *VAR_2, int VAR_3,

               int *VAR_4,

               char *VAR_5, int VAR_6,

               const char *VAR_7)

{

    const char *VAR_8;

    char *VAR_9;

    int VAR_10;



    VAR_10 = -1;



    VAR_8 = VAR_7;

    VAR_9 = VAR_0;

    while (*VAR_8 != ':' && *VAR_8 != '\0') {

        if ((VAR_9 - VAR_0) < VAR_1 - 1)

            *VAR_9++ = *VAR_8;

        VAR_8++;

    }

    if (VAR_1 > 0)

        *VAR_9 = '\0';

    if (*VAR_8 == '\0') {

        if (VAR_1 > 0)

            VAR_0[0] = '\0';

        if (VAR_3 > 0)

            VAR_2[0] = '\0';

        VAR_8 = VAR_7;

    } else {

        VAR_8++;

        if (*VAR_8 == '/')

            VAR_8++;

        if (*VAR_8 == '/')

            VAR_8++;

        VAR_9 = VAR_2;

        while (*VAR_8 != ':' && *VAR_8 != '/' && *VAR_8 != '?' && *VAR_8 != '\0') {

            if ((VAR_9 - VAR_2) < VAR_3 - 1)

                *VAR_9++ = *VAR_8;

            VAR_8++;

        }

        if (VAR_3 > 0)

            *VAR_9 = '\0';

        if (*VAR_8 == ':') {

            VAR_8++;

            VAR_10 = strtoul(VAR_8, (char **)&VAR_8, 10);

        }

    }

    if (VAR_4)

        *VAR_4 = VAR_10;

    pstrcpy(VAR_5, VAR_6, VAR_8);

}

void FUNC_0(char *VAR_0, int VAR_1,
char *VAR_2, int VAR_3,
int *VAR_4,
char *VAR_5, int VAR_6,
const char *VAR_7)
{ const char *VAR_8; char *VAR_9; int VAR_10; VAR_10 = -1; VAR_8 = VAR_7; VAR_9 = VAR_0; while (*VAR_8 != ':' && *VAR_8 != '\0') { if ((VAR_9 - VAR_0) < VAR_1 - 1)
*VAR_9++ = *VAR_8; VAR_8++; } if (VAR_1 > 0)
*VAR_9 = '\0'; if (*VAR_8 == '\0') { if (VAR_1 > 0)
VAR_0[0] = '\0'; if (VAR_3 > 0)
VAR_2[0] = '\0'; VAR_8 = VAR_7; } else { VAR_8++; if (*VAR_8 == '/')
VAR_8++; if (*VAR_8 == '/')
VAR_8++; VAR_9 = VAR_2; while (*VAR_8 != ':' && *VAR_8 != '/' && *VAR_8 != '?' && *VAR_8 != '\0') { if ((VAR_9 - VAR_2) < VAR_3 - 1)
*VAR_9++ = *VAR_8; VAR_8++; } if (VAR_3 > 0)
*VAR_9 = '\0'; if (*VAR_8 == ':') { VAR_8++; VAR_10 = strtoul(VAR_8, (char **)&VAR_8, 10); } } if (VAR_4)
*VAR_4 = VAR_10; pstrcpy(VAR_5, VAR_6, VAR_8); }