1 | /**********************************************************************
|
---|
2 | *
|
---|
3 | * pingaction.cpp --
|
---|
4 | * Copyright (C) 1999 The New Zealand Digital Library Project
|
---|
5 | *
|
---|
6 | * PUT COPYRIGHT NOTICE HERE
|
---|
7 | *
|
---|
8 | * $Id: pingaction.cpp 172 1999-02-25 21:59:02Z rjmcnab $
|
---|
9 | *
|
---|
10 | *********************************************************************/
|
---|
11 |
|
---|
12 | /*
|
---|
13 | $Log$
|
---|
14 | Revision 1.2 1999/02/25 21:58:59 rjmcnab
|
---|
15 |
|
---|
16 | Merged sources.
|
---|
17 |
|
---|
18 | Revision 1.1 1999/02/21 22:35:20 rjmcnab
|
---|
19 |
|
---|
20 | Initial revision.
|
---|
21 |
|
---|
22 | */
|
---|
23 |
|
---|
24 |
|
---|
25 | #include "pingaction.h"
|
---|
26 |
|
---|
27 | pingaction::pingaction () {
|
---|
28 | // this action uses cgi variable "a"
|
---|
29 | cgiarginfo arg_ainfo;
|
---|
30 | arg_ainfo.shortname = "a";
|
---|
31 | arg_ainfo.longname = "action";
|
---|
32 | arg_ainfo.multiplechar = true;
|
---|
33 | arg_ainfo.defaultstatus = cgiarginfo::weak;
|
---|
34 | arg_ainfo.argdefault = "ping";
|
---|
35 | arg_ainfo.savedarginfo = cgiarginfo::must;
|
---|
36 |
|
---|
37 | argsinfo.addarginfo (NULL, arg_ainfo);
|
---|
38 |
|
---|
39 | }
|
---|
40 |
|
---|
41 | void pingaction::get_cgihead_info (cgiargsclass &/*args*/, response_t &response,
|
---|
42 | text_t &response_data, ostream &/*logout*/) {
|
---|
43 | response = content;
|
---|
44 | response_data = "text/html";
|
---|
45 | }
|
---|
46 |
|
---|
47 |
|
---|
48 | bool pingaction::do_action (cgiargsclass &args, recptproto *collectproto,
|
---|
49 | displayclass &/*disp*/, outconvertclass &outconvert,
|
---|
50 | ostream &textout, ostream &logout) {
|
---|
51 | bool wassuccess = false;
|
---|
52 | comerror_t err;
|
---|
53 |
|
---|
54 | if (!args["c"].empty() && (collectproto != NULL)) {
|
---|
55 | collectproto->ping (args["c"], wassuccess, err, logout);
|
---|
56 | if (err != noError) wassuccess = false; // a communication error
|
---|
57 | }
|
---|
58 |
|
---|
59 | textout << outconvert
|
---|
60 | << "<html>\n"
|
---|
61 | << "<head>\n"
|
---|
62 | << "<title>Ping</title>\n"
|
---|
63 | << "</head>\n"
|
---|
64 | << "<body>\n"
|
---|
65 | << "Ping for \"" << args["c"] << "\" ";
|
---|
66 |
|
---|
67 | if (wassuccess) {
|
---|
68 | textout << outconvert << " succeeded.\n";
|
---|
69 | } else {
|
---|
70 | textout << outconvert << " did not succeed.\n";
|
---|
71 | }
|
---|
72 |
|
---|
73 | textout << outconvert
|
---|
74 | << "</body>\n"
|
---|
75 | << "</html>\n";
|
---|
76 |
|
---|
77 | return true;
|
---|
78 | };
|
---|