pacemaker  2.1.7-0f7f88312f
Scalable High-Availability cluster resource manager
Macros | Functions | Variables
scores.c File Reference
#include <crm_internal.h>
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <crm/common/util_compat.h>
Include dependency graph for scores.c:

Go to the source code of this file.

Macros

#define _GNU_SOURCE
 

Functions

int char2score (const char *score)
 Get the integer value of a score string. More...
 
const char * pcmk_readable_score (int score)
 Return a displayable static string for a score value. More...
 
int pcmk__add_scores (int score1, int score2)
 
char * score2char (int score)
 
char * score2char_stack (int score, char *buf, size_t len)
 

Variables

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 scores.c.

Function Documentation

◆ char2score()

int char2score ( const char *  score)

Get the integer value of a score string.

Given a string representation of a score, return the integer equivalent. This accepts infinity strings as well as red, yellow, and green, and bounds the result to +/-INFINITY.

Parameters
[in]scoreScore as string
Returns
Integer value corresponding to score

Definition at line 36 of file scores.c.

◆ pcmk__add_scores()

int pcmk__add_scores ( int  score1,
int  score2 
)

Definition at line 116 of file scores.c.

◆ pcmk_readable_score()

const char* pcmk_readable_score ( int  score)

Return a displayable static string for a score value.

Given a score value, return a pointer to a static string representation of the score suitable for log messages, output, etc.

Parameters
[in]scoreScore to display
Returns
Pointer to static memory containing string representation of score
Note
Subsequent calls to this function will overwrite the returned value, so it should be used only in a local context such as a printf()-style statement.

Definition at line 86 of file scores.c.

◆ score2char()

char* score2char ( int  score)
Deprecated:
Use pcmk_readable_score() instead

Definition at line 148 of file scores.c.

◆ score2char_stack()

char* score2char_stack ( int  score,
char *  buf,
size_t  len 
)
Deprecated:
Use pcmk_readable_score() instead

Definition at line 157 of file scores.c.

Variable Documentation

◆ pcmk__score_green

int pcmk__score_green = 0

Definition at line 21 of file scores.c.

◆ pcmk__score_red

int pcmk__score_red = 0

Definition at line 20 of file scores.c.

◆ pcmk__score_yellow

int pcmk__score_yellow = 0

Definition at line 22 of file scores.c.