| 1 |
#ifndef INLINE_ACCOUNT_H |
| 2 |
#define INLINE_ACCOUNT_H |
| 3 |
|
| 4 |
/* |
| 5 |
* myuser_find(const char *name) |
| 6 |
* |
| 7 |
* Retrieves an account from the accounts DTree. |
| 8 |
* |
| 9 |
* Inputs: |
| 10 |
* - account name to retrieve |
| 11 |
* |
| 12 |
* Outputs: |
| 13 |
* - account wanted or NULL if it's not in the DTree. |
| 14 |
* |
| 15 |
* Side Effects: |
| 16 |
* - none |
| 17 |
*/ |
| 18 |
static inline myuser_t *myuser_find(const char *name) |
| 19 |
{ |
| 20 |
return name ? user(myentity_find(name)) : NULL; |
| 21 |
} |
| 22 |
|
| 23 |
static inline myuser_t *myuser_find_uid(const char *uid) |
| 24 |
{ |
| 25 |
return uid ? user(myentity_find_uid(uid)) : NULL; |
| 26 |
} |
| 27 |
|
| 28 |
/* |
| 29 |
* mynick_find(const char *name) |
| 30 |
* |
| 31 |
* Retrieves a nick from the nicks DTree. |
| 32 |
* |
| 33 |
* Inputs: |
| 34 |
* - nickname to retrieve |
| 35 |
* |
| 36 |
* Outputs: |
| 37 |
* - nick wanted or NULL if it's not in the DTree. |
| 38 |
* |
| 39 |
* Side Effects: |
| 40 |
* - none |
| 41 |
*/ |
| 42 |
static inline mynick_t *mynick_find(const char *name) |
| 43 |
{ |
| 44 |
return name ? mowgli_patricia_retrieve(nicklist, name) : NULL; |
| 45 |
} |
| 46 |
|
| 47 |
static inline myuser_t *myuser_find_by_nick(const char *name) |
| 48 |
{ |
| 49 |
myuser_t *mu; |
| 50 |
mynick_t *mn; |
| 51 |
|
| 52 |
mu = myuser_find(name); |
| 53 |
if (mu != NULL) |
| 54 |
return mu; |
| 55 |
|
| 56 |
if (!nicksvs.no_nick_ownership) |
| 57 |
{ |
| 58 |
mn = mynick_find(name); |
| 59 |
if (mn != NULL) |
| 60 |
return mn->owner; |
| 61 |
} |
| 62 |
|
| 63 |
return NULL; |
| 64 |
} |
| 65 |
|
| 66 |
/* |
| 67 |
* myuser_name_find(const char *name) |
| 68 |
* |
| 69 |
* Retrieves a record from the oldnames DTree. |
| 70 |
* |
| 71 |
* Inputs: |
| 72 |
* - account name to retrieve |
| 73 |
* |
| 74 |
* Outputs: |
| 75 |
* - record wanted or NULL if it's not in the DTree. |
| 76 |
* |
| 77 |
* Side Effects: |
| 78 |
* - none |
| 79 |
*/ |
| 80 |
static inline myuser_name_t *myuser_name_find(const char *name) |
| 81 |
{ |
| 82 |
return name ? mowgli_patricia_retrieve(oldnameslist, name) : NULL; |
| 83 |
} |
| 84 |
|
| 85 |
static inline mychan_t *mychan_find(const char *name) |
| 86 |
{ |
| 87 |
return name ? mowgli_patricia_retrieve(mclist, name) : NULL; |
| 88 |
} |
| 89 |
|
| 90 |
static inline mychan_t *mychan_from(channel_t *chan) |
| 91 |
{ |
| 92 |
return chan ? (chan->mychan ? chan->mychan : mychan_find(chan->name)) : NULL; |
| 93 |
} |
| 94 |
|
| 95 |
static inline bool chanacs_entity_has_flag(mychan_t *mychan, myentity_t *mt, unsigned int level) |
| 96 |
{ |
| 97 |
return mychan && mt ? (chanacs_entity_flags(mychan, mt) & level) != 0 : false; |
| 98 |
} |
| 99 |
|
| 100 |
static inline bool chanacs_source_has_flag(mychan_t *mychan, sourceinfo_t *si, unsigned int level) |
| 101 |
{ |
| 102 |
return si->su != NULL ? chanacs_user_has_flag(mychan, si->su, level) : |
| 103 |
chanacs_entity_has_flag(mychan, entity(si->smu), level); |
| 104 |
} |
| 105 |
|
| 106 |
/* Destroy a chanacs if it has no flags */ |
| 107 |
static inline void chanacs_close(chanacs_t *ca) |
| 108 |
{ |
| 109 |
if (ca->level == 0) |
| 110 |
object_unref(ca); |
| 111 |
} |
| 112 |
|
| 113 |
/* Call this with a chanacs_t with level==0 */ |
| 114 |
static inline bool chanacs_is_table_full(chanacs_t *ca) |
| 115 |
{ |
| 116 |
return chansvs.maxchanacs > 0 && |
| 117 |
MOWGLI_LIST_LENGTH(&ca->mychan->chanacs) > chansvs.maxchanacs; |
| 118 |
} |
| 119 |
|
| 120 |
#endif |