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;
121 if (!doAppInit && !
controlURL && getppid() == 1)
125 char rawExecutablePath[PATH_MAX+1];
126 uint32_t size =
sizeof(rawExecutablePath);
127 _NSGetExecutablePath(rawExecutablePath, &size);
131 printf(
"Usage: %s [options]\n"
133 " --help Display this information.\n"
134 " --vuo-licenses Display license information.\n",
139 else if (doPrintLicenses)
141 printf(
"This composition may include software licensed under the following terms:\n\n");
144 char licensesPath[PATH_MAX+1];
149 strncat(licensesPath,
"/Vuo.framework/Versions/" VUO_FRAMEWORK_VERSION_STRING
"/Documentation/Licenses", PATH_MAX);
154 strncat(licensesPath,
"/VuoRunner.framework/Versions/" VUO_FRAMEWORK_VERSION_STRING
"/Documentation/Licenses", PATH_MAX);
157 bool foundLicenses =
false;
158 if (licensesPath[0] && access(licensesPath, 0) == 0)
160 DIR *dirp = opendir(licensesPath);
162 while ((dp = readdir(dirp)) != NULL)
164 if (dp->d_name[0] ==
'.')
167 printf(
"=== %s =====================================================\n\n",dp->d_name);
169 size_t pathSize = strlen(licensesPath) + dp->d_namlen + 2;
170 char licensePath[pathSize];
171 strlcpy(licensePath, licensesPath, pathSize);
172 strlcat(licensePath,
"/", pathSize);
173 strlcat(licensePath, dp->d_name, pathSize);
175 int fd = open(licensePath, O_RDONLY);
178 while((bytesRead = read(fd, data, 1024)) > 0)
179 write(1, data, bytesRead);
183 foundLicenses =
true;
189 printf(
"(No license information found.)\n");
196 void *executableHandle = dlopen(rawExecutablePath, 0);
197 if (! executableHandle)
199 VUserLog(
"The composition couldn't be started because a handle to the executable couldn't be obtained : %s", dlerror());
206 executableHandle, NULL, doAppInit);
208 dlclose(executableHandle);
234 void *compositionBinaryHandle,
void *previousRuntimeState,
bool doAppInit)
254 workingDirectory, compositionBinaryHandle);
264 typedef void (*vuoAppInitType)(
bool requiresDockIcon);
265 vuoAppInitType vuoAppInit = (vuoAppInitType) dlsym(RTLD_SELF,
"VuoApp_init");