 |
Crossfire Server, Trunk
1.75.0
|
Go to the documentation of this file.
34 #ifndef CF_MXE_CROSS_COMPILE
35 #include <sys/param.h>
72 char *tempname = NULL;
76 const int maxretry = 10;
79 for (i = 0; i < maxretry; i++) {
80 tempname = tempnam(dir, pfx);
88 LOG(
llevError,
"Created file detected in tempnam_secure. Someone hoping for a race condition?\n");
95 file = fdopen(fd,
"w+");
97 LOG(
llevError,
"fdopen() failed in tempnam_secure()!\n");
102 *filename = tempname;
119 char buf[strlen(path) +
sizeof(dirent::d_name) + 1];
123 if ((dirp =
opendir(path)) != NULL) {
131 if (de->d_name[0] ==
'.')
137 status = stat(de->d_name, &statbuf);
138 if ((status != -1) && (S_ISDIR(statbuf.st_mode))) {
139 snprintf(
buf,
sizeof(
buf),
"%s/%s", path, de->d_name);
143 snprintf(
buf,
sizeof(
buf),
"%s/%s", path, de->d_name);
151 LOG(
llevError,
"Unable to remove directory %s\n", path);
172 if (!filename || !*filename)
176 while ((cp = strchr(cp+1, (
int)
'/'))) {
178 if (stat(
buf, &statbuf) || !S_ISDIR(statbuf.st_mode)) {
208 void safe_strcat(
char *dest,
const char *orig,
size_t *curlen,
size_t maxlen) {
209 assert(curlen != NULL);
210 assert(*curlen < maxlen);
212 *curlen = strlcat(dest, orig, maxlen);
214 if (*curlen == (maxlen-1))
216 strncpy(dest+*curlen, orig, maxlen-*curlen-1);
218 *curlen += strlen(orig);
220 if (*curlen > (maxlen-1))
228 size_t strlcpy(
char *dst,
const char *src,
size_t size) {
229 strncpy(dst, src, size - 1);
230 dst[size - 1] =
'\0';
238 const char *
strcasestr(
const char *s,
const char *find)
243 if ((
c = *find++) != 0) {
248 if ((
sc = *s++) == 0)
251 while ((
char)
tolower((
unsigned char)
sc) !=
c);
253 while (strncasecmp(s, find, len) != 0);
@ llevError
Problems requiring server admin to fix.
void LOG(LogLevel logLevel, const char *format,...)
Logs a message to stderr, or to file.
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 ...
static event_registration c
#define tolower(C)
Simple macro to convert a letter to lowercase.
void remove_directory(const char *path)
This function removes everything in the directory, and the directory itself.
DIR * opendir(const char *)
Player Stats effect how well a character can survie and interact inside the crossfire world This section discusses the various what they and how they effect the player s actions Also in this section are the stat modifiers that specific classes professions bring Player and sps the current and maximum the Current and Maximum The Current Sp can go somewhat negative When Sp is negative not all spells can be and a more negative Sp makes spell casting less likey to succeed can affect Damage and how the characters as well as how often the character can attack this affects the prices when buying and selling items if this drops the player will start losing hit points wd Cleric or Dwarf sm Elf wd Fireborn sc
struct dirent * readdir(DIR *)
const char * strcasestr(const char *s, const char *find)
#define MAX_BUF
Used for all kinds of things.
size_t strlcpy(char *dst, const char *src, size_t size)
Portable implementation of strlcpy(3).
bool make_path_to_file(const char *filename)
Recursively creates missing directories in the path to filename until the last directory separator '/...
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.
@ llevDebug
Only for debugging purposes.