pianod2
multisource multiuser scriptable networked music player
Functions | Variables
fb_utility.c File Reference

Football utility functions. More...

#include <config.h>
#include <stdio.h>
#include <errno.h>
#include <ctype.h>
#include <stdbool.h>
#include <assert.h>
#include <stdlib.h>
#include <stdarg.h>
#include <memory.h>
#include <time.h>
#include <arpa/inet.h>
#include "fb_public.h"
#include "fb_service.h"
Include dependency graph for fb_utility.c:

Functions

void fb_set_logging (int logtype, FB_LOGGING_FUNCTION func)
 Set logging level. More...
 
void fb_log_impl (const char *file, int line, const char *func, int level, const char *format,...)
 
const char * fb_connection_info (FB_CONNECTION *connection)
 
bool fb_expandcalloc (void **data, size_t *capacity, size_t newcapacity, size_t itemsize)
 calloc() with ability to expand the allocated data. More...
 
void fb_destroy_argv (char **argv)
 
int fb_create_argv (const char *commandline, char ***result)
 
static char hexvalue (char ch)
 
int fb_create_argv_from_query_string (const char *query_string, char ***result_names, char ***result_values)
 

Variables

static int logmode = 0
 
FB_LOGGING_FUNCTION fb_log = fb_log_impl
 

Detailed Description

Football utility functions.

Function Documentation

◆ fb_connection_info()

const char* fb_connection_info ( FB_CONNECTION connection)

Return a a connection's opposing end as a string.

Parameters
connectionthe connection to get the string of.
Returns
a string with the info, or a stand-in value.
Here is the caller graph for this function:

◆ fb_create_argv()

int fb_create_argv ( const char *  commandline,
char ***  result 
)

Create an argv-style array. A command line with nothing on it results in 0 and a pointer to an array with one null.

Parameters
commandlineThe command to split up. This original string remains unaltered.
resultThe place to put the argv array.
Returns
The number of populated terms in the argv array. On error, returns a negative number and a null pointer.
Here is the caller graph for this function:

◆ fb_create_argv_from_query_string()

int fb_create_argv_from_query_string ( const char *  query_string,
char ***  result_names,
char ***  result_values 
)

Create arrays of parameter names and values from an HTTP query parameter string. An empty query string results in 0 and pointers arrays with one null.

Parameters
query_stringThe command to split up. This original string remains unaltered.
result_namesThe place to put the parameter name array reference.
result_valuesThe place to put the parameter value array reference.
Returns
The number of populated terms in the parameter array. On error, returns a negative number and a null pointer.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ fb_destroy_argv()

void fb_destroy_argv ( char **  argv)

Free up resources used by an argv array.

Parameters
argvThe array to release.
Here is the caller graph for this function:

◆ fb_expandcalloc()

bool fb_expandcalloc ( void **  data,
size_t *  capacity,
size_t  newcapacity,
size_t  itemsize 
)

calloc() with ability to expand the allocated data.

Does nothing if the actual capacity meets or exceeds the requested capacity. When expansion occurs, the added elements are zeroed out.

Parameters
datathe allocation to expand. May be *NULL for initial allocation.
capacitythe capacity of the allocation, which may be adjusted by this call.
newcapacitythe desired capacity of the allocation.
itemsizethe size of data items in the allocation.
Returns
true on success, false on failure (existing allocation remains valid).
Here is the caller graph for this function:

◆ fb_log_impl()

void fb_log_impl ( const char *  file,
int  line,
const char *  func,
int  level,
const char *  format,
  ... 
)

Default logging implementation: Log stuff to stderr. The file, line, and func parameters are removed for release builds (when NDEBUG is set.) An application can provide an alternative function using the second parameter to fb_set_logging.

See also
fb_set_logging
FB_WHERE
Parameters
filethe filename from which the message originates.
linethe line number at which the message originates.
functhe function from which the message originates.
levela bitmask indicating the type of the message (0=error, always logged)
formata printf-style format string, with parameters to follow.

◆ fb_set_logging()

void fb_set_logging ( int  logtype,
FB_LOGGING_FUNCTION  func 
)

Set logging level.

Set which messages will be collected by the internal logging function, or provide an alternate logging function. When using a private logging function, logtype is not used.

Parameters
logtypea bitmask indicating which data to log.
funca logging function that replaces the default one.
Here is the caller graph for this function:

◆ hexvalue()

static char hexvalue ( char  ch)
static
Here is the caller graph for this function:

Variable Documentation

◆ fb_log

◆ logmode

int logmode = 0
static