wiki.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. typedef struct Map Map;
  2. typedef struct Mapel Mapel;
  3. typedef struct Sub Sub;
  4. typedef struct Wdoc Wdoc;
  5. typedef struct Whist Whist;
  6. typedef struct Wpage Wpage;
  7. enum {
  8. Tcache = 5, /* seconds */
  9. Maxmap = 10*1024*1024,
  10. Maxfile = 100*1024,
  11. };
  12. enum {
  13. Wpara,
  14. Wheading,
  15. Wbullet,
  16. Wlink,
  17. Wman,
  18. Wplain,
  19. Wpre,
  20. Nwtxt,
  21. };
  22. struct Wpage {
  23. int type;
  24. char *text;
  25. int section; /* Wman */
  26. char *url; /* Wlink */
  27. Wpage *next;
  28. };
  29. struct Whist {
  30. Ref;
  31. int n;
  32. char *title;
  33. Wdoc *doc;
  34. int ndoc;
  35. int current;
  36. };
  37. struct Wdoc {
  38. char *author;
  39. char *comment;
  40. int conflict;
  41. ulong time;
  42. Wpage *wtxt;
  43. };
  44. enum {
  45. Tpage,
  46. Tedit,
  47. Tdiff,
  48. Thistory,
  49. Tnew,
  50. Toldpage,
  51. Twerror,
  52. Ntemplate,
  53. };
  54. struct Sub {
  55. char *match;
  56. char *sub;
  57. };
  58. struct Mapel {
  59. char *s;
  60. int n;
  61. };
  62. struct Map {
  63. Ref;
  64. Mapel *el;
  65. int nel;
  66. ulong t;
  67. char *buf;
  68. Qid qid;
  69. };
  70. void *erealloc(void*, ulong);
  71. void *emalloc(ulong);
  72. char *estrdup(char*);
  73. char *estrdupn(char*, int);
  74. char *strcondense(char*, int);
  75. char *strlower(char*);
  76. String *s_appendsub(String*, char*, int, Sub*, int);
  77. String *s_appendlist(String*, ...);
  78. Whist *Brdwhist(Biobuf*);
  79. Wpage *Brdpage(char*(*)(void*,int), void*);
  80. void printpage(Wpage*);
  81. String *pagehtml(String*, Wpage*, int);
  82. String *pagetext(String*, Wpage*, int);
  83. String *tohtml(Whist*, Wdoc*, int);
  84. String *totext(Whist*, Wdoc*, int);
  85. String *doctext(String*, Wdoc*);
  86. Whist *getcurrent(int);
  87. Whist *getcurrentbyname(char*);
  88. Whist *gethistory(int);
  89. void closewhist(Whist*);
  90. int allocnum(char*, int);
  91. void freepage(Wpage*);
  92. int nametonum(char*);
  93. char *numtoname(int);
  94. int writepage(int, ulong, String*, char*);
  95. void voidcache(int);
  96. void closemap(Map*);
  97. void currentmap(int);
  98. extern Map *map;
  99. extern RWLock maplock;
  100. extern char *wikidir;
  101. Biobuf *wBopen(char*, int);
  102. int wopen(char*, int);
  103. int wcreate(char*, int, long);
  104. int waccess(char*, int);
  105. Dir *wdirstat(char*);
  106. int opentemp(char*);