Moved parse_url() into libcitadel; I will need it for
authorArt Cancro <ajc@citadel.org>
Mon, 12 May 2008 14:50:00 +0000 (14:50 +0000)
committerArt Cancro <ajc@citadel.org>
Mon, 12 May 2008 14:50:00 +0000 (14:50 +0000)
something outside of rssclient soon.

citadel/citadel.h
citadel/modules/rssclient/serv_rssclient.c
libcitadel/lib/libcitadel.h
libcitadel/lib/tools.c
webcit/webcit.h

index c68393b17e6be059fe378982e820f5e78f975015..044392379815896c4b7f0109196d9b2fbd7c881f 100644 (file)
@@ -41,7 +41,7 @@ extern "C" {
 #define REV_LEVEL      735             /* This version */
 #define REV_MIN                591             /* Oldest compatible database */
 #define EXPORT_REV_MIN 733             /* Oldest compatible export files */
-#define LIBCITADEL_MIN 109             /* Minimum required version of libcitadel */
+#define LIBCITADEL_MIN 113             /* Minimum required version of libcitadel */
 
 #define SERVER_TYPE 0                  /* zero for stock Citadel; other developers please
                                           obtain SERVER_TYPE codes for your implementations */
index e97a59dcb8f391f025c6f50f2517dc1b288151aa..2aaa140efaa0314a55bfc36e8edf1e71c8efab41 100644 (file)
@@ -331,61 +331,6 @@ void rss_xml_chardata(void *data, const XML_Char *s, int len) {
 
 
 
-/* 
- * Parse a URL into host, port number, and resource identifier.
- */
-int parse_url(char *url, char *hostname, int *port, char *identifier)
-{
-       char protocol[1024];
-       char scratch[1024];
-       char *ptr = NULL;
-       char *nptr = NULL;
-       
-       strcpy(scratch, url);
-       ptr = (char *)strchr(scratch, ':');
-       if (!ptr) {
-               return(1);      /* no protocol specified */
-       }
-
-       strcpy(ptr, "");
-       strcpy(protocol, scratch);
-       if (strcmp(protocol, "http")) {
-               return(2);      /* not HTTP */
-       }
-
-       strcpy(scratch, url);
-       ptr = (char *) strstr(scratch, "//");
-       if (!ptr) {
-               return(3);      /* no server specified */
-       }
-       ptr += 2;
-
-       strcpy(hostname, ptr);
-       nptr = (char *)strchr(ptr, ':');
-       if (!nptr) {
-               *port = 80;     /* default */
-               nptr = (char *)strchr(hostname, '/');
-       }
-       else {
-               sscanf(nptr, ":%d", port);
-               nptr = (char *)strchr(hostname, ':');
-       }
-
-       if (nptr) {
-               *nptr = '\0';
-       }
-
-       nptr = (char *)strchr(ptr, '/');
-       
-       if (!nptr) {
-               return(4);      /* no url specified */
-       }
-       
-       strcpy(identifier, nptr);
-       return(0);
-}
-
-
 /*
  * Begin a feed parse
  */
index 7da1178f70e005a1a71d300dde7d5f125f68e438..4bfea6f6fecc48c4f39e29c90dbe815f5d1cfb6b 100644 (file)
@@ -9,7 +9,7 @@
  */
 #include <time.h>
 #include <stdlib.h>
-#define LIBCITADEL_VERSION_NUMBER      112
+#define LIBCITADEL_VERSION_NUMBER      113
 
 /*
  * Here's a bunch of stupid magic to make the MIME parser portable.
@@ -274,35 +274,23 @@ typedef void (*TransitionFunc) (void *Item1, void *Item2, int Odd);
 typedef void (*PrintHashDataFunc) (const char *Key, void *Item, int Odd);
 
 HashList *NewHash(int Uniq, HashFunc F);
-
 void DeleteHash(HashList **Hash);
-
 int GetHash(HashList *Hash, const char *HKey, long HKLen, void **Data);
-
 void Put(HashList *Hash, const char *HKey, long HKLen, void *Data, DeleteHashDataFunc DeleteIt);
-
 int GetKey(HashList *Hash, char *HKey, long HKLen, void **Data);
-
 int GetHashKeys(HashList *Hash, char ***List);
-
 int dbg_PrintHash(HashList *Hash, PrintHashContent first, PrintHashContent Second);
-
-
 int PrintHash(HashList *Hash, TransitionFunc Trans, PrintHashDataFunc PrintEntry);
-
 HashPos *GetNewHashPos(void);
-
 void DeleteHashPos(HashPos **DelMe);
-
 int GetNextHashPos(HashList *Hash, HashPos *At, long *HKLen, char **HashKey, void **Data);
-
 void SortByHashKey(HashList *Hash, int Order);
 void SortByHashKeyStr(HashList *Hash);
 int GetCount(HashList *Hash);
 const void *GetSearchPayload(const void *HashVoid);
 void SortByPayload(HashList *Hash, CompareFunc SortBy);
-
 void convert_spaces_to_underscores(char *str);
+int parse_url(char *url, char *hostname, int *port, char *identifier);
 
 /*
  * Convert 4 bytes char into an Integer.
index 2077a514b6d0c3b482879117609b1cb25d237cac..60168fe91e0ca0cb3cd8c21cc38d775623b43515 100644 (file)
@@ -1031,3 +1031,60 @@ void convert_spaces_to_underscores(char *str)
        }
 }
 
+
+/* 
+ * Parse a URL into host, port number, and resource identifier.
+ * (This is used by various functions which might need to fetch web pages.)
+ */
+int parse_url(char *url, char *hostname, int *port, char *identifier)
+{
+       char protocol[1024];
+       char scratch[1024];
+       char *ptr = NULL;
+       char *nptr = NULL;
+       
+       strcpy(scratch, url);
+       ptr = (char *)strchr(scratch, ':');
+       if (!ptr) {
+               return(1);      /* no protocol specified */
+       }
+
+       strcpy(ptr, "");
+       strcpy(protocol, scratch);
+       if (strcmp(protocol, "http")) {
+               return(2);      /* not HTTP */
+       }
+
+       strcpy(scratch, url);
+       ptr = (char *) strstr(scratch, "//");
+       if (!ptr) {
+               return(3);      /* no server specified */
+       }
+       ptr += 2;
+
+       strcpy(hostname, ptr);
+       nptr = (char *)strchr(ptr, ':');
+       if (!nptr) {
+               *port = 80;     /* default */
+               nptr = (char *)strchr(hostname, '/');
+       }
+       else {
+               sscanf(nptr, ":%d", port);
+               nptr = (char *)strchr(hostname, ':');
+       }
+
+       if (nptr) {
+               *nptr = '\0';
+       }
+
+       nptr = (char *)strchr(ptr, '/');
+       
+       if (!nptr) {
+               return(4);      /* no url specified */
+       }
+       
+       strcpy(identifier, nptr);
+       return(0);
+}
+
+
index a321aba9a1fc7c3bf34f4dd1df950eddf85d17a1..6f123d5a6ff78ce7ca939027128a2e17ee62bd93 100644 (file)
@@ -126,7 +126,7 @@ extern locale_t wc_locales[];
 #define CLIENT_ID              4
 #define CLIENT_VERSION         735             /* This version of WebCit */
 #define MINIMUM_CIT_VERSION    730             /* min required Citadel ver */
-#define        LIBCITADEL_MIN          112             /* min required libcitadel ver */
+#define        LIBCITADEL_MIN          113             /* min required libcitadel ver */
 #define DEFAULT_HOST           "localhost"     /* Default Citadel server */
 #define DEFAULT_PORT           "504"
 #define LB                     (1)             /* Internal escape chars */