diff options
author | Sergey Poznyakoff <gray@gnu.org> | 2013-12-03 15:32:12 +0200 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org> | 2013-12-03 15:32:12 +0200 |
commit | 5e501cf05fd1997018613304761d1104879353aa (patch) | |
tree | fd14fa84bf80b72e8472f8451639e33501afe886 /etc | |
parent | 495c4a5cadf67b7c9b5e0c8b224f7b68c42c8da4 (diff) | |
download | eclat-5e501cf05fd1997018613304761d1104879353aa.tar.gz eclat-5e501cf05fd1997018613304761d1104879353aa.tar.bz2 |
Implement sg --list
* etc/Makefile.am (FLNFILES): Add lsattr.fln
(.fln.forlan): Use all prerequisites, not only the first one.
(FORMATFILES): Remove lsattr.forlan
(lsattr.forlan): Use implicit rule.
(sg.forlan): New rule
* etc/flncat.c (comment): Optionally output the comment.
(main): Output " else " only if some non-whitespace and non-comment
characters were output before.
* etc/lsattr.fln: New file
* src/sg-cl.opt: New option --list.
* src/sg.c (list_option): New variable.
Diffstat (limited to 'etc')
-rw-r--r-- | etc/Makefile.am | 9 | ||||
-rw-r--r-- | etc/flncat.c | 48 | ||||
-rw-r--r-- | etc/lsattr.fln | 16 |
3 files changed, 54 insertions, 19 deletions
diff --git a/etc/Makefile.am b/etc/Makefile.am index 1f53924..caa780c 100644 --- a/etc/Makefile.am +++ b/etc/Makefile.am @@ -45,6 +45,7 @@ FLNFILES=\ detach-volume.fln\ disassociate-address.fln\ get-console-output.fln\ + lsattr.fln\ modify-instance-attribute.fln\ modify-snapshot-attribute.fln\ reboot-instances.fln\ @@ -62,11 +63,11 @@ SUFFIXES=.cfin .conf if SPLIT_FORMATS SUFFIXES += .forlan .fln .fln.forlan: - $(AM_V_GEN)$(abs_builddir)/flncat $< default.fln > $@ -FORMATFILES = $(FLNFILES:.fln=.forlan) lsattr.forlan + $(AM_V_GEN)$(abs_builddir)/flncat $^ default.fln > $@ +FORMATFILES = $(FLNFILES:.fln=.forlan) FORMATNAME = $${command} -lsattr.forlan: describe-instance-attribute.fln describe-snapshot-attribute.fln default.fln - $(AM_V_GEN)(cd $(srcdir); $(abs_builddir)/flncat describe-instance-attribute.fln describe-snapshot-attribute.fln default.fln) > lsattr.forlan +lsattr.forlan: describe-instance-attribute.fln describe-snapshot-attribute.fln default.fln +sg.forlan: sg.fln describe-security-groups.fln else FORMATFILES = eclat.forlan eclat.forlan: $(FLNFILES) default.fln diff --git a/etc/flncat.c b/etc/flncat.c index 0c29453..82c4086 100644 --- a/etc/flncat.c +++ b/etc/flncat.c @@ -19,30 +19,44 @@ #include <assert.h> int -comment(FILE *fp, int c) +comment(FILE *fp, int c, int echo) { if (c != '/') { ungetc(c, fp); return 0; - } + } else if (echo) + fputc(c, stdout); if ((c = getc(fp)) == '/') { - while ((c = getc(fp)) != EOF && c != '\n') - ; + do + if (echo) fputc(c, stdout); + while ((c = getc(fp)) != EOF && c != '\n'); return 1; } + + if (echo) + fputc(c, stdout); if (c == '*') { do { - while ((c = getc(fp)) != '*') { + do { + c = getc(fp); if (c == EOF) return 0; - } - } while ((c = getc(fp)) != '/'); + else if (echo) + fputc(c, stdout); + } while (c != '*'); + c = getc(fp); + if (echo) + fputc(c, stdout); + } while (c != '/'); return 1; + } else + + if (!echo) { + ungetc(c, fp); + ungetc('/', fp); } - ungetc(c, fp); - ungetc('/', fp); return 0; } @@ -54,6 +68,7 @@ main(int argc, char **argv) int c; char buf[128]; size_t lev = 0; + int outchars = 0; for (i = 1; i < argc; i++) { fp = fopen(*++argv, "r"); @@ -62,16 +77,19 @@ main(int argc, char **argv) return 1; } - if (i > 1) { - /* Skip whitespace and comment lines */ - do { - while ((c = fgetc(fp)) != EOF && isspace(c)) - ; - } while (c != EOF && comment(fp, c)); + /* Skip initial whitespace and comment lines, unless it is the + first file we process. */ + do { + while ((c = fgetc(fp)) != EOF && isspace(c)) + if (i == 1) fputc(c, stdout); + } while (c != EOF && comment(fp, c, i == 1)); + + if (outchars) { printf(" else "); } while ((c = fgetc(fp)) != EOF) { + outchars = 1; putchar(c); if (c == '}') { lev = 0; diff --git a/etc/lsattr.fln b/etc/lsattr.fln new file mode 100644 index 0000000..c4aab5c --- /dev/null +++ b/etc/lsattr.fln @@ -0,0 +1,16 @@ +/* This file is part of Eclat. + Copyright (C) 2013 Sergey Poznyakoff. + + Eclat is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3, or (at your option) + any later version. + + Eclat is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Eclat. If not, see <http://www.gnu.org/licenses/>. */ + |