pacemaker  2.1.8-3980678f03
Scalable High-Availability cluster resource manager
Macros | Functions
strings.c File Reference
#include "crm/common/results.h"
#include <crm_internal.h>
#include <regex.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include <float.h>
#include <limits.h>
#include <bzlib.h>
#include <sys/types.h>
#include <crm/common/util_compat.h>
Include dependency graph for strings.c:

Go to the source code of this file.

Macros

#define _GNU_SOURCE
 

Functions

int pcmk__scan_ll (const char *text, long long *result, long long default_value)
 
int pcmk__scan_min_int (const char *text, int *result, int minimum)
 
int pcmk__scan_port (const char *text, int *port)
 
int pcmk__scan_double (const char *text, double *result, const char *default_text, char **end_text)
 
int pcmk__guint_from_hash (GHashTable *table, const char *key, guint default_val, guint *result)
 
long long crm_get_msec (const char *input)
 Parse a time+units string and return milliseconds equivalent. More...
 
int pcmk_parse_interval_spec (const char *input, guint *result_ms)
 Parse milliseconds from a Pacemaker interval specification. More...
 
gboolean crm_is_true (const char *s)
 
int crm_str_to_boolean (const char *s, int *ret)
 
char * pcmk__trim (char *str)
 
bool pcmk__starts_with (const char *str, const char *prefix)
 Check whether a string starts with a certain sequence. More...
 
bool pcmk__ends_with (const char *s, const char *match)
 
bool pcmk__ends_with_ext (const char *s, const char *match)
 
GHashTable * pcmk__strkey_table (GDestroyNotify key_destroy_func, GDestroyNotify value_destroy_func)
 
void pcmk__insert_dup (GHashTable *table, const char *name, const char *value)
 
GHashTable * pcmk__strikey_table (GDestroyNotify key_destroy_func, GDestroyNotify value_destroy_func)
 
GHashTable * pcmk__str_table_dup (GHashTable *old_table)
 
void pcmk__add_separated_word (GString **list, size_t init_size, const char *word, const char *separator)
 
int pcmk__compress (const char *data, unsigned int length, unsigned int max, char **result, unsigned int *result_len)
 
char * crm_strdup_printf (char const *format,...)
 
int pcmk__parse_ll_range (const char *srcstring, long long *start, long long *end)
 
gboolean pcmk__str_in_list (const gchar *s, const GList *lst, uint32_t flags)
 
bool pcmk__strcase_any_of (const char *s,...)
 
bool pcmk__str_any_of (const char *s,...)
 
int pcmk__numeric_strcasecmp (const char *s1, const char *s2)
 
int pcmk__strcmp (const char *s1, const char *s2, uint32_t flags)
 
char * pcmk__str_copy_as (const char *file, const char *function, uint32_t line, const char *str)
 
void pcmk__str_update (char **str, const char *value)
 
void pcmk__g_strcat (GString *buffer,...)
 
gboolean safe_str_neq (const char *a, const char *b)
 
gboolean crm_str_eq (const char *a, const char *b, gboolean use_case)
 
char * crm_itoa_stack (int an_int, char *buffer, size_t len)
 
guint g_str_hash_traditional (gconstpointer v)
 
gboolean crm_strcase_equal (gconstpointer a, gconstpointer b)
 
guint crm_strcase_hash (gconstpointer v)
 
GHashTable * crm_str_table_dup (GHashTable *old_table)
 
long long crm_parse_ll (const char *text, const char *default_text)
 
int crm_parse_int (const char *text, const char *default_text)
 
char * crm_strip_trailing_newline (char *str)
 
int pcmk_numeric_strcasecmp (const char *s1, const char *s2)
 

Macro Definition Documentation

◆ _GNU_SOURCE

#define _GNU_SOURCE

Definition at line 14 of file strings.c.

Function Documentation

◆ crm_get_msec()

long long crm_get_msec ( const char *  input)

Parse a time+units string and return milliseconds equivalent.

