From a56fa2937850177de5c1ba7be646cec6767a7b08 Mon Sep 17 00:00:00 2001 From: dongwenze Date: Fri, 10 Feb 2023 11:06:16 +0800 Subject: [PATCH] =?UTF-8?q?OCT=20=E4=BF=AE=E6=94=B9=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E5=9C=B0=E5=9D=80=E6=B1=A0=E6=8E=A5=E5=8F=A3=E9=83=A8=E5=88=86?= =?UTF-8?q?=E5=AE=9E=E7=8E=B0=E7=BB=86=E8=8A=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- srcs/opendhcp183/query.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/srcs/opendhcp183/query.cpp b/srcs/opendhcp183/query.cpp index 89afac6..bbc5b57 100644 --- a/srcs/opendhcp183/query.cpp +++ b/srcs/opendhcp183/query.cpp @@ -473,11 +473,11 @@ static int add_dhcpd_rangeset(data19 *req, const char *pRequest) { return ERR_SUCCESS; } -struct hash_map { +typedef struct { unsigned int key; unsigned int value; UT_hash_handle hh; -}; +}HASH_MAP, *PHASH_MAP; static int delete_dhcpd_rangeset(data19 *req, const char *pRequest) { char logBuff[512]; @@ -486,7 +486,7 @@ static int delete_dhcpd_rangeset(data19 *req, const char *pRequest) { cJSON *pRspRoot; cJSON *pdelArray; data13 dhcpRanges[MAX_DHCP_RANGES]; - hash_map *delMap = nullptr; + PHASH_MAP delMap = nullptr; int resCount = 0; LOG_MOD(debug, ZLOG_MOD_OPENDHCPD, "Input: %s\n", pRequest); @@ -531,7 +531,7 @@ static int delete_dhcpd_rangeset(data19 *req, const char *pRequest) { cJSON *pdel_Item = cJSON_CreateObject(); cJSON *pdelRange = cJSON_GetArrayItem(pdhcp_range, i); char del_range[256]; - auto *delItem = (struct hash_map *)malloc(sizeof(hash_map)); + auto *delItem = (PHASH_MAP)malloc(sizeof(HASH_MAP)); if (!pdelRange) { continue; @@ -556,7 +556,7 @@ static int delete_dhcpd_rangeset(data19 *req, const char *pRequest) { HASH_FIND_INT(delMap, &st_addr, delItem); if (delItem == nullptr) { - auto *s = (struct hash_map *)malloc(sizeof(struct hash_map)); + auto *s = (PHASH_MAP)malloc(sizeof(HASH_MAP)); s->key = st_addr; s->value = en_addr; HASH_ADD_INT(delMap, key, s); @@ -565,7 +565,7 @@ static int delete_dhcpd_rangeset(data19 *req, const char *pRequest) { for (int i = 0; i < cfig.rangeCount; i++) { cJSON *pdel_Item = cJSON_CreateObject(); - hash_map *delRange; + PHASH_MAP delRange; char del_range[256]; char saddr[128]; char eaddr[128]; @@ -578,7 +578,7 @@ static int delete_dhcpd_rangeset(data19 *req, const char *pRequest) { sprintf(del_range, "%s-%s", saddr, eaddr); cJSON_AddStringToObject(pdel_Item, "dhcpRange", del_range); - //judge whether the input has error + //Determine whether the input is correct or not if (delRange->value == cfig.dhcpRanges[i].rangeEnd) { cJSON_AddNumberToObject(pdel_Item, "status", ERR_SUCCESS); cJSON_AddStringToObject(pdel_Item, "message", getErrorEnumDesc(ERR_SUCCESS)); @@ -594,17 +594,17 @@ static int delete_dhcpd_rangeset(data19 *req, const char *pRequest) { HASH_DEL(delMap, delRange); } else { - //write to dhcpRanges + //Write dhcpRanges memcpy(&dhcpRanges[resCount], &cfig.dhcpRanges[i], sizeof(struct data13)); resCount++; } } - //输入参数不存在的情况 + //The input parameter does not exist if (resCount > cfig.rangeCount - cJSON_GetArraySize(pdhcp_range)) { cJSON *pdel_Item = cJSON_CreateObject(); - auto *s = (struct hash_map *)malloc(sizeof(struct hash_map)); - hash_map *tmp; + auto *s = (PHASH_MAP)malloc(sizeof(HASH_MAP)); + PHASH_MAP tmp; char saddr[128]; char eaddr[128]; char del_range[256]; @@ -623,7 +623,7 @@ static int delete_dhcpd_rangeset(data19 *req, const char *pRequest) { } } - //rewite cfig.dhcpRanges + //Rewrite cfig.dhcpRanges for (int i = 0; i < cfig.rangeCount; i++) { if (i < resCount) { memcpy(&cfig.dhcpRanges[i], &dhcpRanges[i], sizeof(struct data13));