OCT 1. 简化代码
This commit is contained in:
parent
9a0f34b168
commit
c303960261
|
@ -5,7 +5,6 @@
|
||||||
#include <sys/file.h>
|
#include <sys/file.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <stdio.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "user_errno.h"
|
#include "user_errno.h"
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
|
|
|
@ -550,30 +550,27 @@ static int delete_dhcpd_rangeset(const char **pRsp, const char *pRequest) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//The input parameter does not exist
|
//The input parameter does not exist
|
||||||
do {
|
PHASH_MAP s;
|
||||||
PHASH_MAP s;
|
PHASH_MAP tmp;
|
||||||
PHASH_MAP tmp;
|
char saddr[128];
|
||||||
char saddr[128];
|
char eaddr[128];
|
||||||
char eaddr[128];
|
char del_range[256];
|
||||||
char del_range[256];
|
memset(del_range, 0, 256);
|
||||||
memset(del_range, 0, 256);
|
HASH_ITER(hh, delMap, s, tmp) HASH_ITER(hh, delMap, s, tmp) {
|
||||||
|
cJSON *pdel_Item = cJSON_CreateObject();
|
||||||
|
IP2String(saddr, ntohl(s->key));
|
||||||
|
IP2String(eaddr, ntohl(s->value));
|
||||||
|
|
||||||
HASH_ITER(hh, delMap, s, tmp) {
|
sprintf(del_range, "%s-%s", saddr, eaddr);
|
||||||
cJSON *pdel_Item = cJSON_CreateObject();
|
cJSON_AddStringToObject(pdel_Item, "dhcpRange", del_range);
|
||||||
IP2String(saddr, ntohl(s->key));
|
|
||||||
IP2String(eaddr, ntohl(s->value));
|
|
||||||
|
|
||||||
sprintf(del_range, "%s-%s", saddr, eaddr);
|
cJSON_AddNumberToObject(pdel_Item, "status", ERR_ITEM_UNEXISTS);
|
||||||
cJSON_AddStringToObject(pdel_Item, "dhcpRange", del_range);
|
cJSON_AddStringToObject(pdel_Item, "message", getErrorEnumDesc(ERR_ITEM_UNEXISTS));
|
||||||
|
cJSON_AddItemToArray(pdelArray, pdel_Item);
|
||||||
|
|
||||||
cJSON_AddNumberToObject(pdel_Item, "status", ERR_ITEM_UNEXISTS);
|
HASH_DEL(delMap, s);
|
||||||
cJSON_AddStringToObject(pdel_Item, "message", getErrorEnumDesc(ERR_ITEM_UNEXISTS));
|
free(s);
|
||||||
cJSON_AddItemToArray(pdelArray, pdel_Item);
|
}
|
||||||
|
|
||||||
HASH_DEL(delMap, s);
|
|
||||||
free(s);
|
|
||||||
}
|
|
||||||
} while (0);
|
|
||||||
|
|
||||||
//Rewrite cfig.dhcpRanges
|
//Rewrite cfig.dhcpRanges
|
||||||
for (int i = 0; i < cfig.rangeCount; i++) {
|
for (int i = 0; i < cfig.rangeCount; i++) {
|
||||||
|
|
Loading…
Reference in New Issue