pacemaker  2.1.4-dc6eb4362
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 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...
 
char * score2char_stack (int score, char *buf, size_t len)
 Convert an integer score to a string, using a provided buffer. More...
 
char * score2char (int score)
 Return the string equivalent of an integer score. More...
 
int pcmk__add_scores (int score1, int score2)
 

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 140 of file scores.c.

◆ score2char()

char* score2char ( int  score)

Return the string equivalent of an integer score.

Return the string equivalent of a given integer score, using "INFINITY" and "-INFINITY" when appropriate.

Parameters
[in]scoreInteger score to convert
Returns
Newly allocated string equivalent of score
Note
The caller is responsible for freeing the return value. This function asserts on memory errors, so the return value can be assumed to be non-NULL.

Definition at line 114 of file scores.c.

◆ score2char_stack()

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

Convert an integer score to a string, using a provided buffer.

Store the string equivalent of a given integer score in a given string buffer, using "INFINITY" and "-INFINITY" when appropriate.

Parameters
[in]scoreInteger score to convert
[out]bufWhere to store string representation of score
[in]lenSize of buf (in bytes)
Returns
buf (or NULL if len is too small)

Definition at line 85 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.