source: main/trunk/greenstone2/runtime-src/src/recpt/pingaction.cpp@ 22984

Last change on this file since 22984 was 22984, checked in by ak19, 14 years ago
  1. Undoing commit of 22934 where decode_commas was called on stem and fold comma separated list: previously separated due to url-encoding of commas. Now that the problem has been fixed at the source, the decode_commas hack is no longer necessary. 2. Commas in stem and fold are no longer url-encoded because the multiple_value field of the continuously-reused struct arg_ainfo is always set back to the default false after ever being set to true. So it no longer subtly stays at true to affect Greenstone functioning in unforeseen ways (such as suddenly and unnecessarily URL-encoding commas where this is not wanted).
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 2.7 KB
Line 
1/**********************************************************************
2 *
3 * pingaction.cpp --
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 "gsdl_modules_cfg.h"
27#ifdef GSDL_USE_PING_ACTION
28
29#include "pingaction.h"
30
31pingaction::pingaction () {
32 // this action uses cgi variable "a"
33 cgiarginfo arg_ainfo;
34 arg_ainfo.shortname = "a";
35 arg_ainfo.longname = "action";
36 arg_ainfo.multiplechar = true;
37 arg_ainfo.multiplevalue = false;
38 arg_ainfo.defaultstatus = cgiarginfo::weak;
39 arg_ainfo.argdefault = "ping";
40 arg_ainfo.savedarginfo = cgiarginfo::must;
41
42 argsinfo.addarginfo (NULL, arg_ainfo);
43
44}
45
46void pingaction::get_cgihead_info (cgiargsclass &/*args*/, recptprotolistclass * /*protos*/,
47 response_t &response, text_t &response_data,
48 ostream &/*logout*/) {
49 response = content;
50 response_data = "text/html";
51}
52
53
54bool pingaction::do_action (cgiargsclass &args, recptprotolistclass *protos,
55 browsermapclass * /*browsers*/, displayclass &/*disp*/,
56 outconvertclass &outconvert, ostream &textout,
57 ostream &logout) {
58 bool wassuccess = false;
59 comerror_t err;
60
61 recptproto *collectproto = protos->getrecptproto (args["c"], logout);
62 if (!args["c"].empty() && (collectproto != NULL)) {
63 collectproto->ping (args["c"], wassuccess, err, logout);
64 if (err != noError) wassuccess = false; // a communication error
65 }
66
67 textout << outconvert
68 << "<html>\n"
69 << "<head>\n"
70 << "<title>Ping</title>\n"
71 << "</head>\n"
72 << "<body>\n"
73 << "Ping for \"" << args["c"] << "\" ";
74
75 if (wassuccess) {
76 textout << outconvert << " succeeded.\n";
77 } else {
78 textout << outconvert << " did not succeed.\n";
79 }
80
81 textout << outconvert
82 << "</body>\n"
83 << "</html>\n";
84
85 return true;
86};
87
88#endif //GSDL_USE_PING_ACTION
Note: See TracBrowser for help on using the repository browser.