cgi index page

Table of Contents

1. c cgi

#include <time.h>
#include <stdlib.h>
#include <stdio.h>

void print_cgi_table(void);

int
main(void)
{
  time_t rt;

  /* Prepare a noncryptographic random number generator from current time */
  srand((unsigned)time(&rt));

  /* Answer an html requestion with success */
  printf("Status: 200 OK\r\n");
  printf("Content-Type: text/html\r\n");
  printf("\r\n");

  printf("<title>SDF Public Access UNIX System</title>\n"
	 "<html><head><meta name=keywords content=\"bbs, unix, free shell, shell account, free shell account, shell access, free account, netbsd, public access, unix system, dec alpha, arpa, vhost, free webhosting, free webhost, free irc sundays, SDF, Super Dimension Fortress, lisp, genera, eggdrop, bouncer, learn unix, unix training, minecraft, paintchat\"></head>\n"
	 "<center>\n"
	 "<h1>Some vfts computer group cgis</h1>\n"
	 "<i>Hosting for this site is provided by</i><p><a target=new href=http://sdf.org\n"
	 "><img src=http://sdf.org/sdfbanner.png><p><b>The SDF Public Access UNIX System</b>\n"
	 "</a>\n"
	 "</center>\n"
	 "<p>All pages are normal http responses</p>\n"
	 "<p>The https fastcgi hosting is contributed by one of our computer group members.</p>"
	 "<p>Watch for the table below to grow (and refresh for new colours).</p>"
	 );

  print_cgi_table();

  printf("</html>\n");

  return EXIT_SUCCESS;
}

/*print_cg_table(void) -> void
 , prints an html table of file extension columns
 , and filename rows.
 */
void 
print_cgi_table()
{
  int i, j, cgi_no;
  const unsigned sat = 200; /* saturation */
  const unsigned rng = 56; /* random hues */

  const char *cgi_names[] = { "sqlite3", "printf", "random-dice", "thank-you", "print-message", "hello-world", "cgindex"};
  const size_t cgi_len = sizeof(cgi_names) / sizeof(*cgi_names);

  const char *ext_names[] = {"html", "org", "c", "cgi"};
  const size_t ext_len = sizeof(ext_names) / sizeof(*ext_names);
  cgi_no=3;

  printf("<table style=\"width:100%%; table-layout:fixed; border: 1px solid black;"
	 "\">\n");

 /* ext headings */
 printf("<tr>");
 for (j=0; j<ext_len; ++j) printf("<th>%s</th>", ext_names[j]);
 printf("</tr>\n");

  /* each cgi_names */
  for (i=0; i<cgi_len; ++i) {
    printf("<tr style=\"outline: thin solid;"
	   "background-color: rgb(%d,%d,%d);"
	   "\">\n",
	   sat + rand() % rng, sat + rand() % rng, sat + rand() % rng);

    /* each ext_names */
    for (j=0; j<ext_len; ++j){
      printf("<td style=\"border: 1px solid black;\">\n");
      printf("<a href='%s%s.%s'>%s.%s</a>\n", 
	      j == cgi_no ? "http://screwtape.sdf.org/cgi-bin/" :
		  "http://screwtape.sdf.org/vfts/",
	      cgi_names[i], ext_names[j],
	      cgi_names[i], ext_names[j]);
      printf("</td>\n");
    }
    printf("</tr>\n");
  }
  printf("</table>\n");
  return;
}
Status: 200 OK
Content-Type: text/html

