]> Pileus Git - ~andy/fetchmail/commitdiff
Further cleanups to compile with C++ compiler.
authorMatthias Andree <matthias.andree@gmx.de>
Wed, 15 Mar 2006 17:05:25 +0000 (17:05 -0000)
committerMatthias Andree <matthias.andree@gmx.de>
Wed, 15 Mar 2006 17:05:25 +0000 (17:05 -0000)
svn path=/branches/BRANCH_6-3/; revision=4744

25 files changed:
base64.c
driver.c
getpass.c
imap.c
libesmtp/gethostbyname.c
md5c.c
netrc.c
ntlm.h
opie.c
options.c
pop3.c
rcfile_l.l
rcfile_y.y
rfc2047e.c
rpa.c
sink.c
smb.h
smbdes.c
smbencrypt.c
smbencrypt.h
smbutil.c
socket.c
strlcat.c
strlcpy.c
transact.c

index 4fd9a30ce027185a79f140a3ef81c51df77a4a9e..1453257b501ac87d79d0a2ffa7d5baa77a7d9998 100644 (file)
--- a/base64.c
+++ b/base64.c
@@ -30,7 +30,7 @@ static const char base64val[] = {
 void to64frombits(char *out, const void *in_, int inlen)
 /* raw bytes in quasi-big-endian order to base 64 string (NUL-terminated) */
 {
-    const unsigned char *in = in_;
+    const unsigned char *in = (const unsigned char *)in_;
 
     for (; inlen >= 3; inlen -= 3)
     {
@@ -61,7 +61,7 @@ int from64tobits(void *out_, const char *in, int maxlen)
 {
     int len = 0;
     register unsigned char digit1, digit2, digit3, digit4;
-    unsigned char *out = out_;
+    unsigned char *out = (unsigned char *)out_;
 
     if (in[0] == '+' && in[1] == ' ')
        in += 2;
index 89aeb36c97980bf70754fe4e5e0e1c2c11cec8b7..1d39f068b64dfb294c2711445d877127d3e9511a 100644 (file)
--- a/driver.c
+++ b/driver.c
@@ -443,7 +443,7 @@ static int fetch_messages(int mailserver_socket, struct query *ctl,
 
        /* Time to allocate memory to store the sizes */
        xfree(*msgsizes);
-       *msgsizes = xmalloc(sizeof(int) * fetchsizelimit);
+       *msgsizes = (int *)xmalloc(sizeof(int) * fetchsizelimit);
     }
 
     /*
@@ -1029,7 +1029,7 @@ static int do_session(
                {
                    xfree(ctl->server.truename);
                    ctl->server.truename = xstrdup(res->ai_canonname);
-                   ctl->server.trueaddr = xmalloc(res->ai_addrlen);
+                   ctl->server.trueaddr = (struct sockaddr *)xmalloc(res->ai_addrlen);
                    ctl->server.trueaddr_len = res->ai_addrlen;
                    memcpy(ctl->server.trueaddr, res->ai_addr, res->ai_addrlen);
                    freeaddrinfo(res);
@@ -1397,7 +1397,7 @@ is restored."));
                        !(proto->getpartialsizes && NUM_NONZERO(ctl->fetchsizelimit)))
                    {
                        xfree(msgsizes);
-                       msgsizes = xmalloc(sizeof(int) * count);
+                       msgsizes = (int *)xmalloc(sizeof(int) * count);
                        for (i = 0; i < count; i++)
                            msgsizes[i] = 0;
 
@@ -1575,10 +1575,9 @@ closeUp:
     return(err);
 }
 
-int do_protocol(ctl, proto)
-/* retrieve messages from server using given protocol method table */
-struct query *ctl;             /* parsed options with merged-in defaults */
-const struct method *proto;    /* protocol method table */
+/** retrieve messages from server using given protocol method table */
+int do_protocol(struct query *ctl /** parsed options with merged-in defaults */,
+               const struct method *proto /** protocol method table */)
 {
     int        err;
 
index 12f58627545daadd0c1522f5d44fa68ef138b2cb..3c19ba7c832fb9f3825c3b98c6d29e7cd5024351 100644 (file)
--- a/getpass.c
+++ b/getpass.c
@@ -61,8 +61,7 @@ static void disable_tty_echo(void);
 static void restore_tty_state(void);
 static RETSIGTYPE sigint_handler(int);
 
-char *fm_getpassword(prompt)
-char *prompt;
+char *fm_getpassword(char *prompt)
 {
 #if !(defined(HAVE_TCSETATTR) || defined(HAVE_TERMIO_H) || defined(HAVE_STTY))
 #if defined(HAVE_GETPASS) 
diff --git a/imap.c b/imap.c
index 42f572810ac011dc7a768738dea7fe4e769b4171..856f3f86f27de6cb65495e9eaadea9e1135679e1 100644 (file)
--- a/imap.c
+++ b/imap.c
@@ -782,7 +782,7 @@ static int imap_getrange(int sock,
     {
        if (unseen_messages)
            free(unseen_messages);
-       unseen_messages = xmalloc(count * sizeof(unsigned int));
+       unseen_messages = (unsigned int *)xmalloc(count * sizeof(unsigned int));
        memset(unseen_messages, 0, count * sizeof(unsigned int));
        unseen = 0;
 
index d151606d722f1c9e47e1477e19f72f6e80f74b83..2e3beefccf804e45a7e6c49ab54ce77c712ffd3d 100644 (file)
@@ -85,7 +85,7 @@ gethostbyname_ctx (const char *host, struct ghbnctx *ctx)
 
   memset (ctx, 0, sizeof (struct ghbnctx));
   ctx->hostbuf_len = 2048;
-  if ((ctx->hostbuf = malloc (ctx->hostbuf_len)) == NULL)
+  if ((ctx->hostbuf = (char *)malloc (ctx->hostbuf_len)) == NULL)
     {
       errno = ENOMEM;
       return NULL;
@@ -95,7 +95,7 @@ gethostbyname_ctx (const char *host, struct ghbnctx *ctx)
                                 &hp, &ctx->h_err)) == ERANGE)
     {
       ctx->hostbuf_len += 1024;
-      if ((tmp = realloc (ctx->hostbuf, ctx->hostbuf_len)) == NULL)
+      if ((tmp = (char *)realloc (ctx->hostbuf, ctx->hostbuf_len)) == NULL)
        {
          errno = ENOMEM;
          return NULL;
diff --git a/md5c.c b/md5c.c
index ae36de497c55ef82fa0025b7451a390e47226342..61fd2fe73cd79434a1aeb0f9f9b1987a6a032dfa 100644 (file)
--- a/md5c.c
+++ b/md5c.c
@@ -56,7 +56,7 @@ void MD5Init(struct MD5Context *ctx)
  */
 void MD5Update(struct MD5Context *ctx, const void *buf_, unsigned len)
 {
-    const unsigned char *buf = buf_;
+    const unsigned char *buf = (const unsigned char *)buf_;
     register uint32 t;
 
     /* Update bitcount */
diff --git a/netrc.c b/netrc.c
index ea422edf3dfd02c475f437b9e6ce71c19aa5afc2..196db6715c65657d82f3618091f4ecd537024c56 100644 (file)
--- a/netrc.c
+++ b/netrc.c
@@ -76,8 +76,7 @@ maybe_add_to_list (netrc_entry **newentry, netrc_entry **list)
    list of entries.  NULL is returned if the file could not be
    parsed. */
 netrc_entry *
-parse_netrc (file)
-     char *file;
+parse_netrc (char *file)
 {
     FILE *fp;
     char buf[POPBUFSIZE+1], *p, *tok;
@@ -291,9 +290,7 @@ parse_netrc (file)
 /* Return the netrc entry from LIST corresponding to HOST.  NULL is
    returned if no such entry exists. */
 netrc_entry *
-search_netrc (list, host, login)
-     netrc_entry *list;
-     char *host, *login;
+search_netrc (netrc_entry *list, char *host, char *login)
 {
     /* Look for the HOST in LIST. */
     while (list)
diff --git a/ntlm.h b/ntlm.h
index f25e416e3cb77a7012d4f376b6a5113bbadb0bb5..1469633508701a8dcfdadbc9d5647563545d7f7d 100644 (file)
--- a/ntlm.h
+++ b/ntlm.h
@@ -1,9 +1,6 @@
 /* ntlm.h  -- interface declarations for SMB authentication code */
 
-typedef unsigned short uint16;
-typedef unsigned int   uint32;
-typedef unsigned char  uint8;
-
+#include "smbtypes.h"
 
 /* 
  * These structures are byte-order dependant, and should not
diff --git a/opie.c b/opie.c
index b7687d94639280fbf2a449038ef6a8c559490d5a..395de2dd4f5fc65d132a24a5849a655d4dd2d254 100644 (file)
--- a/opie.c
+++ b/opie.c
 #include "md5.h"
 
 #ifdef OPIE_ENABLE
+#ifdef __cplusplus
+extern "C" {
+#endif
 #include <opie.h>
+#ifdef __cplusplus
+}
+#endif
 
 int do_otp(int sock, char *command, struct query *ctl)
 {
index 8f890ed022f550b75a4b1230faf8368d8d039459..9bfc75862ae500746a9dfd97ca89d36fa7fbda98 100644 (file)
--- a/options.c
+++ b/options.c
@@ -215,12 +215,11 @@ static int xatoi(char *s, int *errflagptr)
 #endif
 }
 
-int parsecmdline (argc, argv, rctl, ctl)
-/* parse and validate the command line options */
-int argc;              /* argument count */
-char **argv;           /* argument strings */
-struct runctl *rctl;   /* global run controls to modify */
-struct query *ctl;     /* option record to be initialized */
+/** parse and validate the command line options */
+int parsecmdline (int argc /** argument count */,
+                 char **argv /** argument strings */,
+                 struct runctl *rctl /** global run controls to modify */,
+                 struct query *ctl /** option record to initialize */)
 {
     /*
      * return value: if positive, argv index of last parsed option + 1
diff --git a/pop3.c b/pop3.c
index ff68f614576d7986bea87e565abfdc3cbac65535..4456b2d31af0a4b01e8ab12840e5ef4fdf98b570 100644 (file)
--- a/pop3.c
+++ b/pop3.c
 #include  "i18n.h"
 
 #ifdef OPIE_ENABLE
+#ifdef __cplusplus
+extern "C" {
+#endif
 #include <opie.h>
+#ifdef __cplusplus
+}
+#endif
 #endif /* OPIE_ENABLE */
 
 /* global variables: please reinitialize them explicitly for proper
@@ -533,8 +539,10 @@ static int pop3_getauth(int sock, struct query *ctl, char *greeting)
        if ((challenge = strstr(lastok, "otp-"))) {
          char response[OPIE_RESPONSE_MAX+1];
          int i;
+         char *n = xstrdup("");
 
-         i = opiegenerator(challenge, !strcmp(ctl->password, "opie") ? "" : ctl->password, response);
+         i = opiegenerator(challenge, !strcmp(ctl->password, "opie") ? n : ctl->password, response);
+         free(n);
          if ((i == -2) && !run.poll_interval) {
            char secret[OPIE_SECRET_MAX+1];
            fprintf(stderr, GT_("Secret pass phrase: "));
index 9f4bf5c8a015c181cf7846fc1a47d0ed19681d63..14eb73e4735ccb6867a35b04e92e54718e4e22a2 100644 (file)
@@ -223,12 +223,11 @@ options           {/* EMPTY */}
 
 %%
 
-void escapes(cp, tp)
-/* process standard C-style escape sequences in a string,
+/** process standard C-style escape sequences in a string,
  * this can never lengthen the output, so cp and tp may overlap as long
  * as cp >= tp. */
-const char     *cp;    /* source string with escapes */
-char           *tp;    /* target buffer for digested string */
+void escapes(const char *cp /** source string with escapes */,
+            char       *tp /** target buffer for digested string */)
 {
     while (*cp)
     {
index 0aa9265e400089879a79ca391fbe79c4e551a074..75d57c27c177b5dcb40c506dd98c5a9460e44256 100644 (file)
@@ -518,9 +518,9 @@ static void user_reset(void)
     current.server = save;
 }
 
-struct query *hostalloc(init)
-/* append a host record to the host list */
-struct query *init;    /* pointer to block containing initial values */
+/** append a host record to the host list */
+struct query *hostalloc(struct query *init /** pointer to block containing
+                                              initial values */)
 {
     struct query *node;
 
index 922fe7a9ba8c84a38d9bd97d4caae29623941e6e..fd6ae2bc0f024e14bdd410fcfa2d25b8d709245f 100644 (file)
@@ -104,7 +104,7 @@ char *rfc2047e(const char *string, const char *charset) {
        count++;
        r += strspn(r, ws);
     }
-    words = xmalloc(sizeof(char *) * (count + 1));
+    words = (char **)xmalloc(sizeof(char *) * (count + 1));
 
     idx = 0;
     r = string;
diff --git a/rpa.c b/rpa.c
index 79e4d8ab5c378c7b492a30521e9fbb8aef71651c..433c12e6d0f3474056c3ab22c51ba9723f9a6cdd 100644 (file)
--- a/rpa.c
+++ b/rpa.c
@@ -50,7 +50,7 @@ extern int linecount;
                               unsigned char* rbuf, int unicodeit);
   static void CompUserResp();
   static int  CheckUserAuth();
-  static void md5(void* in, int len, unsigned char* out);
+  static void md5(const void* in, int len, unsigned char* out);
 #endif
 
 /* RPA protocol definitions */
@@ -360,9 +360,7 @@ int POP3_auth_rpa (char *userid, char *passphrase, int socket)
   globals:       reads outlevel.
  *********************************************************************/
 
-static int POP3_rpa_resp (argbuf,socket)
-char *argbuf;
-int socket;
+static int POP3_rpa_resp (char *argbuf, int socket)
 {
     int ok;
     char buf [POPBUFSIZE];
@@ -419,9 +417,7 @@ int socket;
   globals:       none
  *********************************************************************/
 
-static void LenAppend(pptr_,len)
-char **pptr_;
-int  len;
+static void LenAppend(char **pptr_, int len)
 {
     unsigned char **pptr = (unsigned char **)pptr_;
 
@@ -455,9 +451,7 @@ int  len;
   globals:       reads outlevel.
  *********************************************************************/
 
-int LenSkip(pptr,rxlen)
-char **pptr;
-int rxlen;
+int LenSkip(char **pptr, int rxlen)
 {
     int len;
     char *save;
@@ -517,8 +511,7 @@ int rxlen;
   globals:       reads outlevel.
  *********************************************************************/
 
-static int DecBase64(bufp)
-char *bufp;
+static int DecBase64(char *bufp)
 {
     unsigned int   newx, bits=0, cnt=0, i, part=0;
     unsigned char  ch;
@@ -576,9 +569,7 @@ char *bufp;
   globals:       reads outlevel;
  *********************************************************************/
 
-static void EncBase64(bufp,len)
-char *bufp;
-int  len;
+static void EncBase64(char *bufp, int len)
 {
     char* outp;
     unsigned char  c1,c2,c3;
@@ -871,11 +862,11 @@ static int CheckUserAuth(void)
   globals:       reads outlevel
  *********************************************************************/
 
-static void md5(void *in_,int len,unsigned char *out)
+static void md5(const void *in_,int len,unsigned char *out)
 {
     int      i;
     MD5_CTX  md5context;
-    unsigned char *in = in_;
+    const unsigned char *in = (const unsigned char *)in_;
 
     if (outlevel >= O_DEBUG)
     {
diff --git a/sink.c b/sink.c
index 3ceb367f3844c7e740fdea69025d32e38cecb761..aaa0beba828cc0fdfe0060c2515f31e199b00170 100644 (file)
--- a/sink.c
+++ b/sink.c
@@ -920,7 +920,7 @@ static int open_smtp_sink(struct query *ctl, struct msgblk *msg,
     for (idp = msg->recipients; idp; idp = idp->next)
        total_addresses++;
 #ifdef EXPLICIT_BOUNCE_ON_BAD_ADDRESS
-    from_responses = xmalloc(sizeof(char *) * total_addresses);
+    from_responses = (char **)xmalloc(sizeof(char *) * total_addresses);
 #endif /* EXPLICIT_BOUNCE_ON_BAD_ADDRESS */
     for (idp = msg->recipients; idp; idp = idp->next)
        if (idp->val.status.mark == XMIT_ACCEPT)
@@ -1426,7 +1426,7 @@ int close_sink(struct query *ctl, struct msgblk *msg, flag forward)
                char    **responses;
 
                /* eat the RFC2033-required responses, saving errors */ 
-               responses = xmalloc(sizeof(char *) * lmtp_responses);
+               responses = (char **)xmalloc(sizeof(char *) * lmtp_responses);
                for (errors = i = 0; i < lmtp_responses; i++)
                {
                    if ((smtp_err = SMTP_ok(ctl->smtp_socket, ctl->smtphostmode))
diff --git a/smb.h b/smb.h
index eb5e382e68d20d180b6ca34c9ea5a261291c93a9..edefb17d57dc0832790b80514dc5f78fa0535e8d 100644 (file)
--- a/smb.h
+++ b/smb.h
@@ -1,6 +1,4 @@
-typedef unsigned short uint16;
-typedef unsigned       uint32;
-typedef unsigned char  uint8;
+#include "smbtypes.h"
 
 typedef struct
 {
index e3ab78afed7b8259018bea7d84e2f10f7547051f..f738b6a2925c4fe3e7d822131e2c68b8b2da2b9a 100644 (file)
--- a/smbdes.c
+++ b/smbdes.c
@@ -173,7 +173,7 @@ static void concat(char *out, char *in1, char *in2, int l1, int l2)
                *out++ = *in2++;
 }
 
-static void xor(char *out, char *in1, char *in2, int n)
+static void exor(char *out, char *in1, char *in2, int n)
 {
        int i;
        for (i=0;i<n;i++)
@@ -224,7 +224,7 @@ static void dohash(char *out, char *in, char *key, int forw)
 
                permute(er, r, perm4, 48);
 
-               xor(erk, er, ki[forw ? i : 15 - i], 48);
+               exor(erk, er, ki[forw ? i : 15 - i], 48);
 
                for (j=0;j<8;j++)
                        for (k=0;k<6;k++)
@@ -245,7 +245,7 @@ static void dohash(char *out, char *in, char *key, int forw)
                                cb[j*4+k] = b[j][k];
                permute(pcb, cb, perm5, 32);
 
-               xor(r2, l, pcb, 32);
+               exor(r2, l, pcb, 32);
 
                for (j=0;j<32;j++)
                        l[j] = r[j];
index a98c63dcfeb421b06593fa1a347ca7fba2d7afa3..b596587da0fa5698feca3900cf922dc345377f23 100644 (file)
@@ -30,13 +30,13 @@ extern int DEBUGLEVEL;
 #include <ctype.h>
 #include "smbbyteorder.h"
 #include "smbdes.h"
+#include "smbencrypt.h"
 #include "smbmd4.h"
 
 #ifndef _AIX
 typedef unsigned char uchar;
 #endif
 typedef signed short int16;
-typedef unsigned short uint16;
 typedef int BOOL;
 #define False 0
 #define True  1
index 0f33b06282c5d861990d9974922a20b8e2f1d6f6..03e17d943464a5edcd032f94b7720f2507e9ac6b 100644 (file)
@@ -1,2 +1,15 @@
-void SMBencrypt(char *passwd, uint8 *c8, uint8 *p24);
-void SMBNTencrypt(char *passwd, uint8 *c8, uint8 *p24);
+#ifndef SMBENCRYPT_H
+#define SMBENCRYPT_H
+
+#include "smbtypes.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+void SMBencrypt(uint8 *passwd, uint8 *c8, uint8 *p24);
+void SMBNTencrypt(uint8 *passwd, uint8 *c8, uint8 *p24);
+#ifdef __cplusplus
+}
+
+#endif
+#endif
index 74bd5ba278dcae5c9fa5087c5c2839bb0c7ea405..aa50ed09652418effda7ca57255edad822045686 100644 (file)
--- a/smbutil.c
+++ b/smbutil.c
@@ -197,8 +197,8 @@ void buildSmbNtlmAuthResponse(tSmbNtlmAuthChallenge *challenge, tSmbNtlmAuthResp
         *p = '\0';
       }
     
-    SMBencrypt(password,   challenge->challengeData, lmRespData);
-    SMBNTencrypt(password, challenge->challengeData, ntRespData);
+    SMBencrypt((uint8*)password,   challenge->challengeData, lmRespData);
+    SMBNTencrypt((uint8*)password, challenge->challengeData, ntRespData);
     
     response->bufIndex = 0;
     memcpy(response->ident,"NTLMSSP\0\0\0",8);
index b1119ca53025a14bfe8e45db4c36df9afb4eef1e..10cd5d99bbdcffc3834255ce9facfbed5ccd3380 100644 (file)
--- a/socket.c
+++ b/socket.c
@@ -108,7 +108,7 @@ static char *const *parse_plugin(const char *plugin, const char *host, const cha
        }
 
        plugin_copy_len = plugin_len + host_len * host_count + service_len * service_count;
-       plugin_copy = malloc(plugin_copy_len + 1);
+       plugin_copy = (char *)malloc(plugin_copy_len + 1);
        if (!plugin_copy)
        {
                report(stderr, GT_("fetchmail: malloc failed\n"));
@@ -134,7 +134,7 @@ static char *const *parse_plugin(const char *plugin, const char *host, const cha
        }
        plugin_copy[plugin_copy_len] = 0;
 
-       argvec = malloc(s);
+       argvec = (const char **)malloc(s);
        if (!argvec)
        {
                report(stderr, GT_("fetchmail: malloc failed\n"));
@@ -470,7 +470,7 @@ int SockRead(int sock, char *buf, int len)
 #ifdef FORCE_STUFFING
            maxavailable = n;
 #endif
-           if ((newline = memchr(bp, '\n', n)) != NULL)
+           if ((newline = (char *)memchr(bp, '\n', n)) != NULL)
                n = newline - bp + 1;
 #ifndef __BEOS__
            if ((n = fm_read(sock, bp, n)) == -1)
index fe3ec1058d1e69fd233e687063332a45a711d2a0..259500f80546f3ec3c80ba74cab166ccb082ba39 100644 (file)
--- a/strlcat.c
+++ b/strlcat.c
  * If retval >= siz, truncation occurred.
  */
 size_t
-strlcat(dst, src, siz)
-       char *dst;
-       const char *src;
-       size_t siz;
+strlcat(char *dst, const char *src, size_t siz)
 {
        char *d = dst;
        const char *s = src;
index baf2c7a7359bad97b7e39b85172791014a3eb878..bb7d409695cefe883c784c18b9d5e167b5e27efa 100644 (file)
--- a/strlcpy.c
+++ b/strlcpy.c
  * Returns strlen(src); if retval >= siz, truncation occurred.
  */
 size_t
-strlcpy(dst, src, siz)
-       char *dst;
-       const char *src;
-       size_t siz;
+strlcpy(char *dst, const char *src, size_t siz)
 {
        char *d = dst;
        const char *s = src;
index d2a241c59645a189123b72d1137cf7c3ff90f427..c07196152f45c038639d025e2d00b8ec591fb81a 100644 (file)
@@ -869,7 +869,7 @@ int readheaders(int sock,
                || !strncasecmp("Bcc:", line, 4)
                || !strncasecmp("Apparently-To:", line, 14))
            {
-               *to_chainptr = xmalloc(sizeof(struct addrblk));
+               *to_chainptr = (struct addrblk *)xmalloc(sizeof(struct addrblk));
                (*to_chainptr)->offset = (line - msgblk.headers);
                to_chainptr = &(*to_chainptr)->next; 
                *to_chainptr = NULL;
@@ -879,7 +879,7 @@ int readheaders(int sock,
                     || !strncasecmp("Resent-Cc:", line, 10)
                     || !strncasecmp("Resent-Bcc:", line, 11))
            {
-               *resent_to_chainptr = xmalloc(sizeof(struct addrblk));
+               *resent_to_chainptr = (struct addrblk *)xmalloc(sizeof(struct addrblk));
                (*resent_to_chainptr)->offset = (line - msgblk.headers);
                resent_to_chainptr = &(*resent_to_chainptr)->next; 
                *resent_to_chainptr = NULL;
@@ -1476,11 +1476,10 @@ va_dcl
     }
 }
 
-int gen_recv(sock, buf, size)
-/* get one line of input from the server */
-int sock;      /* socket to which server is connected */
-char *buf;     /* buffer to receive input */
-int size;      /* length of buffer */
+/** get one line of input from the server */
+int gen_recv(int sock  /** socket to which server is connected */,
+            char *buf /* buffer to receive input */,
+            int size  /* length of buffer */)
 {
     int oldphase = phase;      /* we don't have to be re-entrant */