ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/src/conf_resv.c
Revision: 1834
Committed: Fri Apr 19 19:50:27 2013 UTC (12 years, 4 months ago) by michael
Content type: text/x-csrc
Original Path: ircd-hybrid/trunk/src/resv.c
File size: 4214 byte(s)
Log Message:
- Revert to -r1831

File Contents

# Content
1 /*
2 * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd).
3 * resv.c: Functions to reserve(jupe) a nick/channel.
4 *
5 * Copyright (C) 2001-2002 Hybrid Development Team
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 #include "stdinc.h"
26 #include "list.h"
27 #include "ircd.h"
28 #include "send.h"
29 #include "client.h"
30 #include "memory.h"
31 #include "numeric.h"
32 #include "resv.h"
33 #include "hash.h"
34 #include "irc_string.h"
35 #include "ircd_defs.h"
36 #include "s_misc.h"
37 #include "conf.h"
38 #include "conf_db.h"
39
40 dlink_list resv_channel_list = { NULL, NULL, 0 };
41
42
43 /* create_channel_resv()
44 *
45 * inputs - name of channel to create resv for
46 * - reason for resv
47 * - flag, 1 for from ircd.conf 0 from elsehwere
48 * output - pointer to struct ResvChannel
49 * side effects -
50 */
51 struct MaskItem *
52 create_channel_resv(const char *name, const char *reason)
53 {
54 struct MaskItem *conf = NULL;
55
56 if (name == NULL || reason == NULL)
57 return NULL;
58
59 if (find_exact_name_conf(CONF_CRESV, NULL, name, NULL, NULL))
60 return NULL;
61
62 conf = conf_make(CONF_CRESV);
63 conf->name = xstrdup(name);
64 conf->reason = xstrndup(reason, IRCD_MIN(strlen(reason), REASONLEN));
65
66 return conf;
67 }
68
69 /* create_nick_resv()
70 *
71 * inputs - name of nick to create resv for
72 * - reason for resv
73 * - 1 if from ircd.conf, 0 if from elsewhere
74 * output - pointer to struct ResvNick
75 * side effects -
76 */
77 struct MaskItem *
78 create_nick_resv(const char *name, const char *reason)
79 {
80 struct MaskItem *conf = NULL;
81
82 if (name == NULL || reason == NULL)
83 return NULL;
84
85 if (find_exact_name_conf(CONF_NRESV, NULL, name, NULL, NULL))
86 return NULL;
87
88 conf = conf_make(CONF_NRESV);
89 conf->name = xstrdup(name);
90 conf->reason = xstrndup(reason, IRCD_MIN(strlen(reason), REASONLEN));
91
92 return conf;
93 }
94
95 /* match_find_resv()
96 *
97 * inputs - pointer to name
98 * output - pointer to a struct ResvChannel
99 * side effects - Finds a reserved channel whose name matches 'name',
100 * if can't find one returns NULL.
101 */
102 struct MaskItem *
103 match_find_resv(const char *name)
104 {
105 dlink_node *ptr = NULL;
106
107 if (EmptyString(name))
108 return NULL;
109
110 DLINK_FOREACH(ptr, resv_channel_list.head)
111 {
112 struct MaskItem *conf = ptr->data;
113
114 if (!match(conf->name, name))
115 return conf;
116 }
117
118 return NULL;
119 }
120
121 /* report_resv()
122 *
123 * inputs - pointer to client pointer to report to.
124 * output - NONE
125 * side effects - report all resvs to client.
126 */
127 void
128 report_resv(struct Client *source_p)
129 {
130 dlink_node *ptr = NULL;
131 struct MaskItem *conf = NULL;
132
133 DLINK_FOREACH(ptr, resv_channel_list.head)
134 {
135 conf = ptr->data;
136 sendto_one(source_p, form_str(RPL_STATSQLINE),
137 me.name, source_p->name,
138 conf->until ? 'q' : 'Q', conf->count,
139 conf->name, conf->reason);
140 }
141
142 DLINK_FOREACH(ptr, nresv_items.head)
143 {
144 conf = ptr->data;
145 sendto_one(source_p, form_str(RPL_STATSQLINE),
146 me.name, source_p->name,
147 conf->until ? 'q' : 'Q', conf->count,
148 conf->name, conf->reason);
149 }
150 }
151
152 /* valid_wild_card_simple()
153 *
154 * inputs - data to check for sufficient non-wildcard characters
155 * outputs - 1 if valid, else 0
156 * side effects - none
157 */
158 int
159 valid_wild_card_simple(const char *data)
160 {
161 const unsigned char *p = (const unsigned char *)data;
162 int nonwild = 0;
163
164 while (*p != '\0')
165 {
166 if ((*p == '\\' && *++p) || (*p && !IsMWildChar(*p)))
167 if (++nonwild == ConfigFileEntry.min_nonwildcard_simple)
168 return 1;
169 if (*p != '\0')
170 ++p;
171 }
172
173 return 0;
174 }

Properties

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