megastubs.c

Go to the documentation of this file.
00001 
00002 /*  $Id: megastubs.c 600 2006-03-04 16:34:45Z 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 "versions.h"   /* 2006-03-04 aradke: for APPNAME */
00032 #include "error.h"
00033 #include "font.h"
00034 #include "memory.h"
00035 #include "quickdraw.h"
00036 #include "dialogs.h"
00037 #include "ops.h"
00038 #include "strings.h"
00039 #include "lang.h"
00040 #include "langinternal.h"
00041 #include "langexternal.h"
00042 #include "langsystem7.h"
00043 #include "shell.h"
00044 #if (MEMTRACKER == 1)
00045     #include "shellprivate.h"
00046     #include "oplist.h"
00047 #endif
00048 #ifndef odbengine
00049     #include "icon.h"
00050     #include "fileloop.h"
00051     #include "resources.h"
00052     #include "frontierwindows.h"
00053     #include "shellhooks.h"
00054     #include "shellprint.h"
00055 #endif
00056 #include "shell.rsrc.h"
00057 #include "process.h"
00058 #if MACVERSION
00059     #include "osacomponent.h"
00060 #endif
00061 #include "tablestructure.h"
00062 #include "Winland.h"
00063 #include "odbinternal.h"
00064 #include "winregistry.h"
00065 
00066 #if (MEMTRACKER == 1)
00067     #pragma message ("***************************************MEMORY TRACKING IS ON!!***************************************")
00068 #endif
00069 
00070 boolean fldatabasesaveas;
00071 
00072 boolean evaluateosascript (const tyvaluerecord *osaval, hdltreenode hparam1, bigstring bsname, tyvaluerecord *vreturned) {
00073     return (false);
00074     }
00075 
00076 boolean isosascriptnode (hdltreenode htree, tyvaluerecord *osaval) {
00077     return (false);
00078     }
00079 
00080 void convertToMacExtended (double foo, extended80 * tenbytebuffer) {
00081     unsigned char myext[10];
00082     unsigned char * tenbuf;
00083     short i;
00084 
00085     tenbuf = tenbytebuffer->x80;
00086 
00087 #if defined(__i386__) && defined(__GNUC__)
00088     /*
00089         10.0a5 - TRT - 29 Dec 2004
00090         GNU by default uses the AT&T assembly code syntax;
00091         MSC/MWERKS uses the Intel assembly code syntax;
00092         some versions of 'gcc' accept -masm=att|intel to
00093         specify which syntax to use; but for those that don't...
00094     */
00095     __asm__("FLD foo/\nFWAIT/\nFSTP tbyte ptr myext/\nFWAIT/");
00096 #elif defined(__powerpc__) && defined(__GNUC__)
00097     dtox80(&foo, tenbytebuffer);    /* at present - see fp.h in Universal Interfaces */
00098 #else
00099     _asm {
00100         FLD foo;
00101         FWAIT;
00102         FSTP tbyte ptr myext;
00103         FWAIT;
00104         }
00105 #endif
00106 
00107     for (i = 9; i >= 0; i--) {
00108         *tenbuf = myext[i];
00109         ++tenbuf;
00110         }
00111     } /*convertToMacExtended*/
00112 
00113 void convertFromMacExtended (double * foo, extended80 * tenbytebuffer) {
00114     unsigned char myext[10];
00115     unsigned char * tenbuf;
00116     short i;
00117     double getfoo;
00118 
00119     tenbuf = tenbytebuffer->x80;
00120 
00121     for (i = 9; i >= 0; i--) {
00122         myext[i] = *tenbuf;
00123         ++tenbuf;
00124         }
00125 
00126 #if defined(__i386__) && defined(__GNUC__)
00127     /*
00128         10.0a5 - TRT - 29 Dec 2004
00129         GNU by default uses the AT&T assembly code syntax;
00130         MSC/MWERKS uses the Intel assembly code syntax;
00131         some versions of 'gcc' accept -masm=att|intel to
00132         specify which syntax to use; but for those that don't...
00133     */
00134     __asm__("FLD tbyte ptr myext\nFWAIT/\nFSTP getfoo/\nFWAIT/");
00135 #elif defined(__powerpc__) && defined(__GNUC__)
00136     *foo = x80tod(tenbytebuffer);   /* at present - see fp.h in Universal Interfaces */
00137 #else
00138     _asm {
00139         FLD tbyte ptr myext
00140         FWAIT;
00141         FSTP getfoo;
00142         FWAIT;
00143         }
00144 #endif
00145 
00146     *foo = getfoo;
00147     } /*convertFromMacExtended*/
00148 
00149 
00150     //-----------------
00154 
00155 #ifdef __MWERKS__
00156 
00157     static int _debugreport(const char *msg) {
00158 
00159         int result;
00160 
00161         if (IsDebuggerPresent()) { 
00162 
00163             OutputDebugString(msg);
00164             
00165             result = 1;
00166             }
00167 
00168         else {
00169             
00170             int itemnum;
00171 
00172             itemnum = MessageBox (hwndMDIClient, msg, "Debug Message", MB_ABORTRETRYIGNORE | MB_ICONSTOP | MB_APPLMODAL);
00173 
00174             if (itemnum == IDABORT)
00175                 abort();
00176             
00177             result = (itemnum == IDRETRY) ? 1 : 0;
00178             }
00179         
00180         return (result);
00181         } /*_debugreport*/
00182             
00183     #define _DEBUGMESSSAGE(msg) \
00184             do { if ((1 == _debugreport(msg))) \
00185                     DebugBreak(); } while (0)
00186 #endif
00187 
00188 void Debugger () {
00189     
00190     #ifdef __MWERKS__
00191         _DEBUGMESSSAGE ("Debugger Exit\n");
00192     #else
00193         _RPT0 (_CRT_ERROR, "Debugger Exit\n");
00194     #endif
00195     }
00196 
00197 void DebugStr (char * bs) {
00198     
00199     char s [256];
00200 
00201     copyptocstring (bs, s);
00202 
00203     #ifdef __MWERKS__
00204         _DEBUGMESSSAGE (s);
00205     #else
00206         _RPT0 (_CRT_ERROR, s);
00207     #endif
00208     }
00209 
00210 typedef struct tymemtrack {
00211     long sig;
00212     long extra;
00213     struct tymemhandleblock * next;
00214     struct tymemhandleblock * prev;
00215     long line;
00216     long id;
00217     unsigned long time;
00218     char name[1];
00219     } tymemtrack, * pmemtrack;
00220 
00221 typedef struct tymemhandleblock {
00222     char * memBlock;
00223     unsigned long memSize;
00224     #if (MEMTRACKER == 1)
00225         pmemtrack debugBlock;
00226     #endif
00227     } tymemhandleblock;
00228 
00229 tymemhandleblock * masterHandleTable = NULL;
00230 tymemhandleblock * masterFreeHandle = NULL;
00231 
00232 #define handlesPerBlock 10000
00233 
00234 long handlecounter = 0;
00235 
00238 static CRITICAL_SECTION allocsection;
00239 static boolean allocsectioninitialized = false;
00240 
00241 
00242 static void frontierReturnHandle (tymemhandleblock * foo) {
00243 
00244     //free (foo);
00245     
00246     EnterCriticalSection (&allocsection);
00247 
00248     foo->memBlock = (char *) masterFreeHandle;
00249     foo->memSize = 0xFFFFFFFF;
00250     masterFreeHandle = foo;
00251     
00252     LeaveCriticalSection (&allocsection);
00253 
00254     } /*frontierReturnHandle*/
00255 
00256 static boolean frontierExpandHandles () {
00257     tymemhandleblock * newblock;
00258     int i;
00259     //should only be called when masterFreeHandle == NULL
00260 
00261     if (!allocsectioninitialized) {
00262 
00263         InitializeCriticalSection (&allocsection);
00264 
00265         allocsectioninitialized = true;
00266         }
00267     
00268     newblock = (tymemhandleblock *) malloc (handlesPerBlock * sizeof(tymemhandleblock));
00269 
00270     if (newblock == NULL)
00271         return (false);
00272 
00273     EnterCriticalSection (&allocsection);
00274 
00275     newblock->memBlock = (char *)masterHandleTable;
00276     newblock->memSize = handlesPerBlock * sizeof(tymemhandleblock);
00277     masterHandleTable = newblock;
00278 
00279     //Initialize the rest of the handle block to free handles
00280     for (i = 1; i < handlesPerBlock; i++) {
00281         newblock[i].memBlock = (char *) masterFreeHandle;
00282         newblock[i].memSize = 0xFFFFFFFF;
00283         masterFreeHandle = &(newblock[i]);
00284         }
00285 
00286     LeaveCriticalSection (&allocsection);
00287 
00288     return (true);
00289     } /*frontierExpandHandles*/
00290 
00291 static tymemhandleblock * frontierGetHandle () {
00292 
00293     //return ((tymemhandleblock *) malloc (sizeof (tymemhandleblock)));
00294     
00295     tymemhandleblock * retVal;
00296 
00297     if (masterFreeHandle == NULL) { //Must allocate more handles
00298         if (! frontierExpandHandles())
00299             return (NULL);
00300         }
00301 
00302     EnterCriticalSection (&allocsection);
00303 
00304     retVal = masterFreeHandle;
00305     masterFreeHandle = (tymemhandleblock *) masterFreeHandle->memBlock;
00306 
00307     LeaveCriticalSection (&allocsection);
00308 
00309     return (retVal);
00310     
00311     } /*frontierGetHandle*/
00312 
00313 
00314 char * CALLBACK frontierLock (Handle foo) {
00315     return (((tymemhandleblock *)foo)->memBlock);
00316     } /*frontierLock*/
00317 
00318 
00319 #if (MEMTRACKER == 1)
00320 tymemhandleblock * debugmasterhandle = NULL;
00321 #endif
00322 
00323 
00324 #if (MEMTRACKER == 1)
00325 static void setsig (Handle foo) {
00326     long * fooPtr;
00327 
00328     fooPtr = (long *) (((tymemhandleblock *)foo)->memBlock + ((tymemhandleblock *)foo)->memSize);
00329     *fooPtr = 'RAB.';
00330     } /*setsig*/
00331 
00332 static void checksig (Handle foo, char * doing) {
00333     long * fooPtr;
00334     char buf[500];
00335     pmemtrack pm;
00336 
00337     fooPtr = (long *) (((tymemhandleblock *)foo)->memBlock + ((tymemhandleblock *)foo)->memSize);
00338 
00339     if (*fooPtr != 'RAB.') {
00340         pm = ((tymemhandleblock *)foo)->debugBlock;
00341         wsprintf (buf, "DATA OVERRUN while %s: %s at line %ld for %ld bytes.  Thread id %ld. [%08lX] at %lu", doing, pm->name, pm->line, ((tymemhandleblock *)foo)->memSize, pm->id, foo, pm->time);
00342         MessageBox (NULL, buf, "Frontier Debug", MB_OKCANCEL);
00343         }
00344     } /*checksig*/
00345 
00346 
00347 static void unloadbuttonlists (void) {
00348     
00349     register short i;
00350     register short resnum;
00351     
00352     for (i = 0; i < topglobalsarray; i++) {
00353         
00354         resnum = globalsarray [i].config.idbuttonstringlist; 
00355         
00356         if (resnum != 0) { /*a button list is attached*/
00357             
00358             opdisposelist ((hdllistrecord) globalsarray [i].buttonlist);
00359             }
00360         } /*for*/
00361     } /*unloadbuttonlists*/
00362 
00363 void displaymemtrack () {
00364     char buf[500];
00365     tymemhandleblock * foo;
00366     long len;
00367     pmemtrack pm;
00368     long count;
00369     FILE * memfile;
00370     boolean flshow = true;
00371     long ctbytesneeded = 0x7fffffff;
00372     hdlhashtable ht = internaltable;
00373     
00374     internaltable = NULL;
00375     
00376     disposehashtable (ht, false);
00377     
00378     environmenttable = NULL;
00379     
00380     disposehashtable (environmenttable, false);
00381 
00382     hashflushcache (&ctbytesneeded);
00383     
00384     unloadbuttonlists ();
00385 
00386     shelldisposescrap ();
00387 
00388     wsprintf (buf, "There are %ld handle still around by count.  Display?", handlecounter);
00389     if (MessageBox (NULL, buf, "Fronter Debug", MB_OKCANCEL) == IDOK) {
00390         memfile = fopen ("memfile.txt", "w+");
00391 
00392         foo = debugmasterhandle;
00393         count = 0;
00394         while (foo != NULL) {
00395             ++count;
00396             len = foo->memSize;     //get logical size;
00397             pm = foo->debugBlock;
00398             wsprintf (buf, "(%ld) %s at line %ld for %ld bytes.  Thread id %ld. [%08lX] at %lu", count, pm->name, pm->line, len, pm->id, foo, pm->time);
00399 
00400             foo = pm->next;
00401 
00402             fprintf (memfile, "%s\n", buf);
00403 
00404             if (flshow)
00405                 if (MessageBox (NULL, buf, "Frontier Debug", MB_OKCANCEL) == IDCANCEL)
00406                     flshow = false;
00407             }
00408 
00409         if (count != handlecounter) {
00410             wsprintf (buf, "Why does handlecounter show %ld while the count of linked memory blocks is %ld.", handlecounter, count);
00411             MessageBox (NULL, buf, "Frontier Debug", MB_OK);
00412             fprintf (memfile, "%s\n", buf);
00413             }
00414 
00415         fclose (memfile);
00416 
00417         }
00418     } /*displaymemtrack*/
00419 
00420 
00421     void CALLBACK debugfrontierFree (Handle foo) {
00422         tymemhandleblock * foonext;
00423         tymemhandleblock * fooprev;
00424         pmemtrack pm, pmnext, pmprev;
00425         
00426         if (foo != NULL) {
00427             --handlecounter;
00428 
00429             //unlink foo
00430             pm = ((tymemhandleblock *)foo)->debugBlock;
00431 
00432             foonext = pm->next;
00433             fooprev = pm->prev;
00434 
00435             if (foonext != NULL) {
00436                 pmnext = foonext->debugBlock;
00437 
00438                 pmnext->prev = fooprev;
00439                 }
00440 
00441             if (fooprev != NULL) {
00442                 pmprev = fooprev->debugBlock;
00443 
00444                 pmprev->next = foonext;
00445                 }
00446 
00447             if ((tymemhandleblock *)foo == debugmasterhandle)
00448                 debugmasterhandle = foonext;
00449 
00450             checksig (foo, "Freeing");
00451 
00452             free (((tymemhandleblock *)foo)->memBlock);
00453             free (((tymemhandleblock *)foo)->debugBlock);
00454             frontierReturnHandle ((tymemhandleblock *)foo);
00455             }
00456         } /*debugfrontierFree*/
00457 
00458 
00459     Handle CALLBACK debugfrontierAlloc (char * filename, unsigned long linenumber, unsigned long threadid, long userSize) {
00460         pmemtrack pm;
00461         tymemhandleblock * foo;
00462         
00463         if (userSize < 0) // 5.0d12 dmb
00464             userSize = 0;
00465 
00466         foo = frontierGetHandle ();
00467 
00468         if (foo == NULL)
00469             return (NULL);
00470 
00471         foo->debugBlock = (pmemtrack) malloc (strlen(filename) + 1 + sizeof(tymemtrack));
00472 
00473         if (foo->debugBlock != NULL) {
00474             foo->memBlock = (char *) malloc (userSize+4);
00475             foo->memSize = userSize;
00476 
00477             if (foo->memBlock != NULL)
00478                 {
00479                 ++handlecounter;
00480 
00481                 pm = foo->debugBlock;
00482                 pm->sig = 'RAB.';
00483                 pm->extra = strlen(filename) + 1 + sizeof(tymemtrack);
00484                 pm->next = debugmasterhandle;
00485                 pm->prev = NULL;
00486                 pm->line = linenumber;
00487                 pm->id = threadid;
00488                 pm->time = GetTickCount();
00489                 strcpy (pm->name, filename);
00490 
00491                 if (debugmasterhandle != NULL) {
00492                     pm = debugmasterhandle->debugBlock;
00493                     pm->prev = foo;
00494                     }
00495 
00496                 debugmasterhandle = foo;
00497 
00498                 setsig ((Handle)foo);
00499 
00500                 return ((Handle)foo);
00501                 }
00502 
00503             free (foo->debugBlock);
00504             }
00505 
00506         frontierReturnHandle (foo);
00507         return (NULL);
00508         } /*debugfrontierAlloc*/
00509 
00510     Handle CALLBACK debugfrontierReAlloc(Handle fooIn, long userSize) {
00511         tymemhandleblock * foo;
00512         char * fooPtr;
00513 
00514         checksig (fooIn, "ReAllocating");
00515 
00516         foo = (tymemhandleblock *)fooIn;
00517 
00518         fooPtr = realloc (foo->memBlock, userSize+4);
00519 
00520         if ((fooPtr == NULL) && (userSize > 0))  
00521             return (NULL);
00522 
00523         foo->memBlock = fooPtr;  //maybe NULL if resized to zero
00524         foo->memSize = userSize;
00525 
00526         setsig (fooIn);
00527 
00528         SetLastError (0);   // dmb 3/6/97
00529         return (fooIn); /*handle never changes*/
00530         } /*debugfrontierReAlloc*/
00531 
00532 Handle CALLBACK frontierAlloc (long userSize) {
00533     return (debugfrontierAlloc (__FILE__, __LINE__, GetCurrentThreadId(), userSize));
00534     } /*frontierAlloc*/
00535 
00536 long CALLBACK frontierSize (Handle foo) {
00537     if (foo == NULL)
00538         return (0);
00539 
00540     return (((tymemhandleblock *)foo)->memSize);
00541     }
00542 
00543 
00544 Handle CALLBACK frontierReAlloc(Handle fooIn, long userSize) {
00545     return (debugfrontierReAlloc(fooIn, userSize));
00546     }
00547 
00548 void CALLBACK frontierFree (Handle foo) {
00549     debugfrontierFree(foo);
00550     }
00551 
00552 #else
00553 //***** Start Normal Routines **********
00554 
00555 void CALLBACK frontierFree (Handle foo) {
00556 
00557     tymemhandleblock *f = (tymemhandleblock *)foo;
00558 
00559     if (f != NULL) {
00560         --handlecounter;
00561 
00562         free (f->memBlock);
00563         frontierReturnHandle (f);
00564         }
00565     } /*frontierFree*/
00566 
00567 Handle CALLBACK frontierAlloc (long userSize) {
00568     tymemhandleblock * foo;
00569     
00570     if (userSize < 0) // 5.0d12 dmb
00571         userSize = 0;
00572 
00573     foo = frontierGetHandle ();
00574 
00575     if (foo == NULL)
00576         return (NULL);
00577 
00578     foo->memBlock = (char *) malloc (userSize+4);
00579     foo->memSize = userSize;
00580 
00581     if (foo->memBlock != NULL)
00582         {
00583         ++handlecounter;
00584         return ((Handle)foo);
00585         }
00586 
00587     frontierReturnHandle (foo);
00588     return (NULL);
00589     }
00590 
00591 long CALLBACK frontierSize (Handle foo) {
00592 
00593     /*
00594     5.0.2b21 dmb: handle disposed handles -- don't crash 
00595     */
00596 
00597     if (foo == NULL)
00598         return (0);
00599 
00600     return (((tymemhandleblock *)foo)->memSize);
00601     } /*frontierSize*/
00602 
00603 
00604 Handle CALLBACK frontierReAlloc(Handle fooIn, long userSize) {
00605     tymemhandleblock * foo;
00606     char * fooPtr;
00607 
00608     foo = (tymemhandleblock *)fooIn;
00609 
00610     fooPtr = realloc (foo->memBlock, userSize+4);
00611 
00612     if ((fooPtr == NULL) && (userSize > 0))  
00613         return (NULL);
00614 
00615     foo->memBlock = fooPtr;  //maybe NULL if resized to zero
00616     foo->memSize = userSize;
00617 
00618     return (fooIn); /*handle never changes*/
00619     }
00620 #endif
00621 
00622 Boolean EmptyRgn (hdlregion rgn) {
00623     RECT winrect;
00624 
00625     return (GetRgnBox ((HRGN) rgn, &winrect) == NULLREGION);
00626     }
00627 
00628 
00629 /*
00630 extern boolean getfiletype (const tyfilespec *, OSType *);
00631 extern boolean fileresolvealias (tyfilespec *);
00632 extern boolean sfdialog (tysfverb, bigstring, ptrsftypelist, tyfilespec *);
00633 extern boolean getapplicationfilespec (bigstring, tyfilespec *);
00634 */
00635 
00636 boolean initmacintosh ()
00637     {
00638     return (true);
00639     }
00640 
00641 
00642 #ifndef odbengine
00643 
00644 WindowPtr getcurrentwindow(){
00645     return (shellwindow);
00646     }
00647 
00648 boolean fileresolvealias (ptrfilespec fs) {
00649     return (true);
00650     }
00651 
00652 #endif
00653 
00654 
00655 // dialogs.c
00656 
00657 #ifndef odbengine
00658 
00659 void centerdialog (HWND hwndDlg) {
00660     HWND hwndOwner; 
00661     RECT rc, rcDlg, rcOwner; 
00662  
00663      // Get the owner window and dialog box rectangles. 
00664 
00665     if ((hwndOwner = GetParent(hwndDlg)) == NULL) {
00666         hwndOwner = GetDesktopWindow(); 
00667         }
00668 
00669     GetWindowRect(hwndOwner, &rcOwner); 
00670     GetWindowRect(hwndDlg, &rcDlg); 
00671     CopyRect(&rc, &rcOwner); 
00672 
00673      // Offset the owner and dialog box rectangles so that 
00674      // right and bottom values represent the width and 
00675      // height, and then offset the owner again to discard 
00676      // space taken up by the dialog box. 
00677 
00678     OffsetRect(&rcDlg, -rcDlg.left, -rcDlg.top); 
00679     OffsetRect(&rc, -rc.left, -rc.top); 
00680     OffsetRect(&rc, -rcDlg.right, -rcDlg.bottom); 
00681 
00682      // The new position is the sum of half the remaining 
00683      // space and the owner's original position. 
00684 
00685     SetWindowPos(hwndDlg, 
00686         HWND_TOP, 
00687         rcOwner.left + (rc.right / 2), 
00688         rcOwner.top + (rc.bottom / 2), 
00689         0, 0,          // ignores size arguments 
00690         SWP_NOSIZE); 
00691     } /*centerdialog*/
00692 
00693 
00694 //#ifdef PIKE /*7.0d8 PBS*/
00695 //#ifndef OPMLEDITOR
00696 //  static char frontierstring [] = "Radio UserLand";
00697 //#else //OPMLEDITOR
00698 //  static char frontierstring [] = "OPML";
00699 //#endif // OPMLEDITOR
00700 //#else
00701 //  static char frontierstring [] = "UserLand Frontier";
00702 //#endif
00703 
00704 static char frontierstring [] = APPNAME;    /* 2006-03-04 aradke: from versions.h */
00705 
00706 
00707 static messagebox (LPCTSTR lpText, LPCTSTR lpCaption, UINT uType) {
00708     
00709     int itemnumber;
00710 
00711     releasethreadglobals ();
00712 
00713     itemnumber = MessageBox (hwndMDIClient, lpText, lpCaption, uType);
00714     
00715     grabthreadglobals ();
00716 
00717     return itemnumber;
00718     } /*messagebox*/
00719 
00720 
00721 boolean msgdialog (bigstring bsprompt) {
00722     
00723     /*
00724     put up the standard "msg" dialog, with the provided prompt and return
00725     true if the user clicked on ok.  false if cancel was clicked.
00726     */
00727     
00728     char s [256];
00729     short itemnumber;
00730 
00731     copyptocstring (bsprompt, s);
00732 
00733     itemnumber = messagebox (s, frontierstring, MB_OKCANCEL | MB_APPLMODAL);
00734     
00735     return (itemnumber == IDOK);
00736     } /*msgdialog*/
00737 
00738 
00739 static unsigned char gMsgAbortButton[256];
00740 static unsigned char gMsgRetryButton[256];
00741 static unsigned char gMsgCancelButton[256];
00742 static unsigned char gMsgIgnoreButton[256];
00743 FARPROC   g_lpMsgBoxProc;          // Message box window procedure
00744 HHOOK     g_hhookCBT;              // CBT hook identifier
00745 static int gMessageBoxMinWidth;
00746 static int gMessageBoxWidth;
00747 static int gButtonWidth;
00748 static int gButtonSpacing;
00749 static long gbaseunits;
00750 
00751 #define MAXBUTTONSTRINGWIDTH    11
00752 void setbuttonstring (bigstring src, unsigned char * dest) {
00753     copyptocstring (src, dest);
00754 
00755     if (stringlength (src) > MAXBUTTONSTRINGWIDTH) {
00756         dest[MAXBUTTONSTRINGWIDTH-2] = '.';
00757         dest[MAXBUTTONSTRINGWIDTH-1] = '.';
00758         dest[MAXBUTTONSTRINGWIDTH] = '.';
00759         dest[MAXBUTTONSTRINGWIDTH+1] = '\0';
00760         }
00761 
00762     } /* setbuttonstring */
00763 
00764 static void setmessageboxbuttonsize (int numberButtons) {
00765     gbaseunits = LOWORD(GetDialogBaseUnits());
00766     gButtonWidth = (35 * gbaseunits) / 4;
00767     gButtonSpacing = (5 * gbaseunits) / 4;
00768     gMessageBoxMinWidth = (numberButtons * (gButtonWidth + gButtonSpacing)) + gButtonSpacing;
00769     } /*setmessageboxbuttonsize*/
00770 
00771 //****************************************************************************
00772 // Function: MsgBoxSubClassProc
00773 //
00774 // Purpose: Subclass procedure for message box to change text and background color
00775 //
00776 // Parameters & return value:
00777 //    Standard. See documentaion for WindowProc
00778 //
00779 //****************************************************************************
00780 LRESULT CALLBACK MsgBoxSubClassProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
00781     {
00782     if (msg == WM_INITDIALOG) {
00783         SetDlgItemText (hwnd, IDABORT, gMsgAbortButton);
00784         SetDlgItemText (hwnd, IDRETRY, gMsgRetryButton);
00785         SetDlgItemText (hwnd, IDCANCEL, gMsgCancelButton);
00786         SetDlgItemText (hwnd, IDIGNORE, gMsgIgnoreButton);
00787         }
00788 
00789     return  CallWindowProc((WNDPROC) g_lpMsgBoxProc, hwnd, msg, wParam, lParam);
00790     } /*MsgBoxSubClassProc*/
00791 
00792 //****************************************************************************
00793 // Function: CBTProc
00794 //
00795 // Purpose: Callback function of WH_CBT hook
00796 //
00797 // Parameters and return value:
00798 //    See documentation for CBTProc. 
00799 //
00800 // Comments: The message box is subclassed on creation and the original
00801 //    window procedure is restored on destruction
00802 //
00803 //****************************************************************************
00804 
00805 LRESULT CALLBACK CBTProc(int nCode, WPARAM wParam, LPARAM lParam)
00806     {
00807    LPCBT_CREATEWND lpcbtcreate;
00808    static HWND hwndMsgBox = NULL;
00809    static BOOL bSubClass = FALSE;
00810    static int buttonCount = 0;
00811    
00812    if (nCode < 0)
00813        return CallNextHookEx(g_hhookCBT, nCode, wParam, lParam); 
00814    
00815    // Window owned by our task is being created. Since the hook is installed just 
00816     //   before the MessageBox call and removed after the MessageBox call, the window
00817     //   being created is either the message box or one of its controls. 
00818     if (nCode == HCBT_CREATEWND)     
00819         {
00820         lpcbtcreate = (LPCBT_CREATEWND)lParam;
00821 
00822         // Check if the window being created is a message box. The class name of
00823         //   a message box is WC_DIALOG since message boxes are just special dialogs.
00824         //   We can't subclass the message box right away because the window 
00825         //   procedure of the message box is not set when this hook is called. So
00826         //   we wait till the hook is called again when one of the message box 
00827         //   controls are created and then we subclass. This will happen because
00828         //   the message box has at least one control.
00829         if (WC_DIALOG == lpcbtcreate->lpcs->lpszClass) 
00830             {
00831             //This is the message box itself; make sure it is wide enough to accept the 
00832             // new button widths
00833             if (lpcbtcreate->lpcs->cx < gMessageBoxMinWidth)
00834                 lpcbtcreate->lpcs->cx = gMessageBoxMinWidth;
00835 
00836             gMessageBoxWidth = lpcbtcreate->lpcs->cx;
00837             
00838             buttonCount = 0;
00839 
00840             hwndMsgBox = (HWND)wParam;
00841             bSubClass = TRUE;      // Remember to subclass when the hook is called next
00842             }
00843         else if (bSubClass)
00844             {
00845             // Subclass the dialog to change the color of the background and text
00846             bSubClass = FALSE;
00847             g_lpMsgBoxProc = (FARPROC)SetWindowLong(hwndMsgBox, GWL_WNDPROC, (long)MsgBoxSubClassProc); 
00848             }
00849 
00850         // Here we know we have initialized the dialog so we must be creating the controls, look for
00851         // one of the known names for the buttons to ensure we are changing the correct thing.
00852         // If so, reset the width and position.
00853         if ((hwndMsgBox != NULL) && (bSubClass == FALSE)) {
00854             if ((stricmp (lpcbtcreate->lpcs->lpszName, "&Retry") == 0) ||
00855                 (stricmp (lpcbtcreate->lpcs->lpszName, "&Ignore") == 0) ||
00856                 (stricmp (lpcbtcreate->lpcs->lpszName, "&Abort") == 0) ||
00857                 (stricmp (lpcbtcreate->lpcs->lpszName, "Cancel") == 0)) {
00858 
00859                 lpcbtcreate->lpcs->cx = gButtonWidth;
00860                 lpcbtcreate->lpcs->x = ((gMessageBoxWidth - gMessageBoxMinWidth) / 2) + gButtonSpacing + (buttonCount * (gButtonWidth + gButtonSpacing));
00861                 ++buttonCount;
00862                 }
00863             }
00864         }
00865     else if (nCode == HCBT_DESTROYWND && (HWND)wParam == hwndMsgBox)
00866         {
00867         // Reset the original window procedure when the message box is about to 
00868         //   be destroyed.
00869         SetWindowLong(hwndMsgBox, GWL_WNDPROC, (LONG)g_lpMsgBoxProc);
00870         hwndMsgBox = NULL;      
00871         }   
00872     return 0;          
00873     } /*CBTProc*/
00874 
00875 
00876 boolean twowaydialog (bigstring bsprompt, bigstring bsok, bigstring bscancel) {
00877     int nResult;
00878     char s[256];
00879     
00880     copyptocstring (bsprompt, s);
00881     setbuttonstring (bsok, gMsgRetryButton);
00882     setbuttonstring (bscancel, gMsgCancelButton);
00883     
00884     setmessageboxbuttonsize (2);
00885 
00886     releasethreadglobals ();
00887 
00888     // Set a task specific CBT hook before calling MessageBox. The CBT hook will
00889     //    be called when the message box is created and will give us access to 
00890     //    the window handle of the MessageBox. The message box
00891     //    can then be subclassed in the CBT hook to change the color of the text and 
00892     //    background. Remove the hook after the MessageBox is destroyed.
00893     g_hhookCBT = SetWindowsHookEx(WH_CBT, CBTProc, shellinstance, 0);
00894     nResult = MessageBox(hwndMDIClient, s, frontierstring, MB_RETRYCANCEL | MB_APPLMODAL);
00895     UnhookWindowsHookEx(g_hhookCBT);
00896     
00897     grabthreadglobals ();
00898 
00899     return (nResult == IDRETRY);
00900     }
00901 
00902 
00903 short threewaydialog (bigstring bsprompt, bigstring bsyes, bigstring bsno, bigstring bscancel) {
00904     int nResult;
00905     char s[256];
00906     
00907     copyptocstring (bsprompt, s);
00908     setbuttonstring (bsyes, gMsgAbortButton);
00909     setbuttonstring (bsno, gMsgRetryButton);
00910     setbuttonstring (bscancel, gMsgIgnoreButton);
00911     
00912     setmessageboxbuttonsize (3);
00913 
00914     releasethreadglobals ();
00915 
00916     // Set a task specific CBT hook before calling MessageBox. The CBT hook will
00917     //    be called when the message box is created and will give us access to 
00918     //    the window handle of the MessageBox. The message box
00919     //    can then be subclassed in the CBT hook to change the color of the text and 
00920     //    background. Remove the hook after the MessageBox is destroyed.
00921     g_hhookCBT = SetWindowsHookEx(WH_CBT, CBTProc, shellinstance, 0);
00922     nResult = MessageBox(hwndMDIClient, s, frontierstring, MB_ABORTRETRYIGNORE | MB_APPLMODAL);
00923     UnhookWindowsHookEx(g_hhookCBT);
00924     
00925     grabthreadglobals ();
00926 
00927     switch (nResult) {
00928         
00929         case IDRETRY:
00930             return 2;
00931             
00932         case IDIGNORE:
00933             return 3;
00934 
00935         default:
00936             return 1;
00937         }
00938     } /*threewaydialog*/
00939 
00940 
00941 boolean alertdialog (bigstring bs) {
00942     
00943     char s [256];
00944     short itemnumber;
00945 
00946     copyptocstring (bs, s);
00947 
00948     releasethreadglobals ();
00949 
00950     itemnumber = messagebox (s, frontierstring, MB_OK | MB_ICONEXCLAMATION | MB_APPLMODAL);
00951     
00952     grabthreadglobals ();
00953 
00954     return (itemnumber == IDOK);
00955     } /*alertdialog*/
00956 
00957 
00958 boolean alertstring (short iderror) {
00959     
00960     bigstring bs;
00961     
00962     getstringlist (alertstringlistnumber, iderror, bs);
00963     
00964     return (alertdialog (bs));
00965     } /*alertstring*/
00966 
00967 
00968 short savedialog (bigstring bsfname) {
00969     
00970     /*
00971     returns 1, 2 or 3.
00972     
00973     if the user said yes, save the changes, the result is 1.
00974     
00975     if the user said no, discard the changes, the result is 2.
00976     
00977     if the user said cancel, continue editing, the result is 3.
00978     
00979     12/20/91 dmb: if file name is nil, just prompt for quit
00980     
00981     1/3/92 dmb: removed code for quit dialog
00982     */
00983     
00984     char s [256];
00985     char msg [300];
00986     short itemnumber;
00987 
00988     copyptocstring (bsfname, s);
00989     wsprintf (msg, "Save %s before closing?", s);
00990     itemnumber = messagebox (msg, "save?", MB_YESNOCANCEL | MB_ICONQUESTION | MB_APPLMODAL);
00991     
00992     switch (itemnumber) {
00993         
00994         case IDYES: 
00995             return (1);
00996         
00997         case IDNO: 
00998             return (2);
00999         
01000         case IDCANCEL: 
01001             return (3);
01002         } /*switch*/
01003     
01004     return (1);
01005     } /*savedialog*/
01006 
01007 
01008 short replacevariabledialog (bigstring bs) {
01009     
01010     /*
01011     returns 1, 2 or 3.
01012     
01013     if the user said yes, save the changes, the result is 1.
01014     
01015     if the user said no, discard the changes, the result is 2.
01016     
01017     if the user said cancel, continue editing, the result is 3.
01018     
01019     12/20/91 dmb: if file name is nil, just prompt for quit
01020     
01021     1/3/92 dmb: removed code for quit dialog
01022     */
01023     
01024     char s [256];
01025     char msg [300];
01026     short itemnumber;
01027 
01028     copyptocstring (bs, s);
01029     wsprintf (msg, "Replace existing %s?", s);
01030     itemnumber = messagebox (msg, "replace?", MB_YESNOCANCEL | MB_ICONQUESTION | MB_APPLMODAL);
01031     
01032     switch (itemnumber) {
01033         
01034         case IDYES: 
01035             return (1);
01036         
01037         case IDNO: 
01038             return (2);
01039         
01040         case IDCANCEL: 
01041             return (3);
01042         } /*switch*/
01043     
01044     return (1);
01045     } /*replacevariabledialog*/
01046 
01047 
01048 boolean revertdialog (bigstring bs) {
01049 
01050     bigstring bsprompt;
01051     short itemnumber;
01052     
01053     shellgetstring (revertitemstring, bsprompt);
01054     
01055     parsedialogstring (bsprompt, bs, nil, nil, nil, bsprompt);
01056      
01057     convertpstring (bsprompt);
01058 
01059     itemnumber = messagebox (bsprompt, "revert?", MB_YESNO | MB_ICONQUESTION | MB_APPLMODAL);
01060     
01061     return (itemnumber == IDYES);
01062     } /*revertdialog*/
01063 
01064 
01065 // Ask Dialog Code
01066 
01067 typedef struct tyAskDialogInfo {
01068     char * caption;
01069     char * textBuffer;
01070     char * retBuffer;
01071     long retBufferLen;
01072     } tyAskDialogInfo;
01073 
01074 LRESULT CALLBACK AskDialogCallback(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) {
01075     
01076     tyAskDialogInfo * p;
01077 
01078     switch (message) {
01079         
01080         case WM_INITDIALOG:
01081             centerdialog (hwnd);
01082 
01083             p = (tyAskDialogInfo *) lParam;
01084 
01085             SetWindowText (hwnd, frontierstring); //p->caption
01086 
01087             SetDlgItemText (hwnd, ID_ASKTEXTDIALOGSTATICFIELD, p->textBuffer);
01088             SetDlgItemText (hwnd, ID_ASKTEXTDIALOGEDITFIELD, stringbaseaddress(p->retBuffer));
01089             SendDlgItemMessage (hwnd, ID_ASKTEXTDIALOGEDITFIELD, EM_SETSEL, 0, -1);
01090             
01091             SetWindowLong (hwnd, DWL_USER, lParam); 
01092 
01093             SetFocus (GetDlgItem (hwnd, ID_ASKTEXTDIALOGEDITFIELD));
01094             return (false);
01095 
01096         case WM_COMMAND:
01097             switch (LOWORD(wParam))
01098                 {
01099                 case IDOK:
01100                     p = (tyAskDialogInfo *) GetWindowLong (hwnd, DWL_USER);
01101 
01102                     GetDlgItemText (hwnd, ID_ASKTEXTDIALOGEDITFIELD, stringbaseaddress(p->retBuffer), p->retBufferLen-1);
01103                     setstringlength (p->retBuffer, strlen(stringbaseaddress(p->retBuffer)));
01104 
01105                     EndDialog (hwnd, TRUE);
01106                     return TRUE;
01107 
01108                 case IDCANCEL:
01109                     EndDialog (hwnd, FALSE);
01110                     return TRUE;
01111 
01112                 default:
01113                     break;
01114                 }
01115 
01116         default:
01117             break;
01118         }
01119 
01120     return FALSE;
01121     } /*AskDialogCallback*/
01122 
01123 static boolean winAskDialog (HWND window, bigstring caption, bigstring message, bigstring retString, long retStringSize, boolean flNumeric, boolean flPassword) {
01124     
01125     tyAskDialogInfo p;
01126     char cmsg[400];
01127     char capmsg[400];
01128     int res;
01129     
01130     memmove (capmsg, stringbaseaddress (caption), stringlength (caption));
01131     capmsg [stringlength(caption)] = 0;
01132     
01133     memmove (cmsg, stringbaseaddress (message), stringlength (message));
01134     cmsg[stringlength (message)] = 0;
01135     
01136     p.retBufferLen = retStringSize;
01137     retString[stringlength(retString)+1] = 0;
01138     p.retBuffer = retString;
01139     p.textBuffer = cmsg;
01140     p.caption = capmsg;
01141     
01142     releasethreadglobals ();
01143 
01144     if (flNumeric)
01145         res = DialogBoxParam (hInst, MAKEINTRESOURCE (IDD_ASKNUMBER), window, (DLGPROC)AskDialogCallback, (LPARAM) &p);
01146     else if (flPassword)
01147         res = DialogBoxParam (hInst, MAKEINTRESOURCE (IDD_ASKPASSWORD), window, (DLGPROC)AskDialogCallback, (LPARAM) &p);
01148     else
01149         res = DialogBoxParam (hInst, MAKEINTRESOURCE (IDD_ASKTEXT), window, (DLGPROC)AskDialogCallback, (LPARAM) &p);
01150     
01151     grabthreadglobals ();
01152 
01153     if (res > 0)
01154         return (true);
01155     
01156     return (false);
01157     } /*winAskDialog*/
01158 
01159 
01160 boolean askdialog (bigstring bsprompt, bigstring bsresult) {
01161     
01162     return (winAskDialog (hwndMDIClient, "", bsprompt, bsresult, lenbigstring, false, false));
01163     } /*askdialog*/
01164 
01165 boolean askpassword (bigstring bsprompt, bigstring bsresult) {
01166     
01167     return (winAskDialog (hwndMDIClient, "", bsprompt, bsresult, lenbigstring, false, true));
01168     } /*askpassword*/
01169 
01170 boolean intdialog (bigstring bsprompt, short *n) {
01171     
01172     bigstring bsresult;
01173 
01174     numbertostring (*n, bsresult);
01175 
01176     if (!winAskDialog (hwndMDIClient, "", bsprompt, bsresult, lenbigstring, true, false))
01177         return (false);
01178     
01179     stringtoshort (bsresult, n);
01180 
01181     return (true);
01182     } /*intdialog*/
01183 
01184 // Char Dialog Code
01185 
01186 typedef struct tyCharDialogInfo {
01187     char * prompt;
01188     char * retBuffer;
01189     long retBufferLen;
01190     } tyCharDialogInfo;
01191 
01192 LRESULT CALLBACK CharDialogCallback(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) {
01193     
01194     tyCharDialogInfo * p;
01195 
01196     switch (message) {
01197         
01198         case WM_INITDIALOG:
01199             centerdialog (hwnd);
01200 
01201             p = (tyCharDialogInfo *) lParam;
01202 
01203             SetDlgItemText (hwnd, IDC_CHARPROMPT, p->prompt);
01204 
01205             SetWindowLong (hwnd, DWL_USER, lParam); 
01206 
01207             SendDlgItemMessage (hwnd, IDC_EDIT1, EM_SETLIMITTEXT, (WPARAM) 1, 0);
01208 
01209             SetFocus (GetDlgItem (hwnd, IDC_EDIT1));
01210             return (false);
01211 
01212         case WM_COMMAND:
01213             switch (LOWORD(wParam))
01214                 {
01215                 case IDOK:
01216                     p = (tyCharDialogInfo *) GetWindowLong (hwnd, DWL_USER);
01217 
01218                     GetDlgItemText (hwnd, IDC_EDIT1, stringbaseaddress(p->retBuffer), p->retBufferLen-1);
01219                     setstringlength (p->retBuffer, strlen(stringbaseaddress(p->retBuffer)));
01220 
01221                     EndDialog (hwnd, TRUE);
01222                     return TRUE;
01223 
01224                 case IDCANCEL:
01225                     EndDialog (hwnd, FALSE);
01226                     return TRUE;
01227 
01228                 case IDC_EDIT1:
01229                     //Since we limit to a single char, always highlight "all" text after a change
01230                     if (HIWORD(wParam) == EN_CHANGE)
01231                         SendDlgItemMessage (hwnd, IDC_EDIT1, EM_SETSEL, (WPARAM) (INT) 0, (LPARAM) (INT) -1);
01232                     break;
01233                     
01234                 default:
01235                     break;
01236                 }
01237 
01238         default:
01239             break;
01240         }
01241 
01242     return FALSE;
01243     } /*CharDialogCallback*/
01244 
01245 boolean chardialog (bigstring prompt, short *n) {
01246     
01247     tyCharDialogInfo p;
01248     char cmsg[400];
01249     bigstring retString;
01250     int res;
01251     
01252     copyptocstring (prompt, cmsg);
01253     
01254     p.retBufferLen = sizeof(bigstring);
01255     setstringlength (retString, 0);
01256     p.retBuffer = retString;
01257     p.prompt = cmsg;
01258     
01259     releasethreadglobals ();
01260 
01261     res = DialogBoxParam (hInst, MAKEINTRESOURCE (IDD_DIALOGCOMMANDKEY), hwndMDIClient, (DLGPROC)CharDialogCallback, (LPARAM) &p);
01262     
01263     grabthreadglobals ();
01264 
01265     *n = getstringcharacter(retString, 0);
01266 
01267     if (res > 0)
01268         return (true);
01269     
01270     return (false);
01271     } /*chardialog*/
01272 // Char Dialog Code
01273 
01274 typedef struct tyUserInfoDialogInfo {
01275     unsigned char * username;
01276     unsigned char * userinitials;
01277     unsigned char * userorg;
01278     unsigned char * useremail;
01279     } tyUserInfoDialogInfo;
01280 
01281 LRESULT CALLBACK UserInfoDialogCallback(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) {
01282     
01283     tyUserInfoDialogInfo * p;
01284 
01285     switch (message) {
01286         
01287         case WM_INITDIALOG:
01288             centerdialog (hwnd);
01289 
01290             p = (tyUserInfoDialogInfo *) lParam;
01291 
01292             SetWindowLong (hwnd, DWL_USER, lParam); 
01293 
01294             SendDlgItemMessage (hwnd, IDC_EDIT1, EM_SETLIMITTEXT, (WPARAM) sizeof(bigstring) - 2, 0);
01295             SendDlgItemMessage (hwnd, IDC_EDIT2, EM_SETLIMITTEXT, (WPARAM) 4, 0);
01296             SendDlgItemMessage (hwnd, IDC_EDIT3, EM_SETLIMITTEXT, (WPARAM) sizeof(bigstring) - 2, 0);
01297             SendDlgItemMessage (hwnd, IDC_EDIT4, EM_SETLIMITTEXT, (WPARAM) sizeof(bigstring) - 2, 0);
01298 
01299             SetDlgItemText (hwnd, IDC_EDIT1, stringbaseaddress(p->username));
01300             SetDlgItemText (hwnd, IDC_EDIT2, stringbaseaddress(p->userinitials));
01301             SetDlgItemText (hwnd, IDC_EDIT3, stringbaseaddress(p->userorg));
01302             SetDlgItemText (hwnd, IDC_EDIT4, stringbaseaddress(p->useremail));
01303 
01304             SendDlgItemMessage (hwnd, IDC_EDIT1, EM_SETSEL, (WPARAM) (INT) 0, (LPARAM) (INT) -1);
01305             SetFocus (GetDlgItem (hwnd, IDC_EDIT1));
01306             return (false);
01307 
01308         case WM_COMMAND:
01309             switch (LOWORD(wParam))
01310                 {
01311                 case IDOK:
01312                     p = (tyUserInfoDialogInfo *) GetWindowLong (hwnd, DWL_USER);
01313 
01314                     GetDlgItemText (hwnd, IDC_EDIT1, stringbaseaddress(p->username), sizeof(bigstring) - 2);
01315                     setstringlength (p->username, strlen(stringbaseaddress(p->username)));
01316 
01317                     GetDlgItemText (hwnd, IDC_EDIT2, stringbaseaddress(p->userinitials), sizeof(bigstring) - 2);
01318                     setstringlength (p->userinitials, strlen(stringbaseaddress(p->userinitials)));
01319 
01320                     GetDlgItemText (hwnd, IDC_EDIT3, stringbaseaddress(p->userorg), sizeof(bigstring) - 2);
01321                     setstringlength (p->userorg, strlen(stringbaseaddress(p->userorg)));
01322 
01323                     GetDlgItemText (hwnd, IDC_EDIT4, stringbaseaddress(p->useremail), sizeof(bigstring) - 2);
01324                     setstringlength (p->useremail, strlen(stringbaseaddress(p->useremail)));
01325 
01326                     EndDialog (hwnd, TRUE);
01327                     return TRUE;
01328 
01329                 case IDCANCEL:
01330                     EndDialog (hwnd, FALSE);
01331                     return TRUE;
01332 
01333                 default:
01334                     break;
01335                 }
01336 
01337         default:
01338             break;
01339         }
01340 
01341     return FALSE;
01342     } /*UserInfoDialogCallback*/
01343 
01344 boolean userinfodialog (bigstring username, bigstring userinitials, bigstring userorg, bigstring useremail) {
01345     OSVERSIONINFO vi;
01346     tyUserInfoDialogInfo p;
01347     int res;
01348     bigstring path;
01349     
01350     p.username = username;
01351     p.userinitials = userinitials;
01352     p.userorg = userorg;
01353     p.useremail = useremail;
01354 
01355     vi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
01356     GetVersionEx (&vi);
01357 
01358     if (vi.dwPlatformId == VER_PLATFORM_WIN32_NT)
01359         copyctopstring ("software\\Microsoft\\Windows NT\\CurrentVersion", path);
01360     else
01361         copyctopstring ("software\\Microsoft\\Windows\\CurrentVersion", path);
01362 
01363     if (stringlength (username) == 0) {
01364         getRegKeyString ((Handle) HKEY_LOCAL_MACHINE, path, "\x0f" "RegisteredOwner", username);
01365 
01366         if (stringlength (username) > 0) {
01367             short pos, i;
01368 
01369             pos = 0;
01370 
01371             setstringlength (userinitials, 0);
01372 
01373             setstringcharacter (userinitials, pos, getstringcharacter(username, 0));
01374 
01375             ++pos;
01376 
01377             for (i = 1; i < (stringlength(username) - 1); i++) {
01378                 if (getstringcharacter (username, i) == ' ') {
01379                     setstringcharacter (userinitials, pos, getstringcharacter(username, i+1));
01380                     ++pos;
01381                     }
01382                 }
01383 
01384             setstringlength(userinitials, pos); /*6.1fc2 AR: was pos+1*/
01385             }
01386         }
01387 
01388     if (stringlength (userorg) == 0) {
01389         getRegKeyString ((Handle) HKEY_LOCAL_MACHINE, path, "\x16" "RegisteredOrganization", userorg);
01390         }
01391 
01392 
01393     nullterminate (username);
01394     nullterminate (userinitials);
01395     nullterminate (userorg);
01396     nullterminate (useremail);
01397 
01398     releasethreadglobals ();
01399 
01400     res = DialogBoxParam (hInst, MAKEINTRESOURCE (IDD_DIALOGUSERINFO), hwndMDIClient, (DLGPROC)UserInfoDialogCallback, (LPARAM) &p);
01401     
01402     grabthreadglobals ();
01403 
01404     if (res > 0)
01405         return (true);
01406     
01407     return (false);
01408     } /*userinfodialog*/
01409 
01410 boolean initdialogs (void) {return true;}
01411 
01412 
01413 #endif
01414 
01415 // land.c
01416 
01417 boolean landeventfilter (EventRecord *ev) {return false;}
01418 
01419 
01420 
01421 /*  Build file name takes the path and file components and concatenats them.
01422     The sources may be a standard string, a pascal string or a c string.
01423     the type field specifies the string type:
01424     0 - standard string
01425     1 - C string
01426     2 - Pascal String
01427 */
01428 
01429 boolean buildfilename (unsigned char * pathsource, short pathtype, unsigned char * filesource, short filetype, char * dest)
01430     {
01431     short pathlen;
01432     short filelen;
01433     char * pathaddr;
01434     char * fileaddr;
01435 
01436     setstringlength (dest, 0);      /* incase we return false - set this string to null*/
01437 
01438     switch (pathtype)
01439         {
01440         case 0:         /*current string type*/
01441             pathlen = stringlength (pathsource);
01442             pathaddr = stringbaseaddress (pathsource);
01443             break;
01444 
01445         case 1:
01446             pathlen = strlen (pathsource);
01447             pathaddr = pathsource;
01448             break;
01449 
01450         case 2:
01451             pathlen = pathsource[0];
01452             pathaddr = &(pathsource[1]);
01453             break;
01454 
01455         default:
01456             return (false);
01457         }
01458 
01459     switch (filetype)
01460         {
01461         case 0:         /*current string type*/
01462             filelen = stringlength (filesource);
01463             fileaddr = stringbaseaddress (filesource);
01464             break;
01465 
01466         case 1:
01467             filelen = strlen (filesource);
01468             fileaddr = filesource;
01469             break;
01470 
01471         case 2:
01472             filelen = filesource[0];
01473             fileaddr = &(filesource[1]);
01474             break;
01475 
01476         default:
01477             return (false);
01478         }
01479 
01480     if ((pathlen + filelen) > 256)
01481         return (false);
01482 
01483     memmove (stringbaseaddress(dest), pathaddr, pathlen);
01484     memmove (stringbaseaddress(dest)+pathlen, fileaddr, filelen);
01485     setstringlength (dest, pathlen + filelen);
01486 #ifdef PASCALSTRINGVERSION
01487         dest [stringlength(dest) + 1] = 0;
01488 #endif
01489     return (true);
01490     }
01491 
01492 boolean appendcstring (bigstring dest, char * cstringsource) {
01493     short lendest, lensource;
01494 
01495     lendest = stringlength (dest);
01496     lensource = strlen (cstringsource);
01497 
01498     if (lensource+lendest > 255)
01499         return (false);
01500 
01501     memmove (stringbaseaddress (dest)+lendest, cstringsource, lensource);
01502     setstringlength (dest, lendest+lensource);
01503     return (true);
01504     }
01505 
01506 
01507 // langipcmenus.c
01508 
01509 boolean langipcmenustartup (void) {return true;}
01510 
01511 boolean langipcmenushutdown (void) {return true;}
01512 
01513 boolean langipcsymbolchanged (hdlhashtable ht, const bigstring bs, boolean fl) {return true;}
01514 
01515 boolean langipcsymbolinserted (hdlhashtable ht, const bigstring bs) {return true;}
01516 
01517 boolean langipcsymboldeleted (hdlhashtable ht, const bigstring bs) {return true;}
01518 
01519 
01520 // langdialog.h
01521 
01522 boolean langdialogstart (void) {return (true);}
01523 
01524 

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