separate headers and src
This commit is contained in:
parent
1cc9e705f9
commit
6a23dbd54d
10 changed files with 20 additions and 12 deletions
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -1,7 +1,5 @@
|
||||||
*
|
*
|
||||||
|
|
||||||
!.gitignore
|
!.gitignore
|
||||||
!*.c
|
|
||||||
!*.h
|
|
||||||
!Makefile
|
!Makefile
|
||||||
!tests
|
!**/
|
||||||
|
|
13
Makefile
13
Makefile
|
@ -16,15 +16,21 @@ LDLIBS =
|
||||||
TARGET_LIB = mulithash.a
|
TARGET_LIB = mulithash.a
|
||||||
TARGET_BIN = multihash
|
TARGET_BIN = multihash
|
||||||
|
|
||||||
SRCS = errors.c hashes.c
|
MAIN = src/main.c
|
||||||
|
MAIN_O = $(MAIN:.c=.o)
|
||||||
|
|
||||||
|
SRCS = src/errors.c src/hashes.c
|
||||||
OBJS = $(SRCS:.c=.o)
|
OBJS = $(SRCS:.c=.o)
|
||||||
|
|
||||||
|
src/%.o: src/%.c
|
||||||
|
$(CC) $(CFLAGS) -c -I include $^ -o $@
|
||||||
|
|
||||||
all: $(TARGET_LIB) $(TARGET_BIN)
|
all: $(TARGET_LIB) $(TARGET_BIN)
|
||||||
|
|
||||||
$(TARGET_LIB): $(OBJS)
|
$(TARGET_LIB): $(OBJS)
|
||||||
ar rcs $@ $^
|
ar rcs $@ $^
|
||||||
|
|
||||||
$(TARGET_BIN): main.o $(TARGET_LIB)
|
$(TARGET_BIN): $(MAIN_O) $(TARGET_LIB)
|
||||||
$(CC) $(LDFLAGS) $^ -o $@
|
$(CC) $(LDFLAGS) $^ -o $@
|
||||||
|
|
||||||
# Tests
|
# Tests
|
||||||
|
@ -42,7 +48,7 @@ tests: $(TEST_BINS)
|
||||||
done
|
done
|
||||||
|
|
||||||
tests/c/test_%.o: tests/c/test_%.c
|
tests/c/test_%.o: tests/c/test_%.c
|
||||||
$(CC) -c -I. $^ -o $@
|
$(CC) $(CFLAGS) -c -I include $^ -o $@
|
||||||
|
|
||||||
tests/c/test_%: tests/c/test_%.o $(TARGET_LIB)
|
tests/c/test_%: tests/c/test_%.o $(TARGET_LIB)
|
||||||
$(CC) $(LDFLAGS) $^ -o $@
|
$(CC) $(LDFLAGS) $^ -o $@
|
||||||
|
@ -56,6 +62,7 @@ clean:
|
||||||
$(RM) $(TEST_BINS)
|
$(RM) $(TEST_BINS)
|
||||||
$(RM) $(TARGET_LIB)
|
$(RM) $(TARGET_LIB)
|
||||||
$(RM) $(TARGET_BIN)
|
$(RM) $(TARGET_BIN)
|
||||||
|
$(RM) $(MAIN_O)
|
||||||
|
|
||||||
dist-clean: clean
|
dist-clean: clean
|
||||||
|
|
||||||
|
|
2
include/mh/.gitignore
vendored
Normal file
2
include/mh/.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
!*.h
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/* vim: set ts=8 sw=8 noexpandtab: */
|
/* vim: set ts=8 sw=8 noexpandtab: */
|
||||||
|
#include "errors.h"
|
||||||
|
|
||||||
// list of avaliable hash functions.
|
// list of avaliable hash functions.
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
@ -28,7 +28,7 @@ typedef struct {
|
||||||
mh_hash hash;
|
mh_hash hash;
|
||||||
int code;
|
int code;
|
||||||
int length;
|
int length;
|
||||||
} mh_hashinfo
|
} mh_hashinfo;
|
||||||
|
|
||||||
// decodes code info hash info, leaves length field zeroed
|
// decodes code info hash info, leaves length field zeroed
|
||||||
mh_error mh_hashinfo_from_code(int code, mh_hashinfo *hinfo);
|
mh_error mh_hashinfo_from_code(int code, mh_hashinfo *hinfo);
|
1
src/.gitignore
vendored
Normal file
1
src/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
!*.c
|
|
@ -1,5 +1,5 @@
|
||||||
/* vim: set ts=8 sw=8 noexpandtab: */
|
/* vim: set ts=8 sw=8 noexpandtab: */
|
||||||
#include "errors.h"
|
#include "mh/errors.h"
|
||||||
|
|
||||||
static const struct mh_error_desc {
|
static const struct mh_error_desc {
|
||||||
int code;
|
int code;
|
|
@ -1,2 +1,2 @@
|
||||||
/* vim: set ts=8 sw=8 noexpandtab: */
|
/* vim: set ts=8 sw=8 noexpandtab: */
|
||||||
|
#include "mh/hashes.h"
|
|
@ -2,7 +2,7 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
|
||||||
#include "errors.h"
|
#include "mh/errors.h"
|
||||||
|
|
||||||
int main(void) {
|
int main(void) {
|
||||||
printf("%s\n", mh_error_string(MH_E_TOO_LONG));
|
printf("%s\n", mh_error_string(MH_E_TOO_LONG));
|
|
@ -1,7 +1,7 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "minunit.h"
|
#include "minunit.h"
|
||||||
|
|
||||||
#include "errors.h"
|
#include "mh/errors.h"
|
||||||
|
|
||||||
char error_buf[256];
|
char error_buf[256];
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue