diff options
| -rw-r--r-- | .gitignore | 2 | ||||
| -rw-r--r-- | Makefile | 32 | ||||
| -rw-r--r-- | ark_string.c | 17 | ||||
| -rw-r--r-- | arktixord.c | 0 | ||||
| -rw-r--r-- | arktixord.h | 12 |
5 files changed, 63 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9d22eb4 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +*.o +*.so diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..e5e8c89 --- /dev/null +++ b/Makefile @@ -0,0 +1,32 @@ +AVER=1 +SRCA=arktixord.c +SRC=ark_string.c +OBJ=$(SRCA:%.c=%.o) +OBJ+=$(SRC:%.c=%.o) +INCDIR=/usr/local/include +LIBDIR=/usr/local/lib + +default: install + +install: libarktixord.so arktixord.h + install -v -m644 ./arktixord.h $(INCDIR)/arktixord.h + install -v -m755 -s ./libarktixord.so $(LIBDIR)/libarktixord.so.$(AVER) + ln -sf $(LIBDIR)/libarktixord.so.1 $(LIBDIR)/libarktixord.so + ldconfig + +libarktixord.so: $(OBJ) arktixord.h + gcc $(LDFLAGS) $(LDLIBS) -shared -o $@ $^ + +%.o: %.c + gcc $(CFLAGS) -c -fPIC $< -o $@ + +clean: + rm -f *.o libarktixord.so + +uninstall: + sudo rm -rf $(INCDIR)/arktixord.h + sudo rm -rf $(LIBDIR)/libarktixord.so + sudo rm -rf $(LIBDIR)/libarktixord.so.$(AVER) + ldconfig + +.PHONY: default lib install clean diff --git a/ark_string.c b/ark_string.c new file mode 100644 index 0000000..19ea175 --- /dev/null +++ b/ark_string.c @@ -0,0 +1,17 @@ +#include "arktixord.h" + +#include <stdio.h> +#include <string.h> +#include <asm-generic/errno-base.h> + +int +ark_check_str_in_array(const char *str, const char *array[], ssize_t array_size) +{ + for (ssize_t i = 0; i < array_size; ++i) { + if (!strcmp(str, array[i])) { + return 1; + } + } + + return 0; +} diff --git a/arktixord.c b/arktixord.c new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/arktixord.c diff --git a/arktixord.h b/arktixord.h new file mode 100644 index 0000000..1dc4c1a --- /dev/null +++ b/arktixord.h @@ -0,0 +1,12 @@ +#ifndef _ARKTIXORD_H +#define _ARKTIXORD_H + +#include <stdio.h> + +#define ARK_CHK_STR_IN_ARR(string, array) \ + ark_check_str_in_array((string), (array), (sizeof(array)/sizeof(array[0]))) + +int +ark_check_str_in_array(const char *str, const char **array, ssize_t array_size); + +#endif /* _ARKTIXORD_H */ |
