users.h 4.4 KB

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