add a_strcmp function

This commit is contained in:
Julien Danjou 2007-09-21 13:09:23 +02:00
parent c80855836a
commit 1340d926ce
1 changed files with 14 additions and 0 deletions

14
util.h
View File

@ -27,6 +27,9 @@
#include <stdlib.h>
#include "config.h"
/** \brief replace \c NULL strings with emtpy strings */
#define NONULL(x) (x ? x : "")
#define ssizeof(foo) (ssize_t)sizeof(foo)
#define countof(foo) (ssizeof(foo) / ssizeof(foo[0]))
@ -118,6 +121,17 @@ static inline char *a_strdup(const char *s)
return len ? p_dup(s, len + 1) : NULL;
}
/** \brief \c NULL resistant strcmp.
* \param[in] a the first string.
* \param[in] b the second string.
* \return <tt>strcmp(a, b)</tt>, and treats \c NULL strings like \c ""
* ones.
*/
static inline int a_strcmp(const char *a, const char *b)
{
return strcmp(NONULL(a), NONULL(b));
}
void die(const char *, ...) __attribute__ ((noreturn)) __attribute__ ((format(printf, 1, 2)));
void eprint(const char *, ...) __attribute__ ((noreturn)) __attribute__ ((format(printf, 1, 2)));
void uicb_spawn(Display *, DC *, awesome_config *, const char *);