/* html-lib.c - C routines that output various HTML constructs
Eugene Kim,
$Id: html-lib.c,v 1.8 1997/02/03 06:40:23 eekim Exp $
Copyright (C) 1996, 1997 Eugene Eric Kim
All Rights Reserved
*/
#include
#include
#include
#include
#include "html-lib.h"
/* HTTP headers */
void html_header()
{
printf("Content-type: text/html\n\n");
}
void mime_header(char *mime)
/* char *mime = valid mime type */
{
printf("Content-type: %s\n\n",mime);
}
void nph_header(char *status)
{
printf("HTTP/1.0 %s\n",status);
printf("Server: CGI using cgihtml\n");
}
void show_html_page(char *loc)
{
printf("Location: %s\n\n",loc);
}
void status(char *status)
{
printf("Status: %s\n",status);
}
void pragma(char *msg)
{
printf("Pragma: %s\n",msg);
}
void set_cookie(char *name, char *value, char *expires, char *path,
char *domain, short secure)
{
/* in later version, do checks for valid variables */
printf("Set-Cookie: %s=%s;",name,value);
if (expires != NULL)
printf(" EXPIRES=%s;",expires);
if (path != NULL)
printf(" PATH=%s;",path);
if (domain != NULL)
printf(" DOMAIN=%s;",domain);
if (secure)
printf(" SECURE");
printf("\n");
}
/* HTML shortcuts */
void html_begin(char *title)
{
printf(" \n");
printf("%s\n",title);
printf("\n\n");
printf("\n");
}
void html_end()
{
printf(" \n");
}
/* what's the best way to implement these tags? Think about this a little
more before you settle on a way to do this. */
void h1(char *header)
{
printf("%s
\n",header);
}
void h2(char *header)
{
printf("%s
\n",header);
}
void h3(char *header)
{
printf("%s
\n",header);
}
void h4(char *header)
{
printf("%s
\n",header);
}
void h5(char *header)
{
printf("%s
\n",header);
}
void h6(char *header)
{
printf("%s
\n",header);
}
/* state related functions */
void hidden(char *name, char *value)
{
printf("\n",name,value);
}