Initial import
This commit is contained in:
28
src/grid.h
Normal file
28
src/grid.h
Normal 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
27
src/main.c
Normal 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);
|
||||
}
|
||||
Reference in New Issue
Block a user