00001
00163 #ifndef __NME__
00164 #define __NME__
00165
00166 #ifdef __cplusplus
00167 extern "C" {
00168 #endif
00169
00171 typedef char NMEChar;
00172
00174 typedef NMEChar *NMEText;
00175
00177 typedef NMEChar const *NMEConstText;
00178
00180 typedef int NMEInt;
00181
00183 typedef int NMEBoolean;
00184
00185 #if !defined(NULL)
00186
00187 # define NULL 0
00188 #endif
00189
00190 #if !defined(FALSE)
00191 # define FALSE 0 ///< false boolean value
00192 # define TRUE 1 ///< true boolean value
00193 #endif
00194
00196 typedef enum
00197 {
00198 kNMEErrOk = 0,
00199 kNMEErrNotEnoughMemory,
00200 kNMEErrBadMarkup,
00201 kNMEErrInternal,
00202
00203 kNMEErr1stNMEOpt,
00204
00205 kNMEErr1stUser = 10000
00206 } NMEErr;
00207
00209 enum
00210 {
00211 kNMEProcessOptDefault = 0,
00212 kNMEProcessOptNoPreAndPost = 0x1,
00213 kNMEProcessOptNoH1 = 0x4,
00214 kNMEProcessOptH1Num = 0x8,
00215 kNMEProcessOptH2Num = 0x10,
00216 kNMEProcessOptNoDL = 0x20,
00217 kNMEProcessOptNoIndentedPar = 0x40,
00218 kNMEProcessOptNoMultilinePar = 0x80,
00219 kNMEProcessOptNoEscape = 0x100,
00220 kNMEProcessOptNoHRule = 0x200,
00221 kNMEProcessOptNoLink = 0x400,
00222 kNMEProcessOptNoImage = 0x800,
00223 kNMEProcessOptNoTable = 0x1000,
00224 kNMEProcessOptNoUnderline = 0x2000,
00225 kNMEProcessOptNoMonospace = 0x4000,
00226 kNMEProcessOptNoSubSuperscript = 0x8000,
00227 kNMEProcessOptNoBold = 0x10000,
00228 kNMEProcessOptNoItalic = 0x20000,
00229 kNMEProcessOptNoPlugin = 0x40000,
00230 kNMEProcessOptVerbatimMono = 0x100000,
00231 kNMEProcessOptXRef = 0x200000
00232 };
00233
00236 typedef struct NMEContextStruct NMEContext;
00237
00248 typedef NMEErr (*NMEEncodeCharFun)(NMEConstText src, NMEInt srcLen, NMEInt *srcIx,
00249 NMEContext *context,
00250 void *data);
00251
00253 typedef enum
00254 {
00255 kNMEWordwrapNo = 0,
00256 kNMEWordwrapReplaceChar,
00257 kNMEWordwrapInsert
00258 } NMEWordwrapPermission;
00259
00269 typedef NMEWordwrapPermission (*NMEWordwrapCheckFun)(NMEConstText txt,
00270 NMEInt len, NMEInt i,
00271 NMEContext *context,
00272 void *data);
00273
00283 typedef NMEErr (*NMEEncodeURLFun)(NMEConstText link, NMEInt linkLen,
00284 NMEContext *context, void *data);
00285
00287 enum
00288 {
00289 kNMEHookLevelPar = 0,
00290 kNMEHookLevelSpan = -1
00291 };
00292
00301 typedef NMEErr (*NMECharHookFun)(NMEInt srcIndex,
00302 NMEContext *context,
00303 void *data);
00304
00319 typedef NMEErr (*NMEProcessHookFun)(NMEInt level,
00320 NMEInt item,
00321 NMEBoolean enter,
00322 NMEConstText markup,
00323 NMEInt srcIndex,
00324 NMEInt srcLineNumber,
00325 NMEContext *context,
00326 void *data);
00327
00341 typedef NMEErr (*NMEPluginFun)(NMEConstText name, NMEInt nameLen,
00342 NMEConstText data, NMEInt dataLen,
00343 NMEContext *context,
00344 void *userData);
00345
00347 enum
00348 {
00349 kNMEPluginOptDefault = 0,
00350 kNMEPluginOptPartialName = 0x1,
00353 kNMEPluginOptReparseOutput = 0x2,
00354 kNMEPluginOptBetweenPar = 0x4,
00355 kNMEPluginOptTripleAngleBrackets = 0x8
00357 };
00358
00360 typedef struct
00361 {
00362 NMEConstText name;
00363 NMEInt options;
00364 NMEPluginFun cb;
00365 void *userData;
00366 } NMEPlugin;
00367
00369 #define NMEPluginTableEnd {NULL, kNMEPluginOptDefault, NULL, NULL}
00370
00382 typedef NMEBoolean (*NMEAutoconvertFun)(NMEConstText src, NMEInt srcLen,
00383 NMEInt *i,
00384 NMEContext *context,
00385 void *userData);
00386
00388 typedef struct
00389 {
00390 NMEAutoconvertFun cb;
00391 void *userData;
00392 } NMEAutoconvert;
00393
00400 typedef NMEInt (*NMEGetVarFun)(NMEChar name, void *userData);
00401
00403 #define NMEAutoconvertTableEnd {NULL, NULL}
00404
00406 typedef struct
00407 {
00408 NMEConstText alias;
00409 NMEConstText urlPrefix;
00410 } NMEInterwiki;
00411
00413 #define NMEInterwikiTableEnd {NULL, NULL}
00414
00464 typedef struct
00465 {
00466 NMEConstText space;
00467 NMEInt indentSpaces;
00469 NMEInt defFontSize;
00471 NMEChar ctrlChar;
00472 NMEConstText beginDoc;
00473 NMEConstText endDoc;
00474 NMEInt maxHeadingLevel;
00475 NMEConstText beginHeading;
00476 NMEConstText endHeading;
00477 NMEConstText beginPar;
00478 NMEConstText endPar;
00479 NMEConstText lineBreak;
00480 NMEConstText beginPre;
00481 NMEConstText endPre;
00482 NMEConstText beginPreLine;
00483 NMEConstText endPreLine;
00484 NMEBoolean sublistInListItem;
00486 NMEConstText beginUL;
00487 NMEConstText endUL;
00488 NMEConstText beginULItem;
00489 NMEConstText endULItem;
00490 NMEConstText beginOL;
00491 NMEConstText endOL;
00492 NMEConstText beginOLItem;
00493 NMEConstText endOLItem;
00494 NMEConstText beginDL;
00495 NMEConstText endDL;
00496 NMEConstText beginDT;
00497 NMEConstText endDT;
00498 NMEConstText emptyDT;
00499 NMEConstText beginDD;
00500 NMEConstText endDD;
00501 NMEConstText beginIndented;
00502 NMEConstText endIndented;
00503 NMEConstText beginIndentedPar;
00504 NMEConstText endIndentedPar;
00505 NMEConstText beginTable;
00506 NMEConstText endTable;
00507 NMEConstText beginTableRow;
00508 NMEConstText endTableRow;
00509 NMEConstText beginTableHCell;
00510 NMEConstText endTableHCell;
00511 NMEConstText beginTableCell;
00512 NMEConstText endTableCell;
00513 NMEConstText horRule;
00514 NMEConstText beginBold;
00515 NMEConstText endBold;
00516 NMEConstText beginItalic;
00517 NMEConstText endItalic;
00518 NMEConstText beginUnderline;
00519 NMEConstText endUnderline;
00520 NMEConstText beginSuperscript;
00521 NMEConstText endSuperscript;
00522 NMEConstText beginSubscript;
00523 NMEConstText endSubscript;
00524 NMEConstText beginCode;
00525 NMEConstText endCode;
00526 NMEConstText beginLink;
00527 NMEConstText endLink;
00528 NMEConstText sepLink;
00529 NMEBoolean linkAfterSep;
00530 NMEConstText beginImage;
00531 NMEConstText endImage;
00532 NMEConstText sepImage;
00533 NMEBoolean imageAfterSep;
00534 NMEBoolean noStyleInAlt;
00535 NMEInterwiki const *interwikis;
00536 NMEEncodeURLFun encodeURLFun;
00537 void *encodeURLData;
00538 NMEEncodeCharFun encodeCharFun;
00539 void *encodeCharData;
00540 NMEEncodeCharFun encodeCharPreFun;
00541 void *encodeCharPreData;
00542 NMEInt textWidth;
00543 NMEWordwrapCheckFun wordwrapPermFun;
00544 void *wordwrapPermData;
00545 NMECharHookFun charHookFun;
00546 void *charHookData;
00547 NMEProcessHookFun divHookFun;
00549 NMEProcessHookFun parHookFun;
00551 NMEProcessHookFun spanHookFun;
00552 void *hookData;
00553 NMEPlugin const *plugins;
00554 NMEAutoconvert const *autoconverts;
00555 NMEGetVarFun getVarFun;
00556 void *getVarData;
00557 } NMEOutputFormat;
00558
00562 typedef struct
00563 {
00564 NMEChar ch;
00565 NMEConstText str;
00566 } NMEEncodeCharDict;
00567
00568 extern NMEEncodeCharDict const NMEXMLCharDict[];
00569
00583 NMEErr NMEEncodeCharFunDict(NMEConstText src, NMEInt srcLen, NMEInt *srcIx,
00584 NMEContext *context, void *data);
00585
00587 extern NMEOutputFormat const NMEOutputFormatText;
00588
00590 extern NMEOutputFormat const NMEOutputFormatTextCompact;
00591
00593 extern NMEOutputFormat const NMEOutputFormatDebug;
00594
00596 extern NMEOutputFormat const NMEOutputFormatNull;
00597
00599 extern NMEOutputFormat const NMEOutputFormatNME;
00600
00602 extern NMEOutputFormat const NMEOutputFormatHTML;
00603
00605 extern NMEOutputFormat const NMEOutputFormatRTF;
00606
00608 extern NMEOutputFormat const NMEOutputFormatLaTeX;
00609
00614 extern NMEOutputFormat const NMEOutputFormatMan;
00615
00636 NMEErr NMEProcess(NMEConstText nmeText, NMEInt nmeTextLen,
00637 NMEText buf, NMEInt bufSize,
00638 NMEInt options,
00639 NMEConstText eol,
00640 NMEOutputFormat const *outputFormat,
00641 NMEInt fontSize,
00642 NMEText *output,
00643 NMEInt *outputLen,
00644 NMEInt *outputUCS16Len);
00645
00653 NMEBoolean NMEAddString(NMEConstText str,
00654 NMEInt strLen,
00655 NMEChar ctrlChar,
00656 NMEContext *context);
00657
00664 NMEErr NMEAddRawString(NMEConstText str,
00665 NMEInt strLen,
00666 NMEContext *context);
00667
00675 NMEErr NMECopySource(NMEInt length,
00676 NMEBoolean copy,
00677 NMEBoolean encodeChar,
00678 NMEContext *context);
00679
00683 void NMEResetOutput(NMEContext *context);
00684
00691 void NMEGetTempMemory(NMEContext const *context,
00692 NMEText *addr,
00693 NMEInt *len);
00694
00701 void NMEGetFormat(NMEContext const *context,
00702 NMEOutputFormat const **outputFormat,
00703 NMEInt *options,
00704 NMEInt *fontSize);
00705
00710 NMEInt NMECurrentInputIndex(NMEContext const *context);
00711
00716 NMEInt NMECurrentOutputIndex(NMEContext const *context);
00717
00722 NMEInt NMECurrentOutputIndexUCS16(NMEContext const *context);
00723
00730 void NMECurrentLink(NMEContext const *context,
00731 NMEInt *linkOffset, NMEInt *linkLength);
00732
00739 void NMECurrentOutput(NMEContext const *context,
00740 NMEConstText *output, NMEInt *outputLength);
00741
00746 NMEConstText NMECurrentListNesting(NMEContext const *context);
00747
00748 #ifdef __cplusplus
00749 }
00750 #endif
00751
00752 #endif