#ifndef MIFFED #define MIFFED #ifndef MIFFEDMAIN extern long noteError(char *wail); enum itemTypes { NA,WORD,NUMBER,STRING,LIST,EOL,CMT }; typedef void * itemHandle; typedef void * treeHandle; #endif /* not MIFFEDMAIN */ /* General item class methods */ extern enum itemTypes itemType(itemHandle ith); #define typeOf(ith) itemType(ith) /* more consistent name */ extern itemHandle nextItem(itemHandle ith); extern itemHandle nextInList(itemHandle ith); extern int equalItem(itemHandle a, itemHandle b); extern int textCmp(itemHandle a, char * b); extern int equalText(itemHandle a,itemHandle b); extern itemHandle copyItem(itemHandle ith); extern itemHandle yankNext(itemHandle ith); extern itemHandle yankNextInList(itemHandle ith); extern void trashNext(itemHandle ith); extern void trashSequence(itemHandle ith); extern void dumpItem(FILE* f,itemHandle ith); extern void dumpSequence(FILE* f,itemHandle ith); extern void dumpStats(FILE *f); extern itemHandle patToMIF(char *pattern, ...); #define KEEP_EOL 1 #define KEEP_CMT 2 extern itemHandle readMIF( FILE *infile, int keepCmt ); extern itemHandle readOneItem( FILE *infile, int keepCmt ); extern itemHandle strToMIF(char *pattern); #define OUT_EOL 1 #define OUT_CMT 2 #define OUT_INDENT 4 extern int outItem( char *buffer, int max, itemHandle anitem, int format); extern void writeMIF( FILE *outfile, itemHandle anItem, int format); /* WORD, STRING, COMMENT functions */ extern itemHandle newString(char *text); extern itemHandle newWord(char *text); extern itemHandle newComment(char *text); extern void changeText(itemHandle ith,char *newval); extern char * textOf(itemHandle ith); /* NUMBER functions */ enum unitMeasures { UM_NA, UM_MM, UM_CM, UM_IN, UM_PT, UM_PC, UM_CC, UM_DD }; #define UM_MM_MM 1.0 #define UM_CM_MM 10.0 #define UM_IN_MM 25.4 #define UM_PT_MM 0.35277778 #define UM_PC_MM 4.23333333 #define UM_CC_MM 4.52 #define UM_DD_MM UM_CC_MM/12.0 extern itemHandle newNumber(char *text, char * unit); extern itemHandle newFloat(float val, char * unit); extern itemHandle newInt(int val, char *unit); extern void changeFloat(itemHandle ith, float newval); extern void changeInt(itemHandle ith, int newval); extern double floatOf(itemHandle ith); extern long integerOf(itemHandle ith); extern double millimetersOf(itemHandle ith); extern enum unitMeasures measureOf(itemHandle ith); extern void convertUnit(itemHandle ith, enum unitMeasures um); extern void changeUnitText(itemHandle ith, char *unit); extern char * unitTextOf(itemHandle ith); /* LIST functions */ extern itemHandle newList(char *name); extern void append(itemHandle list,itemHandle ith); extern itemHandle containerOf(itemHandle ith); extern void insert(itemHandle list,itemHandle ith); extern itemHandle firstOfName(itemHandle ith, char *name); extern itemHandle nextSameName(itemHandle ith); extern itemHandle findTaggedList( itemHandle container, char * listName, char * tagName, char * tagValue); /* TREE functions */ extern void * treeLook(treeHandle root, char*key); extern void treeScan(treeHandle root, void UCB(char *k,void *v)); extern void * treeEnter(treeHandle *pRoot, char *key, void *v); extern void trashTree(treeHandle *pRoot); /* ParaScan functions */ extern itemHandle paraScanInit( itemHandle para, /* handle of to scan */ const unsigned short int textOpts, /* text conversion options */ const unsigned short int nonTextOpts, /* non-text skip options */ const unsigned short int lineOpts, /* line-end handling options */ itemHandle oldScan /* old scan to re-initialize, or NULL */ ); extern int paraScanLine(itemHandle parascan, int lnum); extern int paraScanCount(const itemHandle parascan); extern itemHandle paraScanItem(const itemHandle parascan); extern int paraScan(const itemHandle parascan); extern char * paraScanGets(char *bfr, const int n, const itemHandle hPara); /* The following values are used in the textOpts argument of paraScanInit(). They specify the handling of special characters and their optional conversion to ASCII. */ #define PS_CVT_ACCENTS 0x0001 /* convert accented letters to plain */ #define PS_CVT_DASHES 0x0002 /* em-, en- etc dashes to hyphen */ #define PS_CVT_SPACES 0x0004 /* em-, en- etc spaces to space */ #define PS_CVT_DQUOTES 0x0008 /* left & right double quotes to " */ #define PS_CVT_SQUOTES 0x0010 /* left & right apostrophes to ' */ #define PS_8859_1 0x0020 /* convert ISO-8859-1 glyphs to ISO */ #define PS_CVT_LIKES 0x0100 /* special fraction, circumflex, tilde */ #define PS_TAB_AS_SPACE 0x0200 /* convert to space */ /* use this name as shorthand for "convert all punctuation" */ #define PS_FULL_ASCII (PS_CVT_DASHES+\ PS_CVT_SPACES+\ PS_CVT_DQUOTES+\ PS_CVT_SQUOTES+\ PS_CVT_LIKES+\ PS_TAB_AS_SPACE) #define PS_COMPRESS_SPACES 0x1000 /* compress runs of spaces */ #define PS_SKIP_NOHYPHEN 0x2000 /* don't return the no-hyphen char */ #define PS_SPECIALS_AS_SPACES 0x4000 /* convert nonascii to spaces */ #define PS_SPECIALS_AS_XNN 0x8000 /* convert nonascii to \xnn form */ /* use this name to mean "return maximum readable ascii" */ #define PS_FLAT_ASCII (PS_FULL_ASCII+\ PS_SPECIALS_AS_XNN+\ PS_COMPRESS_SPACES+\ PS_SKIP_NOHYPHEN) /* use this name to mean "return full ISO text" */ #define PS_FLAT_ISO (PS_FULL_ASCII+\ PS_8859_1+\ PS_SPECIALS_AS_XNN+\ PS_COMPRESS_SPACES+\ PS_SKIP_NOHYPHEN) /* use this name to mean "return only simple ascii text" */ #define PS_MIN_ASCII (PS_FULL_ASCII+\ PS_CVT_ACCENTS+\ PS_SPECIALS_AS_SPACES+\ PS_COMPRESS_SPACES+\ PS_SKIP_NOHYPHEN) /* The following values are used in the nonTextOpts argument of paraScanInit(). They specify the handling of non-text lists within lists. If a non-text list is skipped, paraScan() returns no sign that it exists. If it is not skipped, paraScan() returns a flag value >255 (list follows) and paraScanItem() is used to retrieve the itemHandle of the list. */ #define PS_SKIP_FONT 0x0001 /* */ #define PS_SKIP_XREF 0x0002 /* and */ #define PS_SKIP_MARKER 0x0004 /* */ #define PS_SKIP_AFRAME 0x2000 /* */ #define PS_SKIP_ATBL 0x0008 /* */ #define PS_SKIP_VAR 0x0010 /* */ #define PS_SKIP_COND 0x0020 /* */ #define PS_SKIP_UNCOND 0x0040 /* */ #define PS_SKIP_TRID 0x0080 /* */ #define PS_SKIP_SPCH 0x0100 /* */ #define PS_SKIP_FNOTE 0x0200 /* */ #define PS_SKIP_ELBEG 0x0400 /* */ #define PS_SKIP_ELEND 0x0800 /* */ #define PS_SKIP_MATH 0x1000 /* */ #define PS_SKIP_UNKNOWN 0x8000 /* */ /* use this name to mean "show me no lists of any kind" */ #define PS_SKIP_ALL_NONTEXT 0xFFFF /* The following values are returned by paraScan() to signal the appearance of a in the paragraph, provided one of the preceding options was not used to skip that list type. The values are all >255 to distinguish them from characters. */ #define PS_FONT 0x0200 #define PS_XREF 0x0300 #define PS_MARKER 0x0400 #define PS_ATBL 0x0500 #define PS_VAR 0x0600 #define PS_COND 0x0700 #define PS_UNCOND 0x0800 #define PS_TRID 0x0900 #define PS_SPCH 0x0a00 #define PS_FNOTE 0x0b00 #define PS_ELBEG 0x0c00 #define PS_ELEND 0x0d00 #define PS_MATH 0x0e00 #define PS_XREFEND 0x0f00 #define PS_AFRAME 0x1000 #define PS_UNKNOWN 0xf000 /* The following values are used with the lineOpts argument of paraScanInit(). They specify the handling of Frame line-ends (ends of lists). When Frame line-ends are NOT returned (PS_SKIP_LINE_END): * the end of a is returned as a space, unless the last item in it is a discretionary hyphen, in which case there is no sign of the line end. * discretionary hyphens are not returned in any form. * hard returns are by default skipped (PS_SKIP_HARD_CR assumed). * hard returns can be obtained using PS_HARD_CR_AS_SPACE or _AS_CR. When Frame line-ends ARE returned, * the end of a is returned as \n * discretionary hyphens are returned as either the hex 04 used by Frame, or ascii hyphens, depending on the use of PS_CVT_DASHES * hard returns are by default skipped (PS_SKIP_HARD_CR assumed). * hard returns can be returned as spaces or \r's using options. */ #define PS_SKIP_LINE_END 0x0000 #define PS_KEEP_LINE_END 0x0001 #define PS_SKIP_HARD_CR 0x0000 #define PS_HARD_CR_AS_SPACE 0x0004 #define PS_HARD_CR_AS_CR 0x0008 #endif /* NOT MIFFED */