aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/print_help.cpp
diff options
context:
space:
mode:
authorGravatar ridiculousfish <corydoras@ridiculousfish.com>2015-07-24 00:50:58 -0700
committerGravatar ridiculousfish <corydoras@ridiculousfish.com>2015-07-24 00:59:27 -0700
commitb4f53143b0e05fd3061cdf2e65e17a6a2904090b (patch)
tree4785bf31f7b89fc2420aa740d9a6967dc6c6f9b1 /src/print_help.cpp
parent9c2fdc6da57032c4448b59de5872086eea626b74 (diff)
Migrate source files into src/ directory
This change moves source files into a src/ directory, and puts object files into an obj/ directory. The Makefile and xcode project are updated accordingly. Fixes #1866
Diffstat (limited to 'src/print_help.cpp')
-rw-r--r--src/print_help.cpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/print_help.cpp b/src/print_help.cpp
new file mode 100644
index 00000000..06bed30c
--- /dev/null
+++ b/src/print_help.cpp
@@ -0,0 +1,34 @@
+
+/** \file print_help.c
+ Print help message for the specified command
+*/
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "print_help.h"
+
+#define CMD_LEN 1024
+
+#define HELP_ERR "Could not show help message\n"
+
+/* defined in common.h */
+ssize_t write_loop(int fd, const char *buff, size_t count);
+
+
+void print_help(const char *c, int fd)
+{
+ char cmd[ CMD_LEN];
+ int printed = snprintf(cmd, CMD_LEN, "fish -c '__fish_print_help %s >&%d'", c, fd);
+
+ if (printed < CMD_LEN)
+ {
+ if ((system(cmd) == -1))
+ {
+ write_loop(2, HELP_ERR, strlen(HELP_ERR));
+ }
+
+ }
+
+}