| 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" |
| 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 |
|
|
| 48 |
|
* output - pointer to struct ResvChannel |
| 49 |
|
* side effects - |
| 50 |
|
*/ |
| 51 |
< |
struct ConfItem * |
| 51 |
> |
struct MaskItem * |
| 52 |
|
create_channel_resv(char *name, char *reason, int in_conf) |
| 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; |
| 59 |
|
if (hash_find_resv(name)) |
| 60 |
|
return NULL; |
| 61 |
|
|
| 62 |
< |
if (strlen(reason) > REASONLEN) |
| 63 |
< |
reason[REASONLEN] = '\0'; |
| 62 |
> |
conf = conf_make(CONF_CRESV); |
| 63 |
> |
conf->name = xstrdup(name); |
| 64 |
> |
conf->reason = xstrndup(reason, IRCD_MIN(strlen(reason), REASONLEN)); |
| 65 |
|
|
| 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); |
| 66 |
> |
dlinkAdd(conf, &conf->node, &resv_channel_list); |
| 67 |
> |
hash_add_resv(conf); |
| 68 |
|
|
| 69 |
|
return conf; |
| 70 |
|
} |
| 77 |
|
* output - pointer to struct ResvNick |
| 78 |
|
* side effects - |
| 79 |
|
*/ |
| 80 |
< |
struct ConfItem * |
| 80 |
> |
struct MaskItem * |
| 81 |
|
create_nick_resv(char *name, char *reason, int in_conf) |
| 82 |
|
{ |
| 83 |
< |
struct ConfItem *conf; |
| 91 |
< |
struct MatchItem *resv_p; |
| 83 |
> |
struct MaskItem *conf = NULL; |
| 84 |
|
|
| 85 |
|
if (name == NULL || reason == NULL) |
| 86 |
|
return NULL; |
| 87 |
|
|
| 88 |
< |
if (find_matching_name_conf(NRESV_TYPE, name, NULL, NULL, 0)) |
| 88 |
> |
if (find_matching_name_conf(CONF_NRESV, name, NULL, NULL, 0)) |
| 89 |
|
return NULL; |
| 90 |
|
|
| 91 |
< |
if (strlen(reason) > REASONLEN) |
| 92 |
< |
reason[REASONLEN] = '\0'; |
| 93 |
< |
|
| 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; |
| 91 |
> |
conf = conf_make(CONF_NRESV); |
| 92 |
> |
conf->name = xstrdup(name); |
| 93 |
> |
conf->reason = xstrndup(reason, IRCD_MIN(strlen(reason), REASONLEN)); |
| 94 |
|
|
| 95 |
|
return conf; |
| 96 |
|
} |
| 104 |
|
void |
| 105 |
|
clear_conf_resv(void) |
| 106 |
|
{ |
| 107 |
< |
dlink_node *ptr; |
| 122 |
< |
dlink_node *next_ptr; |
| 123 |
< |
struct ResvChannel *resv_cp; |
| 107 |
> |
dlink_node *ptr = NULL, *next_ptr = NULL; |
| 108 |
|
|
| 109 |
|
DLINK_FOREACH_SAFE(ptr, next_ptr, resv_channel_list.head) |
| 110 |
|
{ |
| 111 |
< |
resv_cp = ptr->data; |
| 112 |
< |
delete_channel_resv(resv_cp); |
| 111 |
> |
struct MaskItem *conf = ptr->data; |
| 112 |
> |
|
| 113 |
> |
if (!IsConfDatabase(conf)) |
| 114 |
> |
delete_channel_resv(conf); |
| 115 |
|
} |
| 116 |
|
} |
| 117 |
|
|
| 122 |
|
* side effects - given struct ResvChannel * is removed |
| 123 |
|
*/ |
| 124 |
|
int |
| 125 |
< |
delete_channel_resv(struct ResvChannel *resv_p) |
| 125 |
> |
delete_channel_resv(struct MaskItem *conf) |
| 126 |
|
{ |
| 127 |
< |
struct ConfItem *conf; |
| 128 |
< |
assert(resv_p != NULL); |
| 129 |
< |
|
| 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); |
| 127 |
> |
hash_del_resv(conf); |
| 128 |
> |
dlinkDelete(&conf->node, &resv_channel_list); |
| 129 |
> |
conf_free(conf); |
| 130 |
|
|
| 131 |
|
return 1; |
| 132 |
|
} |
| 138 |
|
* side effects - Finds a reserved channel whose name matches 'name', |
| 139 |
|
* if can't find one returns NULL. |
| 140 |
|
*/ |
| 141 |
< |
struct ResvChannel * |
| 141 |
> |
struct MaskItem * |
| 142 |
|
match_find_resv(const char *name) |
| 143 |
|
{ |
| 144 |
|
dlink_node *ptr = NULL; |
| 148 |
|
|
| 149 |
|
DLINK_FOREACH(ptr, resv_channel_list.head) |
| 150 |
|
{ |
| 151 |
< |
struct ResvChannel *chptr = ptr->data; |
| 151 |
> |
struct MaskItem *conf = ptr->data; |
| 152 |
|
|
| 153 |
< |
if (match_chan(name, chptr->name)) |
| 154 |
< |
return chptr; |
| 153 |
> |
if (match_chan(name, conf->name)) |
| 154 |
> |
return conf; |
| 155 |
|
} |
| 156 |
|
|
| 157 |
|
return NULL; |
| 166 |
|
void |
| 167 |
|
report_resv(struct Client *source_p) |
| 168 |
|
{ |
| 169 |
< |
dlink_node *ptr; |
| 170 |
< |
struct ConfItem *conf; |
| 190 |
< |
struct ResvChannel *resv_cp; |
| 191 |
< |
struct MatchItem *resv_np; |
| 169 |
> |
dlink_node *ptr = NULL; |
| 170 |
> |
struct MaskItem *conf = NULL; |
| 171 |
|
|
| 172 |
|
DLINK_FOREACH(ptr, resv_channel_list.head) |
| 173 |
|
{ |
| 174 |
< |
resv_cp = ptr->data; |
| 174 |
> |
conf = ptr->data; |
| 175 |
|
sendto_one(source_p, form_str(RPL_STATSQLINE), |
| 176 |
|
me.name, source_p->name, |
| 177 |
< |
resv_cp->conf ? 'Q' : 'q', |
| 178 |
< |
resv_cp->name, resv_cp->reason); |
| 177 |
> |
conf->until ? 'q' : 'Q', |
| 178 |
> |
conf->name, conf->reason); |
| 179 |
|
} |
| 180 |
|
|
| 181 |
|
DLINK_FOREACH(ptr, nresv_items.head) |
| 182 |
|
{ |
| 183 |
|
conf = ptr->data; |
| 205 |
– |
resv_np = map_to_conf(conf); |
| 206 |
– |
|
| 184 |
|
sendto_one(source_p, form_str(RPL_STATSQLINE), |
| 185 |
|
me.name, source_p->name, |
| 186 |
< |
resv_np->action ? 'Q' : 'q', |
| 187 |
< |
conf->name, resv_np->reason); |
| 186 |
> |
conf->until ? 'q' : 'Q', |
| 187 |
> |
conf->name, conf->reason); |
| 188 |
|
} |
| 189 |
|
} |
| 190 |
|
|