6 #ifndef INCLUDED_ircd_string_h
7 #define INCLUDED_ircd_string_h
8 #ifndef INCLUDED_config_h
11 #ifndef INCLUDED_ircd_chattr_h
12 #include "ircd_chattr.h"
18 #define EmptyString(x) (!(x) || !(*x))
20 extern char* ircd_strncpy(char* dest, const char* src, size_t len);
21 extern int ircd_strcmp(const char *a, const char *b);
22 extern int ircd_strncmp(const char *a, const char *b, size_t n);
23 extern int unique_name_vector(char* names, char token, char** vector, int size);
24 extern int token_vector(char* names, char token, char** vector, int size);
25 extern const char* ircd_ntoa(const char* addr);
26 extern const char* ircd_ntoa_r(char* buf, const char* addr);
27 extern char* host_from_uh(char* buf, const char* userhost, size_t len);
28 extern char* ircd_strtok(char** save, char* str, char* fs);
30 extern char* sprintf_irc(char* str, const char* format, ...);
32 extern char* canonize(char* buf);
34 #define DupString(x, y) (strcpy((x = (char*) MyMalloc(strlen(y) + 1)), y))
37 /* String classification pseudo-functions, when others are needed add them,
38 strIsXxxxx(s) is true when IsXxxxx(c) is true for every char in s */
40 #define strIsAlnum(s) (strChattr(s) & NTL_ALNUM)
41 #define strIsAlpha(s) (strChattr(s) & NTL_ALPHA)
42 #define strIsDigit(s) (strChattr(s) & NTL_DIGIT)
43 #define strIsLower(s) (strChattr(s) & NTL_LOWER)
44 #define strIsSpace(s) (strChattr(s) & NTL_SPACE)
45 #define strIsUpper(s) (strChattr(s) & NTL_UPPER)
47 #define strIsIrcCh(s) (strChattr(s) & NTL_IRCCH)
48 #define strIsIrcCl(s) (strChattr(s) & NTL_IRCCL)
49 #define strIsIrcNk(s) (strChattr(s) & NTL_IRCNK)
50 #define strIsIrcUi(s) (strChattr(s) & NTL_IRCUI)
51 #define strIsIrcHn(s) (strChattr(s) & NTL_IRCHN)
52 #define strIsIrcIp(s) (strChattr(s) & NTL_IRCIP)
55 * Critical small functions to inline even in separate compilation
56 * when FORCEINLINE is defined (provided you have a compiler that supports
60 #define NTL_HDR_strChattr unsigned int strChattr(const char *s)
62 #define NTL_SRC_strChattr const char *rs = s; \
63 unsigned int x = ~0; \
65 x &= IRCD_CharAttrTab[*rs++ - CHAR_MIN]; \
69 * XXX - bleah should return 1 if different 0 if the same
71 #define NTL_HDR_strCasediff int strCasediff(const char *a, const char *b)
73 #define NTL_SRC_strCasediff const char *ra = a; \
75 while(ToLower(*ra) == ToLower(*rb++)) \
81 extern NTL_HDR_strChattr;
82 extern NTL_HDR_strCasediff;
84 #else /* FORCEINLINE */
86 inline NTL_HDR_strChattr { NTL_SRC_strChattr }
87 inline NTL_HDR_strCasediff { NTL_SRC_strCasediff }
89 static __inline__ NTL_HDR_strChattr { NTL_SRC_strChattr }
90 static __inline__ NTL_HDR_strCasediff { NTL_SRC_strCasediff }
92 #endif /* FORCEINLINE */
95 * Proto types of other externally visible functions
97 extern int strnChattr(const char *s, const size_t n);
99 #endif /* INCLUDED_ircd_string_h */