utilize.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. #ifndef ILK_BACK_H
  2. #define ILK_BACK_H
  3. /*
  4. Include:
  5. #include <dirent.h>
  6. #include <rid.h>
  7. #include <stdint.h>
  8. #include <unfy/unfy.h>
  9. #include <rls/rls.h>
  10. #include <rls/rlsp.h>
  11. #include <nit/list.h>
  12. #include <nit/set.h>
  13. #include <nit/map.h>
  14. #include <nit/err.h>
  15. #include <nit/file.h>
  16. #include <nit/buf.h>
  17. #include <nit/gap.h>
  18. #include <ilk/utilize.h>
  19. */
  20. #ifndef STYLE_9
  21. #include <rls/rlsp.h>
  22. #include <nit/map.h>
  23. #include <nit/file.h>
  24. #include <nit/gap.h>
  25. #endif
  26. typedef struct {
  27. uint16_t max_num;
  28. Rls_act *table;
  29. } Ilk_act_dat;
  30. typedef struct {
  31. uint64_t srch_cnt;
  32. uint16_t act; /* for actable functions */
  33. } Ilk_more;
  34. typedef struct {
  35. Rid id;
  36. Rid grp_id;
  37. uint64_t srch_cnt;
  38. Nit_gap deps;
  39. unsigned changed : 1;
  40. } Ilk_meta;
  41. typedef struct {
  42. Rid id;
  43. Rls_rule *rules;
  44. unsigned changed : 1;
  45. unsigned accessed : 1;
  46. } Ilk_grp;
  47. typedef struct Ilk_sys Ilk_sys;
  48. typedef struct {
  49. Ilk_act_dat act_dat;
  50. Rls_bend bend;
  51. Rlsp_srlz srlz;
  52. Ilk_grp *old_grps;
  53. Ilk_more *old_mores;
  54. Ilk_sys *old_syss;
  55. Rls_recycle rec;
  56. Nit_entry *stack;
  57. Nit_buf buf;
  58. Nit_err err;
  59. unsigned testing : 1;
  60. } Ilk_lib;
  61. struct Ilk_sys {
  62. Ilk_lib *lib;
  63. Nit_map grps;
  64. Nit_map srchs;
  65. Nit_dir dir;
  66. uint64_t srch_cnt;
  67. };
  68. extern const Rid ilk_add_id;
  69. extern const Rid ilk_id_id;
  70. extern const Rid ilk_head_id;
  71. /* grp */
  72. Ilk_grp *
  73. ilk_grp_load(Ilk_sys *sys, const Rid id, Unfy_stat *stat);
  74. int
  75. ilk_grp_unload(Ilk_grp *grp, Ilk_sys *sys);
  76. void
  77. ilk_grp_discard(Ilk_grp *grp, Ilk_sys *sys);
  78. Ilk_grp *
  79. ilk_grp_get(Ilk_sys *sys, const Rid id, Unfy_stat *stat);
  80. Ilk_grp *
  81. ilk_grp_get_term(Ilk_sys *sys, const Unfy_term *term, Unfy_stat *stat);
  82. int
  83. ilk_grp_save(Ilk_grp *grp, Ilk_sys *sys);
  84. /* rule */
  85. int
  86. ilk_rule_origin(Rls_rule *rule, Rls_srch **srch_ref,
  87. uint64_t srch_cnt, Ilk_sys *sys);
  88. /* meta */
  89. int
  90. ilk_meta_init(Ilk_meta *meta, uint64_t srch_cnt, uint64_t deps_len);
  91. void
  92. ilk_meta_dispose(Ilk_meta *meta);
  93. void
  94. ilk_meta_get(Ilk_meta *meta, Rls_srch **srch_ref, Ilk_sys *sys);
  95. int
  96. ilk_meta_save(Ilk_sys *sys, Ilk_meta *meta);
  97. int
  98. ilk_meta_load(Ilk_meta *meta, const Rid id, Ilk_sys *sys);
  99. int
  100. ilk_meta_dep(Ilk_meta *meta, uint64_t srch_cnt);
  101. /* srch */
  102. Unfy_stat
  103. ilk_srch(Ilk_sys *sys, Rls_srch **srch_ref, Unfy_term *term,
  104. int *limit, Rls_info *info);
  105. int
  106. ilk_srch_get(Rls_srch **srch_ref, uint64_t srch_cnt, Ilk_sys *sys);
  107. int
  108. ilk_srch_save(Ilk_sys *sys, Rls_srch *srch, uint64_t srch_cnt);
  109. int
  110. ilk_srch_load(Rls_srch **srch, uint64_t srch_cnt, Ilk_sys *sys);
  111. int
  112. ilk_srch_unload(uint64_t srch_cnt, Ilk_sys *sys);
  113. #endif