OCT ZNJK-1003 1. 删除无用代码

2. 更新返回JSON格式
This commit is contained in:
huangxin 2022-10-09 11:41:05 +08:00
parent 32c0881ace
commit f49a72661f
1 changed files with 12 additions and 21 deletions

View File

@ -743,10 +743,10 @@ void procHTTP(data19 *req) {
return; return;
} }
// if (strcmp(pMethod, "POST") == 0) { // if (strcmp(pMethod, "POST") == 0) {
// sendAllLists(req); // sendAllLists(req);
// return; // return;
// } // }
if (pMethod) { if (pMethod) {
free((void *)pMethod); free((void *)pMethod);
@ -756,7 +756,6 @@ void procHTTP(data19 *req) {
free((void *)pBody); free((void *)pBody);
} }
if (fp && !strcasecmp(fp, "/allusers")) if (fp && !strcasecmp(fp, "/allusers"))
sendAllLists(req); sendAllLists(req);
else if (fp && !strcasecmp(fp, "/")) else if (fp && !strcasecmp(fp, "/"))
@ -789,10 +788,6 @@ typedef struct {
} USER_INFO, *PUSER_INFO; } USER_INFO, *PUSER_INFO;
static void sendUserList(data19 *req, const char *pRequest) { static void sendUserList(data19 *req, const char *pRequest) {
char rsp[] =
"{\"ver\":3,\"cryptoType\":0,\"timeStamp\":1599187216753,\"code\":200,\"msgContent\":{\"items\":[],\"status\":"
"0,\"message\":[\"Success\"]}}";
char logBuff[512]; char logBuff[512];
char rspBuf[2048] = {0}; char rspBuf[2048] = {0};
dhcpMap::iterator p; dhcpMap::iterator p;
@ -902,11 +897,7 @@ static void sendUserList(data19 *req, const char *pRequest) {
pthread_attr_destroy(&attr); pthread_attr_destroy(&attr);
} }
static void sendAllLists(data19* req){ static void sendAllLists(data19 *req) {
char rsp[] =
"{\"ver\":3,\"cryptoType\":0,\"timeStamp\":1599187216753,\"code\":200,\"msgContent\":{\"items\":[],\"status\":"
"0,\"message\":[\"Success\"]}}";
char logBuff[512]; char logBuff[512];
data7 *dhcpEntry = nullptr; data7 *dhcpEntry = nullptr;
dhcpMap::iterator p; dhcpMap::iterator p;
@ -933,18 +924,18 @@ static void sendAllLists(data19* req){
cJSON *pRspMsg = cJSON_CreateObject(); cJSON *pRspMsg = cJSON_CreateObject();
cJSON *pMsgArray = cJSON_CreateArray(); cJSON *pMsgArray = cJSON_CreateArray();
// cJSON_AddItemToObject(pRspMsg, "", pMsgArray); cJSON_AddItemToObject(pRspMsg, "users", pMsgArray);
for (p = dhcpCache.begin(); kRunning && p != dhcpCache.end() && fp < maxData; p++) { for (p = dhcpCache.begin(); kRunning && p != dhcpCache.end() && fp < maxData; p++) {
// cJSON *pRspItem = cJSON_CreateObject(); //cJSON *pRspItem = cJSON_CreateObject();
if ((dhcpEntry = p->second)) { if ((dhcpEntry = p->second)) {
cJSON_AddStringToObject(pMsgArray, " ", dhcpEntry->mapname); cJSON_AddStringToObject(pMsgArray, "", dhcpEntry->mapname);
} }
// cJSON_AddItemToArray(pMsgArray, pRspItem); //cJSON_AddItemToArray(pMsgArray, pRspItem);
} }
cJSON_AddItemToObject(pRspRoot, "msgContent", pMsgArray); cJSON_AddItemToObject(pRspRoot, "msgContent", pRspMsg);
fp += sprintf(fp, "%s", cJSON_Print(pRspRoot)); fp += sprintf(fp, "%s", cJSON_Print(pRspRoot));
@ -1766,8 +1757,8 @@ MYDWORD chkaddr(data9 *req) {
#include <net/if_arp.h> #include <net/if_arp.h>
#pragma clang diagnostic push #pragma clang diagnostic push
#pragma ide diagnostic ignored "cert-err34-c" #pragma ide diagnostic ignored "cert-err34-c"
int getHwAddr(char *buff, char *mac) { int getHwAddr(char *buff, char *mac) {
if (buff == nullptr || mac == nullptr) { if (buff == nullptr || mac == nullptr) {
return -1; return -1;
} }