wiki.h 1.9 KB

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