10 #ifndef PCMK__STRINGS_INTERNAL__H 11 #define PCMK__STRINGS_INTERNAL__H 19 #define PCMK__PARSE_INT_DEFAULT -1 20 #define PCMK__PARSE_DBL_DEFAULT -1.0 33 const char *default_text,
char **end_text);
41 const char *word,
const char *separator);
43 char **
result,
unsigned int *result_len);
51 GDestroyNotify value_destroy_func);
53 GDestroyNotify value_destroy_func);
65 static inline const char *
66 pcmk__s(
const char *s,
const char *default_value)
68 return (s == NULL)? default_value : s;
81 static inline GHashTable *
82 pcmk__intkey_table(GDestroyNotify value_destroy_func)
84 return g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL,
100 static inline gboolean
101 pcmk__intkey_table_insert(GHashTable *hash_table,
int key, gpointer value)
103 return g_hash_table_insert(hash_table, GINT_TO_POINTER(key), value);
115 static inline gpointer
116 pcmk__intkey_table_lookup(GHashTable *hash_table,
int key)
118 return g_hash_table_lookup(hash_table, GINT_TO_POINTER(key));
130 static inline gboolean
131 pcmk__intkey_table_remove(GHashTable *hash_table,
int key)
133 return g_hash_table_remove(hash_table, GINT_TO_POINTER(key));
148 pcmk__str_eq(const
char *s1, const
char *s2, uint32_t
flags)
155 pcmk__add_word(GString **list,
size_t init_size,
const char *word)
178 #define pcmk__plural_alt(i, s1, s2) (((i) == 1)? (s1) : (s2)) 181 #define pcmk__plural_s(i) pcmk__plural_alt(i, "", "s") 184 pcmk__str_empty(
const char *s)
186 return (s == NULL) || (s[0] ==
'\0');
190 pcmk__itoa(
int an_int)
196 pcmk__ftoa(
double a_float)
202 pcmk__ttoa(time_t epoch_time)
208 static inline const char *
209 pcmk__btoa(
bool condition)
211 return condition?
"true" :
"false";
bool pcmk__char_in_any_str(int ch,...) G_GNUC_NULL_TERMINATED
int pcmk__scan_min_int(const char *text, int *result, int minimum)
bool pcmk__strcase_any_of(const char *s,...) G_GNUC_NULL_TERMINATED
void pcmk__add_separated_word(GString **list, size_t init_size, const char *word, const char *separator)
bool pcmk__ends_with(const char *s, const char *match)
int pcmk__scan_ll(const char *text, long long *result, long long default_value)
int pcmk__scan_port(const char *text, int *port)
int pcmk__guint_from_hash(GHashTable *table, const char *key, guint default_val, guint *result)
void pcmk__g_strcat(GString *buffer,...) G_GNUC_NULL_TERMINATED
char * crm_strdup_printf(char const *format,...) G_GNUC_PRINTF(1
void pcmk__str_update(char **str, const char *value)
int pcmk__compress(const char *data, unsigned int length, unsigned int max, char **result, unsigned int *result_len)
bool pcmk__str_any_of(const char *s,...) G_GNUC_NULL_TERMINATED
int pcmk__scan_double(const char *text, double *result, const char *default_text, char **end_text)
GHashTable * pcmk__strkey_table(GDestroyNotify key_destroy_func, GDestroyNotify value_destroy_func)
pcmk__action_result_t result
GHashTable * pcmk__str_table_dup(GHashTable *old_table)
int pcmk__strcmp(const char *s1, const char *s2, uint32_t flags)
int pcmk__numeric_strcasecmp(const char *s1, const char *s2)
int pcmk__parse_ll_range(const char *srcstring, long long *start, long long *end)
bool pcmk__starts_with(const char *str, const char *prefix)
Check whether a string starts with a certain sequence.
char * pcmk__trim(char *str)
bool pcmk__ends_with_ext(const char *s, const char *match)
GHashTable * pcmk__strikey_table(GDestroyNotify key_destroy_func, GDestroyNotify value_destroy_func)
gboolean pcmk__str_in_list(const gchar *s, const GList *lst, uint32_t flags)