home *** CD-ROM | disk | FTP | other *** search
/ Aminet 18 / aminetcdnumber181997.iso / Aminet / text / hyper / hsc_source.lha / hsc / source / hsclib / attrib.h < prev    next >
Encoding:
C/C++ Source or Header  |  1997-01-21  |  5.2 KB  |  141 lines

  1. /*
  2.  * hsclib/attribute.h
  3.  *
  4.  * attribute structure and funcs for hsc
  5.  */
  6.  
  7. #ifndef HSC_ATTRIBUTE_H
  8. #define HSC_ATTRIBUTE_H
  9.  
  10. /* variable types */
  11. #define VT_NONE   0             /* no type; only after init */
  12. #define VT_URI    1             /* uri */
  13. #define VT_STRING 2             /* text string */
  14. #define VT_BOOL   3             /* boolean */
  15. #define VT_NUM    4             /* TODO: numeric */
  16. #define VT_ENUM   5             /* enumerator */
  17. #define VT_ID     6             /* TODO: id (name reference) */
  18. #define VT_COLOR  7             /* TODO: jerk's color */
  19.  
  20. #define VT_STR_URI    "URI"     /* uri */
  21. #define VT_STR_STRING "STRING"  /* text string */
  22. #define VT_STR_BOOL   "BOOL"    /* boolean */
  23. #define VT_STR_NUM    "NUM"     /* numeric */
  24. #define VT_STR_ENUM   "ENUM"    /* enumerator */
  25. #define VT_STR_ID     "ID"      /* id (name reference) */
  26. #define VT_STR_COLOR  "COLOR"   /* color */
  27.  
  28. /* variable flags */
  29. #define VF_ONLYONCE     (1<<0)  /* attribute may occure only once */
  30. #define VF_REQUIRED     (1<<1)  /* attribute is required */
  31. #define VF_CONST        (1<<2)  /* attribute is read-only: <$DEFINE> */
  32. #define VF_JERK         (1<<3)  /* attribute only used by jerks */
  33. #define VF_STRIPEXT     (1<<4)  /* URI: strip tag, if external */
  34. #define VF_GETSIZE      (1<<5)  /* URI: get WIDTH & HEIGHT from here */
  35. #define VF_RECOMMENDED  (1<<6)  /* attribute is recommended to appear */
  36.  
  37. #define VF_KEEP_QUOTES  (1<<28) /* keep quotes untouched */
  38. #define VF_GLOBAL       (1<<29) /* attribute is global: <$DEFINE> */
  39. #define VF_MACRO        (1<<30) /* macro-attr */
  40. #define VF_TAG          (1<<31) /* tag-attr (see note below) */
  41.  
  42. /*
  43.  * NOTE on VF_TAG:
  44.  *
  45.  * Within uri-attributes, there is one problem: if you pass
  46.  * an uri-attr to a macro or <$define>, the uri is parsed twice,
  47.  * when attribute is passed to tag.
  48.  * This produces shit when the uri is parsed the second time
  49.  * (eg absolute uri is converted again)
  50.  *
  51.  * Therefor, uris are only parsed, if the VF_TAG-flag is
  52.  * enabled. By default, VF_TAG is disabled and can only be
  53.  * enabled when copying local macro attribute to the global
  54.  * attribute list. (see "copy_local_varlist()" in "attrib.c")
  55.  */
  56.  
  57. #define VF_CONST_STR       "CONST" /* attr is read only <$DEFINE> */
  58. #define VF_CONST_SHT       "C"
  59. #define VF_GLOBAL_STR      "GLOBAL"        /* global attribute <$DEFINE> */
  60. #define VF_GLOBAL_SHT      "G"
  61. #define VF_JERK_STR        "JERK"  /* attr only used by jerks */
  62. #define VF_JERK_SHT        "J"
  63. #define VF_ONLYONCE_STR    "ONLYONCE"      /* attr may appear only once in tag */
  64. #define VF_ONLYONCE_SHT    "1"
  65. #define VF_REQUIRED_STR    "REQUIRED"      /* attr is required */
  66. #define VF_REQUIRED_SHT    "R"
  67. #define VF_STRIPEXT_STR    "STRIPEXT"      /* strip tag, if URI is external */
  68. #define VF_STRIPEXT_SHT    "X"
  69. #define VF_GETSIZE_STR     "GETSIZE"       /* follow URI to get WIDTH & HEIGHT */
  70. #define VF_GETSIZE_SHT     "Z"
  71. #define VF_RECOMMENDED_STR "RECOMMENDED"       /* follow URI to get WIDTH & HEIGHT */
  72. #define VF_RECOMMENDED_SHT "RCMD"
  73.  
  74. /* prefix for temporary attributes */
  75. #define PREFIX_HSCATTR "HSC."
  76. #define PREFIX_TMPATTR "HSC.TMP."
  77.  
  78. /* chars that act like opening/closing quote */
  79. #define VQ_STR_QUOTE "\"'"
  80.  
  81. /* "no quote" value for quote in HSCATTR */
  82. #define VQ_NO_QUOTE 0
  83.  
  84. /* error return value for set_macro_args() to set var->macro_id with */
  85. #define MCI_GLOBAL  0           /* indicate global attributes */
  86. #define MCI_ERROR   0xffffffff
  87. #define MCI_APPCTAG 0xfffffffe  /* used by app_ctag(); see "tag.c" */
  88.  
  89. /* attribute structure */
  90. typedef struct hscvar
  91. {
  92.     STRPTR name;                /* macro id */
  93.     STRPTR deftext;             /* deftext text */
  94.     STRPTR text;                /* text to be expanded to */
  95.     STRPTR enumstr;             /* enumerator string */
  96.     ULONG macro_id;             /* macro-call-id for local var */
  97.     ULONG varflag;              /* flags; see VF_xx */
  98.     int quote;                  /* quote char */
  99.     BYTE vartype;               /* type; see VT_xx */
  100. }
  101. HSCATTR;
  102.  
  103. #define HSCVAR HSCATTR          /* TODO: remove */
  104.  
  105. /*
  106.  * global funcs
  107.  */
  108. #ifndef NOEXTERN_HSCLIB_VARS_H
  109.  
  110. extern VOID prt_varlist(DLLIST * varlist, STRPTR title);
  111.  
  112. extern HSCATTR *new_hscattr(STRPTR newname);
  113. extern VOID del_hscattr(APTR data);
  114. extern HSCATTR *cpy_hscattr(HSCATTR * oldvar);
  115.  
  116. extern DLNODE *find_attrnode(DLLIST * varlist, STRPTR name);
  117. extern HSCATTR *find_varname(DLLIST * varlist, STRPTR name);
  118. extern HSCATTR *app_var(DLLIST * varlist, STRPTR newname);
  119.  
  120. extern BOOL check_enumstr(HSCATTR * var, STRPTR value, INFILE * inpf);
  121.  
  122. extern STRPTR set_vartext(HSCATTR * var, STRPTR newtext);
  123. extern BOOL set_varbool(HSCATTR * attr, BOOL value);
  124. extern BOOL clr_vartext(HSCATTR * var);
  125. extern VOID clr_attrdef(HSCATTR * attr);
  126. extern BOOL clr_varlist(DLLIST * varlist);
  127. extern VOID clr_varlist_bool(DLLIST * varlist);
  128.  
  129. extern STRPTR get_vartext_byname(DLLIST * varlist, STRPTR name);
  130. extern STRPTR get_vartext(HSCATTR * var);
  131. extern BOOL get_varbool_byname(DLLIST * varlist, STRPTR name);
  132. extern BOOL get_varbool(HSCATTR * attr);
  133. extern LONG get_varnum(HSCATTR * attr);
  134. extern LONG get_varnum_byname(DLLIST * varlist, STRPTR name);
  135.  
  136. extern STRPTR get_vardeftext(HSCATTR * var);
  137.  
  138. #endif /* NOEXTERN_HSCLIB_ATTRIBUTE_H */
  139. #endif /* HSCLIB_ATTRIBUTE_H */
  140.  
  141.