unfp.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. /* This file is part of unfy.
  2. *
  3. * Unfy 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. * Unfy 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 unfy. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. #ifndef UNFP_H
  17. #define UNFP_H
  18. /*
  19. Include:
  20. something with size_t
  21. #include <rid.h>
  22. #include <unfy/unfy.h>
  23. #include <unfy/unfp.h>
  24. */
  25. #ifndef STYLE_9
  26. #include <rid.h>
  27. #include <unfy/unfy.h>
  28. #endif
  29. typedef enum {
  30. UNFP_TNIL = 0,
  31. UNFP_CONST,
  32. UNFP_ORDER,
  33. UNFP_IGN,
  34. UNFP_VAR,
  35. UNFP_LOPEN,
  36. UNFP_LCLOSE,
  37. UNFP_LNIL,
  38. UNFP_BOPEN,
  39. UNFP_BCLOSE,
  40. UNFP_BNIL,
  41. } Unfp_type;
  42. /* term */
  43. void
  44. unfp_term_print(const Unfy_term *term);
  45. Unfy_term *
  46. unfp_term_parse(const char *str, size_t *pos,
  47. const char **error, Unfy_recycle *rec);
  48. int
  49. unfp_term_ser(const Unfy_term *term, unsigned char **buf,
  50. size_t *size, size_t *pos);
  51. size_t
  52. unfp_term_write(const Unfy_term *term, unsigned char *buf);
  53. size_t
  54. unfp_term_len(const Unfy_term *term);
  55. int
  56. unfp_term_deser(Unfy_term **term, const unsigned char *buf,
  57. size_t *pos, Unfy_recycle *rec);
  58. const char *
  59. unfp_term_deserable(const unsigned char *buf, size_t *pos, const size_t max);
  60. /* list */
  61. void
  62. unfp_list_print(const Unfy_list *list);
  63. int
  64. unfp_list_parse(Unfy_list **list, const char *str, size_t *pos,
  65. const char **error, Unfy_recycle *rec);
  66. size_t
  67. unfp_list_len(const Unfy_list *list);
  68. size_t
  69. unfp_list_write(const Unfy_list *list, unsigned char *buf);
  70. int
  71. unfp_list_ser(const Unfy_list *list, unsigned char **buf,
  72. size_t *size, size_t *pos);
  73. int
  74. unfp_list_deser(Unfy_list **list, const unsigned char *buf,
  75. size_t *pos, Unfy_recycle *rec);
  76. const char *
  77. unfp_list_deserable(const unsigned char *buf, size_t *pos, const size_t max);
  78. /* bind */
  79. void
  80. unfp_bind_print(const Unfy_bind *bind);
  81. void
  82. unfp_binds_print(const Unfy_bind *binds, int level);
  83. size_t
  84. unfp_bind_len(const Unfy_bind *bind);
  85. size_t
  86. unfp_bind_write(const Unfy_bind *bind, unsigned char *buf);
  87. int
  88. unfp_bind_ser(const Unfy_bind *bind, unsigned char **buf,
  89. size_t *size, size_t *pos);
  90. int
  91. unfp_bind_deser(Unfy_bind **bind, const unsigned char *buf,
  92. size_t *pos, Unfy_recycle *rec);
  93. const char *
  94. unfp_bind_deserable(const unsigned char *buf, size_t *pos, const size_t max);
  95. /* util */
  96. int
  97. unfp_space(const char *str, size_t *pos, const char **error);
  98. #endif