TOR: fix compilation
[tomato.git] / release / src / router / httpd / ddns.c
blob9a6d1d394075d25340b12c34eb65eae701e7254f
1 /*
3 Tomato Firmware
4 Copyright (C) 2006-2009 Jonathan Zarate
6 */
8 #include "tomato.h"
10 #include <time.h>
11 #include <sys/stat.h>
14 void asp_ddnsx(int argc, char **argv)
16 char *p, *q;
17 int i;
18 char s[256];
19 char m[256];
20 char name[64];
21 time_t tt;
22 struct stat st;
24 web_printf("\nddnsx_ip = '%s';", get_wanip("wan"));
25 web_printf("\nddnsx2_ip = '%s';", get_wanip("wan2"));
26 #ifdef TCONFIG_MULTIWAN
27 web_printf("\nddnsx3_ip = '%s';", get_wanip("wan3"));
28 web_printf("\nddnsx4_ip = '%s';", get_wanip("wan4"));
29 #endif
31 web_printf("\nddnsx_msg = [");
33 for (i = 0; i < 2; ++i) {
34 web_puts(i ? "','" : "'");
35 sprintf(name, "/var/lib/mdu/ddnsx%d.msg", i);
36 f_read_string(name, m, sizeof(m)); // null term'd even on error
37 if (m[0] != 0) {
38 if ((stat(name, &st) == 0) && (st.st_mtime > Y2K)) {
39 strftime(s, sizeof(s), "%a, %d %b %Y %H:%M:%S %z: ", localtime(&st.st_mtime));
40 web_puts(s);
42 web_putj(m);
46 web_puts("'];\nddnsx_last = [");
48 for (i = 0; i < 2; ++i) {
49 web_puts(i ? "','" : "'");
50 sprintf(name, "ddnsx%d", i);
51 if (!nvram_match(name, "")) {
52 sprintf(name, "ddnsx%d_cache", i);
53 if ((p = nvram_get(name)) == NULL) continue;
54 tt = strtoul(p, &q, 10);
55 if (*q++ != ',') continue;
56 if (tt > Y2K) {
57 strftime(s, sizeof(s), "%a, %d %b %Y %H:%M:%S %z: ", localtime(&tt));
58 web_puts(s);
60 web_putj(q);
63 web_puts("'];\n");
66 void asp_ddnsx_ip(int argc, char **argv)
68 char prefix[] = "wan";
69 int unit = 1;
71 web_puts(get_wanip(prefix));