conf.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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 pscloak; /* should the bots bother trying to cloak `ps`? */
  33. int autocron; /* should the bot auto crontab itself? */
  34. int watcher; /* spawn a watcher pid to block ptrace? */
  35. char *localhub; /* my localhub */
  36. char *uname;
  37. char *datadir;
  38. char *username; /* shell username */
  39. char *homedir; /* homedir */
  40. char *binpath; /* path to binary, ie: ~/ */
  41. char *binname; /* binary name, ie: .sshrc */
  42. port_t portmin; /* for hubs, the reserved port range for incoming connections */
  43. port_t portmax; /* for hubs, the reserved port range for incoming connections */
  44. } conf_t;
  45. extern conf_t conf;
  46. enum {
  47. CONF_ENC = 1,
  48. CONF_COMMENT = 2
  49. };
  50. void spawnbot(const char *);
  51. void spawnbots(conf_bot *bots, bool rehashed = 0);
  52. int conf_killbot(conf_bot *, const char *, conf_bot *, int, bool = 0);
  53. void confedit() __attribute__((noreturn));
  54. void conf_addbot(char *, char *, char *, char *);
  55. int conf_delbot(char *, bool kill = 1);
  56. pid_t checkpid(const char *, conf_bot *, const char *);
  57. void init_conf();
  58. void free_conf();
  59. void free_conf_bots(conf_bot *);
  60. void free_bot(conf_bot *bot);
  61. int readconf(const char *, int);
  62. int parseconf(bool);
  63. int writeconf(char *, FILE *, int);
  64. void fill_conf_bot(bool fatal = 1);
  65. void bin_to_conf(bool error = 0);
  66. void conf_checkpids(conf_bot *bots, bool all = 1);
  67. void conf_add_userlist_bots();
  68. conf_bot *conf_bots_dup(conf_bot *);
  69. void deluser_removed_bots(conf_bot *, conf_bot *);
  70. conf_bot *conf_getlocalhub(conf_bot *);
  71. void conf_setmypid(pid_t);
  72. void conf_bot_dup(conf_bot *dest, conf_bot *src);
  73. #ifdef CYGWIN_HACKS
  74. extern char cfile[DIRMAX];
  75. #endif /* CYGWIN_HACKS */
  76. #endif /* !_CONF_H */