<title>SDF Public Access UNIX System</title>
<html><head><meta name=keywords content="bbs, unix, free shell, shell account, free shell account, shell access, free account, netbsd, public access, unix system, dec alpha, arpa, vhost, free webhosting, free webhost, free irc sundays, SDF, Super Dimension Fortress, lisp, genera, eggdrop, bouncer, learn unix, unix training, minecraft, paintchat"></head>
<center>
<h1>Some vfts computer group cgis</h1>
<i>Hosting for this site is provided by</i><p><a target=new href=http://sdf.org
><img src=http://sdf.org/sdfbanner.png><p><b>The SDF Public Access UNIX System</b>
</a>
</center>
<p>All pages are normal http responses</p>
<p>The https fastcgi hosting is contributed by one of our computer group members.</p><p>Watch for the table below to grow (and refresh for new colours).</p><table style="width:100%; table-layout:fixed; border: 1px solid black;">
<tr><th>html</th><th>org</th><th>c</th><th>cgi</th></tr>
<tr style="outline: thin solid;background-color: rgb(217,242,248);">
<td style="border: 1px solid black;">
<a href='http://screwtape.sdf.org/vfts/printf.html'>printf.html</a>
</td>
<td style="border: 1px solid black;">
<a href='http://screwtape.sdf.org/vfts/printf.org'>printf.org</a>
</td>
<td style="border: 1px solid black;">
<a href='http://screwtape.sdf.org/vfts/printf.c'>printf.c</a>
</td>
<td style="border: 1px solid black;">
<a href='http://screwtape.sdf.org/cgi-bin/printf.cgi'>printf.cgi</a>
</td>
</tr>
<tr style="outline: thin solid;background-color: rgb(248,228,211);">
<td style="border: 1px solid black;">
<a href='http://screwtape.sdf.org/vfts/random-dice.html'>random-dice.html</a>
</td>
<td style="border: 1px solid black;">
<a href='http://screwtape.sdf.org/vfts/random-dice.org'>random-dice.org</a>
</td>
<td style="border: 1px solid black;">
<a href='http://screwtape.sdf.org/vfts/random-dice.c'>random-dice.c</a>
</td>
<td style="border: 1px solid black;">
<a href='http://screwtape.sdf.org/cgi-bin/random-dice.cgi'>random-dice.cgi</a>
</td>
</tr>
<tr style="outline: thin solid;background-color: rgb(225,230,217);">
<td style="border: 1px solid black;">
<a href='http://screwtape.sdf.org/vfts/thank-you.html'>thank-you.html</a>
</td>
<td style="border: 1px solid black;">
<a href='http://screwtape.sdf.org/vfts/thank-you.org'>thank-you.org</a>
</td>
<td style="border: 1px solid black;">
<a href='http://screwtape.sdf.org/vfts/thank-you.c'>thank-you.c</a>
</td>
<td style="border: 1px solid black;">
<a href='http://screwtape.sdf.org/cgi-bin/thank-you.cgi'>thank-you.cgi</a>
</td>
</tr>
<tr style="outline: thin solid;background-color: rgb(251,227,238);">
<td style="border: 1px solid black;">
<a href='http://screwtape.sdf.org/vfts/print-message.html'>print-message.html</a>
</td>
<td style="border: 1px solid black;">
<a href='http://screwtape.sdf.org/vfts/print-message.org'>print-message.org</a>
</td>
<td style="border: 1px solid black;">
<a href='http://screwtape.sdf.org/vfts/print-message.c'>print-message.c</a>
</td>
<td style="border: 1px solid black;">
<a href='http://screwtape.sdf.org/cgi-bin/print-message.cgi'>print-message.cgi</a>
</td>
</tr>
<tr style="outline: thin solid;background-color: rgb(235,207,251);">
<td style="border: 1px solid black;">
<a href='http://screwtape.sdf.org/vfts/hello-world.html'>hello-world.html</a>
</td>
<td style="border: 1px solid black;">
<a href='http://screwtape.sdf.org/vfts/hello-world.org'>hello-world.org</a>
</td>
<td style="border: 1px solid black;">
<a href='http://screwtape.sdf.org/vfts/hello-world.c'>hello-world.c</a>
</td>
<td style="border: 1px solid black;">
<a href='http://screwtape.sdf.org/cgi-bin/hello-world.cgi'>hello-world.cgi</a>
</td>
</tr>
<tr style="outline: thin solid;background-color: rgb(200,229,214);">
<td style="border: 1px solid black;">
<a href='http://screwtape.sdf.org/vfts/cgindex.html'>cgindex.html</a>
</td>
<td style="border: 1px solid black;">
<a href='http://screwtape.sdf.org/vfts/cgindex.org'>cgindex.org</a>
</td>
<td style="border: 1px solid black;">
<a href='http://screwtape.sdf.org/vfts/cgindex.c'>cgindex.c</a>
</td>
<td style="border: 1px solid black;">
<a href='http://screwtape.sdf.org/cgi-bin/cgindex.cgi'>cgindex.cgi</a>
</td>
</tr>
</table>
</html>

Author: vfts

Created: 2022-11-14 Mon 03:49