pacemaker  2.0.4-2deceaa
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 <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
 
#define NUMCHARS   "0123456789."
 
#define WHITESPACE   " \t\n\r\f"
 

Functions

char * crm_itoa_stack (int an_int, char *buffer, size_t len)
 
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...
 
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 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 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)
 
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 * pcmk__add_word (char *list, const char *word)
 
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)
 

Macro Definition Documentation

#define _GNU_SOURCE

Definition at line 13 of file strings.c.

#define NUMCHARS   "0123456789."

Definition at line 195 of file strings.c.

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

Definition at line 199 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 -1 on error

Definition at line 211 of file strings.c.

gboolean crm_is_true ( const char *  s)

Definition at line 278 of file strings.c.

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

Definition at line 24 of file strings.c.

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

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

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

Definition at line 326 of file strings.c.

GHashTable* crm_str_table_dup ( GHashTable *  old_table)

Definition at line 495 of file strings.c.

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

Definition at line 289 of file strings.c.

gboolean crm_strcase_equal ( gconstpointer  a,
gconstpointer  b 
)

Definition at line 469 of file strings.c.

guint crm_strcase_hash ( gconstpointer  v)

Definition at line 475 of file strings.c.

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

Definition at line 591 of file strings.c.

char* crm_strip_trailing_newline ( char *  str)

Definition at line 310 of file strings.c.

guint g_str_hash_traditional ( gconstpointer  v)

Definition at line 456 of file strings.c.

char* pcmk__add_word ( char *  list,
const char *  word 
)

Definition at line 517 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 541 of file strings.c.

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

Definition at line 410 of file strings.c.

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

Definition at line 437 of file strings.c.

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

Definition at line 162 of file strings.c.

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

Definition at line 605 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 358 of file strings.c.

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

Definition at line 660 of file strings.c.

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

Definition at line 263 of file strings.c.