/*  copyright 1997, zap technologies  */

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

char *strhex(unsigned long int v, int w, char *s);

main() {
  int b,g,r;
  time_t tm;
  char bg[8], tx[8], tl[8], vl[8];

  time(&tm);
  srand(tm);
  b = rand() & 0xFF; g = rand() & 0xFF; r = rand() & 0xFF;
  strhex(r,2,bg); strhex(g,2,&bg[2]); strhex(b,2,&bg[4]);
  strhex(~r,2,tx); strhex(~g,2,&tx[2]); strhex(~b,2,&tx[4]);
  b = b << 2; g = g << 2; r = r << 2;
  strhex(~r,2,vl); strhex(~g,2,&vl[2]); strhex(~b,2,&vl[4]);

  printf("Content-type: text/html\n\n");
  printf("<!--  copyright 1997, zap technologies  -->\n");
  printf("<!--  http://www.zaptech.com  -->\n\n<html>\n\n");
  printf("<head>\n<title>zap technologies</title>\n</head>\n\n");
  printf("<body bgcolor=#%s text=#%s vlink=#%s>\n", bg, tx, vl);
  printf("<body bgcolor=#%s text=#%s vlink=#%s>\n", bg, tx, vl);

  printf("<center>\n");
  printf("Random color: %s,  Real time: %X\n\n", bg, tm);
  printf("<p><a href=colors>Reload</a> me for more color fun!\n\n");

  printf("<p><a href=/><img src=/graphics/zeb1x.gif width=128 height=96 alt=\"zap technologies\" border=0></a>\n");
  printf("</center>\n");

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


char *strhex(unsigned long int v, int w, char *s) {
  int i;

  s[w] = 0;
  while (w--) {
    i = v & 0xF;
    if (i < 10)
      s[w] = '0' + i;
    else
      s[w] = 'A' - 10 + i;
    v = v >> 4;
    }
  return(s);
  }

