pacemaker  2.0.5-ba59be712
Scalable High-Availability cluster resource manager
Macros | Functions | Variables
utils.c File Reference
#include <crm_internal.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <sys/stat.h>
#include <sys/utsname.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
#include <limits.h>
#include <pwd.h>
#include <time.h>
#include <libgen.h>
#include <signal.h>
#include <qb/qbdefs.h>
#include <crm/crm.h>
#include <crm/services.h>
#include <crm/msg_xml.h>
#include <crm/cib/internal.h>
#include <crm/common/xml.h>
#include <crm/common/util.h>
#include <crm/common/ipc.h>
#include <crm/common/iso8601.h>
#include <crm/common/mainloop.h>
#include <libxml2/libxml/relaxng.h>
#include "crmcommon_private.h"
Include dependency graph for utils.c:

Go to the source code of this file.

Macros

#define _GNU_SOURCE
 
#define PW_BUFFER_LEN   500
 

Functions

 CRM_TRACE_INIT_DATA (common)
 
int char2score (const char *score)
 
char * score2char_stack (int score, char *buf, size_t len)
 
char * score2char (int score)
 
int crm_user_lookup (const char *name, uid_t *uid, gid_t *gid)
 
int pcmk_daemon_user (uid_t *uid, gid_t *gid)
 Get user and group IDs of pacemaker daemon user. More...
 
int compare_version (const char *version1, const char *version2)
 
guint crm_parse_interval_spec (const char *input)
 Parse milliseconds from a Pacemaker interval specification. More...
 
void crm_abort (const char *file, const char *function, int line, const char *assert_condition, gboolean do_core, gboolean do_fork)
 
void pcmk__daemonize (const char *name, const char *pidfile)
 
char * crm_meta_name (const char *field)
 
const char * crm_meta_value (GHashTable *hash, const char *field)
 
char * crm_generate_uuid (void)
 
char * pcmk_hostname ()
 Get the local hostname. More...
 
bool pcmk_str_is_infinity (const char *s)
 
bool pcmk_str_is_minus_infinity (const char *s)
 

Variables

bool pcmk__config_error = false
 
bool pcmk__config_warning = false
 
char * crm_system_name = NULL
 
int pcmk__score_red = 0
 
int pcmk__score_green = 0
 
int pcmk__score_yellow = 0
 

Macro Definition Documentation

◆ _GNU_SOURCE

#define _GNU_SOURCE

Definition at line 13 of file utils.c.

◆ PW_BUFFER_LEN

#define PW_BUFFER_LEN   500

Definition at line 47 of file utils.c.

Function Documentation

◆ char2score()

int char2score ( const char *  score)

Definition at line 61 of file utils.c.

◆ compare_version()

int compare_version ( const char *  version1,
const char *  version2 
)

Definition at line 225 of file utils.c.

◆ crm_abort()

void crm_abort ( const char *  file,
const char *  function,
int  line,
const char *  assert_condition,
gboolean  do_core,
gboolean  do_fork 
)

Definition at line 337 of file utils.c.

◆ crm_generate_uuid()

char* crm_generate_uuid ( void  )

Definition at line 498 of file utils.c.

◆ crm_meta_name()

char* crm_meta_name ( const char *  field)

Definition at line 457 of file utils.c.

◆ crm_meta_value()

const char* crm_meta_value ( GHashTable *  hash,
const char *  field 
)

Definition at line 479 of file utils.c.

◆ crm_parse_interval_spec()

guint crm_parse_interval_spec ( const char *  input)

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)
Returns
Milliseconds equivalent of given specification on success (limited to the range of an unsigned integer), 0 if input is NULL, or 0 (and set errno to EINVAL) on error

Definition at line 307 of file utils.c.

◆ CRM_TRACE_INIT_DATA()

CRM_TRACE_INIT_DATA ( common  )

◆ crm_user_lookup()

int crm_user_lookup ( const char *  name,
uid_t *  uid,
gid_t *  gid 
)

Definition at line 122 of file utils.c.

◆ pcmk__daemonize()

void pcmk__daemonize ( const char *  name,
const char *  pidfile 
)

Definition at line 410 of file utils.c.

◆ pcmk_daemon_user()

int pcmk_daemon_user ( uid_t *  uid,
gid_t *  gid 
)

Get user and group IDs of pacemaker daemon user.

Parameters
[out]uidIf non-NULL, where to store daemon user ID
[out]gidIf non-NULL, where to store daemon group ID
Returns
pcmk_ok on success, -errno otherwise

Definition at line 162 of file utils.c.

◆ pcmk_hostname()

char* pcmk_hostname ( void  )

Get the local hostname.

Returns
Newly allocated string with name, or NULL (and set errno) on error

Definition at line 523 of file utils.c.

◆ pcmk_str_is_infinity()

bool pcmk_str_is_infinity ( const char *  s)

Definition at line 531 of file utils.c.

◆ pcmk_str_is_minus_infinity()

bool pcmk_str_is_minus_infinity ( const char *  s)

Definition at line 536 of file utils.c.

◆ score2char()

char* score2char ( int  score)

Definition at line 110 of file utils.c.

◆ score2char_stack()

char* score2char_stack ( int  score,
char *  buf,
size_t  len 
)

Definition at line 96 of file utils.c.

Variable Documentation

◆ crm_system_name

char* crm_system_name = NULL

Definition at line 54 of file utils.c.

◆ pcmk__config_error

bool pcmk__config_error = false

Definition at line 52 of file utils.c.

◆ pcmk__config_warning

bool pcmk__config_warning = false

Definition at line 53 of file utils.c.

◆ pcmk__score_green

int pcmk__score_green = 0

Definition at line 57 of file utils.c.

◆ pcmk__score_red

int pcmk__score_red = 0

Definition at line 56 of file utils.c.

◆ pcmk__score_yellow

int pcmk__score_yellow = 0

Definition at line 58 of file utils.c.