Skip to content

Commit

Permalink
Work around warnings caused by Solaris misdefinition of 'struct option'.
Browse files Browse the repository at this point in the history
Its man page clearly states that the 'name' field in 'struct option' is a
const char *. It lies, and the compiler bitches about normal assignment
of static strings.

https://www.illumos.org/issues/1881

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
  • Loading branch information
David Woodhouse authored and David Woodhouse committed Apr 19, 2012
1 parent e7afe3b commit 81cc12e
Showing 1 changed file with 58 additions and 48 deletions.
106 changes: 58 additions & 48 deletions main.c
Expand Up @@ -98,55 +98,65 @@ enum {
OPT_NON_INTER,
};

#ifdef __sun__
/*
* The 'name' field in Solaris 'struct option' lacks the 'const', and causes
* lots of warnings unless we cast it... https://www.illumos.org/issues/1881
*/
#define OPTION(name, arg, abbrev) {(char *)name, arg, NULL, abbrev}
#else
#define OPTION(name, arg, abbrev) {name, arg, NULL, abbrev}
#endif

static struct option long_options[] = {
{"background", 0, 0, 'b'},
{"pid-file", 1, 0, OPT_PIDFILE},
{"certificate", 1, 0, 'c'},
{"sslkey", 1, 0, 'k'},
{"cookie", 1, 0, 'C'},
{"deflate", 0, 0, 'd'},
{"no-deflate", 0, 0, 'D'},
{"cert-expire-warning", 1, 0, 'e'},
{"usergroup", 1, 0, 'g'},
{"help", 0, 0, 'h'},
{"interface", 1, 0, 'i'},
{"mtu", 1, 0, 'm'},
{"setuid", 1, 0, 'U'},
{"script", 1, 0, 's'},
{"script-tun", 0, 0, 'S'},
{"syslog", 0, 0, 'l'},
{"key-type", 1, 0, 'K'},
{"key-password", 1, 0, 'p'},
{"proxy", 1, 0, 'P'},
{"user", 1, 0, 'u'},
{"verbose", 0, 0, 'v'},
{"version", 0, 0, 'V'},
{"cafile", 1, 0, OPT_CAFILE},
{"no-dtls", 0, 0, OPT_NO_DTLS},
{"cookieonly", 0, 0, OPT_COOKIEONLY},
{"printcookie", 0, 0, OPT_PRINTCOOKIE},
{"quiet", 0, 0, 'q'},
{"queue-len", 1, 0, 'Q'},
{"xmlconfig", 1, 0, 'x'},
{"cookie-on-stdin", 0, 0, OPT_COOKIE_ON_STDIN},
{"passwd-on-stdin", 0, 0, OPT_PASSWORD_ON_STDIN},
{"no-passwd", 0, 0, OPT_NO_PASSWD},
{"reconnect-timeout", 1, 0, OPT_RECONNECT_TIMEOUT},
{"dtls-ciphers", 1, 0, OPT_DTLS_CIPHERS},
{"authgroup", 1, 0, OPT_AUTHGROUP},
{"servercert", 1, 0, OPT_SERVERCERT},
{"key-password-from-fsid", 0, 0, OPT_KEY_PASSWORD_FROM_FSID},
{"useragent", 1, 0, OPT_USERAGENT},
{"csd-user", 1, 0, OPT_CSD_USER},
{"csd-wrapper", 1, 0, OPT_CSD_WRAPPER},
{"disable-ipv6", 0, 0, OPT_DISABLE_IPV6},
{"no-proxy", 0, 0, OPT_NO_PROXY},
{"libproxy", 0, 0, OPT_LIBPROXY},
{"no-http-keepalive", 0, 0, OPT_NO_HTTP_KEEPALIVE},
{"no-cert-check", 0, 0, OPT_NO_CERT_CHECK},
{"force-dpd", 1, 0, OPT_FORCE_DPD},
{"non-inter", 0, 0, OPT_NON_INTER},
{NULL, 0, 0, 0},
OPTION("background", 0, 'b'),
OPTION("pid-file", 1, OPT_PIDFILE),
OPTION("certificate", 1, 'c'),
OPTION("sslkey", 1, 'k'),
OPTION("cookie", 1, 'C'),
OPTION("deflate", 0, 'd'),
OPTION("no-deflate", 0, 'D'),
OPTION("cert-expire-warning", 1, 'e'),
OPTION("usergroup", 1, 'g'),
OPTION("help", 0, 'h'),
OPTION("interface", 1, 'i'),
OPTION("mtu", 1, 'm'),
OPTION("setuid", 1, 'U'),
OPTION("script", 1, 's'),
OPTION("script-tun", 0, 'S'),
OPTION("syslog", 0, 'l'),
OPTION("key-type", 1, 'K'),
OPTION("key-password", 1, 'p'),
OPTION("proxy", 1, 'P'),
OPTION("user", 1, 'u'),
OPTION("verbose", 0, 'v'),
OPTION("version", 0, 'V'),
OPTION("cafile", 1, OPT_CAFILE),
OPTION("no-dtls", 0, OPT_NO_DTLS),
OPTION("cookieonly", 0, OPT_COOKIEONLY),
OPTION("printcookie", 0, OPT_PRINTCOOKIE),
OPTION("quiet", 0, 'q'),
OPTION("queue-len", 1, 'Q'),
OPTION("xmlconfig", 1, 'x'),
OPTION("cookie-on-stdin", 0, OPT_COOKIE_ON_STDIN),
OPTION("passwd-on-stdin", 0, OPT_PASSWORD_ON_STDIN),
OPTION("no-passwd", 0, OPT_NO_PASSWD),
OPTION("reconnect-timeout", 1, OPT_RECONNECT_TIMEOUT),
OPTION("dtls-ciphers", 1, OPT_DTLS_CIPHERS),
OPTION("authgroup", 1, OPT_AUTHGROUP),
OPTION("servercert", 1, OPT_SERVERCERT),
OPTION("key-password-from-fsid", 0, OPT_KEY_PASSWORD_FROM_FSID),
OPTION("useragent", 1, OPT_USERAGENT),
OPTION("csd-user", 1, OPT_CSD_USER),
OPTION("csd-wrapper", 1, OPT_CSD_WRAPPER),
OPTION("disable-ipv6", 0, OPT_DISABLE_IPV6),
OPTION("no-proxy", 0, OPT_NO_PROXY),
OPTION("libproxy", 0, OPT_LIBPROXY),
OPTION("no-http-keepalive", 0, OPT_NO_HTTP_KEEPALIVE),
OPTION("no-cert-check", 0, OPT_NO_CERT_CHECK),
OPTION("force-dpd", 1, OPT_FORCE_DPD),
OPTION("non-inter", 0, OPT_NON_INTER),
OPTION(NULL, 0, 0)
};

static void helpmessage(void)
Expand Down

0 comments on commit 81cc12e

Please sign in to comment.