[130] | 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 | #define INCL_DOS |
---|
[190] | 36 | #define INCL_WIN |
---|
[130] | 37 | #include <os2.h> |
---|
| 38 | |
---|
[190] | 39 | #include <stdio.h> |
---|
[130] | 40 | #include <string.h> |
---|
| 41 | #include <process.h> |
---|
| 42 | |
---|
| 43 | // |
---|
| 44 | // Lcd.exe sets BEGINLIBPATH to directory where Lucide resides |
---|
| 45 | // and executes Lucide.exe |
---|
| 46 | // |
---|
| 47 | |
---|
| 48 | char lucideDir[ CCHMAXPATH ] = ""; |
---|
| 49 | |
---|
[138] | 50 | typedef APIRET (APIENTRY *LMain)(int argc, char **argv); |
---|
| 51 | |
---|
[130] | 52 | int main( int argc, char *argv[] ) |
---|
| 53 | { |
---|
[138] | 54 | int result = 1; |
---|
[130] | 55 | char *last_slash; |
---|
[190] | 56 | CHAR modName[ CCHMAXPATH ] = { 0 }; |
---|
[138] | 57 | HMODULE hmod = NULLHANDLE; |
---|
[190] | 58 | APIRET rc = 0; |
---|
[130] | 59 | |
---|
[138] | 60 | #ifdef __TEST__ |
---|
| 61 | PPIB pib; |
---|
| 62 | PTIB tib; |
---|
| 63 | DosGetInfoBlocks(&tib, &pib); |
---|
| 64 | pib->pib_ultype = 3; |
---|
| 65 | #endif |
---|
| 66 | |
---|
[130] | 67 | // fill lucide dir |
---|
| 68 | strcpy( lucideDir, argv[0] ); |
---|
| 69 | if ( ( last_slash = strrchr( lucideDir, '\\' ) ) == NULL ) { |
---|
| 70 | return 1; |
---|
| 71 | } |
---|
| 72 | else { |
---|
| 73 | *last_slash = 0; |
---|
| 74 | } |
---|
| 75 | |
---|
| 76 | // set beginlibpath |
---|
| 77 | DosSetExtLIBPATH( lucideDir, BEGIN_LIBPATH ); |
---|
| 78 | |
---|
[190] | 79 | rc = DosLoadModule( modName, sizeof( modName ), "Lucide", &hmod ); |
---|
| 80 | if ( rc == 0 ) |
---|
[138] | 81 | { |
---|
| 82 | PFN pfn = NULL; |
---|
| 83 | if ( DosQueryProcAddr( hmod, 0, "LucideMain", &pfn ) == 0 ) |
---|
| 84 | { |
---|
| 85 | LMain LucideMain = (LMain)pfn; |
---|
| 86 | result = LucideMain( argc, argv ); |
---|
| 87 | } |
---|
[190] | 88 | DosFreeModule( hmod ); |
---|
[138] | 89 | } |
---|
[190] | 90 | else |
---|
| 91 | { |
---|
| 92 | HAB hab; |
---|
| 93 | HMQ hmq; |
---|
| 94 | char msg[ 256 ]; |
---|
[130] | 95 | |
---|
[190] | 96 | hab = WinInitialize( 0 ); |
---|
| 97 | hmq = WinCreateMsgQueue( hab, 0 ); |
---|
| 98 | |
---|
| 99 | if ( modName[0] == 0 ) { // No modulename |
---|
| 100 | snprintf( msg, sizeof( msg ), "Error loading Lucide.dll: SYS%04u", rc ); |
---|
| 101 | } |
---|
| 102 | else { |
---|
| 103 | snprintf( msg, sizeof( msg ), |
---|
| 104 | "Error loading Lucide.dll: can't find module '%s' (SYS%04u)", |
---|
| 105 | modName, rc ); |
---|
| 106 | } |
---|
| 107 | WinMessageBox( HWND_DESKTOP, NULLHANDLE, msg, NULL, 1, MB_OK | MB_MOVEABLE ); |
---|
| 108 | |
---|
| 109 | WinDestroyMsgQueue( hmq ); |
---|
| 110 | WinTerminate( hab ); |
---|
| 111 | } |
---|
| 112 | |
---|
[138] | 113 | return result; |
---|
[130] | 114 | } |
---|
| 115 | |
---|