home *** CD-ROM | disk | FTP | other *** search
/ The Fred Fish Collection 1.5 / ffcollection-1-5-1992-11.iso / ff_disks / 200-299 / ff284.lzh / Dme / src / rexx / storage.i < prev   
Text File  |  1989-11-27  |  10KB  |  235 lines

  1. * === rexx/storage.i ===================================================
  2. *
  3. * Copyright (c) 1986, 1987 by William S. Hawes (All Rights Reserved)
  4. *
  5. * ======================================================================
  6. * Include file for REXX data structures and memory/storage management.
  7.  
  8.          IFND REXX_STORAGE_I
  9. REXX_STORAGE_I SET   1
  10.  
  11.          IFND EXEC_TYPES_I
  12.          INCLUDE "exec/types.i"
  13.          ENDC
  14.  
  15.          IFND EXEC_NODES_I
  16.          INCLUDE "exec/nodes.i"
  17.          ENDC
  18.  
  19.          IFND EXEC_LISTS_I
  20.          INCLUDE "exec/lists.i"
  21.          ENDC
  22.  
  23.          IFND EXEC_PORTS_I
  24.          INCLUDE "exec/ports.i"
  25.          ENDC
  26.  
  27.          IFND EXEC_LIBRARIES_I
  28.          INCLUDE "exec/libraries.i"
  29.          ENDC
  30.  
  31. * The NexxStr structure is used to maintain the internal strings in REXX.
  32. * It includes the buffer area for the string and associated attributes.
  33. * This is actually a variable-length structure; it is allocated for a
  34. * specific length string, and the length is never modified thereafter
  35. * (since it's used for recycling).
  36.  
  37.          STRUCTURE NexxStr,0
  38.          LONG     ns_Ivalue            ; integer value
  39.          UWORD    ns_Length            ; length in bytes (excl null byte)
  40.          UBYTE    ns_Flags             ; attribute flags
  41.          UBYTE    ns_Hash              ; sum-of-characters hash code
  42.          STRUCT   ns_Buff,8            ; buffer area for strings
  43.          LABEL    ns_SIZEOF            ; size: 16 bytes (minimum)
  44.  
  45. NXADDLEN EQU      9                    ; structure offset plus null byte
  46. IVALUE   EQU      ns_Ivalue            ; integer value
  47.  
  48. * String attribute flag bit definitions
  49. NSB_KEEP    EQU   0                    ; permanent string? (in Symbol Table)
  50. NSB_STRING  EQU   1                    ; string form valid?
  51. NSB_NOTNUM  EQU   2                    ; non-numeric?
  52. NSB_NUMBER  EQU   3                    ; a valid number?
  53. NSB_BINARY  EQU   4                    ; integer value saved?
  54. NSB_FLOAT   EQU   5                    ; floating point format?
  55. NSB_EXT     EQU   6                    ; an external string?
  56. NSB_SOURCE  EQU   7                    ; part of the program source?
  57.  
  58. * The flag form of the string attributes
  59. NSF_KEEP    EQU   1<<NSB_KEEP
  60. NSF_STRING  EQU   1<<NSB_STRING
  61. NSF_NOTNUM  EQU   1<<NSB_NOTNUM
  62. NSF_NUMBER  EQU   1<<NSB_NUMBER
  63. NSF_BINARY  EQU   1<<NSB_BINARY
  64. NSF_FLOAT   EQU   1<<NSB_FLOAT
  65. NSF_EXT     EQU   1<<NSB_EXT
  66. NSF_SOURCE  EQU   1<<NSB_SOURCE
  67.  
  68. * Combinations of flags 
  69. NSF_INTNUM  EQU   (NSF_NUMBER!NSF_BINARY!NSF_STRING)
  70. NSF_DPNUM   EQU   (NSF_NUMBER!NSF_FLOAT)
  71. NSF_ALPHA   EQU   (NSF_NOTNUM!NSF_STRING)
  72. NSF_OWNED   EQU   (NSF_SOURCE!NSF_EXT!NSF_KEEP)
  73. KEEPSTR     EQU   (NSF_STRING!NSF_SOURCE!NSF_NOTNUM)
  74. KEEPNUM     EQU   (NSF_STRING!NSF_SOURCE!NSF_NUMBER!NSF_BINARY)
  75.  
  76. * The RexxArg structure is identical to the NexxStr structure, but
  77. * is allocated from system memory rather than from internal storage.
  78. * This structure is used for passing arguments to external programs.
  79. * It is usually passed as an "argstring", a pointer to the string buffer.
  80.  
  81.          STRUCTURE RexxArg,0
  82.          LONG     ra_Size              ; total allocated length
  83.          UWORD    ra_Length            ; length of string
  84.          UBYTE    ra_Flags             ; attribute flags
  85.          UBYTE    ra_Hash              ; hash code
  86.          STRUCT   ra_Buff,8            ; buffer area
  87.          LABEL    ra_SIZEOF            ; size: 16 bytes
  88.  
  89. * The RexxMsg structure is used for all communications with Rexx programs.
  90. * It is an EXEC message with a parameter block appended.
  91.  
  92.          STRUCTURE RexxMsg,MN_SIZE
  93.          APTR     rm_TaskBlock         ; pointer to RexxTask structure
  94.          APTR     rm_LibBase           ; library pointer
  95.          LONG     rm_Action            ; command (action) code
  96.          LONG     rm_Result1           ; return code
  97.          LONG     rm_Result2           ; secondary result
  98.          STRUCT   rm_Args,16*4         ; argument block (ARG0-ARG15)
  99.          APTR     rm_PassPort          ; forwarding port
  100.          APTR     rm_CommAddr          ; host address (port name)
  101.          APTR     rm_FileExt           ; file extension
  102.          LONG     rm_Stdin             ; input stream
  103.          LONG     rm_Stdout            ; output stream
  104.          LONG     rm_avail             ; future expansion
  105.          LABEL    rm_SIZEOF            ; size: 128 bytes
  106.  
  107. * Field definitions
  108. ACTION   EQU      rm_Action            ; action code
  109. RESULT1  EQU      rm_Result1           ; primary return/error level
  110. RESULT2  EQU      rm_Result2           ; secondary return/result string
  111. ARG0     EQU      rm_Args              ; start of argblock
  112. ARG1     EQU      rm_Args+4            ; first argument
  113. ARG2     EQU      rm_Args+8            ; second argument
  114.  
  115. MAXRMARG EQU      15                   ; maximum arguments
  116.  
  117. * Command (action) codes for message packets
  118. RXCOMM   EQU      $01000000            ; a command-level invocation
  119. RXFUNC   EQU      $02000000            ; a function call
  120. RXCLOSE  EQU      $03000000            ; close the port
  121. RXQUERY  EQU      $04000000            ; query for information
  122. RXADDFH  EQU      $07000000            ; add a function host
  123. RXADDLIB EQU      $08000000            ; add a function library
  124. RXREMLIB EQU      $09000000            ; remove a function library
  125. RXADDCON EQU      $0A000000            ; add/update a ClipList string
  126. RXREMCON EQU      $0B000000            ; remove a ClipList string
  127. RXTCOPN  EQU      $0C000000            ; open the trace console
  128. RXTCCLS  EQU      $0D000000            ; close the trace console
  129.  
  130. * Command modifier flag bits
  131. RXFB_NOIO   EQU   16                   ; suppress I/O inheritance?
  132. RXFB_RESULT EQU   17                   ; result string expected?
  133. RXFB_STRING EQU   18                   ; program is a "string file"?
  134. RXFB_TOKEN  EQU   19                   ; tokenize the command line?
  135. RXFB_NONRET EQU   20                   ; a "no-return" message?
  136.  
  137. * Modifier flags
  138. RXFF_RESULT EQU   1<<RXFB_RESULT
  139. RXFF_STRING EQU   1<<RXFB_STRING
  140. RXFF_TOKEN  EQU   1<<RXFB_TOKEN
  141. RXFF_NONRET EQU   1<<RXFB_NONRET
  142.  
  143. RXCODEMASK  EQU   $FF000000
  144. RXARGMASK   EQU   $0000000F
  145.  
  146. * The RexxRsrc structure is used to manage global resources.
  147. * The name string for each node is created as a RexxArg structure,
  148. * and the total size of the node is saved in the "rr_Size" field.
  149. * Functions are provided to allocate and release resource nodes.
  150. * If special deletion operations are required, an offset and base can
  151. * be provided in "rr_Func" and "rr_Base", respectively.  This function
  152. * will be called with the base in register A6 and the node in A0.
  153.  
  154.          STRUCTURE RexxRsrc,LN_SIZE
  155.          WORD     rr_Func              ; "auto-delete" offset
  156.          APTR     rr_Base              ; "auto-delete" base
  157.          LONG     rr_Size              ; total size of node
  158.          LONG     rr_Arg1              ; available ...
  159.          LONG     rr_Arg2              ; available ...
  160.          LABEL    rr_SIZEOF            ; size: 32 bytes
  161.  
  162. * Field definitions
  163. RRTYPE   EQU      LN_TYPE              ; node type
  164. RRNAME   EQU      LN_NAME              ; node name (argstring)
  165. RRSIZE   EQU      rr_Size              ; total size of node
  166.  
  167. * Resource node types
  168. RRT_ANY  EQU      0                    ; any node type ...
  169. RRT_LIB  EQU      1                    ; a function library
  170. RRT_PORT EQU      2                    ; a public port
  171. RRT_FILE EQU      3                    ; a file IoBuff
  172. RRT_HOST EQU      4                    ; a function host
  173. RRT_CLIP EQU      5                    ; a Clip List node
  174.  
  175. * The RexxTask structure holds the fields used by REXX to communicate with
  176. * external processes, including the client task.  It includes the global
  177. * data structure (and the base environment).  The structure is passed to
  178. * the newly-created task in its "wake-up" message.
  179.  
  180. GLOBALSZ EQU      200                  ; space for the Global Data structure
  181.  
  182.          STRUCTURE RexxTask,GLOBALSZ   ; global data structure
  183.          STRUCT   rt_MsgPort,MP_SIZE   ; message port
  184.          UBYTE    rt_Flags             ; task flag bits
  185.          BYTE     rt_SigBit            ; signal bit 
  186.  
  187.          APTR     rt_ClientID          ; the client's task ID
  188.          APTR     rt_MsgPkt            ; the packet being processed
  189.          APTR     rt_TaskID            ; our task ID
  190.          APTR     rt_RexxPort          ; the REXX public port
  191.  
  192.          APTR     rt_ErrTrap           ; Error trap address
  193.          APTR     rt_StackPtr          ; stack pointer for traps
  194.  
  195.          STRUCT   rt_Header1,LH_SIZE
  196.          STRUCT   rt_Header2,LH_SIZE
  197.          STRUCT   rt_Header3,LH_SIZE
  198.          STRUCT   rt_Header4,LH_SIZE
  199.          STRUCT   rt_Header5,LH_SIZE
  200.          LABEL    rt_SIZEOF
  201.  
  202. ENVLIST  EQU      rt_Header1           ; environment list (internal)
  203. FREELIST EQU      rt_Header2           ; freelist (internal)
  204. MEMLIST  EQU      rt_Header3           ; allocation list (external)
  205. FILELIST EQU      rt_Header4           ; I/O files list (external)
  206. PORTLIST EQU      rt_Header5           ; message ports list (external)
  207. NUMLISTS EQU      5
  208.  
  209. * Definitions for RexxTask flag bits
  210. RTFB_TRACE  EQU      0                 ; external trace flag
  211. RTFB_HALT   EQU      1                 ; external halt flag
  212. RTFB_SUSP   EQU      2                 ; suspend task?
  213. RTFB_TCUSE  EQU      3                 ; trace console in use?
  214. RTFB_WAIT   EQU      6                 ; waiting for reply?
  215. RTFB_CLOSE  EQU      7                 ; task completed?
  216.  
  217. * Definitions for memory allocation constants
  218. MEMQUANT EQU      16                   ; quantum of memory space
  219. MEMMASK  EQU      $FFFFFFF0            ; mask for rounding the size
  220.  
  221. MEMQUICK EQU      (1<<0)               ; EXEC flags: MEMF_PUBLIC
  222. MEMCLEAR EQU      (1<<16)              ; EXEC flags: MEMF_CLEAR
  223.  
  224. * The SrcNode is a temporary structure used to hold values destined for a
  225. * segment array.  It is also used to maintain the memory freelist.
  226.  
  227.          STRUCTURE SrcNode,0           ; temporary source data structure
  228.          APTR     sn_Succ
  229.          APTR     sn_Pred
  230.          APTR     sn_Ptr               ; pointer value
  231.          LONG     sn_Size              ; size of object
  232.          LABEL    sn_SIZEOF            ; size: 16 bytes
  233.  
  234.          ENDC
  235.