Parameters
[in]inputString with a nonnegative number and optional unit (optionally with whitespace before and/or after the number). If missing, the unit defaults to seconds.
Returns
Milliseconds corresponding to string expression, or PCMK__PARSE_INT_DEFAULT on error

Definition at line 356 of file strings.c.

◆ crm_is_true()

gboolean crm_is_true ( const char *  s)

Definition at line 488 of file strings.c.

◆ crm_itoa_stack()

char* crm_itoa_stack ( int  an_int,
char *  buf,
size_t  len 
)
Deprecated:
Use snprintf() instead

Definition at line 1355 of file strings.c.

◆ crm_parse_int()

int crm_parse_int ( const char *  text,
const char *  default_text 
)
Deprecated:
Use strtoll() instead

Definition at line 1405 of file strings.c.

◆ crm_parse_ll()

long long crm_parse_ll ( const char *  text,
const char *  default_text 
)
Deprecated:
Use strtoll() instead

Definition at line 1388 of file strings.c.

◆ crm_str_eq()

gboolean crm_str_eq ( const char *  a,
const char *  b,
gboolean  use_case 
)
Deprecated:
Use strcmp() or strcasecmp() instead

Definition at line 1335 of file strings.c.

◆ crm_str_table_dup()

GHashTable* crm_str_table_dup ( GHashTable *  old_table)
Deprecated:
Do not use Pacemaker for generic hash table manipulation

Definition at line 1382 of file strings.c.

◆ crm_str_to_boolean()

int crm_str_to_boolean ( const char *  s,
int *  ret 
)

Definition at line 496 of file strings.c.

◆ crm_strcase_equal()

gboolean crm_strcase_equal ( gconstpointer  a,
gconstpointer  b 
)
Deprecated:
Do not use Pacemaker for generic string comparison

Definition at line 1370 of file strings.c.

◆ crm_strcase_hash()

guint crm_strcase_hash ( gconstpointer  v)
Deprecated:
Do not use Pacemaker for generic string manipulation

Definition at line 1376 of file strings.c.

◆ crm_strdup_printf()

char* crm_strdup_printf ( char const *  format,
  ... 
)

Definition at line 889 of file strings.c.

◆ crm_strip_trailing_newline()

char* crm_strip_trailing_newline ( char *  str)
Deprecated:
Don't use Pacemaker for string manipulation

Definition at line 1430 of file strings.c.

◆ g_str_hash_traditional()

guint g_str_hash_traditional ( gconstpointer  v)
Deprecated:
Use g_str_hash() instead

Definition at line 1364 of file strings.c.

◆ pcmk__add_separated_word()

void pcmk__add_separated_word ( GString **  list,
size_t  init_size,
const char *  word,
const char *  separator 
)

Definition at line 794 of file strings.c.

◆ pcmk__compress()

int pcmk__compress ( const char *  data,
unsigned int  length,
unsigned int  max,
char **  result,
unsigned int *  result_len 
)

Definition at line 837 of file strings.c.

◆ pcmk__ends_with()

bool pcmk__ends_with ( const char *  s,
const char *  match 
)

Definition at line 608 of file strings.c.

◆ pcmk__ends_with_ext()

bool pcmk__ends_with_ext ( const char *  s,
const char *  match 
)

Definition at line 635 of file strings.c.

◆ pcmk__g_strcat()

void pcmk__g_strcat ( GString *  buffer,
  ... 
)

Definition at line 1296 of file strings.c.

◆ pcmk__guint_from_hash()

int pcmk__guint_from_hash ( GHashTable *  table,
const char *  key,
guint  default_val,
guint *  result 
)

Definition at line 311 of file strings.c.

◆ pcmk__insert_dup()

void pcmk__insert_dup ( GHashTable *  table,
const char *  name,
const char *  value 
)

Definition at line 701 of file strings.c.

◆ pcmk__numeric_strcasecmp()

int pcmk__numeric_strcasecmp ( const char *  s1,
const char *  s2 
)

Definition at line 1078 of file strings.c.

◆ pcmk__parse_ll_range()

int pcmk__parse_ll_range ( const char *  srcstring,
long long *  start,
long long *  end 
)

