1 | /*
|
---|
2 | Launch4j (http://launch4j.sourceforge.net/)
|
---|
3 | Cross-platform Java application wrapper for creating Windows native executables.
|
---|
4 |
|
---|
5 | Copyright (C) 2004, 2006 Grzegorz Kowal
|
---|
6 |
|
---|
7 | This library is free software; you can redistribute it and/or
|
---|
8 | modify it under the terms of the GNU Lesser General Public
|
---|
9 | License as published by the Free Software Foundation; either
|
---|
10 | version 2.1 of the License, or (at your option) any later version.
|
---|
11 |
|
---|
12 | This library is distributed in the hope that it will be useful,
|
---|
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
15 | Lesser General Public License for more details.
|
---|
16 |
|
---|
17 | You should have received a copy of the GNU Lesser General Public
|
---|
18 | License along with this library; if not, write to the Free Software
|
---|
19 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
---|
20 |
|
---|
21 |
|
---|
22 | Compiled with Mingw port of GCC,
|
---|
23 | Bloodshed Dev-C++ IDE (http://www.bloodshed.net/devcpp.html)
|
---|
24 | */
|
---|
25 |
|
---|
26 | #include "../resource.h"
|
---|
27 | #include "../head.h"
|
---|
28 |
|
---|
29 | int main(int argc, char* argv[])
|
---|
30 | {
|
---|
31 |
|
---|
32 | //added by oran - to store the value of the 'subcommand' to be run
|
---|
33 | char subcom[8] = "run";
|
---|
34 |
|
---|
35 | setConsoleFlag();
|
---|
36 | HMODULE hLibrary = NULL;
|
---|
37 | char cmdLine[BIG_STR] = {0};
|
---|
38 | int i; // causes error: 'for' loop initial declaration used outside C99 mode.
|
---|
39 | for (i = 1; i < argc; i++) {
|
---|
40 | BOOL quote = strchr(argv[i], ' ') != NULL;
|
---|
41 | if (quote) {
|
---|
42 | strcat(cmdLine, "\"");
|
---|
43 | }
|
---|
44 | strcat(cmdLine, argv[i]);
|
---|
45 | if (quote) {
|
---|
46 | strcat(cmdLine, "\"");
|
---|
47 | }
|
---|
48 |
|
---|
49 | if ( _stricmp(argv[i], "-find") == 0 ) {
|
---|
50 | strcpy( subcom, "find" );
|
---|
51 | } else if ( _stricmp(argv[i], "-compare") == 0 ) {
|
---|
52 | strcpy( subcom, "compare" );
|
---|
53 | }
|
---|
54 |
|
---|
55 | if (i < argc - 1) {
|
---|
56 | strcat(cmdLine, " ");
|
---|
57 | }
|
---|
58 | }
|
---|
59 |
|
---|
60 | if (!prepare(hLibrary, cmdLine, subcom)) {
|
---|
61 | if (hLibrary != NULL) {
|
---|
62 | FreeLibrary(hLibrary);
|
---|
63 | }
|
---|
64 | return 1;
|
---|
65 | }
|
---|
66 | FreeLibrary(hLibrary);
|
---|
67 | int result = (int) execute(TRUE);
|
---|
68 | if (result == -1) {
|
---|
69 | char errMsg[BIG_STR];
|
---|
70 | strcpy(errMsg, "could not start the application: ");
|
---|
71 | strcat(errMsg, strerror(errno));
|
---|
72 | msgBox(errMsg);
|
---|
73 | return 1;
|
---|
74 | } else {
|
---|
75 | return result;
|
---|
76 | }
|
---|
77 | }
|
---|