conf.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. #ifndef _CONF_H
  2. #define _CONF_H
  3. #include <sys/types.h>
  4. #include <stdio.h>
  5. #include "types.h"
  6. #include "eggdrop.h"
  7. #include "settings.h"
  8. #include <bdlib/src/Array.h>
  9. typedef struct conf_net_b {
  10. char *host;
  11. char *host6;
  12. char *ip;
  13. char *ip6;
  14. bool v6;
  15. } conf_net;
  16. typedef struct conf_bot_b {
  17. struct conf_bot_b *next;
  18. struct userrec *u; /* our own user record */
  19. struct conf_net_b net;
  20. pid_t pid; /* contains the PID for the bot (read for the pidfile) */
  21. int localhub; /* bot is localhub */
  22. bool hub; /* should bot behave as a hub? */
  23. bool disabled; /* is bot disabled in the conf? */
  24. char *nick;
  25. char *pid_file; /* path and filename of the .pid file */
  26. } conf_bot;
  27. typedef struct conf_b {
  28. bd::Array<bd::String> hubs;
  29. conf_bot *bots; /* the list of bots */
  30. conf_bot *bot; /* single bot (me) */
  31. int features; /* Pack features (take, mdop, beta... etc..) */
  32. int uid;
  33. int autocron; /* should the bot auto crontab itself? */
  34. char *localhub; /* my localhub */
  35. char *localhub_socket; /* my localhub unix socket */
  36. char *datadir;
  37. char *username; /* shell username */
  38. char *homedir; /* homedir */
  39. port_t portmin; /* for hubs, the reserved port range for incoming connections */
  40. port_t portmax; /* for hubs, the reserved port range for incoming connections */
  41. } conf_t;
  42. extern conf_t conf;
  43. enum {
  44. CONF_ENC = 1,
  45. CONF_COMMENT = 2
  46. };
  47. void spawnbot(const char *);
  48. void spawnbots(conf_bot *bots, bool rehashed = 0);
  49. int conf_killbot(conf_bot *, const char *, conf_bot *, int, bool = 0);
  50. void confedit() __attribute__((noreturn));
  51. void conf_addbot(const char*, const char*, const char*, const char*);
  52. int conf_delbot(char *, bool kill = 1);
  53. pid_t checkpid(const char *, conf_bot *);
  54. void init_conf();
  55. void free_conf();
  56. void free_conf_bots(conf_bot *);
  57. void free_bot(conf_bot *bot);
  58. int readconf(const char *, int);
  59. int parseconf(bool);
  60. int writeconf(char *, int, int);
  61. void fill_conf_bot(bool fatal = 1);
  62. void bin_to_conf(bool error = 0);
  63. void conf_checkpids(conf_bot *bots, bool all = 1);
  64. void conf_add_userlist_bots();
  65. conf_bot *conf_bots_dup(conf_bot *);
  66. void deluser_removed_bots(conf_bot *, conf_bot *);
  67. conf_bot *conf_getlocalhub(conf_bot *);
  68. void conf_setmypid(pid_t);
  69. void conf_bot_dup(conf_bot *dest, conf_bot *src);
  70. void conf_update_hubs(struct userrec* list);
  71. #endif /* !_CONF_H */