diff options
author | David Adam <zanchey@ucc.gu.uwa.edu.au> | 2015-07-26 10:20:13 +0800 |
---|---|---|
committer | David Adam <zanchey@ucc.gu.uwa.edu.au> | 2015-07-26 10:20:13 +0800 |
commit | 3929e9de0e69666b37df87347d5ce15663e81347 (patch) | |
tree | b2701c439c0260840ce1c68beaebf7de1178cc53 /src/print_help.cpp | |
parent | 793e1afa084982dac92c4fe19e50c25e326a79c2 (diff) | |
parent | f4d1657c22c81a7720a91026f915b80d2d6aa6e8 (diff) |
Merge branch 'master' into iwyu
Diffstat (limited to 'src/print_help.cpp')
-rw-r--r-- | src/print_help.cpp | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/print_help.cpp b/src/print_help.cpp new file mode 100644 index 00000000..da401134 --- /dev/null +++ b/src/print_help.cpp @@ -0,0 +1,36 @@ + +/** \file print_help.c + Print help message for the specified command +*/ + +#include <stdlib.h> +#include <stdio.h> +#include <string.h> +#include <stddef.h> +#include <sys/types.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)); + } + + } + +} |