Skip to content

Commit

Permalink
Revert "RDKCOM-4839: RDKBDEV-2684: replace dependency on glib-2"
Browse files Browse the repository at this point in the history
This reverts commit 2900502.
  • Loading branch information
schall488 committed Feb 12, 2025
1 parent 072d066 commit ba4460b
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 441 deletions.
8 changes: 4 additions & 4 deletions source/dcautil/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
##########################################################################
lib_LTLIBRARIES = libdcautil.la

libdcautil_la_SOURCES = dcautil.c dca.c dcalist.c legacyutils.c dcaproc.c dcajson.c rdk_linkedlist.c
libdcautil_la_CFLAGS =
libdcautil_la_LDFLAGS = -shared -fPIC -lcjson
libdcautil_la_CFLAGS += $(DBUS_CFLAGS) -DUSE_TR181_CCSP_MESSAGEBUS
libdcautil_la_SOURCES = dcautil.c dca.c dcalist.c legacyutils.c dcaproc.c dcajson.c
libdcautil_la_CFLAGS = $(GLIB_CFLAGS)
libdcautil_la_LDFLAGS = -shared -fPIC $(GLIB_LIBS) -lcjson
libdcautil_la_CFLAGS += $(DBUS_CFLAGS) -DUSE_TR181_CCSP_MESSAGEBUS
libdcautil_la_LDFLAGS += $(DBUS_LIBS)

libdcautil_la_LIBADD = ${top_builddir}/source/ccspinterface/libccspinterface.la ${top_builddir}/source/utils/libt2utils.la
Expand Down
36 changes: 18 additions & 18 deletions source/dcautil/dca.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@
#include <unistd.h>
#include <ctype.h>

#include <glib.h>
#include <cjson/cJSON.h>

#include "dcalist.h"
#include "dcautil.h"
#include "legacyutils.h"
#include "rdk_linkedlist.h"

