aboutsummaryrefslogtreecommitdiff
path: root/src/util.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/util.c')
-rw-r--r--src/util.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/util.c b/src/util.c
index 146567c..30b3979 100644
--- a/src/util.c
+++ b/src/util.c
@@ -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));

Return to:

Send suggestions and report system problems to the System administrator.