File: xbase_c19.html

package info (click to toggle)
xdb 1.2.0-7.2
  • links: PTS
  • area: main
  • in suites: lenny, squeeze, wheezy
  • size: 1,688 kB
  • ctags: 1,053
  • sloc: cpp: 14,001; sh: 6,711; makefile: 150
file content (380 lines) | stat: -rw-r--r-- 15,159 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
<!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>