10 #ifndef PCMK__CRM_COMMON_STRINGS_INTERNAL__H 11 #define PCMK__CRM_COMMON_STRINGS_INTERNAL__H 27 #define PCMK__PARSE_INT_DEFAULT -1 28 #define PCMK__PARSE_DBL_DEFAULT -1.0 41 const char *default_text,
char **end_text);
49 const char *word,
const char *separator);
51 char **
result,
unsigned int *result_len);
59 GDestroyNotify value_destroy_func);
61 GDestroyNotify value_destroy_func);
74 static inline const char *
75 pcmk__s(
const char *s,
const char *default_value)
77 return (s == NULL)? default_value : s;
90 static inline GHashTable *
91 pcmk__intkey_table(GDestroyNotify value_destroy_func)
93 return g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL,
109 static inline gboolean
110 pcmk__intkey_table_insert(GHashTable *hash_table,
int key, gpointer value)
112 return g_hash_table_insert(hash_table, GINT_TO_POINTER(key), value);
124 static inline gpointer
125 pcmk__intkey_table_lookup(GHashTable *hash_table,
int key)
127 return g_hash_table_lookup(hash_table, GINT_TO_POINTER(key));
139 static inline gboolean
140 pcmk__intkey_table_remove(GHashTable *hash_table,
int key)
142 return g_hash_table_remove(hash_table, GINT_TO_POINTER(key));
167 #define pcmk__str_copy(str) pcmk__str_copy_as(__FILE__, __func__, __LINE__, str) 174 pcmk__str_eq(const
char *s1, const
char *s2, uint32_t
flags)
181 pcmk__add_word(GString **list,
size_t init_size,
const char *word)
204 #define pcmk__plural_alt(i, s1, s2) (((i) == 1)? (s1) : (s2)) 207 #define pcmk__plural_s(i) pcmk__plural_alt(i, "", "s") 210 pcmk__str_empty(
const char *s)
212 return (s == NULL) || (s[0] ==
'\0');
216 pcmk__itoa(
int an_int)
222 pcmk__ftoa(
double a_float)
228 pcmk__ttoa(time_t epoch_time)
234 static inline const char *
235 pcmk__btoa(
bool condition)
244 #endif // PCMK__CRM_COMMON_STRINGS_INTERNAL__H
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
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)
char * crm_strdup_printf(char const *format,...) G_GNUC_PRINTF(1
gboolean pcmk__str_in_list(const gchar *s, const GList *lst, uint32_t flags)