Definition at line 903 of file strings.c.

◆ pcmk__scan_double()

int pcmk__scan_double ( const char *  text,
double *  result,
const char *  default_text,
char **  end_text 
)

Definition at line 199 of file strings.c.

◆ pcmk__scan_ll()

int pcmk__scan_ll ( const char *  text,
long long *  result,
long long  default_value 
)

Definition at line 97 of file strings.c.

◆ pcmk__scan_min_int()

int pcmk__scan_min_int ( const char *  text,
int *  result,
int  minimum 
)

Definition at line 127 of file strings.c.

◆ pcmk__scan_port()

int pcmk__scan_port ( const char *  text,
int *  port 
)

Definition at line 161 of file strings.c.

◆ pcmk__starts_with()

bool pcmk__starts_with ( const char *  str,
const char *  prefix 
)

Check whether a string starts with a certain sequence.

Parameters
[in]strString to check
[in]prefixSequence to match against beginning of str
Returns
true if str begins with match, false otherwise
Note
This is equivalent to !strncmp(s, prefix, strlen(prefix)) but is likely less efficient when prefix is a string literal if the compiler optimizes away the strlen() at compile time, and more efficient otherwise.

Definition at line 556 of file strings.c.

◆ pcmk__str_any_of()

bool pcmk__str_any_of ( const char *  s,
  ... 
)

Definition at line 1050 of file strings.c.

◆ pcmk__str_copy_as()

char* pcmk__str_copy_as ( const char *  file,
const char *  function,
uint32_t  line,
const char *  str 
)

Definition at line 1248 of file strings.c.

◆ pcmk__str_in_list()

gboolean pcmk__str_in_list ( const gchar *  s,
const GList *  lst,
uint32_t  flags 
)

Definition at line 981 of file strings.c.

◆ pcmk__str_table_dup()

GHashTable* pcmk__str_table_dup ( GHashTable *  old_table)

Definition at line 766 of file strings.c.

◆ pcmk__str_update()

void pcmk__str_update ( char **  str,
const char *  value 
)

Definition at line 1277 of file strings.c.

◆ pcmk__strcase_any_of()

bool pcmk__strcase_any_of ( const char *  s,
  ... 
)

Definition at line 1026 of file strings.c.

◆ pcmk__strcmp()

int pcmk__strcmp ( const char *  s1,
const char *  s2,
uint32_t  flags 
)

Definition at line 1163 of file strings.c.

◆ pcmk__strikey_table()

GHashTable* pcmk__strikey_table ( GDestroyNotify  key_destroy_func,
GDestroyNotify  value_destroy_func 
)

Definition at line 739 of file strings.c.

◆ pcmk__strkey_table()

GHashTable* pcmk__strkey_table ( GDestroyNotify  key_destroy_func,
GDestroyNotify  value_destroy_func 
)

Definition at line 683 of file strings.c.

◆ pcmk__trim()

char* pcmk__trim ( char *  str)

Definition at line 528 of file strings.c.

◆ pcmk_numeric_strcasecmp()

int pcmk_numeric_strcasecmp ( const char *  s1,
const char *  s2 
)
Deprecated:
Don't use Pacemaker for string manipulation

Definition at line 1436 of file strings.c.

◆ pcmk_parse_interval_spec()

int pcmk_parse_interval_spec ( const char *  input,
guint *  result_ms 
)

Parse milliseconds from a Pacemaker interval specification.

Parameters
[in]inputPacemaker time interval specification (a bare number of seconds; a number with a unit, optionally with whitespace before and/or after the number; or an ISO 8601 duration)
[out]result_msWhere to store milliseconds equivalent of input on success (limited to the range of an unsigned integer), or 0 if input is NULL or invalid
Returns
Standard Pacemaker return code (specifically, pcmk_rc_ok if input is valid or NULL, and EINVAL otherwise)

Definition at line 451 of file strings.c.

◆ safe_str_neq()

gboolean safe_str_neq ( const char *  a,
const char *  b 
)
Deprecated:
Use strcmp() instead

Definition at line 1320 of file strings.c.