#define TR181BUF_LENGTH 512
#define OBJ_DELIMITER "{i}"
Expand Down Expand Up @@ -82,10 +82,10 @@ int processTopPattern(GList *pchead, Vector* grepResultList) {
T2Error("Invalid arguments for %s\n", __FUNCTION__);
return -1;
}
rdkList_t *tlist = pchead;
GList *tlist = pchead;
pcdata_t *tmp = NULL;
while(NULL != tlist) {
tmp = tlist->m_pUserData;
tmp = tlist->data;
if(NULL != tmp) {
if((NULL != tmp->header) && (NULL != strstr(tmp->header, "Load_Average"))) {
if(0 == getLoadAvg(grepResultList, tmp->trimparam, tmp->regexparam)) {
Expand All @@ -106,7 +106,7 @@ int processTopPattern(GList *pchead, Vector* grepResultList) {
}
}
}
tlist = rdk_list_find_next_node(tlist);
tlist = g_list_next(tlist);
}

T2Debug("%s --out\n", __FUNCTION__);
Expand Down Expand Up @@ -166,7 +166,7 @@ static T2ERROR processTr181Objects(GList *pchead) {
T2Debug("%s ++in\n", __FUNCTION__);
T2ERROR ret_val = T2ERROR_FAILURE;
int length, obj_count, i = 0;
rdkList_t *tlist = NULL;
GList *tlist = NULL;
pcdata_t *tmp = NULL;
char tr181objBuff[TR181BUF_LENGTH + 15] = { '\0' };
char *tck, *first_tck = NULL;
Expand All @@ -175,9 +175,9 @@ static T2ERROR processTr181Objects(GList *pchead) {
return T2ERROR_FAILURE;
}
//Loop through the given list and fill the data field of each node
for( tlist = pchead; tlist != NULL; tlist = rdk_list_find_next_node(tlist) ) {
for( tlist = pchead; tlist != NULL; tlist = g_list_next(tlist) ) {
char* tr181dataBuff = NULL;
tmp = tlist->m_pUserData;
tmp = tlist->data;
if(NULL != tmp) {
if(NULL != tmp->header && NULL != tmp->pattern && strlen(tmp->pattern) < TR181BUF_LENGTH && NULL == tmp->data) {

Expand Down Expand Up @@ -245,16 +245,16 @@ static T2ERROR processTr181Objects(GList *pchead) {
*
* @return Returns status of operation.
*/
static void addToJson(rdkList_t *pchead) {
void addToJson(GList *pchead) {
if(pchead == NULL){
T2Error("pchead is NULL for %s\n", __FUNCTION__);
return;
}
T2Debug("%s ++in\n", __FUNCTION__);
rdkList_t *tlist = pchead;
GList *tlist = pchead;
pcdata_t *tmp = NULL;
while(NULL != tlist) {
tmp = tlist->m_pUserData;
tmp = tlist->data;
if(NULL != tmp) {
if(tmp->pattern) {
if(tmp->d_type == OCCURENCE) {
Expand All @@ -270,7 +270,7 @@ static void addToJson(rdkList_t *pchead) {
}
}
}
tlist = rdk_list_find_next_node(tlist);
tlist = g_list_next(tlist);
}
T2Debug("%s --out\n", __FUNCTION__);
}
Expand All @@ -283,18 +283,18 @@ static void addToJson(rdkList_t *pchead) {
*
* @return Returns status of operation.
*/
static int addToVector(rdkList_t *pchead, Vector* grepResultList) {
static int addToVector(GList *pchead, Vector* grepResultList) {

T2Debug("%s ++in\n", __FUNCTION__);
if(pchead == NULL || grepResultList == NULL){
T2Error("Inavlid arguments for %s\n", __FUNCTION__);
return -1;
}
rdkList_t *tlist = pchead;
GList *tlist = pchead;
pcdata_t *tmp = NULL;

while(NULL != tlist) {
tmp = tlist->m_pUserData;
tmp = tlist->data;
if(NULL != tmp) {

if(tmp->pattern && grepResultList != NULL ) {
Expand Down Expand Up @@ -342,7 +342,7 @@ static int addToVector(rdkList_t *pchead, Vector* grepResultList) {
T2Debug("%s : grepResultList is NULL \n", __FUNCTION__);
}
}
tlist = rdk_list_find_next_node(tlist);
tlist = g_list_next(tlist);
}
T2Debug("%s --out\n", __FUNCTION__);
return 0;
Expand Down Expand Up @@ -454,7 +454,7 @@ int getErrorCode(char *str, char *ec) {
* @return Returns status of operation.
* @retval Return 0 upon success, -1 on failure.
*/
static int handleRDKErrCodes(rdkList_t **rdkec_head, char *line) {
static int handleRDKErrCodes(GList **rdkec_head, char *line) {
T2Debug("%s ++in\n", __FUNCTION__);
char err_code[20] = { 0 }, rdkec[30] = { 0 };
pcdata_t *tnode = NULL;
Expand All @@ -466,7 +466,7 @@ static int handleRDKErrCodes(rdkList_t **rdkec_head, char *line) {
if(NULL != tnode) {
tnode->count++;
}else {
/* Args: rdkList_t **pch, char *pattern, char *header, DType_t dtype, int count, char *data, bool trim, char *regex */
/* Args: GList **pch, char *pattern, char *header, DType_t dtype, int count, char *data bool trim char* regex */
insertPCNode(rdkec_head, rdkec, rdkec, OCCURENCE, 1, NULL, false, NULL);
}
T2Debug("%s --out\n", __FUNCTION__);
Expand Down Expand Up @@ -637,7 +637,7 @@ static int parseMarkerList(char* profileName, Vector* vMarkerList, Vector* grepR
T2Debug("%s ++in \n", __FUNCTION__);

char *filename = NULL, *prevfile = NULL;
rdkList_t *pchead = NULL, *rdkec_head = NULL;
GList *pchead = NULL, *rdkec_head = NULL;
GrepSeekProfile* gsProfile = NULL;
size_t var = 0;

Expand Down
26 changes: 13 additions & 13 deletions source/dcautil/dcalist.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
*
* @return Returns the value of rc.
*/
int insertPCNode(rdkList_t **pch, char *pattern, char *header, DType_t dtype, int count, char *data, bool trim, char *regex)
int insertPCNode(GList **pch, char *pattern, char *header, DType_t dtype, int count, char *data, bool trim, char* regex)
{
pcdata_t *new = NULL;
int rc = -1;
Expand Down Expand Up @@ -86,7 +86,7 @@ int insertPCNode(rdkList_t **pch, char *pattern, char *header, DType_t dtype, in
}
new->trimparam = trim;
new->regexparam = regex;
*pch = rdk_list_add_node(*pch , new);
*pch = g_list_append(*pch , new);
rc = 0;
}
return rc;
Expand All @@ -101,7 +101,7 @@ int insertPCNode(rdkList_t **pch, char *pattern, char *header, DType_t dtype, in
* @return Returns status of the operation.
* @retval Returns 0 on success and NULL on failure.
*/
int comparePattern(const void *np, const void *sp)
gint comparePattern(gconstpointer np, gconstpointer sp)
{
pcdata_t *tmp = (pcdata_t *)np;
if (tmp && tmp->pattern && (NULL != sp) && (NULL != strstr(sp, tmp->pattern))) {
Expand All @@ -118,15 +118,15 @@ int comparePattern(const void *np, const void *sp)
*
* @return Returns node on success and NULL on failure.
*/
pcdata_t* searchPCNode(rdkList_t *pch, char *pattern)
pcdata_t* searchPCNode(GList *pch, char *pattern)
{
rdkList_t *fnode = NULL;
GList *fnode = NULL;
if(pch == NULL && pattern == NULL){
return NULL;
}
fnode = rdk_list_find_node_custom(pch, pattern, (fnRDKListCustomCompare)comparePattern);
fnode = g_list_find_custom(pch, pattern, (GCompareFunc)comparePattern);
if (NULL != fnode)
return fnode->m_pUserData;
return fnode->data;
else
return NULL;
}
Expand All @@ -137,7 +137,7 @@ pcdata_t* searchPCNode(rdkList_t *pch, char *pattern)
* @param[in] data node data
* @param[in] user_data user data
*/
void print_pc_node(void *data, void *user_data)
void print_pc_node(gpointer data, gpointer user_data)
{
(void) user_data;
if(data == NULL){
Expand All @@ -159,20 +159,20 @@ void print_pc_node(void *data, void *user_data)
*
* @param[in] pch node head
*/
void printPCNodes(rdkList_t *pch)
void printPCNodes(GList *pch)
{
if(pch == NULL){
return;
}
rdk_list_foreach(pch, (fnRDKListCustomExecute)print_pc_node, NULL);
g_list_foreach(pch, (GFunc)print_pc_node, NULL);
}

/**
* @brief To delete a node.
*
* @param[in] node Node head.
*/
void freePCNode(void *node)
void freePCNode(gpointer node)
{
pcdata_t *tmp = (pcdata_t *)(node);
if (NULL != tmp)
Expand Down Expand Up @@ -200,11 +200,11 @@ void printPCNodes(rdkList_t *pch)
*
* @param[in] pch Node head.
*/
void clearPCNodes(rdkList_t **pch)
void clearPCNodes(GList **pch)
{
if(pch == NULL)
return;
rdk_list_free_all_nodes_custom(*pch, &freePCNode);
g_list_free_full(*pch, &freePCNode);
}

/** @} */ //END OF GROUP DCA_APIS
Expand Down
19 changes: 10 additions & 9 deletions source/dcautil/dcalist.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <glib.h>
#include <stdbool.h>

#include "rdk_linkedlist.h"
#include "vector.h"

typedef enum {
Expand All @@ -60,15 +60,16 @@ typedef struct pclist {
char* regexparam;
} pcdata_t;

extern rdkList_t *pchead;
extern GList *pchead;

int insertPCNode(GList **pch, char *pattern, char *header, DType_t dtype, int count, char *data, bool trim, char *regex);
pcdata_t* searchPCNode(GList *pch, char *pattern);
void printPCNodes(GList *pch);
void clearPCNodes(GList **pch);
gint comparePattern(gconstpointer np, gconstpointer sp);
void print_pc_node(gpointer data, gpointer user_data);
int processTopPattern(GList *pchead, Vector* grepResultList);

int insertPCNode(rdkList_t **pch, char *pattern, char *header, DType_t dtype, int count, char *data, bool trim, char *regex);
pcdata_t* searchPCNode(rdkList_t *pch, char *pattern);
void printPCNodes(rdkList_t *pch);
void clearPCNodes(rdkList_t **pch);
int comparePattern(const void *np, const void *sp);
void print_pc_node(void *data, void *user_data);
int processTopPattern(rdkList_t *pchead, Vector* grepResultList);
/** @} */


Expand Down
Loading

0 comments on commit ba4460b

Please sign in to comment.