home *** CD-ROM | disk | FTP | other *** search
/ Enter 1999 April - Disc 1 / enter_04_1999_1.iso / OS2 / OSMULTI / OSMULTI2.C < prev    next >
Encoding:
C/C++ Source or Header  |  1999-02-01  |  2.9 KB  |  160 lines

  1. /*
  2.  * osmulti2.c - Osuwari Multi for OS/2 PM, Program Entry
  3.  */
  4.  
  5. #include <stdio.h>
  6. #include <stdlib.h>
  7. #include <string.h>
  8.  
  9. #define INCL_PM
  10. #include <os2.h>
  11. #include "shapewin.h"
  12.  
  13. #include "osmulti2.h"
  14. #include "osmulres.h"
  15.  
  16. /*
  17.  * myname - adjust and save program names
  18.  */
  19.  
  20. UCHAR   ProgramPath[256] ;
  21. UCHAR   ProgramName[256] ;
  22. UCHAR   ProfilePath[256] ;
  23.  
  24. static  void    myname(PSZ me)
  25. {
  26.     PUCHAR  p, last ;
  27.  
  28.     /*
  29.      * full pathname of program
  30.      */
  31.  
  32.     for (p = me, last = NULL ; *p ; p++) {
  33.         if (*p == '/' || *p == '\\') {
  34.             last = p ;
  35.         }
  36.     }
  37.     if (last != NULL) {
  38.         strcpy(ProgramPath, me) ;
  39.     } else if (DosSearchPath(7, "PATH", me, ProgramPath, 256) != 0) {
  40.         strcpy(ProgramPath, me) ;
  41.     }
  42.  
  43.     /*
  44.      * basename of program
  45.      */
  46.  
  47.     for (p = ProgramPath, last = NULL ; *p ; p++) {
  48.         if (*p == '/' || *p == '\\') {
  49.             last = p ;
  50.         }
  51.     }
  52.     if (last == NULL) {
  53.         strcpy(ProgramName, ProgramPath) ;
  54.     } else {
  55.         strcpy(ProgramName, &last[1]) ;
  56.     }
  57.     if ((p = strrchr(ProgramName, '.')) != NULL) {
  58.         *p = '\0' ;
  59.     }
  60.  
  61.     /*
  62.      * pathname of Profile
  63.      */
  64.  
  65.     strcpy(ProfilePath, ProgramPath) ;
  66.  
  67.     if ((p = strrchr(ProfilePath, '.')) == NULL) {
  68.         strcat(ProfilePath, ".ini") ;
  69.     } else {
  70.         strcpy(p, ".ini") ;
  71.     }
  72. }
  73.  
  74. /*
  75.  * parseArgs - parse command line arguments
  76.  */
  77.  
  78. int     ProgramLang = NLS_JA ;
  79.  
  80. static  void    parseArgs(int ac, char *av[])
  81. {
  82.     int     i ;
  83.  
  84.     for (i = 1 ; i < ac ; i++) {
  85.         if (stricmp(av[i], "ja") == 0) {
  86.         ProgramLang = NLS_JA ;
  87.     } else if (stricmp(av[i], "en") == 0) {
  88.         ProgramLang = NLS_EN ;
  89.     }
  90.     }
  91. }
  92.  
  93. /*
  94.  * Error Notify
  95.  */
  96.  
  97. void    osmMessage(PSZ msg)
  98. {
  99.     WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, msg, ProgramName, 0, MB_OK) ;
  100. }
  101.  
  102. /*
  103.  * main - program start here
  104.  */
  105.  
  106. int     main(int ac, char *av[])
  107. {
  108.     HAB     hab  ;
  109.     HMQ     hmq  ;
  110.     QMSG    qmsg ;
  111.     SWP     swp  ;
  112.  
  113.     /*
  114.      * Initializing
  115.      */
  116.  
  117.     myname(av[0]) ;
  118.     _wildcard(&ac, &av) ;
  119.     parseArgs(ac, av)   ;
  120.  
  121.     hab = WinInitialize(0) ;
  122.     hmq = WinCreateMsgQueue(hab, 0) ;
  123.  
  124.     profileLoad(hab) ;
  125.  
  126.     if (bitmapLoad(hab) != TRUE) {
  127.         osmMessage("failed to load Bitmaps") ;
  128.         WinDestroyMsgQueue(hmq) ;
  129.         WinTerminate(hab) ;
  130.     return 1 ;
  131.     }
  132.     if (windowCreate(hab) != TRUE) {
  133.         osmMessage("failed to create Windows") ;
  134.     bitmapFree() ;
  135.         WinDestroyMsgQueue(hmq) ;
  136.         WinTerminate(hab) ;
  137.     return 2 ;
  138.     }
  139.     
  140.     /*
  141.      * Start Window Processing
  142.      */
  143.  
  144.     while (WinGetMsg(hab, &qmsg, 0, 0, 0)) {
  145.         WinDispatchMsg(hab, &qmsg) ;
  146.     }
  147.  
  148.     /*
  149.      * dispose resources
  150.      */
  151.  
  152.     windowDispose(hab) ;
  153.     bitmapFree() ;
  154.     
  155.     WinDestroyMsgQueue(hmq) ;
  156.     WinTerminate(hab) ;
  157.  
  158.     return 0 ;
  159. }
  160.