From: Florian Forster Date: Wed, 7 May 2008 15:03:42 +0000 (+0200) Subject: src/sn_normalize.c: Add a program to normalize sort networks. X-Git-Tag: v1.0.0~105 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=796caac3ca3c0c829ed092d0dc6bf3c4bfd778fb;p=sort-networks.git src/sn_normalize.c: Add a program to normalize sort networks. --- diff --git a/src/sn-normalize.c b/src/sn-normalize.c new file mode 100644 index 0000000..320555f --- /dev/null +++ b/src/sn-normalize.c @@ -0,0 +1,49 @@ +#include +#include +#include + +#include "sn_network.h" + +void exit_usage (const char *name) +{ + printf ("%s [file]\n", name); + exit (1); +} + +int main (int argc, char **argv) +{ + sn_network_t *n; + + if (argc > 2) + { + exit_usage (argv[0]); + } + else if (argc == 2) + { + if ((strcmp ("-h", argv[1]) == 0) + || (strcmp ("--help", argv[1]) == 0) + || (strcmp ("-help", argv[1]) == 0)) + exit_usage (argv[0]); + + n = sn_network_read_file (argv[1]); + } + else + { + n = sn_network_read (stdin); + } + + if (n == NULL) + { + printf ("n == NULL!\n"); + return (1); + } + + sn_network_normalize (n); + sn_network_compress (n); + + sn_network_write (n, stdout); + + return (0); +} /* int main */ + +/* vim: set shiftwidth=2 softtabstop=2 : */