diff options
Diffstat (limited to 'examples/c4copy.c')
| -rw-r--r-- | examples/c4copy.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/examples/c4copy.c b/examples/c4copy.c new file mode 100644 index 0000000..35e201b --- /dev/null +++ b/examples/c4copy.c @@ -0,0 +1,36 @@ +#include <stdlib.h> +#include <stdio.h> + +#include "cc4group.h" + +int main(int argc, char* argv[]) +{ + if(argc != 3) + { + fprintf(stderr, "USAGE: %s <group> <target>\n", argv[0]); + return EXIT_FAILURE; + } + + bool success = true; + + CC4Group* group = cc4group.new(); + if(!cc4group.openExisting(group, argv[1])) + { + fprintf(stderr, "ERROR: Can not open group file \"%s\": %s\n", argv[1], cc4group.getErrorMessage(group)); + + success = false; + } + else + { + success = cc4group.save(group, argv[2]); + + if(!success) + { + fprintf(stderr, "ERROR: Can not save group file to \"%s\": %s\n", argv[2], cc4group.getErrorMessage(group)); + } + } + + cc4group.delete(group); + + return success ? EXIT_SUCCESS : EXIT_FAILURE; +} |
