11 #include <mach-o/dyld.h>
36 bool doAppInit =
false;
39 bool isPaused =
false;
43 bool doPrintHelp =
false;
44 bool doPrintLicenses =
false;
49 char **getoptArgV = (
char **)malloc(
sizeof(
char *) * argc);
50 for(
int i = 0; i < argc; ++i)
53 if (strncmp(argv[i],
"-psn_", 5) == 0)
61 getoptArgV[getoptArgC++] = argv[i];
64 static struct option options[] = {
65 {
"help", no_argument, NULL, 0},
66 {
"vuo-control", required_argument, NULL, 0},
67 {
"vuo-telemetry", required_argument, NULL, 0},
68 {
"vuo-pause", no_argument, NULL, 0},
69 {
"vuo-loader", required_argument, NULL, 0},
70 {
"vuo-runner-pipe", required_argument, NULL, 0},
71 {
"vuo-continue-if-runner-dies", no_argument, NULL, 0},
72 {
"vuo-licenses", no_argument, NULL, 0},
73 {
"vuo-runner-pid", required_argument, NULL, 0},
74 {NULL, no_argument, NULL, 0}
78 while ((ret = getopt_long(getoptArgC, getoptArgV,
"", options, &optionIndex)) != -1)
110 doPrintLicenses =
true;
122 if (!doAppInit && !
controlURL && getppid() == 1)
126 char rawExecutablePath[PATH_MAX+1];
127 uint32_t size =
sizeof(rawExecutablePath);
128 _NSGetExecutablePath(rawExecutablePath, &size);
132 printf(
"Usage: %s [options]\n"
134 " --help Display this information.\n"
135 " --vuo-licenses Display license information.\n",
140 else if (doPrintLicenses)
142 printf(
"This composition may include software licensed under the following terms:\n\n");
145 char licensesPath[PATH_MAX+1];
150 strncat(licensesPath,
"/Vuo.framework/Versions/" VUO_FRAMEWORK_VERSION_STRING
"/Documentation/Licenses", PATH_MAX);
155 strncat(licensesPath,
"/VuoRunner.framework/Versions/" VUO_FRAMEWORK_VERSION_STRING
"/Documentation/Licenses", PATH_MAX);
158 bool foundLicenses =
false;
159 if (licensesPath[0] && access(licensesPath, 0) == 0)
161 DIR *dirp = opendir(licensesPath);
163 while ((dp = readdir(dirp)) != NULL)
165 if (dp->d_name[0] ==
'.')
168 printf(
"=== %s =====================================================\n\n",dp->d_name);
170 size_t pathSize = strlen(licensesPath) + dp->d_namlen + 2;
171 char licensePath[pathSize];
172 strlcpy(licensePath, licensesPath, pathSize);
173 strlcat(licensePath,
"/", pathSize);
174 strlcat(licensePath, dp->d_name, pathSize);
176 int fd = open(licensePath, O_RDONLY);
179 while((bytesRead = read(fd, data, 1024)) > 0)
180 write(1, data, bytesRead);
184 foundLicenses =
true;
190 printf(
"(No license information found.)\n");
197 void *executableHandle = dlopen(rawExecutablePath, 0);
198 if (! executableHandle)
200 VUserLog(
"The composition couldn't be started because a handle to the executable couldn't be obtained : %s", dlerror());
207 executableHandle, NULL, doAppInit);
209 dlclose(executableHandle);
235 void *compositionBinaryHandle,
void *previousRuntimeState,
bool doAppInit)
255 workingDirectory, compositionBinaryHandle);
265 typedef void (*vuoAppInitType)(
bool requiresDockIcon);
266 vuoAppInitType vuoAppInit = (vuoAppInitType) dlsym(RTLD_SELF,
"VuoApp_init");