RDK Documentation (Open Sourced RDK Components)
rmh_app.h
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 #ifndef RMH_APP_H
20 #define RMH_APP_H
21 
22 #include <stdlib.h>
23 #include <stdio.h>
24 #include <string.h>
25 #include "rdk_moca_hal.h"
26 
27 #define RMH_PrintErr(fmt, ...) RMH_Print(RMH_LOG_ERROR, "ERROR: ", fmt, ##__VA_ARGS__);
28 #define RMH_PrintWrn(fmt, ...) RMH_Print(RMH_LOG_ERROR, "WARNING: ", fmt, ##__VA_ARGS__);
29 #define RMH_PrintMsg(fmt, ...) RMH_Print(RMH_LOG_MESSAGE, "", fmt, ##__VA_ARGS__);
30 #define RMH_PrintDbg(fmt, ...) RMH_Print(RMH_LOG_DEBUG, "", fmt, ##__VA_ARGS__);
31 #define RMH_Print(level, logPrefix, fmt, ...) { \
32  if (app && (app->apiLogLevel & level) == level) { \
33  fprintf(stdout, "%s" logPrefix fmt "", app->appPrefix ? app->appPrefix : "", ##__VA_ARGS__); \
34  } \
35 }
36 
37 struct RMHApp;
38 typedef struct RMHApp_API {
39  const char* apiName;
40  const char* apiAlias;
41  RMH_Result (*apiFunc)();
42  const RMH_Result (*apiHandlerFunc)(const struct RMHApp *app, void *api);
43 } RMHApp_API;
44 
45 typedef struct RMHApp_List {
46  uint32_t apiListSize;
47  struct RMHApp_API apiList[RMH_MAX_NUM_APIS];
48 } RMHApp_List;
49 
50 typedef struct RMHApp {
51  RMH_Handle rmh;
52  int argc;
53  char **argv;
54 
55  bool argMonitorDriverDebug;
56  bool argHelpRequested;
57  bool argPrintMatch;
58  bool argPrintApis;
59 
60  uint32_t apiLogLevel;
61  uint32_t driverLogLevel;
62  const char* argRunCommand;
63  const char* appPrefix;
64 
65  RMH_APIList* allAPIs;
66  RMH_APIList* unimplementedAPIs;
67  RMH_APITagList* rmhAPITags;
68 
69  RMHApp_List handledAPIs;
70  RMH_APIList local;
71 } RMHApp;
72 
73 RMH_Result RMHApp_ReadMenuOption(RMHApp *app, uint32_t *value, bool helpSupported, bool *helpRequested);
74 const char * RMHApp_ReadNextArg(RMHApp *app);
75 void RMHApp_RegisterAPIHandlers(RMHApp *app);
76 
77 #endif
RMH_APITagList
Definition: rmh_type.h:240
RMH
Definition: librmh.h:57
RMHApp
Definition: rmh_app.h:50
RMHApp_API
Definition: rmh_app.h:38
RMH_APIList
Definition: rmh_type.h:234
RMHApp_List
Definition: rmh_app.h:45