OCT 优化函数调用参数传递
This commit is contained in:
parent
2e2ff5a6fc
commit
e6a0f3546a
|
@ -696,7 +696,7 @@ void procHTTP(data19 *req) {
|
||||||
fp = myGetToken(buffer, 1);
|
fp = myGetToken(buffer, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
int judge_flag = method_Judge(req, buffer1, fp, kRunning, dhcpCache, cfig, t);
|
int judge_flag = method_Judge(req, buffer1, fp, kRunning, &dhcpCache, &cfig, t);
|
||||||
if(judge_flag == 1 || judge_flag == 2)
|
if(judge_flag == 1 || judge_flag == 2)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
|
@ -633,9 +633,9 @@ MYWORD myTokenize(char*, char*, const char*, bool);
|
||||||
MYWORD pQu(char*, char*);
|
MYWORD pQu(char*, char*);
|
||||||
MYWORD qLen(char*);
|
MYWORD qLen(char*);
|
||||||
const char *getRequestMethod(const char *buffer);
|
const char *getRequestMethod(const char *buffer);
|
||||||
int method_Judge(data19 *req, char *buffer, char *fp, bool kRunning, dhcpMap dhcpCache, data2 cfig, time_t t);
|
int method_Judge(data19 *req, char *buffer, char *fp, bool kRunning, dhcpMap *dhcpCache, data2 *cfig, time_t t);
|
||||||
void sendUserList(data19 *req, const char *pRequest, dhcpMap dhcpCache, data2 cfig, time_t t);
|
void sendUserList(data19 *req, const char *pRequest, dhcpMap *dhcpCache, data2 *cfig, time_t t);
|
||||||
void sendAllLists(data19 *req, bool kRunning, dhcpMap dhcpCache, data2 cfig);
|
void sendAllLists(data19 *req, bool kRunning, dhcpMap *dhcpCache, data2 *cfig);
|
||||||
int getHwAddr(char *buff, char *mac);
|
int getHwAddr(char *buff, char *mac);
|
||||||
int arpSet(const char *ifname, char *ipStr, char *mac);
|
int arpSet(const char *ifname, char *ipStr, char *mac);
|
||||||
sockaddr_in get_cliAddr(char *nicif, char *tempbuff, data9 *req);
|
sockaddr_in get_cliAddr(char *nicif, char *tempbuff, data9 *req);
|
|
@ -39,7 +39,7 @@ const char *getRequestMethod(const char *buffer) {
|
||||||
return strdup(httpMethod);
|
return strdup(httpMethod);
|
||||||
}
|
}
|
||||||
|
|
||||||
void sendUserList(data19 *req, const char *pRequest, dhcpMap dhcpCache, data2 cfig, time_t t) {
|
void sendUserList(data19 *req, const char *pRequest, dhcpMap *dhcpCache, data2 *cfig, time_t t) {
|
||||||
char logBuff[512];
|
char logBuff[512];
|
||||||
dhcpMap::iterator p;
|
dhcpMap::iterator p;
|
||||||
|
|
||||||
|
@ -79,7 +79,7 @@ void sendUserList(data19 *req, const char *pRequest, dhcpMap dhcpCache, data2 cf
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
req->memSize = (int)(2048 + (135 * dhcpCache.size()) + (cfig.dhcpSize * 26));
|
req->memSize = (int)(2048 + (135 * dhcpCache->size()) + (cfig->dhcpSize * 26));
|
||||||
req->dp = (char *)calloc(1, req->memSize);
|
req->dp = (char *)calloc(1, req->memSize);
|
||||||
|
|
||||||
if (!req->dp) {
|
if (!req->dp) {
|
||||||
|
@ -105,10 +105,10 @@ void sendUserList(data19 *req, const char *pRequest, dhcpMap dhcpCache, data2 cf
|
||||||
cJSON *pItem = cJSON_GetArrayItem(pUserMac, i);
|
cJSON *pItem = cJSON_GetArrayItem(pUserMac, i);
|
||||||
cJSON *pRspItem = cJSON_CreateObject();
|
cJSON *pRspItem = cJSON_CreateObject();
|
||||||
|
|
||||||
p = dhcpCache.find(pItem->valuestring);
|
p = dhcpCache->find(pItem->valuestring);
|
||||||
cJSON_AddStringToObject(pRspItem, "userMac", pItem->valuestring);
|
cJSON_AddStringToObject(pRspItem, "userMac", pItem->valuestring);
|
||||||
|
|
||||||
if (p != dhcpCache.end()) {
|
if (p != dhcpCache->end()) {
|
||||||
data7 *dhcpEntry = p->second;
|
data7 *dhcpEntry = p->second;
|
||||||
|
|
||||||
cJSON_AddStringToObject(pRspItem, "ip", IP2String(tempbuff, dhcpEntry->ip));
|
cJSON_AddStringToObject(pRspItem, "ip", IP2String(tempbuff, dhcpEntry->ip));
|
||||||
|
@ -148,12 +148,12 @@ void sendUserList(data19 *req, const char *pRequest, dhcpMap dhcpCache, data2 cf
|
||||||
pthread_attr_destroy(&attr);
|
pthread_attr_destroy(&attr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void sendAllLists(data19 *req, bool kRunning, dhcpMap dhcpCache, data2 cfig) {
|
void sendAllLists(data19 *req, bool kRunning, dhcpMap *dhcpCache, data2 *cfig) {
|
||||||
char logBuff[512];
|
char logBuff[512];
|
||||||
data7 *dhcpEntry;
|
data7 *dhcpEntry;
|
||||||
dhcpMap::iterator p;
|
dhcpMap::iterator p;
|
||||||
|
|
||||||
req->memSize = (int)(2048 + (135 * dhcpCache.size()) + (cfig.dhcpSize * 26));
|
req->memSize = (int)(2048 + (135 * dhcpCache->size()) + (cfig->dhcpSize * 26));
|
||||||
req->dp = (char *)calloc(1, req->memSize);
|
req->dp = (char *)calloc(1, req->memSize);
|
||||||
|
|
||||||
if (!req->dp) {
|
if (!req->dp) {
|
||||||
|
@ -177,7 +177,7 @@ void sendAllLists(data19 *req, bool kRunning, dhcpMap dhcpCache, data2 cfig) {
|
||||||
|
|
||||||
cJSON_AddItemToObject(pRspMsg, "users", 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);
|
||||||
|
@ -201,7 +201,7 @@ void sendAllLists(data19 *req, bool kRunning, dhcpMap dhcpCache, data2 cfig) {
|
||||||
pthread_attr_destroy(&attr);
|
pthread_attr_destroy(&attr);
|
||||||
}
|
}
|
||||||
|
|
||||||
int method_Judge(data19 *req, char *buffer, char *fp, bool kRunning, dhcpMap dhcpCache, data2 cfig, time_t t) {
|
int method_Judge(data19 *req, char *buffer, char *fp, bool kRunning, dhcpMap *dhcpCache, data2 *cfig, time_t t) {
|
||||||
const char *pMethod = getRequestMethod(buffer);
|
const char *pMethod = getRequestMethod(buffer);
|
||||||
const char *pBody = strstr(buffer, "\r\n\r\n");
|
const char *pBody = strstr(buffer, "\r\n\r\n");
|
||||||
|
|
||||||
|
@ -247,6 +247,8 @@ int method_Judge(data19 *req, char *buffer, char *fp, bool kRunning, dhcpMap dhc
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#pragma clang diagnostic push
|
||||||
|
#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;
|
||||||
|
@ -265,6 +267,7 @@ int getHwAddr(char *buff, char *mac) {
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
#pragma clang diagnostic pop
|
||||||
|
|
||||||
int arpSet(const char *ifname, char *ipStr, char *mac) {
|
int arpSet(const char *ifname, char *ipStr, char *mac) {
|
||||||
if (ifname == nullptr || ipStr == nullptr || mac == nullptr) {
|
if (ifname == nullptr || ipStr == nullptr || mac == nullptr) {
|
||||||
|
|
Loading…
Reference in New Issue