ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/include/irc_string.h
Revision: 1921
Committed: Tue Apr 30 14:54:20 2013 UTC (12 years, 3 months ago) by michael
Content type: text/x-chdr
File size: 4531 byte(s)
Log Message:
- Forward-port -r1920 [Dropped PCRE support]

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

Properties

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