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 32 const char *default_text,
char **end_text);
40 const char *separator);
42 char **result,
unsigned int *result_len);
44 int pcmk__scan_ll(
const char *text,
long long *result,
long long default_value);
50 GDestroyNotify value_destroy_func);
52 GDestroyNotify value_destroy_func);
65 static inline GHashTable *
66 pcmk__intkey_table(GDestroyNotify value_destroy_func)
68 return g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL,
84 static inline gboolean
85 pcmk__intkey_table_insert(GHashTable *hash_table,
int key, gpointer value)
87 return g_hash_table_insert(hash_table, GINT_TO_POINTER(key), value);
99 static inline gpointer
100 pcmk__intkey_table_lookup(GHashTable *hash_table,
int key)
102 return g_hash_table_lookup(hash_table, GINT_TO_POINTER(key));
114 static inline gboolean
115 pcmk__intkey_table_remove(GHashTable *hash_table,
int key)
117 return g_hash_table_remove(hash_table, GINT_TO_POINTER(key));
130 pcmk__str_eq(const
char *s1, const
char *s2, uint32_t
flags)
137 pcmk__add_word(
char **list,
size_t *len,
const char *word)
160 #define pcmk__plural_alt(i, s1, s2) (((i) == 1)? (s1) : (s2)) 163 #define pcmk__plural_s(i) pcmk__plural_alt(i, "", "s") 166 pcmk__str_empty(
const char *s)
168 return (s == NULL) || (s[0] ==
'\0');
172 pcmk__itoa(
int an_int)
178 pcmk__ftoa(
double a_float)
184 pcmk__ttoa(time_t epoch_time)
190 static inline const char *
191 pcmk__btoa(
bool condition)
193 return condition?
"true" :
"false";
void pcmk__add_separated_word(char **list, size_t *len, const char *word, const char *separator)
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
gboolean pcmk__str_in_list(GList *lst, const gchar *s, uint32_t flags)
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)
char * crm_strdup_printf(char const *format,...) G_GNUC_PRINTF(1
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)
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)