ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/src/resv.c
(Generate patch)

Comparing:
ircd-hybrid-7.2/src/resv.c (file contents), Revision 34 by lusky, Sun Oct 2 21:05:51 2005 UTC vs.
ircd-hybrid/trunk/src/resv.c (file contents), Revision 1825 by michael, Sun Apr 14 19:54:48 2013 UTC

# Line 23 | Line 23
23   */
24  
25   #include "stdinc.h"
26 < #include "tools.h"
27 < #include "common.h"
28 < #include "fdlist.h"
26 > #include "list.h"
27   #include "ircd.h"
28   #include "send.h"
29   #include "client.h"  
# Line 35 | Line 33
33   #include "hash.h"
34   #include "irc_string.h"
35   #include "ircd_defs.h"
36 < #include "s_conf.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  
# Line 48 | Line 48 | dlink_list resv_channel_list = { NULL, N
48   * output       - pointer to struct ResvChannel
49   * side effects -
50   */
51 < struct ConfItem *
52 < create_channel_resv(char *name, char *reason, int in_conf)
51 > struct MaskItem *
52 > create_channel_resv(const char *name, const char *reason)
53   {
54 <  struct ConfItem *conf;
55 <  struct ResvChannel *resv_p;
54 >  struct MaskItem *conf = NULL;
55  
56    if (name == NULL || reason == NULL)
57      return NULL;
58  
59 <  if (hash_find_resv(name))
59 >  if (find_exact_name_conf(CONF_CRESV, NULL, name, NULL, NULL))
60      return NULL;
61  
62 <  if (strlen(reason) > REASONLEN)
63 <    reason[REASONLEN] = '\0';
64 <
66 <  conf = make_conf_item(CRESV_TYPE);
67 <  resv_p = map_to_conf(conf);
68 <
69 <  strlcpy(resv_p->name, name, sizeof(resv_p->name));
70 <  DupString(resv_p->reason, reason);
71 <  resv_p->conf = in_conf;
72 <
73 <  dlinkAdd(resv_p, &resv_p->node, &resv_channel_list);
74 <  hash_add_resv(resv_p);
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   }
# Line 84 | Line 74 | create_channel_resv(char *name, char *re
74   * output       - pointer to struct ResvNick
75   * side effects -
76   */
77 < struct ConfItem *
78 < create_nick_resv(char *name, char *reason, int in_conf)
77 > struct MaskItem *
78 > create_nick_resv(const char *name, const char *reason)
79   {
80 <  struct ConfItem *conf;
91 <  struct MatchItem *resv_p;
80 >  struct MaskItem *conf = NULL;
81  
82    if (name == NULL || reason == NULL)
83      return NULL;
84  
85 <  if (find_matching_name_conf(NRESV_TYPE, name, NULL, NULL, 0))
85 >  if (find_exact_name_conf(CONF_NRESV, NULL, name, NULL, NULL))
86      return NULL;
87  
88 <  if (strlen(reason) > REASONLEN)
89 <    reason[REASONLEN] = '\0';
90 <
102 <  conf = make_conf_item(NRESV_TYPE);
103 <  resv_p = map_to_conf(conf);
104 <
105 <  DupString(conf->name, name);
106 <  DupString(resv_p->reason, reason);
107 <  resv_p->action = in_conf;
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  
112 – /* clear_conf_resv()
113 – *
114 – * inputs       - none
115 – * output       - none
116 – * side effects - All resvs are cleared out
117 – */
118 – void
119 – clear_conf_resv(void)
120 – {
121 –  dlink_node *ptr;
122 –  dlink_node *next_ptr;
123 –  struct ResvChannel *resv_cp;
124 –
125 –  DLINK_FOREACH_SAFE(ptr, next_ptr, resv_channel_list.head)
126 –  {
127 –    resv_cp = ptr->data;
128 –    delete_channel_resv(resv_cp);
129 –  }
130 – }
131 –
132 – /* delete_channel_resv()
133 – *
134 – * inputs       - pointer to channel resv to delete
135 – * output       - none
136 – * side effects - given struct ResvChannel * is removed
137 – */
138 – int
139 – delete_channel_resv(struct ResvChannel *resv_p)
140 – {
141 –  struct ConfItem *conf;
142 –  assert(resv_p != NULL);
143 –
144 –  hash_del_resv(resv_p);
145 –  dlinkDelete(&resv_p->node, &resv_channel_list);
146 –  MyFree(resv_p->reason);
147 –  conf = unmap_conf_item(resv_p);
148 –  delete_conf_item(conf);
149 –
150 –  return 1;
151 – }
152 –
95   /* match_find_resv()
96   *
97   * inputs       - pointer to name
# Line 157 | Line 99 | delete_channel_resv(struct ResvChannel *
99   * side effects - Finds a reserved channel whose name matches 'name',
100   *                if can't find one returns NULL.
101   */
102 < struct ResvChannel *
102 > struct MaskItem *
103   match_find_resv(const char *name)
104   {
105    dlink_node *ptr = NULL;
# Line 167 | Line 109 | match_find_resv(const char *name)
109  
110    DLINK_FOREACH(ptr, resv_channel_list.head)
111    {
112 <    struct ResvChannel *chptr = ptr->data;
112 >    struct MaskItem *conf = ptr->data;
113  
114 <    if (match_chan(name, chptr->name))
115 <      return chptr;
114 >    if (!match(conf->name, name))
115 >      return conf;
116    }
117  
118    return NULL;
# Line 185 | Line 127 | match_find_resv(const char *name)
127   void
128   report_resv(struct Client *source_p)
129   {
130 <  dlink_node *ptr;
131 <  struct ConfItem *conf;
190 <  struct ResvChannel *resv_cp;
191 <  struct MatchItem *resv_np;
130 >  dlink_node *ptr = NULL;
131 >  struct MaskItem *conf = NULL;
132  
133    DLINK_FOREACH(ptr, resv_channel_list.head)
134    {
135 <    resv_cp = ptr->data;
135 >    conf = ptr->data;
136      sendto_one(source_p, form_str(RPL_STATSQLINE),
137                 me.name, source_p->name,
138 <               resv_cp->conf ? 'Q' : 'q',
139 <               resv_cp->name, resv_cp->reason);
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;
205 –    resv_np = map_to_conf(conf);
206 –
145      sendto_one(source_p, form_str(RPL_STATSQLINE),
146                 me.name, source_p->name,
147 <               resv_np->action ? 'Q' : 'q',
148 <               conf->name, resv_np->reason);
147 >               conf->until ? 'q' : 'Q', conf->count,
148 >               conf->name, conf->reason);
149    }
150   }
151  

Diff Legend

– Removed lines
+ Added lines
< Changed lines (old)
> Changed lines (new)