Atrinik Client 2.5
Functions | Variables
client/wrapper.c File Reference
#include <global.h>

Go to the source code of this file.

Functions

void LOG (LogLevel logLevel, char *format,...)
void system_start ()
void system_end ()
char * get_word_from_string (char *str, int *pos)
static int mkdir_recurse (const char *path)
void copy_file (const char *filename, const char *filename_out)
void copy_if_exists (const char *from, const char *to, const char *src, const char *dst)
void rmrf (const char *path)
void copy_rec (const char *src, const char *dst)
const char * get_config_dir ()
void get_data_dir_file (char *buf, size_t len, const char *fname)
char * file_path (const char *fname, const char *mode)
FILE * fopen_wrapper (const char *fname, const char *mode)
SDL_Surface * IMG_Load_wrapper (const char *file)
TTF_Font * TTF_OpenFont_wrapper (const char *file, int ptsize)

Variables

static FILE * logstream = NULL
static const char *const loglevel_names []

Detailed Description

General convenience functions for the client.

Definition in file wrapper.c.


Function Documentation

void copy_file ( const char *  filename,
const char *  filename_out 
)

Copy a file.

Parameters:
filenameSource file.
filename_outDestination file.

Definition at line 202 of file wrapper.c.

void copy_if_exists ( const char *  from,
const char *  to,
const char *  src,
const char *  dst 
)

Copy a file/directory if it exists.

Parameters:
fromDirectory where to copy from.
toDirectort to copy to.
srcFile/directory to copy.
dstWhere to copy the file/directory to.

Definition at line 251 of file wrapper.c.

void copy_rec ( const char *  src,
const char *  dst 
)

Recursively copy a file or directory.

Parameters:
srcSource file/directory to copy.
dstWhere to copy to.

Definition at line 315 of file wrapper.c.

char* file_path ( const char *  fname,
const char *  mode 
)

Get path to file, to implement saving settings related data to user's home directory.

Parameters:
fnameThe file path.
modeFile mode.
Returns:
The path to the file.

Definition at line 420 of file wrapper.c.

const char* get_config_dir ( )

Get configuration directory.

Returns:
The configuration directory.

Definition at line 369 of file wrapper.c.

void get_data_dir_file ( char *  buf,
size_t  len,
const char *  fname 
)

Get path to a file in the data directory.

Parameters:
bufBuffer where to store the path.
lenSize of buf.
fnameFile.

Definition at line 394 of file wrapper.c.

char* get_word_from_string ( char *  str,
int *  pos 
)

Get a single word from a string, free from left and right whitespace.

Parameters:
strThe string pointer
posThe position pointer
Returns:
The word, or NULL if there is no word left

Definition at line 127 of file wrapper.c.

void LOG ( LogLevel  logLevel,
char *  format,
  ... 
)

Logs an error, debug output, etc.

Parameters:
logLevelLevel of the log message (llevInfo, llevDebug, ...)
formatFormatting of the message, like sprintf
...Additional arguments for format

Definition at line 49 of file wrapper.c.

static int mkdir_recurse ( const char *  path) [static]

Recursively creates directories from path.

Used by file_path().

Parameters:
pathThe path
Returns:
0 on success, -1 otherwise

Definition at line 162 of file wrapper.c.

void rmrf ( const char *  path)

Recursively remove a directory and its contents.

Effectively same as 'rf -rf path'.

Parameters:
pathWhat to remove.

Definition at line 269 of file wrapper.c.

void system_end ( )

End the system.

Definition at line 103 of file wrapper.c.

void system_start ( )

Start the base system, setting caption name and window icon.

Definition at line 84 of file wrapper.c.


Variable Documentation

const char* const loglevel_names[] [static]
Initial value:
{
    "[Error] ",
    "[Bug]   ",
    "[Debug] ",
    "[Info]  "
}

Human-readable names of log levels.

Definition at line 36 of file wrapper.c.