diff options
author | Tobias Brunner <tobias@strongswan.org> | 2012-09-14 12:06:02 +0200 |
---|---|---|
committer | Tobias Brunner <tobias@strongswan.org> | 2012-09-21 18:16:26 +0200 |
commit | a2a28d90ac72cd53136801aef0aadf80a049df8d (patch) | |
tree | 791af687cc460d445f0b600ea1fe5064727c7ba9 | |
parent | dad6d904ee96a2411c4bfa30cc59f1451f6e13df (diff) | |
download | strongswan-a2a28d90ac72cd53136801aef0aadf80a049df8d.tar.bz2 strongswan-a2a28d90ac72cd53136801aef0aadf80a049df8d.tar.xz |
Make streq() and strcaseeq() static inline functions so they can be used as callbacks
-rw-r--r-- | src/charon-nm/nm/nm_service.c | 2 | ||||
-rw-r--r-- | src/libstrongswan/utils.h | 56 |
2 files changed, 32 insertions, 26 deletions
diff --git a/src/charon-nm/nm/nm_service.c b/src/charon-nm/nm/nm_service.c index fd96f436b..b7155b44b 100644 --- a/src/charon-nm/nm/nm_service.c +++ b/src/charon-nm/nm/nm_service.c @@ -624,7 +624,7 @@ static gboolean need_secrets(NMVPNPlugin *plugin, NMConnection *connection, } } } - else if streq(method, "smartcard") + else if (streq(method, "smartcard")) { if (nm_setting_vpn_get_secret(settings, "password")) { diff --git a/src/libstrongswan/utils.h b/src/libstrongswan/utils.h index ec7173953..f47c65ac1 100644 --- a/src/libstrongswan/utils.h +++ b/src/libstrongswan/utils.h @@ -52,9 +52,33 @@ #define BUF_LEN 512 /** - * Macro compares two strings for equality + * General purpose boolean type. */ -#define streq(x,y) (strcmp(x, y) == 0) +#ifdef HAVE_STDBOOL_H +# include <stdbool.h> +#else +# ifndef HAVE__BOOL +# define _Bool signed char +# endif /* HAVE__BOOL */ +# define bool _Bool +# define false 0 +# define true 1 +# define __bool_true_false_are_defined 1 +#endif /* HAVE_STDBOOL_H */ +#ifndef FALSE +# define FALSE false +#endif /* FALSE */ +#ifndef TRUE +# define TRUE true +#endif /* TRUE */ + +/** + * Helper function that compares two strings for equality + */ +static inline bool streq(const char *x, const char *y) +{ + return strcmp(x, y) == 0; +} /** * Macro compares two strings for equality, length limited @@ -62,9 +86,12 @@ #define strneq(x,y,len) (strncmp(x, y, len) == 0) /** - * Macro compares two strings for equality ignoring case + * Helper function that compares two strings for equality ignoring case */ -#define strcaseeq(x,y) (strcasecmp(x, y) == 0) +static inline bool strcaseeq(const char *x, const char *y) +{ + return strcasecmp(x, y) == 0; +} /** * Macro compares two strings for equality ignoring case, length limited @@ -203,27 +230,6 @@ static inline char *strdupnull(const char *s) #define TIME_32_BIT_SIGNED_MAX 0x7fffffff /** - * General purpose boolean type. - */ -#ifdef HAVE_STDBOOL_H -# include <stdbool.h> -#else -# ifndef HAVE__BOOL -# define _Bool signed char -# endif /* HAVE__BOOL */ -# define bool _Bool -# define false 0 -# define true 1 -# define __bool_true_false_are_defined 1 -#endif /* HAVE_STDBOOL_H */ -#ifndef FALSE -# define FALSE false -#endif /* FALSE */ -#ifndef TRUE -# define TRUE true -#endif /* TRUE */ - -/** * define some missing fixed width int types on OpenSolaris. * TODO: since the uintXX_t types are defined by the C99 standard we should * probably use those anyway |