summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tool/mqtool.c24
1 files changed, 22 insertions, 2 deletions
diff --git a/tool/mqtool.c b/tool/mqtool.c
index 76bf660..e6ce706 100644
--- a/tool/mqtool.c
+++ b/tool/mqtool.c
@@ -51,9 +51,11 @@ int main(int argc, char **argv)
//argument value that to send into queue
int flagSendStr = 0;
char *sStrSend = NULL; //mq string that should be push'ed in queue
+ //print help
+ int flagHelp = 0;
//get arguments
- while ((c = getopt(argc, argv, "elp:c:s:q:")) != -1)
+ while ((c = getopt(argc, argv, "elp:c:s:q:h")) != -1)
switch(c)
{
//list all mqueue's
@@ -83,6 +85,9 @@ int main(int argc, char **argv)
case 'e':
flagExtra = 1;
break;
+ case 'h':
+ flagHelp = 1;
+ break;
default:
break;
}
@@ -103,7 +108,7 @@ int main(int argc, char **argv)
{
if(sscanf(entryPath->d_name, "agni-%d", &id) == 1)
{
- printf("%s\n",entryPath->d_name);
+ printf("/%s\n",entryPath->d_name);
}
}
//should free entryPath? maybe
@@ -166,6 +171,7 @@ int main(int argc, char **argv)
cBuf = malloc(mqAttr.mq_msgsize);
if (cBuf == NULL)
{
+ perror("cant alloc memory");
exit(1);
}
@@ -229,4 +235,18 @@ int main(int argc, char **argv)
exit(0);
}
+ if (flagHelp)
+ {
+ printf("""Help: ./mqtool\n\
+-l - list all avaliable mq's\n\
+-p [MQ_NAME] - show params of mq\n\
+-c [MQ_NAME] - clear mq, and print all messages\n\
+-s [MQ_NAME] - mq name, \"/mq-name\"\n\
+-q [STR] - string to send, combined with -s \n\
+-e - print extra info if there is\n\
+-h - print this help\n\
+""");
+ exit(0);
+ }
+
} \ No newline at end of file