1/********************************************************************************************** 2 * Author: Noel V Aguilar 3 * Version: 1.4 4 * Filename: html-lib.c 5 * 6 * This C HTML library will facilitate the creation of CGI scripts using 7 * C. In order to access the functions contained within this library 8 * please include the "html-lib.h" file in your source. This file will only assist in 9 * is using html references and will not do any data manipulation. 10***********************************************************************************************/ 11 12#include "html-lib.h" 13 14 15/*----------------------------------------------------------------------------------------*/ 16 17 18/* 19 mime_header() - This function will take any text passed to it and it will diplay it as 20 the mime type. 21*/ 22void mime_header(char *mime) 23{ 24 printf("Content-type: %s\n\n",mime); 25} 26 27 28/*----------------------------------------------------------------------------------------*/ 29 30 31/* 32 html_begin() - This function will diplay the top of the head of the html page all the 33 way upto the body tag. The title and body attributes may be passed, if 34 for any of these fields are not desired, then pass NULL. 35*/ 36void html_begin(char *title, char *attributes) 37{ 38 puts("<HTML>"); 39 puts("<HEAD>"); 40 (title == NULL) ? puts("<TITLE></TITLE>") : printf("<TITLE>%s</TITLE>\n",title); 41 puts("</HEAD>"); 42 (attributes == NULL) ? puts("<BODY>") : printf("<BODY %s>\n",attributes); 43} 44 45 46/*----------------------------------------------------------------------------------------*/ 47 48 49/* 50 h1() - This function will diplay whatever text is given between the tags. 51*/ 52void h1(char *str) 53{ 54 printf("<H1>%s</H1>\n",str); 55} 56 57 58/*----------------------------------------------------------------------------------------*/ 59 60 61/* 62 h2() - This function will diplay whatever text is given between the tags. 63*/ 64void h2(char *str) 65{ 66 printf("<H2>%s</H2>\n",str); 67} 68 69 70/*----------------------------------------------------------------------------------------*/ 71 72 73/* 74 h3() - This function will diplay whatever text is given between the tags. 75*/ 76void h3(char *str) 77{ 78 printf("<H3>%s</H3>\n",str); 79} 80 81 82/*----------------------------------------------------------------------------------------*/ 83 84 85/* 86 h4() - This function will diplay whatever text is given between the tags. 87*/ 88void h4(char *str) 89{ 90 printf("<H4>%s</H4>\n",str); 91} 92 93 94/*----------------------------------------------------------------------------------------*/ 95 96 97/* 98 h5() - This function will diplay whatever text is given between the tags. 99*/ 100void h5(char *str) 101{ 102 printf("<H5>%s</H5>\n",str); 103} 104 105 106/*----------------------------------------------------------------------------------------*/ 107 108 109/* 110 h6() - This function will diplay whatever text is given between the tags. 111*/ 112void h6(char *str) 113{ 114 printf("<H6>%s</H6>\n",str); 115} 116 117 118/*----------------------------------------------------------------------------------------*/ 119 120 121/* 122 hidden() - This function will print out hidden fields to the html page. The Name and 123 value of the hidden field must be passed. 124*/ 125void hidden(char *name, char *value) 126{ 127 printf("<INPUT TYPE=hidden NAME=\"%s\" VALUE=\"%s\">\n",name,value); 128} 129 130 131/*----------------------------------------------------------------------------------------*/ 132 133 134/* 135 html_end() - This function will do nothing more than to just give the ending tags 136 of the html page. 137*/ 138void html_end(void) 139{ 140 puts("</BODY>"); 141 puts("</HTML>"); 142} 143 144 145/*----------------------------------------------------------------------------------------*/ 146 147 148/* 149 location() - This function will redirect a browser to another URL. 150*/ 151void location(char *loc) 152{ 153 printf("Location: %s\n\n",loc); 154} 155 156 157