Permalink
Browse files

Merge pull request #12 from grierj/master

Add list output to crange
  • Loading branch information...
2 parents f28376a + 2f3ffd5 commit e9997bee7632875cf512de329562a71b65976ac1 @grierj grierj committed Feb 26, 2013
Showing with 32 additions and 3 deletions.
  1. +32 −3 libcrange/source/src/main.c
@@ -12,16 +12,45 @@ int main(int argc, char const* const* argv)
{
apr_pool_t* pool;
struct range_request* rr;
+ const char **nodes;
+ int expand_flag = 0;
+ int c;
apr_app_initialize(&argc, &argv, NULL);
atexit(apr_terminate);
apr_pool_create(&pool, NULL);
- rr = range_expand(NULL, pool, argv[1]);
- printf("%s\n", range_request_compressed(rr));
+ while ((c = getopt (argc, argv, "e")) != -1) {
+ switch (c)
+ {
+ case 'e':
+ expand_flag = 1;
+ break;
+ case '?':
+ fprintf (stderr, "Usage: crange [-e] <range>\n\n");
+ return 1;
+ default:
+ abort ();
+ }
+ }
+
+ if (argc > 3) {
+ fprintf (stderr, "Usage: crange [-e] <range>\n\n");
+ return 1;
+ }
+
+ rr = range_expand(NULL, pool, argv[argc-1]);
+ if (expand_flag == 1) {
+ nodes = range_request_nodes(rr);
+ while (*nodes) {
+ printf("%s\n", *nodes++);
+ }
+ } else {
+ printf("%s\n", range_request_compressed(rr));
+ }
if (range_request_has_warnings(rr))
- printf("%s\n", range_request_warnings(rr));
+ printf("%s\n", range_request_warnings(rr));
apr_pool_destroy(pool);
return 0;

0 comments on commit e9997be

Please sign in to comment.