home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 5 / DATAFILE_PDCD5.iso / utilities / m / makedrawf / Source / h / mkdrawf < prev   
Encoding:
Text File  |  1997-04-09  |  6.6 KB  |  239 lines

  1. /* mkdrawf.h
  2.  *
  3.  * Types, defines etc needed by both mouth.c and stomach.c
  4.  */
  5.  
  6. #ifdef ONLINE_MEDIA
  7. #ifndef TAGS
  8. #define TAGS 1
  9. #endif
  10. #ifdef NO_JPEG
  11. #undef NO_JPEG
  12. #endif
  13. #endif
  14.  
  15. #ifdef DEBUG_ALL
  16. #define DEBUG_TOKENS
  17. #define DEBUG_XTOKENS
  18. #define DEBUG_MEMORY
  19. #endif
  20.  
  21. #define VERSION_STRING "3.09 (9/4/1997)"
  22.  
  23. typedef unsigned int uint;
  24.  
  25. /* Something that can be held in a single word:
  26.  */
  27. typedef union word {
  28.   int I;
  29.   uint U;
  30.   char *CP;
  31.   int *IP;
  32.   union word *WP;    /* we'll call this a |Word *| really */
  33.   uint T;        /* |Type| */
  34.   union two_words *PP;    /* |TwoWords *| -- P is for pair */
  35.   struct token *TP;    /* |Token *| */
  36.   struct saved *SP;    /* |Saved *| */
  37.   void (*FP)(void);    /* pointer to function */
  38.   struct looprec *LP;    /* |LoopRecord *| */
  39.   struct hashent *HP;    /* |HashEntry *| */
  40. } Word;
  41.  
  42. /* Something that can be held in two words:
  43.  */
  44. typedef union two_words {
  45.   int I; uint U; char *CP; int *IP; union word *WP;
  46.   uint T; union two_words *PP; struct token *TP;
  47.   struct looprec *LP; struct hashent *HP;
  48.   void (*FP)(void);
  49.   double D;
  50.   struct { Word first; Word rest; } P;    /* P for "pair" again */
  51. } TwoWords;
  52.  
  53. /* Types of token:
  54.  * NB: this is just the low byte. The rest may be used for dreadful things.
  55.  */
  56. enum {
  57.   t_NoValue=0,    /* undefined variables etc */
  58.   t_keyword,    /* Length    */
  59.   t_real,    /* 123.456    */
  60.   t_string,    /* "foo bar"    */
  61.   t_colour,    /* r200g5b123    */
  62.   t_toklist,    /* { 1 Foo $3 }    */
  63.   t_special,    /* EndIf    */
  64.   t_macro,    /* MyMacro    */
  65.   t_global,    /* $foo        */
  66.   t_local,    /* %bar        */
  67.   t_localP,    /* positional parameter */
  68.   t_openbr,    /* {        */
  69.   t_closebr,    /* }        */
  70.   t_unready,    /* As-yet undefined macro */
  71.   t_magicEOM,    /* end of macro expansion */
  72.   t_magicNEXT    /* end of loop token list */
  73. };
  74.  
  75. /* The following are all the sorts of special token:
  76.  */
  77. enum {
  78.   s_Define,    /* macro */
  79.   s_Set,    /* variable */
  80.   s_IfExists,    /* variable */
  81.   s_IfLess,    /* numbers */
  82.   s_IfEqual,    /* anything */
  83.   s_Else,
  84.   s_EndIf,
  85.   s_For,        /* loop */
  86.   s_Plus,s_Minus,s_Times,s_Over,/* arithmetic */
  87.   s_Sqrt,s_Sin,s_Cos,s_Tan,    /* other functions */
  88.   s_Arcsin,s_Arccos,s_Arctan,    /* and some more */
  89.   s_Arctan2,
  90.   s_Floor,
  91.   s_Include,    /* file inclusion */
  92. #ifdef TAGS
  93.   s_TagOpen,s_TagLookup,s_TagClose,
  94. #endif
  95.   s_Append,    /* string append */
  96.   s_GSTrans,    /* call GSTrans, for access to variables etc */
  97.   s_Font,    /* font name -> number conversion */
  98.   s_Str2Num,s_Num2Str,    /* Guess what these do */
  99.   s_Random,    /* random number in [0,1) */
  100.   s_Units,    /* set units */
  101.   s_Unit    /* read units */
  102. };
  103.  
  104. /* The following are all the keywords:
  105.  */
  106. enum {
  107.   k_Header,    /* pseudo-object for stuff in drawfile header */
  108.   k_FontTable,k_Text,k_Path,k_Sprite,k_Group,k_Tagged,k_TextArea,k_Column,
  109.   k_Options,k_XfText,k_XfSprite,    /* object types */
  110. #ifndef NO_JPEG
  111.   k_JPEG,
  112. #endif
  113.   k_Version,    /* indicate Draw version number */
  114.   k_Creator,    /* of this file */
  115.   k_BoundingBox,
  116.   k_Colour,k_Background,k_Style,
  117.   k_Size,k_StartAt,    /* things in text objects */
  118.   k_FillColour,k_OutlineColour,k_Width,    /* top-level in path object */
  119.   k_Move,k_Close,k_Line,k_Curve,    /* path components */
  120.   k_RMove,k_RLine,k_RCurve,    /* relative motion */
  121.   k_Mitred,k_Round,k_Bevelled,    /* join types */
  122.   k_EndCap,k_StartCap,k_Butt,k_Square,k_Triangular, /* cap types. Also Round */
  123.   k_WindingRule,k_Dash,
  124.   k_CapWidth,k_CapLength,    /* other path style options */
  125.   k_NonZero,k_EvenOdd,    /* winding rules */
  126.   k_Offset,k_Pattern,    /* dash specifications */
  127.   k_Name,    /* of grouped object */
  128.   k_Identifier,    /* of tagged object */
  129.   k_OtherData,    /* for tagged object */
  130.   k_Matrix,k_Kerned,k_RightToLeft,    /* for transformed text object */
  131.   k_PaperSize,k_Limits,k_Grid,k_Zoom,
  132.   k_NoToolbox,k_Mode,k_UndoSize,    /* options top-level */
  133.   k_Shown,k_Landscape,k_NonDefault,    /* limits options */
  134.   k_Spacing,k_Divisions,k_Isometric,
  135.   k_AutoAdjust,k_Lock,k_Inches,    /* grid things. */
  136.   k_Ratio,    /* for zoom */
  137.   k_ClosedLine,k_ClosedCurve,k_Rectangle,k_Ellipse,k_Select,    /* modes */
  138.   k_FromFile,    /* in sprite or xfsprite object */
  139.   k_HCentreIn,k_CentreIn,    /* text centred in a box */
  140.   k_HCentreOn,k_CentreAt,    /* ditto, more economical */
  141.   k_Virtual,    /* fake text objects */
  142. #ifndef NO_JPEG
  143.   k_DPI,k_Length,
  144. #endif
  145.   k_Illegal    /* when sthg goes wrong but need to return a keyword number */
  146.   /* More will go here when some other things are implemented. */
  147. };
  148.  
  149. /* A token has a 1-word type and a 2-word value.
  150.  * Why 2 words? So that we can fit a |double| into it.
  151.  */
  152. typedef struct token {
  153.   uint type;
  154.   TwoWords value;
  155. } Token;
  156.  
  157. /* The following really ought to be in mouth.c, but it goes here because
  158.  * it's used in stomach.c as well.
  159.  * This figure includes the \n\0.
  160.  */
  161. #define max_line_length 256
  162.  
  163. /* Visible variables from general.c:
  164.  */
  165. extern char *prog_name;
  166. extern int line_number;
  167. extern int no_filenames;
  168.  
  169. /* Visible variables from mouth.c:
  170.  */
  171. extern FILE *input_file;
  172. extern char *input_file_name;
  173. extern char *line_tail;
  174. extern Token curr_token;
  175. extern int scaling;
  176. extern double unit;
  177.  
  178. /* Visible functions from general.c:
  179.  */
  180. extern void warn(char *, ...);
  181. extern void minor(char *, ...);
  182. extern void error(char *, ...);
  183. extern int final_report(void);
  184. extern void *xmalloc(uint, char *);
  185. #ifdef DEBUG_MEMORY
  186. extern void xfree(void *);
  187. #else
  188. #define xfree(x) free(x)
  189. #endif
  190. extern int cistreq(const char *, const char *);
  191. extern char *copy_string(const char *s);
  192.  
  193. /* Visible functions from mouth.c:
  194.  */
  195. extern void init_global_hash(void);
  196. extern int get_line(void);
  197. extern int get_x_token(int);
  198. extern double read_double(void);
  199. extern int read_int(void);
  200. extern char *read_string(void);
  201. extern int read_real640(void);
  202. extern int read_real1000(void);
  203. extern void read_openbr(void);
  204. extern void read_closebr(void);
  205. extern int read_kwd(void);
  206. extern int read_kwd_or_cbr(void);
  207. extern int read_colour(void);
  208. extern void set_variable(const char *, double);
  209. extern void init_vars(void);
  210.  
  211. /* Visible functions from stomach.c:
  212.  */
  213. extern int font_number(const char *);
  214.  
  215. /* Visible functions from syscalls.s:
  216.  */
  217. extern int findfont(char *name, int xsz, int ysz, int xres, int yres);
  218. extern void losefont(int handle);
  219. extern void stringbbox(int handle, char *string, int *bbox, int flags, int *matrix);
  220. extern int processpath(int *path, int fill_style, int *matrix, int flatness,
  221.                 int width, int *cap_and_join, int *dash_pattern,
  222.                 int *output_buffer);
  223. extern int gstrans(char *str, char *buf, int len);
  224. extern int file_size(char *name);
  225. extern int load_file(char *name, void *address);
  226. extern int mono_time(void);
  227.  
  228. #ifdef TAGS
  229. /* Visible variables from tagfile.c:
  230.  */
  231. extern struct tag *tags;
  232.  
  233. /* Visible functions from tagfile.c:
  234.  */
  235. extern int tag_open(const char *);
  236. extern char *tag_lookup(const char *);
  237. extern void tag_close(void);
  238. #endif
  239.