HTML
<a href=
"http://cyber.cs.ntou.edu.tw/cgi-bin/cgiwrap/~pyting/SimpleHTMLCGI">
C source: SimpleHTMLCGI.c
// gcc SimpleHTMLCGI.c -o SimpleHTMLCGI
#include <stdio.h>
void main()
{
printf("Content-type: text/html\n\n");
printf("<HTML>\n");
printf("<HEAD>\n");
printf("<TITLE>\n");
printf("This is a test page for CGI return simple HTML doc\n");
printf("</TITLE>\n");
printf("</HEAD>\n");
printf("<BODY>\n");
printf("<H1>\n");
printf("This is a test page for CGI return simple HTML doc\n");
printf("</H1>\n");
printf("</BODY>\n");
printf("</HTML>\n");
}
HTML
<a href=
"http://cyber.cs.ntou.edu.tw/cgi-bin/cgiwrap/~pyting/SimpleTextCGI">
C source: SimpleTextCGI.c
// gcc SimpleTExtCGI.c -o SimpleTextCGI
#include <stdio.h>
void main()
{
printf("Content-type: text/plain\n\n");
printf("This is a test page for CGI returns simple text\n");
}
HTML
<a href=
"http://cyber.cs.ntou.edu.tw/cgi-bin/cgiwrap/~pyting/SimpleImageCGI">
C source: SimpleImageCGI.c
// gcc SimpleImageCGI.c -o SimpleImageCGI
#include <stdio.h>
void main()
{
FILE *fp;
int c;
printf("Content-type: image/jpeg\n\n");
fp = fopen("banner.jpg","rb");
while ((c = getc(fp)) != EOF)
putchar(c);
fclose(fp);
}
HTML
<a href=
"http://cyber.cs.ntou.edu.tw/cgi-bin/cgiwrap/~pyting/SimpleDateTimeCGI">
C source: SimpleDateTimeCGI.c
// gcc SimpleDateTimeCGI.c -o SimpleDateTimeCGI
#include <stdio.h>
#include <sys/times.h>
void main()
{
long tim;
time(&tim);
printf("Content-type: text/html\n\n");
printf("Current time is %s", ctime(&tim));
}