home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / anwor032.zip / antiword.0.32 / antiword.h < prev    next >
C/C++ Source or Header  |  2001-09-25  |  14KB  |  415 lines

  1. /*
  2.  * antiword.h
  3.  * Copyright (C) 1998-2001 A.J. van Os; Released under GPL
  4.  *
  5.  * Description:
  6.  * Generic include file for project 'Antiword'
  7.  */
  8.  
  9. #if !defined(__antiword_h)
  10. #define __antiword_h 1
  11.  
  12. #if defined(DEBUG) == defined(NDEBUG)
  13. #error Exactly one of the DEBUG and NDEBUG flags MUST be set
  14. #endif /* DEBUG == NDEBUG */
  15.  
  16. #include <stdio.h>
  17. #include <limits.h>
  18. #if defined(__riscos)
  19. #include "wimp.h"
  20. #include "drawfobj.h"
  21. #include "font.h"
  22. #include "werr.h"
  23. #include "draw.h"
  24. #else
  25. #include <sys/types.h>
  26. #endif /* __riscos */
  27. #include "wordconst.h"
  28. #include "wordtypes.h"
  29. #include "fail.h"
  30. #include "debug.h"
  31.  
  32. /* Constants */
  33. #if !defined(PATH_MAX)
  34.  #if defined(__riscos)
  35.  #define PATH_MAX         255
  36.  #else
  37.   #if defined(MAXPATHLEN)
  38.   #define PATH_MAX        MAXPATHLEN
  39.   #else
  40.   #define PATH_MAX        1024
  41.   #endif /* MAXPATHLEN */
  42.  #endif /* __riscos */
  43. #endif /* !PATH_MAX */
  44.  
  45. #if !defined(SIZE_T_MAX)
  46. #define SIZE_T_MAX        (size_t)UINT_MAX
  47. #endif /* SIZE_T_MAX */
  48.  
  49. #if defined(__riscos)
  50. #define FILE_SEPARATOR        "."
  51. #elif defined(__dos)
  52. #define FILE_SEPARATOR        "\\"
  53. #else
  54. #define FILE_SEPARATOR        "/"
  55. #endif /* __riscos */
  56.  
  57. /* PNG chunk names */
  58. #define PNG_CN_IDAT        0x49444154
  59. #define PNG_CN_IEND        0x49454e44
  60. #define PNG_CN_IHDR        0x49484452
  61. #define PNG_CN_PLTE        0x504c5445
  62.  
  63. /* The screen width */
  64. #define MIN_SCREEN_WIDTH     45
  65. #define DEFAULT_SCREEN_WIDTH     76
  66. #define MAX_SCREEN_WIDTH    145
  67.  
  68. #if defined(__riscos)
  69. /* The scale factors as percentages */
  70. #define MIN_SCALE_FACTOR     25
  71. #define DEFAULT_SCALE_FACTOR    100
  72. #define MAX_SCALE_FACTOR    400
  73.  
  74. /* Filetypes */
  75. #define FILETYPE_MSWORD        0xae6
  76. #define FILETYPE_DRAW        0xaff
  77. #define FILETYPE_JPEG        0xc85
  78. #define FILETYPE_POSCRIPT    0xff5
  79. #define FILETYPE_SPRITE        0xff9
  80. #define FILETYPE_TEXT        0xfff
  81.  
  82. /* The button numbers in the choices window */
  83. #define CHOICES_DEFAULT_BUTTON         3
  84. #define CHOICES_SAVE_BUTTON         2
  85. #define CHOICES_CANCEL_BUTTON         1
  86. #define CHOICES_APPLY_BUTTON         0
  87. #define CHOICES_BREAK_BUTTON         6
  88. #define CHOICES_BREAK_WRITEABLE         7
  89. #define CHOICES_BREAK_UP_BUTTON         8
  90. #define CHOICES_BREAK_DOWN_BUTTON     9
  91. #define CHOICES_NO_BREAK_BUTTON        11
  92. #define CHOICES_AUTOFILETYPE_BUTTON    14
  93. #define CHOICES_HIDDEN_TEXT_BUTTON    22
  94. #define CHOICES_WITH_IMAGES_BUTTON    17
  95. #define CHOICES_NO_IMAGES_BUTTON    18
  96. #define CHOICES_TEXTONLY_BUTTON        19
  97. #define CHOICES_SCALE_WRITEABLE        25
  98. #define CHOICES_SCALE_UP_BUTTON        26
  99. #define CHOICES_SCALE_DOWN_BUTTON    27
  100.  
  101. /* The button numbers in the scale view window */
  102. #define SCALE_CANCEL_BUTTON         1
  103. #define SCALE_SCALE_BUTTON         0
  104. #define SCALE_SCALE_WRITEABLE         3
  105. #define SCALE_50_PCT             5
  106. #define SCALE_75_PCT             6
  107. #define SCALE_100_PCT             7
  108. #define SCALE_150_PCT             8
  109.  
  110. /* New draw objects */
  111. #define draw_OBJJPEG        16
  112. #else
  113. /* Margins for the PostScript version */
  114. #define PS_LEFT_MARGIN            (72 * 640L)
  115. #define PS_RIGHT_MARGIN            (48 * 640L)
  116. #define PS_TOP_MARGIN            (72 * 640L)
  117. #define PS_BOTTOM_MARGIN        (72 * 640L)
  118. #endif /* __riscos */
  119.  
  120. /* Macros */
  121. #define STREQ(x,y)    (*(x) == *(y) && strcmp(x,y) == 0)
  122. #define STRNEQ(x,y,n)    (*(x) == *(y) && strncmp(x,y,n) == 0)
  123. #define elementsof(a)    (sizeof(a) / sizeof(a[0]))
  124. #define odd(x)        (((x)&0x01)!=0)
  125. #define ROUND4(x)    (((x)+3)&~0x03)
  126. #define BIT(x)        ((unsigned long)1 << (x))
  127. #if !defined(max)
  128. #define max(x,y)    ((x)>(y)?(x):(y))
  129. #endif /* !max */
  130. #if !defined(min)
  131. #define min(x,y)    ((x)<(y)?(x):(y))
  132. #endif /* !min */
  133.  
  134. #if defined(__riscos)
  135. /* The name of the table font */
  136. #define TABLE_FONT        "Corpus.Medium"
  137. #else
  138. /* The name of the table font */
  139. #define TABLE_FONT        "Courier"
  140. /* The name of the antiword directories and the font information file */
  141. #if defined(__dos)
  142. #define GLOBAL_ANTIWORD_DIR    "C:\\antiword"
  143. #define ANTIWORD_DIR        "antiword"
  144. #define FONTNAMES_FILE        "fontname.txt"
  145. #else
  146. #define GLOBAL_ANTIWORD_DIR    "/opt/antiword/share"
  147. #define ANTIWORD_DIR        ".antiword"
  148. #define FONTNAMES_FILE        "fontnames"
  149. #endif /* __dos */
  150. /* The name of the default mapping file */
  151. #define MAPPING_FILE_DEFAULT_1    "8859-1.txt"
  152. #define MAPPING_FILE_DEFAULT_2    "8859-2.txt"
  153. #define MAPPING_FILE_DEFAULT_8    "UTF-8.txt"
  154. #endif /* __riscos */
  155.  
  156. /* Prototypes */
  157.  
  158. /* asc85enc.c */
  159. extern void    vASCII85EncodeByte(FILE *, int);
  160. extern void    vASCII85EncodeArray(FILE *, FILE *, int);
  161. extern void    vASCII85EncodeFile(FILE *, FILE *, int);
  162. /* blocklist.c */
  163. extern void    vDestroyTextBlockList(void);
  164. extern BOOL    bAdd2TextBlockList(text_block_type *);
  165. extern void    vSplitBlockList(long, long, long, long, long, BOOL);
  166. extern unsigned short    usNextChar(FILE *, list_id_enum,
  167.                 long *, long *, unsigned short *);
  168. extern long    lTextOffset2FileOffset(long);
  169. #if defined(__riscos)
  170. extern long    lGetDocumentLength(void);
  171. #endif /* __riscos */
  172. /* chartrans.c */
  173. extern BOOL    bReadCharacterMappingTable(const char *);
  174. extern unsigned long    ulTranslateCharacters(unsigned short, long, BOOL, BOOL);
  175. extern unsigned long    ulToUpper(unsigned long);
  176. /* datalist.c */
  177. extern void    vDestroyDataBlockList(void);
  178. extern BOOL    bAdd2DataBlockList(data_block_type *);
  179. extern BOOL    bSetDataOffset(FILE *, long);
  180. extern int    iNextByte(FILE *);
  181. extern unsigned short    usNextWord(FILE *);
  182. extern unsigned long    ulNextLong(FILE *);
  183. extern unsigned short    usNextWordBE(FILE *);
  184. extern unsigned long    ulNextLongBE(FILE *);
  185. extern int    iSkipBytes(FILE *, size_t);
  186. extern long    lDataOffset2FileOffset(long);
  187. /* depot.c */
  188. extern void    vDestroySmallBlockList(void);
  189. extern BOOL    bCreateSmallBlockList(long, const long *, size_t);
  190. extern long    lDepotOffset(long, size_t);
  191. /* dib2eps & dib2sprt.c */
  192. extern BOOL    bTranslateDIB(diagram_type *,
  193.             FILE *, long, const imagedata_type *);
  194. /* draw.c & postscript.c */
  195. extern BOOL    bAddDummyImage(diagram_type *, const imagedata_type *);
  196. extern diagram_type *pCreateDiagram(const char *, const char *);
  197. extern void    vAddFonts2Diagram(diagram_type *);
  198. extern void    vSubstring2Diagram(diagram_type *,
  199.             char *, int, long, int, unsigned char,
  200.             draw_fontref, int, int);
  201. extern void    vMove2NextLine(diagram_type *, draw_fontref, int);
  202. extern void    vEndOfParagraph2Diagram(diagram_type *, draw_fontref, int);
  203. extern void    vEndOfPage2Diagram(diagram_type *, draw_fontref, int);
  204. #if defined(__riscos)
  205. extern void    vImage2Diagram(diagram_type *, const imagedata_type *,
  206.             unsigned char *, size_t);
  207. extern BOOL    bVerifyDiagram(diagram_type *);
  208. extern void    vShowDiagram(diagram_type *);
  209. extern void    vMainEventHandler(wimp_eventstr *, void *);
  210. extern void    vScaleOpenAction(diagram_type *);
  211. extern void    vSetTitle(diagram_type *);
  212. extern void    vScaleEventHandler(wimp_eventstr *, void *);
  213. #else
  214. extern void    vImagePrologue(diagram_type *, const imagedata_type *);
  215. extern void    vImageEpilogue(diagram_type *);
  216. extern void    vDestroyDiagram(diagram_type *);
  217. #endif /* __riscos */
  218. /* finddata.c */
  219. extern BOOL    bAddDataBlocks(long , long, long, const long *, size_t);
  220. extern BOOL    bGet6DocumentData(FILE *, long,
  221.                 const long *, size_t, const unsigned char *);
  222. /* findtext.c */
  223. extern BOOL    bAddTextBlocks(long , long, BOOL,
  224.                 unsigned short, long, const long *, size_t);
  225. extern BOOL    bGet6DocumentText(FILE *, BOOL, long,
  226.                 const long *, size_t, const unsigned char *);
  227. extern BOOL    bGet8DocumentText(FILE *, const pps_info_type *,
  228.                 const long *, size_t, const long *, size_t,
  229.                 const unsigned char *);
  230. /* fontlist.c */
  231. extern void    vDestroyFontInfoList(void);
  232. extern void    vAdd2FontInfoList(const font_block_type *);
  233. extern void    vReset2FontInfoList(long);
  234. extern const font_block_type    *pGetNextFontInfoListItem(
  235.                     const font_block_type *);
  236. /* fonts.c */
  237. extern int    iGetFontByNumber(int, unsigned char);
  238. extern const char    *szGetOurFontname(int);
  239. extern int    iFontname2Fontnumber(const char *, unsigned char);
  240. extern void    vCreate6FontTable(FILE *, long,
  241.             const long *, size_t, const unsigned char *);
  242. extern void    vCreate8FontTable(FILE *, const pps_info_type *,
  243.             const long *, size_t, const long *, size_t,
  244.             const unsigned char *);
  245. extern void    vDestroyFontTable(void);
  246. extern const font_table_type    *pGetNextFontTableRecord(
  247.                         const font_table_type *);
  248. extern size_t    tGetFontTableLength(void);
  249. /* fonts_r.c & fonts_u.c */
  250. extern FILE    *pOpenFontTableFile(void);
  251. extern void    vCloseFont(void);
  252. extern draw_fontref    tOpenFont(int, unsigned char, int);
  253. extern draw_fontref    tOpenTableFont(int);
  254. extern long    lComputeStringWidth(char *, int, draw_fontref, int);
  255. /* fonts_u.c */
  256. #if !defined(__riscos)
  257. extern const char    *szGetFontname(draw_fontref);
  258. #endif /* !__riscos */
  259. #if defined(__riscos)
  260. /* icons.c */
  261. extern void    vUpdateIcon(wimp_w, wimp_icon *);
  262. extern void    vUpdateRadioButton(wimp_w, wimp_i, BOOL);
  263. extern void    vUpdateWriteable(wimp_w, wimp_i, char *);
  264. extern void    vUpdateWriteableNumber(wimp_w, wimp_i, int);
  265. #endif /* __riscos */
  266. /* imgexam.c */
  267. extern image_info_enum    eExamineImage(FILE *, long, imagedata_type *);
  268. /* imgtrans */
  269. extern BOOL    bTranslateImage(diagram_type *,
  270.             FILE *, BOOL, long, const imagedata_type *);
  271. /* jpeg2eps.c & jpeg2spr.c */
  272. extern BOOL    bTranslateJPEG(diagram_type *,
  273.             FILE *, long, int, const imagedata_type *);
  274. /* misc.c */
  275. #if !defined(__riscos)
  276. extern const char    *szGetHomeDirectory(void);
  277. #endif /* !__riscos */
  278. extern long    lGetFilesize(const char *);
  279. #if defined(DEBUG)
  280. extern void    vPrintBlock(const char *, int, const unsigned char *, size_t);
  281. extern void    vPrintUnicode(const char *, int, const char *);
  282. extern BOOL    bCheckDoubleLinkedList(output_type *);
  283. #endif /* DEBUG */
  284. extern BOOL    bReadBytes(unsigned char *, size_t, long, FILE *);
  285. extern BOOL    bReadBuffer(FILE *, long, const long *, size_t, size_t,
  286.             unsigned char *, long, size_t);
  287. extern unsigned int    uiColor2Color(int);
  288. extern output_type *pSplitList(output_type *);
  289. extern int    iInteger2Roman(int, BOOL, char *);
  290. extern int    iInteger2Alpha(int, BOOL, char *);
  291. extern char    *unincpy(char *, const char *, size_t);
  292. extern size_t    unilen(const char *);
  293. extern const char    *szBasename(const char *);
  294. extern int    iGetVersionNumber(const unsigned char *);
  295. extern BOOL    bIsWord6MacFile(void);
  296. extern long    lComputeLeading(int);
  297. /* notes.c */
  298. extern void    vDestroyNotesInfoLists(void);
  299. extern void    vGetNotesInfo(FILE *, const pps_info_type *,
  300.             const long *, size_t, const long *, size_t,
  301.             const unsigned char *, int);
  302. extern notetype_enum eGetNotetype(long);
  303. /* options.c */
  304. extern int    iReadOptions(int, char **);
  305. extern void    vGetOptions(options_type *);
  306. #if defined(__riscos)
  307. extern void    vChoicesOpenAction(wimp_w);
  308. extern void    vChoicesMouseClick(wimp_mousestr *);
  309. extern void    vChoicesKeyPressed(wimp_caretstr *);
  310. #endif /* __riscos */
  311. /* out2window.c */
  312. extern void    vSetLeftIndentation(diagram_type *, long);
  313. extern void    vAlign2Window(diagram_type *, output_type *,
  314.             long, unsigned char);
  315. extern void    vJustify2Window(diagram_type *, output_type *,
  316.             long, long, unsigned char);
  317. extern void    vResetStyles(void);
  318. extern int    iStyle2Window(char *, const style_block_type *);
  319. extern void    vTableRow2Window(diagram_type *,
  320.             output_type *, const row_block_type *);
  321. /* pictlist.c */
  322. extern void    vDestroyPicInfoList(void);
  323. extern void    vAdd2PicInfoList(const picture_block_type *);
  324. extern long    lGetPicInfoListItem(long);
  325. /* png2eps.c & png2spr.c */
  326. extern BOOL    bTranslatePNG(diagram_type *,
  327.             FILE *, long, int, const imagedata_type *);
  328. /* prop6.c */
  329. extern row_info_enum    eGet6RowInfo(int,
  330.                 const unsigned char *, int, row_block_type *);
  331. extern void    vGet6PapInfo(FILE *, long, const long *, size_t,
  332.             const unsigned char *);
  333. extern void    vGet6ChrInfo(FILE *, const pps_info_type *,
  334.             const long *, size_t, const unsigned char *);
  335. /* prop8.c */
  336. extern row_info_enum    eGet8RowInfo(int,
  337.                 const unsigned char *, int, row_block_type *);
  338. extern void    vGet8PapInfo(FILE *, const pps_info_type *,
  339.             const long *, size_t, const long *, size_t,
  340.             const unsigned char *);
  341. extern void    vGet8ChrInfo(FILE *, const pps_info_type *,
  342.             const long *, size_t, const long *, size_t,
  343.             const unsigned char *);
  344. /* properties.c */
  345. extern void    vGetPropertyInfo(FILE *, const pps_info_type *,
  346.             const long *, size_t, const long *, size_t,
  347.             const unsigned char *, int);
  348. extern row_info_enum    ePropMod2RowInfo(unsigned short, int);
  349. /* propmod.c */
  350. extern void    vDestroyPropModList(void);
  351. extern void    vAdd2PropModList(const unsigned char *);
  352. extern const unsigned char    *pucReadPropModListItem(unsigned short);
  353. /* rowlist.c */
  354. extern void    vDestroyRowInfoList(void);
  355. extern void    vAdd2RowInfoList(const row_block_type *);
  356. extern const row_block_type    *pGetNextRowInfoListItem(void);
  357. /* riscos.c */
  358. #if defined(__riscos)
  359. extern int    iGetFiletype(const char *);
  360. extern void    vSetFiletype(const char *, int);
  361. extern BOOL    bMakeDirectory(const char *);
  362. extern BOOL    bISO_8859_1_IsCurrent(void);
  363. extern int    iGetRiscOsVersion(void);
  364. extern BOOL    bDrawRenderDiag360(draw_diag *,
  365.             draw_redrawstr *, double, draw_error *);
  366. #endif /* __riscos */
  367. /* stylelist.c */
  368. extern void    vDestroyStyleInfoList(void);
  369. extern void    vAdd2StyleInfoList(const style_block_type *);
  370. extern const style_block_type    *pGetNextStyleInfoListItem(void);
  371. /* tabstop.c */
  372. extern void    vSetDefaultTabWidth(FILE *, const pps_info_type *,
  373.             const long *, size_t, const long *, size_t,
  374.             const unsigned char *, int);
  375. extern long    lGetDefaultTabWidth(void);
  376. /* unix.c */
  377. #if !defined(__riscos)
  378. extern void    werr(int, const char *, ...);
  379. extern void    visdelay_begin(void);
  380. extern void    visdelay_end(void);
  381. #endif /* !__riscos */
  382. /* saveas.c */
  383. #if defined(__riscos)
  384. extern void    vSaveTextfile(diagram_type *);
  385. extern void    vSaveDrawfile(diagram_type *);
  386. #endif /* __riscos */
  387. /* utf-8.c */
  388. #if !defined(__riscos)
  389. extern int    wcwidth(unsigned long);
  390. extern long    utf8_strwidth(const char *, int);
  391. extern BOOL    is_locale_utf8(void);
  392. #endif /* !__riscos */
  393. /* word2text.c */
  394. extern void    vWord2Text(FILE *, long, diagram_type *);
  395. /* wordlib.c */
  396. extern int    iInitDocument(FILE *, long);
  397. extern void    vFreeDocument(void);
  398. extern BOOL    bIsSupportedWordFile(FILE *, long);
  399. extern BOOL    bIsWord245File(FILE *);
  400. extern BOOL    bIsRtfFile(FILE *);
  401. /* xmalloc.c */
  402. extern void     *xmalloc(size_t);
  403. extern void     *xrealloc(void *, size_t);
  404. extern char    *xstrdup(const char *);
  405. extern void     *xfree(void *);
  406.  
  407. /* For use with Gray Watson dmalloc library */
  408. #if defined(DMALLOC)
  409. #include "dmalloc.h"
  410. /* The xfree in Antiword is incompatible with the one in dmalloc */
  411. #undef xfree
  412. #endif /* DMALLOC */
  413.  
  414. #endif /* __antiword_h */
  415.