eudora-mac/aeutil.c

1 line
18 KiB
C
Raw Permalink Normal View History

2018-05-23 09:59:15 +00:00
/* Copyright (c) 2017, Computer History Museum All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted (subject to the limitations in the disclaimer below) provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of Computer History Museum nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #define FILE_NUM 65 /* Copyright (c) 1994 by QUALCOMM Incorporated */ #include "aeutil.h" #pragma segment MAEUtil pascal OSErr MyAEIdle(EventRecord *event,long *sleep, RgnHandle *rgn); /********************************************************************** * SimpleAESend - send an AE, without all the crap * psn - the psn to send to * eClass - the event class * eId - the event id * mode - the send mode * varargs parameters come next * keyword - keyword. special are typeNull, keyEuIgnoreDesc, keyEuDesc * for Desc types, next argument is pointer to descriptor * for non-Desc types, next three pointers are type, data, and size * size<0 means argument is real, not pointer * if the keyword is typeNull or keyEuIgnoreDesc, arguments are consumed but not * actually added to the event * nil ends the parameters * then we begin with attributes, with the same scheme **********************************************************************/ OSErr SimpleAESend(ProcessSerialNumber *psn,DescType eClass, DescType eId, AppleEvent *reply,AESendMode mode,...) { AppleEvent ae; AEDesc d; OSErr err; DescType type, key; long size; UPtr arg; UPtr aVal; Boolean attribs = False; va_list args; va_start(args,mode); NullADList(&ae,&d,reply,nil); if (!(err=AECreateDesc(typeProcessSerialNumber,psn,sizeof(*psn),&d))) if (!(err=AECreateAppleEvent(eClass,eId,&d,kAutoGenerateReturnID,kAnyTransactionID,&ae))) { for (key = va_arg(args,DescType);!err && (key||!attribs);key = va_arg(args,DescType)) { if (!key) attribs = True; else { type = va_arg(args,DescType); arg = va_arg(args,void *); if (type==keyEuIgnoreDesc || type==keyEuDesc) { if (type!=keyEuIgnoreDesc) if (arg) err = attribs?AEPutAttributeDesc(&ae,key,(void*)arg):AEPutParamDesc(&ae,key,(void*)arg); else err = paramErr; } else { size = va_arg(args,long); if (size<0) { size = -size; aVal = arg; arg = (void*)&aVal; } if (type!=typeNull) err = attribs?AEPutAttributePtr(&ae,key,type,arg,size):AEPutParamPtr(&ae,key,type,arg,size); } } } } if (!err) err = MyAESend(&ae,reply,mode,kAENormalPriority,GetRLong(AE_TIMEOUT_TICKS)); if (err<0 && err!=-1711) WarnUser(AE_TROUBLE,err); va_end(args); DisposeADList(&ae,&d,nil); return(err); } /************************************************************