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))
21 * initialize recognizers
23 extern int init_string(void);
25 extern int string_is_hostname(const char* str);
26 extern int string_is_address(const char* str);
27 extern int string_has_wildcards(const char* str);
29 extern char* ircd_strncpy(char* dest, const char* src, size_t len);
30 extern int ircd_strcmp(const char *a, const char *b);
31 extern int ircd_strncmp(const char *a, const char *b, size_t n);
32 extern int unique_name_vector(char* names, char token, char** vector, int size);
33 extern int token_vector(char* names, char token, char** vector, int size);
34 extern const char* ircd_ntoa(const char* addr);
35 extern const char* ircd_ntoa_r(char* buf, const char* addr);
36 extern char* host_from_uh(char* buf, const char* userhost, size_t len);
37 extern char* ircd_strtok(char** save, char* str, char* fs);
39 extern char* sprintf_irc(char* str, const char* format, ...);
41 extern char* canonize(char* buf);
43 #define DupString(x, y) (strcpy((x = (char*) MyMalloc(strlen(y) + 1)), y))
46 /* String classification pseudo-functions, when others are needed add them,
47 strIsXxxxx(s) is true when IsXxxxx(c) is true for every char in s */
49 #define strIsAlnum(s) (strChattr(s) & NTL_ALNUM)
50 #define strIsAlpha(s) (strChattr(s) & NTL_ALPHA)
51 #define strIsDigit(s) (strChattr(s) & NTL_DIGIT)
52 #define strIsLower(s) (strChattr(s) & NTL_LOWER)
53 #define strIsSpace(s) (strChattr(s) & NTL_SPACE)
54 #define strIsUpper(s) (strChattr(s) & NTL_UPPER)
56 #define strIsIrcCh(s) (strChattr(s) & NTL_IRCCH)
57 #define strIsIrcCl(s) (strChattr(s) & NTL_IRCCL)
58 #define strIsIrcNk(s) (strChattr(s) & NTL_IRCNK)
59 #define strIsIrcUi(s) (strChattr(s) & NTL_IRCUI)
60 #define strIsIrcHn(s) (strChattr(s) & NTL_IRCHN)
61 #define strIsIrcIp(s) (strChattr(s) & NTL_IRCIP)
64 * Critical small functions to inline even in separate compilation
65 * when FORCEINLINE is defined (provided you have a compiler that supports
69 #define NTL_HDR_strChattr unsigned int strChattr(const char *s)
71 #define NTL_SRC_strChattr const char *rs = s; \
72 unsigned int x = ~0; \
74 x &= IRCD_CharAttrTab[*rs++ - CHAR_MIN]; \
78 * XXX - bleah should return 1 if different 0 if the same
80 #define NTL_HDR_strCasediff int strCasediff(const char *a, const char *b)
82 #define NTL_SRC_strCasediff const char *ra = a; \
84 while(ToLower(*ra) == ToLower(*rb++)) \
90 extern NTL_HDR_strChattr;
91 extern NTL_HDR_strCasediff;
93 #else /* FORCEINLINE */
95 inline NTL_HDR_strChattr { NTL_SRC_strChattr }
96 inline NTL_HDR_strCasediff { NTL_SRC_strCasediff }
98 static __inline__ NTL_HDR_strChattr { NTL_SRC_strChattr }
99 static __inline__ NTL_HDR_strCasediff { NTL_SRC_strCasediff }
101 #endif /* FORCEINLINE */
104 * Proto types of other externally visible functions
106 extern int strnChattr(const char *s, const size_t n);
108 #endif /* INCLUDED_ircd_string_h */