Code/Resource
Windows Develop
Linux-Unix program
Internet-Socket-Network
Web Server
Browser Client
Ftp Server
Ftp Client
Browser Plugins
Proxy Server
Email Server
Email Client
WEB Mail
Firewall-Security
Telnet Server
Telnet Client
ICQ-IM-Chat
Search Engine
Sniffer Package capture
Remote Control
xml-soap-webservice
P2P
WEB(ASP,PHP,...)
TCP/IP Stack
SNMP
Grid Computing
SilverLight
DNS
Cluster Service
Network Security
Communication-Mobile
Game Program
Editor
Multimedia program
Graph program
Compiler program
Compress-Decompress algrithms
Crypt_Decrypt algrithms
Mathimatics-Numerical algorithms
MultiLanguage
Disk/Storage
Java Develop
assembly language
Applications
Other systems
Database system
Embeded-SCM Develop
FlashMX/Flex
source in ebook
Delphi VCL
OS Develop
MiddleWare
MPI
MacOS develop
LabView
ELanguage
Software/Tools
E-Books
Artical/Document
CGITEST.C
Package: ertos.rar [view]
Upload User: sunrenlu
Upload Date: 2022-06-13
Package Size: 1419k
Code Size: 2k
Category:
OS Develop
Development Platform:
DOS
- /* This example show a CGI script in use
- *
- */
- #include <rtos.h>
- #include <net.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <time.h>
- #include <string.h>
- #include <graph.h>
- #include <smtpcli.h>
- #include <httpd.h>
- #include <strlst.h>
- crit_x *dos;
- void web_showform( tcp_Socket *s )
- {
- sock_puts( s, "<form method="post" action="square">"
- "Enter a number "
- "<input type="TEXT" name="NUMBER" value="23">"
- "<input type="submit" value="Square">"
- "<input type="reset" value="Reset">"
- "</form>");
- html_tail( s );
- }
- void web_index( tcp_Socket *s )
- {
- FILE *f;
- char buf[128];
- sock_puts(s, "Content-Type: text/htmlrn");
- html_hdr( s, "Simple CGI");
- web_showform( s );
- }
- void web_result( tcp_Socket *s )
- {
- stringlist *sl;
- char *p, *q;
- DWORD x = 0;
- char buf[ 128 ];
- sock_puts(s, "Content-Type: text/htmlrn");
- sl = cgi_getstrings( s );
- if ( (p = strlst_findfirst( sl, "NUMBER", NULL, &q )) != NULL )
- x = atol( q );
- cgi_freestrings( sl );
- html_hdr(s,"Simple CGI");
- sprintf( buf, "<p>%lu squared is %lu</p>", x, x*x );
- sock_puts(s, buf );
- web_showform( s );
- }
- /*
- * - the web server calls this proc for each web request
- * - it is called in the context of *one* of the HTTPD threads,
- * though which is not known or important
- * - multiple threads may be in the same proc at the same time
- */
- void user_proc( tcp_Socket *s, char *cmd, char *file, char *ext )
- {
- if ( !stricmp( file, "/" )) web_index( s );
- if ( !stricmp( file, "/square" )) web_result( s );
- }
- main()
- {
- int i;
- kdebug = 1;
- rt_init(100);
- dos = cs_alloc();
- sock_init(); /* initialize network */
- cputs("starting...rn");
- #define MAXHTTPD 5
- for ( i = 0 ; i < MAXHTTPD; ++i )
- rt_newthread( httpdthread, (DWORD)&user_proc, 8192, 0, "httpd worker" );
- do {
- /* nothing */
- rt_yield();
- } while ( 1 );
- }