Crossfire Client, Trunk  R19726
Functions | Variables
misc.c File Reference

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

#include "client.h"
#include <errno.h>
#include <glib.h>
#include <stdarg.h>
#include <stdio.h>
#include <sys/wait.h>
Include dependency graph for misc.c:

Go to the source code of this file.

Functions

static const char * getLogLevelText (LogLevel level)
 
void LOG (LogLevel level, const char *origin, const char *format,...)
 Log messages of a certain importance to stderr. More...
 
void logChildPipe (ChildProcess *child, LogLevel level, int flag)
 
void logPipe (ChildProcess *child, LogLevel level, int pipe)
 
int make_path_to_file (char *filename)
 If any directories in the given path doesn't exist, they are created. More...
 
void monitorChilds (void)
 
void purgePipe (ChildProcess *cp, int pipe)
 
ChildProcessraiseChild (char *name, int flag)
 
void replace_chars_with_string (char *buffer, const guint16 buffer_size, const char find, const char *replace)
 Convert a buffer of a specified maximum size by replacing token characters with a provided string. More...
 

Variables

static ChildProcessFirstChild = NULL
 
static ChildProcessLastChild = NULL
 
int MINLOG = LOG_INFO
 Log level, or the threshold below which messages are suppressed. More...
 

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

static const char* getLogLevelText ( LogLevel  level)
static

Definition at line 98 of file misc.c.

References LOG_CRITICAL.

Referenced by LOG().

Here is the caller graph for this function:

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

Log messages of a certain importance to stderr.

See 'client.h' for a full list of possible log levels.

Definition at line 115 of file misc.c.

References getLogLevelText(), and MINLOG.

Referenced by AccountPlayersCmd(), add_marked_text_to_pane(), AddMeFail(), AddMeSuccess(), AddspellCmd(), AnimCmd(), beat_check(), cache_newpng(), close_server_connection(), common_item_command(), CompleteCmd(), config_check(), config_load_legacy(), DeleteInventory(), DeleteItem(), DeleteSpell(), display_newpng(), do_network(), do_num_free_items(), draw_magic_map(), DrawExtInfoCmd(), DrawInfoCmd(), event_loop(), Face2Cmd(), FailureCmd(), fill_combobox_from_datadir(), finish_face_cmd(), get_class_info(), get_exp_info(), get_image_info(), get_image_sums(), get_new_char_info(), get_race_info(), get_skill_info(), get_starting_map_info(), get_type_from_name(), GoodbyeCmd(), gtk_draw_map(), handle_query(), Image2Cmd(), image_add_hash(), image_find_hash(), image_process_line(), image_remove_hash(), init_connection(), init_default_keybindings(), init_image_cache_data(), init_sockets(), init_sounds(), init_ui(), inventory_get_styles(), inventory_init(), keybind_insert(), keybinding_get_data(), keybinding_selection_func(), keyfunc(), list_selection_func(), load_image(), load_theme(), logPipe(), MagicMapCmd(), Map2Cmd(), map_scrollCmd(), mapdata_init(), menu_quit_program(), metaserver_connect_to(), monitorChilds(), ms_writer(), MusicCmd(), negotiate_connection(), on_combobox_rcs_changed(), on_keybinding_button_remove_clicked(), on_keybinding_button_update_clicked(), on_spell_cast_clicked(), on_spell_invoke_clicked(), on_spell_treeview_row_activated(), on_treeview_choose_character_activated(), on_window_destroy_event(), parse_args(), parse_keybind_line(), parse_keys_file(), pickup_init(), play_sound_effect(), PlayerCmd(), png_to_data(), png_to_gdkpixmap(), process_race_class_info(), purgePipe(), raiseChild(), ReplyInfoCmd(), rescale_rgba_data(), save_keys(), script_init(), send_command(), setup_config_window(), SetupCmd(), SockList_AddChar(), SockList_AddInt(), SockList_AddShort(), SockList_ReadPacket(), Sound2Cmd(), spell_get_styles(), stats_get_styles(), StatsCmd(), trigger_skill(), unbind_key(), UpdateItemCmd(), UpdspellCmd(), VersionCmd(), and write_socket().

Here is the call graph for this function:

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

Definition at line 240 of file misc.c.

References CHILD_STDERR, CHILD_STDOUT, ChildProcess::flag, and logPipe().

Referenced by init_sounds().

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 216 of file misc.c.

References PipeLog::level, LOG(), PipeLog::log, LOG_WARNING, ChildProcess::logger, PipeLog::name, ChildProcess::name, ChildProcess::pid, and ChildProcess::tube.

Referenced by logChildPipe().

Here is the call graph for this function:

Here is the caller graph for this function:

int make_path_to_file ( char *  filename)

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

Definition at line 91 of file misc.c.

Referenced by save_keys().

Here is the caller graph for this function:

void monitorChilds ( void  )

Definition at line 175 of file misc.c.

References FirstChild, LOG(), PipeLog::log, LOG_INFO, ChildProcess::logger, ChildProcess::name, ChildProcess::next, ChildProcess::pid, and purgePipe().

Here is the call graph for this function:

void purgePipe ( ChildProcess cp,
int  pipe 
)

Definition at line 139 of file misc.c.

References PipeLog::level, LOG(), LOG_ERROR, ChildProcess::logger, PipeLog::name, ChildProcess::name, and ChildProcess::tube.

Referenced by monitorChilds().

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 253 of file misc.c.

References CHILD_PIPEERR, CHILD_PIPEIN, CHILD_PIPEOUT, CHILD_SILENTFAIL, CHILD_STDERR, CHILD_STDIN, CHILD_STDOUT, CHILD_TUBE, ChildProcess::flag, LOG(), LOG_DEBUG, LOG_ERROR, name, ChildProcess::name, ChildProcess::next, and ChildProcess::pid.

Referenced by init_sounds().

Here is the call graph for this function:

Here is the caller graph for this function:

void replace_chars_with_string ( char *  buffer,
const guint16  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 56 of file misc.c.

Variable Documentation

ChildProcess* FirstChild = NULL
static

Definition at line 34 of file misc.c.

Referenced by monitorChilds().

ChildProcess* LastChild = NULL
static

Definition at line 35 of file misc.c.

int MINLOG = LOG_INFO

Log level, or the threshold below which messages are suppressed.

Definition at line 38 of file misc.c.

Referenced by LOG().