]> mj.ucw.cz Git - libucw.git/blobdiff - ucw/url.c
option parser: Empty stub of the documentation
[libucw.git] / ucw / url.c
index 7145af5f764e80b9b9ed60cd223743a76093b008..6d940018d2165acbb27124bb094a16ff958bcc0a 100644 (file)
--- a/ucw/url.c
+++ b/ucw/url.c
  *     XXX: The buffer handling in this module is really horrible, but it works.
  */
 
-#include "ucw/lib.h"
-#include "ucw/url.h"
-#include "ucw/chartype.h"
-#include "ucw/conf.h"
-#include "ucw/prime.h"
+#include <ucw/lib.h>
+#include <ucw/url.h>
+#include <ucw/chartype.h>
+#include <ucw/conf.h>
+#include <ucw/prime.h>
 
 #include <string.h>
 #include <stdlib.h>
@@ -30,6 +30,7 @@ static uns url_min_repeat_count = 0x7fffffff;
 static uns url_max_repeat_length = 0;
 static uns url_max_occurences = ~0U;
 
+#ifndef TEST
 static struct cf_section url_config = {
   CF_ITEMS {
     CF_UNS("IgnoreSpaces", &url_ignore_spaces),
@@ -46,6 +47,7 @@ static void CONSTRUCTOR url_init_config(void)
 {
   cf_declare_section("URL", &url_config, 0);
 }
+#endif
 
 /* Escaping and de-escaping */
 
@@ -135,15 +137,15 @@ url_enescape(const char *s, char *d)
       if (d >= end)
        return URL_ERR_TOO_LONG;
       if (Calnum(c) ||                                                 /* RFC 2396 (2.1-2.3): Only alphanumerics ... */
-         c == '-' || c == '_' || c == '.' || c == '+' || c == '~' ||   /* ... and several other exceptions ... */
-         c == '!' || c == '*' || c == '\'' || c == '(' || c == ')' ||
-         c == '/' || c == '?' || c == ':' || c == '@' ||               /* ... and reserved chars used for reserved purpose */
-         c == '=' || c == '&' || c == '#' || c == ';' ||
-         c == '$' || c == '+' || c == ',')
+         c == '!' || c == '*' || c == '\'' || c == '(' || c == ')' ||  /* ... and some exceptions and reserved chars */
+         c == '$' || c == '-' || c == '_' || c == '.' || c == '+' ||
+         c == ',' || c == '=' || c == '&' || c == '#' || c == ';' ||
+         c == '/' || c == '?' || c == ':' || c == '@' || c == '~'
+       )
        *d++ = *s++;
       else
        {
-         uns val = ((byte)*s < NCC_MAX) ? NCC_CHARS[(byte)*s] : *s;
+         uns val = (byte)(((byte)*s < NCC_MAX) ? NCC_CHARS[(byte)*s] : *s);
          *d++ = '%';
          *d++ = enhex(val >> 4);
          *d++ = enhex(val & 0x0f);
@@ -163,14 +165,14 @@ url_enescape_friendly(const char *src, char *dest)
     {
       if (dest >= end)
        return URL_ERR_TOO_LONG;
-      if (*srcb < NCC_MAX)
+      if ((byte)*srcb < NCC_MAX)
        *dest++ = NCC_CHARS[*srcb++];
       else if (*srcb >= 0x20 && *srcb < 0x7f)
        *dest++ = *srcb++;
       else
        {
          *dest++ = '%';
-         *dest++ = enhex(*srcb >> 4);
+         *dest++ = enhex((byte)*srcb >> 4);
          *dest++ = enhex(*srcb++ & 0x0f);
        }
     }
@@ -184,7 +186,7 @@ char *url_proto_names[URL_PROTO_MAX] = URL_PNAMES;
 static int url_proto_path_flags[URL_PROTO_MAX] = URL_PATH_FLAGS;
 
 uns
-identify_protocol(const char *p)
+url_identify_protocol(const char *p)
 {
   uns i;
 
@@ -212,7 +214,7 @@ url_split(char *s, struct url *u, char *d)
          while (s < p)
            *d++ = *s++;
          *d++ = 0;
-         u->protoid = identify_protocol(u->protocol);
+         u->protoid = url_identify_protocol(u->protocol);
          s++;
          if (url_proto_path_flags[u->protoid] && (s[0] != '/' || s[1] != '/'))
            {
@@ -512,7 +514,7 @@ url_pack(struct url *u, char *d)
     {
       d = append(d, u->protocol, e);
       d = append(d, ":", e);
-      u->protoid = identify_protocol(u->protocol);
+      u->protoid = url_identify_protocol(u->protocol);
     }
   if (u->host)
     {