Make streq() and strcaseeq() static inline functions so they can be used as callbacks

This commit is contained in:
Tobias Brunner 2012-09-14 12:06:02 +02:00
parent dad6d904ee
commit a2a28d90ac
2 changed files with 32 additions and 26 deletions

View File

@ -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"))
{

View File

@ -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
@ -202,27 +229,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