langpack.c

Go to the documentation of this file.
00001 
00002 /*  $Id: langpack.c 1316 2006-04-20 20:06:19Z andreradke $    */
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 "memory.h"
00032 #include "strings.h"
00033 #include "cursor.h"
00034 #include "ops.h"
00035 #include "quickdraw.h"
00036 #include "oplist.h"
00037 #include "shell.h"
00038 #include "lang.h"
00039 #include "langinternal.h"
00040 #include "langexternal.h"
00041 #include "langsystem7.h"
00042 #include "tablestructure.h"
00043 #include "byteorder.h"  /* 2006-04-08 aradke: endianness conversion macros */
00044 
00045 
00046 
00047 #define ctsigbytes 19 /*length of string + 1 byte for length*/
00048 
00049 #define signaturestring (ptrstring) "\x12" "packed binary data"
00050 
00051 
00052 typedef struct tyoldpackedvalue {
00053     
00054     byte sigbytes [ctsigbytes]; /*a signature -- keeps errors from causing crashes*/
00055     
00056     tyvaluetype valuetype;
00057     
00058     /*depending on type, any number of bytes following contain the value data*/
00059     } tyoldpackedvalue, *ptroldpackedvalue, **hdloldpackedvalue;
00060 
00061 
00062 typedef struct typackedvalue {
00063     
00064     OSType typeid;
00065     
00066     /*depending on type, any number of bytes following contain the value data*/
00067     } typackedvalue, *ptrpackedvalue, **hdlpackedvalue;
00068 
00069 /*
00070 
00071 static hdlpackedvalue hpackedvalue; //6.2a13 AR: eliminated for better thread-safety
00072 
00073 static long ixunpack; //6.2a13 AR: eliminated for better thread-safety
00074 
00075 static boolean floldformat; //6.2a13 AR: eliminated for better thread-safety
00076 */
00077 
00078 
00079 static boolean langpackdata (long lendata, ptrvoid pdata, hdlpackedvalue hpackedvalue) {
00080     
00081     return (enlargehandle ((Handle) hpackedvalue, lendata, pdata));
00082     } /*langpackdata*/
00083 
00084 
00085 static boolean langpackhandle (Handle hdata, hdlpackedvalue hpackedvalue) {
00086 
00087     boolean fl;
00088 
00089     if (hdata == nil)
00090         return (true);
00091     
00092     lockhandle (hdata);
00093     
00094     fl = langpackdata (gethandlesize (hdata), *hdata, hpackedvalue);
00095     
00096     unlockhandle (hdata);
00097 
00098     return (fl);
00099     } /*langpackhandle*/
00100 
00101 
00102 boolean langpackvalue (tyvaluerecord val, Handle *h, hdlhashnode hnode) {
00103     
00104     /*
00105     4/8/93 dmb: save/restore hdlpackedvalue to allow reentrancy needed for code values
00106     
00107     5.0.2b10 dmb: don't disable langerror when getting an address path.
00108     
00109     2006-04-20 sethdill & aradke: convert rgb values from native byte order to big-endian
00110     */
00111     
00112     register boolean fl;
00113     typackedvalue header;
00114     hdlpackedvalue hpackedvalue;
00115     Handle hdata;
00116     
00117     /*
00118     copystring (signaturestring, header.sigbytes); /%prevents crashes on bad data%/
00119     
00120     header.valuetype = val.valuetype;
00121     */
00122     
00123     header.typeid = langexternalgettypeid (val);
00124     
00125     memtodisklong (header.typeid);
00126 
00127     if (!newfilledhandle (&header, sizeof (header), (Handle *) &hpackedvalue))
00128         return (false);
00129     
00130     switch (val.valuetype) {
00131     
00132         case novaluetype:
00133             fl = true; /*nothing to pack*/
00134             
00135             break;
00136         
00137         case booleanvaluetype:
00138             fl = langpackdata (sizeof (val.data.flvalue), &val.data.flvalue, hpackedvalue);
00139             
00140             break;
00141         
00142         case charvaluetype:
00143         case directionvaluetype:
00144             fl = langpackdata (sizeof (val.data.chvalue), &val.data.chvalue, hpackedvalue);
00145             
00146             break;
00147         
00148         case intvaluetype:
00149         case tokenvaluetype:
00150             memtodiskshort (val.data.intvalue);
00151 
00152             fl = langpackdata (sizeof (val.data.intvalue), &val.data.intvalue, hpackedvalue);
00153             
00154             break;
00155         
00156         case longvaluetype:
00157         case ostypevaluetype:
00158         case enumvaluetype:
00159         case fixedvaluetype:
00160             memtodisklong (val.data.longvalue);
00161 
00162             fl = langpackdata (sizeof (val.data.longvalue), &val.data.longvalue, hpackedvalue);
00163             
00164             break;
00165         
00166         case pointvaluetype:
00167             memtodiskshort (val.data.pointvalue.h);
00168             memtodiskshort (val.data.pointvalue.v);
00169 
00170             fl = langpackdata (sizeof (val.data.pointvalue), &val.data.pointvalue, hpackedvalue);
00171             
00172             break;
00173         
00174         case datevaluetype:
00175             memtodisklong (val.data.longvalue);
00176 
00177             fl = langpackdata (sizeof (val.data.datevalue), &val.data.datevalue, hpackedvalue);
00178             
00179             break;
00180         
00181         case addressvaluetype: {
00182             bigstring bs;
00183             
00184             /*
00185             copyheapstring (val.data.addressvalue, bs);
00186             */
00187             
00188         //  disablelangerror ();
00189             
00190             fl = getaddresspath (val, bs);
00191             
00192         //  enablelangerror ();
00193             
00194             if (!fl)
00195                 break;
00196             
00197             fl = langpackdata ((long) stringlength (bs), bs + 1, hpackedvalue);
00198             
00199             break;
00200             }
00201         
00202         case singlevaluetype:
00203             // ??? need swapping ???
00204             fl = langpackdata (sizeof (val.data.singlevalue), &val.data.singlevalue, hpackedvalue);
00205             
00206             break;
00207         
00208         case rectvaluetype: {
00209             diskrect rdisk;
00210              
00211             recttodiskrect (*val.data.rectvalue, &rdisk);
00212             
00213             fl = langpackdata (sizeof (rdisk), &rdisk, hpackedvalue);
00214             
00215             break;
00216             }
00217         
00218         case rgbvaluetype: {    /* 2006-04-20 sethdill & aradke */
00219             diskrgb rgbdiskk;
00220              
00221             rgbtodiskrgb (*val.data.rgbvalue, &rgbdiskk);
00222             
00223             fl = langpackdata (sizeof (rgbdiskk), &rgbdiskk, hpackedvalue);
00224             
00225             break;
00226             }
00227         
00228         #if noextended
00229         
00230             case doublevaluetype: {
00231                 long double x = **val.data.doublevalue;
00232                 extended80 x80;
00233                  
00234                 #ifdef WIN95VERSION
00235                     convertToMacExtended (x, &x80);
00236                 #else
00237                     safeldtox80 (&x, &x80);
00238                 #endif      
00239                                      
00240                 fl = langpackdata (sizeof (x80), &x80, hpackedvalue);
00241                 
00242                 break;
00243                 }
00244         #else
00245         
00246             case doublevaluetype:
00247             
00248         #endif
00249         
00250         case stringvaluetype:
00251         case passwordvaluetype:
00252         case patternvaluetype:
00253         case objspecvaluetype:
00254     #ifndef version5orgreater
00255         case filespecvaluetype:
00256         case aliasvaluetype:
00257     #endif
00258     #ifndef oplanglists
00259         case listvaluetype:
00260         case recordvaluetype:
00261     #endif
00262         case binaryvaluetype:
00263             fl = langpackhandle (val.data.binaryvalue, hpackedvalue);
00264             
00265             break;
00266         
00267     #ifdef oplanglists
00268         case listvaluetype:
00269         case recordvaluetype:
00270             fl = oppacklist (val.data.listvalue, &hdata);
00271             
00272             if (!fl)
00273                 break;
00274             
00275             fl = langpackhandle (hdata, hpackedvalue);
00276             
00277             disposehandle (hdata);
00278 
00279             break;
00280     #endif
00281     
00282     #ifdef version5orgreater
00283         case filespecvaluetype:
00284         case aliasvaluetype:
00285             fl = langpackfileval (&val, &hdata);
00286             
00287             if (!fl)
00288                 break;
00289             
00290             langpackhandle (hdata, hpackedvalue);
00291             
00292             disposehandle (hdata);
00293             
00294             break;
00295     #endif
00296 
00297         case codevaluetype:
00298             fl = langpacktree (val.data.codevalue, &hdata);
00299             
00300             if (!fl)
00301                 break;
00302             
00303             langpackhandle (hdata, hpackedvalue);
00304             
00305             disposehandle (hdata);
00306             
00307             break;
00308         
00309         case externalvaluetype: {
00310             register Handle lh = val.data.externalvalue;
00311             Handle hpacked;
00312             
00313             initbeachball (left);
00314             
00315             fl = langexternalmemorypack ((hdlexternalvariable) lh, &hpacked, hnode);
00316             
00317             if (!fl)
00318                 break;
00319             
00320             langpackhandle (hpacked, hpackedvalue);
00321             
00322             disposehandle (hpacked);
00323             
00324             break;
00325             }
00326         
00327         default:
00328             langerror (cantpackerror);
00329             
00330             fl = false;
00331             
00332             break;  
00333         } /*switch*/
00334     
00335     if (fl)
00336         *h = (Handle) hpackedvalue;
00337     else
00338         disposehandle ((Handle) hpackedvalue);
00339     
00340     return (fl);
00341     } /*langpackvalue*/
00342 
00343 
00344 boolean langpackverb (hdltreenode hparam1, tyvaluerecord *vreturned) {
00345     
00346     tyvaluerecord val;
00347     register boolean fl;
00348     hdlhashtable htable;
00349     bigstring bsvarname;
00350     Handle hpacked;
00351     
00352     setbooleanvalue (false, vreturned); /*default returned value of verb*/
00353         
00354     if (!getparamvalue (hparam1, 1, &val)) /*the value to be packed*/
00355         return (false);
00356     
00357     flnextparamislast = true;
00358     
00359     if (!getvarparam (hparam1, 2, &htable, bsvarname)) /*the place to put the binary value*/
00360         return (false);
00361     
00362     if (!langpackvalue (val, &hpacked, HNoNode))
00363         return (false);
00364     
00365     fl = langsetbinaryval (htable, bsvarname, hpacked);
00366     
00367     (*vreturned).data.flvalue = fl;
00368     
00369     return (fl);
00370     } /*langpackverb*/
00371 
00372 
00373 boolean langpackwindowverb (hdltreenode hparam1, tyvaluerecord *vreturned) {
00374     
00375     /*
00376     6.16.97 dmb: new verb for standalone window handling.
00377     */
00378     
00379     hdlwindowinfo hinfo;
00380     tyvaluerecord val;
00381     register boolean fl;
00382     hdlhashtable htable;
00383     bigstring bsvarname;
00384     Handle hpacked;
00385     Handle x;
00386     
00387     
00388     setbooleanvalue (false, vreturned); /*default returned value of verb*/
00389     
00390     if (!getwinparam (hparam1, 1, &hinfo)) /*the value to be packed*/
00391         return (false);
00392     
00393     flnextparamislast = true;
00394     
00395     if (!getvarparam (hparam1, 2, &htable, bsvarname)) /*the place to put the binary value*/
00396         return (false);
00397     
00398     if (hinfo == nil) {
00399         
00400         langparamerror (badwindowerror, BIGSTRING ("\x04" "pack"));
00401         
00402         return (false);
00403         }
00404     
00405     if (!shellgetexternaldata (hinfo, &x))
00406         return (false);
00407     
00408     setexternalvalue (x, &val);
00409     
00410     if (!langpackvalue (val, &hpacked, HNoNode))
00411         return (false);
00412     
00413     fl = langsetbinaryval (htable, bsvarname, hpacked);
00414     
00415     (*vreturned).data.flvalue = fl;
00416     
00417     return (fl);
00418     } /*langpackwindowverb*/
00419 
00420 
00421 static boolean langunpackdata (long lendata, ptrvoid pdata, hdlpackedvalue hpackedvalue, long* ptrixunpack) {
00422     
00423     return (loadfromhandle ((Handle) hpackedvalue, ptrixunpack, lendata, pdata));
00424     } /*langunpackdata*/
00425 
00426 
00427 static boolean langunpackstring (hdlstring *hstring, hdlpackedvalue hpackedvalue, long* ptrixunpack) {
00428     
00429     register Handle h = (Handle) hpackedvalue;
00430     register long len;
00431     bigstring bs;
00432             
00433     if (!loadfromhandle (h, ptrixunpack, (long) 1, bs)) /*get string length*/
00434         return (false);
00435     
00436     len = (long) stringlength (bs);
00437     
00438     if (len > 0)
00439         if (!loadfromhandle (h, ptrixunpack, len, &bs [1]))
00440             return (false);
00441     
00442     return (newheapstring (bs, hstring));
00443     } /*langunpackstring*/
00444 
00445 
00446 static boolean langunpackhandle (boolean fltemp, Handle *hbinary, hdlpackedvalue hpackedvalue, long *ptrixunpack) {
00447     
00448     /*
00449     load all the bytes following the header into the handle.
00450     */
00451     
00452     register Handle h = (Handle) hpackedvalue;
00453     register long ctbytes;
00454     
00455     ctbytes = gethandlesize (h) - *ptrixunpack;
00456     
00457     return (loadfromhandletohandle (h, ptrixunpack, ctbytes, fltemp, hbinary));
00458     } /*langunpackhandle*/
00459 
00460 
00461 static boolean langunpackexternal (hdlexternalhandle *hexternal, hdlpackedvalue hpackedvalue, long *ptrixunpack) {
00462     
00463     register boolean fl;
00464     Handle hpacked;
00465     
00466     if (!langunpackhandle (true, &hpacked, hpackedvalue, ptrixunpack))
00467         return (false);
00468     
00469     initbeachball (right);
00470     
00471     fl = langexternalmemoryunpack (hpacked, hexternal);
00472     
00473     disposehandle (hpacked);
00474     
00475     return (fl);
00476     } /*langunpackexternal*/
00477 
00478 
00479 static boolean langunpackoldheader (tyvaluetype *valuetype, hdlpackedvalue hpackedvalue, long *ptrixunpack) {
00480     
00481     long ixorig = *ptrixunpack;
00482     tyoldpackedvalue oldheader;
00483     
00484     if (!langunpackdata (sizeof (oldheader), &oldheader, hpackedvalue, ptrixunpack))
00485         return (false);
00486     
00487     if (!equalstrings (oldheader.sigbytes, signaturestring)) {
00488         
00489         *ptrixunpack = ixorig; /*restore*/
00490         
00491         return (false);
00492         }
00493     
00494     *valuetype = oldheader.valuetype;
00495     
00496     return (true);
00497     } /*langunpackoldheader*/
00498 
00499 
00500 boolean langunpackvalue (Handle hpacked, tyvaluerecord *val) {
00501     
00502     /*
00503     6/4/91 dmb: new header is just type id, but retain backward compatibility.
00504     
00505     4/8/93 dmb: save/restore hdlpackedvalue to allow reentrancy needed for code values
00506     
00507     5.0.2b3 dmb: unpacking addresses, if stringtoaddress fails, set valuetype to string
00508     
00509     2006-04-20 sethdill & aradke: convert rgb values to native byte order
00510     */
00511     
00512     tyvaluerecord v;
00513     register hdlpackedvalue h;
00514     boolean fl, flpush;
00515     typackedvalue header;
00516     Handle hdata;
00517     long ixunpack = 0;
00518     
00519     initvalue (&v, novaluetype);
00520     
00521     h = (hdlpackedvalue) hpacked; /*copy into register*/
00522     
00523     if (langunpackoldheader (&v.valuetype, h, &ixunpack))
00524         goto unpack;
00525     
00526     if (!langunpackdata (sizeof (header), &header, h, &ixunpack))
00527         goto formaterror;
00528     
00529     disktomemlong (header.typeid);
00530 
00531     v.valuetype = langexternalgetvaluetype (header.typeid);
00532     
00533     langunpackoldheader (&v.valuetype, h, &ixunpack); /*may have added new header before old*/
00534     
00535 unpack:
00536     
00537     switch (v.valuetype) {
00538     
00539         case novaluetype:
00540             fl = true; /*nothing to unpack*/
00541             
00542             break;
00543         
00544         case booleanvaluetype:
00545             fl = langunpackdata (sizeof (v.data.flvalue), &v.data.flvalue, h, &ixunpack);
00546             
00547             break;
00548             
00549         case charvaluetype:
00550         case directionvaluetype:
00551             fl = langunpackdata (sizeof (v.data.chvalue), &v.data.chvalue, h, &ixunpack);
00552             
00553             break;
00554         
00555         case intvaluetype:
00556         case tokenvaluetype:
00557             fl = langunpackdata (sizeof (v.data.intvalue), &v.data.intvalue, h, &ixunpack);
00558             
00559             disktomemshort (v.data.intvalue);
00560             break;
00561         
00562         case longvaluetype:
00563         case ostypevaluetype:
00564         case enumvaluetype:
00565         case fixedvaluetype:
00566             fl = langunpackdata (sizeof (v.data.longvalue), &v.data.longvalue, h, &ixunpack);
00567             
00568             disktomemlong (v.data.longvalue);
00569             break;
00570         
00571         case pointvaluetype:
00572             fl = langunpackdata (sizeof (v.data.pointvalue), &v.data.pointvalue, h, &ixunpack);
00573             
00574             disktomemshort (v.data.pointvalue.h);
00575             disktomemshort (v.data.pointvalue.v);
00576             break;
00577         
00578         case datevaluetype:
00579             fl = langunpackdata (sizeof (v.data.datevalue), &v.data.datevalue, h, &ixunpack);
00580             
00581             disktomemlong (v.data.datevalue);
00582             break;
00583         
00584         case singlevaluetype:
00585             fl = langunpackdata (sizeof (v.data.singlevalue), &v.data.singlevalue, h, &ixunpack);
00586             // ??? need swapping ???
00587             
00588             break;
00589         
00590         case oldstringvaluetype: 
00591             fl = langunpackstring ((hdlstring *) &v.data.stringvalue, h, &ixunpack);
00592             
00593             if (fl)
00594                 pullfromhandle (v.data.stringvalue, 0, 1, nil); /*shed length byte*/
00595             
00596             break;
00597         
00598         case addressvaluetype:
00599             fl = langunpackhandle (false, &v.data.stringvalue, h, &ixunpack);
00600             
00601             if (!fl)
00602                 break;
00603             
00604             flpush = (currenthashtable == nil);
00605             
00606             if (flpush)
00607                 flpush = pushhashtable (roottable);
00608             
00609             if (stringtoaddress (&v))
00610                 exemptfromtmpstack (&v);
00611             else
00612                 v.valuetype = stringvaluetype;
00613             
00614             if (flpush)
00615                 pophashtable ();
00616             
00617             break;
00618         
00619         case rectvaluetype: {
00620             Rect r;
00621             diskrect rdisk;
00622              
00623             fl = langunpackdata (sizeof (rdisk), &rdisk, h, &ixunpack);
00624             
00625             if (fl) {
00626                 
00627                 diskrecttorect (&rdisk, &r);
00628                 
00629                 fl = newheapvalue (&r, sizeof (r), rectvaluetype, &v);
00630                 
00631                 if (fl)
00632                     exemptfromtmpstack (&v);
00633                 }
00634             
00635             break;
00636             }
00637         
00638         case rgbvaluetype: { /* 2006-04-20 sethdill & aradke */
00639             RGBColor rgb;
00640             diskrgb rgbdisk;
00641              
00642             fl = langunpackdata (sizeof (rgbdisk), &rgbdisk, h, &ixunpack);
00643             
00644             if (fl) {
00645                 
00646                 diskrgbtorgb (&rgbdisk, &rgb);
00647                 
00648                 fl = newheapvalue (&rgb, sizeof (rgb), rgbvaluetype, &v);
00649                 
00650                 if (fl)
00651                     exemptfromtmpstack (&v);
00652                 }
00653             
00654             break;
00655             }
00656         
00657         #if noextended
00658         
00659             case doublevaluetype: {
00660                 long double x;
00661                 extended80 x80;
00662                  
00663                 fl = langunpackdata (sizeof (x80), &x80, h, &ixunpack);
00664                 
00665                 if (fl) {
00666                     
00667                     #ifdef WIN95VERSION
00668                         convertFromMacExtended (&x, &x80);
00669                     #else
00670                         safex80told (&x80, &x);
00671                     #endif          
00672                      
00673                     fl = setdoublevalue (x, &v);
00674                     
00675                     if (fl)
00676                         exemptfromtmpstack (&v);
00677                     }
00678                 
00679                 break;
00680                 }
00681         #else
00682         
00683             case doublevaluetype:
00684             
00685         #endif
00686         
00687         case stringvaluetype:
00688         case passwordvaluetype: 
00689         case patternvaluetype:
00690         case binaryvaluetype:
00691     #ifndef version5orgreater
00692         case objspecvaluetype:
00693         case filespecvaluetype:
00694         case aliasvaluetype:
00695     #endif
00696     #ifndef oplanglists
00697         case listvaluetype:
00698         case recordvaluetype:
00699     #endif
00700             fl = langunpackhandle (false, &v.data.binaryvalue, h, &ixunpack);
00701             
00702             break;
00703         
00704     #ifdef oplanglists
00705         case listvaluetype:
00706         case recordvaluetype:
00707             fl = langunpackhandle (true, &hdata, h, &ixunpack);
00708             
00709             if (!fl)
00710                 break;
00711             
00712             fl = opunpacklist (hdata, &v.data.listvalue);
00713             
00714             break;
00715     #endif
00716 
00717     #ifdef version5orgreater
00718         case objspecvaluetype: {
00719             Handle hobjspec;
00720             
00721             fl = langunpackhandle (false, &hobjspec, h, &ixunpack);
00722             
00723             if (!fl)
00724                 break;
00725             
00726             if (gethandlesize (hobjspec) == 0) {
00727                 
00728                 disposehandle (hobjspec);
00729                 
00730                 hobjspec = nil;
00731                 }
00732             
00733             v.data.objspecvalue = hobjspec;
00734             
00735             break;
00736             }
00737         
00738         
00739         case filespecvaluetype:
00740         case aliasvaluetype:
00741             fl = langunpackhandle (true, &hdata, h, &ixunpack);
00742             
00743             if (!fl)
00744                 break;
00745             
00746             fl = langunpackfileval (hdata, &v);
00747             
00748             break;
00749     #endif
00750 
00751         case codevaluetype:
00752             fl = langunpackhandle (true, &hdata, h, &ixunpack);
00753             
00754             if (!fl)
00755                 break;
00756             
00757             fl = langunpacktree (hdata, &v.data.codevalue);
00758             
00759             break;
00760         
00761         case externalvaluetype:
00762             fl = langunpackexternal ((hdlexternalvariable *) &v.data.externalvalue, h, &ixunpack);
00763             
00764             break;
00765         
00766         default:
00767             langerror (cantunpackerror);
00768             
00769             return (false);     
00770         } /*switch*/
00771     
00772     *val = v;
00773     
00774     return (fl);
00775     
00776     formaterror:
00777     
00778     langerror (unpackformaterror);
00779     
00780     return (false);
00781     } /*langunpackvalue*/
00782 
00783 
00784 boolean langunpackverb (hdltreenode hparam1, tyvaluerecord *vreturned) {
00785 
00786     tyvaluerecord val;
00787     hdlhashtable htable;
00788     bigstring bsvarname;
00789     Handle hpacked;
00790     
00791     setbooleanvalue (false, vreturned); /*default returned value of verb*/
00792     
00793     if (!getbinaryvalue (hparam1, 1, true, (Handle *) &hpacked)) /*the value to be unpacked*/
00794         return (false);
00795     
00796     flnextparamislast = true;
00797     
00798     if (!getvarparam (hparam1, 2, &htable, bsvarname)) /*the place to put the unpacked value*/
00799         return (false);
00800     
00801     if (!langunpackvalue ((Handle) hpacked, &val))
00802         return (false);
00803     
00804     if (!langsetsymboltableval (htable, bsvarname, val)) {
00805         
00806         disposevaluerecord (val, false);
00807         
00808         return (false);
00809         }
00810     
00811     (*vreturned).data.flvalue = true;
00812     
00813     return (true);
00814     } /*langunpackverb*/
00815 
00816 
00817 boolean langunpackwindowverb (hdltreenode hparam1, tyvaluerecord *vreturned) {
00818 
00819     tyvaluerecord val;
00820     tyfilespec fspec;
00821     ptrfilespec fs;
00822     Handle hpacked;
00823     
00824     setbooleanvalue (false, vreturned); /*default returned value of verb*/
00825     
00826     if (!getbinaryvalue (hparam1, 1, true, (Handle *) &hpacked)) /*the value to be unpacked*/
00827         return (false);
00828     
00829     flnextparamislast = true;
00830     
00831     if (!getfilespecvalue (hparam1, 2, &fspec)) /*the file the value came from*/
00832         return (false);
00833     
00834     if (!langunpackvalue ((Handle) hpacked, &val))
00835         return (false);
00836     
00837     if (val.valuetype != externalvaluetype) {
00838         
00839         langerror (cantunpackthisexternalerror);
00840         
00841         return (false);
00842         }
00843     
00844     fs = &fspec;
00845     
00846     if (isemptystring (fsname (fs)))
00847         fs = nil;
00848     else
00849         langexternalsetdirty ((hdlexternalhandle) val.data.externalvalue, false);
00850     
00851     if (!langexternalzoomfilewindow (&val, fs, true)) {
00852         
00853         disposevaluerecord (val, false);
00854         
00855         return (false);
00856         }
00857     
00858     (*vreturned).data.flvalue = true;
00859     
00860     return (true);
00861     } /*langunpackwindowverb*/
00862 
00863 #if !flruntime
00864 
00865 boolean langvaluetotextscrap (tyvaluerecord val, Handle htext) {
00866     
00867     /*
00868     convert the given value to text, appending to the indicated handle
00869     */
00870     
00871     bigstring bstype, bsvalue, bssize;
00872     
00873     if (!hashvaltostrings (val, bstype, bsvalue, bssize))
00874         return (false);
00875     
00876     pushchar (':', bstype);
00877     
00878     if (val.valuetype == externalvaluetype) {
00879         pushchar (chreturn, bstype);
00880 
00881         #ifdef xxxWIN95VERSION
00882             pushchar (chlinefeed, bstype);
00883         #endif
00884         }
00885     else {
00886         pushchar (chtab, bstype);
00887         }
00888 
00889     if (!pushtexthandle (bstype, htext))
00890         return (false);
00891     
00892     if (val.valuetype == externalvaluetype)
00893         return (langexternalpacktotext ((hdlexternalvariable) val.data.externalvalue, htext));
00894     
00895     pushchar (chreturn, bsvalue);
00896 
00897     #ifdef xxxWIN95VERSION
00898         pushchar (chlinefeed, bsvalue);
00899     #endif
00900     
00901     return (pushtexthandle (bsvalue, htext));
00902     } /*langvaluetotextscrap*/
00903 
00904 #endif
00905 
00906 
00907 

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