source: trunk/gsdl/src/recpt/pingaction.cpp@ 533

Last change on this file since 533 was 533, checked in by sjboddie, 25 years ago

added GPL notice

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 2.8 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 * $Id: pingaction.cpp 533 1999-09-07 04:57:01Z sjboddie $
25 *
26 *********************************************************************/
27
28/*
29 $Log$
30 Revision 1.4 1999/09/07 04:56:57 sjboddie
31 added GPL notice
32
33 Revision 1.3 1999/07/30 02:24:45 sjboddie
34 added collectinfo argument to some functions
35
36 Revision 1.2 1999/02/25 21:58:59 rjmcnab
37
38 Merged sources.
39
40 Revision 1.1 1999/02/21 22:35:20 rjmcnab
41
42 Initial revision.
43
44 */
45
46
47#include "pingaction.h"
48
49pingaction::pingaction () {
50 // this action uses cgi variable "a"
51 cgiarginfo arg_ainfo;
52 arg_ainfo.shortname = "a";
53 arg_ainfo.longname = "action";
54 arg_ainfo.multiplechar = true;
55 arg_ainfo.defaultstatus = cgiarginfo::weak;
56 arg_ainfo.argdefault = "ping";
57 arg_ainfo.savedarginfo = cgiarginfo::must;
58
59 argsinfo.addarginfo (NULL, arg_ainfo);
60
61}
62
63void pingaction::get_cgihead_info (cgiargsclass &/*args*/, response_t &response,
64 text_t &response_data, ostream &/*logout*/) {
65 response = content;
66 response_data = "text/html";
67}
68
69
70bool pingaction::do_action (cgiargsclass &args, const ColInfoResponse_t &/*collectinfo*/,
71 recptproto *collectproto, displayclass &/*disp*/,
72 outconvertclass &outconvert, ostream &textout,
73 ostream &logout) {
74 bool wassuccess = false;
75 comerror_t err;
76
77 if (!args["c"].empty() && (collectproto != NULL)) {
78 collectproto->ping (args["c"], wassuccess, err, logout);
79 if (err != noError) wassuccess = false; // a communication error
80 }
81
82 textout << outconvert
83 << "<html>\n"
84 << "<head>\n"
85 << "<title>Ping</title>\n"
86 << "</head>\n"
87 << "<body>\n"
88 << "Ping for \"" << args["c"] << "\" ";
89
90 if (wassuccess) {
91 textout << outconvert << " succeeded.\n";
92 } else {
93 textout << outconvert << " did not succeed.\n";
94 }
95
96 textout << outconvert
97 << "</body>\n"
98 << "</html>\n";
99
100 return true;
101};
Note: See TracBrowser for help on using the repository browser.