-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdcm_utils.h
More file actions
135 lines (111 loc) · 4.57 KB
/
dcm_utils.h
File metadata and controls
135 lines (111 loc) · 4.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
/*
* If not stated otherwise in this file or this component's LICENSE
* file the following copyright and licenses apply:
* Copyright 2024 Comcast Cable Communications Management, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef _DCM_UTILS_H_
#define _DCM_UTILS_H_
#ifdef __cplusplus
extern "C"
{
#endif
#ifdef HAS_MAINTENANCE_MANAGER
#ifndef GTEST_ENABLE
#include "libIBus.h"
#include "maintenanceMGR.h"
#endif
#endif
#ifndef GTEST_ENABLE
#include "rbus.h"
#endif
#ifdef RDK_LOGGER_ENABLED
#include "rdk_debug.h"
#endif
#define DCM_LIB_PATH "/lib/rdk"
#define DCM_PID_FILE "/tmp/.dcm-daemon.pid"
#define DEVICE_PROP_FILE "/etc/device.properties"
#define TELEMETRY_2_FILE "/etc/telemetry2_0.properties"
#define INCLUDE_PROP_FILE "/etc/include.properties"
#define DCM_TMP_CONF "/tmp/DCMSettings.conf"
#define DCM_OPT_CONF "/opt/.DCMSettings.conf"
#define DCM_RESPONSE_PATH "/.t2persistentfolder/DCMresponse.txt"
#define PERSISTENT_ENTRY "PERSISTENT_PATH"
#define DEFAULT_PERSISTENT_PATH "/opt"
#ifndef DCM_LOG_TFTP // please define your log upload url
#define DCM_LOG_TFTP "Fallbacklogupload"
#endif
/* DCM Error Codes */
#define DCM_SUCCESS 0
#define DCM_FAILURE -1
#define DCM_IARM_COMPLETE 0
#define DCM_IARM_ERROR 1
#define MAX_DEVICE_PROP_BUFF_SIZE 80
#define EXECMD_BUFF_SIZE 1024
#define MAX_URL_SIZE 128
#define DEBUG_INI_NAME "/etc/debug.ini"
#define PREFIX(format) "[DCM] %s[%d]: " format
#ifdef RDK_LOGGER_ENABLED
extern int g_rdk_logger_enabled;
#define LOG_ERROR(format, ...) if(g_rdk_logger_enabled) {\
RDK_LOG(RDK_LOG_ERROR, "LOG.RDK.DCM", format, __VA_ARGS__);\
} else {\
fprintf (stderr, format, __VA_ARGS__);\
}
#define LOG_WARN(format, ...) if(g_rdk_logger_enabled) {\
RDK_LOG(RDK_LOG_WARN, "LOG.RDK.DCM", format, __VA_ARGS__);\
} else {\
fprintf (stderr, format, __VA_ARGS__);\
}
#define LOG_INFO(format, ...) if(g_rdk_logger_enabled) {\
RDK_LOG(RDK_LOG_INFO, "LOG.RDK.DCM", format, __VA_ARGS__);\
} else {\
fprintf (stderr, format, __VA_ARGS__);\
}
#define LOG_DEBUG(format, ...) if(g_rdk_logger_enabled) {\
RDK_LOG(RDK_LOG_DEBUG, "LOG.RDK.DCM", format, __VA_ARGS__);\
} else {\
fprintf (stderr, format, __VA_ARGS__);\
}
#define LOG_TRACE(format, ...) if(g_rdk_logger_enabled) {\
RDK_LOG(RDK_LOG_TRACE1, "LOG.RDK.DCM", format, __VA_ARGS__);\
} else {\
fprintf (stderr, format, __VA_ARGS__);\
}
#else
#define LOG_ERROR(format, ...) fprintf(stderr, format, __VA_ARGS__)
#define LOG_WARN(format, ...) fprintf(stderr, format, __VA_ARGS__)
#define LOG_INFO(format, ...) fprintf(stderr, format, __VA_ARGS__)
#define LOG_DEBUG(format, ...) fprintf(stderr, format, __VA_ARGS__)
#define LOG_TRACE(format, ...) fprintf(stderr, format, __VA_ARGS__)
#endif //RDK_LOGGER_ENABLED
#define DCMError(format, ...) LOG_ERROR(PREFIX(format), __FUNCTION__, __LINE__, ##__VA_ARGS__)
#define DCMWarn(format, ...) LOG_WARN(PREFIX(format), __FUNCTION__, __LINE__, ##__VA_ARGS__)
#define DCMInfo(format, ...) LOG_INFO(PREFIX(format), __FUNCTION__, __LINE__, ##__VA_ARGS__)
#define DCMDebug(format, ...) LOG_DEBUG(PREFIX(format), __FUNCTION__, __LINE__, ##__VA_ARGS__)
#define DCMTrace(format, ...) LOG_TRACE(PREFIX(format), __FUNCTION__, __LINE__, ##__VA_ARGS__)
INT32 dcmIARMEvntSend(INT32 status);
INT32 dcmUtilsSysCmdExec(INT8 *cmd);
VOID dcmUtilsCopyCommandOutput (INT8 *cmd, INT8 *out, INT32 len);
INT32 dcmUtilsCheckDaemonStatus();
VOID dcmUtilsRemovePIDfile();
INT32 dcmUtilsFilePresentCheck(const INT8 *file_name);
INT8* dcmUtilsGetFileEntry(const INT8* fileName, const INT8* searchEntry);
void DCMLOGInit();
#ifdef __cplusplus
}
#endif
#endif //_DCM_UTILS_H