libepp_nicbr
PollFunctions.H
Go to the documentation of this file.
1 /* ${copyright}$ */
2 /* $Id: PollFunctions.H 1086 2010-12-10 13:07:28Z eduardo $ */
6 #ifndef __POLL_FUNCTIONS_H__
7 #define __POLL_FUNCTIONS_H__
9 
10 #include "Poll.H"
11 
13 
18 int cmd_poll_help(string error_msg)
19 {
20  if (error_msg != "") {
21  printf("error: %s\n", error_msg.c_str());
22  }
23 
24  printf("poll command syntax help:\n");
25  printf("\n");
26 
27  printf(" req\n");
28  printf("\n");
29  printf(" ack <msgID>\n");
30  printf("\n");
31 
32  if (error_msg != "") {
33  return -1;
34  }
35 
36  return 0;
37 }
38 
40 
44 int cmd_poll(vector<string> &args)
45 {
46  Poll act;
47  PollCmd *cmd = act.get_command();
48 
49  // poll command processing
50  if (!args.empty() && !(args[0] == "help")) {
51  if (args[0] == "req" || args[0] == "ack") {
52  cmd->set_op(args[0]);
53  args.erase(args.begin());
54 
55  if (cmd->get_op() == "req") {
56  if (!args.empty()) {
57  return cmd_poll_help("too many arguments");
58  }
59  } else { //cmd->get_op() == "ack"
60  if (args.empty()) {
61  return cmd_poll_help("unspecified msgID");
62  } else if (args.size() > 1) {
63  return cmd_poll_help("too many arguments");
64  }
65  cmd->set_msgID(args[0]);
66  }
67 
68  if (_debug) {
69  printf("poll op: [%s]\n", cmd->get_op().c_str());
70 
71  if (cmd->get_msgID() != "") {
72  printf(" msgID: [%s]\n", cmd->get_msgID().c_str());
73  }
74  } //_debug
75 
76  if (process_action(act) != 0) {
77  return -1;
78  }
79 
80  return 0;
81  } else {
82  return cmd_poll_help("invalid command: poll " + args[0]);
83  }
84  }
85 
86  return cmd_poll_help("");
87 }
88 
89 #endif //__POLL_FUNCTIONS_H__
EPP PollCmd Class.
Definition: PollCmd.H:21
string get_msgID() const
Returns the msgID of the message.
Definition: PollCmd.H:54
PollCmd * get_command()
Returns raw pointer to the command.
Definition: Poll.H:57
EPP Poll Class.
string get_op() const
Returns the operation of the poll command.
Definition: PollCmd.H:48
void set_op(const string &op)
Sets the operation of the poll command ("req" or "ack")
Definition: PollCmd.H:36
int cmd_poll_help(string error_msg)
print poll command usage info
Definition: PollFunctions.H:18
int process_action(Action &act)
Send and EPP Action.
Definition: SheppCommandFunctions.H:871
int cmd_poll(vector< string > &args)
main poll command
Definition: PollFunctions.H:44
void set_msgID(const string &msgID)
Sets the msgID of the message being acknowledged.
Definition: PollCmd.H:42
EPP Poll Class.
Definition: Poll.H:23
EPP command-line shell client command functions include file.