diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2012-09-26 22:27:04 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2012-09-26 22:30:07 +0300 |
commit | 0c8a7ab953a86426a13aa0eccaf2b2c46f8271c0 (patch) | |
tree | 6f507697a5914bfb0ba9425aef3701ac00d94ec7 /src/util.c | |
parent | 22084e1264031d59b8954b684c1d9f40733c8786 (diff) | |
download | eclat-0c8a7ab953a86426a13aa0eccaf2b2c46f8271c0.tar.gz eclat-0c8a7ab953a86426a13aa0eccaf2b2c46f8271c0.tar.bz2 |
Improve documentation output.
* src/dscrinststat-cl.opt: Document available filters.
* src/dscrtags-cl.opt: Likewise.
* src/eclat.c (list_filters): New function.
* src/eclat.h (FILTER_STRING,FILTER_DATE)
(FILTER_ENUM): : New defines.
(filter_descr): New struct.
* src/util.c (get_scr_cols): New function.
(describe_query_create): Minor fix.
Diffstat (limited to 'src/util.c')
-rw-r--r-- | src/util.c | 21 |
1 files changed, 19 insertions, 2 deletions
@@ -15,6 +15,23 @@ along with Eclat. If not, see <http://www.gnu.org/licenses/>. */ #include "eclat.h" +#include <termios.h> +#include <sys/ioctl.h> + +int +get_scr_cols() +{ + struct winsize ws; + + ws.ws_col = ws.ws_row = 0; + if ((ioctl(1, TIOCGWINSZ, (char *) &ws) < 0) || ws.ws_col == 0) { + const char *p = getenv ("COLUMNS"); + if (p) + ws.ws_col = strtol(p, NULL, 10); + } + return ws.ws_col ? ws.ws_col : 80; +} + struct ec2_query * describe_query_create(CURL *curl, const char *verb, int argc, char **argv) @@ -33,14 +50,14 @@ describe_query_create(CURL *curl, const char *verb, int argc, char **argv) ws.ws_delim = ","; wsflags = WRDSF_DEFFLAGS | WRDSF_DELIM; - for (i = 0, j = 1; i < argc; i++) { + for (i = 0, j = 1; i < argc; i++, j++) { char *p = strchr(argv[i], '='); if (!p) die(EX_USAGE, "maformed filter: %s", argv[i]); *p++ = 0; grecs_asprintf(&bufptr, &bufsize, "Filter.%d.Name", j); eclat_query_add_param(q, bufptr, argv[i]); - + if (wordsplit(p, &ws, wsflags)) die(EX_SOFTWARE, "wordsplit failed at \"%s\": %s", p, wordsplit_strerror(&ws)); |