| 1 |
/* |
| 2 |
* Copyright (c) 2011 William Pitcock <[email protected]> |
| 3 |
* |
| 4 |
* Rights to this code are as documented in doc/LICENSE. |
| 5 |
*/ |
| 6 |
|
| 7 |
#include "atheme.h" |
| 8 |
#include "exttarget.h" |
| 9 |
|
| 10 |
DECLARE_MODULE_V1 |
| 11 |
( |
| 12 |
"exttarget/oper", false, _modinit, _moddeinit, |
| 13 |
PACKAGE_STRING, |
| 14 |
VENDOR_STRING |
| 15 |
); |
| 16 |
|
| 17 |
static mowgli_patricia_t **exttarget_tree = NULL; |
| 18 |
|
| 19 |
static myentity_t dummy_entity; |
| 20 |
|
| 21 |
static chanacs_t *dummy_match_user(chanacs_t *ca, user_t *u) |
| 22 |
{ |
| 23 |
if (is_ircop(u)) |
| 24 |
return ca; |
| 25 |
|
| 26 |
return NULL; |
| 27 |
} |
| 28 |
|
| 29 |
static chanacs_t *dummy_match_entity(chanacs_t *ca, myentity_t *mt) |
| 30 |
{ |
| 31 |
if (ca->entity == mt) |
| 32 |
return ca; |
| 33 |
|
| 34 |
return NULL; |
| 35 |
} |
| 36 |
|
| 37 |
static bool dummy_can_register_channel(myentity_t *mt) |
| 38 |
{ |
| 39 |
return false; |
| 40 |
} |
| 41 |
|
| 42 |
static bool dummy_allow_foundership(myentity_t *mt) |
| 43 |
{ |
| 44 |
return false; |
| 45 |
} |
| 46 |
|
| 47 |
static entity_chanacs_validation_vtable_t dummy_validate = { |
| 48 |
.match_entity = dummy_match_entity, |
| 49 |
.match_user = dummy_match_user, |
| 50 |
.can_register_channel = dummy_can_register_channel, |
| 51 |
.allow_foundership = dummy_allow_foundership, |
| 52 |
}; |
| 53 |
|
| 54 |
static myentity_t dummy_entity = { |
| 55 |
.name = "$oper", |
| 56 |
.type = ENT_EXTTARGET, |
| 57 |
.chanacs_validate = &dummy_validate, |
| 58 |
}; |
| 59 |
|
| 60 |
static myentity_t *oper_validate_f(const char *param) |
| 61 |
{ |
| 62 |
return &dummy_entity; |
| 63 |
} |
| 64 |
|
| 65 |
void _modinit(module_t *m) |
| 66 |
{ |
| 67 |
MODULE_TRY_REQUEST_SYMBOL(m, exttarget_tree, "exttarget/main", "exttarget_tree"); |
| 68 |
|
| 69 |
mowgli_patricia_add(*exttarget_tree, "oper", oper_validate_f); |
| 70 |
|
| 71 |
object_init(object(&dummy_entity), "$oper", NULL); |
| 72 |
} |
| 73 |
|
| 74 |
void _moddeinit(module_unload_intent_t intent) |
| 75 |
{ |
| 76 |
mowgli_patricia_delete(*exttarget_tree, "oper"); |
| 77 |
} |