Add 'const' to immutable arrays.
authorDan Fandrich <dan@coneharvesters.com>
Wed, 15 Dec 2004 01:38:25 +0000 (01:38 +0000)
committerDan Fandrich <dan@coneharvesters.com>
Wed, 15 Dec 2004 01:38:25 +0000 (01:38 +0000)
lib/base64.c
lib/formdata.c
lib/md5.c
lib/md5.h
lib/mprintf.c
lib/security.c
lib/urldata.h
src/main.c
src/writeenv.c
src/writeout.c

index 2416bca..7cb66c5 100644 (file)
@@ -110,7 +110,7 @@ size_t Curl_base64_decode(const char *src, char *dest)
 }
 
 /* ---- Base64 Encoding --- */
-static char table64[]=
+static const char table64[]=
   "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
 
 /*
index fa26ebb..07e5a0d 100644 (file)
@@ -261,7 +261,7 @@ static const char * ContentTypeForFilename (const char *filename,
     const char *extension;
     const char *type;
   };
-  static struct ContentType ctts[]={
+  static const struct ContentType ctts[]={
     {".gif",  "image/gif"},
     {".jpg",  "image/jpeg"},
     {".jpeg", "image/jpeg"},
@@ -1543,7 +1543,7 @@ char *Curl_FormBoundary(void)
                               the same form won't be identical */
   size_t i;
 
-  static char table16[]="abcdef0123456789";
+  static const char table16[]="abcdef0123456789";
 
   retstring = (char *)malloc(BOUNDARY_LENGTH+1);
 
index 1847c3c..7e9c3e9 100644 (file)
--- a/lib/md5.c
+++ b/lib/md5.c
@@ -25,7 +25,7 @@
 
 #ifndef CURL_DISABLE_CRYPTO_AUTH
 
-#ifndef USE_SSLEAY
+#if !defined(USE_SSLEAY) || !defined(USE_OPENSSL)
 /* This code segment is only used if OpenSSL is not provided, as if it is
    we use the MD5-function provided there instead. No good duplicating
    code! */
