|
|
@@ -44,11 +44,8 @@
|
|
|
|
|
|
#define _SLEN LINE_BUFFER_SIZE
|
|
|
|
|
|
-/*
|
|
|
-#include "fbutil.h"
|
|
|
-#include "expat-2.0.1/lib/expat.h"
|
|
|
-#include "menu.h"
|
|
|
-*/
|
|
|
+static const char *s_http_port = "60535";
|
|
|
+static struct mg_serve_http_opts s_http_server_opts;
|
|
|
|
|
|
struct mg_mgr g_mgr;
|
|
|
|
|
|
@@ -65,6 +62,26 @@ time_t mkgmtime(struct tm *tm);
|
|
|
int token_diag_serial = 0;
|
|
|
char token_diag_string[LINE_BUFFER_SIZE] = {0};
|
|
|
|
|
|
+
|
|
|
+// return total bytes in dst
|
|
|
+//
|
|
|
+static size_t _strnncat(char *dst, char *src, size_t n) {
|
|
|
+ size_t dst_n, src_n, N, i;
|
|
|
+
|
|
|
+ dst_n = strlen(dst);
|
|
|
+ src_n = strlen(src);
|
|
|
+ N = n-1;
|
|
|
+ if (dst_n < N) { N -= dst_n; }
|
|
|
+
|
|
|
+ for (i=0; (i<N) && (i<src_n); i++) {
|
|
|
+ dst[dst_n + i] = src[i];
|
|
|
+ }
|
|
|
+
|
|
|
+ dst[dst_n+i] = '\0';
|
|
|
+
|
|
|
+ return dst_n + i;
|
|
|
+}
|
|
|
+
|
|
|
//unsigned char menu_checksum[MD5_DIGEST_LENGTH];
|
|
|
|
|
|
time_t paddle_req_timeout = 0;
|
|
|
@@ -634,9 +651,7 @@ static inline int can_report_diu_error()
|
|
|
|
|
|
//-------- web server functions ----
|
|
|
|
|
|
-static const char *s_http_port = "60535";
|
|
|
-static struct mg_serve_http_opts s_http_server_opts;
|
|
|
-
|
|
|
+/*
|
|
|
static void send_ws_heartbeat(struct mg_connection *nc) {
|
|
|
int n;
|
|
|
char buf[_SLEN];
|
|
|
@@ -653,6 +668,7 @@ static void send_ws_heartbeat(struct mg_connection *nc) {
|
|
|
}
|
|
|
|
|
|
}
|
|
|
+*/
|
|
|
|
|
|
static void process_ws_message(struct websocket_message *ws_msg) {
|
|
|
int i;
|
|
|
@@ -695,10 +711,11 @@ static void ui_handle_status_input(struct mg_connection *nc, struct http_message
|
|
|
pkgs[i].pkgname, pkgs[i].pkgver,
|
|
|
pkgtime.tm_mon + 1, pkgtime.tm_mday, pkgtime.tm_year + 1900,
|
|
|
pkgtime.tm_hour, pkgtime.tm_min, pkgtime.tm_sec);
|
|
|
- //if (npkgnet>0) { strncat(pkgnetline, "|", _SLEN); }
|
|
|
- strncat(pkgnetline, "|", _SLEN);
|
|
|
- strncat(pkgnetline, _str, _SLEN);
|
|
|
+
|
|
|
+ _strnncat(pkgnetline, "|", _SLEN);
|
|
|
+ _strnncat(pkgnetline, _str, _SLEN);
|
|
|
npkgnet++;
|
|
|
+
|
|
|
}
|
|
|
|
|
|
fp = fopen("/tmp/net_ids", "rb");
|
|
|
@@ -706,8 +723,8 @@ static void ui_handle_status_input(struct mg_connection *nc, struct http_message
|
|
|
i=0;
|
|
|
while (fgets(_str, _SLEN, fp)) {
|
|
|
strip_crlf(_str);
|
|
|
- strncat(pkgnetline, "|", _SLEN);
|
|
|
- strncat(pkgnetline, _str, _SLEN);
|
|
|
+ _strnncat(pkgnetline, "|", _SLEN);
|
|
|
+ _strnncat(pkgnetline, _str, _SLEN);
|
|
|
npkgnet++;
|
|
|
}
|
|
|
fclose(fp);
|
|
|
@@ -747,9 +764,6 @@ static void ui_handle_status_input(struct mg_connection *nc, struct http_message
|
|
|
|
|
|
pkgnetline);
|
|
|
|
|
|
- //DEBUG
|
|
|
- printf("%s\n", buf);
|
|
|
-
|
|
|
mg_printf(nc, "HTTP/1.1 200 OK\r\nContent-Length: %lu\r\n\r\n%s",
|
|
|
(unsigned long)strlen(buf), buf);
|
|
|
}
|
|
|
@@ -892,8 +906,6 @@ static void ui_handle_driver_login(struct mg_connection *nc, struct http_message
|
|
|
static void api_handle_req(struct mg_connection *nc, struct http_message *hm) {
|
|
|
int ret;
|
|
|
char s_action[_SLEN];
|
|
|
- char _default_msg[_SLEN] = "";
|
|
|
- struct mg_str hdr;
|
|
|
|
|
|
ret = mg_get_http_var(&(hm->body), "action", s_action, _SLEN);
|
|
|
|
|
|
@@ -1064,7 +1076,7 @@ int main(int argc, char **argv) {
|
|
|
}
|
|
|
|
|
|
mg_set_protocol_http_websocket(nc);
|
|
|
- s_http_server_opts.document_root = "html";
|
|
|
+ s_http_server_opts.document_root = CONFIG_FILE_PATH "/html";
|
|
|
s_http_server_opts.enable_directory_listing = "no";
|
|
|
|
|
|
|
|
|
@@ -1504,6 +1516,9 @@ int main(int argc, char **argv) {
|
|
|
else {
|
|
|
message_callback_return msg_status;
|
|
|
msg_status = process_message(&incoming_msg);
|
|
|
+ if (msg_status) {
|
|
|
+ //pass
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
}
|