#include #include #include #include #include "cc4group.h" int main(int argc, char* argv[]) { if(argc != 2 && argc != 3) { fprintf(stderr, "USAGE: %s [author]\n", argv[0]); return EXIT_FAILURE; } CC4Group* group = cc4group.new(); cc4group.setLazy(group, false); bool success, exists; struct stat st; if(stat(argv[1], &st) == 0) { success = cc4group.openExisting(group, argv[1]); exists = true; } else { success = cc4group.create(group); exists = false; } if(!success) { const char* error = cc4group.getErrorMessage(group); if(exists) { fprintf(stderr, "ERROR: Can not open group file \"%s\": %s\n", argv[1], error); } else { fprintf(stderr, "ERROR: Can not initialize empty group file: %s\n", error); } } if(success) { cc4group.setCreation(group, time(NULL), NULL, false); if(argc == 3) { cc4group.setMaker(group, argv[2], NULL, true); } if(exists) { success = cc4group.saveParent(group); } else { success = cc4group.saveAs(group, argv[1]); } if(!success) { fprintf(stderr, "ERROR: Can not save group file to \"%s\": %s\n", argv[1], cc4group.getErrorMessage(group)); } } cc4group.delete(group); return success ? EXIT_SUCCESS : EXIT_FAILURE; }