home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 310.lha / Rexx_4th / storage.f < prev    next >
Text File  |  1980-12-10  |  11KB  |  240 lines

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