]> www.infradead.org Git - users/dwmw2/openconnect.git/commitdiff
Get rid of LIBSTOKEN_HDR and LIBOATH_HDR
authorKevin Cernekee <cernekee@gmail.com>
Mon, 25 Mar 2013 01:13:57 +0000 (18:13 -0700)
committerDavid Woodhouse <David.Woodhouse@intel.com>
Mon, 25 Mar 2013 15:30:26 +0000 (15:30 +0000)
Unlike libproxy, these two libraries have well-defined names for their
respective header files.  So include the headers by name, and use
HAVE_LIBSTOKEN / HAVE_LIBOATH for compile-time tests.

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
auth.c
configure.ac
library.c
main.c
openconnect-internal.h

diff --git a/auth.c b/auth.c
index e3f80da035357f7559c9a186af699d728658ca41..c3bc4fbc720696ecd8e9db7c0af64a9b5815c6de 100644 (file)
--- a/auth.c
+++ b/auth.c
 #include <ctype.h>
 #include <errno.h>
 
-#ifdef LIBSTOKEN_HDR
-#include LIBSTOKEN_HDR
+#ifdef HAVE_LIBSTOKEN
+#include <stoken.h>
 #endif
 
-#ifdef LIBOATH_HDR
-#include LIBOATH_HDR
+#ifdef HAVE_LIBOATH
+#include <liboath/oath.h>
 #endif
 
 #include <libxml/parser.h>
@@ -849,7 +849,7 @@ bad:
 }
 
 
