home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 3 / BBS in a box - Trilogy III.iso / Files / System7 tools / Frontier / Frontier SDK 2.1 / Toolkits / IAC Tools / iacbinary.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-06-09  |  1.8 KB  |  97 lines  |  [TEXT/KAHL]

  1.  
  2. /*© Copyright 1988-1993 UserLand Software, Inc.  All Rights Reserved.*/
  3.  
  4. #include "iacinternal.h"
  5.  
  6.  
  7.  
  8. Boolean IACpushbinaryparam (Handle val, OSType binarytype, OSType keyword) {
  9.  
  10.     return (IACpushbinaryitem (IACglobals.event, val, binarytype, keyword));
  11.     } /*IACpushbinaryparam*/
  12.  
  13.  
  14. Boolean IACreturnbinary (Handle x, OSType binarytype) {
  15.     
  16.     return (IACpushbinaryitem (IACglobals.reply, x, binarytype, keyDirectObject));
  17.     } /*IACreturnbinary*/
  18.     
  19.     
  20. Boolean IACgetbinaryparam (OSType keyword, Handle *hbinary, OSType *binarytype) {
  21.  
  22.     if (!IACgetbinaryitem (IACglobals.event, keyword, hbinary, binarytype)) {
  23.     
  24.         IACparamerror (IACglobals.errorcode, "\pbinary", keyword);
  25.         
  26.         return (false);
  27.         }
  28.  
  29.     IACglobals.nextparamoptional = false; /*must be reset for each param*/
  30.     
  31.     return (true);
  32.     } /*IACgetbinaryparam*/
  33.  
  34.  
  35. Boolean IACgetbinaryitem (AEDescList *list, long n, Handle *val, OSType *binarytype) {
  36.     
  37.     register OSErr ec;
  38.     AEDesc desc;
  39.     DescType key;
  40.     Size actualSize;
  41.     
  42.     if ((*list).descriptorType != typeAEList) {
  43.     
  44.         ec = AEGetKeyDesc (list, n, typeWildCard, &desc);
  45.         
  46.         if (ec != errAEDescNotFound)
  47.             goto done;
  48.         }
  49.  
  50.     ec = AEGetNthDesc (list, n, typeWildCard, &key, &desc);
  51.     
  52.     done:
  53.     
  54.     IACglobals.errorcode = ec;
  55.     
  56.     if (ec == noErr) {
  57.     
  58.         *binarytype = desc.descriptorType;
  59.         
  60.         *val = desc.dataHandle;    
  61.         
  62.         return (true);
  63.         }
  64.     else {
  65.         *binarytype = 0L;
  66.         
  67.         *val = NULL;
  68.         
  69.         return (false);
  70.         }
  71.     } /*IACgetbinaryitem*/
  72.  
  73.  
  74. Boolean IACpushbinaryitem (AEDescList *list, Handle val, OSType binarytype, long n) {
  75.     
  76.     register OSErr ec;
  77.     AEDesc desc;
  78.     
  79.     desc.descriptorType = binarytype;
  80.     
  81.     desc.dataHandle = val;
  82.     
  83.     if ((*list).descriptorType != typeAEList)
  84.         
  85.         ec = AEPutKeyDesc (list, n, &desc);
  86.     else
  87.         ec = AEPutDesc (list, n, &desc);
  88.     
  89.     IACglobals.errorcode = ec;
  90.     
  91.     AEDisposeDesc (&desc);
  92.     
  93.     return (ec == noErr);
  94.     } /*IACpushbinaryitem*/
  95.  
  96.  
  97.