Crossfire Server, Trunk
|
#include <assert.h>
#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
#include <sys/param.h>
#include <sys/stat.h>
#include <sys/wait.h>
#include "global.h"
Go to the source code of this file.
Functions | |
void | make_path_to_file (const char *filename) |
void | remove_directory (const char *path) |
void | safe_strcat (char *dest, const char *orig, size_t *curlen, size_t maxlen) |
size_t | strlcpy (char *dst, const char *src, size_t size) |
FILE * | tempnam_secure (const char *dir, const char *pfx, char **filename) |
This file contains various functions that are not really unique for crossfire, but rather provides what should be standard functions for systems that do not have them. In this way, most of the nasty system dependent stuff is contained here, with the program calling these functions.
Definition in file porting.c.
void make_path_to_file | ( | const char * | filename | ) |
Checks if any directories in the given path doesn't exist, and creates if necessary.
filename | file path we'll want to access. Can be NULL. |
Definition at line 162 of file porting.c.
References buf, npc_dialog::filename, llevDebug, llevError, LOG(), MAX_BUF, safe_strncpy, and SAVE_DIR_MODE.
Referenced by apply_race_and_class(), create_destination(), key_change_class(), save_map(), save_player(), and write_pictures_from_real_size().
void remove_directory | ( | const char * | path | ) |
This function removes everything in the directory, and the directory itself.
Errors are LOG() to error level.
path | directory to remove. |
Definition at line 115 of file porting.c.
References buf, closedir(), dirent, llevError, LOG(), MAX_BUF, opendir(), python_init::path, readdir(), remove_directory(), and takeitem::status.
Referenced by delete_character(), and remove_directory().
void safe_strcat | ( | char * | dest, |
const char * | orig, | ||
size_t * | curlen, | ||
size_t | maxlen | ||
) |
Simple function we use below to keep adding to the same string but also make sure we don't overwrite that string.
dest | string to append to. | |
orig | string to append. | |
[out] | curlen | current length of dest. Will be updated by this function. |
maxlen | maximum length of dest buffer. |
Definition at line 200 of file porting.c.
References convert::dest.
Referenced by display_motd(), query_base_name(), query_name(), query_short_name(), send_new_char_info(), send_news(), send_rules(), spellbook_type_describe(), and while().
size_t strlcpy | ( | char * | dst, |
const char * | src, | ||
size_t | size | ||
) |
Portable implementation of strlcpy(3).
Definition at line 220 of file porting.c.
Referenced by apply_race_and_class(), cfapi_map_set_map_property(), cfapi_object_get_property(), check_login(), check_path(), clean_path(), command_reset(), command_use(), compute_face_name(), do_tell(), dump_alchemy(), dump_alchemy_costs(), enter_fixed_template_map(), enter_random_map(), enter_random_template_map(), enter_unique_map(), esrv_update_item(), find_style(), get_who_escape_code_value(), init_dynamic(), key_change_class(), knowledge_player_knows(), make_map_walls(), nstrtok(), party_form(), party_set_password(), path_combine(), player_get_title(), player_set_own_title(), query_base_name(), query_short_name(), replace(), save_map(), strtoktolin(), and unclean_path().
FILE* tempnam_secure | ( | const char * | dir, |
const char * | pfx, | ||
char ** | filename | ||
) |
A replacement for the tempnam_local() function since that one is not very secure. This one will open the file in an atomic way on platforms where it is possible.
dir | Directory where to create the file. Can be NULL, in which case NULL is returned. |
pfx | Prefix to create unique name. Can be NULL. |
filename | This should be a pointer to a char*, the function will overwrite the char* with the name of the resulting file. Must be freed by caller. Value is unchanged if the function returns NULL. |
Definition at line 69 of file porting.c.
References mad_mage_user::file, npc_dialog::filename, llevError, LOG(), CFBank::open(), S_IRUSR, and S_IWUSR.
Referenced by save_player().