pacemaker  2.0.3-4b1f869f0f
Scalable High-Availability cluster resource manager
Macros | Functions
strings.c File Reference
#include <crm_internal.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <limits.h>
#include <bzlib.h>
#include <sys/types.h>
Include dependency graph for strings.c:

Go to the source code of this file.

Macros

#define _GNU_SOURCE
 

Functions

char * crm_itoa_stack (int an_int, char *buffer, size_t len)
 
long long crm_int_helper (const char *text, char **end_text)
 
long long crm_parse_ll (const char *text, const char *default_text)
 Parse a long long integer value from a string. More...
 
int crm_parse_int (const char *text, const char *default_text)
 Parse an integer value from a string. More...
 
guint crm_parse_ms (const char *text)
 
gboolean safe_str_neq (const char *a, const char *b)
 
gboolean crm_is_true (const char *s)
 
int crm_str_to_boolean (const char *s, int *ret)
 
char * crm_strip_trailing_newline (char *str)
 
gboolean crm_str_eq (const char *a, const char *b, gboolean use_case)
 
bool crm_starts_with (const char *str, const char *prefix)
 Check whether a string starts with a certain sequence. More...
 
gboolean crm_ends_with (const char *s, const char *match)
 
gboolean crm_ends_with_ext (const char *s, const char *match)
 
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)
 
char * add_list_element (char *list, const char *value)
 
bool crm_compress_string (const char *data, int length, int max, char **result, unsigned int *result_len)
 
gint crm_alpha_sort (gconstpointer a, gconstpointer b)
 Compare two strings alphabetically (case-insensitive) More...
 
char * crm_strdup_printf (char const *format,...)
 

Macro Definition Documentation

◆ _GNU_SOURCE

#define _GNU_SOURCE

Definition at line 13 of file strings.c.

Function Documentation

◆ add_list_element()

char* add_list_element ( char *  list,
const char *  value 
)

Definition at line 412 of file strings.c.

◆ crm_alpha_sort()

gint crm_alpha_sort ( gconstpointer  a,
gconstpointer  b 
)

Compare two strings alphabetically (case-insensitive)

Parameters
[in]aFirst string to compare
[in]bSecond string to compare
Returns
0 if strings are equal, -1 if a < b, 1 if a > b
Note
Usable as a GCompareFunc with g_list_sort(). NULL is considered less than non-NULL.

Definition at line 493 of file strings.c.

◆ crm_compress_string()

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

Definition at line 431 of file strings.c.

◆ crm_ends_with()

gboolean crm_ends_with ( const char *  s,
const char *  match 
)

Definition at line 313 of file strings.c.

◆ crm_ends_with_ext()

gboolean crm_ends_with_ext ( const char *  s,
const char *  match 
)

Definition at line 342 of file strings.c.

◆ crm_int_helper()

long long crm_int_helper ( const char *  text,
char **  end_text 
)

Definition at line 34 of file strings.c.

◆ crm_is_true()

gboolean crm_is_true ( const char *  s)

Definition at line 176 of file strings.c.

◆ crm_itoa_stack()

char* crm_itoa_stack ( int  an_int,
char *  buffer,
size_t  len 
)

Definition at line 24 of file strings.c.

◆ crm_parse_int()

int crm_parse_int ( const char *  text,
const char *  default_text 
)

Parse an integer value from a string.

Parameters
[in]textThe string to parse
[in]default_textDefault string to parse if text is NULL
Returns
Parsed value on success, INT_MIN or INT_MAX (and set errno to ERANGE) if parsed value is out of integer range, otherwise -1 (and set errno)

Definition at line 114 of file strings.c.

◆ crm_parse_ll()

long long crm_parse_ll ( const char *  text,
const char *  default_text 
)

Parse a long long integer value from a string.

Parameters
[in]textThe string to parse
[in]default_textDefault string to parse if text is NULL
Returns
Parsed value on success, -1 (and set errno) on error

Definition at line 91 of file strings.c.

◆ crm_parse_ms()

guint crm_parse_ms ( const char *  text)

Definition at line 147 of file strings.c.

◆ crm_starts_with()

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

Check whether a string starts with a certain sequence.

Parameters
[in]strString to check
[in]matchSequence 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 263 of file strings.c.

◆ crm_str_eq()

gboolean crm_str_eq ( const char *  a,
const char *  b,
gboolean  use_case 
)

Definition at line 224 of file strings.c.

◆ crm_str_table_dup()

GHashTable* crm_str_table_dup ( GHashTable *  old_table)

Definition at line 400 of file strings.c.

◆ crm_str_to_boolean()

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

Definition at line 187 of file strings.c.

◆ crm_strcase_equal()

gboolean crm_strcase_equal ( gconstpointer  a,
gconstpointer  b 
)

Definition at line 374 of file strings.c.

◆ crm_strcase_hash()

guint crm_strcase_hash ( gconstpointer  v)

Definition at line 380 of file strings.c.

◆ crm_strdup_printf()

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

Definition at line 506 of file strings.c.

◆ crm_strip_trailing_newline()

char* crm_strip_trailing_newline ( char *  str)

Definition at line 208 of file strings.c.

◆ g_str_hash_traditional()

guint g_str_hash_traditional ( gconstpointer  v)

Definition at line 361 of file strings.c.

◆ safe_str_neq()

gboolean safe_str_neq ( const char *  a,
const char *  b 
)

Definition at line 161 of file strings.c.