< prev index next >

src/jdk.jpackage/linux/native/jpackageapplauncher/launcher.cpp

Print this page




  40     ssize_t len = 0;
  41     std::string result;
  42     char buffer[MAX_PATH] = {0};
  43 
  44     if ((len = readlink("/proc/self/exe", buffer, MAX_PATH - 1)) != -1) {
  45         buffer[len] = '\0';
  46         result = buffer;
  47     }
  48 
  49     return result;
  50 }
  51 
  52 int main(int argc, char *argv[]) {
  53     int result = 1;
  54     setlocale(LC_ALL, "en_US.utf8");
  55     void* library = NULL;
  56 
  57     {
  58         std::string programPath = GetProgramPath();
  59         std::string libraryName = dirname((char*)programPath.c_str());
  60         libraryName += "/libapplauncher.so";
  61         library = dlopen(libraryName.c_str(), RTLD_LAZY);
  62 
  63         if (library == NULL) {
  64             fprintf(stderr, "dlopen failed: %s\n", dlerror());
  65             fprintf(stderr, "%s not found.\n", libraryName.c_str());
  66         }
  67     }
  68 
  69     if (library != NULL) {
  70         start_launcher start = (start_launcher)dlsym(library, "start_launcher");
  71         stop_launcher stop = (stop_launcher)dlsym(library, "stop_launcher");
  72 
  73         if (start != NULL && stop != NULL) {
  74             if (start(argc, argv) == true) {
  75                 result = 0;
  76                 stop();
  77             }
  78         } else {
  79             fprintf(stderr, "cannot find start_launcher and stop_launcher in libapplauncher.so");
  80         }


  40     ssize_t len = 0;
  41     std::string result;
  42     char buffer[MAX_PATH] = {0};
  43 
  44     if ((len = readlink("/proc/self/exe", buffer, MAX_PATH - 1)) != -1) {
  45         buffer[len] = '\0';
  46         result = buffer;
  47     }
  48 
  49     return result;
  50 }
  51 
  52 int main(int argc, char *argv[]) {
  53     int result = 1;
  54     setlocale(LC_ALL, "en_US.utf8");
  55     void* library = NULL;
  56 
  57     {
  58         std::string programPath = GetProgramPath();
  59         std::string libraryName = dirname((char*)programPath.c_str());
  60         libraryName += "/../lib/libapplauncher.so";
  61         library = dlopen(libraryName.c_str(), RTLD_LAZY);
  62 
  63         if (library == NULL) {
  64             fprintf(stderr, "dlopen failed: %s\n", dlerror());
  65             fprintf(stderr, "%s not found.\n", libraryName.c_str());
  66         }
  67     }
  68 
  69     if (library != NULL) {
  70         start_launcher start = (start_launcher)dlsym(library, "start_launcher");
  71         stop_launcher stop = (stop_launcher)dlsym(library, "stop_launcher");
  72 
  73         if (start != NULL && stop != NULL) {
  74             if (start(argc, argv) == true) {
  75                 result = 0;
  76                 stop();
  77             }
  78         } else {
  79             fprintf(stderr, "cannot find start_launcher and stop_launcher in libapplauncher.so");
  80         }
< prev index next >