tclhash.h 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /*
  2. * tclhash.h
  3. *
  4. */
  5. #ifndef _EGG_TCLHASH_H
  6. #define _EGG_TCLHASH_H
  7. #include "cmds.h"
  8. typedef int (*HashFunc) (void *, void *, void *, void *, void *, void *, void *, void *, void *, void *);
  9. /* Match type flags for bind tables. */
  10. #define MATCH_PARTIAL BIT0
  11. #define MATCH_EXACT BIT1
  12. #define MATCH_MASK BIT2
  13. #define MATCH_CASE BIT3
  14. #define MATCH_NONE BIT4
  15. #define MATCH_FLAGS_AND BIT5
  16. #define MATCH_FLAGS_OR BIT6
  17. #define MATCH_FLAGS BIT7
  18. /* Flags for binds. */
  19. /* Does the callback want their client_data inserted as the first argument? */
  20. #define BIND_WANTS_CD BIT0
  21. #define BIND_BREAKABLE BIT1
  22. #define BIND_STACKABLE BIT2
  23. #define BIND_DELETED BIT3
  24. #define BIND_FAKE BIT4
  25. /*** Note: bind entries can specify these two flags, defined above.
  26. #define MATCH_FLAGS_AND BIT5
  27. #define MATCH_FLAGS_OR BIT6
  28. ***/
  29. /* Flags for return values from bind callbacks */
  30. #define BIND_RET_LOG 1
  31. #define BIND_RET_BREAK 2
  32. /* This holds the information of a bind entry. */
  33. typedef struct bind_entry_b {
  34. struct bind_entry_b *next, *prev;
  35. struct flag_record user_flags;
  36. char *mask;
  37. char *function_name;
  38. HashFunc callback;
  39. void *client_data;
  40. int nhits;
  41. int flags;
  42. int id;
  43. } bind_entry_t;
  44. /* This is the highest-level structure. It's like the "msg" table
  45. or the "pubm" table. */
  46. typedef struct bind_table_b {
  47. struct bind_table_b *next;
  48. bind_entry_t *entries;
  49. char *name;
  50. char *syntax;
  51. int nargs;
  52. int match_type;
  53. int flags;
  54. } bind_table_t;
  55. void kill_binds(void);
  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 */