users.h 4.4 KB

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