source: trunk/Lucide/gui/lcd.c @ 467

Last change on this file since 467 was 467, checked in by dmik, 11 years ago

launcher: Retain the previous BEGINLIBPATH setting since loading lucide.dll may fail otherwise if some of its prerequisites (like libc063.dll) are located in a path from that previous setting and LIBPATHSTRICT=T mode is used (fixes ticket:219).

File size: 3.5 KB
Line 
1/* ***** BEGIN LICENSE BLOCK *****
2 * Version: CDDL 1.0/LGPL 2.1
3 *
4 * The contents of this file are subject to the COMMON DEVELOPMENT AND
5 * DISTRIBUTION LICENSE (CDDL) Version 1.0 (the "License"); you may not use
6 * this file except in compliance with the License. You may obtain a copy of
7 * the License at http://www.sun.com/cddl/
8 *
9 * Software distributed under the License is distributed on an "AS IS" basis,
10 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11 * for the specific language governing rights and limitations under the
12 * License.
13 *
14 * The Initial Developer of the Original Code is
15 * Eugene Romanenko, netlabs.org.
16 * Portions created by the Initial Developer are Copyright (C) 2006
17 * the Initial Developer. All Rights Reserved.
18 *
19 * Contributor(s):
20 *
21 * Alternatively, the contents of this file may be used under the terms of
22 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
23 * in which case the provisions of the LGPL are applicable instead of those
24 * above. If you wish to allow use of your version of this file only under the
25 * terms of the LGPL, and not to allow others to use your version of this file
26 * under the terms of the CDDL, indicate your decision by deleting the
27 * provisions above and replace them with the notice and other provisions
28 * required by the LGPL. If you do not delete the provisions above, a recipient
29 * may use your version of this file under the terms of any one of the CDDL
30 * or the LGPL.
31 *
32 * ***** END LICENSE BLOCK ***** */
33
34
35#include "os2all.h"
36
37#include <stdio.h>
38#include <string.h>
39#include <process.h>
40
41//
42// Lcd.exe sets BEGINLIBPATH to directory where Lucide resides
43// and executes Lucide.exe
44//
45
46char lucideDir[ CCHMAXPATH ] = "";
47
48typedef APIRET (APIENTRY *LMain)(int argc, char **argv);
49
50int main( int argc, char *argv[] )
51{
52    int result = 1;
53    char *last_slash;
54    CHAR modName[ CCHMAXPATH + 15 /*";%BEGINLIBPATH%"*/ ] = { 0 };
55    HMODULE hmod = NULLHANDLE;
56    APIRET rc = 0;
57
58#ifdef __TEST__
59    PPIB pib;
60    PTIB tib;
61    DosGetInfoBlocks(&tib, &pib);
62    pib->pib_ultype = 3;
63#endif
64
65    // fill lucide dir
66    strcpy( lucideDir, argv[0] );
67    if ( ( last_slash = strrchr( lucideDir, '\\' ) ) == NULL )
68    {
69        return 1;
70    }
71    else
72    {
73        *last_slash = 0;
74    }
75    // retain the previous BEGINLIBPATH setting
76    strcat(lucideDir, ";%BEGINLIBPATH%");
77
78    // set beginlibpath
79    DosSetExtLIBPATH( lucideDir, BEGIN_LIBPATH );
80
81    rc = DosLoadModule( modName, sizeof( modName ), "Lucide", &hmod );
82    if ( rc == 0 )
83    {
84        PFN pfn = NULL;
85        if ( DosQueryProcAddr( hmod, 0, "LucideMain", &pfn ) == 0 )
86        {
87            LMain LucideMain = (LMain)pfn;
88            result = LucideMain( argc, argv );
89        }
90        DosFreeModule( hmod );
91    }
92    else
93    {
94        HAB hab;
95        HMQ hmq;
96        char msg[ 256 ];
97
98        hab = WinInitialize( 0 );
99        hmq = WinCreateMsgQueue( hab, 0 );
100
101        if ( modName[0] == 0 ) { // No modulename
102            snprintf( msg, sizeof( msg ), "Error loading Lucide.dll: SYS%04u", rc );
103        }
104        else {
105            snprintf( msg, sizeof( msg ),
106                      "Error loading Lucide.dll: can't find module '%s' (SYS%04u)",
107                      modName, rc );
108        }
109        WinMessageBox( HWND_DESKTOP, NULLHANDLE, msg, NULL, 1, MB_OK | MB_MOVEABLE );
110
111        WinDestroyMsgQueue( hmq );
112        WinTerminate( hab );
113    }
114
115    return result;
116}
117
Note: See TracBrowser for help on using the repository browser.