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);
66 static inline const char *
67 pcmk__s(
const char *s,
const char *default_value)
69 return (s == NULL)? default_value : s;
82 static inline GHashTable *
83 pcmk__intkey_table(GDestroyNotify value_destroy_func)
85 return g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL,
101 static inline gboolean
102 pcmk__intkey_table_insert(GHashTable *hash_table,
int key, gpointer value)
104 return g_hash_table_insert(hash_table, GINT_TO_POINTER(key), value);
116 static inline gpointer
117 pcmk__intkey_table_lookup(GHashTable *hash_table,
int key)
119 return g_hash_table_lookup(hash_table, GINT_TO_POINTER(key));
131 static inline gboolean
132 pcmk__intkey_table_remove(GHashTable *hash_table,
int key)
134 return g_hash_table_remove(hash_table, GINT_TO_POINTER(key));
159 #define pcmk__str_copy(str) pcmk__str_copy_as(__FILE__, __func__, __LINE__, str) 166 pcmk__str_eq(const
char *s1, const
char *s2, uint32_t
flags)
173 pcmk__add_word(GString **list,
size_t init_size,
const char *word)
196 #define pcmk__plural_alt(i, s1, s2) (((i) == 1)? (s1) : (s2)) 199 #define pcmk__plural_s(i) pcmk__plural_alt(i, "", "s") 202 pcmk__str_empty(
const char *s)
204 return (s == NULL) || (s[0] ==
'\0');
208 pcmk__itoa(
int an_int)
214 pcmk__ftoa(
double a_float)
220 pcmk__ttoa(time_t epoch_time)
226 static inline const char *
227 pcmk__btoa(
bool condition)
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
char * pcmk__str_copy_as(const char *file, const char *function, uint32_t line, const char *str)
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)
void pcmk__insert_dup(GHashTable *table, const char *name, const char *value)
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)