conf.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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. typedef struct conf_net_b {
  9. char *host;
  10. char *host6;
  11. char *ip;
  12. char *ip6;
  13. bool v6;
  14. } conf_net;
  15. typedef struct conf_bot_b {
  16. struct conf_bot_b *next;
  17. struct userrec *u; /* our own user record */
  18. struct conf_net_b net;
  19. pid_t pid; /* contains the PID for the bot (read for the pidfile) */
  20. int localhub; /* bot is localhub */
  21. bool hub; /* should bot behave as a hub? */
  22. bool disabled; /* is bot disabled in the conf? */
  23. char *nick;
  24. char *pid_file; /* path and filename of the .pid file */
  25. } conf_bot;
  26. typedef struct conf_b {
  27. conf_bot *bots; /* the list of bots */
  28. conf_bot *bot; /* single bot (me) */
  29. int features; /* Pack features (take, mdop, beta... etc..) */
  30. int uid;
  31. int autouname; /* should we just auto update any changed in uname output? */
  32. int autocron; /* should the bot auto crontab itself? */
  33. int watcher; /* spawn a watcher pid to block ptrace? */
  34. char *localhub; /* my localhub */
  35. char *uname;
  36. char *datadir;
  37. char *username; /* shell username */
  38. char *homedir; /* homedir */
  39. char *binpath; /* path to binary, ie: ~/ */
  40. char *binname; /* binary name, ie: .sshrc */
  41. port_t portmin; /* for hubs, the reserved port range for incoming connections */
  42. port_t portmax; /* for hubs, the reserved port range for incoming connections */
  43. } conf_t;
  44. extern conf_t conf;
  45. enum {
  46. CONF_ENC = 1,
  47. CONF_COMMENT = 2
  48. };
  49. void spawnbot(const char *);
  50. void spawnbots(conf_bot *bots, bool rehashed = 0);
  51. int conf_killbot(conf_bot *, const char *, conf_bot *, int, bool = 0);
  52. void confedit() __attribute__((noreturn));
  53. void conf_addbot(const char*, const char*, const char*, const char*);
  54. int conf_delbot(char *, bool kill = 1);
  55. pid_t checkpid(const char *, conf_bot *);
  56. void init_conf();
  57. void free_conf();
  58. void free_conf_bots(conf_bot *);
  59. void free_bot(conf_bot *bot);
  60. int readconf(const char *, int);
  61. int parseconf(bool);
  62. int writeconf(char *, FILE *, int);
  63. void fill_conf_bot(bool fatal = 1);
  64. void bin_to_conf(bool error = 0);
  65. void conf_checkpids(conf_bot *bots, bool all = 1);
  66. void conf_add_userlist_bots();
  67. conf_bot *conf_bots_dup(conf_bot *);
  68. void deluser_removed_bots(conf_bot *, conf_bot *);
  69. conf_bot *conf_getlocalhub(conf_bot *);
  70. void conf_setmypid(pid_t);
  71. void conf_bot_dup(conf_bot *dest, conf_bot *src);
  72. #ifdef CYGWIN_HACKS
  73. extern char cfile[DIRMAX];
  74. #endif /* CYGWIN_HACKS */
  75. #endif /* !_CONF_H */