golist

Name

golist -- auxiliary functions

Synopsis


#include <go.h>


int         str_to_int                      (const char *str,
                                             int def);
double      str_to_double                   (const char *str,
                                             double def);
gboolean    rank_to_strength                (const char *rank,
                                             double *strength_ptr);
void        snprint_strength                (char *str,
                                             size_t size,
                                             double strength);

Description

Details

str_to_int ()

int         str_to_int                      (const char *str,
                                             int def);

str : 
def : 
Returns : 


str_to_double ()

double      str_to_double                   (const char *str,
                                             double def);

str : 
def : 
Returns : 


rank_to_strength ()

gboolean    rank_to_strength                (const char *rank,
                                             double *strength_ptr);

Convert a rank string of the form "3d" or "5k" into a numerical strength value. rank must be an integer number x, followed by either d (for dan grades) or k (for kyu grades). The computed strength value is x-1 for "x dan" or -x for "x kyu".

rank may be NULL or the empty string. In this case the strength value -100 (meaning "unknown strength") is returned.

rank : a player's rank
strength_ptr : a pointer to the place where the strength value should be filled in.
Returns : TRUE if the conversion was succesful and FALSE on error.


snprint_strength ()

void        snprint_strength                (char *str,
                                             size_t size,
                                             double strength);

Prints the rank, which is closest to strength into str. This is the inverse operation to rank_to_strength().

str : a buffer to print the rank into
size : length of the buffer
strength : the strength value to print