Start build system and add error types
This commit is contained in:
parent
722192d78f
commit
f035ebfbe7
4 changed files with 78 additions and 0 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -31,3 +31,4 @@
|
|||
# Debug files
|
||||
*.dSYM/
|
||||
*.su
|
||||
.depend
|
||||
|
|
45
Makefile
Normal file
45
Makefile
Normal file
|
@ -0,0 +1,45 @@
|
|||
CC = gcc
|
||||
RM = rm -f
|
||||
CFLAGS = -fPIC -g -O2 -std=c99 \
|
||||
-Wall -Wextra -pedantic -Werror \
|
||||
-Wdeclaration-after-statement \
|
||||
-Wno-format-zero-length \
|
||||
-Wold-style-definition \
|
||||
-Woverflow \
|
||||
-Wpointer-arith \
|
||||
-Wstrict-prototypes \
|
||||
-Wunused \
|
||||
-Wvla
|
||||
|
||||
LDFLAGS = -g -shared
|
||||
LDLIBS =
|
||||
|
||||
TARGET_LIB = mulithash.so
|
||||
|
||||
SRCS = errors.c
|
||||
OBJS = $(subst .c,.o,$(SRCS))
|
||||
|
||||
all: ${TARGET_LIB}
|
||||
|
||||
$(TARGET_LIB): $(OBJS)
|
||||
$(CC) ${LDFLAGS} -o $@ $^
|
||||
|
||||
test: test.o pid.o
|
||||
$(C) $(LDFLAGS) -o test test.o pid.o $(LDLIBS)
|
||||
|
||||
depend: .depend
|
||||
|
||||
.depend: $(SRCS)
|
||||
rm -f ./.depend
|
||||
$(CC) $(CFLAGS) -MM $^>>./.depend;
|
||||
|
||||
clean:
|
||||
$(RM) $(OBJS)
|
||||
$(RM) $(TARGET_LIB)
|
||||
|
||||
dist-clean: clean
|
||||
$(RM) *~ .depend
|
||||
|
||||
.PHONY: all depend clean dist-clean
|
||||
|
||||
include .depend
|
18
errors.c
Normal file
18
errors.c
Normal file
|
@ -0,0 +1,18 @@
|
|||
/* vim: set ts=8 sw=8 noexpandtab: */
|
||||
#include "errors.h"
|
||||
|
||||
static const struct mh_error_desc {
|
||||
int code;
|
||||
char *message;
|
||||
} mh_errordesc[] = {
|
||||
{ MH_E_UNKNOWN_CODE, "unknown multihash code" },
|
||||
{ MH_E_TOO_SHORT, "multihash too short. must be > 3 bytes" },
|
||||
{ MH_E_TOO_LONG, "multihash too long. must be < 129 bytes" },
|
||||
{ MH_E_LEN_NOT_SUPPORTED, "multihash does not yet support"
|
||||
" digests longer than 127 bytes" }
|
||||
};
|
||||
|
||||
const char *mh_error_string(mh_error code) {
|
||||
code += 1;
|
||||
return "";
|
||||
}
|
14
errors.h
Normal file
14
errors.h
Normal file
|
@ -0,0 +1,14 @@
|
|||
/* vim: set ts=8 sw=8 noexpandtab: */
|
||||
#ifndef ERROR_H
|
||||
#define ERROR_H
|
||||
|
||||
typedef enum {
|
||||
MH_E_UNKNOWN_CODE = -1,
|
||||
MH_E_TOO_SHORT = -2,
|
||||
MH_E_TOO_LONG = -3,
|
||||
MH_E_LEN_NOT_SUPPORTED = -4
|
||||
} mh_error;
|
||||
|
||||
const char *mh_error_string(mh_error code);
|
||||
|
||||
#endif /* end of include guard */
|
Loading…
Reference in a new issue