• R/O
  • SSH
  • HTTPS

exewrap: Commit


Commit MetaInfo

Revision45 (tree)
Time2017-11-28 22:16:26
Authorhirukawa_ryo

Log Message

* exewrap 1.2.3 VMオプション・ファイル機能を追加しました。

Change Summary

Incremental Difference

--- exewrap/trunk/exewrap/src/jvm.c (revision 44)
+++ exewrap/trunk/exewrap/src/jvm.c (revision 45)
@@ -31,6 +31,7 @@
3131 int GetArchitectureBits(const char* jvmpath);
3232 static LPWSTR A2W(LPCSTR s);
3333 static LPSTR W2A(LPCWSTR s);
34+static char* get_line(FILE* fp);
3435
3536
3637 typedef jint (WINAPI* JNIGetDefaultJavaVMInitArgs)(JavaVMInitArgs*);
@@ -95,6 +96,7 @@
9596 int argc;
9697 int i;
9798 int result;
99+ char* vmoptions[256] = {0};
98100
99101 if (!path_initialized)
100102 {
@@ -145,6 +147,29 @@
145147 options[vm_args.nOptions++].optionString = argv[i];
146148 }
147149
150+ //read .exe.vmoptions
151+ //同じVM引数が複数回指定された場合は後優先になるので、.exe.vmoptionsを優先するために最後に追加します。
152+ {
153+ char vm_opt_file[MAX_PATH];
154+ GetModuleFileName(NULL, vm_opt_file, MAX_PATH);
155+ strcat(vm_opt_file, ".vmoptions");
156+ if(GetFileAttributes(vm_opt_file) != -1)
157+ {
158+ FILE* fp = fopen(vm_opt_file, "r");
159+ if(fp != NULL)
160+ {
161+ char* line = NULL;
162+ i = 0;
163+ while((line = get_line(fp)) != NULL)
164+ {
165+ vmoptions[i++] = line;
166+ options[vm_args.nOptions++].optionString = line;
167+ }
168+ fclose(fp);
169+ }
170+ }
171+ }
172+
148173 /*
149174 for(i = 0; i < vm_args.nOptions; i++)
150175 {
@@ -168,6 +193,13 @@
168193 }
169194 HeapFree(GetProcessHeap(), 0, argv);
170195 }
196+ for(i = 0; i < 256; i++)
197+ {
198+ if(vmoptions[i] != NULL)
199+ {
200+ free(vmoptions[i]);
201+ }
202+ }
171203
172204 return env;
173205 }
@@ -1066,3 +1098,40 @@
10661098
10671099 return buf;
10681100 }
1101+
1102+static char* get_line(FILE* fp)
1103+{
1104+ int size = 32;
1105+ int pos = 0;
1106+ int c;
1107+ char* buf = (char*)malloc(size);
1108+
1109+ do {
1110+ c = fgetc(fp);
1111+ if(c != EOF)
1112+ {
1113+ buf[pos++] = (char)c;
1114+ }
1115+ if(pos >= size - 1)
1116+ {
1117+ size *= 2;
1118+ buf = (char*)realloc(buf, size);
1119+ }
1120+ } while(c != EOF && c != '\n');
1121+
1122+ if(pos == 0)
1123+ {
1124+ free(buf);
1125+ return NULL;
1126+ }
1127+ if(pos >= 1 && buf[pos - 1] == '\n')
1128+ {
1129+ buf[pos - 1] = '\0';
1130+ if(pos >= 2 && buf[pos -2] == '\r')
1131+ {
1132+ buf[pos -2] = '\0';
1133+ }
1134+ }
1135+ buf[pos] = '\0';
1136+ return buf;
1137+}
--- exewrap/trunk/exewrap/src/exewrap.c (revision 44)
+++ exewrap/trunk/exewrap/src/exewrap.c (revision 45)
@@ -84,7 +84,7 @@
8484 exe_file = argv[0];
8585 }
8686
87- printf("exewrap 1.2.2 for %s (%d-bit) \r\n"
87+ printf("exewrap 1.2.3 for %s (%d-bit) \r\n"
8888 "Native executable java application wrapper.\r\n"
8989 "Copyright (C) 2005-2017 HIRUKAWA Ryo. All rights reserved.\r\n"
9090 "\r\n"
Show on old repository browser