tclhash.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /*
  2. * tclhash.h
  3. *
  4. */
  5. #ifndef _EGG_TCLHASH_H
  6. #define _EGG_TCLHASH_H
  7. #include "cmds.h"
  8. /* Match type flags for bind tables. */
  9. #define MATCH_PARTIAL BIT0
  10. #define MATCH_EXACT BIT1
  11. #define MATCH_MASK BIT2
  12. #define MATCH_CASE BIT3
  13. #define MATCH_NONE BIT4
  14. #define MATCH_FLAGS_AND BIT5
  15. #define MATCH_FLAGS_OR BIT6
  16. #define MATCH_FLAGS BIT7
  17. /* Flags for binds. */
  18. /* Does the callback want their client_data inserted as the first argument? */
  19. #define BIND_WANTS_CD BIT0
  20. #define BIND_BREAKABLE BIT1
  21. #define BIND_STACKABLE BIT2
  22. #define BIND_DELETED BIT3
  23. #define BIND_FAKE BIT4
  24. /*** Note: bind entries can specify these two flags, defined above.
  25. #define MATCH_FLAGS_AND BIT5
  26. #define MATCH_FLAGS_OR BIT6
  27. ***/
  28. /* Flags for return values from bind callbacks */
  29. #define BIND_RET_LOG 1
  30. #define BIND_RET_BREAK 2
  31. /* This holds the information of a bind entry. */
  32. typedef struct bind_entry_b {
  33. struct bind_entry_b *next, *prev;
  34. struct flag_record user_flags;
  35. char *mask;
  36. char *function_name;
  37. Function callback;
  38. void *client_data;
  39. int nhits;
  40. int flags;
  41. int id;
  42. } bind_entry_t;
  43. /* This is the highest-level structure. It's like the "msg" table
  44. or the "pubm" table. */
  45. typedef struct bind_table_b {
  46. struct bind_table_b *next;
  47. bind_entry_t *entries;
  48. char *name;
  49. char *syntax;
  50. int nargs;
  51. int match_type;
  52. int flags;
  53. } bind_table_t;
  54. void kill_binds(void);
  55. void binds_init();
  56. int check_bind(bind_table_t *table, const char *match, struct flag_record *flags, ...);
  57. int check_bind_hits(bind_table_t *table, const char *match, struct flag_record *flags, int *hits, ...);
  58. bind_table_t *bind_table_add(const char *name, int nargs, const char *syntax, int match_type, int flags);
  59. void bind_table_del(bind_table_t *table);
  60. bind_table_t *bind_table_lookup(const char *name);
  61. bind_table_t *bind_table_lookup_or_fake(const char *name);
  62. int bind_entry_add(bind_table_t *table, const char *flags, const char *mask, const char *function_name, int bind_flags, Function callback, void *client_data);
  63. int bind_entry_del(bind_table_t *table, int id, const char *mask, const char *function_name, Function callback);
  64. int bind_entry_modify(bind_table_t *table, int id, const char *mask, const char *function_name, const char *newflags, const char *newmask);
  65. int bind_entry_overwrite(bind_table_t *table, int id, const char *mask, const char *function_name, Function callback, void *client_data);
  66. void add_builtins(const char *table_name, cmd_t *cmds);
  67. void rem_builtins(const char *table_name, cmd_t *cmds);
  68. #endif /* _EGG_TCLHASH_H */