diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2012-09-28 16:31:51 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2012-09-28 16:31:51 +0300 |
commit | 4d6c1e56790f61be15501977e970753a6088104f (patch) | |
tree | 64ddcd26b8c88faf5f05c6500bdc521ad70ef471 /src | |
parent | a5ca53e9de8e689d8f83ac2eacc9b7c3fcb27bed (diff) | |
download | eclat-4d6c1e56790f61be15501977e970753a6088104f.tar.gz eclat-4d6c1e56790f61be15501977e970753a6088104f.tar.bz2 |
Remove spurious sources.
* src/eclat.h (generic_parse_options): New proto.
(generic_proginfo): New extern.
* src/Makefile.am: Update.
* src/dscrinsts-cl.opt: Remove.
* src/dscrtags-cl.opt: Remove.
* src/startinst-cl.opt: Remove.
* src/generic-cl.opt: New file.
* src/genericcl.c: New file.
* src/dscrinsts.c: Use generic_parse_options.
* src/dscrtags.c: Likewise.
* src/startinst.c: Likewise.
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile.am | 16 | ||||
-rw-r--r-- | src/dscrinsts-cl.opt | 143 | ||||
-rw-r--r-- | src/dscrinsts.c | 121 | ||||
-rw-r--r-- | src/dscrtags-cl.opt | 60 | ||||
-rw-r--r-- | src/dscrtags.c | 39 | ||||
-rw-r--r-- | src/eclat.h | 4 | ||||
-rw-r--r-- | src/generic-cl.opt (renamed from src/startinst-cl.opt) | 14 | ||||
-rw-r--r-- | src/genericcl.c | 18 | ||||
-rw-r--r-- | src/startinst.c | 9 |
9 files changed, 201 insertions, 223 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index 7f3e1f0..e2702ca 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -21,15 +21,12 @@ eclat_SOURCES=\ cmdline.h\ config.c\ dscrtags.c\ - dscrtags-cl.h\ dscrinsts.c\ - dscrinsts-cl.h\ dscrinststat.c\ - dscrinststat-cl.h\ eclat.c\ eclat.h\ + genericcl.c\ startinst.c\ - startinst-cl.h\ util.c AM_LDFLAGS = $(CURL_LIBS) @@ -42,17 +39,14 @@ AM_CPPFLAGS= \ -DDEFAULT_PREPROCESSOR="$(DEFAULT_PREPROCESSOR)" OPTFILES=\ - dscrinsts-cl.opt\ dscrinststat-cl.opt\ - dscrtags-cl.opt\ - startinst-cl.opt + generic-cl.opt + +eclat_SOURCES += $(OPTFILES:.opt=.h) BUILT_SOURCES=\ cmdline.h\ - $(OPTFILES:.opt=.h)\ - dscrinststat-cl.h\ - dscrtags-cl.h\ - startinst-cl.h + $(OPTFILES:.opt=.h) EXTRA_DIST=\ cmdline.opt\ diff --git a/src/dscrinsts-cl.opt b/src/dscrinsts-cl.opt deleted file mode 100644 index acfe531..0000000 --- a/src/dscrinsts-cl.opt +++ /dev/null @@ -1,143 +0,0 @@ -/* This file is part of Eclat. - Copyright (C) 2012 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/>. */ - -OPTIONS_BEGIN("eclat describe-instances", - [<List instances>], - [<[FILTER...]>], - [<gnu>], - [<nousage>], - [<noversion>]) - -OPTIONS_END - -static void -parse_options(int argc, char *argv[], int *index) -{ - static char *architecture_str[] = { "i386", "x86_64", NULL }; - static char *lifecycle_str[] = { "spot", NULL }; - static char * state_code_str[] = { - "0 (pending)", "16 (running)", "32 (shutting-down)", - "48 (terminated)", "64 (stopping)", "80 (stopped)", - NULL - }; - static char *state_name_str[] = { - "pending", "running", - "shutting-down", "terminated", - "stopping", "stopped", - NULL - }; - static char *state_str[] = { "disabled", "enabled", NULL }; - static char *prod_code_str[] = { "devpay", "marketplace", - NULL }; - static char *device_type_str[] = { - "ebs", - "instance-store", - NULL - }; - static char *virt_type_str[] = { "paravirtual", "hvm", NULL }; - static char *hypervisor_str[] = { "ovm", "xen", NULL }; - static char *iface_status_str[] = { "available", "in-use", NULL }; - static char *iface_att_str[] = { - "attaching", "attached", "detaching", "detached", NULL - }; - static struct filter_descr filters[] = { - { "architecture", FILTER_ENUM, architecture_str }, - { "availability-zone", FILTER_STRING }, - { "block-device-mapping.attach-time", FILTER_DATE }, - { "block-device-mapping.delete-on-termination", FILTER_BOOL }, - { "block-device-mapping.device-name", FILTER_STRING }, - { "block-device-mapping.status", FILTER_STRING }, - { "block-device-mapping.volume-id", FILTER_STRING }, - { "client-token", FILTER_STRING }, - { "dns-name", FILTER_STRING }, - { "group-id", FILTER_STRING }, - { "group-name", FILTER_STRING }, - { "image-id", FILTER_STRING }, - { "instance-id", FILTER_STRING }, - { "instance-lifecycle", FILTER_ENUM, lifecycle_str }, - { "instance-state-code", FILTER_ENUM, state_code_str }, - { "instance-state-name", FILTER_ENUM, state_name_str }, - { "instance-type", FILTER_STRING }, - { "instance.group-id", FILTER_STRING }, - { "instance.group-name", FILTER_STRING }, - { "ip-address", FILTER_STRING }, - { "kernel-id", FILTER_STRING }, - { "key-name", FILTER_STRING }, - { "launch-index", FILTER_STRING }, - { "launch-time", FILTER_DATE }, - { "monitoring-state", FILTER_ENUM, state_str }, - { "owner-id", FILTER_STRING }, - { "placement-group-name", FILTER_STRING }, - { "private-dns-name", FILTER_STRING }, - { "private-ip-address", FILTER_STRING }, - { "product-code", FILTER_STRING }, - { "product-code.type", FILTER_ENUM, prod_code_str }, - { "ramdisk-id", FILTER_STRING }, - { "reason", FILTER_STRING }, - { "requester-id", FILTER_STRING }, - { "reservation-id", FILTER_STRING }, - { "root-device-name", FILTER_STRING }, - { "root-device-type", FILTER_ENUM, device_type_str }, - { "source-dest-check", FILTER_BOOL }, - { "spot-instance-request-id", FILTER_STRING }, - { "state-reason-code", FILTER_STRING }, - { "state-reason-message", FILTER_STRING }, - { "subnet-id", FILTER_STRING }, - { "tag-key", FILTER_STRING }, - { "tag-value", FILTER_STRING }, - { "tag:key", FILTER_STRING }, - { "virtualization-type", FILTER_STRING, virt_type_str }, - { "vpc-id", FILTER_STRING }, - { "hypervisor", FILTER_ENUM, hypervisor_str }, - { "network-interface.description", FILTER_STRING }, - { "network-interface.subnet-id", FILTER_STRING }, - { "network-interface.vpc-id", FILTER_STRING }, - { "network-interface.network-interface.id", FILTER_STRING }, - { "network-interface.owner-id", FILTER_STRING }, - { "network-interface.availability-zone", FILTER_STRING }, - { "network-interface.requester-id", FILTER_STRING }, - { "network-interface.requester-managed", FILTER_BOOL }, - { "network-interface.status", FILTER_ENUM, iface_status_str }, - { "network-interface.mac-address", FILTER_STRING }, - { "network-interface-private-dns-name", FILTER_STRING }, - { "network-interface.source-destination-check", FILTER_BOOL }, - { "network-interface.group-id", FILTER_STRING }, - { "network-interface.group-name", FILTER_STRING }, - { "network-interface.attachment.attachment-id", FILTER_STRING }, - { "network-interface.attachment.instance-id", FILTER_STRING }, - { "network-interface.attachment.instance-owner-id", FILTER_STRING }, - { "network-interface.addresses.private-ip-address", FILTER_STRING }, - { "network-interface.attachment.device-index", FILTER_INT }, - { "network-interface.attachment.status", FILTER_ENUM, - iface_att_str }, - { "network-interface.attachment.attach-time", FILTER_DATE }, - { "network-interface.attachment.delete-on-termination", - FILTER_BOOL }, - { "network-interface.addresses.primary", FILTER_BOOL }, - { "network-interface.addresses.association.public-ip", - FILTER_STRING }, - { "network-interface.addresses.association.ip-owner-id", FILTER_STRING }, - { "association.public-ip", FILTER_STRING }, - { "association.ip-owner-id", FILTER_STRING }, - { "association.allocation-id", FILTER_STRING }, - { NULL } - }; - - available_filters = filters; - proginfo.print_help_hook = list_filters; - - GETOPT(argc, argv, *index, exit(EX_USAGE)) -} diff --git a/src/dscrinsts.c b/src/dscrinsts.c index d051395..392fe37 100644 --- a/src/dscrinsts.c +++ b/src/dscrinsts.c @@ -15,7 +15,126 @@ along with Eclat. If not, see <http://www.gnu.org/licenses/>. */ #include "eclat.h" -#include "dscrinsts-cl.h" + +static void +parse_options(int argc, char *argv[], int *index) +{ + static char *architecture_str[] = { "i386", "x86_64", NULL }; + static char *lifecycle_str[] = { "spot", NULL }; + static char * state_code_str[] = { + "0 (pending)", "16 (running)", "32 (shutting-down)", + "48 (terminated)", "64 (stopping)", "80 (stopped)", + NULL + }; + static char *state_name_str[] = { + "pending", "running", + "shutting-down", "terminated", + "stopping", "stopped", + NULL + }; + static char *state_str[] = { "disabled", "enabled", NULL }; + static char *prod_code_str[] = { "devpay", "marketplace", + NULL }; + static char *device_type_str[] = { + "ebs", + "instance-store", + NULL + }; + static char *virt_type_str[] = { "paravirtual", "hvm", NULL }; + static char *hypervisor_str[] = { "ovm", "xen", NULL }; + static char *iface_status_str[] = { "available", "in-use", NULL }; + static char *iface_att_str[] = { + "attaching", "attached", "detaching", "detached", NULL + }; + static struct filter_descr filters[] = { + { "architecture", FILTER_ENUM, architecture_str }, + { "availability-zone", FILTER_STRING }, + { "block-device-mapping.attach-time", FILTER_DATE }, + { "block-device-mapping.delete-on-termination", FILTER_BOOL }, + { "block-device-mapping.device-name", FILTER_STRING }, + { "block-device-mapping.status", FILTER_STRING }, + { "block-device-mapping.volume-id", FILTER_STRING }, + { "client-token", FILTER_STRING }, + { "dns-name", FILTER_STRING }, + { "group-id", FILTER_STRING }, + { "group-name", FILTER_STRING }, + { "image-id", FILTER_STRING }, + { "instance-id", FILTER_STRING }, + { "instance-lifecycle", FILTER_ENUM, lifecycle_str }, + { "instance-state-code", FILTER_ENUM, state_code_str }, + { "instance-state-name", FILTER_ENUM, state_name_str }, + { "instance-type", FILTER_STRING }, + { "instance.group-id", FILTER_STRING }, + { "instance.group-name", FILTER_STRING }, + { "ip-address", FILTER_STRING }, + { "kernel-id", FILTER_STRING }, + { "key-name", FILTER_STRING }, + { "launch-index", FILTER_STRING }, + { "launch-time", FILTER_DATE }, + { "monitoring-state", FILTER_ENUM, state_str }, + { "owner-id", FILTER_STRING }, + { "placement-group-name", FILTER_STRING }, + { "private-dns-name", FILTER_STRING }, + { "private-ip-address", FILTER_STRING }, + { "product-code", FILTER_STRING }, + { "product-code.type", FILTER_ENUM, prod_code_str }, + { "ramdisk-id", FILTER_STRING }, + { "reason", FILTER_STRING }, + { "requester-id", FILTER_STRING }, + { "reservation-id", FILTER_STRING }, + { "root-device-name", FILTER_STRING }, + { "root-device-type", FILTER_ENUM, device_type_str }, + { "source-dest-check", FILTER_BOOL }, + { "spot-instance-request-id", FILTER_STRING }, + { "state-reason-code", FILTER_STRING }, + { "state-reason-message", FILTER_STRING }, + { "subnet-id", FILTER_STRING }, + { "tag-key", FILTER_STRING }, + { "tag-value", FILTER_STRING }, + { "tag:key", FILTER_STRING }, + { "virtualization-type", FILTER_STRING, virt_type_str }, + { "vpc-id", FILTER_STRING }, + { "hypervisor", FILTER_ENUM, hypervisor_str }, + { "network-interface.description", FILTER_STRING }, + { "network-interface.subnet-id", FILTER_STRING }, + { "network-interface.vpc-id", FILTER_STRING }, + { "network-interface.network-interface.id", FILTER_STRING }, + { "network-interface.owner-id", FILTER_STRING }, + { "network-interface.availability-zone", FILTER_STRING }, + { "network-interface.requester-id", FILTER_STRING }, + { "network-interface.requester-managed", FILTER_BOOL }, + { "network-interface.status", FILTER_ENUM, iface_status_str }, + { "network-interface.mac-address", FILTER_STRING }, + { "network-interface-private-dns-name", FILTER_STRING }, + { "network-interface.source-destination-check", FILTER_BOOL }, + { "network-interface.group-id", FILTER_STRING }, + { "network-interface.group-name", FILTER_STRING }, + { "network-interface.attachment.attachment-id", FILTER_STRING }, + { "network-interface.attachment.instance-id", FILTER_STRING }, + { "network-interface.attachment.instance-owner-id", FILTER_STRING }, + { "network-interface.addresses.private-ip-address", FILTER_STRING }, + { "network-interface.attachment.device-index", FILTER_INT }, + { "network-interface.attachment.status", FILTER_ENUM, + iface_att_str }, + { "network-interface.attachment.attach-time", FILTER_DATE }, + { "network-interface.attachment.delete-on-termination", + FILTER_BOOL }, + { "network-interface.addresses.primary", FILTER_BOOL }, + { "network-interface.addresses.association.public-ip", + FILTER_STRING }, + { "network-interface.addresses.association.ip-owner-id", FILTER_STRING }, + { "association.public-ip", FILTER_STRING }, + { "association.ip-owner-id", FILTER_STRING }, + { "association.allocation-id", FILTER_STRING }, + { NULL } + }; + + available_filters = filters; + generic_proginfo->print_help_hook = list_filters; + return generic_parse_options("eclat describe-instances", + "List instances", + argc, argv, index); +} int eclat_describe_instances(CURL *curl, int argc, char **argv) diff --git a/src/dscrtags-cl.opt b/src/dscrtags-cl.opt deleted file mode 100644 index adada32..0000000 --- a/src/dscrtags-cl.opt +++ /dev/null @@ -1,60 +0,0 @@ -/* This file is part of Eclat. - Copyright (C) 2012 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/>. */ - -OPTIONS_BEGIN("eclat describe-tags", - [<List tags and their values>], - [<[FILTER...]>], - [<gnu>], - [<nousage>], - [<noversion>]) - -OPTIONS_END - -static void -parse_options(int argc, char *argv[], int *index) -{ - static char *resource_types[] = { - "customer-gateway", - "dhcp-options", - "image", - "instance", - "internet-gateway", - "network-acl", - "reserved-instances", - "route-table", - "security-group", - "snapshot", - "spot-instances-request", - "subnet", - "volume", - "vpc", - "vpn-connection", - "vpn-gateway", - NULL - }; - - static struct filter_descr filters[] = { - { "key", FILTER_STRING }, - { "resource-id", FILTER_STRING }, - { "resource-type", FILTER_ENUM, resource_types }, - { "value", FILTER_STRING }, - { NULL } - }; - - available_filters = filters; - proginfo.print_help_hook = list_filters; - GETOPT(argc, argv, *index, exit(EX_USAGE)) -} diff --git a/src/dscrtags.c b/src/dscrtags.c index 0bab3bb..0d762e7 100644 --- a/src/dscrtags.c +++ b/src/dscrtags.c @@ -15,7 +15,44 @@ along with Eclat. If not, see <http://www.gnu.org/licenses/>. */ #include "eclat.h" -#include "dscrtags-cl.h" + +static void +parse_options(int argc, char *argv[], int *index) +{ + static char *resource_types[] = { + "customer-gateway", + "dhcp-options", + "image", + "instance", + "internet-gateway", + "network-acl", + "reserved-instances", + "route-table", + "security-group", + "snapshot", + "spot-instances-request", + "subnet", + "volume", + "vpc", + "vpn-connection", + "vpn-gateway", + NULL + }; + + static struct filter_descr filters[] = { + { "key", FILTER_STRING }, + { "resource-id", FILTER_STRING }, + { "resource-type", FILTER_ENUM, resource_types }, + { "value", FILTER_STRING }, + { NULL } + }; + + available_filters = filters; + generic_proginfo->print_help_hook = list_filters; + return generic_parse_options("eclat describe-tags", + "List tags and their values", + argc, argv, index); +} int eclat_describe_tags(CURL *curl, int argc, char **argv) diff --git a/src/eclat.h b/src/eclat.h index 28f5cce..acea219 100644 --- a/src/eclat.h +++ b/src/eclat.h @@ -25,6 +25,7 @@ #include <curl/curl.h> #include <expat.h> #include "grecs.h" +#include "grecsopt.h" #include "wordsplit.h" #include "libeclat.h" #include "forlan.h" @@ -96,3 +97,6 @@ int get_access_creds(const char *id, char **access_key_ptr, void define_format(const char *name, const char *fmt, grecs_locus_t *loc); forlan_eval_env_t find_format(const char *name); +void generic_parse_options(const char *pname, const char *docstring, + int argc, char *argv[], int *index); +extern struct grecs_proginfo *generic_proginfo; diff --git a/src/startinst-cl.opt b/src/generic-cl.opt index 9f986aa..93d8000 100644 --- a/src/startinst-cl.opt +++ b/src/generic-cl.opt @@ -15,19 +15,21 @@ along with Eclat. If not, see <http://www.gnu.org/licenses/>. */ OPTIONS_BEGIN(NULL, - NULL, - [<ID [ID...]>], + [<>], + [<[FILTER...]>], [<gnu>], [<nousage>], [<noversion>]) OPTIONS_END -static void -parse_options(const char *progname, const char *docstring, - int argc, char *argv[], int *index) +struct grecs_proginfo *generic_proginfo = &proginfo; + +void +generic_parse_options(const char *pname, const char *docstring, + int argc, char *argv[], int *index) { - proginfo.progname = progname; + proginfo.progname = pname; proginfo.docstring = docstring; GETOPT(argc, argv, *index, exit(EX_USAGE)) } diff --git a/src/genericcl.c b/src/genericcl.c new file mode 100644 index 0000000..86360ab --- /dev/null +++ b/src/genericcl.c @@ -0,0 +1,18 @@ +/* This file is part of Eclat. + Copyright (C) 2012 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/>. */ + +#include "eclat.h" +#include "generic-cl.h" diff --git a/src/startinst.c b/src/startinst.c index 581b76f..d316811 100644 --- a/src/startinst.c +++ b/src/startinst.c @@ -15,7 +15,14 @@ along with Eclat. If not, see <http://www.gnu.org/licenses/>. */ #include "eclat.h" -#include "startinst-cl.h" + +static void +parse_options(const char *progname, const char *docstring, + int argc, char *argv[], int *index) +{ + generic_proginfo->args_doc = "ID [ID...]"; + return generic_parse_options(progname, docstring, argc, argv, index); +} static int start_stop_instance(CURL *curl, const char *action, int argc, char **argv) |