-#ifdef LIBSTOKEN_HDR
+#ifdef HAVE_LIBSTOKEN
 static void nuke_opt_values(struct oc_form_opt *opt)
 {
        for (; opt; opt = opt->next) {
@@ -873,7 +873,7 @@ static void nuke_opt_values(struct oc_form_opt *opt)
  */
 int prepare_stoken(struct openconnect_info *vpninfo)
 {
-#ifdef LIBSTOKEN_HDR
+#ifdef HAVE_LIBSTOKEN
        struct oc_auth_form form;
        struct oc_form_opt opts[3], *opt = opts;
        char **devid = NULL, **pass = NULL, **pin = NULL;
@@ -998,7 +998,7 @@ static int can_gen_stoken_code(struct openconnect_info *vpninfo,
                               struct oc_auth_form *form,
                               struct oc_form_opt *opt)
 {
-#ifdef LIBSTOKEN_HDR
+#ifdef HAVE_LIBSTOKEN
        if ((strcmp(opt->name, "password") && strcmp(opt->name, "answer")) ||
            vpninfo->token_bypassed)
                return -EINVAL;
@@ -1031,7 +1031,7 @@ static int can_gen_totp_code(struct openconnect_info *vpninfo,
                             struct oc_auth_form *form,
                             struct oc_form_opt *opt)
 {
-#if defined(LIBOATH_HDR)
+#ifdef HAVE_LIBOATH
        if ((strcmp(opt->name, "secondary_password") != 0) ||
            vpninfo->token_bypassed)
                return -EINVAL;
@@ -1079,7 +1079,7 @@ static int do_gen_stoken_code(struct openconnect_info *vpninfo,
                              struct oc_auth_form *form,
                              struct oc_form_opt *opt)
 {
-#ifdef LIBSTOKEN_HDR
+#ifdef HAVE_LIBSTOKEN
        char tokencode[STOKEN_MAX_TOKENCODE + 1];
 
        if (!vpninfo->token_time)
@@ -1105,7 +1105,7 @@ static int do_gen_totp_code(struct openconnect_info *vpninfo,
                            struct oc_auth_form *form,
                            struct oc_form_opt *opt)
 {
-#if defined(LIBOATH_HDR)
+#ifdef HAVE_LIBOATH
        int oath_err;
        char tokencode[7];
 
index 10cb1b4da1662cbfdf974a803d1dd0c49daaa05c..81635f3c1cc9662248520d30a6cb9b1e95fc0292 100644 (file)
@@ -499,7 +499,7 @@ AC_ARG_WITH([stoken],
 AS_IF([test "x$with_stoken" != "xno"], [
        PKG_CHECK_MODULES(LIBSTOKEN, stoken,
                        [AC_SUBST(LIBSTOKEN_PC, stoken)
-                        AC_DEFINE([LIBSTOKEN_HDR], ["stoken.h"])
+                        AC_DEFINE([HAVE_LIBSTOKEN], 1)
                         libstoken_pkg=yes],
                         libstoken_pkg=no)
 ], [libstoken_pkg=disabled])
@@ -510,7 +510,7 @@ AC_ARG_WITH([liboath],
 AS_IF([test "x$with_liboath" != "xno"], [
        PKG_CHECK_MODULES(LIBOATH, liboath,
                [AC_SUBST(LIBOATH_PC, liboath)
-                AC_DEFINE([LIBOATH_HDR], ["liboath/oath.h"])
+                AC_DEFINE([HAVE_LIBOATH], 1)
                 liboath_pkg=yes],
                 liboath_pkg=no)
 ])
index c0db569b8c730bc0427a67fbb89cd6bac4046fce..c6f7a40ab54903e20fe640a9acc54b7fc4c49648 100644 (file)
--- a/library.c
+++ b/library.c
 #include <errno.h>
 #include <stdlib.h>
 
-#ifdef LIBSTOKEN_HDR
-#include LIBSTOKEN_HDR
+#ifdef HAVE_LIBSTOKEN
+#include <stoken.h>
 #endif
 
-#ifdef LIBOATH_HDR
-#include LIBOATH_HDR
+#ifdef HAVE_LIBOATH
+#include <liboath/oath.h>
 #endif
 
 #include <libxml/tree.h>
@@ -144,13 +144,13 @@ void openconnect_vpninfo_free(struct openconnect_info *vpninfo)
                vpninfo->peer_cert = NULL;
        }
        free(vpninfo->useragent);
-#ifdef LIBSTOKEN_HDR
+#ifdef HAVE_LIBSTOKEN
        if (vpninfo->stoken_pin)
                free(vpninfo->stoken_pin);
        if (vpninfo->stoken_ctx)
                stoken_destroy(vpninfo->stoken_ctx);
 #endif
-#ifdef LIBOATH_HDR
+#ifdef HAVE_LIBOATH
        if (vpninfo->oath_secret)
                oath_done();
 #endif
@@ -323,7 +323,7 @@ int openconnect_has_tss_blob_support(void)
 
 int openconnect_has_stoken_support(void)
 {
-#ifdef LIBSTOKEN_HDR
+#ifdef HAVE_LIBSTOKEN
        return 1;
 #else
        return 0;
@@ -332,7 +332,7 @@ int openconnect_has_stoken_support(void)
 
 int openconnect_has_oath_support(void)
 {
-#ifdef LIBOATH_HDR
+#ifdef HAVE_LIBOATH
        return 1;
 #else
        return 0;
@@ -342,7 +342,7 @@ int openconnect_has_oath_support(void)
 static int set_libstoken_mode(struct openconnect_info *vpninfo,
                              const char *token_str)
 {
-#ifdef LIBSTOKEN_HDR
+#ifdef HAVE_LIBSTOKEN
        int ret;
 
        if (!vpninfo->stoken_ctx) {
@@ -367,7 +367,7 @@ static int set_libstoken_mode(struct openconnect_info *vpninfo,
 static int set_oath_mode(struct openconnect_info *vpninfo,
                         const char *token_str)
 {
-#ifdef LIBOATH_HDR
+#ifdef HAVE_LIBOATH
        int ret;
 
        ret = oath_init();
diff --git a/main.c b/main.c
index f8ce9d846cfe71aec80e5ad05513b639291e6066..3d081309bbcdce51af51f04f52acb47ee3f52bcd 100644 (file)
--- a/main.c
+++ b/main.c
@@ -293,10 +293,10 @@ static void usage(void)
        printf("      --token-mode=MODE           %s\n", _("Software token type: stoken (default) or totp"));
        printf("      --token-secret[=STRING]     %s\n", _("Software token secret (can be empty for stoken mode"));
        printf("                                  %s\n", _("    to read from ~/.stokenrc)"));
-#ifndef LIBSTOKEN_HDR
+#ifndef HAVE_LIBSTOKEN
        printf("                                  %s\n", _("(NOTE: libstoken (RSA SecurID) disabled in this build)"));
 #endif
-#ifndef LIBOATH_HDR
+#ifndef HAVE_LIBOATH
        printf("                                  %s\n", _("(NOTE: liboath (TOTP) disabled in this build)"));
 #endif
        printf("      --reconnect-timeout         %s\n", _("Connection retry timeout in seconds"));
index 1ca93f6fa65304726bc79a9e9d242f9cf30b01e2..51172af09a1ca45d783716635e1169b655c5b8eb 100644 (file)
@@ -62,8 +62,8 @@
 #include LIBPROXY_HDR
 #endif
 
-#ifdef LIBSTOKEN_HDR
-#include LIBSTOKEN_HDR
+#ifdef HAVE_LIBSTOKEN
+#include <stoken.h>
 #endif
 
 #ifdef ENABLE_NLS
@@ -185,11 +185,11 @@ struct openconnect_info {
        int token_bypassed;
        int token_tries;
        time_t token_time;
-#ifdef LIBSTOKEN_HDR
+#ifdef HAVE_LIBSTOKEN
        struct stoken_ctx *stoken_ctx;
        char *stoken_pin;
 #endif
-#ifdef LIBOATH_HDR
+#ifdef HAVE_LIBOATH
        char *oath_secret;
        size_t oath_secret_len;
 #endif