Merge "[Service] Apply WebAssembly.compileForCaching()" into tizen
[platform/framework/web/wrtjs.git] / loader / wrt_loader.cc
1 /*
2  * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  *    Licensed under the Apache License, Version 2.0 (the "License");
5  *    you may not use this file except in compliance with the License.
6  *    You may obtain a copy of the License at
7  *
8  *        http://www.apache.org/licenses/LICENSE-2.0
9  *
10  *    Unless required by applicable law or agreed to in writing, software
11  *    distributed under the License is distributed on an "AS IS" BASIS,
12  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  *    See the License for the specific language governing permissions and
14  *    limitations under the License.
15  */
16 #include <dlfcn.h>
17 #include <dlog/dlog.h>
18
19 // loader file must have "User" execute label, because launchpad daemon runs
20 // with "System::Privileged" label.
21 int main(int argc, char* argv[]) {
22   dlog_print(DLOG_INFO, "CHROMIUM", "Begin wrt-loader");
23   void* handle = dlopen("/usr/bin/wrt", RTLD_NOW);
24   if (!handle) {
25     dlog_print(DLOG_ERROR, "CHROMIUM", "Failed to load wrt (%s)", dlerror());
26     return 1;
27   }
28
29   typedef int (*MAIN_FUNC)(int argc, char* argv[]);
30
31   MAIN_FUNC real_main = reinterpret_cast<MAIN_FUNC>(dlsym(handle, "main"));
32   if (!real_main) {
33     dlog_print(DLOG_ERROR, "CHROMIUM", "Failed to load real_main (%s)", dlerror());
34     return 1;
35   }
36
37   int ret = real_main(argc, argv);
38   dlclose(handle);
39
40   return ret;
41 }