landgetparam.c

Go to the documentation of this file.
00001 
00002 /*  $Id: landgetparam.c 1190 2006-04-05 21:16:40Z 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 #include "frontier.h"
00029 #include "standard.h"
00030 
00031 #include "landinternal.h"
00032 
00033 #if TARGET_API_MAC_CARBON == 1 /*PBS 03/14/02: AE OS X fix.*/
00034     #include "aeutils.h" /*PBS 03/14/02: AE OS X fix.*/
00035 #endif
00036 
00037 
00038 
00039 pascal boolean landgetparam (hdlverbrecord hverb, typaramkeyword key, typaramtype type, typaramrecord *param) {
00040     
00041     /*
00042     search the parameters of the verb record for one with the indicated key.
00043     
00044     return the value and type of the parameter, and true if it was found.
00045     
00046     10/29/90 DW: added support for optional params.  the user sets the landglobals
00047     field true if the param is to be optional.  if we don't find one with the
00048     indicated key, we return false to our caller, without returning an error to 
00049     the IAC caller.  the landglobals field must be reset every for every getparam
00050     call.  it's implemented as a global because optional parameters are expected
00051     to be the exception, not the rule -- we don't clutter up our parameter lists
00052     with this boolean.
00053     
00054     10/30/90 DW: if type is notype, we don't care about the type of the parameter,
00055     we just look for a match for the key.
00056     
00057     11/27/90 dmb: the optional parameter field mentioned above is now in the verb 
00058     record, not in landglobals.
00059     */
00060     
00061     register hdlverbrecord hv = hverb;
00062     register boolean fl;
00063     AppleEvent event, reply;
00064     
00065     landsystem7geteventrecords (hv, &event, &reply);
00066     
00067     fl = landsystem7getparam (&event, key, type, param);
00068     
00069     if (!fl) {
00070         
00071         if ((**hv).flnextparamisoptional)
00072             landseterror (noErr);
00073         else
00074             landreturnerror (hv, nosuchparamerror);
00075         }
00076     
00077     (**hv).flnextparamisoptional = false; /*must be reset every time*/
00078     
00079     return (fl);
00080     } /*landgetparam*/
00081 
00082 
00083 pascal boolean landgetnthparam (hdlverbrecord hverb, short n, typaramrecord *param) {
00084     
00085     /*
00086     return the nth parameter in the verb's parameter list.  we return all the info
00087     we have about the parameter in the paramrecord.
00088     
00089     n is 1-based.
00090     
00091     we don't return an error to the caller if the parameter isn't there -- this allows
00092     the caller to sniff around the parameter list without making any assertions.
00093     */
00094     
00095     register hdlverbrecord hv = hverb;
00096     AppleEvent event, reply;
00097     
00098     if (n > (**hv).ctparams) /*there aren't that many parameters*/
00099         return (false);
00100     
00101     landsystem7geteventrecords (hv, &event, &reply);
00102     
00103     return (landsystem7getnthparam (&event, n, param));
00104     } /*landgetnthparam*/
00105 
00106 
00107 pascal boolean landgetintparam (hdlverbrecord hverb, typaramkeyword key, short *x) {
00108     
00109     typaramrecord param;
00110     
00111     if (!landgetparam (hverb, key, inttype, &param)) 
00112         return (false);
00113     
00114     #if TARGET_API_MAC_CARBON == 1 /*PBS 03/14/02: AE OS X fix.*/
00115     
00116         {       
00117         Handle h;
00118         
00119         copydatahandle (&(param.desc), &h);
00120         
00121         *x = **(short **) h;
00122         
00123         disposehandle (h);
00124         }
00125     
00126     #else
00127         
00128         *x = **(short **) param.desc.dataHandle;
00129     
00130     #endif
00131     
00132     landdisposeparamrecord (&param);
00133     
00134     return (true);
00135     } /*landgetintparam*/
00136     
00137 
00138 pascal boolean landgetlongparam (hdlverbrecord hverb, typaramkeyword key, long *x) {
00139     
00140     typaramrecord param;
00141     Handle           theData;
00142     boolean          done = false;
00143 
00144     if (!landgetparam (hverb, key, longtype, &param)) 
00145         return (false);
00146 
00147     /* kw - 2006-02-19 --- don't dereference the nil handle... */
00148 #if TARGET_API_MAC_CARBON == 1 /*PBS 03/14/02: AE OS X fix.*/
00149 
00150     if (copydatahandle (&(param.desc), &theData))
00151     {
00152         lockhandle(theData);
00153 
00154         *x = **(long **) theData;
00155 
00156         unlockhandle(theData);
00157 
00158         disposehandle (theData);
00159 
00160         done = true;
00161     }
00162 #else
00163     done = true;
00164     *x = **(long **) param.desc.dataHandle;
00165 #endif
00166 
00167     landdisposeparamrecord (&param);
00168     
00169     return (done);
00170     } /*landgetlongparam*/
00171     
00172 
00173 pascal boolean landgetstringparam (hdlverbrecord hverb, typaramkeyword key, bigstring x) {
00174     
00175     /*
00176     7/20/92 dmb: always use texttype
00177     */
00178     
00179     typaramrecord param;
00180     
00181     if (!landgetparam (hverb, key, texttype, &param)) 
00182         return (false);
00183     
00184     #if TARGET_API_MAC_CARBON == 1 /*PBS 03/14/02: AE OS X fix.*/
00185     
00186          datahandletostring (&(param.desc), x);
00187     
00188     #else
00189     
00190         texthandletostring (param.desc.dataHandle, x);
00191     
00192     #endif
00193     
00194     landdisposeparamrecord (&param);
00195     
00196     return (true);
00197     } /*landgetstringparam*/
00198 
00199 
00200 pascal boolean landgettextparam (hdlverbrecord hverb, typaramkeyword key, Handle *x) {
00201     
00202     typaramrecord param;
00203     
00204     if (!landgetparam (hverb, key, texttype, &param)) 
00205         return (false);
00206 
00207     #if TARGET_API_MAC_CARBON == 1 /*PBS 03/14/02: AE OS X fix.*/
00208     
00209          copydatahandle (&(param.desc), x);
00210     
00211     #else
00212         
00213         *x = param.desc.dataHandle;
00214     
00215     #endif
00216 
00217     return (true);
00218     } /*landgettextparam*/
00219 
00220 
00221 

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