@@ -67,7 +67,7 @@ struct md5_ctx {
 typedef struct md5_ctx MD5_CTX;
 
 static void MD5_Init(struct md5_ctx *);
-static void MD5_Update(struct md5_ctx *, unsigned char *, unsigned int);
+static void MD5_Update(struct md5_ctx *, const unsigned char *, unsigned int);
 static void MD5_Final(unsigned char [16], struct md5_ctx *);
 
 /* Constants for MD5Transform routine.
@@ -90,11 +90,11 @@ static void MD5_Final(unsigned char [16], struct md5_ctx *);
 #define S43 15
 #define S44 21
 
-static void MD5Transform(UINT4 [4], unsigned char [64]);
+static void MD5Transform(UINT4 [4], const unsigned char [64]);
 static void Encode(unsigned char *, UINT4 *, unsigned int);
-static void Decode(UINT4 *, unsigned char *, unsigned int);
+static void Decode(UINT4 *, const unsigned char *, unsigned int);
 
-static unsigned char PADDING[64] = {
+static const unsigned char PADDING[64] = {
   0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
@@ -151,9 +151,9 @@ static void MD5_Init(struct md5_ctx *context)
   operation, processing another message block, and updating the
   context.
  */
-static void MD5_Update (struct md5_ctx *context, /* context */
-                        unsigned char *input, /* input block */
-                        unsigned int inputLen)/* length of input block */
+static void MD5_Update (struct md5_ctx *context,    /* context */
+                        const unsigned char *input, /* input block */
+                        unsigned int inputLen)      /* length of input block */
 {
   unsigned int i, bufindex, partLen;
 
@@ -214,7 +214,7 @@ static void MD5_Final(unsigned char digest[16], /* message digest */
 
 /* MD5 basic transformation. Transforms state based on block. */
 static void MD5Transform(UINT4 state[4],
-                         unsigned char block[64])
+                         const unsigned char block[64])
 {
   UINT4 a = state[0], b = state[1], c = state[2], d = state[3], x[16];
 
@@ -322,7 +322,7 @@ static void Encode (unsigned char *output,
    a multiple of 4.
 */
 static void Decode (UINT4 *output,
-                    unsigned char *input,
+                    const unsigned char *input,
                     unsigned int len)
 {
   unsigned int i, j;
@@ -341,7 +341,7 @@ static void Decode (UINT4 *output,
 #include "md5.h"
 
 void Curl_md5it(unsigned char *outbuffer, /* 16 bytes */
-                unsigned char *input)
+                const unsigned char *input)
 {
   MD5_CTX ctx;
   MD5_Init(&ctx);
index 12b3a5e..63cc70e 100644 (file)
--- a/lib/md5.h
+++ b/lib/md5.h
@@ -24,6 +24,6 @@
  ***************************************************************************/
 
 void Curl_md5it(unsigned char *output,
-                unsigned char *input);
+                const unsigned char *input);
 
 #endif
index 56bede3..30f0f7a 100644 (file)
@@ -816,8 +816,8 @@ static int dprintf_formatf(
     case FORMAT_STRING:
             /* String.  */
       {
-        static char null[] = "(nil)";
-        char *str;
+        static const char null[] = "(nil)";
+        const char *str;
         size_t len;
 
         str = (char *) p->data.str;
@@ -830,7 +830,7 @@ static int dprintf_formatf(
             p->flags &= (~FLAGS_ALT);
           }
           else {
-            str = (char *)"";
+            str = "";
             len = 0;
           }
         }
@@ -875,8 +875,8 @@ static int dprintf_formatf(
         }
         else {
           /* Write "(nil)" for a nil pointer.  */
-          static char strnil[] = "(nil)";
-          char *point;
+          static const char strnil[] = "(nil)";
+          const char *point;
 
           width -= sizeof(strnil) - 1;
           if (p->flags & FLAGS_LEFT)
index e87a514..f34729b 100644 (file)
@@ -65,7 +65,7 @@
 
 #define min(a, b)   ((a) < (b) ? (a) : (b))
 
-static struct {
+static const struct {
     enum protection_level level;
     const char *name;
 } level_names[] = {
@@ -85,7 +85,7 @@ name_to_level(const char *name)
   return (enum protection_level)-1;
 }
 
-static struct Curl_sec_client_mech *mechs[] = {
+static const struct Curl_sec_client_mech *mechs[] = {
 #ifdef KRB5
   /* not supported */
 #endif
@@ -400,7 +400,7 @@ int
 Curl_sec_login(struct connectdata *conn)
 {
   int ret;
-  struct Curl_sec_client_mech **m;
+  const struct Curl_sec_client_mech **m;
   ssize_t nread;
   struct SessionHandle *data=conn->data;
   int ftpcode;
index a58a9e4..64c8a1d 100644 (file)
@@ -573,7 +573,7 @@ struct connectdata {
   int sec_complete;
   void *app_data;
 
-  struct Curl_sec_client_mech *mech;
+  const struct Curl_sec_client_mech *mech;
   struct sockaddr_in local_addr;
 
 #endif
index 001bbd4..5bc466f 100644 (file)
@@ -1191,7 +1191,7 @@ static ParameterError getparameter(char *flag, /* f or -long-flag */
      long-name,
      boolean whether it takes an additional argument
      */
-  struct LongShort aliases[]= {
+  static const struct LongShort aliases[]= {
     /* all these ones, starting with "*" or "$" as a short-option have *no*
        short option to mention. */
     {"*", "url",         TRUE},
@@ -2036,7 +2036,7 @@ static ParameterError getparameter(char *flag, /* f or -long-flag */
           const char *name;
           int bitmask;
         };
-        struct feat feats[] = {
+        static const struct feat feats[] = {
           {"AsynchDNS", CURL_VERSION_ASYNCHDNS},
           {"Debug", CURL_VERSION_DEBUG},
           {"GSS-Negotiate", CURL_VERSION_GSSNEGOTIATE},
@@ -4014,11 +4014,11 @@ char *
 msdosify (char *file_name)
 {
   static char dos_name[PATH_MAX];
-  static char illegal_chars_dos[] = ".+, ;=[]|<>\\\":?*";
-  static char *illegal_chars_w95 = &illegal_chars_dos[8];
+  static const char illegal_chars_dos[] = ".+, ;=[]|<>\\\":?*";
+  static const char *illegal_chars_w95 = &illegal_chars_dos[8];
   int idx, dot_idx;
   char *s = file_name, *d = dos_name;
-  char *illegal_aliens = illegal_chars_dos;
+  const char *illegal_aliens = illegal_chars_dos;
   size_t len = sizeof (illegal_chars_dos) - 1;
   int lfn = 0;
 
index 833d9a6..90d3413 100644 (file)
 #ifdef USE_ENVIRONMENT
 
 #include <curl/curl.h>
+#include "writeenv.h"
 
 #ifdef __riscos__
 #include <kernel.h>
 #endif
 
-struct
+static const struct
 {
   const char * name;
   CURLINFO id;
index b396eeb..a7b8729 100644 (file)
@@ -68,7 +68,7 @@ struct variable {
 };
 
 
-static struct variable replacements[]={
+static const struct variable replacements[]={
   {"url_effective", VAR_EFFECTIVE_URL},
   {"http_code", VAR_HTTP_CODE},
   {"time_total", VAR_TOTAL_TIME},