gnupg/keyserver (ChangeLog curl-shim.c curl-shim.h)

cvs user dshaw cvs at cvs.gnupg.org
Sun Apr 17 00:04:56 CEST 2005


    Date: Sunday, April 17, 2005 @ 00:21:28
  Author: dshaw
    Path: /cvs/gnupg/gnupg/keyserver

Modified: ChangeLog curl-shim.c curl-shim.h

* curl-shim.h, curl-shim.c (curl_escape, curl_free): Emulate
curl_escape and curl_free.


-------------+
 ChangeLog   |    3 ++
 curl-shim.c |   61 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 curl-shim.h |    2 +
 3 files changed, 66 insertions(+)


Index: gnupg/keyserver/ChangeLog
diff -u gnupg/keyserver/ChangeLog:1.121 gnupg/keyserver/ChangeLog:1.122
--- gnupg/keyserver/ChangeLog:1.121	Sat Apr 16 20:50:46 2005
+++ gnupg/keyserver/ChangeLog	Sun Apr 17 00:21:28 2005
@@ -1,5 +1,8 @@
 2005-04-16  David Shaw  <dshaw at jabberwocky.com>
 
+	* curl-shim.h, curl-shim.c (curl_escape, curl_free): Emulate
+	curl_escape and curl_free.
+
 	* gpgkeys_curl.c (main): If the http-proxy option is given without
 	any arguments, try to get the proxy from the environment.
 
Index: gnupg/keyserver/curl-shim.c
diff -u gnupg/keyserver/curl-shim.c:1.2 gnupg/keyserver/curl-shim.c:1.3
--- gnupg/keyserver/curl-shim.c:1.2	Sat Feb 12 04:15:02 2005
+++ gnupg/keyserver/curl-shim.c	Sun Apr 17 00:21:28 2005
@@ -151,3 +151,64 @@
 
   return handle_error(curl,err,errstr);
 }
+
+/* This is not the same exact set that is allowed according to
+   RFC-2396, but it is what the real curl uses. */
+#define VALID_URI_CHARS "abcdefghijklmnopqrstuvwxyz" \
+                        "ABCDEFGHIJKLMNOPQRSTUVWXYZ" \
+                        "0123456789"
+
+char *curl_escape(char *str,int length)
+{
+  int len,max,idx,enc_idx=0;
+  char *enc;
+
+  if(length)
+    len=length;
+  else
+    len=strlen(str);
+
+  enc=malloc(len+1);
+  if(!enc)
+    return enc;
+
+  max=len;
+
+  for(idx=0;idx<len;idx++)
+    {
+      if(enc_idx+3>max)
+	{
+	  char *tmp;
+
+	  max+=100;
+
+	  tmp=realloc(enc,max+1);
+	  if(!tmp)
+	    {
+	      free(enc);
+	      return NULL;
+	    }
+
+	  enc=tmp;
+	}
+
+      if(strchr(VALID_URI_CHARS,str[idx]))
+	enc[enc_idx++]=str[idx];
+      else
+	{
+	  char numbuf[5];
+	  sprintf(numbuf,"%%%02X",str[idx]);
+	  strcpy(&enc[enc_idx],numbuf);
+	  enc_idx+=3;
+	}
+    }
+
+  enc[enc_idx]='\0';
+
+  return enc;
+}
+
+void curl_free(char *ptr)
+{
+  free(ptr);
+}
Index: gnupg/keyserver/curl-shim.h
diff -u gnupg/keyserver/curl-shim.h:1.2 gnupg/keyserver/curl-shim.h:1.3
--- gnupg/keyserver/curl-shim.h:1.2	Sat Feb 12 04:15:02 2005
+++ gnupg/keyserver/curl-shim.h	Sun Apr 17 00:21:28 2005
@@ -68,5 +68,7 @@
 CURLcode curl_easy_setopt(CURL *curl,CURLoption option,...);
 CURLcode curl_easy_perform(CURL *curl);
 void curl_easy_cleanup(CURL *curl);
+char *curl_escape(char *str,int len);
+void curl_free(char *ptr);
 
 #endif /* !_CURL_SHIM_H_ */




More information about the Gnupg-commits mailing list