home *** CD-ROM | disk | FTP | other *** search
/ The HTML Web Publisher's Construction Kit / HTMLWPCK.ISO / unix / cgi / c_src / brady.c next >
Encoding:
C/C++ Source or Header  |  1995-07-27  |  2.0 KB  |  94 lines

  1. /* brady.c
  2.    this produces a 3X3 matrix of images much like the opening 
  3.    if the brady bunch. All the names/urls/images match objects
  4.    on a local machine at NYU and will have to be changed to customize.
  5.  
  6.    It is included not to be used as a stand=alone, but rather as 
  7.    some sample code to base other cgi apps on. To take a look at
  8.    what this produces on my server, try this URL:
  9.  
  10.     http://found.cs.nyu.edu/cgi-bin/downing/brady
  11. */
  12.  
  13. #include <stdio.h>
  14.  
  15. #define LF        10
  16. #define TRUE        1
  17. #define FALSE        0
  18. #define PATH        "http://found.cs.nyu.edu/MRL/faces/"
  19. #define RPATH        "http://found.cs.nyu.edu"
  20.  
  21.  
  22. int main(void)
  23. {
  24.  
  25.     unsigned char rn;
  26.     int people[]= {0,0,0,0,0,0,0,0,0};
  27.     int index, list[8],assigned;
  28.     char *names[]= {
  29.       "allison",
  30.       "ken",
  31.       "richard",
  32.       "robo",
  33.       "dancer",
  34.       "troy",
  35.       "raj",
  36.       "athomas",
  37.       "fred"
  38.     };
  39.  
  40.     char *reference[]= {
  41.       "/nobody.html",
  42.       "/play.a/perlin/public-html/index.html",
  43.       "/robust.b/robots/rsw/public-html/index.html",
  44.       "/robust.b/robots/rsw/public-html/robotics.html",
  45.       "/MRL/proc_anim/animation.html",
  46.       "/shaggy.a/downing/public-html/index.html",
  47.       "/large.a/rajesh/public-html/index.html",
  48.       "/large.a/athomas/public-html/index.html",
  49.       "/cadman.a/robots/hansen/public-html/index.html"
  50.     };
  51.  
  52.     char *position[]= {
  53.       "TL",
  54.       "TC",
  55.       "TR",
  56.       "CL",
  57.       "CC",
  58.       "CR",
  59.       "BL",
  60.       "BC",
  61.       "BR"
  62.     };
  63.  
  64.  
  65.      printf("Content-type: text/html%c%c",LF,LF);
  66.     srand(getpid());
  67.  
  68.     for(index=0;index <= 8;index++){
  69.       assigned=FALSE;
  70.       while(!assigned){
  71.          rn = rand()%9;
  72.          if(people[rn]==FALSE){
  73.         list[index]=rn;
  74.         people[rn]=TRUE;
  75.         assigned=TRUE;
  76.          }
  77.       }
  78.     }
  79.     printf("<HTML><HEAD><META http-equiv=\"Refresh\" content=25>");
  80.     printf("<title>MRL Faces</title>");
  81.     printf("</HEAD>");
  82.     printf("<h1>Faces at the MRL</h1><p><hr>%c",LF);
  83.     printf("<PRE>");
  84.     for(index=0;index <= 8; index++){
  85.        printf("<a href=\"%s%s\"><img src=\"%s%s%s.gif\"></a> ",
  86.           RPATH,reference[list[index]],PATH,names[list[index]],
  87.           position[index]);
  88.        if(((index-2)%3)==0)
  89.          printf("<p>%c",LF);
  90.     }
  91.     printf("</PRE>");
  92.     return(0);
  93. }
  94.