Skip to content

Commit

Permalink
softcenter:fix skipdbv2 api
Browse files Browse the repository at this point in the history
  • Loading branch information
paldier committed Jul 1, 2020
1 parent bea13bc commit 82aa131
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 8 deletions.
15 changes: 15 additions & 0 deletions release/src/router/httpd/dbapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,21 @@ int dbclient_start(dbclient* client) {
return 0;
}

int dbclient_rm(dbclient* client, const char* key, int nk) {
int n1,n2;

if(nk < 0) {
return -1;
}

n1 = nk + 2 + 6;
check_buf(client, n1 + HEADER_PREFIX);
n2 = snprintf(client->buf, client->buf_max, "%s%07d remove %s\n", MAGIC, n1, key);
write(client->remote_fd, client->buf, n2);

return 0;
}

int dbclient_bulk(dbclient* client, const char* command, const char* key, int nk, const char* value, int nv) {
int n1,n2,nc;

Expand Down
1 change: 1 addition & 0 deletions release/src/router/httpd/dbapi.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ typedef struct _dbclient {
typedef int (*fn_db_parse)(dbclient* client, webs_t wp, char* prefix, char* key, char* value);

int dbclient_start(dbclient* client);
int dbclient_rm(dbclient* client, const char* key, int nk);
int dbclient_bulk(dbclient* client, const char* command, const char* key, int nk, const char* value, int nv);
int dbclient_end(dbclient* client);
int dbclient_list(dbclient* client, char* prefix, webs_t wp, fn_db_parse fn);
Expand Down
2 changes: 1 addition & 1 deletion release/src/router/httpd/sysinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,7 @@ unsigned int get_phy_temperature(int radio)
snprintf(s, sizeof(s), "wlan2 gTemperature:%%d %%*[0-9 ]");
}
if ((fp = popen(iw, "r")) != NULL) {
if(fgets(buffer, 100, fp) != NULL) {
if(fgets(buffer, 99, fp) != NULL) {
sscanf(buffer, s, &temp);
}
pclose(fp);
Expand Down
14 changes: 7 additions & 7 deletions release/src/router/httpd/web.c
Original file line number Diff line number Diff line change
Expand Up @@ -15787,7 +15787,7 @@ applydb_cgi(webs_t wp, char_t *urlPrefix, char_t *webDir, int arg,
char *result = NULL;
char *temp = NULL;
char *name = websGetVar(wp, "p","");
char *userm = strstr(url, "use_rm=1");
char *userm = websGetVar(wp, "use_rm", "");
char scPath[128];
char *post_db_buf = post_json_buf;

Expand Down Expand Up @@ -15825,8 +15825,8 @@ applydb_cgi(webs_t wp, char_t *urlPrefix, char_t *webDir, int arg,
strcpy(dbval, temp+1);
strncpy(dbvar, dbjson[j], strlen(dbjson[j])-strlen(temp));
//logmessage("HTTPD", "name: %s post: %s", dbvar, dbval);
if(userm)
doSystem("dbus remove %s", dbvar);
if(*userm || dbval[0]=='\0')
dbclient_rm(&client, dbvar, strlen(dbvar));
else
dbclient_bulk(&client, "set", dbvar, strlen(dbvar), dbval, strlen(dbval));
}
Expand Down Expand Up @@ -15856,9 +15856,9 @@ applydb_cgi(webs_t wp, char_t *urlPrefix, char_t *webDir, int arg,
temp=strstr(dbjson[j], "=");
strcpy(dbval, temp+1);
strncpy(dbvar, dbjson[j], strlen(dbjson[j])-strlen(temp));
//logmessage("HTTPD", "name: %s post: %s", dbvar, dbval);
if(userm)
doSystem("dbus remove %s", dbvar);
//logmessage("HTTPD", "dbvar: %s dbval: %s", dbvar, dbval);
if(*userm || dbval[0]=='\0')
dbclient_rm(&client, dbvar, strlen(dbvar));
else
dbclient_bulk(&client, "set", dbvar, strlen(dbvar), dbval, strlen(dbval));
}
Expand Down Expand Up @@ -15999,7 +15999,7 @@ do_logread(webs_t wp, char_t *urlPrefix, char_t *webDir, int arg,
//sscanf(url, "logreaddb.cgi?%s", filename);
char *filename = websGetVar(wp, "p","");
char *script = websGetVar(wp, "script", "");
if(script){
if(*script){
sprintf(scPath, "/jffs/softcenter/scripts/%s", script);
strlcpy(SystemCmd, scPath, sizeof(SystemCmd));
sys_script("syscmd.sh");
Expand Down

0 comments on commit 82aa131

Please sign in to comment.