rlsr.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. /* This file is part of rls.
  2. *
  3. * Rls is free software: you can redistribute it and/or modify
  4. * it under the terms of the GNU Lesser General Public License as published by
  5. * the Free Software Foundation, either version 3 of the License, or
  6. * (at your option) any later version.
  7. *
  8. * Rls is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU Lesser General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU Lesser General Public License
  14. * along with rls. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. #ifndef RLSR_H
  17. #define RLSR_H
  18. /*
  19. Include:
  20. something with size_t
  21. #include <rid.h>
  22. #include <stdint.h>
  23. #include <unfy/unfy.h>
  24. #include <rls/rls.h>
  25. #include <rls/rlsr.h>
  26. */
  27. #ifndef STYLE_9
  28. #include <rls/rls.h>
  29. #endif
  30. typedef enum { RLSR_ASSERT, RLSR_SEARCH, RLSR_VIEW, RLSR_ERROR } Rlsr_cmd;
  31. typedef struct {
  32. /* used by both assert and search */
  33. Rlsr_cmd cmd;
  34. Unfy_term *term;
  35. size_t term_pos;
  36. /* used by assert */
  37. Rid id;
  38. size_t id_pos;
  39. Unfy_list *list;
  40. size_t list_pos;
  41. /* used by search */
  42. int limit;
  43. size_t limit_pos;
  44. } Rlsr_stmnt;
  45. typedef struct Rlsr_lsnr Rlsr_lsnr;
  46. typedef Unfy_stat (*Rlsr_lsn)(Rlsr_lsnr *lsnr, Rls_rule **rules,
  47. Rls_srch **srch, char **str, size_t *size,
  48. Rls_info *info, void *extra, Rls_recycle *rec);
  49. typedef int (*Rlsr_assert)(Rlsr_lsnr *lsnr, Rlsr_stmnt *stmnt,
  50. Rls_rule **rules, void *extra, Rls_recycle *rec);
  51. typedef Unfy_stat (*Rlsr_search)(Rlsr_lsnr *lsnr, Rlsr_stmnt *stmnt,
  52. Rls_srch **srch_ref, Rls_rule **rules,
  53. Rls_info *info, void *extra,
  54. Rls_recycle *rec);
  55. typedef void (*Rlsr_error)(Rlsr_lsnr *lsnr, void *extra);
  56. struct Rlsr_lsnr {
  57. Rlsr_lsn lsn;
  58. Rlsr_assert assert;
  59. Rlsr_search search;
  60. Rlsr_error error;
  61. Rls_bend bend;
  62. const char *error_str;
  63. size_t pos;
  64. };
  65. Rlsr_cmd
  66. rlsr_cmd_parse(const char *str, size_t *pos, const char **error);
  67. int
  68. rlsr_stmnt_parse(Rlsr_stmnt *stmnt, const char *str, size_t *pos,
  69. const char **error, Rls_recycle *rec);
  70. Unfy_stat
  71. rlsr_searching(Rlsr_lsnr *lsnr, Rlsr_stmnt *stmnt, Rls_rule **rules,
  72. Rls_srch **srch, char **str, size_t *n, Rls_info *info,
  73. void *extra, Rls_recycle *rec);
  74. Unfy_stat
  75. rlsr_asserting(Rlsr_lsnr *lsnr, Rlsr_stmnt *stmnt, Rls_rule **rules,
  76. void *extra, Rls_recycle *rec);
  77. void
  78. rlsr_lsnr_init(Rlsr_lsnr *lsnr, Rlsr_lsn lsn, Rlsr_assert assert,
  79. Rlsr_search search, Rlsr_error error, Rls_bend bend,
  80. const char *error_str, size_t pos);
  81. void
  82. rlsr_repl(Rls_rule **rules, Rlsr_lsnr *lsnr, void *extra, Rls_recycle *rec);
  83. Unfy_stat
  84. rlsr_default_lsn(Rlsr_lsnr *lsnr, Rls_rule **rules, Rls_srch **srch,
  85. char **str, size_t *size, Rls_info *info, void *extra,
  86. Rls_recycle *rec);
  87. int
  88. rlsr_default_assert(Rlsr_lsnr *lsnr, Rlsr_stmnt *stmnt,
  89. Rls_rule **rules, void *extra, Rls_recycle *rec);
  90. Unfy_stat
  91. rlsr_default_search(Rlsr_lsnr *lsnr, Rlsr_stmnt *stmnt, Rls_srch **srch_ref,
  92. Rls_rule **rules, Rls_info *info, void *extra,
  93. Rls_recycle *rec);
  94. void
  95. rlsr_default_error(Rlsr_lsnr *lsnr, void *extra);
  96. #endif