ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/include/irc_string.h
Revision: 2865
Committed: Sun Jan 19 14:35:22 2014 UTC (11 years, 7 months ago) by michael
Content type: text/x-chdr
File size: 4585 byte(s)
Log Message:
- Clean up all files in include/ (fixed indentation, removed whitespaces/tabs)
- Fixed copyright years

File Contents

# User Rev Content
1 adx 30 /*
2 michael 2865 * ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
3 adx 30 *
4 michael 2865 * Copyright (c) 1999-2014 ircd-hybrid development team
5 adx 30 *
6     * This program is free software; you can redistribute it and/or modify
7     * it under the terms of the GNU General Public License as published by
8     * the Free Software Foundation; either version 2 of the License, or
9     * (at your option) any later version.
10     *
11     * This program is distributed in the hope that it will be useful,
12     * but WITHOUT ANY WARRANTY; without even the implied warranty of
13     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14     * GNU General Public License for more details.
15     *
16     * You should have received a copy of the GNU General Public License
17     * along with this program; if not, write to the Free Software
18     * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19     * USA
20     */
21    
22 michael 2865 /*! \file irc_string.h
23     * \brief A header for the ircd string functions.
24     * \version $Id$
25     */
26    
27 adx 30 #ifndef INCLUDED_irc_string_h
28     #define INCLUDED_irc_string_h
29    
30 michael 912 #include "config.h"
31 adx 30
32 michael 1400
33     extern int has_wildcards(const char *);
34 adx 30 extern int match(const char *, const char *);
35    
36     /*
37 michael 2865 * collapse - collapse a string in place, converts multiple adjacent *'s
38 adx 30 * into a single *.
39 michael 2865 * collapse - modifies the contents of pattern
40 adx 30 */
41     extern char *collapse(char *);
42    
43     /*
44     * NOTE: The following functions are NOT the same as strcasecmp
45     * and strncasecmp! These functions use the Finnish (RFC1459)
46     * character set. Do not replace!
47 michael 2865 *
48 adx 30 * irccmp - case insensitive comparison of s1 and s2
49     */
50     extern int irccmp(const char *, const char *);
51    
52     /*
53     * ircncmp - counted case insensitive comparison of s1 and s2
54     */
55     extern int ircncmp(const char *, const char *, size_t);
56    
57     #ifndef HAVE_STRLCPY
58     extern size_t strlcpy(char *, const char *, size_t);
59     #endif
60    
61     #ifndef HAVE_STRLCAT
62     extern size_t strlcat(char *, const char *, size_t);
63     #endif
64    
65 michael 978 extern const char *libio_basename(const char *);
66 adx 30
67     /*
68     * strip_tabs - convert tabs to spaces
69     * - jdc
70     */
71     extern void strip_tabs(char *, const char *, size_t);
72    
73     const char *myctime(time_t);
74    
75     #define EmptyString(x) (!(x) || (*(x) == '\0'))
76    
77     #ifndef HAVE_STRTOK_R
78     extern char *strtoken(char **, char *, const char *);
79     #endif
80    
81     /*
82     * character macros
83     */
84     extern const unsigned char ToLowerTab[];
85     #define ToLower(c) (ToLowerTab[(unsigned char)(c)])
86    
87     extern const unsigned char ToUpperTab[];
88     #define ToUpper(c) (ToUpperTab[(unsigned char)(c)])
89    
90     extern const unsigned int CharAttrs[];
91    
92 michael 632 #define PRINT_C 0x00001
93     #define CNTRL_C 0x00002
94     #define ALPHA_C 0x00004
95     #define PUNCT_C 0x00008
96     #define DIGIT_C 0x00010
97     #define SPACE_C 0x00020
98     #define NICK_C 0x00040
99     #define CHAN_C 0x00080
100     #define KWILD_C 0x00100
101     #define CHANPFX_C 0x00200
102     #define USER_C 0x00400
103     #define HOST_C 0x00800
104     #define NONEOS_C 0x01000
105     #define SERV_C 0x02000
106     #define EOL_C 0x04000
107     #define MWILD_C 0x08000
108 db 633 #define VCHAN_C 0x10000
109 adx 30
110 db 633 #define IsVisibleChanChar(c) (CharAttrs[(unsigned char)(c)] & VCHAN_C)
111 adx 30 #define IsHostChar(c) (CharAttrs[(unsigned char)(c)] & HOST_C)
112     #define IsUserChar(c) (CharAttrs[(unsigned char)(c)] & USER_C)
113     #define IsChanPrefix(c) (CharAttrs[(unsigned char)(c)] & CHANPFX_C)
114     #define IsChanChar(c) (CharAttrs[(unsigned char)(c)] & CHAN_C)
115     #define IsKWildChar(c) (CharAttrs[(unsigned char)(c)] & KWILD_C)
116     #define IsMWildChar(c) (CharAttrs[(unsigned char)(c)] & MWILD_C)
117     #define IsNickChar(c) (CharAttrs[(unsigned char)(c)] & NICK_C)
118     #define IsServChar(c) (CharAttrs[(unsigned char)(c)] & (NICK_C | SERV_C))
119     #define IsCntrl(c) (CharAttrs[(unsigned char)(c)] & CNTRL_C)
120     #define IsAlpha(c) (CharAttrs[(unsigned char)(c)] & ALPHA_C)
121     #define IsSpace(c) (CharAttrs[(unsigned char)(c)] & SPACE_C)
122     #define IsLower(c) (IsAlpha((c)) && ((unsigned char)(c) > 0x5f))
123     #define IsUpper(c) (IsAlpha((c)) && ((unsigned char)(c) < 0x60))
124     #define IsDigit(c) (CharAttrs[(unsigned char)(c)] & DIGIT_C)
125 michael 2865 #define IsXDigit(c) (IsDigit(c) || ('a' <= (c) && (c) <= 'f') || \
126     ('A' <= (c) && (c) <= 'F'))
127 adx 30 #define IsAlNum(c) (CharAttrs[(unsigned char)(c)] & (DIGIT_C | ALPHA_C))
128     #define IsPrint(c) (CharAttrs[(unsigned char)(c)] & PRINT_C)
129     #define IsAscii(c) ((unsigned char)(c) < 0x80)
130     #define IsGraph(c) (IsPrint((c)) && ((unsigned char)(c) != 0x32))
131     #define IsPunct(c) (!(CharAttrs[(unsigned char)(c)] & \
132     (CNTRL_C | ALPHA_C | DIGIT_C)))
133    
134     #define IsNonEOS(c) (CharAttrs[(unsigned char)(c)] & NONEOS_C)
135     #define IsEol(c) (CharAttrs[(unsigned char)(c)] & EOL_C)
136     #endif /* INCLUDED_irc_string_h */

Properties

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