Ported processes cgi to Contiki 2.x.

This commit is contained in:
oliverschmidt 2007-04-07 01:31:29 +00:00
parent e37d79e4a3
commit fe3e6c1a36
2 changed files with 23 additions and 19 deletions

View file

@ -28,7 +28,7 @@
* *
* This file is part of the uIP TCP/IP stack. * This file is part of the uIP TCP/IP stack.
* *
* $Id: httpd-cgi.c,v 1.2 2006/08/09 16:13:39 bg- Exp $ * $Id: httpd-cgi.c,v 1.3 2007/04/07 01:31:29 oliverschmidt Exp $
* *
*/ */
@ -95,6 +95,10 @@ static const char time_wait[] = /* "TIME-WAIT,"*/
static const char last_ack[] = /* "LAST-ACK"*/ static const char last_ack[] = /* "LAST-ACK"*/
{0x4c, 0x41, 0x53, 0x54, 0x2d, 0x41, 0x43, {0x4c, 0x41, 0x53, 0x54, 0x2d, 0x41, 0x43,
0x4b, 0}; 0x4b, 0};
static const char none[] = "NONE";
static const char init[] = "INIT";
static const char running[] = "RUNNING";
static const char needs_poll[] = "NEEDS POLL";
static const char *states[] = { static const char *states[] = {
closed, closed,
@ -105,7 +109,11 @@ static const char *states[] = {
fin_wait_2, fin_wait_2,
closing, closing,
time_wait, time_wait,
last_ack}; last_ack,
none,
init,
running,
needs_poll};
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
@ -185,34 +193,27 @@ PT_THREAD(tcp_stats(struct httpd_state *s, char *ptr))
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static unsigned short static unsigned short
make_processes(void *s) make_processes(void *p)
{ {
struct process *p = (struct process *)s;
char name[40]; char name[40];
strncpy(name, p->name, 40); strncpy(name, ((struct process *)p)->name, 40);
petsciiconv_toascii(name, 40); petsciiconv_toascii(name, 40);
return sprintf((char *)uip_appdata, return sprintf((char *)uip_appdata,
"<tr align=\"center\"><td>%p</td><td>%s</td><td>0x%02x</td><td>%p</td></tr>\r\n", "<tr align=\"center\"><td>%p</td><td>%s</td><td></td><td>%p</td><td></td><td>%s</td></tr>\r\n",
p, name, 0, p, name,
p->thread); ((struct process *)p)->thread,
states[9 + ((struct process *)p)->state]);
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static static
PT_THREAD(processes(struct httpd_state *s, char *ptr)) PT_THREAD(processes(struct httpd_state *s, char *ptr))
{ {
struct process *p = NULL;
PSOCK_BEGIN(&s->sout); PSOCK_BEGIN(&s->sout);
/* for(s->ptr = PROCESS_LIST(); s->ptr != NULL; s->ptr = ((struct process *)s->ptr)->next) {
for(s->count = 0; s->count < EK_CONF_MAXPROCS; ++s->count) { PSOCK_GENERATOR_SEND(&s->sout, make_processes, s->ptr);
p = ek_process(s->count);
if(p != NULL) {
PSOCK_GENERATOR_SEND(&s->sout, make_processes, p);
} }
}
*/
PSOCK_END(&s->sout); PSOCK_END(&s->sout);
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/

View file

@ -28,7 +28,7 @@
* *
* This file is part of the uIP TCP/IP stack. * This file is part of the uIP TCP/IP stack.
* *
* $Id: httpd.h,v 1.2 2006/08/09 16:13:39 bg- Exp $ * $Id: httpd.h,v 1.3 2007/04/07 01:31:29 oliverschmidt Exp $
* *
*/ */
@ -51,7 +51,10 @@ struct httpd_state {
char *scriptptr; char *scriptptr;
int scriptlen; int scriptlen;
union {
unsigned short count; unsigned short count;
void *ptr;
};
}; };