Crossfire Client, Trunk  R18666
Functions | Variables
/home/leaf/crossfire/client/trunk/common/misc.c File Reference
#include "client.h"
#include <stdarg.h>
#include <stdio.h>
#include <errno.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/wait.h>
Include dependency graph for misc.c:

Go to the source code of this file.

Functions

void replace_chars_with_string (char *buffer, const uint16 buffer_size, const char find, const char *replace)
int make_path_to_dir (char *directory)
int make_path_to_file (char *filename)
char * strdup_local (const char *str)
int setLogListener (LogListener li)
void clearLogListener (void)
char * getLogTextRaw (LogLevel level, const char *origin, const char *message)
char * getLogText (const LogEntry *le)
void LOG (LogLevel level, const char *origin, const char *format,...)
void purgePipe (ChildProcess *cp, int pipe)
void monitorChilds (void)
void logPipe (ChildProcess *child, LogLevel level, int pipe)
void logChildPipe (ChildProcess *child, LogLevel level, int flag)
ChildProcessraiseChild (char *name, int flag)

Variables

const char *const rcsid_common_misc_c = "$Id: misc.c 13982 2010-10-09 22:41:04Z anmaster $"
LogEntryLogFirst = NULL
LogEntryLogLast = NULL
int logcount = 0
LogListener loglist = NULL
int MINLOG = MINLOGLEVEL
ChildProcessFirstChild = NULL
ChildProcessLastChild = NULL

Detailed Description

Contains misc useful functions that may be useful to various parts of code, but are not especially tied to it.

Definition in file misc.c.


Function Documentation

void clearLogListener ( void  )

Definition at line 195 of file misc.c.

char* getLogText ( const LogEntry le)

Definition at line 228 of file misc.c.

Here is the call graph for this function:

Here is the caller graph for this function:

char* getLogTextRaw ( LogLevel  level,
const char *  origin,
const char *  message 
)

Definition at line 218 of file misc.c.

Here is the caller graph for this function:

void LOG ( LogLevel  level,
const char *  origin,
const char *  format,
  ... 
)

Logs a message to stderr and save it in memory. Or discards the message if it is of no importanse, and none have asked to hear messages of that logLevel.

See client.h for possible logLevels.

Definition at line 241 of file misc.c.

Here is the call graph for this function:

void logChildPipe ( ChildProcess child,
LogLevel  level,
int  flag 
)

Definition at line 365 of file misc.c.

Here is the call graph for this function:

Here is the caller graph for this function:

void logPipe ( ChildProcess child,
LogLevel  level,
int  pipe 
)

Definition at line 343 of file misc.c.

Here is the call graph for this function:

Here is the caller graph for this function:

int make_path_to_dir ( char *  directory)

Verifies that the directory exists, creates it if necessary Returns -1 on failure

Definition at line 100 of file misc.c.

int make_path_to_file ( char *  filename)

If any directories in the given path doesn't exist, they are created.

Definition at line 139 of file misc.c.

Here is the call graph for this function:

Here is the caller graph for this function:

void monitorChilds ( void  )

Definition at line 308 of file misc.c.

Here is the call graph for this function:

void purgePipe ( ChildProcess cp,
int  pipe 
)

Definition at line 276 of file misc.c.

Here is the call graph for this function:

Here is the caller graph for this function:

ChildProcess* raiseChild ( char *  name,
int  flag 
)

Definition at line 375 of file misc.c.

Here is the call graph for this function:

Here is the caller graph for this function:

void replace_chars_with_string ( char *  buffer,
const uint16  buffer_size,
const char  find,
const char *  replace 
)

Convert a buffer of a specified maximum size by replacing token characters with a provided string. Given a buffered template string "/input/to/edit", the maximum size of the buffer, a token '/', and a replacement string ":", the input string is transformed to ":input:to:edit". If the replacement string is empty, the token characters are simply removed. The template is processed from left to right, replacing token characters as they are found. Replacement strings are always inserted whole. If token replacement would overflow the size of the conversion buffer, the token is not replaced, and the remaining portion of the input string is appended after truncating it as required to avoid overfilling the buffer.

Parameters:
bufferA string to perform a find and replace operation on.
buffer_sizeAllocated buffer size (used to avoid buffer overflow).
findA token character to find and replace in the buffer.
replaceA string that is to replace each token in the buffer.

Definition at line 60 of file misc.c.

Definition at line 185 of file misc.c.

char* strdup_local ( const char *  str)

A replacement of strdup(), since it's not defined at some unix variants.

Definition at line 170 of file misc.c.

Here is the caller graph for this function:


Variable Documentation

Definition at line 270 of file misc.c.

Definition at line 271 of file misc.c.

int logcount = 0

Definition at line 179 of file misc.c.

LogEntry* LogFirst = NULL

Definition at line 177 of file misc.c.

LogEntry* LogLast = NULL

Definition at line 178 of file misc.c.

Definition at line 180 of file misc.c.

int MINLOG = MINLOGLEVEL

Definition at line 232 of file misc.c.

const char* const rcsid_common_misc_c = "$Id: misc.c 13982 2010-10-09 22:41:04Z anmaster $"

Definition at line 1 of file misc.c.