RDK Documentation (Open Sourced RDK Components)
librmh.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 
20 #ifndef LIB_RMH_H
21 #define LIB_RMH_H
22 
23 #include <stdio.h>
24 #include <stdlib.h>
25 #include <unistd.h>
26 #include <sys/time.h>
27 #include <time.h>
28 #include <string.h>
29 #include <dlfcn.h>
30 #include "rmh_type.h"
31 
32 void RMH_Print(const RMH_Handle handle, const RMH_LogLevel level, const char *filename, const uint32_t lineNumber, const char *format, ...);
33 #define RMH_PrintErr(fmt, ...) if (!handle || (handle->logLevelBitMask & RMH_LOG_ERROR) == RMH_LOG_ERROR) { RMH_Print(handle, RMH_LOG_ERROR, __FUNCTION__, __LINE__, "ERROR: " fmt, ##__VA_ARGS__); }
34 #define RMH_PrintWrn(fmt, ...) if (!handle || (handle->logLevelBitMask & RMH_LOG_WARNING) == RMH_LOG_WARNING) { RMH_Print(handle, RMH_LOG_WARNING, __FUNCTION__, __LINE__, "WARNING: " fmt, ##__VA_ARGS__); }
35 #define RMH_PrintMsg(fmt, ...) if (!handle || (handle->logLevelBitMask & RMH_LOG_MESSAGE) == RMH_LOG_MESSAGE) { RMH_Print(handle, RMH_LOG_MESSAGE, __FUNCTION__, __LINE__, fmt, ##__VA_ARGS__); }
36 #define RMH_PrintDbg(fmt, ...) if (!handle || (handle->logLevelBitMask & RMH_LOG_DEBUG) == RMH_LOG_DEBUG) { RMH_Print(handle, RMH_LOG_DEBUG, __FUNCTION__, __LINE__, fmt, ##__VA_ARGS__); }
37 #define RMH_PrintTrace(fmt, ...) if ((handle->logLevelBitMask & RMH_LOG_TRACE) == RMH_LOG_TRACE) { RMH_Print(handle, RMH_LOG_TRACE, __FUNCTION__, __LINE__, "[0x%p|0x%p]%.*s" fmt, handle, handle->handle, handle->apiDepth, "\t\t\t\t\t\t\t\t\t", ##__VA_ARGS__); }
38 
39 #define BRMH_RETURN_IF(expr, ret) { if (expr) { RMH_PrintErr("'" #expr "' is true!\n"); return ret; } }
40 #define BRMH_RETURN_IF_FAILED(cmd) { \
41  RMH_Result ret = cmd; \
42  if (ret == RMH_NOT_SUPPORTED) { \
43  RMH_PrintWrn("'" #cmd "' is not supported by this device\n"); \
44  } \
45  else if (ret != RMH_SUCCESS) { \
46  RMH_PrintDbg("'" #cmd "' failed with error %s!\n", RMH_ResultToString(ret)); \
47  return ret; \
48  } \
49 }
50 
51 #define RMH_MAX_PRINT_LINE_SIZE 2048
52 
53 extern RMH_APIList hRMHGeneric_APIList;
54 extern RMH_APIList hRMHGeneric_SoCUnimplementedAPIList;
55 extern RMH_APITagList hRMHGeneric_APITags;
56 
57 typedef struct RMH {
58  RMH_Handle handle;
59  void* soclib;
60  FILE *localLogToFile;
61  struct timeval startTime;
62  RMH_EventCallback eventCB;
63  char* printBuf;
64  RMH_LogLevel logLevelBitMask;
65  RMH_Event eventNotifyBitMask;
66  void* eventCBUserContext;
67  uint32_t apiDepth;
68 } RMH;
69 
70 #endif /* LIB_RMH_H */
RMH_APITagList
Definition: rmh_type.h:240
RMH
Definition: librmh.h:57
RMH_APIList
Definition: rmh_type.h:234