Crossfire Client, Trunk
Functions | Variables
misc.c File Reference
#include "client.h"
#include <errno.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,...)
 
int make_path_to_file (char *filename)
 
void replace_chars_with_string (char *buffer, const guint16 buffer_size, const char find, const char *replace)
 

Variables

GTimer * global_time
 
LogLevel MINLOG = LOG_INFO
 

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

◆ getLogLevelText()

static const char* getLogLevelText ( LogLevel  level)
static

Definition at line 94 of file misc.c.

References LOG_CRITICAL.

Referenced by LOG().

Here is the caller graph for this function:

◆ LOG()

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

References getLogLevelText(), global_time, and MINLOG.

Referenced by AccountPlayersCmd(), add_marked_text_to_pane(), add_to_textbuf(), AddMeFail(), AddMeSuccess(), AddspellCmd(), AnimCmd(), cache_newpng(), cf_play_music(), cf_play_sound(), client_disconnect(), client_negotiate(), client_run(), CompleteCmd(), config_check(), config_load(), config_load_legacy(), DeleteInventory(), DeleteItem(), DeleteSpell(), display_newpng(), do_network(), draw_ext_info(), draw_inv_table(), draw_magic_map(), draw_map(), DrawExtInfoCmd(), DrawInfoCmd(), event_loop(), Face2Cmd(), FailureCmd(), 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(), handle_query(), Image2Cmd(), image_add_hash(), image_find_hash(), image_process_line(), image_remove_hash(), info_get_styles(), init_default_keybindings(), init_ui(), inventory_get_styles(), inventory_init(), Item2Cmd(), keybind_insert(), keybinding_get_data(), keybinding_selection_func(), keybindings_init(), keyfunc(), launch_mapedit(), list_selection_func(), load_image(), load_msgctrl_configuration(), load_theme(), MagicMapCmd(), main(), Map2Cmd(), map_init(), map_scrollCmd(), mapdata_set_anim_layer(), menu_quit_program(), message_callback(), metaserver_connect_to(), MusicCmd(), on_combobox_rcs_changed(), on_keybinding_button_remove_clicked(), on_keybinding_button_update_clicked(), on_spell_cast_clicked(), on_spell_invoke_clicked(), on_window_destroy_event(), parse_args(), parse_keybind_line(), pickup_init(), PlayerCmd(), png_to_data(), process_race_class_info(), read_config_dialog(), ReplyInfoCmd(), rescale_rgba_data(), save_keys(), save_msgctrl_configuration(), script_init(), send_command(), SetupCmd(), SockList_AddChar(), SockList_AddInt(), SockList_AddShort(), SockList_Send(), Sound2Cmd(), spell_get_styles(), stats_get_styles(), StatsCmd(), trigger_skill(), unbind_key(), UpdateItemCmd(), UpdspellCmd(), and VersionCmd().

Here is the call graph for this function:

◆ make_path_to_file()

int make_path_to_file ( char *  filename)

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

Definition at line 87 of file misc.c.

Referenced by save_keys(), and save_msgctrl_configuration().

Here is the caller graph for this function:

◆ replace_chars_with_string()

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

Variable Documentation

◆ global_time

GTimer* global_time

Definition at line 31 of file misc.c.

Referenced by LOG(), and main().

◆ MINLOG

LogLevel MINLOG = LOG_INFO

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

Definition at line 34 of file misc.c.

Referenced by LOG(), and parse_args().