RDK Documentation (Open Sourced RDK Components)
mfrMgrMain.c
1 /*
2  * If not stated otherwise in this file or this component's Licenses.txt file the
3  * following copyright and licenses apply:
4  *
5  * Copyright 2016 RDK Management
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18 */
19 
20 
21 /**
22 * @defgroup iarmmgrs
23 * @{
24 * @defgroup mfr
25 * @{
26 **/
27 
28 
29 #include "mfrMgrInternal.h"
30 
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34 #include <stdio.h>
35 #ifdef ENABLE_SD_NOTIFY
36 #include <systemd/sd-daemon.h>
37 #endif
38 #ifdef __cplusplus
39 }
40 #endif
41 #include "safec_lib.h"
42 
43 #ifdef RDK_LOGGER_ENABLED
44 
45 int b_rdk_logger_enabled = 0;
46 
47 void logCallback(const char *buff)
48 {
49  LOG("%s",buff);
50 }
51 #endif
52 
53 
54 int main(int argc, char *argv[])
55 {
56  const char* debugConfigFile = NULL;
57  int itr=0;
58  errno_t safec_rc = -1;
59  int ind = -1;
60  int debug_len = strlen("--debugconfig");
61  while (itr < argc)
62  {
63  safec_rc = strcmp_s( "--debugconfig", debug_len, argv[itr], &ind);
64  ERR_CHK(safec_rc);
65  if ((!ind) && (safec_rc == EOK))
66  {
67  itr++;
68  if (itr < argc)
69  {
70  debugConfigFile = argv[itr];
71  }
72  else
73  {
74  break;
75  }
76  }
77  itr++;
78  }
79 
80 #ifdef RDK_LOGGER_ENABLED
81 
82  if(rdk_logger_init(debugConfigFile) == 0) b_rdk_logger_enabled = 1;
83  IARM_Bus_RegisterForLog(logCallback);
84 
85 #endif
86 
87 
88  MFRLib_Start();
89 
90 #ifdef ENABLE_SD_NOTIFY
91  sd_notifyf(0, "READY=1\n"
92  "STATUS=mfrMgrMain is Successfully Initialized\n"
93  "MAINPID=%lu",
94  (unsigned long) getpid());
95 #endif
96 
97  MFRLib_Loop();
98  MFRLib_Stop();
99 }
100 
101 
102 
103 /** @} */
104 /** @} */
MFRLib_Start
IARM_Result_t MFRLib_Start(void)
Starts the MFR lib.
Definition: mfrMgr.c:40
mfrMgrInternal.h
IARM-Bus MFR Manager Internal API.
MFRLib_Stop
IARM_Result_t MFRLib_Stop(void)
Terminates the MFR lib.
Definition: mfrMgr.c:61
MFRLib_Loop
IARM_Result_t MFRLib_Loop()
Listens for component specific events from drivers.
Definition: mfrMgr.c:66
rdk_logger_init
rdk_Error rdk_logger_init(const char *debugConfigFile)
Initialize the logger. Sets up the environment variable storage by parsing debug configuration file t...
Definition: rdk_logger_init.c:57