From 9f5f94a729ecbd99a8d2adac29b107afa80574c6 Mon Sep 17 00:00:00 2001 From: Nakidai Date: Fri, 29 Nov 2024 10:37:47 +0300 Subject: Add LibHTTPC_SOCK compile-time flag --- Makefile | 6 +++--- configure | 11 +++++++++-- include/config.h | 1 + include/libhttpc.h | 4 ++++ src/response.c | 3 +++ 5 files changed, 20 insertions(+), 5 deletions(-) create mode 100644 include/config.h diff --git a/Makefile b/Makefile index 86265ce..d99eef5 100644 --- a/Makefile +++ b/Makefile @@ -27,14 +27,14 @@ libhttpc.a: ar rcs $@ $^ install: all - install -d $(DESTDIR)/lib + install -d $(DESTDIR)/lib ${DESTDIR}/include/libhttpc install -m644 libhttpc.a $(DESTDIR)/lib install -m755 libhttpc.so $(DESTDIR)/lib - install -m644 include/libhttpc.h $(DESTDIR)/include + install -m644 include/{config,libhttpc}.h $(DESTDIR)/include uninstall: $(RM) $(DESTDIR)/lib/libhttpc.{a,so} - $(RM) $(DESTDIR)/include/libhttpc.h + $(RM) $(DESTDIR)/include/libhttpc/{config,libhttpc}.h clean: rm -f ${OBJS} libhttpc.a libhttpc.so diff --git a/configure b/configure index fab6a12..0dc8210 100755 --- a/configure +++ b/configure @@ -6,7 +6,8 @@ usage() CC - compiler (default: cc) CFLAGS - flags for compiler LDFLAGS - flags for linker - DESTDIR - path to make install (default: /usr/local)" + DESTDIR - path to make install (default: /usr/local) + NOSOCK - set to cut part of libhttpc that works with sockets" exit 1 } @@ -29,8 +30,14 @@ echo "Configuration: Compiler: $CC CFLAGS: $CFLAGS LDFLAGS: $LDFLAGS - DESTDIR: $DESTDIR" + DESTDIR: $DESTDIR + NOSOCK: ${NOSOCK:-not set}" echo " DESTDIR=$DESTDIR " > config.mk + +echo > include/config.h +if [ -z "$NOSOCK" ]; then + echo "#define LibHTTPC_SOCK" > include/config.h +fi diff --git a/include/config.h b/include/config.h new file mode 100644 index 0000000..ddbd399 --- /dev/null +++ b/include/config.h @@ -0,0 +1 @@ +#define LibHTTPC_SOCK diff --git a/include/libhttpc.h b/include/libhttpc.h index 702a662..de45b9f 100644 --- a/include/libhttpc.h +++ b/include/libhttpc.h @@ -1,6 +1,8 @@ #ifndef __LIBHTTPC_H__ #define __LIBHTTPC_H__ +#include "config.h" + #include #include #include @@ -273,6 +275,7 @@ char *LibHTTPC_dumpResponse(struct LibHTTPC_Response *response, char *buf, size_ */ int LibHTTPC_Request_(struct LibHTTPC_Request *request); +#ifdef LibHTTPC_SOCK /** * Not implemented yet */ @@ -286,5 +289,6 @@ struct LibHTTPC_Request *LibHTTPC_readRequest( * Not implemented yet */ int LibHTTPC_writeResponse(int sockfd, struct LibHTTPC_Response *response); +#endif #endif /* __LIBHTTPC_H__ */ diff --git a/src/response.c b/src/response.c index 6776da3..b930fc6 100644 --- a/src/response.c +++ b/src/response.c @@ -1,3 +1,4 @@ +#include "config.h" #include "libhttpc.h" #include @@ -49,6 +50,7 @@ char *LibHTTPC_dumpResponse(struct LibHTTPC_Response *response, char *buf, size_ return NULL; } +#ifdef LibHTTPC_SOCK int LibHTTPC_writeResponse(int sockfd, struct LibHTTPC_Response *response) { char status[10]; @@ -73,3 +75,4 @@ int LibHTTPC_writeResponse(int sockfd, struct LibHTTPC_Response *response) return 0; } +#endif -- cgit 1.4.1