Modify tizen coding style
[platform/core/dotnet/launcher.git] / NativeLauncher / launcher / main.cc
index a25eaae..5754589 100644 (file)
@@ -40,110 +40,85 @@ static std::string StandaloneOption("--standalone");
 
 int main(int argc, char *argv[])
 {
-  int i;
-  bool standalone = false;
-  const char* standalonePath = nullptr;
-
-  std::vector<char*> vargs;
-
-  // start index 1 to avoid passing executable name "dotnet-launcher" as a parameter
-  for (i=1; i<argc; i++)
-  {
-    if (VersionOption.compare(argv[i]) == 0)
-    {
-      printf("Dotnet launcher Version %s\n", LAUNCHER_VERSION_STR);
-      return 0;
-    }
-    else if (StandaloneOption.compare(argv[i]) == 0)
-    {
-      standalone = true;
-
-      if (i > argc-1)
-      {
-        fprintf(stderr, "Assembly path must be after \"--standalone\" option\n");
-        return 1;
-      }
-      i++;
-      standalonePath = argv[i];
-    }
-    else
-    {
-      vargs.push_back(argv[i]);
-    }
-  }
-
-  using tizen::runtime::LauncherInterface;
-  using tizen::runtime::Launchpad;
-  using tizen::runtime::AppInfo;
-  std::unique_ptr<LauncherInterface> runtime;
-
-  using tizen::runtime::dotnetcore::CoreRuntime;
-  std::unique_ptr<LauncherInterface> coreRuntime(new CoreRuntime());
-  runtime = std::move(coreRuntime);
-
-  if (standalone)
-  {
-    _DBG("##### Run it standalone #########");
-    const char* appid = getenv("AUL_APPID");
-    _DBG("AUL_APPID : %s", appid);
-    std::string approot;
-    if (appid != nullptr)
-    {
-      const char* approot_path = aul_get_app_root_path();
-      if (approot_path != nullptr)
-      {
-        approot = std::string(approot_path);
-      }
-    }
-    if (approot.empty())
-    {
-      approot = Basename(standalonePath);
-    }
-    if (runtime->Initialize(true) != 0)
-    {
-      _ERR("Failed to initialize");
-      return 1;
-    }
-
-    int args_len = vargs.size();
-    char** args = &vargs[0];
-    if (runtime->Launch(appid, approot.c_str(), standalonePath, args_len, args))
-    {
-      _ERR("Failed to launch");
-      return 0;
-    }
-  }
-  else
-  {
-    Launchpad.OnCreate = [&runtime]()
-    {
-      if (runtime->Initialize(false) != 0)
-      {
-        _ERR("Failed to initialized");
-      }
-      else
-      {
-        _DBG("Success to initialized");
-      }
-    };
-
-    Launchpad.OnTerminate = [&runtime](const AppInfo& info, int argc, char** argv)
-    {
-      _DBG("terminated with app path : %s", info.path.c_str());
-      _DBG("appid : %s", info.id.c_str());
-      _DBG("pkg : %s", info.pkg.c_str());
-      _DBG("type : %s", info.type.c_str());
-
-      // The launchpad pass the name of exe file to the first argument.
-      // For the C# spec, we have to skip this first argument.
-
-      if (runtime->Launch(info.id.c_str(), info.root.c_str(), info.path.c_str(), argc-1, argv+1))
-      {
-        _ERR("Failed to launch");
-      }
-    };
-    Launchpad.LoaderMain(argc, argv);
-  }
-
-  return 0;
+       int i;
+       bool standalone = false;
+       const char* standalonePath = nullptr;
+
+       std::vector<char*> vargs;
+
+       // start index 1 to avoid passing executable name "dotnet-launcher" as a parameter
+       for (i = 1;     i <argc; i++) {
+               if (VersionOption.compare(argv[i]) == 0) {
+                       printf("Dotnet launcher Version %s\n", LAUNCHER_VERSION_STR);
+                       return 0;
+               } else if (StandaloneOption.compare(argv[i]) == 0) {
+                       standalone = true;
+
+                       if (i > argc-1) {
+                               fprintf(stderr, "Assembly path must be after \"--standalone\" option\n");
+                               return 1;
+                       }
+                       i++;
+                       standalonePath = argv[i];
+               } else {
+                       vargs.push_back(argv[i]);
+               }
+       }
+
+       using tizen::runtime::LauncherInterface;
+       using tizen::runtime::Launchpad;
+       using tizen::runtime::AppInfo;
+       std::unique_ptr<LauncherInterface> runtime;
+
+       using tizen::runtime::dotnetcore::CoreRuntime;
+       std::unique_ptr<LauncherInterface> coreRuntime(new CoreRuntime());
+       runtime = std::move(coreRuntime);
+
+       if (standalone) {
+               _DBG("##### Run it standalone #########");
+               const char* appId = getenv("AUL_APPID");
+               _DBG("AUL_APPID : %s", appId);
+               std::string appRoot;
+               if (appId != nullptr) {
+                       const char* appRootPath = aul_get_app_root_path();
+                       if (appRootPath != nullptr)
+                               appRoot = std::string(appRootPath);
+               }
+               if (appRoot.empty())
+                       appRoot = baseName(standalonePath);
+               if (runtime->initialize(true) != 0) {
+                       _ERR("Failed to initialize");
+                       return 1;
+               }
+
+               int argsLen = vargs.size();
+               char** args = &vargs[0];
+               if (runtime->launch(appId, appRoot.c_str(), standalonePath, argsLen, args)) {
+                       _ERR("Failed to launch");
+                       return 0;
+               }
+       } else {
+               Launchpad.onCreate = [&runtime]() {
+                       if (runtime->initialize(false) != 0)
+                               _ERR("Failed to initialized");
+                       else
+                               _DBG("Success to initialized");
+               };
+
+               Launchpad.onTerminate = [&runtime](const AppInfo& appInfo, int argc, char** argv) {
+                       _DBG("terminated with app path : %s", appInfo.path.c_str());
+                       _DBG("appId : %s", appInfo.id.c_str());
+                       _DBG("pkg : %s", appInfo.pkg.c_str());
+                       _DBG("type : %s", appInfo.type.c_str());
+
+                       // The launchpad pass the name of exe file to the first argument.
+                       // For the C# spec, we have to skip this first argument.
+
+                       if (runtime->launch(appInfo.id.c_str(), appInfo.root.c_str(), appInfo.path.c_str(), argc-1, argv+1))
+                               _ERR("Failed to launch");
+               };
+               Launchpad.loaderMain(argc, argv);
+       }
+
+       return 0;
 }