/[svn]/ircd-hybrid-7.2/include/irc_string.h
ViewVC logotype

Contents of /ircd-hybrid-7.2/include/irc_string.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 978 - (show annotations)
Sun Aug 9 09:47:58 2009 UTC (12 years, 1 month ago) by michael
File MIME type: text/x-csrc
File size: 5715 byte(s)
- avoid using native basename() since some implementations may or may not modify passed data

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 "config.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
34 /*
35 * match - compare name with mask, mask may contain * and ? as wildcards
36 * match - returns 1 on successful match, 0 otherwise
37 *
38 * match_esc - compare with support for escaping chars
39 * match_chan - like match_esc with first character auto-escaped
40 */
41 extern int match(const char *, const char *);
42 extern int match_esc(const char *, const char *);
43 extern int match_chan(const char *, const char *);
44
45 /*
46 * collapse - collapse a string in place, converts multiple adjacent *'s
47 * into a single *.
48 * collapse - modifies the contents of pattern
49 *
50 * collapse_esc() - collapse with support for escaping chars
51 */
52 extern char *collapse(char *);
53 extern char *collapse_esc(char *);
54
55 /*
56 * NOTE: The following functions are NOT the same as strcasecmp
57 * and strncasecmp! These functions use the Finnish (RFC1459)
58 * character set. Do not replace!
59 *
60 * irccmp - case insensitive comparison of s1 and s2
61 */
62 extern int irccmp(const char *, const char *);
63
64 /*
65 * ircncmp - counted case insensitive comparison of s1 and s2
66 */
67 extern int ircncmp(const char *, const char *, size_t);
68
69 /*
70 * inetntoa - optimized inet_ntoa
71 */
72 extern const char *inetntoa(const char *);
73
74 /* XXX
75 * inetntop()
76 * portable interface for inet_ntop(), kludge; please use inet_ntop if possible
77 * since inet_misc has a more conformant one
78 */
79 extern const char *inetntop(int, const void *, char *, unsigned int);
80
81 #ifndef HAVE_STRLCPY
82 extern size_t strlcpy(char *, const char *, size_t);
83 #endif
84
85 #ifndef HAVE_STRLCAT
86 extern size_t strlcat(char *, const char *, size_t);
87 #endif
88
89 #ifndef HAVE_SNPRINTF
90 extern int snprintf(char *, size_t, const char *,...);
91 #endif
92
93 #ifndef HAVE_VSNPRINTF
94 extern int vsnprintf(char *, size_t, const char *, va_list);
95 #endif
96
97 extern const char *libio_basename(const char *);
98
99 /*
100 * clean_string - cleanup control and high ascii characters
101 * -Dianora
102 */
103 extern char *clean_string(char *, const unsigned char *, size_t);
104
105 /*
106 * strip_tabs - convert tabs to spaces
107 * - jdc
108 */
109 extern void strip_tabs(char *, const char *, size_t);
110
111 const char *myctime(time_t);
112
113 #define EmptyString(x) (!(x) || (*(x) == '\0'))
114
115 #ifndef HAVE_STRTOK_R
116 extern char *strtoken(char **, char *, const char *);
117 #endif
118
119 /*
120 * character macros
121 */
122 extern const unsigned char ToLowerTab[];
123 #define ToLower(c) (ToLowerTab[(unsigned char)(c)])
124
125 extern const unsigned char ToUpperTab[];
126 #define ToUpper(c) (ToUpperTab[(unsigned char)(c)])
127
128 extern const unsigned int CharAttrs[];
129
130 #define PRINT_C 0x00001
131 #define CNTRL_C 0x00002
132 #define ALPHA_C 0x00004
133 #define PUNCT_C 0x00008
134 #define DIGIT_C 0x00010
135 #define SPACE_C 0x00020
136 #define NICK_C 0x00040
137 #define CHAN_C 0x00080
138 #define KWILD_C 0x00100
139 #define CHANPFX_C 0x00200
140 #define USER_C 0x00400
141 #define HOST_C 0x00800
142 #define NONEOS_C 0x01000
143 #define SERV_C 0x02000
144 #define EOL_C 0x04000
145 #define MWILD_C 0x08000
146 #define VCHAN_C 0x10000
147
148 #define IsVisibleChanChar(c) (CharAttrs[(unsigned char)(c)] & VCHAN_C)
149 #define IsHostChar(c) (CharAttrs[(unsigned char)(c)] & HOST_C)
150 #define IsUserChar(c) (CharAttrs[(unsigned char)(c)] & USER_C)
151 #define IsChanPrefix(c) (CharAttrs[(unsigned char)(c)] & CHANPFX_C)
152 #define IsChanChar(c) (CharAttrs[(unsigned char)(c)] & CHAN_C)
153 #define IsKWildChar(c) (CharAttrs[(unsigned char)(c)] & KWILD_C)
154 #define IsMWildChar(c) (CharAttrs[(unsigned char)(c)] & MWILD_C)
155 #define IsNickChar(c) (CharAttrs[(unsigned char)(c)] & NICK_C)
156 #define IsServChar(c) (CharAttrs[(unsigned char)(c)] & (NICK_C | SERV_C))
157 #define IsCntrl(c) (CharAttrs[(unsigned char)(c)] & CNTRL_C)
158 #define IsAlpha(c) (CharAttrs[(unsigned char)(c)] & ALPHA_C)
159 #define IsSpace(c) (CharAttrs[(unsigned char)(c)] & SPACE_C)
160 #define IsLower(c) (IsAlpha((c)) && ((unsigned char)(c) > 0x5f))
161 #define IsUpper(c) (IsAlpha((c)) && ((unsigned char)(c) < 0x60))
162 #define IsDigit(c) (CharAttrs[(unsigned char)(c)] & DIGIT_C)
163 #define IsXDigit(c) (IsDigit(c) || ('a' <= (c) && (c) <= 'f') || \
164 ('A' <= (c) && (c) <= 'F'))
165 #define IsAlNum(c) (CharAttrs[(unsigned char)(c)] & (DIGIT_C | ALPHA_C))
166 #define IsPrint(c) (CharAttrs[(unsigned char)(c)] & PRINT_C)
167 #define IsAscii(c) ((unsigned char)(c) < 0x80)
168 #define IsGraph(c) (IsPrint((c)) && ((unsigned char)(c) != 0x32))
169 #define IsPunct(c) (!(CharAttrs[(unsigned char)(c)] & \
170 (CNTRL_C | ALPHA_C | DIGIT_C)))
171
172 #define IsNonEOS(c) (CharAttrs[(unsigned char)(c)] & NONEOS_C)
173 #define IsEol(c) (CharAttrs[(unsigned char)(c)] & EOL_C)
174
175 #endif /* INCLUDED_irc_string_h */

Properties

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

svnadmin@ircd-hybrid.org
ViewVC Help
Powered by ViewVC 1.1.28