Go to the documentation of this file.00001
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048 #include "uip.h"
00049 #include "psock.h"
00050 #include "httpd.h"
00051 #include "httpd-cgi.h"
00052 #include "httpd-fs.h"
00053 #include "http_func.h"
00054
00055 #include "../mprintf/mprintf.h"
00056 #include <string.h>
00057 #include <stdio.h>
00058
00059 HTTPD_CGI_CALL(temp, "tag-temp", cgitemperature );
00060
00061
00062
00063
00064
00065 static const struct httpd_cgi_call *calls[] = { &temp, NULL };
00066
00067
00068 static
00069 PT_THREAD(nullfunction(struct httpd_state *s, char *ptr))
00070 {
00071 PSOCK_BEGIN(&s->sout);
00072 PSOCK_END(&s->sout);
00073 }
00074
00075 httpd_cgifunction
00076 httpd_cgi(char *name)
00077 {
00078 const struct httpd_cgi_call **f;
00079
00080
00081 for(f = calls; *f != NULL; ++f) {
00082 if(strncmp((*f)->name, name, strlen((*f)->name)) == 0) {
00083 return (*f)->function;
00084 }
00085 }
00086 return nullfunction;
00087 }
00088 extern unsigned char temp0, temp1, setpoint, ac_auto_on, ac_modo;
00089
00090 static unsigned short cgi_gettemp( void *arg )
00091 {
00092 sprintf( uip_appdata, "%3d,%02d", (int)temp1, (int)temp0);
00093
00094 return strlen( uip_appdata );
00095 }
00096
00097 static PT_THREAD(cgitemperature(struct httpd_state *s, char *ptr))
00098 {
00099 PSOCK_BEGIN(&s->sout);
00100 PSOCK_GENERATOR_SEND(&s->sout, cgi_gettemp, NULL);
00101 PSOCK_END(&s->sout);
00102 }
00103
00104
00105 void cgiProcessFormInput( char *pcInputString, int xInputLength )
00106 {
00107 char *c, *d, *e, *pcText;
00108 char tac_modo, tsetpoint;
00109 char deb[100];
00110
00111 DEBUG_ENTER;
00112 c = strstr( pcInputString, "?" );
00113 sprintf(deb, "%s\n", c);
00114 DEBUG_HTTP(deb);
00115 if( c )
00116 {
00117 printf("\n\n");
00118 *c = 0x00;
00119 c++;
00120 e = strstr( c, " " );
00121 if( e != NULL )
00122 {
00123 *e = 0x00;
00124 }
00125 d = strstr( c, "slcd=");
00126 if (d) {
00127 c=d;
00128 c += strlen("slcd=");
00129 d = strchr( c, '&');
00130 *d = '\0';
00131 http_set_lcd(c);
00132 printf("--[%s]--",c);
00133 c=d+1;
00134 }
00135
00136 d = strstr( c, "shr=");
00137 if(d) {
00138 c=d;
00139 c += strlen("shr=");
00140 d = strchr( c, '&');
00141 *d = '\0';
00142 http_set_hour(c);
00143
00144 c=d+1;
00145 }
00146
00147 d = strstr( c, "smin=");
00148 if(d) {
00149 c=d;
00150 c += strlen("smin=");
00151 d = strchr( c, '&');
00152 *d = '\0';
00153 http_set_min(c);
00154
00155 c=d+1;
00156 }
00157
00158 d = strstr( c, "ssec=");
00159 if(d) {
00160 c=d;
00161 c += strlen("ssec=");
00162 http_set_sec(c);
00163
00164 }
00165 }
00166 show_lcd_time();
00167 DEBUG_EXIT;
00168 }
00169