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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1652 - (show annotations)
Tue Nov 13 20:28:53 2012 UTC (7 years, 7 months ago) by michael
File MIME type: text/x-csrc
File size: 5006 byte(s)
- changed match() polarity. match() now returns 0 on match and 1 on non-match
  This cleans up several places where function pointers of different matching
  functions like irccmp/strcmp/match are passed to other functions.
- added improved collapse() to match.c

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
30
31 extern int has_wildcards(const char *);
32 extern int ircd_pcre_exec(const void *, const char *);
33 extern void *ircd_pcre_compile(const char *, const char **);
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 */
42 extern int match(const char *, const char *);
43 extern int match_esc(const char *, const char *);
44 extern int match_chan(const char *, const char *);
45
46 /*
47 * collapse - collapse a string in place, converts multiple adjacent *'s
48 * into a single *.
49 * collapse - modifies the contents of pattern
50 */
51 extern char *collapse(char *);
52
53 /*
54 * NOTE: The following functions are NOT the same as strcasecmp
55 * and strncasecmp! These functions use the Finnish (RFC1459)
56 * character set. Do not replace!
57 *
58 * irccmp - case insensitive comparison of s1 and s2
59 */
60 extern int irccmp(const char *, const char *);
61
62 /*
63 * ircncmp - counted case insensitive comparison of s1 and s2
64 */
65 extern int ircncmp(const char *, const char *, size_t);
66
67 #ifndef HAVE_STRLCPY
68 extern size_t strlcpy(char *, const char *, size_t);
69 #endif
70
71 #ifndef HAVE_STRLCAT
72 extern size_t strlcat(char *, const char *, size_t);
73 #endif
74
75 extern const char *libio_basename(const char *);
76
77 /*
78 * strip_tabs - convert tabs to spaces
79 * - jdc
80 */
81 extern void strip_tabs(char *, const char *, size_t);
82
83 const char *myctime(time_t);
84
85 #define EmptyString(x) (!(x) || (*(x) == '\0'))
86
87 #ifndef HAVE_STRTOK_R
88 extern char *strtoken(char **, char *, const char *);
89 #endif
90
91 /*
92 * character macros
93 */
94 extern const unsigned char ToLowerTab[];
95 #define ToLower(c) (ToLowerTab[(unsigned char)(c)])
96
97 extern const unsigned char ToUpperTab[];
98 #define ToUpper(c) (ToUpperTab[(unsigned char)(c)])
99
100 extern const unsigned int CharAttrs[];
101
102 #define PRINT_C 0x00001
103 #define CNTRL_C 0x00002
104 #define ALPHA_C 0x00004
105 #define PUNCT_C 0x00008
106 #define DIGIT_C 0x00010
107 #define SPACE_C 0x00020
108 #define NICK_C 0x00040
109 #define CHAN_C 0x00080
110 #define KWILD_C 0x00100
111 #define CHANPFX_C 0x00200
112 #define USER_C 0x00400
113 #define HOST_C 0x00800
114 #define NONEOS_C 0x01000
115 #define SERV_C 0x02000
116 #define EOL_C 0x04000
117 #define MWILD_C 0x08000
118 #define VCHAN_C 0x10000
119
120 #define IsVisibleChanChar(c) (CharAttrs[(unsigned char)(c)] & VCHAN_C)
121 #define IsHostChar(c) (CharAttrs[(unsigned char)(c)] & HOST_C)
122 #define IsUserChar(c) (CharAttrs[(unsigned char)(c)] & USER_C)
123 #define IsChanPrefix(c) (CharAttrs[(unsigned char)(c)] & CHANPFX_C)
124 #define IsChanChar(c) (CharAttrs[(unsigned char)(c)] & CHAN_C)
125 #define IsKWildChar(c) (CharAttrs[(unsigned char)(c)] & KWILD_C)
126 #define IsMWildChar(c) (CharAttrs[(unsigned char)(c)] & MWILD_C)
127 #define IsNickChar(c) (CharAttrs[(unsigned char)(c)] & NICK_C)
128 #define IsServChar(c) (CharAttrs[(unsigned char)(c)] & (NICK_C | SERV_C))
129 #define IsCntrl(c) (CharAttrs[(unsigned char)(c)] & CNTRL_C)
130 #define IsAlpha(c) (CharAttrs[(unsigned char)(c)] & ALPHA_C)
131 #define IsSpace(c) (CharAttrs[(unsigned char)(c)] & SPACE_C)
132 #define IsLower(c) (IsAlpha((c)) && ((unsigned char)(c) > 0x5f))
133 #define IsUpper(c) (IsAlpha((c)) && ((unsigned char)(c) < 0x60))
134 #define IsDigit(c) (CharAttrs[(unsigned char)(c)] & DIGIT_C)
135 #define IsXDigit(c) (IsDigit(c) || ('a' <= (c) && (c) <= 'f') || \
136 ('A' <= (c) && (c) <= 'F'))
137 #define IsAlNum(c) (CharAttrs[(unsigned char)(c)] & (DIGIT_C | ALPHA_C))
138 #define IsPrint(c) (CharAttrs[(unsigned char)(c)] & PRINT_C)
139 #define IsAscii(c) ((unsigned char)(c) < 0x80)
140 #define IsGraph(c) (IsPrint((c)) && ((unsigned char)(c) != 0x32))
141 #define IsPunct(c) (!(CharAttrs[(unsigned char)(c)] & \
142 (CNTRL_C | ALPHA_C | DIGIT_C)))
143
144 #define IsNonEOS(c) (CharAttrs[(unsigned char)(c)] & NONEOS_C)
145 #define IsEol(c) (CharAttrs[(unsigned char)(c)] & EOL_C)
146
147 #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