diff options
author | ZoRo <dos21h@gmail.com> | 2017-02-07 08:32:09 +0000 |
---|---|---|
committer | ZoRo <dos21h@gmail.com> | 2017-02-07 08:32:09 +0000 |
commit | 0397a4c9dee0300e0ee843fe85aa4c2d77630758 (patch) | |
tree | 3328ac203ea1539b185e639dd0cc92673461339a /tool/mqtool.c | |
parent | 27ab3cf81930b63113f4bd6daa1db3c3cc43a3e1 (diff) | |
download | agni-0397a4c9dee0300e0ee843fe85aa4c2d77630758.tar.gz agni-0397a4c9dee0300e0ee843fe85aa4c2d77630758.zip |
Added matching table for executed commands
Diffstat (limited to 'tool/mqtool.c')
-rw-r--r-- | tool/mqtool.c | 53 |
1 files changed, 51 insertions, 2 deletions
diff --git a/tool/mqtool.c b/tool/mqtool.c index 61e78af..76bf660 100644 --- a/tool/mqtool.c +++ b/tool/mqtool.c @@ -45,23 +45,41 @@ int main(int argc, char **argv) char* mqNameClear = NULL; //clear print extra info if there is int flagExtra = 0; - + //send string to queue + int flagSendQueue = 0; + char *mqNameSend = NULL; //mq name where to send + //argument value that to send into queue + int flagSendStr = 0; + char *sStrSend = NULL; //mq string that should be push'ed in queue //get arguments - while ((c = getopt(argc, argv, "elp:c:")) != -1) + while ((c = getopt(argc, argv, "elp:c:s:q:")) != -1) switch(c) { + //list all mqueue's case 'l': flagListAll = 1; break; + //show param of mq case 'p': flagMqParam = 1; mqName = optarg; break; + //get all messages, print out and clean queue case 'c': flagClear = 1; mqNameClear = optarg; break; + //send string to queue + case 's': + flagSendQueue = 1; + mqNameSend = optarg; + break; + case 'q': + flagSendStr = 1; + sStrSend = optarg; + break; + //show extra information if avaliable case 'e': flagExtra = 1; break; @@ -179,5 +197,36 @@ int main(int argc, char **argv) exit(0); } + if (flagSendQueue && flagSendStr) + { + size_t szStr=0; + int mqFd = -1; + int numRead = -1; + int prio = 0; + struct mq_attr mqAttr; + + mqFd = mq_open(mqNameSend, O_RDWR, 0666, NULL); + if (mqFd == -1) + { + printf("Cant open %s\n", mqName); + exit(1); + } + + iRet = mq_getattr(mqFd, &mqAttr); + if (iRet == -1) + { + perror("Cant get attributes"); + exit(1); + } + + iRet = mq_send(mqFd, sStrSend, strlen(sStrSend), prio); + if (iRet == -1) + { + perror("Cant send message"); + exit(1); + } + + exit(0); + } }
\ No newline at end of file |