aeutils.c

Go to the documentation of this file.
00001 
00002 /*  $Id: aeutils.c 478 2005-12-15 21:44:05Z karstenw $    */
00003 
00004 /******************************************************************************
00005 
00006     UserLand Frontier(tm) -- High performance Web content management,
00007     object database, system-level and Internet scripting environment,
00008     including source code editing and debugging.
00009 
00010     Copyright (C) 1992-2004 UserLand Software, Inc.
00011 
00012     This program is free software; you can redistribute it and/or modify
00013     it under the terms of the GNU General Public License as published by
00014     the Free Software Foundation; either version 2 of the License, or
00015     (at your option) any later version.
00016 
00017     This program is distributed in the hope that it will be useful,
00018     but WITHOUT ANY WARRANTY; without even the implied warranty of
00019     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00020     GNU General Public License for more details.
00021 
00022     You should have received a copy of the GNU General Public License
00023     along with this program; if not, write to the Free Software
00024     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00025 
00026 ******************************************************************************/
00027 
00028 #if TARGET_API_MAC_CARBON == 1 /*PBS 03/14/02: AE OS X fix.*/
00029 
00030 #include "frontier.h"
00031 #include "standard.h"
00032 
00033 #include "aeutils.h"
00034 #include "memory.h"
00035 
00036 
00037 static boolean getdescdata (AEDesc *desc, Handle *h) {
00038     
00039     /*
00040     PBS 03/14/02: get data from AEDesc's data handle as
00041     a handle. The handle is allocated here. Caller
00042     will dispose of handle, unless this function returns false.
00043     */
00044     
00045     Size len;
00046     
00047     len = AEGetDescDataSize (desc);
00048     
00049 /* kw - 2005-12-12 - we should return at least a zero sized handle
00050     if (len < 1) {
00051         
00052         *h = nil;
00053         
00054         return (false);
00055         }
00056 */
00057     if (!newclearhandle (len, h)) {
00058         
00059         *h = nil;
00060         
00061         return (false);
00062         }
00063     
00064     lockhandle (*h);
00065     
00066     if (AEGetDescData (desc, **h, len) != noErr) {
00067          
00068          disposehandle (*h);
00069          
00070          *h = nil;
00071          
00072          return (false);
00073          } /*if*/
00074     
00075     unlockhandle (*h);
00076     
00077     return (true);
00078     } /*getdescdata*/
00079 
00080 
00081 OSErr putdescdatapointer (AEDesc *desc, DescType typeCode, ptrvoid pvoid, long len) {
00082     
00083     /*
00084     PBS 03/14/02: put data into the datahandle.
00085     */
00086 
00087     return (AEReplaceDescData (typeCode, pvoid, len, desc) == noErr);   
00088     } /*putdescdatapointer*/
00089 
00090 
00091 boolean putdeschandle (AEDesc *desc, DescType typeCode, Handle h) {
00092     
00093     /*
00094     PBS 03/14/02: set a datahandle from a handle.
00095     */
00096 
00097     OSErr err = noErr;
00098     
00099     lockhandle (h);
00100     
00101     err = AEReplaceDescData (typeCode, *h, gethandlesize (h), desc);
00102         
00103     unlockhandle (h);
00104     
00105     return (err != noErr);
00106     } /*putdeschandle*/
00107 
00108 
00109 /*boolean newdescnull (AEDesc *desc) {
00110 
00111     AEInitializeDescInline (desc);
00112     
00113     return (AECreateDesc (typeNull, nil, 0, desc) != noErr);
00114     } #*newdescnull*/
00115 boolean newdescnull (AEDesc *desc, DescType typeCode) {  // MJL 08/12/03: Broken boolean obj spec fix
00116     AEInitializeDescInline (desc);
00117     return (AECreateDesc (typeCode, nil, 0, desc) != noErr);
00118 } /*newdescnull*/
00119 
00120 
00121 boolean nildatahandle (AEDesc *desc) {
00122 
00123     AEInitializeDescInline (desc);
00124     return (true);
00125     //return (AEReplaceDescData (typeNull, nil, 0, desc) == noErr); 
00126     } /*nildatahandle*/
00127     
00128 
00129 boolean newdescwithhandle (AEDesc *desc, DescType typeCode, Handle h) {
00130     
00131     /*
00132     PBS 03/14/02: Create a new AEDesc with the given type and value.
00133     */
00134     
00135     OSErr err = noErr;
00136     long len = gethandlesize (h);
00137     
00138     AEInitializeDescInline (desc);
00139         
00140     if (h == nil)
00141         
00142         err = AECreateDesc (typeCode, nil, 0, desc);
00143         
00144     else {
00145     
00146         lockhandle (h);
00147         
00148         err = AECreateDesc (typeCode, *h, len, desc);
00149 
00150         unlockhandle (h);
00151         } /*else*/
00152     
00153     return (err == noErr);      
00154     } /*newdescwithhandle*/
00155     
00156     
00157 boolean datahandletostring (AEDesc *desc, bigstring bs) {
00158 
00159     /*
00160     PBS 03/14/02: get data from AEDesc's data handle as
00161     a bigstring.
00162     
00163     2002-10-13 AR: Removed variable len to eliminate compiler warning
00164     about unused variables
00165     */
00166 
00167     Handle h;
00168     
00169     if (!getdescdata (desc, &h))
00170         return (false);
00171     
00172     texthandletostring (h, bs);
00173     
00174     disposehandle (h);
00175     
00176     return (true);
00177     } /*datahandletostring*/
00178 
00179 
00180 boolean copydatahandle (AEDesc *desc, Handle *h) {
00181     
00182     /*
00183     PBS 03/14/02: copy the datahandle to another handle.
00184     */
00185     
00186     return (getdescdata (desc, h));
00187     } /*copydatahandle*/
00188 
00189 
00190 #endif

Generated on Wed May 31 18:19:38 2006 for frontierkernel 10.1.10a by  doxygen 1.4.6