00001
00142 #ifndef __NME__
00143 #define __NME__
00144
00145 #ifdef __cplusplus
00146 extern "C" {
00147 #endif
00148
00150 typedef char NMEChar;
00151
00153 typedef NMEChar *NMEText;
00154
00156 typedef NMEChar const *NMEConstText;
00157
00159 typedef int NMEInt;
00160
00162 typedef int NMEBoolean;
00163
00164 #if !defined(NULL)
00166 # define NULL 0
00167 #endif
00168
00169 #if !defined(FALSE)
00170 # define FALSE 0
00171 # define TRUE 1
00172 #endif
00173
00175 typedef enum
00176 {
00177 kNMEErrOk = 0,
00178 kNMEErrNotEnoughMemory,
00179 kNMEErrBadMarkup,
00180 kNMEErrInternal,
00181
00182 kNMEErr1stNMEOpt,
00183
00184 kNMEErr1stUser = 10000
00185 } NMEErr;
00186
00188 enum
00189 {
00190 kNMEProcessOptDefault = 0,
00191 kNMEProcessOptNoPreAndPost = 0x1,
00192 kNMEProcessOptNoH1 = 0x4,
00193 kNMEProcessOptH1Num = 0x8,
00194 kNMEProcessOptH2Num = 0x10,
00195 kNMEProcessOptNoDL = 0x20,
00196 kNMEProcessOptNoIndentedPar = 0x40,
00197 kNMEProcessOptNoMultilinePar = 0x80,
00198 kNMEProcessOptNoEscape = 0x100,
00199 kNMEProcessOptNoHRule = 0x200,
00200 kNMEProcessOptNoLink = 0x400,
00201 kNMEProcessOptNoImage = 0x800,
00202 kNMEProcessOptNoTable = 0x1000,
00203 kNMEProcessOptNoUnderline = 0x2000,
00204 kNMEProcessOptNoMonospace = 0x4000,
00205 kNMEProcessOptNoSubSuperscript = 0x8000,
00206 kNMEProcessOptNoBold = 0x10000,
00207 kNMEProcessOptNoItalic = 0x20000,
00208 kNMEProcessOptNoPlugin = 0x40000,
00209 kNMEProcessOptVerbatimMono = 0x100000,
00210 kNMEProcessOptXRef = 0x200000
00211 };
00212
00215 typedef struct NMEContextStruct NMEContext;
00216
00227 typedef NMEErr (*NMEEncodeCharFun)(NMEConstText src, NMEInt srcLen, NMEInt *srcIx,
00228 NMEContext *context,
00229 void *data);
00230
00232 typedef enum
00233 {
00234 kNMEWordwrapNo = 0,
00235 kNMEWordwrapReplaceChar,
00236 kNMEWordwrapInsert
00237 } NMEWordwrapPermission;
00238
00247 typedef NMEWordwrapPermission (*NMEWordwrapCheckFun)(NMEConstText txt,
00248 NMEInt len, NMEInt i,
00249 void *data);
00250
00260 typedef NMEErr (*NMEEncodeURLFun)(NMEConstText link, NMEInt linkLen,
00261 NMEContext *context, void *data);
00262
00264 enum
00265 {
00266 kNMEHookLevelPar = 0,
00267 kNMEHookLevelSpan = -1
00268 };
00269
00278 typedef NMEErr (*NMECharHookFun)(NMEInt srcIndex,
00279 NMEContext *context,
00280 void *data);
00281
00295 typedef NMEErr (*NMEProcessHookFun)(NMEInt level,
00296 NMEInt item,
00297 NMEBoolean enter,
00298 NMEConstText markup,
00299 NMEInt srcIndex,
00300 NMEContext *context,
00301 void *data);
00302
00316 typedef NMEErr (*NMEPluginFun)(NMEConstText name, NMEInt nameLen,
00317 NMEConstText data, NMEInt dataLen,
00318 NMEContext *context,
00319 void *userData);
00320
00322 enum
00323 {
00324 kNMEPluginOptDefault = 0,
00325 kNMEPluginOptPartialName = 0x1,
00328 kNMEPluginOptReparseOutput = 0x2,
00329 kNMEPluginOptBetweenPar = 0x4,
00330 kNMEPluginOptTripleAngleBrackets = 0x8
00332 };
00333
00335 typedef struct
00336 {
00337 NMEConstText name;
00338 NMEInt options;
00339 NMEPluginFun cb;
00340 void *userData;
00341 } NMEPlugin;
00342
00344 #define NMEPluginTableEnd {NULL, kNMEPluginOptDefault, NULL, NULL}
00345
00357 typedef NMEBoolean (*NMEAutoconvertFun)(NMEConstText src, NMEInt srcLen,
00358 NMEInt *i,
00359 NMEContext *context,
00360 void *userData);
00361
00363 typedef struct
00364 {
00365 NMEAutoconvertFun cb;
00366 void *userData;
00367 } NMEAutoconvert;
00368
00375 typedef NMEInt (*NMEGetVarFun)(NMEChar name, void *userData);
00376
00378 #define NMEAutoconvertTableEnd {NULL, NULL}
00379
00381 typedef struct
00382 {
00383 NMEConstText alias;
00384 NMEConstText urlPrefix;
00385 } NMEInterwiki;
00386
00388 #define NMEInterwikiTableEnd {NULL, NULL}
00389
00437 typedef struct
00438 {
00439 NMEConstText space;
00440 NMEInt indentSpaces;
00442 NMEInt defFontSize;
00444 NMEChar ctrlChar;
00445 NMEConstText beginDoc;
00446 NMEConstText endDoc;
00447 NMEInt maxHeadingLevel;
00448 NMEConstText beginHeading;
00449 NMEConstText endHeading;
00450 NMEConstText beginPar;
00451 NMEConstText endPar;
00452 NMEConstText lineBreak;
00453 NMEConstText beginPre;
00454 NMEConstText endPre;
00455 NMEConstText beginPreLine;
00456 NMEConstText endPreLine;
00457 NMEConstText beginUL;
00458 NMEConstText endUL;
00459 NMEConstText beginULItem;
00460 NMEConstText endULItem;
00461 NMEConstText beginOL;
00462 NMEConstText endOL;
00463 NMEConstText beginOLItem;
00464 NMEConstText endOLItem;
00465 NMEConstText beginDL;
00466 NMEConstText endDL;
00467 NMEConstText beginDT;
00468 NMEConstText endDT;
00469 NMEConstText emptyDT;
00470 NMEConstText beginDD;
00471 NMEConstText endDD;
00472 NMEConstText beginIndented;
00473 NMEConstText endIndented;
00474 NMEConstText beginIndentedPar;
00475 NMEConstText endIndentedPar;
00476 NMEConstText beginTable;
00477 NMEConstText endTable;
00478 NMEConstText beginTableRow;
00479 NMEConstText endTableRow;
00480 NMEConstText beginTableHCell;
00481 NMEConstText endTableHCell;
00482 NMEConstText beginTableCell;
00483 NMEConstText endTableCell;
00484 NMEConstText horRule;
00485 NMEConstText beginBold;
00486 NMEConstText endBold;
00487 NMEConstText beginItalic;
00488 NMEConstText endItalic;
00489 NMEConstText beginUnderline;
00490 NMEConstText endUnderline;
00491 NMEConstText beginSuperscript;
00492 NMEConstText endSuperscript;
00493 NMEConstText beginSubscript;
00494 NMEConstText endSubscript;
00495 NMEConstText beginCode;
00496 NMEConstText endCode;
00497 NMEConstText beginLink;
00498 NMEConstText endLink;
00499 NMEConstText sepLink;
00500 NMEBoolean linkAfterSep;
00501 NMEConstText beginImage;
00502 NMEConstText endImage;
00503 NMEConstText sepImage;
00504 NMEBoolean imageAfterSep;
00505 NMEBoolean noStyleInAlt;
00506 NMEInterwiki const *interwikis;
00507 NMEEncodeURLFun encodeURLFun;
00508 void *encodeURLData;
00509 NMEEncodeCharFun encodeCharFun;
00510 void *encodeCharData;
00511 NMEEncodeCharFun encodeCharPreFun;
00512 void *encodeCharPreData;
00513 NMEInt textWidth;
00514 NMEWordwrapCheckFun wordwrapPermFun;
00515 void *wordwrapPermData;
00516 NMECharHookFun charHookFun;
00517 void *charHookData;
00518 NMEProcessHookFun divHookFun;
00520 NMEProcessHookFun parHookFun;
00522 NMEProcessHookFun spanHookFun;
00523 void *hookData;
00524 NMEPlugin const *plugins;
00525 NMEAutoconvert const *autoconverts;
00526 NMEGetVarFun getVarFun;
00527 void *getVarData;
00528 } NMEOutputFormat;
00529
00533 typedef struct
00534 {
00535 NMEChar ch;
00536 NMEConstText str;
00537 } NMEEncodeCharDict;
00538
00552 NMEErr NMEEncodeCharFunDict(NMEConstText src, NMEInt srcLen, NMEInt *srcIx,
00553 NMEContext *context, void *data);
00554
00556 extern NMEOutputFormat const NMEOutputFormatText;
00557
00559 extern NMEOutputFormat const NMEOutputFormatTextCompact;
00560
00562 extern NMEOutputFormat const NMEOutputFormatNull;
00563
00565 extern NMEOutputFormat const NMEOutputFormatNME;
00566
00568 extern NMEOutputFormat const NMEOutputFormatHTML;
00569
00571 extern NMEOutputFormat const NMEOutputFormatRTF;
00572
00574 extern NMEOutputFormat const NMEOutputFormatLaTeX;
00575
00580 extern NMEOutputFormat const NMEOutputFormatMan;
00581
00602 NMEErr NMEProcess(NMEConstText nmeText, NMEInt nmeTextLen,
00603 NMEText buf, NMEInt bufSize,
00604 NMEInt options,
00605 NMEConstText eol,
00606 NMEOutputFormat const *outputFormat,
00607 NMEInt fontSize,
00608 NMEText *output,
00609 NMEInt *outputLen,
00610 NMEInt *outputUCS16Len);
00611
00619 NMEBoolean NMEAddString(NMEConstText str,
00620 NMEInt strLen,
00621 NMEChar ctrlChar,
00622 NMEContext *context);
00623
00631 NMEErr NMECopySource(NMEInt length,
00632 NMEBoolean copy,
00633 NMEBoolean encodeChar,
00634 NMEContext *context);
00635
00642 void NMEGetTempMemory(NMEContext const *context,
00643 NMEText *addr,
00644 NMEInt *len);
00645
00652 void NMEGetFormat(NMEContext const *context,
00653 NMEOutputFormat const **outputFormat,
00654 NMEInt *options,
00655 NMEInt *fontSize);
00656
00661 NMEInt NMECurrentOutputIndex(NMEContext const *context);
00662
00667 NMEInt NMECurrentOutputIndexUCS16(NMEContext const *context);
00668
00675 void NMECurrentLink(NMEContext const *context,
00676 NMEInt *linkOffset, NMEInt *linkLength);
00677
00684 void NMECurrentOutput(NMEContext const *context,
00685 NMEConstText *output, NMEInt *outputLength);
00686
00691 NMEConstText NMECurrentListNesting(NMEContext const *context);
00692
00693 #ifdef __cplusplus
00694 }
00695 #endif
00696
00697 #endif