Skip to content

Commit

Permalink
Use libcgi instead of badly written code
Browse files Browse the repository at this point in the history
  • Loading branch information
jaskorpe committed Aug 27, 2010
1 parent f051358 commit 55bf204
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions brainfuck_cgi.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

#include <unistd.h>

#include <cgi.h>


unsigned char *cells;
unsigned int cell;
Expand Down Expand Up @@ -97,9 +99,6 @@ interpret (int ignore)
void
header (char *title)
{
printf ("Content-type: text/html\n\n");


printf ("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"");
printf ("\t\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">");

Expand Down Expand Up @@ -233,11 +232,17 @@ int
main (void)
{
char *filename;
char *get = getenv ("QUERY_STRING");

char byte;

if (!*get)
s_cgi *cgi;


cgi = cgiInit ();

cgiHeader ();

if (!(filename = cgiGetValue (cgi, "file")))
{
header (NULL);
main_site ();
Expand All @@ -246,7 +251,6 @@ main (void)

cell = 0;

filename = extract_get_var (get, "file");
filename = (valid_filename (filename));

if (filename)
Expand Down

0 comments on commit 55bf204

Please sign in to comment.