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 #ifdef __cplusplus
31 extern "C" {
32 #endif
33 #include <stdio.h>
34 #ifdef ENABLE_SD_NOTIFY
35 #include <systemd/sd-daemon.h>
36 #endif
37 #ifdef __cplusplus
38 }
39 #endif
40 #include "safec_lib.h"
41 
42 #ifdef RDK_LOGGER_ENABLED
43 int b_rdk_logger_enabled = 0;
44 
45 void logCallback(const char *buff)
46 {
47  LOG("%s",buff);
48 }
49 #endif
50 
51 
52 int main(int argc, char *argv[])
53 {
54  const char* debugConfigFile = NULL;
55  int itr=0;
56  errno_t safec_rc = -1;
57  int ind = -1;
58  int debug_len = strlen("--debugconfig");
59 
60  while (itr < argc)
61  {
62  safec_rc = strcmp_s( "--debugconfig", debug_len, argv[itr], &ind);
63  ERR_CHK(safec_rc);
64  if ((!ind) && (safec_rc == EOK))
65  {
66  itr++;
67  if (itr < argc)
68  {
69  debugConfigFile = argv[itr];
70  }
71  else
72  {
73  break;
74  }
75  }
76  itr++;
77  }
78 
79  #ifdef RDK_LOGGER_ENABLED
80 
81  if(rdk_logger_init(debugConfigFile) == 0) b_rdk_logger_enabled = 1;
82  IARM_Bus_RegisterForLog(logCallback);
83 
84  #endif
85 
86 
87  MFRLib_Start();
88 
89  #ifdef ENABLE_SD_NOTIFY
90  sd_notifyf(0, "READY=1\n"
91  "STATUS=mfrMgrMain is Successfully Initialized\n"
92  "MAINPID=%lu",
93  (unsigned long) getpid());
94  #endif
95 
96  MFRLib_Loop();
97  MFRLib_Stop();
98 
99  return 0;
100 }
101 
102 
103 
104 /** @} */
105 /** @} */
MFRLib_Start
IARM_Result_t MFRLib_Start(void)
Starts the MFR lib.
Definition: mfrMgr.c:40
MFRLib_Stop
IARM_Result_t MFRLib_Stop(void)
Terminates the MFR lib.
Definition: mfrMgr.c:61
mfrMgrInternal.h
IARM-Bus MFR Manager Internal API.
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