]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/message.cpp
cmode(), cflags(), cstatus() -> chanrec::GetStatusChar(), chanrec::GetStatusFlags...
[user/henk/code/inspircd.git] / src / message.cpp
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd is copyright (C) 2002-2006 ChatSpike-Dev.
6  *                       E-mail:
7  *                <brain@chatspike.net>
8  *                <Craig@chatspike.net>
9  *     
10  * Written by Craig Edwards, Craig McLure, and others.
11  * This program is free but copyrighted software; see
12  *            the file COPYING for details.
13  *
14  * ---------------------------------------------------
15  */
16
17 using namespace std;
18
19 #include "inspircd_config.h"
20 #include "inspircd.h"
21 #include "configreader.h"
22 #include <unistd.h>
23 #include <fcntl.h>
24 #include <sys/errno.h>
25 #include <sys/utsname.h>
26 #include <time.h>
27 #include <string>
28 #include <ext/hash_map>
29 #include <map>
30 #include <sstream>
31 #include <vector>
32 #include <deque>
33 #include "users.h"
34 #include "ctables.h"
35 #include "globals.h"
36 #include "modules.h"
37 #include "dynamic.h"
38 #include "wildcard.h"
39 #include "commands.h"
40 #include "message.h"
41 #include "inspstring.h"
42 #include "dns.h"
43 #include "helperfuncs.h"
44
45 extern int MODCOUNT;
46 extern std::vector<Module*> modules;
47 extern std::vector<ircd_module*> factory;
48 extern time_t TIME;
49 extern InspIRCd* ServerInstance;
50
51 /* verify that a user's ident and nickname is valid */
52
53 int isident(const char* n)
54 {
55         if (!n || !*n)
56         {
57                 return 0;
58         }
59         for (char* i = (char*)n; *i; i++)
60         {
61                 if ((*i >= 'A') && (*i <= '}'))
62                 {
63                         continue;
64                 }
65                 if (((*i >= '0') && (*i <= '9')) || (*i == '-') || (*i == '.'))
66                 {
67                         continue;
68                 }
69                 return 0;
70         }
71         return 1;
72 }
73
74
75 int isnick(const char* n)
76 {
77         if (!n || !*n)
78         {
79                 return 0;
80         }
81         int p = 0;
82         for (char* i = (char*)n; *i; i++, p++)
83         {
84                 /* "A"-"}" can occur anywhere in a nickname */
85                 if ((*i >= 'A') && (*i <= '}'))
86                 {
87                         continue;
88                 }
89                 /* "0"-"9", "-" can occur anywhere BUT the first char of a nickname */
90                 if ((((*i >= '0') && (*i <= '9')) || (*i == '-')) && (i > n))
91                 {
92                         continue;
93                 }
94                 /* invalid character! abort */
95                 return 0;
96         }
97         return (p < NICKMAX - 1);
98 }
99