home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / yacl-012.zip / ui / mainprog.cxx < prev    next >
C/C++ Source or Header  |  1995-04-04  |  2KB  |  91 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6. /*
  7.  *
  8.  *          Copyright (C) 1994, M. A. Sridhar
  9.  *  
  10.  *
  11.  *     This software is Copyright M. A. Sridhar, 1994. You are free
  12.  *     to copy, modify or distribute this software  as you see fit,
  13.  *     and to use  it  for  any  purpose, provided   this copyright
  14.  *     notice and the following   disclaimer are included  with all
  15.  *     copies.
  16.  *
  17.  *                        DISCLAIMER
  18.  *
  19.  *     The author makes no warranties, either expressed or implied,
  20.  *     with respect  to  this  software, its  quality, performance,
  21.  *     merchantability, or fitness for any particular purpose. This
  22.  *     software is distributed  AS IS.  The  user of this  software
  23.  *     assumes all risks  as to its quality  and performance. In no
  24.  *     event shall the author be liable for any direct, indirect or
  25.  *     consequential damages, even if the  author has been  advised
  26.  *     as to the possibility of such damages.
  27.  *
  28.  */
  29.  
  30.  
  31.  
  32.  
  33. #if defined(__GNUC__)
  34. #pragma implementation
  35. #endif
  36.  
  37.  
  38. // A default main program included with YACL's user interface library
  39.  
  40. #if defined(__MS_WINDOWS__)
  41. #include <string.h>
  42. #include <windows.h>
  43. #endif
  44.  
  45. #include "base/string.h"
  46. #include "ui/applic.h"
  47.  
  48.  
  49. #if defined(__MS_WINDOWS__)
  50. int PASCAL WinMain(HANDLE hInstance, HANDLE hPrevInstance,
  51.                    LPSTR lpCmdLn, int nCmdShow)
  52. #elif defined(__X_MOTIF__) || defined(__OS2__)
  53. int main (int argc, char* argv[])
  54. #endif
  55.     
  56. {
  57.     bool ownApp = FALSE;
  58.     UI_Application* theApp = _TheApplication;
  59.     if (!theApp) {
  60.         theApp = new UI_Application;
  61.         ownApp = TRUE;
  62.     }
  63.     
  64. #if defined(__MS_WINDOWS__)
  65.     CL_String fld[20];
  66.     short argc = CL_String (lpCmdLn).Split (fld, 20);
  67.     char** argv = new char* [argc+1];
  68.     for (short i = 0; i < argc; i++) {
  69.         argv[i] = new char [fld[i].Size() + 1];
  70.         strcpy (argv[i], (const char*) fld[i]);
  71.     }
  72.     argv[argc] = 0;
  73.     theApp->Initialize (hInstance, hPrevInstance, lpCmdLn, nCmdShow);
  74. #elif defined(__X_MOTIF__) || defined(__OS2__)
  75.     theApp->Initialize (argc, argv);
  76. #endif
  77.  
  78.     int returnVal =  theApp->Main (argc, argv);
  79.  
  80. #if defined(__MS_WINDOWS__)
  81.     for (i = 0; i < argc; i++) {
  82.         delete [] argv[i];
  83.     }
  84.     delete [] argv;
  85. #endif
  86.     if (ownApp)
  87.         delete theApp;
  88.     return returnVal;
  89.     
  90. }
  91.