wiki.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. /*
  2. * This file is part of the UCB release of Plan 9. It is subject to the license
  3. * terms in the LICENSE file found in the top-level directory of this
  4. * distribution and at http://akaros.cs.berkeley.edu/files/Plan9License. No
  5. * part of the UCB release of Plan 9, including this file, may be copied,
  6. * modified, propagated, or distributed except according to the terms contained
  7. * in the LICENSE file.
  8. */
  9. typedef struct Map Map;
  10. typedef struct Mapel Mapel;
  11. typedef struct Sub Sub;
  12. typedef struct Wdoc Wdoc;
  13. typedef struct Whist Whist;
  14. typedef struct Wpage Wpage;
  15. enum {
  16. Tcache = 5, /* seconds */
  17. Maxmap = 10*1024*1024,
  18. Maxfile = 100*1024,
  19. };
  20. enum {
  21. Wpara,
  22. Wheading,
  23. Wbullet,
  24. Wlink,
  25. Wman,
  26. Wplain,
  27. Wpre,
  28. Whr,
  29. Nwtxt,
  30. };
  31. struct Wpage {
  32. int type;
  33. char *text;
  34. int section; /* Wman */
  35. char *url; /* Wlink */
  36. Wpage *next;
  37. };
  38. struct Whist {
  39. Ref;
  40. int n;
  41. char *title;
  42. Wdoc *doc;
  43. int ndoc;
  44. int current;
  45. };
  46. struct Wdoc {
  47. char *author;
  48. char *comment;
  49. int conflict;
  50. uint32_t time;
  51. Wpage *wtxt;
  52. };
  53. enum {
  54. Tpage,
  55. Tedit,
  56. Tdiff,
  57. Thistory,
  58. Tnew,
  59. Toldpage,
  60. Twerror,
  61. Ntemplate,
  62. };
  63. struct Sub {
  64. char *match;
  65. char *sub;
  66. };
  67. struct Mapel {
  68. char *s;
  69. int n;
  70. };
  71. struct Map {
  72. Ref;
  73. Mapel *el;
  74. int nel;
  75. ulong t;
  76. char *buf;
  77. Qid qid;
  78. };
  79. void *erealloc(void*, uint32_t);
  80. void *emalloc(uint32_t);
  81. char *estrdup(char*);
  82. char *estrdupn(char*, int);
  83. char *strcondense(char*, int);
  84. char *strlower(char*);
  85. String *s_appendsub(String*, char*, int, Sub*, int);
  86. String *s_appendlist(String*, ...);
  87. Whist *Brdwhist(Biobuf*);
  88. Wpage *Brdpage(char*(*)(void*,int), void*);
  89. void printpage(Wpage*);
  90. String *pagehtml(String*, Wpage*, int);
  91. String *pagetext(String*, Wpage*, int);
  92. String *tohtml(Whist*, Wdoc*, int);
  93. String *totext(Whist*, Wdoc*, int);
  94. String *doctext(String*, Wdoc*);
  95. Whist *getcurrent(int);
  96. Whist *getcurrentbyname(char*);
  97. Whist *gethistory(int);
  98. void closewhist(Whist*);
  99. int allocnum(char*, int);
  100. void freepage(Wpage*);
  101. int nametonum(char*);
  102. char *numtoname(int);
  103. int writepage(int, uint32_t, String*, char*);
  104. void voidcache(int);
  105. void closemap(Map*);
  106. void currentmap(int);
  107. extern Map *map;
  108. extern RWLock maplock;
  109. extern char *wikidir;
  110. Biobuf *wBopen(char*, int);
  111. int wopen(char*, int);
  112. int wcreate(char*, int, long);
  113. int waccess(char*, int);
  114. Dir *wdirstat(char*);
  115. int opentemp(char*);