return 1;
}
-static int
-get_dir_fd_from_path(const char* path)
-{
- int i = 0;
- int count = 0;
- const int len = strlen(path);
- char dname[PATH_MAX];
- memset(dname, 0, PATH_MAX);
-
- const char* p = path + len;
- for (i = 0; i < len; i++, p--)
- {
- if (*p == '/')
- {
- count++;
-
- if (count == 2)
- {
- goto OUT;
- }
- }
- }
-
- LOGI("Wrong path format : %s.", path);
-
- return -1;
-
-OUT:
- strncpy(dname, path, p - path);
-
- const int fd = open(dname, O_RDONLY | O_CLOEXEC | O_DIRECTORY);
-
- LOGI("Directory path : %s, fd : %d.", dname, fd);
- return fd;
-}
-
int
main(int argc, char* argv[])
return -1;
}
- int fd = get_dir_fd_from_path(argv[0]);
- if (fd == -1)
- {
- LOGE("Failed to open path.");
- fprintf(stderr, "Failed to open %s.\n", argv[0]);
- dlclose(real_handle);
- return -1;
- }
-
pRealMain = (int (*)(int, char*[])) dlsym(real_handle, "OspMain");
errormsg = dlerror();
if (errormsg != NULL)
}
// actual initialization
- (*pAppInfoInit)(appid, executable_name, argc, argv, fd);
+ (*pAppInfoInit)(appid, executable_name, argc, argv, -1);
(*pRealMain)(argc, argv);
LOGI("Osp application terminates.");
return 1;
}
-static int
-get_dir_fd_from_path(const char* path)
-{
- int i = 0;
- int count = 0;
- const int len = strlen(path);
- char dname[PATH_MAX];
- memset(dname, 0, PATH_MAX);
-
- const char* p = path + len;
- for (i = 0; i < len; i++, p--)
- {
- if (*p == '/')
- {
- count++;
-
- if (count == 2)
- {
- goto OUT;
- }
- }
- }
-
- LOGI("Wrong path format : %s.", path);
-
- return -1;
-
-OUT:
- strncpy(dname, path, p - path);
-
- const int fd = open(dname, O_RDONLY | O_CLOEXEC | O_DIRECTORY);
-
- LOGI("Directory path : %s, fd : %d.", dname, fd);
- return fd;
-}
-
int
main(int argc, char* argv[])
return -1;
}
- int fd = get_dir_fd_from_path(argv[0]);
- if (fd == -1)
- {
- LOGE("Failed to open path.");
- fprintf(stderr, "Failed to open %s.\n", argv[0]);
- dlclose(real_handle);
- return -1;
- }
-
pRealMain = (int (*)(int, char*[])) dlsym(real_handle, "OspMain");
errormsg = dlerror();
if (errormsg != NULL)
}
// actual initialization
- (*pAppInfoInit)(appid, executable_name, argc, argv, fd);
+ (*pAppInfoInit)(appid, executable_name, argc, argv, -1);
(*pRealMain)(argc, argv);
LOGI("Osp application terminates.");
return 0;
}
-static int
-get_dir_fd_from_path(const char* path)
-{
- int i = 0;
- int count = 0;
- const int len = strlen(path);
- char dname[PATH_MAX];
- memset(dname, 0, PATH_MAX);
-
- const char* p = path + len;
- for (i = 0; i < len; i++, p--)
- {
- if (*p == '/')
- {
- count++;
-
- if (count == 2)
- {
- goto OUT;
- }
- }
- }
-
- LOGI("Wrong path format : %s.", path);
-
- return -1;
-
-OUT:
- strncpy(dname, path, p - path);
-
- const int fd = open(dname, O_RDONLY | O_CLOEXEC | O_DIRECTORY);
-
- LOGI("Directory path : %s, fd : %d.", dname, fd);
- return fd;
-}
int
main(int argc, char* argv[])
return -1;
}
- int fd = get_dir_fd_from_path(argv[0]);
- if (fd == -1)
- {
- LOGE("Failed to open path.");
- fprintf(stderr, "Failed to open %s.\n", argv[0]);
- dlclose(so_handle);
- return -1;
- }
-
handle = dlopen(buffer, RTLD_LAZY | RTLD_GLOBAL);
if (!handle)
{
}
// actual initialization
- (*pAppInfoInit)(appid, executable_name, argc, argv, fd);
+ (*pAppInfoInit)(appid, executable_name, argc, argv, -1);
(*pRealMain)(argc, argv);
LOGI("Osp application terminates.");