users.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. /*
  2. * users.h
  3. * structures and definitions used by users.c and userrec.c
  4. *
  5. */
  6. #ifndef _EGG_USERS_H
  7. #define _EGG_USERS_H
  8. #ifdef HAVE_CONFIG_H
  9. # include "config.h"
  10. #endif
  11. /* List functions :) , next *must* be the 1st item in the struct */
  12. struct list_type {
  13. struct list_type *next;
  14. char *extra;
  15. };
  16. #define list_insert(a,b) { \
  17. (b)->next = *(a); \
  18. *(a) = (b); \
  19. }
  20. int list_append(struct list_type **, struct list_type *);
  21. int list_delete(struct list_type **, struct list_type *);
  22. int list_contains(struct list_type *, struct list_type *);
  23. /* New userfile format stuff
  24. */
  25. struct userrec;
  26. struct user_entry;
  27. struct user_entry_type {
  28. struct user_entry_type *next;
  29. int (*got_share) (struct userrec *, struct user_entry *, char *, int);
  30. int (*dup_user) (struct userrec *, struct userrec *,
  31. struct user_entry *);
  32. int (*unpack) (struct userrec *, struct user_entry *);
  33. int (*pack) (struct userrec *, struct user_entry *);
  34. int (*write_userfile) (FILE *, struct userrec *, struct user_entry *);
  35. int (*kill) (struct user_entry *);
  36. void *(*get) (struct userrec *, struct user_entry *);
  37. int (*set) (struct userrec *, struct user_entry *, void *);
  38. void (*display) (int idx, struct user_entry *, struct userrec *);
  39. char *name;
  40. };
  41. #ifndef MAKING_MODS
  42. extern struct user_entry_type USERENTRY_COMMENT, USERENTRY_LASTON,
  43. USERENTRY_INFO, USERENTRY_BOTADDR, USERENTRY_HOSTS,
  44. USERENTRY_PASS, USERENTRY_BOTFL,
  45. USERENTRY_STATS,
  46. USERENTRY_ADDED,
  47. USERENTRY_MODIFIED,
  48. USERENTRY_CONFIG,
  49. USERENTRY_SECPASS;
  50. #endif /* MAKING_MODS */
  51. struct laston_info {
  52. time_t laston;
  53. char *lastonplace;
  54. };
  55. struct bot_addr {
  56. int telnet_port;
  57. int relay_port;
  58. int hublevel;
  59. char *address;
  60. char *uplink;
  61. int roleid;
  62. };
  63. struct user_entry {
  64. struct user_entry *next;
  65. struct user_entry_type *type;
  66. union {
  67. char *string;
  68. void *extra;
  69. struct list_type *list;
  70. unsigned long ulong;
  71. } u;
  72. char *name;
  73. };
  74. struct xtra_key {
  75. struct xtra_key *next;
  76. char *key;
  77. char *data;
  78. };
  79. struct filesys_stats {
  80. int uploads;
  81. int upload_ks;
  82. int dnloads;
  83. int dnload_ks;
  84. };
  85. int add_entry_type(struct user_entry_type *);
  86. int del_entry_type(struct user_entry_type *);
  87. struct user_entry_type *find_entry_type(char *);
  88. struct user_entry *find_user_entry(struct user_entry_type *, struct userrec *);
  89. void *get_user(struct user_entry_type *, struct userrec *);
  90. int set_user(struct user_entry_type *, struct userrec *, void *);
  91. #define bot_flags(u) ((long)get_user(&USERENTRY_BOTFL, (u)))
  92. #define is_bot(u) ((u) && ((u)->flags & USER_BOT))
  93. #define is_owner(u) ((u) && ((u)->flags & USER_OWNER))
  94. /* Fake users used to store ignores and bans
  95. */
  96. #define IGNORE_NAME "*ignore"
  97. #define BAN_NAME "*ban"
  98. #define EXEMPT_NAME "*exempt"
  99. #define INVITE_NAME "*Invite"
  100. #define CHANS_NAME "*channels"
  101. #define CONFIG_NAME "*Config"
  102. /* Channel-specific info
  103. */
  104. struct chanuserrec {
  105. struct chanuserrec *next;
  106. char channel[81];
  107. time_t laston;
  108. unsigned long flags;
  109. unsigned long flags_udef;
  110. char *info;
  111. };
  112. /* New-style userlist
  113. */
  114. struct userrec {
  115. struct userrec *next;
  116. char handle[HANDLEN + 1];
  117. unsigned long flags;
  118. unsigned long flags_udef;
  119. struct chanuserrec *chanrec;
  120. struct user_entry *entries;
  121. };
  122. struct igrec {
  123. struct igrec *next;
  124. char *igmask;
  125. time_t expire;
  126. char *user;
  127. time_t added;
  128. char *msg;
  129. int flags;
  130. };
  131. extern struct igrec *global_ign;
  132. #define IGREC_PERM 2
  133. /*
  134. * Note: Flags are in eggdrop.h
  135. */
  136. struct userrec *adduser();
  137. struct userrec *get_user_by_handle(struct userrec *, char *);
  138. struct userrec *get_user_by_host(char *);
  139. struct userrec *get_user_by_nick(char *);
  140. struct userrec *check_chanlist();
  141. struct userrec *check_chanlist_hand();
  142. /* All the default userentry stuff, for code re-use
  143. */
  144. int def_unpack(struct userrec *u, struct user_entry *e);
  145. int def_pack(struct userrec *u, struct user_entry *e);
  146. int def_kill(struct user_entry *e);
  147. int def_write_userfile(FILE *f, struct userrec *u, struct user_entry *e);
  148. void *def_get(struct userrec *u, struct user_entry *e);
  149. int def_set(struct userrec *u, struct user_entry *e, void *buf);
  150. int def_gotshare(struct userrec *u, struct user_entry *e,
  151. char *data, int idx);
  152. void def_display(int idx, struct user_entry *e, struct userrec *u);
  153. int def_dupuser(struct userrec *new, struct userrec *old,
  154. struct user_entry *e);
  155. #ifndef MAKING_MODS
  156. int whois_access(struct userrec *, struct userrec *);
  157. #ifdef HUB
  158. void backup_userfile();
  159. #endif /* HUB */
  160. void addignore(char *, char *, char *, time_t);
  161. int delignore(char *);
  162. void tell_ignores(int, char *);
  163. int match_ignore(char *);
  164. void check_expired_ignores();
  165. void autolink_cycle(char *);
  166. void tell_file_stats(int, char *);
  167. void tell_user_ident(int, char *, int);
  168. void tell_users_match(int, char *, int, int, int, char *);
  169. int readuserfile(char *, struct userrec **);
  170. void check_pmode();
  171. void link_pref_val(struct userrec *u, char *lval);
  172. #endif /* !MAKING_MODS */
  173. #endif /* _EGG_USERS_H */