diff options
Diffstat (limited to 'examples/c4info.c')
| -rw-r--r-- | examples/c4info.c | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/examples/c4info.c b/examples/c4info.c new file mode 100644 index 0000000..6fa63fe --- /dev/null +++ b/examples/c4info.c @@ -0,0 +1,45 @@ +#include <stdlib.h> +#include <stdio.h> +#include <time.h> + +#include "cc4group.h" + +const char* formatTime(int32_t time) +{ + time_t tTime = time; + static char ret[128]; + strftime(ret, sizeof(ret), "%c", localtime(&tTime)); + return ret; +} + +int main(int argc, char* argv[]) +{ + if(argc != 2) + { + fprintf(stderr, "USAGE: %s <group>\n", argv[0]); + return EXIT_FAILURE; + } + + CC4Group* group = cc4group.new(); + bool success = cc4group.openExisting(group, argv[1]); + if(!success) + { + fprintf(stderr, "ERROR: Can not open group file \"%s\": %s\n", argv[1], cc4group.getErrorMessage(group)); + } + else + { + CC4Group_EntryInfo info; + cc4group.getEntryInfo(group, "", &info); + + puts(argv[1]); + printf("Created: %s\n", formatTime(info.modified)); + printf("Author: %s\n", info.author); + if(info.official) + { + puts("Official"); + } + } + cc4group.delete(group); + + return success ? EXIT_SUCCESS : EXIT_FAILURE; +} |
