Initial import
This commit is contained in:
10
.gitignore
vendored
Normal file
10
.gitignore
vendored
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
CMakeCache.txt
|
||||||
|
CMakeFiles
|
||||||
|
CPackConfig.cmake
|
||||||
|
CPackSourceConfig.cmake
|
||||||
|
Makefile
|
||||||
|
_CPack_Packages
|
||||||
|
cmake_install.cmake
|
||||||
|
config.h
|
||||||
|
install_manifest.txt
|
||||||
|
mazemaker
|
||||||
35
CMakeLists.txt
Normal file
35
CMakeLists.txt
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
cmake_minimum_required (VERSION 2.8.12)
|
||||||
|
project (mazemaker)
|
||||||
|
set(CMAKE_C_FLAGS "-Wall -O2 -g")
|
||||||
|
set (VERSION_MAJOR 0)
|
||||||
|
set (VERSION_MINOR 1)
|
||||||
|
|
||||||
|
configure_file (
|
||||||
|
"${PROJECT_SOURCE_DIR}/config.h.in"
|
||||||
|
"${PROJECT_BINARY_DIR}/config.h"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
find_package(PkgConfig REQUIRED)
|
||||||
|
pkg_search_module(POPT REQUIRED popt)
|
||||||
|
|
||||||
|
include_directories("${PROJECT_BINARY_DIR}")
|
||||||
|
|
||||||
|
file(GLOB_RECURSE SOURCES src/*.c src/*.h)
|
||||||
|
|
||||||
|
add_executable (mazemaker ${SOURCES})
|
||||||
|
install (TARGETS mazemaker DESTINATION bin)
|
||||||
|
|
||||||
|
target_link_libraries(mazemaker PUBLIC ${POPT_LIBRARIES})
|
||||||
|
target_include_directories(mazemaker PUBLIC ${POPT_INCLUDE_DIRS})
|
||||||
|
target_compile_options(mazemaker PUBLIC ${POPT_CFLAGS_OTHER})
|
||||||
|
target_link_options(mazemaker PUBLIC ${POPT_LDFLAGS_OTHER})
|
||||||
|
|
||||||
|
set(
|
||||||
|
CPACK_SOURCE_PACKAGE_FILE_NAME
|
||||||
|
"mazemaker-${VERSION_MAJOR}.${VERSION_MINOR}"
|
||||||
|
CACHE INTERNAL "tarball basename"
|
||||||
|
)
|
||||||
|
set(CPACK_SOURCE_GENERATOR "TGZ")
|
||||||
|
set(CPACK_SOURCE_IGNORE_FILES "/build/;/.git/;~$;/CMakeFiles/;*.cmake;*.tar.gz;${CPACK_SOURCE_IGNORE_FILES}")
|
||||||
|
include (CPack)
|
||||||
3
config.h.in
Normal file
3
config.h.in
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
// the configured options and settings for Tutorial
|
||||||
|
#define VERSION_MAJOR @VERSION_MAJOR@
|
||||||
|
#define VERSION_MINOR @VERSION_MINOR@
|
||||||
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