Revision: 14699
Author: adrian.chadd
Date: Wed May 26 02:10:52 2010
Log: Implement an alternative, mostly-not-stdio-using,slightly inefficent
version of the HTTP URL assembly function.


http://code.google.com/p/lusca-cache/source/detail?r=14699

Modified:
 /branches/LUSCA_HEAD/libsqurl/url.c
 /branches/LUSCA_HEAD/libsqurl/url.h

=======================================
--- /branches/LUSCA_HEAD/libsqurl/url.c Sun May 23 07:03:12 2010
+++ /branches/LUSCA_HEAD/libsqurl/url.c Wed May 26 02:10:52 2010
@@ -122,3 +122,64 @@

        return len;
 }
+
+int
+urlMakeHttpCanonical2(char *urlbuf, protocol_t protocol, const char *login,
+    const char *host, int port, const char *urlpath, int urlpath_len)
+{
+       LOCAL_ARRAY(char, buf, MAX_URL);
+       LOCAL_ARRAY(char, portbuf, 32);
+       LOCAL_ARRAY(char, loginbuf, MAX_LOGIN_SZ + 1);
+       char *t;
+       int i, j;
+       const char *s;
+       static const char ts[] = "://";
+
+       portbuf[0] = '\0';
+       if (port != urlDefaultPort(protocol))
+               snprintf(portbuf, 32, ":%d", port);
+
+       loginbuf[0] = '\0';
+       if ((int) strlen(login) > 0) {
+               strcpy(loginbuf, login);
+               if ((t = strchr(loginbuf, ':')))
+                       *t = '\0';
+               strcat(loginbuf, "@");
+       }
+
+       /*
+ * This stuff would be better if/when each of these strings is a String with
+        * a known length..
+       */
+       s = ProtocolStr[protocol];
+       for (i = 0; i < MAX_URL && *s != '\0'; i++, s++) {
+               buf[i] = *s;
+       }
+       s = ts;
+       for (; i < MAX_URL && *s != '\0'; i++, s++) {
+               buf[i] = *s;
+       }
+       s = loginbuf;
+       for (; i < MAX_URL && *s != '\0'; i++, s++) {
+               buf[i] = *s;
+       }
+       s = host;
+       for (; i < MAX_URL && *s != '\0'; i++, s++) {
+               buf[i] = *s;
+       }
+       s = portbuf;
+       for (; i < MAX_URL && *s != '\0'; i++, s++) {
+               buf[i] = *s;
+       }
+       for (j = 0; i < MAX_URL && j < urlpath_len; i++, j++) {
+               buf[i] = urlpath[j];
+       }
+
+       if (i >= (MAX_URL - 1)) {
+               buf[MAX_URL - 1] = '\0';
+       } else {
+               buf[i] = '\0';
+       }
+
+       return i;
+}
=======================================
--- /branches/LUSCA_HEAD/libsqurl/url.h Sun May 23 07:00:44 2010
+++ /branches/LUSCA_HEAD/libsqurl/url.h Wed May 26 02:10:52 2010
@@ -7,5 +7,8 @@
 extern int urlMakeHttpCanonical(char *urlbuf, protocol_t protocol,
     const char *login, const char *host, int port, const char *urlpath,
     int urlpath_len);
+extern int urlMakeHttpCanonical2(char *urlbuf, protocol_t protocol,
+    const char *login, const char *host, int port, const char *urlpath,
+    int urlpath_len);

 #endif

--
You received this message because you are subscribed to the Google Groups 
"lusca-commit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/lusca-commit?hl=en.

Reply via email to