users.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  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 (*unpack) (struct userrec *, struct user_entry *);
  31. #ifdef HUB
  32. int (*write_userfile) (FILE *, struct userrec *, struct user_entry *);
  33. #endif /* HUB */
  34. int (*kill) (struct user_entry *);
  35. void *(*get) (struct userrec *, struct user_entry *);
  36. int (*set) (struct userrec *, struct user_entry *, void *);
  37. void (*display) (int idx, struct user_entry *, struct userrec *);
  38. char *name;
  39. };
  40. extern struct user_entry_type USERENTRY_COMMENT, USERENTRY_LASTON,
  41. USERENTRY_INFO, USERENTRY_BOTADDR, USERENTRY_HOSTS,
  42. USERENTRY_PASS,
  43. USERENTRY_STATS,
  44. USERENTRY_ADDED,
  45. USERENTRY_MODIFIED,
  46. USERENTRY_CONFIG,
  47. USERENTRY_SECPASS;
  48. struct laston_info {
  49. time_t laston;
  50. char *lastonplace;
  51. };
  52. struct bot_addr {
  53. port_t telnet_port;
  54. port_t relay_port;
  55. unsigned short hublevel;
  56. char *address;
  57. char *uplink;
  58. unsigned int roleid;
  59. };
  60. struct user_entry {
  61. struct user_entry *next;
  62. struct user_entry_type *type;
  63. union {
  64. char *string;
  65. void *extra;
  66. struct list_type *list;
  67. unsigned long ulong;
  68. } u;
  69. char *name;
  70. };
  71. struct xtra_key {
  72. struct xtra_key *next;
  73. char *key;
  74. char *data;
  75. };
  76. struct filesys_stats {
  77. int uploads;
  78. int upload_ks;
  79. int dnloads;
  80. int dnload_ks;
  81. };
  82. int add_entry_type(struct user_entry_type *);
  83. struct user_entry_type *find_entry_type(char *);
  84. struct user_entry *find_user_entry(struct user_entry_type *, struct userrec *);
  85. void *get_user(struct user_entry_type *, struct userrec *);
  86. int set_user(struct user_entry_type *, struct userrec *, void *);
  87. #define is_bot(u) ((u) && ((u)->flags & USER_BOT))
  88. /* Fake users used to store ignores and bans
  89. */
  90. #define IGNORE_NAME "*ignore"
  91. #define BAN_NAME "*ban"
  92. #define EXEMPT_NAME "*exempt"
  93. #define INVITE_NAME "*Invite"
  94. #define CHANS_NAME "*channels"
  95. #define CONFIG_NAME "*Config"
  96. /* Channel-specific info
  97. */
  98. struct chanuserrec {
  99. struct chanuserrec *next;
  100. char channel[81];
  101. time_t laston;
  102. flag_t flags;
  103. char *info;
  104. };
  105. /* New-style userlist
  106. */
  107. struct userrec {
  108. struct userrec *next;
  109. char handle[HANDLEN + 1];
  110. flag_t flags;
  111. struct chanuserrec *chanrec;
  112. struct user_entry *entries;
  113. };
  114. struct igrec {
  115. struct igrec *next;
  116. char *igmask;
  117. time_t expire;
  118. char *user;
  119. time_t added;
  120. char *msg;
  121. int flags;
  122. };
  123. extern struct igrec *global_ign;
  124. #define IGREC_PERM 2
  125. /*
  126. * Note: Flags are in eggdrop.h
  127. */
  128. struct userrec *adduser();
  129. struct userrec *get_user_by_handle(struct userrec *, char *);
  130. struct userrec *get_user_by_host(char *);
  131. struct userrec *get_user_by_nick(char *);
  132. struct userrec *check_chanlist();
  133. struct userrec *check_chanlist_hand();
  134. /* All the default userentry stuff, for code re-use
  135. */
  136. int def_unpack(struct userrec *u, struct user_entry *e);
  137. int def_kill(struct user_entry *e);
  138. int def_write_userfile(FILE *f, struct userrec *u, struct user_entry *e);
  139. void *def_get(struct userrec *u, struct user_entry *e);
  140. int def_set(struct userrec *u, struct user_entry *e, void *buf);
  141. int def_gotshare(struct userrec *u, struct user_entry *e,
  142. char *data, int idx);
  143. void def_display(int idx, struct user_entry *e, struct userrec *u);
  144. int def_dupuser(struct userrec *new, struct userrec *old,
  145. struct user_entry *e);
  146. #ifdef HUB
  147. void backup_userfile();
  148. #endif /* HUB */
  149. void addignore(char *, char *, char *, time_t);
  150. int delignore(char *);
  151. void tell_ignores(int, char *);
  152. int match_ignore(char *);
  153. void check_expired_ignores();
  154. void autolink_cycle(char *);
  155. void tell_file_stats(int, char *);
  156. void tell_user_ident(int, char *, int);
  157. void tell_users_match(int, char *, int, int, int, char *);
  158. int readuserfile(char *, struct userrec **);
  159. void check_pmode();
  160. void link_pref_val(struct userrec *u, char *lval);
  161. extern char natip[], userfile[];
  162. extern int ignore_time;
  163. #endif /* _EGG_USERS_H */