ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid-7.2/include/irc_string.h
Revision: 34
Committed: Sun Oct 2 21:05:51 2005 UTC (18 years, 5 months ago) by lusky
Content type: text/x-chdr
File size: 5743 byte(s)
Log Message:
create 7.2 branch, we can move/rename it as needed.


File Contents

# Content
1 /*
2 * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd).
3 * irc_string.h: A header for the ircd string functions.
4 *
5 * Copyright (C) 2002 by the past and present ircd coders, and others.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20 * USA
21 *
22 * $Id$
23 */
24
25 #ifndef INCLUDED_irc_string_h
26 #define INCLUDED_irc_string_h
27
28 #include "setup.h"
29 #include "pcre.h"
30
31 extern int ircd_pcre_exec(const pcre *, const char *);
32 extern pcre *ircd_pcre_compile(const char *, const char **);
33 extern char *xstrldup(const char *, size_t);
34
35 /*
36 * match - compare name with mask, mask may contain * and ? as wildcards
37 * match - returns 1 on successful match, 0 otherwise
38 *
39 * match_esc - compare with support for escaping chars
40 * match_chan - like match_esc with first character auto-escaped
41 * match_cidr - compares u!h@addr with u!h@addr/cidr
42 */
43 extern int match(const char *, const char *);
44 extern int match_esc(const char *, const char *);
45 extern int match_chan(const char *, const char *);
46 extern int match_cidr(const char *, const char *);
47
48 /*
49 * collapse - collapse a string in place, converts multiple adjacent *'s
50 * into a single *.
51 * collapse - modifies the contents of pattern
52 *
53 * collapse_esc() - collapse with support for escaping chars
54 */
55 extern char *collapse(char *);
56 extern char *collapse_esc(char *);
57
58 /*
59 * NOTE: The following functions are NOT the same as strcasecmp
60 * and strncasecmp! These functions use the Finnish (RFC1459)
61 * character set. Do not replace!
62 *
63 * irccmp - case insensitive comparison of s1 and s2
64 */
65 extern int irccmp(const char *, const char *);
66
67 /*
68 * ircncmp - counted case insensitive comparison of s1 and s2
69 */
70 extern int ircncmp(const char *, const char *, size_t);
71
72 /*
73 * inetntoa - optimized inet_ntoa
74 */
75 extern const char *inetntoa(const char *);
76
77 /* XXX
78 * inetntop()
79 * portable interface for inet_ntop(), kludge; please use inet_ntop if possible
80 * since inet_misc has a more conformant one
81 */
82 extern const char *inetntop(int, const void *, char *, unsigned int);
83
84 #ifndef HAVE_STRLCPY
85 extern size_t strlcpy(char *, const char *, size_t);
86 #endif
87
88 #ifndef HAVE_STRLCAT
89 extern size_t strlcat(char *, const char *, size_t);
90 #endif
91
92 #ifndef HAVE_SNPRINTF
93 extern int snprintf(char *, size_t, const char *,...);
94 #endif
95
96 #ifndef HAVE_VSNPRINTF
97 extern int vsnprintf(char *, size_t, const char *, va_list);
98 #endif
99
100 #ifndef HAVE_BASENAME
101 extern char *basename(char *);
102 #endif
103
104 /*
105 * clean_string - cleanup control and high ascii characters
106 * -Dianora
107 */
108 extern char *clean_string(char *, const unsigned char *, size_t);
109
110 /*
111 * strip_tabs - convert tabs to spaces
112 * - jdc
113 */
114 extern void strip_tabs(char *, const char *, size_t);
115
116 const char *myctime(time_t);
117
118 #define EmptyString(x) (!(x) || (*(x) == '\0'))
119
120 #ifndef HAVE_STRTOK_R
121 extern char *strtoken(char **, char *, const char *);
122 #endif
123
124 /*
125 * character macros
126 */
127 extern const unsigned char ToLowerTab[];
128 #define ToLower(c) (ToLowerTab[(unsigned char)(c)])
129
130 extern const unsigned char ToUpperTab[];
131 #define ToUpper(c) (ToUpperTab[(unsigned char)(c)])
132
133 extern const unsigned int CharAttrs[];
134
135 #define PRINT_C 0x001
136 #define CNTRL_C 0x002
137 #define ALPHA_C 0x004
138 #define PUNCT_C 0x008
139 #define DIGIT_C 0x010
140 #define SPACE_C 0x020
141 #define NICK_C 0x040
142 #define CHAN_C 0x080
143 #define KWILD_C 0x100
144 #define CHANPFX_C 0x200
145 #define USER_C 0x400
146 #define HOST_C 0x800
147 #define NONEOS_C 0x1000
148 #define SERV_C 0x2000
149 #define EOL_C 0x4000
150 #define MWILD_C 0x8000
151
152 #define IsHostChar(c) (CharAttrs[(unsigned char)(c)] & HOST_C)
153 #define IsUserChar(c) (CharAttrs[(unsigned char)(c)] & USER_C)
154 #define IsChanPrefix(c) (CharAttrs[(unsigned char)(c)] & CHANPFX_C)
155 #define IsChanChar(c) (CharAttrs[(unsigned char)(c)] & CHAN_C)
156 #define IsKWildChar(c) (CharAttrs[(unsigned char)(c)] & KWILD_C)
157 #define IsMWildChar(c) (CharAttrs[(unsigned char)(c)] & MWILD_C)
158 #define IsNickChar(c) (CharAttrs[(unsigned char)(c)] & NICK_C)
159 #define IsServChar(c) (CharAttrs[(unsigned char)(c)] & (NICK_C | SERV_C))
160 #define IsCntrl(c) (CharAttrs[(unsigned char)(c)] & CNTRL_C)
161 #define IsAlpha(c) (CharAttrs[(unsigned char)(c)] & ALPHA_C)
162 #define IsSpace(c) (CharAttrs[(unsigned char)(c)] & SPACE_C)
163 #define IsLower(c) (IsAlpha((c)) && ((unsigned char)(c) > 0x5f))
164 #define IsUpper(c) (IsAlpha((c)) && ((unsigned char)(c) < 0x60))
165 #define IsDigit(c) (CharAttrs[(unsigned char)(c)] & DIGIT_C)
166 #define IsXDigit(c) (IsDigit(c) || ('a' <= (c) && (c) <= 'f') || \
167 ('A' <= (c) && (c) <= 'F'))
168 #define IsAlNum(c) (CharAttrs[(unsigned char)(c)] & (DIGIT_C | ALPHA_C))
169 #define IsPrint(c) (CharAttrs[(unsigned char)(c)] & PRINT_C)
170 #define IsAscii(c) ((unsigned char)(c) < 0x80)
171 #define IsGraph(c) (IsPrint((c)) && ((unsigned char)(c) != 0x32))
172 #define IsPunct(c) (!(CharAttrs[(unsigned char)(c)] & \
173 (CNTRL_C | ALPHA_C | DIGIT_C)))
174
175 #define IsNonEOS(c) (CharAttrs[(unsigned char)(c)] & NONEOS_C)
176 #define IsEol(c) (CharAttrs[(unsigned char)(c)] & EOL_C)
177
178 #endif /* INCLUDED_irc_string_h */

Properties

Name Value
svn:eol-style native
svn:keywords Id Revision