| 944 | */ |
| 945 | |
| 946 | http_uri_status_t /* O - Result of separation */ |
| 947 | httpSeparateURI( |
| 948 | http_uri_coding_t decoding, /* I - Decoding flags */ |
| 949 | const char *uri, /* I - Universal Resource Identifier */ |
| 950 | char *scheme, /* O - Scheme (http, https, etc.) */ |
| 951 | int schemelen, /* I - Size of scheme buffer */ |
| 952 | char *username, /* O - Username */ |
| 953 | int usernamelen, /* I - Size of username buffer */ |
| 954 | char *host, /* O - Hostname */ |
| 955 | int hostlen, /* I - Size of hostname buffer */ |
| 956 | int *port, /* O - Port number to use */ |
| 957 | char *resource, /* O - Resource/filename */ |
| 958 | int resourcelen) /* I - Size of resource buffer */ |
| 959 | { |
| 960 | char *ptr, /* Pointer into string... */ |
| 961 | *end; /* End of string */ |
| 962 | const char *sep; /* Separator character */ |
| 963 | http_uri_status_t status; /* Result of separation */ |
| 964 | |
| 965 | |
| 966 | /* |
| 967 | * Initialize everything to blank... |
| 968 | */ |
| 969 | |
| 970 | if (scheme && schemelen > 0) |
| 971 | *scheme = '\0'; |
| 972 | |
| 973 | if (username && usernamelen > 0) |
| 974 | *username = '\0'; |
| 975 | |
| 976 | if (host && hostlen > 0) |
| 977 | *host = '\0'; |
| 978 | |
| 979 | if (port) |
| 980 | *port = 0; |
| 981 | |
| 982 | if (resource && resourcelen > 0) |
| 983 | *resource = '\0'; |
| 984 | |
| 985 | /* |
| 986 | * Range check input... |
| 987 | */ |
| 988 | |
| 989 | if (!uri || !port || !scheme || schemelen <= 0 || !username || |
| 990 | usernamelen <= 0 || !host || hostlen <= 0 || !resource || |
| 991 | resourcelen <= 0) |
| 992 | return (HTTP_URI_STATUS_BAD_ARGUMENTS); |
| 993 | |
| 994 | if (!*uri) |
| 995 | return (HTTP_URI_STATUS_BAD_URI); |
| 996 | |
| 997 | /* |
| 998 | * Grab the scheme portion of the URI... |
| 999 | */ |
| 1000 | |
| 1001 | status = HTTP_URI_STATUS_OK; |
| 1002 | |
| 1003 | if (!strncmp(uri, "//", 2)) |