Commit c3e52ea6 authored by Matthias Andree's avatar Matthias Andree

Further cleanups to compile with C++ compiler.

svn path=/branches/BRANCH_6-3/; revision=4744
parent 10ad1196
......@@ -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;
......
......@@ -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;
......
......@@ -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)
......
......@@ -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;
......
......@@ -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;
......
......@@ -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 */
......
......@@ -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)
......
/* 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
......
......@@ -18,7 +18,13 @@
#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)
{
......
......@@ -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
......
......@@ -23,7 +23,13 @@
#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: "));
......
......@@ -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)
{
......
......@@ -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;
......
......@@ -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;
......
......@@ -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)
{
......
......@@ -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))
......
typedef unsigned short uint16;
typedef unsigned uint32;
typedef unsigned char uint8;
#include "smbtypes.h"
typedef struct
{
......
......@@ -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];
......
......@@ -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
......
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
......@@ -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);
......
......@@ -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)
......
......@@ -30,10 +30,7 @@
* 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;
......
......@@ -28,10 +28,7 @@
* 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;
......
......@@ -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 */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment