Sophie

Sophie

distrib > Mandriva > 2008.1 > x86_64 > by-pkgid > 57254662b08bab0259d9d4ac98ef679c > files > 51

lib64xbase2-devel-2.0.0-7mdv2008.1.x86_64.rpm

<!DOCTYPE xbHtml PUBLIC>
<xbHtml>
<TITLE>Xbase DBMS Chapter 19</TITLE>
<BODY BGCOLOR=#FFFFFF>
<H1><p align="center">xbHtml/CGI Interface Methods<br></H1>
<p align="center">Chapter Updated 2/1/98</p><hr>
<TABLE BORDER>
<CAPTION ALIGN="TOP"><h3>xbHtml Class Methods</H3></CAPTION>
<TR VALIGN="BASELINE">
<TR><TH ALIGN="LEFT">Class<TD>Description
<TR><TH ALIGN="LEFT">BoldOn()<TD>Turn on bold
<TR><TH ALIGN="LEFT">BoldOff()<TD>Turn off bold
<TR><TH ALIGN="LEFT">Bullet()<TD>Create a bullet point
<TR><TH ALIGN="LEFT">DumpArray()<TD>Dumps the internal field array
<TR><TH ALIGN="LEFT">EmphasizeOn()<TD>Turn on emphasize
<TR><TH ALIGN="LEFT">EmphasizeOff()<TD>Turn off emphasize
<TR><TH ALIGN="LEFT">EndHtmlPage()<TD>Generate end-of-page tags
<TR><TH ALIGN="LEFT">GenFormFields(...)<TD>Print a form with data fields
<TR><TH ALIGN="LEFT">GetArrayNo(char * FieldName)<TD>Gets a field's offset into the internal data array
<TR><TH ALIGN="LEFT">GetCookie(char *CookieName)<TD>Get a cookie data value
<TR><TH ALIGN="LEFT">GetData(xbShort ArrayNo)<TD>Gets data for a particular array offset
<TR><TH ALIGN="LEFT">GetDataForField(char * FldName)<TD>Gets the value for a particlar field
<TR><TH ALIGN="LEFT">GetEnv(char * EnvString)<TD>Get an environment string
<TR><TH ALIGN="LEFT">GetMethod()<TD>Returns true if get method used
<TR><TH ALIGN="LEFT">HeaderOn(xbShort HeaderLevel)<TD>Turn on a header
<TR><TH ALIGN="LEFT">HeaderOff(xbShort HeaderLevel)<TD>Turn off header
<TR><TH ALIGN="LEFT">ItalicOn()<TD>Turn on italics
<TR><TH ALIGN="LEFT">ItalicOff()<TD>Turn off italics
<TR><TH ALIGN="LEFT">Newline()<TD>Generate a newline
<TR><TH ALIGN="LEFT">PlusToSpace(char *s)<TD>Convert + symbols to spaces 
<TR><TH ALIGN="LEFT">PostMethod()<TD>Returns true if post method used
<TR><TH ALIGN="LEFT">PrintHtml(char * String)<TD>Print a string or number
<TR><TH ALIGN="LEFT">PrintEncodedChar(char c)<TD>Prints an encoded xbHtml character
<TR><TH ALIGN="LEFT">PrintEncodedStringCHAR *s)<TD>Prints an encoded xbHtml string
<TR><TH ALIGN="LEFT">SendRedirect(char * RedirectURL)<TD>Send redirect command<TD>
<TR><TH ALIGN="LEFT">SetCookie(...)<TD>Set up and send a cookie to the client
<TR><TH ALIGN="LEFT">SpaceToPlus(char *s)<TD>Convert spaces to + symbols 
<TR><TH ALIGN="LEFT">StartHtmlPage(char *Title)<TD>Generates beginning of Html page tags
<TR><TH ALIGN="LEFT">StartTextPage()<TD>Generates beginning of Text page tags
<TR><TH ALIGN="LEFT">Tally(char * FileName)<TD>Increment a counter
</TABLE>
<br><br>
<hr>
<h2>Method Definitions</h2>
<hr>
<h4>Method void xbHtml::BoldOn()</h4><br>
This method prints the bold on tag.
<h4>Example Program:</h4>
See program <A HREF="/XbaseSamples/testhtml.cpp">testhtml.cpp</A> for an example of how
to use this program.
<hr>
<h4>Method void xbHtml::BoldOff()</h4><br>
This method prints the bold off tag.
<h4>Example Program:</h4>
See program <A HREF="/XbaseSamples/testhtml.cpp">testhtml.cpp</A> for an example of how
to use this program.
<hr>
<h4>Method void xbHtml::Bullet( void )</h4><br>
This method prints a bullet point.
<h4>Example Program:</h4>
See program <A HREF="/XbaseSamples/testhtml.cpp">testhtml.cpp</A> for an example of how
to use this program.
<hr>
<h4>Method void xbHtml::DumpArray( void )</h4><br>
This method dumps the internal array which stores all data passed to the 
program from the previous form.  This method is mostly used for trouble
shooting.<br><br>
<h4>Example Program:</h4>
See program <A HREF="/XbaseSamples/testhtml.cpp">testhtml.cpp</A> for an example of how
to use this program.
<hr>
<h4>Method void xbHtml::EmphasizeOn( void )</h4><br>
This method prints the emphasize on tag.
<h4>Example Program:</h4>
See program <A HREF="/XbaseSamples/testhtml.cpp">testhtml.cpp</A> for an example of how
to use this program.
<hr>
<h4>Method void xbHtml::EmphasizeOff( void )</h4><br>
This method prints the emphasize off tag.
<h4>Example Program:</h4>
See program <A HREF="/XbaseSamples/testhtml.cpp">testhtml.cpp</A> for an example of how
to use this program.
<hr>
<h4>Method void xbHtml::EndHtmlPage( void )</h4><br>
This method prints the end-of-page tags </body></html> .
<h4>Example Program:</h4>
See program <A HREF="/XbaseSamples/testhtml.cpp">testhtml.cpp</A> for an example of how
to use this program.
<hr>
<h4>Method xbShort xbHtml::GetArrayNo( char * FieldName )</h4>
This method returns a the offset into the internal array where the data for
field FieldName is stored.  It will return -1 on error.<br><br>
<h4>Example Program:</h4>
See program <A HREF="/XbaseSamples/testhtml.cpp">testhtml.cpp</A> for an example of how
to use this program.
<hr>

<h4>Method void xbHtml::GetFormFields( xbDbf *d, xbShort Option, const char * Title, 
   xbFieldList * fl )</h4>
This method is used for creating an xbHtml page with database (or non database)
fields and displaying them.  
The method creates an xbHtml table in order to align the fields
in an asthetically pleasing manner.<br><br>

<TABLE BORDER>
<CAPTION ALIGN="TOP"><H3>Method Paramaters</H3></CAPTION><BR>
<TR VALIGN="BASELINE">
<TR><TH ALIGN="LEFT">Paramater<TD>Description
<TR><TH ALIGN="LEFT">xbDbf *d<TD>A pointer to a xbDbf object, or 0 if no dbf fields used 
<TR><TH ALIGN="LEFT">xbShort Option<TD>0 = Display empty fields
<br>1 = Display field data from record buffer of object d
<TR><TH ALIGN="LEFT">char * Title<TD>An optional title
<TR><TH ALIGN="LEFT">xbFieldList *fl<TD>An array of field specific information
used for building the output
</TABLE>

<TABLE BORDER>
<CAPTION ALIGN="TOP"><H3>Stucture xbFieldList</H3></CAPTION><BR>
<TR VALIGN="BASELINE">
<TR><TH ALIGN="LEFT">Paramater<TD>Description
<TR><TH ALIGN="LEFT">char * Label<TD>Field label on form
<TR><TH ALIGN="LEFT">char * FieldName<TD>Form Field Name
<TR><TH ALIGN="LEFT">char * FieldLen<TD>Form Display Length
<TR><TH ALIGN="LEFT">xbShort DbfFieldNo<TD>Corresponding database field no 
<TR><TH ALIGN="LEFT">xbShort FieldOption<TD>0 - display as input/output field<br>
1 - display as password field<br>2 - display as output data only
</TABLE>


<TABLE BORDER>
<CAPTION ALIGN="TOP"><H3>Return Codes</H3></CAPTION><BR>
<TR VALIGN="BASELINE">
<TR><TH ALIGN="LEFT">Return Code<TD>Description
<TR><TH ALIGN="LEFT">XB_NOT_OPEN<TD>Database is not open
<TR><TH ALIGN="LEFT">XB_NO_ERROR<TD>No error
</TABLE>


<h4>Example Program:</h4>

<xmp>

xbXBase x;
xbDbf d( &x );
xbHtml p;

xbFieldList FL[] = 
{
  { "Name",    "NAME",    0, 0 },
  { "Address", "ADDRESS", 1, 0 },
  { "City",    "CITY",    2, 0 },
  { "State",   "STATE",   3, 0 },
  { "Zip",     "ZIP",     4, 0 }
}

// open the database and get a record

p.GenFormFields( &d, 1, "Address Information", FL );
</xmp>

<hr>
<h4>Method char * xbHtml::GetCookie( char * CookieName )</h4>
This method returns a pointer to the data for cookie <em>CookieName</em>
<h4>Sample Usage:</h4>
<xmp>
xbHtml p;
char CookieDataBuffer[10];
if( p.GetCookie( "COOKIETEST" ))
  strcpy( CookieDataBuffer, p.GetCookie( "COOKIETEST" ), 9 );
</xmp>
<hr>
<h4>Method char * xbHtml::GetData( xbShort ArrayNo )</h4>
This method returns the data from the internal array for offset ArrayNo.
It will return NULL if there is no data in the array for ArrayNo or if ArrayNo
is out of range.<br><br>
<h4>Example Program:</h4>
See program <A HREF="/XbaseSamples/testhtml.cpp">testhtml.cpp</A> for an example of how
to use this program.
<hr>
<h4>Method char * xbHtml::GetDataForField( char * FieldName )</h4>
This method returns the data for from the internal array for field FieldName.
It will return NULL if FieldName is not in the internal array, or if there is
no data for field FieldName.<br><br>
<h4>Example Program:</h4>
See program <A HREF="/zips/zipinq.cpp">zipinq.cpp</A> for an example of how
to use this program.
<hr>
<h4>Method char * xbHtml::GetEnv( char * EnvString )</h4><br>
This method returns a pointer to the data for environment string EnvString.
<br><br>
<TABLE BORDER>
<CAPTION ALIGN="TOP"><h3>EnvString Values</H3></CAPTION>
<TR VALIGN="BASELINE">
<TR><TH ALIGN="LEFT">EnvString
<TR><TH ALIGN="LEFT">AUTH_TYPE
<TR><TH ALIGN="LEFT">CONTENT_LENGTH
<TR><TH ALIGN="LEFT">CONTENT_TYPE
<TR><TH ALIGN="LEFT">HTTP_REQUEST_METHOD
<TR><TH ALIGN="LEFT">QUERY_STRING
<TR><TH ALIGN="LEFT">REMOTE_ADDR
<TR><TH ALIGN="LEFT">REMOTE_HOST
<TR><TH ALIGN="LEFT">REMOTE_USER
<TR><TH ALIGN="LEFT">SCRIPT_FILENAME
<TR><TH ALIGN="LEFT">SCRIPT_NAME
<TR><TH ALIGN="LEFT">SERVER_PORT
<TR><TH ALIGN="LEFT">SERVER_PROTOCOL
<TR><TH ALIGN="LEFT">SCRIPT_PATH
<TR><TH ALIGN="LEFT">CGI_STDIN
<TR><TH ALIGN="LEFT">CGI_STDOUT
<TR><TH ALIGN="LEFT">CGI_STDERR
<TR><TH ALIGN="LEFT">HTTP_USER_AGENT
<TR><TH ALIGN="LEFT">HTTP_CONTENT_LENGTH
<TR><TH ALIGN="LEFT">HTTP_ACCEPT
<TR><TH ALIGN="LEFT">HTTP_HOST
<TR><TH ALIGN="LEFT">REQUEST_METHOD
</TABLE>
<h4>Example Program:</h4>
See program <A HREF="/XbaseSamples/testhtml.cpp">testhtml.cpp</A> for an example of how
to use this program.
<hr>
<h4>Method xbShort xbHtml::GetMethod( void )</h4><br>
This method returns true if a GET method was used.
<h4>Example Program:</h4>
See program <A HREF="/XbaseSamples/testhtml.cpp">testhtml.cpp</A> for an example of how
<hr>
<h4>Method void xbHtml::HeaderOn( xbShort lvl )</h4><br>
This method prints the header on tag where lvl is a level 1 thru 6. </Hx> 
<h4>Example Program:</h4>
See program <A HREF="/XbaseSamples/testhtml.cpp">testhtml.cpp</A> for an example of how
to use this program.
<hr>
<h4>Method void xbHtml::HeaderOff( xbShort lvl )</h4><br>
This method prints the header off tag where lvl is a level 1 thru 6. </Hx> 
<h4>Example Program:</h4>
See program <A HREF="/XbaseSamples/testhtml.cpp">testhtml.cpp</A> for an example of how
to use this program.
<hr>
<h4>Method void xbHtml::ItalicOn( void )</h4><br>
This method prints the italic on tag.
<h4>Example Program:</h4>
See program <A HREF="/XbaseSamples/testhtml.cpp">testhtml.cpp</A> for an example of how
to use this program.
<hr>
<h4>Method void xbHtml::ItalicOff( void )</h4><br>
This method prints the italic off tag.
<h4>Example Program:</h4>
See program <A HREF="/XbaseSamples/testhtml.cpp">testhtml.cpp</A> for an example of how
to use this program.
<hr>
<h4>Method void xbHtml::Newline( void )</h4><br>
This method prints the newline tag.
<h4>Example Program:</h4>
See program <A HREF="/XbaseSamples/testhtml.cpp">testhtml.cpp</A> for an example of how
to use this program.
<hr>

<h4>Method void xbHtml::PrintEncodedChar( char )</h4><br>
This method prints an xbHtml encoded character.  For example, the '<' character 
is printed as '&amp lt'.  
<hr>

<h4>Method void xbHtml::PrintEncodedString( char * )</h4><br>
This method prints an xbHtml encoded string. For example, any '<' characters 
in the string are printed as '&amp lt'.  
<hr>

<h4>Method void xbHtml::Newline( void )</h4><br>
This method prints the newline tag.
<h4>Example Program:</h4>
See program <A HREF="/XbaseSamples/testhtml.cpp">testhtml.cpp</A> for an example of how
to use this program.
<hr>

<h4>Method void xbHtml::PlusToSpace( char * String )</h4><br>
This method is used for converting all + symbols to spaces in a given string.
This is useful for sending URLs with spaces in the data.<br> 

<h4>Sample Code:</h4>
<xmp>
xbHtml p;
char MyUrlString[40];
strcpy( MyUrlString, "program.cgi?PARM=My paramater information" );
p.SpaceToPlus( MyUrlString );    // eliminate the spaces
p.SendRedirect( MyUrlString );   // send it
p.PlusToSpace( MyUrlString );    // un-eliminate the spaces
</xmp><hr>


<h4>Method xbShort xbHtml::PostMethod( void )</h4><br>
This method returns true if a POST method was used.
<h4>Example Program:</h4>
See program <A HREF="/XbaseSamples/testhtml.cpp">testhtml.cpp</A> for an example of how
<hr>
<h4>Method void xbHtml::PrintHtml( char * x )<br>
    Method void xbHtml::PrintHtml( xbLong x )<br>
    Method void xbHtml::PrintHtml( xbShort x )<br>
</h4>
This method prints the data x on the page.
<h4>Example Program:</h4>
See program <A HREF="/XbaseSamples/testhtml.cpp">testhtml.cpp</A> for an example of how
to use this program.
<hr>


<h4>Method void xbHtml::SetCookie( char * Name, char * Value, char * ExpDate,
  char * ExpTime, char * TimeZone, char * Path, char * Domain, xbShort Secure );
</h4>
Some browsers support the Netscape cookie method for storing client side data
such as state information.  The cookie containing data is passed along in the
HTTP request-response dialog.  To send a cookie to a browser, you must send 
the cookie before any html data is sent.

<h4>Sample Usage:</H4>
xbXBase x;<br>
xbHtml p;<br>
char ExpireDate[15];<br><br>
strcpy( ExpireDateBuf, x.FormatDate( "DDD DD-MMM-YY", x.Sysdate()));<br>
p.SendCookie( "COOKIETEST", "Y", ExpireDate, 0, "CST" );<br><br>
If the SendCookie method doesn't work, you could optionally do this:<br>
cout << "Set-Cookie: COOKIETEST=Y; " << ExpireDateBuf << " CST" << endl;
<br>
<hr>
<h4>Method void xbHtml::SendRedirect( char * RedirectURL )</h4><br>
The output of a CGI program can be a redirect command.  The redirect command
is used to instruct the client to display the contents of the new URL instead
of loading the URL from the present location.
<br><H4>Example:</H4><br>
xbHtml h;<br>
h.SendRedirect( "http://www.startech.keller.tx.us" );<br><br>
<hr>

<h4>Method void xbHtml::SpaceToPlus( char * String )</h4><br>
This method is used for converting all spaces in a given string to + symbols.
This is useful for sending URLs with spaces in the data.<br> 

<h4>Sample Code:</h4>
<xmp>
xbHtml p;
char MyUrlString[40];
strcpy( MyUrlString, "program.cgi?PARM=My paramater information" );
p.SpaceToPlus( MyUrlString );    // eliminate the spaces
p.SendRedirect( MyUrlString );   // send it
p.PlusToSpace( MyUrlString );    // un-eliminate the spaces
</xmp><hr>

<h4>Method void xbHtml::StartHtmlPage( char * Title )</h4><br>
This method prints data necessary to begin an Html page:<br> 
Content-type: text/html\n\n<br><br>
and also sets the page title to <em>title</em>.
<h4>Example Program:</h4>
See program <A HREF="/XbaseSamples/testhtml.cpp">testhtml.cpp</A> for an example of how
to use this program.
<hr>
<h4>Method void xbHtml::StartTextPage( void )</h4><br>
This method prints data necessary to begin a Text page:<br> 
Content-type: text/plain\n\n<br><br>
<h4>Example Program:</h4>
See program <A HREF="/XbaseSamples/testhtml.cpp">testhtml.cpp</A> for an example of how
to use this program.
<hr>
<h4>Method xbLong xbHtml::Tally( char * Filename )</h4><br>
This method increments a counter stored in Filename and returns the new count.
The Web server needs write access to the directory where Filename is stored for
this routine to function.   This method will not create a file. It expects the
file to already exist. 
To initialize a file, create an ASCII file with the number 0 in it.  It is a
case sensitive routine.
<br><br>
This routine returns 0 if it fails, otherwise it returns the current tally
count for Filename.<br><br>
<h4>Example Program:</h4>
See program <A HREF="/XbaseSamples/testhtml.cpp">testhtml.cpp</A> for an example of how
to use this program.
<hr>
<A HREF="mailto:xbase@startech.keller.tx.us">
Send me mail - xbase@startech.keller.tx.us</A><br>
<p>(c)1997 StarTech
<p><img src="xbase.jpg"><br><hr>
</BODY>
</xbHtml>