inc/htmshell.h

Go to the documentation of this file.
00001 /* Htmshell.h - stuff to make it easier to generate HTML files on
00002  * the fly.  Typically included with cheapcgi.h in almost any
00003  * CGI program.
00004  *
00005  * To use this generally you should call the function htmShell()
00006  * very early inside of main().  You pass htmShell() a routine
00007  * which does most of the work of your web server-side applet.
00008  * 
00009  * These routines will throw errors, which are caught by 
00010  * htmShell, which then returns.  For the most part you just
00011  * want an error to cause an error message to be printed and
00012  * then terminate your CGI program, so this works fine.
00013  *
00014  * This file is copyright 2002 Jim Kent, but license is hereby
00015  * granted for all use - public, private or commercial. */
00016 
00017 void htmlSetCookie(char* name, char* value, char* expires, char* path, char* domain, boolean isSecure);
00018 /* create a cookie with the given stats */
00019 
00020 void htmlParagraph(char *line, ...);
00021 /* Print a line in it's own paragraph. */
00022 
00023 void htmlVaParagraph(char *line, va_list args);
00024 /* Print a line in it's own paragraph. */
00025 
00026 void htmlCenterParagraph(char *line, ...);
00027 /* Center a line in it's own paragraph. */
00028 
00029 void htmlHorizontalLine();
00030 /* Print a horizontal line. */
00031 
00032 void htmlNbSpaces(int count);
00033 /* Print a number of non-breaking spaces. */
00034 
00035 void htmHorizontalLine(FILE *f);
00036 /* Print a horizontal line. */
00037 
00038 void htmTextOut(FILE *f, char *s);
00039 /* Print out string to file, if necessary replacing > with > and the like */
00040 
00041 void htmlTextOut(char *s);
00042 /* Print out string, if necessary replacing > with > and the like */
00043 
00044 char *htmlEncode(char *s);
00045 /* Return a clone of s but if necessary replacing > with > and the like */
00046 
00047 void htmlMemDeath();
00048 /* Complain about lack of memory and abort.  */
00049 
00050 void htmlStart(char *title);
00051 /* Write the start of a cgi-generated html file */
00052 
00053 void htmStart(FILE *f, char *title);
00054 /* Write the start of a stand alone .html file. */
00055 
00056 void htmlEnd();
00057 /* Write the end of a cgi-generated html file */
00058 
00059 void htmEnd(FILE *f);
00060 /* Write the end of a stand-alone html file */
00061 
00062 extern char *htmlStyleUndecoratedLink;
00063 /* Style that gets rid of underline of links. */
00064 
00065 void htmlSetStyle(char *style);
00066 /* Set document wide style. A favorite style to
00067  * use for many purposes is htmlStyleUndecoratedLink
00068  * which will remove underlines from links. 
00069  * Needs to be called before htmlStart or htmShell. */
00070 
00071 void htmlSetBackground(char *imageFile);
00072 /* Set background image - needs to be called before htmlStart
00073  * or htmShell. */
00074 
00075 void htmlSetBgColor(int color);
00076 /* Set background color - needs to be called before htmlStart
00077  * or htmShell. */
00078 
00079 void htmlEchoInput();
00080 /* Echo the input string to the output. */
00081 
00082 void htmlBadVar(char *varName); 
00083 /* Complain about input variables. */
00084 
00085 void htmlImage(char *fileName, int width, int height); 
00086 /* Display centered image file. */
00087 
00088 jmp_buf htmlRecover;  /* Error recovery jump. Exposed for cart's use. */
00089 
00090 void htmlVaWarn(char *format, va_list args);
00091 /* Write an error message.  (Generally you just call warn() or errAbort().
00092  * This is exposed mostly for the benefit of the cart.) */
00093 
00094 char *htmlWarnStartPattern();
00095 /* Return starting pattern for warning message. */
00096 
00097 char *htmlWarnEndPattern();
00098 /* Return ending pattern for warning message. */
00099 
00100 void htmlAbort();
00101 /* Terminate HTML file.  Exposed for cart's use. */
00102 
00103 void htmlPushEarlyHandlers();
00104 /* Push stuff to close out web page to make sensible error
00105  * message during initialization. */
00106 
00107 /* Wrap error recovery around call to doMiddle. */
00108 void htmErrOnlyShell(void (*doMiddle)());
00109 
00110 /* Wrap error recovery and and input processing around call to doMiddle. */
00111 void htmEmptyShell(void (*doMiddle)(), char *method);
00112 
00113 /* Wrap an html file around the passed in function.
00114  * The passed in function is already in the body. It
00115  * should just make paragraphs and return. 
00116  * Method should be "query" or "get" or "post" (or NULL
00117  * if you don't care)..
00118  */
00119 void htmShell( char *title, void (*doMiddle)(), char *method); 
00120 
00121 /* Wrap an html file around the passed in function.
00122  * The passed in function is already in the body. It
00123  * should just make paragraphs and return. 
00124  * Method should be "query" or "get" or "post".
00125 param title - The HTML page title
00126 param head - The head text: can be a refresh directive or javascript
00127 param method - The function pointer to execute in the middle
00128 param method - The browser request method to use
00129  */
00130 void htmShellWithHead( char *title, char *head, void (*doMiddle)(), char *method); 
00131 
00132 /* tell htmlOut to not escape special HTML chars '<', '>' */
00133 void htmlNoEscape();
00134 
00135 /* tell htmlOut to escape special HTML chars '<', '>' */
00136 void htmlDoEscape();
00137 
00138 /* Include an HTML file in a CGI.
00139  *   The file path is relative to the web server document root */
00140 void htmlIncludeWebFile(char *file);
00141 
00142 /* Include an HTML file in a CGI */
00143 void htmlIncludeFile(char *path);

Generated on Tue Dec 25 18:39:29 2007 for blat by  doxygen 1.5.2