Introduce STR_EQ and STRN_EQ macros

This commit is contained in:
Benedikt Heine 2018-10-09 00:17:55 +02:00
parent 516161e765
commit bb02897bc8
4 changed files with 12 additions and 1 deletions

View File

@ -8,6 +8,8 @@
#include <glib.h>
#include "utils.h"
static GLogLevelFlags log_level = G_LOG_LEVEL_WARNING;
/* see log.h */

View File

@ -6,7 +6,6 @@
#include <glib.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include "log.h"

View File

@ -3,9 +3,18 @@
#define DUNST_UTILS_H
#include <glib.h>
#include <string.h>
//! Test if a string is NULL or empty
#define STR_EMPTY(s) (!s || (*s == '\0'))
//! Test if a string is non-NULL and not empty
#define STR_FULL(s) !(STR_EMPTY(s))
//! Test if string a and b contain the same chars
#define STR_EQ(a, b) (strcmp(a, b) == 0)
//! Test if string a and b are same up to n chars
#define STRN_EQ(a, b, n) (strncmp(a, b, n) == 0)
//! Test if string a and b are the same case-insensitively
#define STR_CASEQ(a, b) (strcasecmp(a, b) == 0)
/* replace all occurrences of the character needle with the character replacement in haystack */
char *string_replace_char(char needle, char replacement, char *haystack);

View File

@ -17,6 +17,7 @@
#include "src/log.h"
#include "src/settings.h"
#include "src/utils.h"
#include "x.h"
struct screen_info *screens;