about summary refs log tree commit diff
diff options
context:
space:
mode:
authorNakidai <nakidai@disroot.org>2024-11-29 10:37:47 +0300
committerNakidai <nakidai@disroot.org>2024-11-29 10:37:47 +0300
commit9f5f94a729ecbd99a8d2adac29b107afa80574c6 (patch)
tree49798529314b60c31070b9cffe122cf0331565d3
parent2502543936a8523a24b630ca49b3185ebfd724d5 (diff)
downloadlibhttpc-9f5f94a729ecbd99a8d2adac29b107afa80574c6.tar.gz
libhttpc-9f5f94a729ecbd99a8d2adac29b107afa80574c6.zip
Add LibHTTPC_SOCK compile-time flag
-rw-r--r--Makefile6
-rwxr-xr-xconfigure11
-rw-r--r--include/config.h1
-rw-r--r--include/libhttpc.h4
-rw-r--r--src/response.c3
5 files changed, 20 insertions, 5 deletions
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 <stdlib.h>
 #include <stddef.h>
 #include <stdint.h>
@@ -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 <stddef.h>
@@ -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