]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - include/inspstring.h
Guess what i added here?
[user/henk/code/inspircd.git] / include / inspstring.h
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd: (C) 2002-2007 InspIRCd Development Team
6  * See: http://www.inspircd.org/wiki/index.php/Credits
7  *
8  * This program is free but copyrighted software; see
9  *            the file COPYING for details.
10  *
11  * ---------------------------------------------------
12  */
13
14 #ifndef __IN_INSPSTRING_H
15 #define __IN_INSPSTRING_H
16
17 #include "inspircd_config.h"
18 #include <string.h>
19 #include <cstddef>
20
21 #ifndef HAS_STRLCPY
22 /** strlcpy() implementation for systems that don't have it (linux) */
23 CoreExport size_t strlcpy(char *dst, const char *src, size_t siz);
24 /** strlcat() implementation for systems that don't have it (linux) */
25 CoreExport size_t strlcat(char *dst, const char *src, size_t siz);
26 #endif
27
28 /** charlcat() will append one character to a string using the same
29  * safety scemantics as strlcat().
30  * @param x The string to operate on
31  * @param y the character to append to the end of x
32  * @param z The maximum allowed length for z including null terminator
33  */
34 CoreExport int charlcat(char* x,char y,int z);
35 /** charremove() will remove all instances of a character from a string
36  * @param mp The string to operate on
37  * @param remove The character to remove
38  */
39 CoreExport bool charremove(char* mp, char remove);
40
41 /** strnewdup() is an implemenetation of strdup() which calls operator new
42  * rather than malloc to allocate the new string, therefore allowing it to
43  * be hooked into the C++ memory manager, and freed with operator delete.
44  * This is required for windows, where we override operators new and delete
45  * to allow for global allocation between modules and the core.
46  */
47 inline char * strnewdup(const char * s1)
48 {
49         size_t len = strlen(s1) + 1;
50         char * p = new char[len];
51         memcpy(p, s1, len);
52         return p;
53 }
54
55 #endif
56