From f8a913ac80a967d0385b5c9577765791a08a055d Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Sun, 27 Mar 2011 12:06:41 +0200 Subject: [PATCH] avoid preprocessor warnings on missing features: #if => #ifdef (cherry picked from commit 4afd31a45755d8321f4e913b8092076d01c16335) Conflicts: src/drv_imap.c --- src/compat/main.c | 6 +++--- src/drv_imap.c | 42 +++++++++++++++++++++--------------------- src/main.c | 2 +- 3 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/compat/main.c b/src/compat/main.c index 6183a91..4689d8e 100644 --- a/src/compat/main.c +++ b/src/compat/main.c @@ -34,7 +34,7 @@ #include #include -#if HAVE_GETOPT_LONG +#ifdef HAVE_GETOPT_LONG # define _GNU_SOURCE # include struct option Opts[] = { @@ -185,7 +185,7 @@ main( int argc, char **argv ) #define FLAGS "wW:alCLRc:defhp:qu:r:F:M:1I:s:vVD" mod = all = list = ops = writeout = Quiet = Verbose = Debug = 0; -#if HAVE_GETOPT_LONG +#ifdef HAVE_GETOPT_LONG while ((i = getopt_long( argc, argv, FLAGS, Opts, NULL )) != -1) #else while ((i = getopt( argc, argv, FLAGS )) != -1) @@ -250,7 +250,7 @@ main( int argc, char **argv ) mod = 1; break; case 's': -#if HAVE_LIBSSL +#ifdef HAVE_LIBSSL if (!strncasecmp( "imaps:", optarg, 6 )) { global.use_imaps = 1; global.port = 993; diff --git a/src/drv_imap.c b/src/drv_imap.c index afe6df0..573f601 100644 --- a/src/drv_imap.c +++ b/src/drv_imap.c @@ -44,7 +44,7 @@ #include #include #include -#if HAVE_LIBSSL +#ifdef HAVE_LIBSSL # include # include # include @@ -59,7 +59,7 @@ typedef struct imap_server_conf { int port; char *user; char *pass; -#if HAVE_LIBSSL +#ifdef HAVE_LIBSSL char *cert_file; unsigned use_imaps:1; unsigned require_ssl:1; @@ -92,7 +92,7 @@ typedef struct _list { typedef struct { int fd; -#if HAVE_LIBSSL +#ifdef HAVE_LIBSSL SSL *ssl; unsigned int use_ssl:1; #endif @@ -117,7 +117,7 @@ typedef struct imap { /* command queue */ int nexttag, num_in_progress, literal_pending; struct imap_cmd *in_progress, **in_progress_append; -#if HAVE_LIBSSL +#ifdef HAVE_LIBSSL SSL_CTX *SSLContext; #endif buffer_t buf; /* this is BIG, so put it last */ @@ -154,7 +154,7 @@ enum CAPABILITY { UIDPLUS, LITERALPLUS, NAMESPACE, -#if HAVE_LIBSSL +#ifdef HAVE_LIBSSL CRAM, STARTTLS, #endif @@ -165,7 +165,7 @@ static const char *cap_list[] = { "UIDPLUS", "LITERAL+", "NAMESPACE", -#if HAVE_LIBSSL +#ifdef HAVE_LIBSSL "AUTH=CRAM-MD5", "STARTTLS", #endif @@ -186,7 +186,7 @@ static const char *Flags[] = { "Deleted", }; -#if HAVE_LIBSSL +#ifdef HAVE_LIBSSL static int host_matches( const char *host, const char *pattern ) @@ -339,7 +339,7 @@ init_ssl_ctx( imap_store_t *ctx ) static void socket_perror( const char *func, Socket_t *sock, int ret ) { -#if HAVE_LIBSSL +#ifdef HAVE_LIBSSL int err; if (sock->use_ssl) { @@ -373,7 +373,7 @@ static int socket_read( Socket_t *sock, char *buf, int len ) { int n = -#if HAVE_LIBSSL +#ifdef HAVE_LIBSSL sock->use_ssl ? SSL_read( sock->ssl, buf, len ) : #endif read( sock->fd, buf, len ); @@ -389,7 +389,7 @@ static int socket_write( Socket_t *sock, char *buf, int len ) { int n = -#if HAVE_LIBSSL +#ifdef HAVE_LIBSSL sock->use_ssl ? SSL_write( sock->ssl, buf, len ) : #endif write( sock->fd, buf, len ); @@ -410,7 +410,7 @@ socket_pending( Socket_t *sock ) return -1; if (num > 0) return num; -#if HAVE_LIBSSL +#ifdef HAVE_LIBSSL if (sock->use_ssl) return SSL_pending( sock->ssl ); #endif @@ -1260,7 +1260,7 @@ imap_open_store( store_conf_t *conf, store_t *oldctx ) struct hostent *he; struct sockaddr_in addr; int s, a[2], preauth; -#if HAVE_LIBSSL +#ifdef HAVE_LIBSSL int use_ssl; #endif @@ -1280,7 +1280,7 @@ imap_open_store( store_conf_t *conf, store_t *oldctx ) imap->in_progress_append = &imap->in_progress; /* open connection to IMAP server */ -#if HAVE_LIBSSL +#ifdef HAVE_LIBSSL use_ssl = 0; #endif @@ -1338,7 +1338,7 @@ imap_open_store( store_conf_t *conf, store_t *oldctx ) imap->buf.sock.fd = s; } -#if HAVE_LIBSSL +#ifdef HAVE_LIBSSL if (srvc->use_imaps) { if (start_tls( ctx )) goto ssl_bail; @@ -1368,7 +1368,7 @@ imap_open_store( store_conf_t *conf, store_t *oldctx ) goto bail; if (!preauth) { -#if HAVE_LIBSSL +#ifdef HAVE_LIBSSL if (!srvc->use_imaps && (srvc->use_sslv2 || srvc->use_sslv3 || srvc->use_tlsv1)) { /* always try to select SSL support if available */ if (CAP(STARTTLS)) { @@ -1413,7 +1413,7 @@ imap_open_store( store_conf_t *conf, store_t *oldctx ) */ srvc->pass = nfstrdup( arg ); } -#if HAVE_LIBSSL +#ifdef HAVE_LIBSSL if (CAP(CRAM)) { struct imap_cmd_cb cb; @@ -1432,7 +1432,7 @@ imap_open_store( store_conf_t *conf, store_t *oldctx ) fprintf( stderr, "Skipping account %s@%s, server forbids LOGIN\n", srvc->user, srvc->host ); goto bail; } -#if HAVE_LIBSSL +#ifdef HAVE_LIBSSL if (!use_ssl) #endif warn( "*** IMAP Warning *** Password is being sent in the clear\n" ); @@ -1460,7 +1460,7 @@ imap_open_store( store_conf_t *conf, store_t *oldctx ) ctx->trashnc = 1; return (store_t *)ctx; -#if HAVE_LIBSSL +#ifdef HAVE_LIBSSL ssl_bail: /* This avoids that we try to send LOGOUT to an unusable socket. */ close( imap->buf.sock.fd ); @@ -1792,7 +1792,7 @@ imap_parse_store( conffile_t *cfg, store_conf_t **storep, int *err ) } else return 0; -#if HAVE_LIBSSL +#ifdef HAVE_LIBSSL /* this will probably annoy people, but its the best default just in * case people forget to turn it on */ @@ -1803,7 +1803,7 @@ imap_parse_store( conffile_t *cfg, store_conf_t **storep, int *err ) while (getcline( cfg ) && cfg->cmd) { if (!strcasecmp( "Host", cfg->cmd )) { /* The imap[s]: syntax is just a backwards compat hack. */ -#if HAVE_LIBSSL +#ifdef HAVE_LIBSSL if (!memcmp( "imaps:", cfg->val, 6 )) { cfg->val += 6; server->use_imaps = 1; @@ -1825,7 +1825,7 @@ imap_parse_store( conffile_t *cfg, store_conf_t **storep, int *err ) server->pass = nfstrdup( cfg->val ); else if (!strcasecmp( "Port", cfg->cmd )) server->port = parse_int( cfg ); -#if HAVE_LIBSSL +#ifdef HAVE_LIBSSL else if (!strcasecmp( "CertificateFile", cfg->cmd )) { server->cert_file = expand_strdup( cfg->val ); if (access( server->cert_file, R_OK )) { diff --git a/src/main.c b/src/main.c index 3aa0038..b56d724 100644 --- a/src/main.c +++ b/src/main.c @@ -70,7 +70,7 @@ PACKAGE " " VERSION " - mailbox synchronizer\n" "--create and --expunge can be suffixed with -master/-slave. Read the man page.\n" "\nSupported mailbox formats are: IMAP4rev1, Maildir\n" "\nCompile time options:\n" -#if HAVE_LIBSSL +#ifdef HAVE_LIBSSL " +HAVE_LIBSSL\n" #else " -HAVE_LIBSSL\n"