FB67XX5EGNF45JNAQISW7CBLSLS36F6JEUOBTTPUMVBMOVLGA3VQC #ifndef MACROS_H#define MACROS_H/*** ARRAY_SIZE - get the number of elements in a visibl array.** DOES NOT WORK ON POINTERS*/#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))#endif
#include <unistd.h> /* getopt(3p) */#include <stdio.h>#include <stdlib.h>/*** ani init [-h|--help] [--channel <CHANNEL>] <PATH>*//*** Init initializes a new repository as** mkdir .pijul/{pristine, changes}** plus maybe a few other things?*/intinit(){/* create the directory with mkdir(2) */printf("init!\n");return 0;}/*** ani init [-c <channel>] [<dir>]*/int cmd_init(int argc, const char **argv){int c;char *channel = "main";/* Parse cmdline args */while ((c = getopt(argc, argv, "")) != -1) {switch (c) {case 'c':channel = optarg;break;case '?':fprintf(stderr, "unrecognized option '-%c'\n", optopt);exit(1);}}/* Return result of init() */return init();}
int cmd_init(int argc, const char *argv[]);
// TODO: impl cmdline argument parsing//// ani init Initialize an empty pijul repository// ani key Key generation and management
static struct cmd *find_cmd(const char *s){int i;struct cmd *p;for (i = 0; i < ARRAY_SIZE(commands); i++) {p = commands + i;if (!strcmp(s, p->name))return p;}return NULL;}intcmd_main(int argc, char *argv[]){char *cmd_name;struct cmd *command;cmd_name = *++argv;command = find_cmd(cmd_name);if (command == NULL) {fprintf(stderr, "command not found '%s'\n", cmd_name);return -1;}argc--;return (command->fn)(argc, argv);}/*** TODO: impl cmdline argument parsing** ani init Initialize an empty pijul repository* ani key Key generation and management**/