source: trunk/gsdl/src/recpt/cgiwrapper.cpp@ 12485

Last change on this file since 12485 was 12400, checked in by kjdon, 18 years ago

cgicc stuff, we get the arguments form formData then put them back into a querystring so the rest of the code is still getting the same stuff. Had to add in an encode step so argument values remained encoded cgi_safe

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 22.0 KB
Line 
1/**********************************************************************
2 *
3 * cgiwrapper.cpp -- output pages using the cgi protocol
4 * Copyright (C) 1999 The New Zealand Digital Library Project
5 *
6 * A component of the Greenstone digital library software
7 * from the New Zealand Digital Library Project at the
8 * University of Waikato, New Zealand.
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 *
24 *********************************************************************/
25
26#include "gsdlconf.h"
27#include "cgiwrapper.h"
28#include "cgiutils.h"
29#include "recptconfig.h"
30#include "fileutil.h"
31#include <stdlib.h>
32#include <assert.h>
33
34#if defined(GSDL_USE_OBJECTSPACE)
35# include <ospace/std/iostream>
36# include <ospace/std/fstream>
37#elif defined(GSDL_USE_IOS_H)
38# include <iostream.h>
39# include <fstream.h>
40#else
41# include <iostream>
42# include <fstream>
43#endif
44
45#include "cgicc/Cgicc.h"
46
47using namespace cgicc;
48extern Cgicc* formData;
49
50
51#ifdef USE_FASTCGI
52#include "fcgiapp.h"
53#endif
54
55
56#ifdef USE_FASTCGI
57// used to output the text from receptionist
58class fcgistreambuf : public streambuf {
59public:
60 fcgistreambuf ();
61 int sync ();
62 int overflow (int ch);
63 int underflow () {return EOF;}
64
65 void fcgisbreset() {fcgx_stream = NULL; other_ostream = NULL;};
66 void set_fcgx_stream(FCGX_Stream *newone) {fcgx_stream=newone;};
67 void set_other_ostream(ostream *newone) {other_ostream=newone;};
68
69private:
70 FCGX_Stream *fcgx_stream;
71 ostream *other_ostream;
72};
73
74fcgistreambuf::fcgistreambuf() {
75 fcgisbreset();
76 if (base() == ebuf()) allocate();
77 setp (base(), ebuf());
78};
79
80int fcgistreambuf::sync () {
81 if ((fcgx_stream != NULL) &&
82 (FCGX_PutStr (pbase(), out_waiting(), fcgx_stream) < 0)) {
83 fcgx_stream = NULL;
84 }
85
86 if (other_ostream != NULL) {
87 char *thepbase=pbase();
88 for (int i=0;i<out_waiting();++i) (*other_ostream).put(thepbase[i]);
89 }
90
91 setp (pbase(), epptr());
92
93 return 0;
94}
95
96int fcgistreambuf::overflow (int ch) {
97 if (sync () == EOF) return EOF;
98 if (ch != EOF) sputc (ch);
99 return 0;
100}
101
102#endif
103
104static void format_error_string (text_t &errorpage, const text_t &errortext, bool debug) {
105
106 errorpage.clear();
107
108 if (debug) {
109 errorpage += "\n";
110 errorpage += "ERROR: " + errortext;
111 errorpage += "\n";
112
113 } else {
114
115 errorpage += "Content-type: text/html\n\n";
116
117 errorpage += "<html>\n";
118 errorpage += "<head>\n";
119 errorpage += "<title>Error</title>\n";
120 errorpage += "</head>\n";
121 errorpage += "<body>\n";
122 errorpage += "<h2>Oops!</h2>\n";
123 errorpage += errortext;
124 errorpage += "</body>\n";
125 errorpage += "</html>\n";
126 }
127}
128
129static void page_errorcollect (const text_t &gsdlhome, text_t &errorpage, bool debug) {
130
131 text_t collectdir = filename_cat (gsdlhome, "collect");
132
133 text_t errortext = "No valid collections were found: Check that your collect directory\n";
134 errortext += "(" + collectdir + ") is readable and contains at least one valid collection.\n";
135 errortext += "Note that modelcol is NOT a valid collection.\n";
136 errortext += "If the path to your collect directory is wrong edit the 'gsdlhome' field\n";
137 errortext += "in your gsdlsite.cfg configuration file.\n";
138
139 format_error_string (errorpage, errortext, debug);
140}
141
142static void page_errorsitecfg (text_t &errorpage, bool debug, int mode) {
143
144 text_t errortext;
145
146 if (mode == 0) {
147 errortext += "The gsdlsite.cfg configuration file could not be found. This\n";
148 errortext += "file should contain configuration information relating to this\n";
149 errortext += "site's setup.\n";
150
151 } else if (mode == 1) {
152 errortext += "The gsdlsite.cfg configuration file does not contain a valid\n";
153 errortext += "gsdlhome entry.\n";
154 }
155
156 if (debug) {
157 errortext += "gsdlsite.cfg should reside in the directory from which the\n";
158 errortext += "library executable was run.\n";
159 } else {
160 errortext += "gsdlsite.cfg should reside in the same directory as the library\n";
161 errortext += "executable file.\n";
162 }
163
164 format_error_string (errorpage, errortext, debug);
165}
166
167
168static void page_errormaincfg (const text_t &gsdlhome, const text_t &collection,
169 bool debug, text_t &errorpage) {
170
171 text_t errortext;
172
173 if (collection.empty()) {
174 text_t main_cfg_file = filename_cat (gsdlhome, "etc", "main.cfg");
175 errortext += "The main.cfg configuration file could not be found. This file\n";
176 errortext += "should contain configuration information relating to the\n";
177 errortext += "setup of the interface. As this receptionist is not being run\n";
178 errortext += "in collection specific mode the file should reside at\n";
179 errortext += main_cfg_file + ".\n";
180 } else {
181 text_t collect_cfg_file = filename_cat (gsdlhome, "collect", collection, "etc", "collect.cfg");
182 text_t main_collect_cfg_file = filename_cat (gsdlhome, "etc", "collect.cfg");
183 text_t main_cfg_file = filename_cat (gsdlhome, "etc", "main.cfg");
184 errortext += "Either the collect.cfg or main.cfg configuration file could\n";
185 errortext += "not be found. This file should contain configuration information\n";
186 errortext += "relating to the setup of the interface. As this receptionist is\n";
187 errortext += "being run in collection specific mode the file should reside\n";
188 errortext += "at either " + collect_cfg_file + ",\n";
189 errortext += main_collect_cfg_file + " or " + main_cfg_file + ".\n";
190 }
191
192 format_error_string (errorpage, errortext, debug);
193}
194
195
196static void page_errorinit (const text_t &gsdlhome, bool debug, text_t &errorpage) {
197
198 text_t errortext = "An error occurred during the initialisation of the Greenstone Digital\n";
199 errortext += "Library software. It is likely that the software has not been setup\n";
200 errortext += "correctly.\n";
201
202 text_t error_file = filename_cat (gsdlhome, "etc", "error.txt");
203 char *efile = error_file.getcstr();
204 ifstream errin (efile);
205 delete []efile;
206 if (errin) {
207 errortext += "The error log, " + error_file + ", contains the\n";
208 errortext += "following information:\n\n";
209 if (!debug) errortext += "<pre>\n";
210
211 char c;
212 errin.get(c);
213 while (!errin.eof ()) {
214 errortext.push_back(c);
215 errin.get(c);
216 }
217
218 if (!debug) errortext += "</pre>\n";
219
220 errin.close();
221
222 } else {
223 errortext += "Please consult " + error_file + " for more information.\n";
224 }
225
226 format_error_string (errorpage, errortext, debug);
227}
228
229static void page_errorparseargs (const text_t &gsdlhome, bool debug, text_t &errorpage) {
230
231 text_t errortext = "An error occurred during the parsing of the cgi arguments.\n";
232
233 text_t error_file = filename_cat (gsdlhome, "etc", "error.txt");
234 char *efile = error_file.getcstr();
235 ifstream errin (efile);
236 delete []efile;
237 if (errin) {
238 errortext += "The error log, " + error_file + ", contains the\n";
239 errortext += "following information:\n\n";
240 if (!debug) errortext += "<pre>\n";
241
242 char c;
243 errin.get(c);
244 while (!errin.eof ()) {
245 errortext.push_back(c);
246 errin.get(c);
247 }
248 if (!debug) errortext += "</pre>\n";
249 errin.close();
250
251 } else {
252 errortext += "Please consult " + error_file + " for more information.\n";
253 }
254
255 format_error_string (errorpage, errortext, debug);
256}
257
258static void page_errorcgipage (const text_t &gsdlhome, bool debug, text_t &errorpage) {
259
260 text_t errortext = "An error occurred during the construction of the cgi page.\n";
261
262 text_t error_file = filename_cat (gsdlhome, "etc", "error.txt");
263 char *efile = error_file.getcstr();
264 ifstream errin (efile);
265 delete []efile;
266 if (errin) {
267 errortext += "The error log, " + error_file + ", contains the\n";
268 errortext += "following information:\n\n";
269 if (!debug) errortext += "<pre>\n";
270
271 char c;
272 errin.get(c);
273 while (!errin.eof ()) {
274 errortext.push_back(c);
275 errin.get(c);
276 }
277 if (!debug) errortext += "</pre>\n";
278 errin.close();
279
280 } else {
281 errortext += "Please consult " + error_file + " for more information.\n";
282 }
283
284 format_error_string (errorpage, errortext, debug);
285}
286
287static void print_debug_info (receptionist &recpt) {
288
289 outconvertclass text_t2ascii;
290 const recptconf &configinfo = recpt.get_configinfo ();
291 text_t etc_dir = filename_cat (configinfo.gsdlhome, "etc");
292
293 cout << "\n";
294 cout << text_t2ascii
295 << "------------------------------------------------------------\n"
296 << "Configuration and initialization completed successfully.\n"
297 << " Note that more debug information may be available in the\n"
298 << " initialization and error log error.txt in " << etc_dir << ".\n"
299 << "------------------------------------------------------------\n\n";
300
301 bool colspec = false;
302 if (configinfo.collection.empty()) {
303 cout << "Receptionist is running in \"general\" (i.e. not \"collection\n"
304 << "specific\") mode.\n";
305 } else {
306 cout << text_t2ascii
307 << "Receptionist is running in \"collection specific\" mode.\n"
308 << " collection=" << configinfo.collection << "\n"
309 << " collection directory=" << configinfo.collectdir << "\n";
310 colspec = true;
311 }
312
313 cout << text_t2ascii << "gsdlhome=" << configinfo.gsdlhome << "\n";
314 if (!configinfo.gdbmhome.empty())
315 cout << text_t2ascii << "gdbmhome=" << configinfo.gdbmhome << "\n";
316 cout << text_t2ascii << "httpprefix=" << configinfo.httpprefix << "\n";
317 cout << text_t2ascii << "httpimg=" << configinfo.httpimg << "\n";
318 cout << text_t2ascii << "gwcgi=" << configinfo.gwcgi << "\n"
319 << " Note that unless gwcgi has been set from a configuration\n"
320 << " file it is dependent on environment variables set by your\n"
321 << " webserver. Therefore it may not have the same value when run\n"
322 << " from the command line as it would be when run from your\n"
323 << " web server.\n";
324 if (configinfo.usecookies)
325 cout << "cookies are enabled\n";
326 else
327 cout << "cookies are disabled\n";
328 if (configinfo.logcgiargs)
329 cout << "logging is enabled\n";
330 else
331 cout << "logging is disabled\n";
332 cout << "------------------------------------------------------------\n\n";
333
334 text_tset::const_iterator this_mfile = configinfo.macrofiles.begin();
335 text_tset::const_iterator end_mfile = configinfo.macrofiles.end();
336 cout << "Macro Files:\n"
337 << "------------\n";
338 text_t mfile;
339 bool found;
340 while (this_mfile != end_mfile) {
341 cout << text_t2ascii << *this_mfile;
342 int spaces = (22 - (*this_mfile).size());
343 if (spaces < 2) spaces = 2;
344 text_t outspaces;
345 for (int i = 0; i < spaces; ++i) outspaces.push_back (' ');
346 cout << text_t2ascii << outspaces;
347
348 found = false;
349 if (colspec) {
350 // collection specific - try collectdir/macros first
351 mfile = filename_cat (configinfo.collectdir, "macros", *this_mfile);
352 if (file_exists (mfile)) {
353 cout << text_t2ascii << "found (" << mfile << ")\n";
354 found = true;
355 }
356 }
357
358 if (!found) {
359 // try main macro directory
360 mfile = filename_cat (configinfo.gsdlhome, "macros", *this_mfile);
361 if (file_exists (mfile)) {
362 cout << text_t2ascii << "found (" << mfile << ")\n";
363 found = true;
364 }
365 }
366
367 if (!found)
368 cout << text_t2ascii << "NOT FOUND\n";
369
370 ++this_mfile;
371 }
372
373 cout << "------------------------------------------------------------\n\n"
374 << "Collections:\n"
375 << "------------\n"
376 << " Note that collections will only appear as \"running\" if\n"
377 << " their build.cfg files exist, are readable, contain a valid\n"
378 << " builddate field (i.e. > 0), and are in the collection's\n"
379 << " index directory (i.e. NOT the building directory)\n\n";
380
381 recptprotolistclass *protos = recpt.get_recptprotolist_ptr();
382 recptprotolistclass::iterator rprotolist_here = protos->begin();
383 recptprotolistclass::iterator rprotolist_end = protos->end();
384
385 bool is_z3950 = false;
386 bool found_valid_col = false;
387
388
389 while (rprotolist_here != rprotolist_end) {
390 comerror_t err;
391 if ((*rprotolist_here).p == NULL) continue;
392 else if (is_z3950==false &&
393 (*rprotolist_here).p->get_protocol_name(err) == "z3950proto") {
394 cout << "\nZ39.50 Servers: (always public)\n"
395 << "---------------\n";
396 is_z3950=true;
397 }
398
399 text_tarray collist;
400 (*rprotolist_here).p->get_collection_list (collist, err, cerr);
401 if (err == noError) {
402 text_tarray::iterator collist_here = collist.begin();
403 text_tarray::iterator collist_end = collist.end();
404
405 while (collist_here != collist_end) {
406
407 cout << text_t2ascii << *collist_here;
408
409 int spaces = (22 - (*collist_here).size());
410 if (spaces < 2) spaces = 2;
411 text_t outspaces;
412 for (int i = 0; i < spaces; ++i) outspaces.push_back (' ');
413 cout << text_t2ascii << outspaces;
414
415 ColInfoResponse_t *cinfo = recpt.get_collectinfo_ptr ((*rprotolist_here).p, *collist_here, cerr);
416 if (cinfo != NULL) {
417 if (cinfo->isPublic) cout << "public ";
418 else cout << "private";
419
420 if (cinfo->buildDate > 0) {
421 cout << " running ";
422 found_valid_col = true;
423 } else {
424 cout << " not running";
425 }
426 }
427
428 cout << "\n";
429
430 ++collist_here;
431 }
432 }
433 is_z3950=false;
434 ++rprotolist_here;
435 } // end of while loop
436
437 if (!found_valid_col) {
438 cout << "WARNING: No \"running\" collections were found. You need to\n";
439 cout << " build one of the above collections\n";
440 }
441
442 cout << "\n------------------------------------------------------------\n";
443 cout << "------------------------------------------------------------\n\n";
444 cout << "receptionist running in command line debug mode\n";
445 cout << "enter cgi arguments as name=value pairs (e.g. 'a=p&p=home'):\n";
446
447}
448
449// cgiwrapper does everything necessary to output a page
450// using the cgi protocol. If this is being run for a particular
451// collection then "collection" should be set, otherwise it
452// should equal "".
453void cgiwrapper (receptionist &recpt, text_t collection) {
454
455 int numrequests = 0;
456 bool debug = false;
457 const recptconf &configinfo = recpt.get_configinfo ();
458
459 // find out whether this is being run as a cgi-script
460 // or a fastcgi script
461#ifdef USE_FASTCGI
462 fcgistreambuf outbuf;
463 int isfastcgi = !FCGX_IsCGI();
464 FCGX_Stream *fcgiin, *fcgiout, *fcgierr;
465 FCGX_ParamArray fcgienvp;
466#else
467 int isfastcgi = 0;
468#endif
469
470 // get the query string if it is not being run as a fastcgi
471 // script
472 text_t argstr = g_EmptyText;
473 cgiargsclass args;
474 char *aURIStr;
475 if (!isfastcgi) {
476
477 // Iterate through the vector, and synthesis argstr
478 bool first = true;
479
480 for(const_form_iterator iter = formData->getElements().begin();
481 iter != formData->getElements().end();
482 ++iter) {
483
484 const char* name_cstr = iter->getName().c_str();
485 const char* value_cstr = iter->getValue().c_str();
486 // the args have been decoded and as we are building up the argument
487 // string again, we need to re encode them
488 text_t value_textt = cgi_safe(value_cstr);
489 const char * safe_value_cstr = value_textt.getcstr();
490 if (first) {
491 argstr = name_cstr;
492 argstr.append("=");
493 argstr.append(safe_value_cstr);
494 first = false;
495 }
496 else {
497 argstr.append("&");
498 argstr.append(name_cstr);
499 argstr.append("=");
500 argstr.append(safe_value_cstr);
501 }
502 delete [] safe_value_cstr;
503 }
504 }
505
506 if (debug) {
507 cout << "Configuring Greenstone...\n";
508 cout << flush;
509 }
510
511 // init stuff - we can't output error pages directly with
512 // fastcgi so the pages are stored until we can output them
513 text_t errorpage;
514 outconvertclass text_t2ascii;
515
516 // set defaults
517 int maxrequests = 10000;
518 recpt.configure ("collection", collection);
519 recpt.configure ("httpimg", "/gsdl/images");
520 char *script_name = getenv("SCRIPT_NAME");
521 if (script_name != NULL) recpt.configure("gwcgi", script_name);
522 else recpt.configure("gwcgi", "/gsdl");
523
524 // read in the configuration files.
525 text_t gsdlhome;
526 if (!site_cfg_read (recpt, gsdlhome, maxrequests)) {
527 // couldn't find the site configuration file
528 page_errorsitecfg (errorpage, debug, 0);
529 } else if (gsdlhome.empty()) {
530 // no gsdlhome in gsdlsite.cfg
531 page_errorsitecfg (errorpage, debug, 1);
532 } else if (!directory_exists(gsdlhome)) {
533 // gsdlhome not a valid directory
534 page_errorsitecfg (errorpage, debug, 1);
535 } else if (!main_cfg_read (recpt, gsdlhome, collection)) {
536 // couldn't find the main configuration file
537 page_errormaincfg (gsdlhome, collection, debug, errorpage);
538 } else if (configinfo.collectinfo.empty() && false) { // commented out for corba
539 // don't have any collections
540 page_errorcollect (gsdlhome, errorpage, debug);
541 }
542
543 if (errorpage.empty()) {
544
545 // initialise the library software
546 if (debug) {
547 cout << "Initializing...\n";
548 cout << flush;
549 }
550
551 text_t error_file = filename_cat (gsdlhome, "etc", "error.txt");
552 char *eout = error_file.getcstr();
553 ofstream errout (eout, ios::app);
554 delete []eout;
555 if (!recpt.init(errout)) {
556 // an error occurred during the initialisation
557 errout.close();
558 page_errorinit(gsdlhome, debug, errorpage);
559 }
560 errout.close();
561 }
562
563 if (debug && errorpage.empty()) {
564 // get query string from command line
565 print_debug_info (recpt);
566 char cinURIStr[1024];
567 cin.get(cinURIStr, 1024);
568 argstr = cinURIStr;
569 }
570
571 // cgi scripts only deal with one request
572 if (!isfastcgi) maxrequests = 1;
573
574 // Page-request loop. If this is not being run as a fastcgi
575 // process then only one request will be processed and then
576 // the process will exit.
577 while (numrequests < maxrequests) {
578#ifdef USE_FASTCGI
579 if (isfastcgi) {
580 if (FCGX_Accept(&fcgiin, &fcgiout, &fcgierr, &fcgienvp) < 0) break;
581
582 char *request_method_str = FCGX_GetParam ("REQUEST_METHOD", fcgienvp);
583 char *content_length_str = FCGX_GetParam ("CONTENT_LENGTH", fcgienvp);
584
585 if (request_method_str != NULL && strcmp(request_method_str, "POST") == 0 &&
586 content_length_str != NULL) {
587 // POST form data
588 int content_length = text_t(content_length_str).getint();
589 if (content_length > 0) {
590 argstr.clear();
591 int c;
592 do {
593 c = FCGX_GetChar (fcgiin);
594 if (c < 0) break;
595 argstr.push_back (c);
596 --content_length;
597 } while (content_length > 0);
598 }
599
600 } else {
601 // GET form data
602 aURIStr = FCGX_GetParam("QUERY_STRING", fcgienvp);
603 if (aURIStr != NULL) argstr = aURIStr;
604 else argstr = g_EmptyText;
605 }
606 }
607#endif
608
609 // get output streams ready
610#ifdef USE_FASTCGI
611 outbuf.fcgisbreset ();
612 if (isfastcgi) outbuf.set_fcgx_stream (fcgiout);
613 else outbuf.set_other_ostream (&cout);
614 ostream pageout (&outbuf);
615#else
616#define pageout cout
617#endif
618
619 // if using fastcgi we'll load environment into a map,
620 // otherwise simply pass empty map (can't get environment
621 // variables using getenv() while using FCGX versions
622 // of fastcgi - at least I can't ;-) - Stefan)
623 text_tmap fastcgienv;
624#ifdef USE_FASTCGI
625 if (isfastcgi) {
626 for(; *fcgienvp != NULL; ++fcgienvp) {
627 text_t fvalue = *fcgienvp;
628 text_t::const_iterator begin = fvalue.begin();
629 text_t::const_iterator end = fvalue.end();
630 text_t::const_iterator equals_sign = findchar (begin, end, '=');
631 if (equals_sign != end)
632 fastcgienv[substr(begin, equals_sign)] = substr(equals_sign+1, end);
633 }
634 }
635#endif
636
637 // temporarily need to configure gwcgi here when using fastcgi as I can't
638 // get it to pass the SCRIPT_NAME environment variable to the initial
639 // environment (if anyone can work out how to do this using the apache
640 // server, let me know). Note that this overrides the gwcgi field in
641 // site.cfg (which it shouldn't do) but I can't at present set gwcgi
642 // from site.cfg as I have old receptionists laying around that wouldn't
643 // appreciate it. The following 5 lines of code should be deleted once
644 // I either a: get the server to pass SCRIPT_NAME at initialization
645 // time or b: convert all the collections using old receptionists over
646 // to this version and uncomment gwcgi in the site.cfg file -- Stefan.
647#ifdef USE_FASTCGI
648 if (isfastcgi) {
649 recpt.configure("gwcgi", fastcgienv["SCRIPT_NAME"]);
650 }
651#endif
652
653
654 // if there has been no error so far, perform the production of the
655 // output page
656 if (errorpage.empty()) {
657 text_t error_file = filename_cat (gsdlhome, "etc", "error.txt");
658 char *eout = error_file.getcstr();
659 ofstream errout (eout, ios::app);
660 delete []eout;
661
662#if defined(__WIN32__) && defined(GSDL_USE_IOS_H)
663 // old Windows compilers (VC++4.2)
664 cerr = errout;
665#else
666 // can't do this anymore according to c++ standard...
667 // cerr = errout;
668 // ... but can do this instead
669 streambuf* errbuf = cerr.rdbuf(errout.rdbuf());
670#endif
671
672 // parse the cgi arguments and produce the resulting page if there
673 // has been no errors so far
674 if (!recpt.parse_cgi_args (argstr, args, errout, fastcgienv)) {
675 errout.close ();
676 page_errorparseargs(gsdlhome, debug, errorpage);
677 } else {
678 // produce the output page
679
680 if (!recpt.produce_cgi_page (args, pageout, errout, fastcgienv)) {
681 errout.close ();
682 page_errorcgipage(gsdlhome, debug, errorpage);
683 }
684 recpt.log_cgi_args (args, errout, fastcgienv);
685 errout.close ();
686 }
687
688#if !defined(__WIN32__) || !defined(GSDL_USE_IOS_H)
689 // restore the cerr buffer
690 cerr.rdbuf(errbuf);
691#endif
692 }
693
694 // there was an error, output the error page
695 if (!errorpage.empty()) {
696 pageout << text_t2ascii << errorpage;
697 errorpage.clear();
698 numrequests = maxrequests; // make this the last page
699 }
700 pageout << flush;
701
702 // finish with the output streams
703#ifdef USE_FASTCGI
704 if (isfastcgi) FCGX_Finish();
705#endif
706
707 ++numrequests;
708 }
709
710 return;
711}
Note: See TracBrowser for help on using the repository browser.