|
To access the contents, click the chapter and section titles.
Platinum Edition Using HTML 4, XML, and Java 1.2
SSIDumpThe SSIDump program is a handy debugging utility that dumps the SSI environment variables and command-line arguments back to the browser (see Listing 32.1). Listing 32.1 ssidump.cSSI Program for Dumping SSI Environment Variables // SSIDUMP.C // This program dumps the SSI environment variables // to the screen. The code is platform-independent. // Compile it for your system and place it in your // CGI-BIN directory. #include <windows.h> // only required for Windows machines #include <stdio.h> void main(int argc, char * argv[]) { // First declare our variables. This program // only uses one, i, a generic integer counter. int i; // Print some nice-looking header // information. Note that unlike a CGI // program, there is no need to include the // standard HTTP headers. printf(<H1>SSI Environment Dump</H1>\n); printf(<B>Command-Line Arguments:</B>\n); // Now print the command-line arguments. // By convention, arg[0] is the path to this // program at run-time. args[1] through // arg[argc-1] are passed to the program as // parameters. Only some servers will allow // command-line arguments. Well use a nice // bulleted list format to make it readable: printf(<ul>\n); for (i = 0; i < argc; i++) { printf(<li>argv[%i]=%s\n,i,argv[i]); } printf(</ul>\n); // Now print out whatever environment variables // are visible to us. Well use the bulleted // list format again: printf(<b>Environment Variables:</b>\n<ul>\n); i = 0; while (_environ[i]) { printf(<li>%s\n,_environ[i]); i++; } printf(</ul>\n); // Flush the output and were done fflush(stdout); return; } RQThe RQ program hunts up a random quotation or other bit of text from a file and outputs it. The quotation file uses a simple format: Each entry must be contiguous, but can span any number of lines. Entries are separated by a single blank line. Listing 32.2 is a sample quotation file. The entries were chosen randomly by RQ itself. Make of that what you will. Listing 32.2 Rq.txtSample Text File for Use with the RQ Program KEEPING THIS A HAPPY FILE: o All entries should start flush-left. o Entries may be up to 8K in length. o Entries must be at least one line. o Entries may contain 1-9999 lines (8K max). o Line length is irrelevant; CRs are ignored. o Entries are separated by ONE blank line. o The last entry must be followed by a blank line, too. o The first entry (these lines here) will never get picked, o so we use it to document the file. o Length of the file doesnt change retrieval time. o Any line beginning with -- it is treated as a byline. o It must be the last line in the block, otherwise the o quotation might get cut off. o You can use HTML formatting tags. Drunk is feeling sophisticated when you cant say it. --Anon What really flatters a man is that you think him worth flattery. --George Bernard Shaw True patriotism hates injustice in its own land more than anywhere else. --Clarence Darrow If by fundies we mean fanatics, thats okay with me, but in that case shouldnt we call them fannies? --Damon Knight My <I>other</I> car is <I>also</I> a Porsche. --Bumper Sticker The death sentence is a necessary and efficacious means for the Church to attain its ends when rebels against it disturb the ecclesiastical unity, especially obstinate heretics who cannot be restrained by any other penalty from continuing to disturb ecclesiastical order. --Pope Leo XIII Note that although the preceding sample file has text quotations in it, you can just as easily use RQ for random links or graphics. For random links or graphics, leave off the bylines and use standard <A HREF> format. You can even use RQ for single words or phrases used to complete a sentence in real-time. For example, the phrases in parentheses can come from an RQ file to complete this sentence: If you dont like this page, youre (a pusillanimous slug) (a cultured person) (pond scum) (probably dead) (quite perceptive) (drunk) (an editor). Ill leave it to you to figure out which are compliments and which are insults.
RQ can accept the name of a quotation file from a command-line argument. If youre unlucky enough to run RQ on a server that doesnt support command-line arguments, or if you leave the command-line arguments off, RQ tries to open Rq.txt in the same directory its in. You can have multiple executables, each reading a different file, simply by having copies of RQ with different names. RQ looks for its executable name at runtime, strips the extension, and adds .txt. So if you have a copy of RQ named RQ2, it opens Rq2.txt. Listing 32.3 shows the code for the rq.c program.
|
Products | Contact Us | About Us | Privacy | Ad Info | Home
Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc. All rights reserved. Reproduction whole or in part in any form or medium without express written permission of EarthWeb is prohibited. Read EarthWeb's privacy statement. |