1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131
|
/* lsendcommand.cpp ************************************************/
/*
* This file is subject to the terms and conditions of the GNU General Public
* License. See the file COPYING in the main directory of this archive for
* more details.
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <lineak/lineak_core_functions.h>
#include <lineak/lineak_util_functions.h>
#include <lineak/lobject.h>
#include <lineak/lkey.h>
#include <lineak/msgpasser.h>
#include <vector>
#include <iostream>
#include <string>
#include <stdlib.h>
#if __GNUC__ >= 3
#include <ostream>
#include <iostream>
#include <sstream>
#else
#include <ostream.h>
#include <iostream.h>
#include <sstream.h>
#endif
using namespace std;
using namespace lineak_core_functions;
using namespace lineak_util_functions;
int main(int argc, char **argv)
{
if (argc < 2)
return 1;
char *arg1 = argv[1];
char *arg2;
string type = arg1;
string argument = "";
if (argc > 2) {
argument = string(argv[2]);
}
//cout << "type = " << type << endl;
//cout << "argument = " << argument << endl;
eak_msg msg;
msgPasser myMsg;
myMsg.start();
if ( type == "RECIEVE_KEY" ) {
msg.msg_type = msgPasser::GETDATA;
msg.directive.data_type=LOBJECT_BYNAME;
strcpy(msg.directive.args,"Mute");
myMsg.sendMessage(msg);
sleep(2);
eak_data data = myMsg.getMessageData();
cout << data.directive.args << endl;
string data1 = data.directive.args;
stringstream ss(data1);
LKey key;
ss >> key;
}
if ( type == "SEND_KEY" ) {
msg.msg_type = msgPasser::SEND_KEY;
}
if ( type == "HUP") {
cout << "Sending an HUP message" << endl;
//msg.msg_type = msgPasser::HUP;
myMsg.sendMessage(msgPasser::HUP,"hup");
}
if ( type == "RELOAD") {
cout << "Sending an RELOAD message" << endl;
//msg.msg_type = msgPasser::RELOAD;
myMsg.sendMessage(msgPasser::HUP,"hup");
}
if ( type == "EXIT") {
cout << "Sending an EXIT message" << endl;
//msg.msg_type = msgPasser::EXIT;
myMsg.sendMessage(msgPasser::EXIT,"exit");
}
if ( type == "TERM") {
cout << "Sending a TERMINATE message" << endl;
//msg.msg_type = msgPasser::TERM;
myMsg.sendMessage(msgPasser::TERM,"term");
}
if ( type == "DISABLE") {
cout << "Sending the DISABLE message" << endl;
//msg.msg_type = msgPasser::DISABLE;
myMsg.sendMessage(msgPasser::DISABLE,"disable");
}
if ( type == "ENABLE") {
cout << "Sending the ENABLE message" << endl;
//msg.msg_type = msgPasser::ENABLE;
myMsg.sendMessage(msgPasser::ENABLE,"enable");
}
if ( type == "COMMAND") {
cout << "Sending a COMMAND message" << endl;
//cout << "argument = " << argument << endl;
//char command[ARGSIZE] = "Testing 1 2 3\0";
msg.msg_type = msgPasser::COMMAND;
msg.directive.data_type=STRING_COMMAND;
//strcpy(msg.command,command);
//msg.directive.data = argv[2];
//cout << "data = " << msg.directive.data << endl;
//cout << "data = " << (char*)msg.directive.data << endl;
myMsg.sendMessage(msg);
// sleep(1);
/* while (msg.msg_type != msgPasser::ACK) {
sleep(1);
msg = myMsg.getMessage();
cout << "Got a: " << msg.msg_type << " message" << endl;
} */
}
if ( type == "GETDATA") {
msg.msg_type = msgPasser::GETDATA;
}
if ( type == "SENDDATA") {
msg.msg_type = msgPasser::SENDDATA;
}
return 0;
}
|