RSS


[ Pobierz całość w formacie PDF ]
.\n""An hundred years should go to praise\n""Thine eyes, and on thy forehead gaze.\n""Two hundred to adore each breast:\n""But thirty thousand to the rest.\n""An age at least to every part,\n""And the last age should show your heart.\n""For lady, you deserve this state;\n""Nor would I love at lower rate.\n""But at my back I always hear\n""Time's winged chariot hurrying near:\n""And yonder all before us lie\n""Deserts of vast eternity.\n""Thy beauty shall no more be found,\n""Nor, in thy marble vault, shall sound\n""My echoing song; then worms shall try\n""That long preserved virginity:\n""And your quaint honour turn to dust;\n""And into ashes all my lust.\n""The grave's a fine and private place,\n""But none, I think , do there embrace.\n""Now therefore, while the youthful hue\n""Sits on thy skin like morning dew,\n""And while thy willing soul transpires\n""At every pore with instant fires,\n""Now let us sport us while we may;\n""And now, like am'rous birds of prey,\n""Rather at once our time devour,\n"file:///D|/DOWNLOAD/charlie_calvert's_borland_c++_builder_unleashed/ch26.htm (36 of 42) [10/10/2000 1:15:36 AM] Ch 26 -- Extending an Internet Server with ISAPI"Than languish in his slow chapped power\n""Let us roll all our strength, and all\n""Our sweetness, up into one ball:\n""And tear our pleasures with rough strife,\n""Through the iron gates of life.\n""Thus, though we cannot make our sun\n""Stand still, yet we will make him run.\n""-- Andrew Marvell";void main(void){setvbuf(stdout, NULL, _IONBF, 0);printf("\nContent-type: text/html\n\n");printf("\n");printf("\n");printf("");printf(S);printf("\n");printf("\n");}This console application has no main form; its output appears only in a browser, as shown in Figure 26.5.Figure 26.5The Simple CGI application.To create the SimpleCGI application, start a new project and remove the main form.Save the project file in its owndirectory, and then choose Options | Project | Linker and set the Application Type to Console Application.You can alsouse File | New and select Console App from the App Expert dialog.Remove all the WinMain business, and replace it with a simple DOS-style main block:void main(void){setvbuf(stdout, NULL, _IONBF, 0);file:///D|/DOWNLOAD/charlie_calvert's_borland_c++_builder_unleashed/ch26.htm (37 of 42) [10/10/2000 1:15:36 AM] Ch 26 -- Extending an Internet Server with ISAPIprintf("\nContent-type: text/html\n\n");printf("\n");printf("\n");printf(".the sessions of sweet silent thought.");printf("\n");printf("\n");}This complete CGI application needs only be compiled and then copied to a server.You call a CGI application exactly as you would an ISAPI DLL:SimpleCgi.exeTwo complete HTML files for use with this chapter are available in the root of the Chap26 directory on the CD thataccompanies this book.You might, of course, have to edit the paths shown in these files.Retrieving the Variables Passed to a CGI ApplicationThe variables passed to a CGI application can be retrieved from the DOS environment.You see these same types ofvariables when you type Set at the DOS prompt.You can use the getenv or _environ function to retrieve thisdata.NOTE: Ghastly function names like getenv and the deplorable _environ are the result of a bygonetime when compilers had a limited ability to work with long identifiers.Furthermore, there was a need totry to save every byte in the applications being produced.Despite the ugly function names, those were romantic and exciting times.It was a period when allPC-based computer technology was new, and the industry was experiencing dynamic growth.Despite the romance of that era, our much more complex contemporary programming environmentsrequire more careful habits.In modern programming, these functions would have easier-to-understandnames like GetEnvironment and Environment.I sometimes catch myself wondering how many wasted hours have been lost, on a global scale, as a resultof the horrible naming conventions and ludicrous capitalization standards that used to exist.On the otherhand, I also can't help but look back fondly, on the smaller, more manageable APIs that existed in thosetimes, and on the highly charged, and much more friendly, atmosphere that prevailed.The CGIVars application found on the CD that accompanies this book shows how to iterate through all theenvironment variables passed to a CGI application.The output from that program is shown in Figure 26.6, and thesource for the program is shown in Listing 26.8 through Listing 26.10.FIGURE 26.6.The output from the CGIVars application.Listing 26.8.The CGIVars application shows how to retrieve all the variables passed to a CGI application.///////////////////////////////////////// CGIVars.cpp// Using an object to make CGI easierfile:///D|/DOWNLOAD/charlie_calvert's_borland_c++_builder_unleashed/ch26.htm (38 of 42) [10/10/2000 1:15:36 AM] Ch 26 -- Extending an Internet Server with ISAPI// Copyright (c) 1997 by Charlie Calvert//#include#pragma hdrstop#include "CGIHelp1.h"USEUNIT(".\.\Utils\CGIHelp1.cpp");void main(void){TCGIHelp CGI;CGI.Header("World Enough and Time");CGI.ShowEnv();}Listing 26.9.The TCGIHelp object provides support for CGI application.This is the header for the module.///////////////////////////////////////// CGIHelp1.h// An object to make CGI easier// Copyright (c) 1997 by Charlie Calvert//#ifndef CGIHelp1H#define CGIHelp1Henum TColorType {ctLightBlue, ctRedYellow, ctBlueYellow, ctGreenBlack};class TCGIHelp{public:TCGIHelp();file:///D|/DOWNLOAD/charlie_calvert's_borland_c++_builder_unleashed/ch26.htm (39 of 42) [10/10/2000 1:15:36 AM] Ch 26 -- Extending an Internet Server with ISAPI~TCGIHelp();void HTMLHeader();void Header(AnsiString S);AnsiString GetQuery();void Colors(TColorType ColorType);void ShowEnv();};#endifListing 26.10.The main source file for the TCGIHelp utility.///////////////////////////////////////// CGIHelp1.cpp// An object to make CGI easier// Copyright (c) 1997 by Charlie Calvert//#include#pragma hdrstop#include "CGIHelp1.h"TCGIHelp::TCGIHelp(){setvbuf(stdout, NULL, _IONBF, 0);printf("\nContent-type: text/html\n\n");printf("\n");printf("\n");}TCGIHelp::~TCGIHelp(){file:///D|/DOWNLOAD/charlie_calvert's_borland_c++_builder_unleashed/ch26.htm (40 of 42) [10/10/2000 1:15:36 AM] Ch 26 -- Extending an Internet Server with ISAPIprintf("\n");printf("\n");}void TCGIHelp::Header(AnsiString S){AnsiString Temp = "" + S + AnsiString("");printf(Temp [ Pobierz całość w formacie PDF ]
  • zanotowane.pl
  • doc.pisz.pl
  • pdf.pisz.pl
  • wblaskucienia.xlx.pl