11 #include <mach-o/dyld.h>
35 bool doAppInit =
false;
38 bool isPaused =
false;
42 bool doPrintHelp =
false;
43 bool doPrintLicenses =
false;
48 char **getoptArgV = (
char **)malloc(
sizeof(
char *) * argc);
49 for(
int i = 0; i < argc; ++i)
52 if (strncmp(argv[i],
"-psn_", 5) == 0)
60 getoptArgV[getoptArgC++] = argv[i];
63 static struct option options[] = {
64 {
"help", no_argument, NULL, 0},
65 {
"vuo-control", required_argument, NULL, 0},
66 {
"vuo-telemetry", required_argument, NULL, 0},
67 {
"vuo-pause", no_argument, NULL, 0},
68 {
"vuo-loader", required_argument, NULL, 0},
69 {
"vuo-runner-pipe", required_argument, NULL, 0},
70 {
"vuo-continue-if-runner-dies", no_argument, NULL, 0},
71 {
"vuo-licenses", no_argument, NULL, 0},
72 {
"vuo-runner-pid", required_argument, NULL, 0},
73 {NULL, no_argument, NULL, 0}
77 while ((ret = getopt_long(getoptArgC, getoptArgV,
"", options, &optionIndex)) != -1)
109 doPrintLicenses =
true;
115 VUserLog(
"Error: Unknown option %d.", optionIndex);
124 if (!doAppInit && !
controlURL && getppid() == 1)
128 char rawExecutablePath[PATH_MAX+1];
129 uint32_t size =
sizeof(rawExecutablePath);
130 _NSGetExecutablePath(rawExecutablePath, &size);
134 printf(
"Usage: %s [options]\n"
136 " --help Display this information.\n"
137 " --vuo-licenses Display license information.\n",
142 else if (doPrintLicenses)
144 printf(
"This composition may include software licensed under the following terms:\n\n");
147 char licensesPath[PATH_MAX+1];
152 strncat(licensesPath,
"/Vuo.framework/Versions/" VUO_FRAMEWORK_VERSION_STRING
"/Documentation/Licenses", PATH_MAX);
157 strncat(licensesPath,
"/VuoRunner.framework/Versions/" VUO_FRAMEWORK_VERSION_STRING
"/Documentation/Licenses", PATH_MAX);
160 bool foundLicenses =
false;
161 if (licensesPath[0] && access(licensesPath, 0) == 0)
163 DIR *dirp = opendir(licensesPath);
165 while ((dp = readdir(dirp)) != NULL)
167 if (dp->d_name[0] ==
'.')
170 printf(
"=== %s =====================================================\n\n",dp->d_name);
172 size_t pathSize = strlen(licensesPath) + dp->d_namlen + 2;
173 char licensePath[pathSize];
174 strlcpy(licensePath, licensesPath, pathSize);
175 strlcat(licensePath,
"/", pathSize);
176 strlcat(licensePath, dp->d_name, pathSize);
178 int fd = open(licensePath, O_RDONLY);
181 while((bytesRead = read(fd, data, 1024)) > 0)
182 write(1, data, bytesRead);
186 foundLicenses =
true;
192 printf(
"(No license information found.)\n");
199 void *executableHandle = dlopen(rawExecutablePath, 0);
200 if (! executableHandle)
202 VUserLog(
"The composition couldn't be started because a handle to the executable couldn't be obtained : %s", dlerror());
209 executableHandle, NULL, doAppInit);
211 dlclose(executableHandle);
237 void *compositionBinaryHandle,
void *previousRuntimeState,
bool doAppInit)
257 workingDirectory, compositionBinaryHandle);
267 typedef void (*vuoAppInitType)(
bool requiresDockIcon);
268 vuoAppInitType vuoAppInit = (vuoAppInitType) dlsym(RTLD_SELF,
"VuoApp_init");