pacemaker  2.1.0-7c3f660
Scalable High-Availability cluster resource manager
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Macros | Functions
strings.c File Reference
#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 <math.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
 
#define NUMCHARS   "0123456789."
 
#define WHITESPACE   " \t\n\r\f"
 

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...
 
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)
 
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 (char **list, size_t *len, 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 (GList *lst, const gchar *s)
 
bool pcmk__strcase_any_of (const char *s,...)
 
bool pcmk__str_any_of (const char *s,...)
 
bool pcmk__char_in_any_str (int ch,...)
 
int pcmk__numeric_strcasecmp (const char *s1, const char *s2)
 
int pcmk__strcmp (const char *s1, const char *s2, uint32_t flags)
 
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

#define _GNU_SOURCE

Definition at line 13 of file strings.c.

#define NUMCHARS   "0123456789."

Definition at line 346 of file strings.c.

#define WHITESPACE   " \t\n\r\f"

Definition at line 350 of file strings.c.

Function Documentation

long long crm_get_msec ( const char *  input)

Parse a time+units string and return milliseconds equivalent.

Parameters
[in]inputString with a number and units (optionally with whitespace before and/or after the number)
Returns
Milliseconds corresponding to string expression, or PCMK__PARSE_INT_DEFAULT on error

Definition at line 363 of file strings.c.

gboolean crm_is_true ( const char *  s)

Definition at line 415 of file strings.c.

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

Definition at line 1202 of file strings.c.

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

Definition at line 1252 of file strings.c.

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

Definition at line 1235 of file strings.c.

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

Definition at line 1182 of file strings.c.

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

Definition at line 1229 of file strings.c.

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

Definition at line 426 of file strings.c.

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

Definition at line 1217 of file strings.c.

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

Definition at line 1223 of file strings.c.

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

Definition at line 798 of file strings.c.

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

Definition at line 1277 of file strings.c.

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

Definition at line 1211 of file strings.c.

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

Definition at line 702 of file strings.c.

bool pcmk__char_in_any_str ( int  ch,
  ... 
)

Definition at line 976 of file strings.c.

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

Definition at line 748 of file strings.c.

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

Definition at line 535 of file strings.c.

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

Definition at line 562 of file strings.c.

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

Definition at line 311 of file strings.c.

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

Definition at line 1019 of file strings.c.

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

Definition at line 812 of file strings.c.

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

Definition at line 199 of file strings.c.

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

Definition at line 97 of file strings.c.

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

Definition at line 127 of file strings.c.

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

Definition at line 161 of file strings.c.

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 483 of file strings.c.

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

Definition at line 953 of file strings.c.

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

Definition at line 881 of file strings.c.

GHashTable* pcmk__str_table_dup ( GHashTable *  old_table)

Definition at line 674 of file strings.c.

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

Definition at line 929 of file strings.c.

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

Definition at line 1097 of file strings.c.

GHashTable* pcmk__strikey_table ( GDestroyNotify  key_destroy_func,
GDestroyNotify  value_destroy_func 
)

Definition at line 648 of file strings.c.

GHashTable* pcmk__strkey_table ( GDestroyNotify  key_destroy_func,
GDestroyNotify  value_destroy_func 
)

Definition at line 610 of file strings.c.

char* pcmk__trim ( char *  str)

Definition at line 455 of file strings.c.

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

Definition at line 1283 of file strings.c.

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

Definition at line 1167 of file strings.c.