⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ch4.htm

📁 CGI programming is the hottest stuff to look out for in this book
💻 HTM
📖 第 1 页 / 共 2 页
字号:
Does not return a value. Used to send status messages to the browser.
<LI><TT><FONT FACE="Courier">pragma(char *msg)</FONT></TT>. Does
not return a value. Sends the browser an HTML Pragma header.
<LI><TT><FONT FACE="Courier">html_begin(char *title)</FONT></TT>.
Does not return a value. Sends the HTML tags that should appear
at the beginning of any HTML file.
<LI><TT><FONT FACE="Courier">html_end()</FONT></TT>. Does not
return a value. Sends the HTML tags that should appear at the
end of any HTML file.
<LI><TT><FONT FACE="Courier">h1(char <I>*str</I>)</FONT></TT>.
Outputs string <TT><I><FONT FACE="Courier">str</FONT></I></TT>
surrounded by <TT><FONT FACE="Courier">&lt;H1&gt;&lt;/H1&gt;</FONT></TT>
tags. Does not return a value.
<LI><TT><FONT FACE="Courier">h2</FONT></TT> through <TT><FONT FACE="Courier">h6</FONT></TT>.
Same as <TT><FONT FACE="Courier">h1</FONT></TT>, only different
heading levels (for example, <TT><FONT FACE="Courier">H2</FONT></TT>,
<TT><FONT FACE="Courier">H3</FONT></TT>, and so on).
<LI><TT><FONT FACE="Courier">list_create(llist <I>*l</I>)</FONT></TT>.
Does not return a value. Creates the list pointed to by l.
<LI><TT><FONT FACE="Courier">list_next(node <I>*l</I>)</FONT></TT>.
Returns a <TT><FONT FACE="Courier">node*</FONT></TT> type. Returns
the next node on the list pointed to by <TT><FONT FACE="Courier">w</FONT></TT>.
<LI><TT><FONT FACE="Courier">on_list(llist <I>*l</I>, node <I>*l</I>)</FONT></TT>.
Returns a <TT><FONT FACE="Courier">short</FONT></TT>. If node
<TT><FONT FACE="Courier">w</FONT></TT> is on the list <TT><FONT FACE="Courier">l</FONT></TT>,
it returns 1.
<LI><TT><FONT FACE="Courier">on_list_debug(llist <I>*l</I>, <I>node*
w</I>)</FONT></TT>. Returns a <TT><FONT FACE="Courier">short</FONT></TT>.
This is an <TT><FONT FACE="Courier">on_list</FONT></TT> that is
always reliable.
<LI><TT><FONT FACE="Courier">list_traverse(llist <I>*l</I>, void
<I>(*visit)</I> (<I>entrytype item</I>))</FONT></TT>. Does not
return a value. For use with a function that will be used on every
node in the list.
<LI><TT><FONT FACE="Courier">list_insafter(llist* l, <I>node*
w</I>, <I>entrytype item</I>)</FONT></TT>. Returns a <TT><FONT FACE="Courier">node*</FONT></TT>
type. Adds the entry after node <TT><FONT FACE="Courier">w</FONT></TT>
and returns the new node.
<LI><TT><FONT FACE="Courier">list_clear(llist <I>*l</I>)</FONT></TT>.
Does not return a value. Frees the memory used by list l.
<LI><TT><FONT FACE="Courier">newstr(char <I>*str</I>)</FONT></TT>.
Returns a <TT><FONT FACE="Courier">char*</FONT></TT>. Correctly
allocates memory for the string.
</UL>
<P>
The following describes the documentation and support available
for CGI-HTML:
<UL>
<LI><FONT COLOR=#000000>Amount of Documentation: Depends on font
size used in browser. Comes only in HTML format.</FONT>
<LI><FONT COLOR=#000000>Quality of Documentation: Not bad, but
not professional.</FONT>
<LI><FONT COLOR=#000000>Commercial License Required/Price: No.</FONT>
<LI><FONT COLOR=#000000>Actively Maintained: Yes. This library
is updated periodically by Eugene Kim.</FONT>
<LI><FONT COLOR=#000000>Level of Support: Only e-mail support
is available.</FONT>
<LI><FONT COLOR=#000000>Ease of Use: Moderately difficult.</FONT>
<LI><FONT COLOR=#000000>Number of sample programs: 5.</FONT>
</UL>
<P>
The following contains a summary of each sample program:
<UL>
<LI><TT><FONT FACE="Courier">test.cgi.c</FONT></TT>: Prints out
cgi environment variables.
<LI><TT><FONT FACE="Courier">query-results.c</FONT></TT>: Prints
out the form that is sent to it.
<LI><TT><FONT FACE="Courier">mail.cgi.c</FONT></TT>: Prints out
a comment form and mails it by e-mail.
<LI><TT><FONT FACE="Courier">index-sample.cgi.c</FONT></TT>: Determines
if the browser supports images and sends the appropriate page.
<LI><TT><FONT FACE="Courier">ignore.cgi.c</FONT></TT>: Sends a
status of 204.
</UL>
<P>
The following describes compatibility information about CGI-HTML:
<UL>
<LI><FONT COLOR=#000000>Cross-Platform Compatibility: Should run
on any platform that has an ANSI C compiler.</FONT>
</UL>
<P>
If you would like more information about CGI-HTML, you can find
it at the following places:
<UL>
<LI><FONT COLOR=#000000>Author's e-mail address: </FONT><TT><FONT FACE="Courier">eekim@fas.harvard.edu</FONT></TT>.
<LI><FONT COLOR=#000000>Author's Web page: </FONT><TT><FONT FACE="Courier"><A HREF="http://hcs.harvard.edu/~eekim/web/cgihtml">http://hcs.harvard.edu/~eekim/web/cgihtml</A></FONT></TT>.
</UL>
<H2><A NAME="TheccGIClassLibraries"><FONT SIZE=5 COLOR=#FF0000>The
C++ CGI Class Libraries</FONT></A></H2>
<P>
Of the two C++ class libraries for CGI that I could find, AHTML
is easily the best of the two. It is constantly updated, contains
many neat features, and is very easy to use.
<H3><A NAME="AHTML">AHTML</A></H3>
<P>
AHTML is a great C++ class library, and although I am biased towards
C++ as a language (not C with a little C++ thrown in, just pure
C++), there is no denying it is such. It is the only CGI library
of any language to include encryption and encoding/decoding to
4-bit hex and 7-bit alpha.
<P>
Following are the features of AHTML:
<UL>
<LI><FONT COLOR=#000000>Great form handling.</FONT>
<LI><FONT COLOR=#000000>Can handle all CGI environment variables.</FONT>
<LI><FONT COLOR=#000000>Includes arrays, matrixes, and linked
lists.</FONT>
<LI><FONT COLOR=#000000>Contains classes for handling bitmaps
and other image types.</FONT>
<LI><FONT COLOR=#000000>Can perform automatic redirection.</FONT>
<LI><FONT COLOR=#000000>It can output HTTP error/status codes
instead of a document.</FONT>
</UL>
<P>
The following lists the procedures and functions of AHTML and
contains a short synopsis of each. For more information, see the
documentation. Unfortunately, by the time this book is printed,
some of the class names will have been added and or changed. The
Web page and the included documentation are great at providing
a quick reference.
<UL>
<LI><FONT COLOR=#000000>Amount of Documentation: Nine pages of
text and a Web site.</FONT>
<LI><FONT COLOR=#000000>Quality of Documentation: The documentation
for this library is written for programmers, but it does include
examples for every class basically.</FONT>
<LI><FONT COLOR=#000000>Commercial License Required/Price: No.</FONT>
<LI><FONT COLOR=#000000>Actively Maintained: Yes. This library
is updated periodically by Alex Chachanashvili.</FONT>
<LI><FONT COLOR=#000000>Level of Support: E-mail support.</FONT>
<LI><FONT COLOR=#000000>Ease of Use: Moderately easy.</FONT>
<LI><FONT COLOR=#000000>Number of sample programs: Three.</FONT>
</UL>
<P>
The following describes the compatibility information for AHTML:
<UL>
<LI><FONT COLOR=#000000>Cross-Platform Compatibility: Should run
on any platform that has an ANSI C++ compiler.</FONT>
</UL>
<P>
If you would like more information about AHTML, you can find it
at the following places:
<UL>
<LI><FONT COLOR=#000000>Author's e-mail address: </FONT><TT><FONT FACE="Courier">achacha@panix.com</FONT></TT>.
<LI><FONT COLOR=#000000>Author's Web Page: </FONT><TT><FONT FACE="Courier"><A HREF="http://www.serve.com/adc/acgi">http://www.serve.com/adc/acgi</A></FONT></TT>.
</UL>
<H3><A NAME="KellyBlacksCGIcclasses">Kelly Black's CGI C++ Classes</A>
</H3>
<P>
This C++ class library appears to have been created in someone's
spare time, given the fact that the docs don't exist and it is
missing some features. The thing it does have going for it, though,
is the fact that it supports the creation of forms.
<P>
The author does not provide a list of features in the documentation,
and it is not possible to tell just from looking at the code,
mainly because the code is not documented well enough.
<P>
As for a list of functions and procedures, some of the procedures
have comments, but not enough to make a quick reference out of.
<P>
The following describes documentation and support available for
these CGI classes:
<UL>
<LI><FONT COLOR=#000000>Amount of Documentation: Nonexistent as
of yet.</FONT>
<LI><FONT COLOR=#000000>Quality of Documentation: N/A.</FONT>
<LI><FONT COLOR=#000000>Commercial License Required/Price: No.</FONT>
<LI><FONT COLOR=#000000>Actively Maintained: Not that I can tell.
Last update was 12/20/95.</FONT>
<LI><FONT COLOR=#000000>Level of Support: Unknown.</FONT>
<LI><FONT COLOR=#000000>Ease of Use: Fairly difficult.</FONT>
<LI><FONT COLOR=#000000>Number of sample programs: Two.</FONT>
</UL>
<P>
The following contains a summary of each sample program:
<UL>
<LI><FONT COLOR=#000000>cgiform.cpp: Shows how to create forms
using the library.</FONT>
<LI><FONT COLOR=#000000>cgimap.cpp: Imagemapping.</FONT>
</UL>
<P>
The following describes the compatibility of the CGI classes.
<UL>
<LI><FONT COLOR=#000000>Cross-Platform Compatibility: Should run
on any platform that has an ANSI C++ compiler.</FONT>
</UL>
<P>
If you would like more information about the CGI classes, you
can find it at the following places:
<UL>
<LI><FONT COLOR=#000000>Author's e-mail address: </FONT><TT><FONT FACE="Courier">black@vidalia.unh.edu</FONT></TT>.
<LI><FONT COLOR=#000000>Author's Web page: </FONT><TT><FONT FACE="Courier"><A HREF="http://www.math.unh.edu/~black/cgi">http://www.math.unh.edu/~black/cgi</A></FONT></TT>.
</UL>
<H2><A NAME="PerlLibraries"><FONT SIZE=5 COLOR=#FF0000>Perl Libraries</FONT></A>
</H2>
<P>
Unlike the other languages, there is a basically standard library
for CGI programming in Perl: CGI-Lib.
<H3><A NAME="CGILib">CGI-Lib</A></H3>
<P>
The following lists the features of CGI-Lib:
<UL>
<LI><FONT COLOR=#000000>Standard.</FONT>
<LI><FONT COLOR=#000000>Supports form processing.</FONT>
<LI><FONT COLOR=#000000>Has basic error handling.</FONT>
</UL>
<P>
The following contains the CGI-Lib procedures and functions and
a short synopsis of each. For more information, see the documentation.
<UL>
<LI><TT><FONT FACE="Courier">ReadParse</FONT></TT>. This subroutine
reads and parses the CGI data and places it in a usable format.
<LI><TT><FONT FACE="Courier">PrintHeader</FONT></TT>. Prints out
the Content Type required for an HTML document.
<LI><TT><FONT FACE="Courier">HtmlTop</FONT></TT>. Returns the
proper tags for the beginning of an HTML document.
<LI><TT><FONT FACE="Courier">HtmlBot</FONT></TT>. Returns the
proper tags for the end of an HTML document.
<LI><TT><FONT FACE="Courier">MethGet</FONT></TT>. True if the
<TT><FONT FACE="Courier">GET</FONT></TT> method was used.
<LI><TT><FONT FACE="Courier">MethPost</FONT></TT>. True if the
<TT><FONT FACE="Courier">POST</FONT></TT> method was used.
<LI><TT><FONT FACE="Courier">MyBaseURL</FONT></TT>. Returns the
base URL of the script.
<LI><TT><FONT FACE="Courier">MyFullURL</FONT></TT>. Returns the
full URL of the script.
<LI><TT><FONT FACE="Courier">CgiError</FONT></TT>. Prints out
an error message with the proper headers.
<LI><TT><FONT FACE="Courier">CgiDie</FONT></TT>. <TT><FONT FACE="Courier">CgiError</FONT></TT>
that quits after printing out the info on the error.
<LI><TT><FONT FACE="Courier">PrintVariables.</FONT></TT> Prints
out the CGI variables.
<LI><TT><FONT FACE="Courier">PrintEnv</FONT></TT>. Nicely prints
out the environment variables.
</UL>
<P>
The following describes documentation and support available for
CGI-Lib:
<UL>
<LI><FONT COLOR=#000000>Amount of Documentation: Web page, various
tutorials, and the library itself has a lot of comments in it.</FONT>
<LI><FONT COLOR=#000000>Quality of Documentation: Depends on the
documentation used. Most of it is written well.</FONT>
<LI><FONT COLOR=#000000>Commercial License Required/Price: No,
but credit is needed.</FONT>
<LI><FONT COLOR=#000000>Actively Maintained: Yes. This library
is updated periodically by Steven E. Brenner.</FONT>
<LI><FONT COLOR=#000000>Level of Support: Listservs, e-mail, and
so on.</FONT>
<LI><FONT COLOR=#000000>Ease of Use: Moderately easy.</FONT>
<LI><FONT COLOR=#000000>Number of sample programs: None included
in library; hundreds available on the Web.</FONT>
</UL>
<P>
The following describes the compatibility information on CGI-Lib:
<UL>
<LI><FONT COLOR=#000000>Cross-Platform Compatibility: Runs on
any platform that has a Perl Interpreter. Compatible with versions
4 and 5 of Perl.</FONT>
</UL>
<P>
If you would like more information about CGI-Lib, you can find
it in the following places:
<UL>
<LI><FONT COLOR=#000000>Author's e-mail address: </FONT><TT><FONT FACE="Courier">S.E.Brenner@bioc.cam.ac.uk</FONT></TT>.
<LI><FONT COLOR=#000000>Author's Web page: </FONT><TT><FONT FACE="Courier"><A HREF="http://www.bio.cam.ac.uk/cgi-lib/">http://www.bio.cam.ac.uk/cgi-lib/</A></FONT></TT>.
</UL>
<H2><A NAME="Summary"><FONT SIZE=5 COLOR=#FF0000>Summary</FONT></A>
</H2>
<P>
That just about does it for our look at the various CGI libraries
that are available to developers. The next chapter explores designing
your CGI application.
<P>
<HR WIDTH="100%"></P>

<CENTER><P><A HREF="ch3.htm"><IMG SRC="pc.gif" BORDER=0 HEIGHT=88 WIDTH=140></A><A HREF="#CONTENTS"><IMG SRC="cc.gif" BORDER=0 HEIGHT=88 WIDTH=140></A><A HREF="index.htm"><IMG SRC="hb.gif" BORDER=0 HEIGHT=88 WIDTH=140></A><A HREF="ch5.htm"><IMG 
SRC="nc.gif" BORDER=0 HEIGHT=88 WIDTH=140></A></P></CENTER>

<P>
<HR WIDTH="100%"></P>

</BODY>
</HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -