home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Programming / Misc / OB3.2D4.DMS / in.adf / Interfaces / Utility.mod < prev    next >
Encoding:
Text File  |  1993-10-24  |  22.7 KB  |  549 lines

  1. (*-------------------------------------------------------------------------*)
  2. (*                                                                         *)
  3. (*  Amiga Oberon Interface Module:                    Date: 24-Oct-93      *)
  4. (*                                                                         *)
  5. (*   © 1993 by Fridtjof Siebert                                            *)
  6. (*   updated for V39 by hartmut Goebel                                     *)
  7. (*                                                                         *)
  8. (*-------------------------------------------------------------------------*)
  9.  
  10. MODULE Utility;
  11.  
  12. (* !!! ATTENTION !!!
  13.  * Before you use any routine of this library, you'll have to check
  14.  * Utility.base#NIL.
  15.  *)
  16.  
  17. IMPORT e * := Exec,
  18.               SYSTEM,
  19.               OberonLib;
  20.  
  21. CONST
  22.   utilityName * = "utility.library";
  23.  
  24. (*****************************************************************************)
  25. TYPE
  26.   ClockDataPtr * = UNTRACED POINTER TO ClockData;
  27.   ClockData * = STRUCT
  28.     sec  * : INTEGER;
  29.     min  * : INTEGER;
  30.     hour * : INTEGER;
  31.     mday * : INTEGER;
  32.     month* : INTEGER;
  33.     year * : INTEGER;
  34.     wday * : INTEGER;
  35.   END;
  36.  
  37.  
  38. (* new standard hook structure *)
  39.   HookPtr * = UNTRACED POINTER TO Hook;
  40.   Hook * = STRUCT (minNode * : e.MinNode)
  41.     entry   * : PROCEDURE(hook{8}: HookPtr;
  42.                           object{10}: e.APTR;
  43.                           message{9}: e.APTR): LONGINT; (* assembler entry point        *)
  44.     subEntry* : PROCEDURE(hook: HookPtr;
  45.                           object: e.APTR;
  46.                           message: e.APTR): LONGINT;    (* often HLL entry point        *)
  47.     data    * : e.APTR;                                 (* owner specific               *)
  48.   END;
  49.  
  50. (* ---- Default Hook-Dispatcher ---- *)
  51. PROCEDURE HookEntry*(hook{8}: HookPtr;               (* $SaveRegs+ $StackChk- *)
  52.                      object{10}: e.APTR;
  53.                      message{9}: e.APTR): LONGINT;
  54. (*
  55.  * Calls haook.subEntry. The contents of A5 have to be stored in hook.data,
  56.  * else A5 would not be set correctly.
  57.  *)
  58.  
  59. BEGIN
  60.   SYSTEM.SETREG(13,hook.data);
  61.   RETURN hook.subEntry(hook,object,message);
  62. END HookEntry;
  63.  
  64.  
  65. PROCEDURE InitHook* (hook: HookPtr;
  66.                      entry: PROCEDURE(hook: HookPtr;
  67.                                       object: e.APTR;
  68.                                       message: e.APTR): LONGINT);
  69. BEGIN
  70.   hook.entry := HookEntry;
  71.   hook.subEntry := entry;
  72.   hook.data := SYSTEM.REG(13);
  73. END InitHook;
  74.  
  75. (*
  76.  * Hook calling conventions:
  77.  *
  78.  * The function pointed to by Hook.h_Entry is called with the following
  79.  * parameters:
  80.  *
  81.  *    A0 - pointer to hook data structure itself
  82.  *    A1 - pointer to parameter structure ("message")
  83.  *    A2 - Hook specific address data ("object")
  84.  *
  85.  * Control will be passed to the routine h_Entry.  For many
  86.  * High-Level Languages (HLL), this will be an assembly language
  87.  * stub which pushes registers on the stack, does other setup,
  88.  * and then calls the function at h_SubEntry.
  89.  *
  90.  * The standard C receiving code is:
  91.  *
  92.  *    HookFunc(struct Hook *hook, APTR object, APTR message)
  93.  *
  94.  * Note that register natural order differs from this convention for C
  95.  * parameter order, which is A0,A2,A1.
  96.  *
  97.  * The assembly language stub for "vanilla" C parameter conventions
  98.  * could be:
  99.  *
  100.  * _hookEntry:
  101.  *    move.l  a1,-(sp)                ; push message packet pointer
  102.  *    move.l  a2,-(sp)                ; push object pointer
  103.  *    move.l  a0,-(sp)                ; push hook pointer
  104.  *    move.l  h_SubEntry(a0),a0       ; fetch C entry point ...
  105.  *    jsr     (a0)                    ; ... and call it
  106.  *    lea     12(sp),sp               ; fix stack
  107.  *    rts
  108.  *
  109.  * With this function as your interface stub, you can write a Hook setup
  110.  * function as:
  111.  *
  112.  * InitHook(struct Hook *hook, ULONG ( *c_function)(), APTR userdata)
  113.  * {
  114.  * ULONG ( *hookEntry)();
  115.  *
  116.  *     hook->h_Entry  = hookEntry;
  117.  *     hook->h_SubEntry = c_function;
  118.  *     hook->h_Data   = userdata;
  119.  * }
  120.  *
  121.  * With a compiler capable of registerized parameters, such as SAS C, you
  122.  * can put the C function in the h_Entry field directly. For example, for
  123.  * SAS C:
  124.  *
  125.  *   ULONG __saveds __asm HookFunc(register __a0 struct Hook *hook,
  126.  *                               register __a2 APTR         object,
  127.  *                               register __a1 APTR         message);
  128.  *
  129.  *)
  130.  
  131. (* ======================================================================= *)
  132. (* ==== TagItem ========================================================== *)
  133. (* ======================================================================= *)
  134. (* Tags are a general mechanism of extensible data arrays for parameter
  135.  * specification and property inquiry. In practice, tags are used in arrays,
  136.  * or chain of arrays.
  137.  *
  138.  *)
  139.  
  140. TYPE
  141.   Tag * = e.APTR;
  142.  
  143.   TagItem * = STRUCT
  144.     tag  * : Tag;     (* identifies the type of data *)
  145.     data * : e.APTR;  (* type-specific data          *)
  146.   END;
  147.  
  148.   TagItemPtr * = UNTRACED POINTER TO TagItem;
  149.   TagListPtr * = UNTRACED POINTER TO ARRAY MAX(INTEGER) OF TagItem;
  150.  
  151. (* Types for 'ARRAY OF TagItem'-Parameters: *)
  152.  
  153.   Tags1  * = ARRAY  1 OF TagItem;
  154.   Tags2  * = ARRAY  2 OF TagItem;
  155.   Tags3  * = ARRAY  3 OF TagItem;
  156.   Tags4  * = ARRAY  4 OF TagItem;
  157.   Tags5  * = ARRAY  5 OF TagItem;
  158.   Tags6  * = ARRAY  6 OF TagItem;
  159.   Tags7  * = ARRAY  7 OF TagItem;
  160.   Tags8  * = ARRAY  8 OF TagItem;
  161.   Tags9  * = ARRAY  9 OF TagItem;
  162.   Tags10 * = ARRAY 10 OF TagItem;
  163.   Tags11 * = ARRAY 11 OF TagItem;
  164.   Tags12 * = ARRAY 12 OF TagItem;
  165.   Tags13 * = ARRAY 13 OF TagItem;
  166.   Tags14 * = ARRAY 14 OF TagItem;
  167.   Tags15 * = ARRAY 15 OF TagItem;
  168.   Tags16 * = ARRAY 16 OF TagItem;
  169.   Tags17 * = ARRAY 17 OF TagItem;
  170.   Tags18 * = ARRAY 18 OF TagItem;
  171.   Tags19 * = ARRAY 19 OF TagItem;
  172.   Tags20 * = ARRAY 20 OF TagItem;
  173.   Tags21 * = ARRAY 21 OF TagItem;
  174.   Tags22 * = ARRAY 22 OF TagItem;
  175.   Tags23 * = ARRAY 23 OF TagItem;
  176.   Tags24 * = ARRAY 24 OF TagItem;
  177.   Tags25 * = ARRAY 25 OF TagItem;
  178.   Tags26 * = ARRAY 26 OF TagItem;
  179.   Tags27 * = ARRAY 27 OF TagItem;
  180.   Tags28 * = ARRAY 28 OF TagItem;
  181.   Tags29 * = ARRAY 29 OF TagItem;
  182.  
  183. CONST
  184. (*****************************************************************************)
  185.  
  186. (* constants for Tag.ti_Tag, system tag values *)
  187.   done   * = 0;    (* terminates array of TagItems. ti_Data unused *)
  188.   end    * = done; (* synonym for TAG_DONE                         *)
  189.   ignore * = 1;    (* ignore this item, not end of array           *)
  190.   more   * = 2;    (* ti_Data is pointer to another array of TagItems
  191.                     * note that this tag terminates the current array
  192.                     *)
  193.   skip   * = 3;    (* skip this and the next TagItem.data items    *)
  194.  
  195. (* Indication of user tag, OR this in with user tag values *)
  196.   user   * = 80000000H;   (* differentiates user tags from system tags*)
  197.  
  198. (* NOTE: Until further notice, tag bits 16-30 are RESERVED and should be zero.
  199.  * Also, the value (user + 0) should never be used as a tag value.
  200.  *)
  201.  
  202. (*****************************************************************************)
  203.  
  204. (* Tag filter logic specifiers for use with FilterTagItems() *)
  205.   filterAnd * = 0;     (* exclude everything but filter hits   *)
  206.   filterNot * = 1;     (* exclude only filter hits             *)
  207.  
  208. (*****************************************************************************)
  209.  
  210. (* Mapping types for use with MapTags() *)
  211.   removeNotFound * = 0;        (* remove tags that aren't in mapList *)
  212.   keepNotFound   * = 1;        (* keep tags that aren't in mapList   *)
  213.  
  214.  
  215. (*****************************************************************************)
  216.  
  217. (* Merging types for use with MergeTagItems() *)
  218.   orList1   * = 0;   (* list 1's item is preferred        *)
  219.   orList2   * = 1;   (* list 2's item is preferred        *)
  220.   andList1  * = 2;   (* item must appear in both lists    *)
  221.   andList2  * = 3;   (* item must appear in both lists    *)
  222.   notList1  * = 4;   (* item must not appear in list 1    *)
  223.   notList2  * = 5;   (* item must not appear in list 2    *)
  224.   xor       * = 6;   (* item must appear in only one list *)
  225.  
  226.  
  227. (*****************************************************************************)
  228. TYPE
  229. (* The named object structure
  230.  * Note how simple this structure is!  You have nothing else that is
  231.  * defined.  Remember that...  Do not hack at the namespaces!!!
  232.  *)
  233.   NamedObjectPtr * = UNTRACED POINTER TO NamedObject;
  234.   NamedObject * = STRUCT
  235.     object * : e.APTR;     (* Your pointer, for whatever you want *)
  236.   END;
  237.  
  238. (* Tags for AllocNamedObjectTags *)
  239. CONST
  240.   nameSpace  * =   4000;    (* Tag to define namespace      *)
  241.   userSpace  * =   4001;    (* tag to define userspace      *)
  242.   priority   * =   4002;    (* tag to define priority       *)
  243.   flags      * =   4003;    (* tag to define flags          *)
  244.  
  245. (* Flags for tag ANO_FLAGS *)
  246.   noDups    * =   0;       (* Default allow duplicates *)
  247.   case      * =   1;       (* Default to caseless... *)
  248.  
  249. (*****************************************************************************)
  250.  
  251.  
  252. (* PackTable definition:
  253.  *
  254.  * The PackTable is a simple array of LONGWORDS that are evaluated by
  255.  * PackStructureTags() and UnpackStructureTags().
  256.  *
  257.  * The table contains compressed information such as the tag offset from
  258.  * the base tag. The tag offset has a limited range so the base tag is
  259.  * defined in the first longword.
  260.  *
  261.  * After the first longword, the fields look as follows:
  262.  *
  263.  *      +--------- 1 = signed, 0 = unsigned (for bits, 1=inverted boolean)
  264.  *      |
  265.  *      |  +------ 00 = Pack/Unpack, 10 = Pack, 01 = Unpack, 11 = special
  266.  *      | / \
  267.  *      | | |  +-- 00 = Byte, 01 = Word, 10 = Long, 11 = Bit
  268.  *      | | | / \
  269.  *      | | | | | /----- For bit operations: 1 = TAG_EXISTS is TRUE
  270.  *      | | | | | |
  271.  *      | | | | | | /-------------------- Tag offset from base tag value
  272.  *      | | | | | | |                 \
  273.  *      m n n o o p q q q q q q q q q q r r r s s s s s s s s s s s s s
  274.  *                                      \   | |               |
  275.  *      Bit offset (for bit operations) ----/ |               |
  276.  *                                            \                       |
  277.  *      Offset into data structure -----------------------------------/
  278.  *
  279.  * A -1 longword signifies that the next longword will be a new base tag
  280.  *
  281.  * A 0 longword signifies that it is the end of the pack table.
  282.  *
  283.  * What this implies is that there are only 13-bits of address offset
  284.  * and 10 bits for tag offsets from the base tag.  For most uses this
  285.  * should be enough, but when this is not, either multiple pack tables
  286.  * or a pack table with extra base tags would be able to do the trick.
  287.  * The goal here was to make the tables small and yet flexible enough to
  288.  * handle most cases.
  289.  *)
  290.  
  291.   signed * = 31;
  292.   unpack * = 30;    (* Note that these are active low... *)
  293.   pack   * = 29;    (* Note that these are active low... *)
  294.   exists * = 26;    (* Tag exists bit true flag hack...  *)
  295.  
  296. (*****************************************************************************)
  297.  
  298.  
  299.   ctrlPackUnpack * = 000000000H;
  300.   ctrlPackOnly   * = 040000000H;
  301.   ctrlUnpackOnly * = 020000000H;
  302.  
  303.   ctrlByte       * = 080000000H;
  304.   ctrlWord       * = 088000000H;
  305.   ctrlLong       * = 090000000H;
  306.  
  307.   ctrlUByte      * = 000000000H;
  308.   ctrlUWord      * = 008000000H;
  309.   ctrlULong      * = 010000000H;
  310.  
  311.   ctrlBit        * = 018000000H;
  312.   ctrlFlipBit    * = 098000000H;
  313.  
  314. (*****************************************************************************)
  315.  
  316. TYPE
  317.   UtilityBasePtr * = UNTRACED POINTER TO UtilityBase;
  318.   UtilityBase * = STRUCT (libNode: e.Library)
  319.     language   * : SHORTINT;
  320.     reserved   * : SHORTINT;
  321.   END;
  322.  
  323. (******************************************************************************)
  324.  
  325. (*
  326.  * Sorry, but since Oberon has no precompiler (this is good) and thuth
  327.  * no macros like in 'C', you this PACK macros can not be translated to
  328.  * Oberon :-(. If you got an idea, how to solve this problen (e.g. you
  329.  * have written a pre-compiler ;-) please contact us:
  330.  * e-mail: amok@oberon.nbg.sub.org
  331.  * snail-mail: see members of AMOK in the compiler manual
  332.  * THANKS!
  333.  *)
  334.  
  335. (* Macros used by the next batch of macros below. Normally, you don't use
  336.  * this batch directly. Then again, some folks are wierd
  337.  *)
  338. (*
  339. #define PK_BITNUM1(flg) ((flg) == 0x01 ? 0 : (flg) == 0x02 ? 1 : (flg) == 0x04 ? 2 : (flg) == 0x08 ? 3 : (flg) == 0x10 ? 4 : (flg) == 0x20 ? 5 : (flg) == 0x40 ? 6 : 7)
  340. #define PK_BITNUM2(flg) ((flg < 0x100 ? PK_BITNUM1(flg) : 8+PK_BITNUM1(flg >> 8)))
  341. #define PK_BITNUM(flg) ((flg < 0x10000 ? PK_BITNUM2(flg) : 16+PK_BITNUM2(flg >> 16)))
  342. #define PK_WORDOFFSET(flg) ((flg) < 0x100 ? 1 : 0)
  343. #define PK_LONGOFFSET(flg) ((flg) < 0x100  ? 3 : (flg) < 0x10000 ? 2 : (flg) < 0x1000000 ? 1 : 0)
  344. #define PK_CALCOFFSET(type,field) ((ULONG)(&((struct type * )0)->field))
  345. *)
  346.  
  347. (*****************************************************************************)
  348.  
  349.  
  350. (* Some handy dandy macros to easily create pack tables
  351.  *
  352.  * Use PACK_STARTTABLE() at the start of a pack table. You pass it the
  353.  * base tag value that will be handled in the following chunk of the pack
  354.  * table.
  355.  *
  356.  * PACK_ENDTABLE() is used to mark the end of a pack table.
  357.  *
  358.  * PACK_NEWOFFSET() lets you change the base tag value used for subsequent
  359.  * entries in the table
  360.  *
  361.  * PACK_ENTRY() lets you define an entry in the pack table. You pass it the
  362.  * base tag value, the tag of interest, the type of the structure to use,
  363.  * the field name in the structure to affect and control bits (combinations of
  364.  * the various PKCTRL_XXX bits)
  365.  *
  366.  * PACK_BYTEBIT() lets you define a bit-control entry in the pack table. You
  367.  * pass it the same data as PACK_ENTRY, plus the flag bit pattern this tag
  368.  * affects. This macro should be used when the field being affected is byte
  369.  * sized.
  370.  *
  371.  * PACK_WORDBIT() lets you define a bit-control entry in the pack table. You
  372.  * pass it the same data as PACK_ENTRY, plus the flag bit pattern this tag
  373.  * affects. This macro should be used when the field being affected is word
  374.  * sized.
  375.  *
  376.  * PACK_LONGBIT() lets you define a bit-control entry in the pack table. You
  377.  * pass it the same data as PACK_ENTRY, plus the flag bit pattern this tag
  378.  * affects. This macro should be used when the field being affected is longword
  379.  * sized.
  380.  *
  381.  * EXAMPLE:
  382.  *
  383.  *    ULONG packTable[] =
  384.  *    {
  385.  *         PACK_STARTTABLE(GA_Dummy),
  386.  *         PACK_ENTRY(GA_Dummy,GA_Left,Gadget,LeftEdge,PKCTRL_WORD|PKCTRL_PACKUNPACK),
  387.  *         PACK_ENTRY(GA_Dummy,GA_Top,Gadget,TopEdge,PKCTRL_WORD|PKCTRL_PACKUNPACK),
  388.  *         PACK_ENTRY(GA_Dummy,GA_Width,Gadget,Width,PKCTRL_UWORD|PKCTRL_PACKUNPACK),
  389.  *         PACK_ENTRY(GA_Dummy,GA_Height,Gadget,Height,PKCTRL_UWORD|PKCTRL_PACKUNPACK),
  390.  *         PACK_WORDBIT(GA_Dummy,GA_RelVerify,Gadget,Activation,PKCTRL_BIT|PKCTRL_PACKUNPACK,GACT_RELVERIFY)
  391.  *         PACK_ENDTABLE
  392.  *    };
  393.  *)
  394. (*
  395. #define PACK_STARTTABLE(tagbase)                           (tagbase)
  396. #define PACK_NEWOFFSET(tagbase)                            (-1L),(tagbase)
  397. #define PACK_ENDTABLE                                      0
  398. #define PACK_ENTRY(tagbase,tag,type,field,control)         (control | ((tag-tagbase) << 16L) | PK_CALCOFFSET(type,field))
  399. #define PACK_BYTEBIT(tagbase,tag,type,field,control,flags) (control | ((tag-tagbase) << 16L) | PK_CALCOFFSET(type,field) | (PK_BITNUM(flags) << 13L))
  400. #define PACK_WORDBIT(tagbase,tag,type,field,control,flags) (control | ((tag-tagbase) << 16L) | (PK_CALCOFFSET(type,field)+PK_WORDOFFSET(flags)) | ((PK_BITNUM(flags)&7) << 13L))
  401. #define PACK_LONGBIT(tagbase,tag,type,field,control,flags) (control | ((tag-tagbase) << 16L) | (PK_CALCOFFSET(type,field)+PK_LONGOFFSET(flags)) | ((PK_BITNUM(flags)&7) << 13L))
  402.  *)
  403.  
  404. (*****************************************************************************)
  405.  
  406. VAR
  407.   base * : UtilityBasePtr;
  408.  
  409.  
  410. (* $OvflChk- $RangeChk- $StackChk- $NilChk- $ReturnChk- $CaseChk- *)
  411.  
  412.  
  413. (*--- functions in V36 or higher (distributed as Release 2.0) ---*)
  414.  
  415. (* Tag item functions *)
  416.  
  417. PROCEDURE FindTagItemA    *{base,- 30}(tagVar{0}      : Tag;
  418.                                        tagList{8}     : ARRAY OF TagItem): TagItemPtr;
  419. PROCEDURE FindTagItem     *{base,- 30}(tagVar{0}      : Tag;
  420.                                        tags{8}        : e.APTR): TagItemPtr;
  421. PROCEDURE GetTagDataA     *{base,- 36}(tagVal{0}      : Tag;
  422.                                        defaultValue{1}: LONGINT;
  423.                                        tagList{8}     : ARRAY OF TagItem): LONGINT;
  424. PROCEDURE GetTagData      *{base,- 36}(tagVal{0}      : Tag;
  425.                                        defaultValue{1}: LONGINT;
  426.                                        tags{8}        : e.APTR): LONGINT;
  427. PROCEDURE PackBoolTagsA   *{base,- 42}(initialFlags{0}: LONGSET;
  428.                                        tagList{8}     : ARRAY OF TagItem;
  429.                                        boolMap{9}     : ARRAY OF TagItem): LONGSET;
  430. PROCEDURE PackBoolTags    *{base,- 42}(initialFlags{0}: LONGSET;
  431.                                        taga{8}        : e.APTR;
  432.                                        boolMap{9}     : ARRAY OF TagItem): LONGSET;
  433. PROCEDURE NextTagItem     *{base,- 48}(VAR tagListPtr{8}: TagItemPtr): TagItemPtr;
  434. PROCEDURE FilterTagChanges*{base,- 54}(changeList{8}  : ARRAY OF TagItem;
  435.                                        originalList{9}: ARRAY OF TagItem;
  436.                                        apply{0}       : BOOLEAN);
  437. PROCEDURE MapTags         *{base,- 60}(tagList{8}     : ARRAY OF TagItem;
  438.                                        mapList{9}     : ARRAY OF TagItem;
  439.                                        mapType{0}     : LONGINT);
  440. PROCEDURE AllocateTagItems*{base,- 66}(numTags{0}     : LONGINT): TagListPtr;
  441. PROCEDURE CloneTagItemsA  *{base,- 72}(tagList{8}     : ARRAY OF TagItem): TagListPtr;
  442. PROCEDURE CloneTagItems   *{base,- 72}(tagList{8}..   : Tag): TagListPtr;
  443. PROCEDURE FreeTagItems    *{base,- 78}(tagList{8}     : TagListPtr);
  444. PROCEDURE RefreshTagItemClones*{base,- 84}(clone{8}   : ARRAY OF TagItem;
  445.                                        original{9}    : ARRAY OF TagItem);
  446. PROCEDURE TagInArrayA     *{base,- 90}(tagValue{0}    : Tag;
  447.                                        tagArray{8}    : ARRAY OF TagItem): BOOLEAN;
  448. PROCEDURE TagInArray      *{base,- 90}(tagValue{0}    : Tag;
  449.                                        tags{8}        : e.APTR): BOOLEAN;
  450. PROCEDURE FilterTagItems  *{base,- 96}(tagList{8}     : ARRAY OF TagItem;
  451.                                        filterArray{9} : ARRAY OF TagItem;
  452.                                        logic{0}       : LONGINT): LONGINT;
  453.  
  454. (* HOOK FUNCTIONS *)
  455.  
  456. PROCEDURE CallHookPkt     *{base,-102}(hook{8}        : HookPtr;
  457.                                        object{10}     : e.ADDRESS;
  458.                                        paramPacket{9} : e.ADDRESS): LONGINT;
  459.  
  460. (* DATE FUNCTIONS *)
  461.  
  462. PROCEDURE Amiga2Date      *{base,-120}(seconds{0}     : LONGINT;
  463.                                        VAR date{8}    : ClockData);
  464. PROCEDURE Date2Amiga      *{base,-126}(VAR date{8}    : ClockData): LONGINT;
  465. PROCEDURE CheckDate       *{base,-132}(VAR date{8}    : ClockData): LONGINT;
  466.  
  467. (* 32 bit integer muliply functions *)
  468.  
  469. PROCEDURE SMult32         *{base,-138}(factor1{0},  factor2{0} : LONGINT): LONGINT;
  470. PROCEDURE UMult32         *{base,-144}(factor1{0},  factor2{0} : LONGINT): LONGINT;
  471.  
  472. (* 32 bit integer division funtions. The quotient and the remainder are *)
  473. (* returned respectively in d0 and d1 *)
  474.  
  475. PROCEDURE SDivMod32       *{base,-150}(dividend{0}, divisor{1} : LONGINT): LONGINT;
  476. PROCEDURE UDivMod32       *{base,-156}(dividend{0}, divisor{1} : LONGINT): LONGINT;
  477.  
  478. (*--- functions in V37 or higher (distributed as Release 2.04) ---*)
  479.  
  480. (* International string routines *)
  481.  
  482. PROCEDURE Stricmp         *{base,-162}(string1{8}: ARRAY OF CHAR;
  483.                                        string2{9}: ARRAY OF CHAR): LONGINT;
  484. PROCEDURE Strnicmp        *{base,-168}(string1{8}: ARRAY OF CHAR;
  485.                                        string2{9}: ARRAY OF CHAR;
  486.                                        length{0}: LONGINT): LONGINT;
  487. PROCEDURE ToUpper         *{base,-174}(character{0}: CHAR): CHAR;
  488. PROCEDURE ToLower         *{base,-180}(character{0}: CHAR): CHAR;
  489.  
  490. (*--- functions in V39 or higher (beta release for developers only) ---*)
  491.  
  492. (* More tag Item functions *)
  493.  
  494. PROCEDURE ApplyTagChangesA*{base,-0BAH}(list{8}          : ARRAY OF TagItem;
  495.                                         changeList{9}    : ARRAY OF TagItem);
  496. PROCEDURE ApplyTagChanges *{base,-0BAH}(list{8}          : ARRAY OF TagItem;
  497.                                         changeList{9}    : e.APTR);
  498.  
  499. (* 64 bit integer muliply functions. The results are 64 bit quantities *)
  500. (* returned in D0 and D1 *)
  501.  
  502. PROCEDURE SMult64         *{base,-0C6H}(arg1{0}: LONGINT; arg2{1}: LONGINT): LONGINT;
  503. PROCEDURE UMult64         *{base,-0CCH}(arg1{0}: LONGINT; arg2{1}: LONGINT): LONGINT;
  504.  
  505. (* Structure to Tag and Tag to Structure support routines *)
  506.  
  507. PROCEDURE PackStructureTagsA  *{base,-0D2H}(pack{8}      : e.APTR;
  508.                                             packTable{9} : ARRAY OF LONGINT;
  509.                                             tagList{10}  : ARRAY OF TagItem): LONGINT;
  510. PROCEDURE PackStructureTags   *{base,-0D2H}(pack{8}      : e.APTR;
  511.                                             packTable{9} : ARRAY OF LONGINT;
  512.                                             tagList{10}  : e.APTR): LONGINT;
  513. PROCEDURE UnpackStructureTagsA*{base,-0D8H}(pack{8}      : e.APTR;
  514.                                             packTable{9} : ARRAY OF LONGINT;
  515.                                             tagList{10}  : ARRAY OF TagItem): LONGINT;
  516. PROCEDURE UnpackStructureTags *{base,-0D8H}(pack{8}      : e.APTR;
  517.                                             packTable{9} : ARRAY OF LONGINT;
  518.                                             tagList{10}  : e.APTR): LONGINT;
  519.  
  520. (* New, object-oriented NameSpaces *)
  521.  
  522. PROCEDURE AddNamedObject  *{base,-0DEH}(nameSpace{8}   : NamedObjectPtr;
  523.                                         object{9}      : NamedObjectPtr): BOOLEAN;
  524. PROCEDURE AllocNamedObjectA *{base,-0E4H}(name{8}      : ARRAY OF CHAR;
  525.                                           tags{9}      : ARRAY OF TagItem): NamedObjectPtr;
  526. PROCEDURE AllocNamedObject  *{base,-0E4H}(name{8}      : ARRAY OF CHAR;
  527.                                           tag1{9}..    : Tag): NamedObjectPtr;
  528. PROCEDURE AttemptRemNamedObject*{base,-0EAH}( object{8}: NamedObjectPtr): BOOLEAN;
  529. PROCEDURE FindNamedObject  *{base,-0F0H}(nameSpace{8}  : NamedObjectPtr;
  530.                                          name{9}       : ARRAY OF CHAR;
  531.                                          lastobject{10}: NamedObjectPtr): NamedObjectPtr;
  532. PROCEDURE FreeNamedObject *{base,-0F6H}(object{8}      : NamedObjectPtr);
  533. PROCEDURE NamedObjectName *{base,-0FCH}(object{8}      : NamedObjectPtr): e.STRPTR;
  534. PROCEDURE ReleaseNamedObject*{base,-102H}(object{8}    : NamedObjectPtr);
  535. PROCEDURE RemNamedObject  *{base,-108H}(object{8}      : NamedObjectPtr;
  536.                                         message{9}     : e.MessagePtr);
  537.  
  538. (* Unique ID generator *)
  539.  
  540. PROCEDURE GetUniqueID     *{base,-10EH}(): LONGINT;
  541.  
  542. BEGIN
  543.   base :=  e.OpenLibrary(utilityName,37);
  544. CLOSE
  545.   IF base#NIL THEN e.CloseLibrary(base) END;
  546.  
  547. END Utility.
  548.  
  549.