Init basesystem source codes.
[staging/basesystem.git] / video_in_hal / systemservice / logger_service / server / realtimeUsbLog / src / loggerservice_main.cpp
1 /*
2  * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
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
17 ///////////////////////////////////////////////////////////////////////////////
18 /// \ingroup  tag_SystemManager
19 /// \brief    Application entry point.
20 ///
21 ///////////////////////////////////////////////////////////////////////////////
22 #include <errno.h>
23 #include <sys/types.h>
24 #include <fcntl.h>
25 #include <stdio.h>
26 #include <sys/stat.h>
27 #include <system_service/ss_system_if.h>
28 #include <native_service/frameworkunified_dispatcher.h>
29 #include <system_service/ss_string_maps.h>
30 #include <system_service/ss_version.h>
31 #include <native_service/ns_version_if.h>
32 #include <system_service/ss_system_types.h>
33 #include <system_service/ss_logger_store_logs.h>
34 #include <fstream>
35 #include <cstdlib>
36
37 BOOL   g_isExec = FALSE;
38
39 //////////////////////////////////////////
40 //  Function : FrameworkunifiedOnInitialization
41 //////////////////////////////////////////
42 EFrameworkunifiedStatus FrameworkunifiedOnInitialization(HANDLE hApp) {
43   EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
44   eStatus = StartRtUsbLogThread(hApp);
45   return eStatus;
46 }
47
48 //////////////////////////////////////////
49 //  Function : FrameworkunifiedOnDestroy
50 //////////////////////////////////////////
51 EFrameworkunifiedStatus FrameworkunifiedOnDestroy(HANDLE hApp) {
52   return eFrameworkunifiedStatusOK;
53 }
54
55 //////////////////////////////////////////
56 //  Function : FrameworkunifiedOnDummy
57 //////////////////////////////////////////
58 EFrameworkunifiedStatus FrameworkunifiedOnDummy(HANDLE hApp) {
59   return eFrameworkunifiedStatusOK;
60 }
61
62 //////////////////////////////////////////
63 //  Function : main
64 //////////////////////////////////////////
65 int main(int argc, char *argv[]) {
66   HANDLE hApp;
67   int nsFd;
68   char clientName[16] = "realtimeUsbLog";
69   FrameworkunifiedDefaultCallbackHandler cbFuncs;
70
71   cbFuncs.onInitilization = FrameworkunifiedOnInitialization;
72   cbFuncs.onDestroy = FrameworkunifiedOnDestroy;
73
74   cbFuncs.onStart = FrameworkunifiedOnDummy;
75   cbFuncs.onStop = FrameworkunifiedOnDummy;
76   cbFuncs.onDebugDump = FrameworkunifiedOnDummy;
77   cbFuncs.createStateMachine = FrameworkunifiedOnDummy;
78   cbFuncs.ssFrameworkInterface = FrameworkunifiedOnDummy;
79
80   FrameworkunifiedCreateDispatcherWithoutLoop(clientName, hApp, argc, argv, &cbFuncs, FALSE);
81
82   FrameworkunifiedGetDispatcherFD(hApp, &nsFd);
83
84   g_isExec = TRUE;
85   while (g_isExec) {
86     fd_set  fds;
87     int maxFd = 0;
88
89     FD_ZERO(&fds);
90
91     FD_SET(nsFd, &fds);
92     maxFd = nsFd;
93
94     select(maxFd + 1, &fds, NULL, NULL, NULL);
95
96     if (FD_ISSET(nsFd, &fds)) {
97       FrameworkunifiedDispatchProcessWithoutLoop(hApp);
98     }
99   }
100
101   FrameworkunifiedDestroyDispatcherWithoutLoop(hApp);
102   return 0;
103 }