rlsp.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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 RLSP_H
  17. #define RLSP_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/rlsp.h>
  26. */
  27. #ifndef STYLE_9
  28. #include <rls/rls.h>
  29. #endif
  30. typedef enum {
  31. RLSP_RULE,
  32. RLSP_ROPEN,
  33. RLSP_RCLOSE,
  34. RLSP_RNIL,
  35. RLSP_SNIL,
  36. RLSP_SOPEN
  37. } Rlsp_type;
  38. typedef void (*Rlsp_dat_print)(void *extra);
  39. typedef struct Rlsp_srlz Rlsp_srlz;
  40. typedef size_t (*Rlsp_len)(const Rls_rule *rule, void *extra);
  41. typedef size_t (*Rlsp_write)(const Rls_rule *rule, unsigned char *buf,
  42. void *extra);
  43. typedef int (*Rlsp_deser)(Rls_rule *rule, const unsigned char *buf,
  44. size_t *pos, void *extra);
  45. typedef const char *
  46. (*Rlsp_deserable)(const unsigned char *buf, size_t *pos,
  47. size_t max, void *extra);
  48. struct Rlsp_srlz {
  49. Rls_dat_free dat_free;
  50. Rlsp_len len;
  51. Rlsp_write write;
  52. Rlsp_deser deser;
  53. Rlsp_deserable deserable;
  54. };
  55. /* rule */
  56. void
  57. rlsp_rule_print(const Rls_rule *rule, Rlsp_dat_print dat_print);
  58. size_t
  59. rlsp_rule_len(const Rls_rule *rule, Rlsp_srlz *srlz, void *extra);
  60. size_t
  61. rlsp_rule_write(const Rls_rule *rules, unsigned char *buf,
  62. Rlsp_srlz *srlz, void *extra);
  63. int
  64. rlsp_rule_ser(const Rls_rule *rules, unsigned char **buf, size_t *size,
  65. size_t *pos, Rlsp_srlz *srlz, void *extra);
  66. int
  67. rlsp_rule_deser(Rls_rule **rules, const unsigned char *buf, size_t *pos,
  68. Rlsp_srlz *srlz, void *extra, Rls_recycle *rec);
  69. const char *
  70. rlsp_rule_deserable(const unsigned char *buf, size_t *pos,
  71. const size_t max, Rlsp_srlz *srlz, void *extra);
  72. /* srch */
  73. void
  74. rlsp_srch_print(const Rls_srch *srch, int level);
  75. size_t
  76. rlsp_srch_len(const Rls_srch *srch);
  77. size_t
  78. rlsp_srch_write(const Rls_srch *srch, unsigned char *buf);
  79. int
  80. rlsp_srch_ser(const Rls_srch *srch, unsigned char **buf,
  81. size_t *size, size_t *pos);
  82. const char *
  83. rlsp_srch_deser(Rls_srch **srch, const unsigned char *buf, size_t *pos,
  84. Rls_rule *rules, Rls_bend bend, void *extra, Rls_recycle *rec);
  85. const char *
  86. rlsp_srch_deserable(const unsigned char *buf, size_t *pos, const size_t max);
  87. #endif