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

Last change on this file since 1233 was 1170, checked in by sjboddie, 24 years ago

minor modifications to get web library compiling under VC++ 6.0

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