Initial import

This commit is contained in:
2021-04-15 13:31:30 -04:00
parent f0a260bd82
commit b127690a48
6 changed files with 107 additions and 0 deletions

28
src/grid.h Normal file
View File

@@ -0,0 +1,28 @@
#ifndef _GRID_H
#define _GRID_H 1
typedef uint8 edgeweight_t;
typedef struct {
edgeweight_t up, right;
} mazeedges_t;
typedef struct {
size_t width, height;
mazeedges_t** grid;
} mazegrid_t;
typedef enum {
EDGE_UP,
EDGE_RIGHT,
EDGE_DOWN,
EDGE_LEFT
} mazeedge_dir_t;
mazegrid_t mazegrid_new(size_t width, size_t height);
void mazegrid_free(mazegrid_t* g);
int mazegrid_set_edge(mazegrid_t* g, size_t x, size_t y, mazeedge_dir_t dir, edgeweight_t wt);
edgeweight_t mazegrid_get_edge(mazegrid_t const* g, size_t, size_t y, mazeedge_dir_t dir);
#endif // !def(_GRID_H)

27
src/main.c Normal file
View File

@@ -0,0 +1,27 @@
#include <stdio.h>
#include <stdlib.h>
#include <popt.h>
int main(int argc, char* argv[]) {
char c;
int width = 0, height = 0;
struct poptOption options_table[] = {
{ "width", 'w', POPT_ARG_INT, &width, 0 },
{ "height", 'h', POPT_ARG_INT, &height, 0 },
POPT_AUTOHELP
{ NULL, 0, 0, NULL, 0 }
};
poptContext ctx = poptGetContext(NULL, argc, argv, options_table, 0);
if (argc < 2) {
poptPrintUsage(ctx, stderr, 0);
exit(1);
}
while ((c = poptGetNextOpt(ctx)) >= 0) /* noop */ ;
if (c < -1) {
fprintf(stderr, "%s: %s\n", poptBadOption(ctx, POPT_BADOPTION_NOALIAS), poptStrerror(c));
return 1;
}
printf("width: %d\n", width);
printf("height: %d\n", height);
poptFreeContext(ctx);
}