aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorAleksey Veresov <aleksey@veresov.pro>2020-02-06 11:27:59 +0300
committerAleksey Veresov <aleksey@veresov.pro>2020-02-06 11:27:59 +0300
commitfca83975899b01c62ede4258f175346b7039be3d (patch)
tree37c2bb8faf95de1252a97942a68183f795eb82a0 /examples
parent8ef310a22a54dca7a80947f83f03bc296ab298dd (diff)
parent746c3f3076fe5994f08d729aa1b958465231b0c8 (diff)
downloadmagi-fca83975899b01c62ede4258f175346b7039be3d.tar
magi-fca83975899b01c62ede4258f175346b7039be3d.tar.xz
magi-fca83975899b01c62ede4258f175346b7039be3d.zip
Merge branch 'master' into test
Diffstat (limited to 'examples')
-rw-r--r--examples/Makefile31
-rw-r--r--examples/echo.c4
-rw-r--r--examples/upload.c1
3 files changed, 26 insertions, 10 deletions
diff --git a/examples/Makefile b/examples/Makefile
index d93176b..2f57b1e 100644
--- a/examples/Makefile
+++ b/examples/Makefile
@@ -1,29 +1,48 @@
-# Uncomment following to enable debug mode:
+# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
+# Compilation Options
+# Debug mode (allowing to debug the examples via gdb):
# DEBUG = yes
-
+# Specify your favourite C compiler here (e.g. tcc):
CC = gcc
+
+
+# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
+# Preparations
EXAMPLES = append cookie upload echo
+# Compile under the most strict conditions:
CFLAGS = -xc -ansi -pedantic -Wall
+# Debug and optimisation are not compatible:
ifeq '$(DEBUG)' 'yes'
CFLAGS += -g -O0
else
CFLAGS += -O3
endif
+# Including magi library headers and setting linker to use it:
INCLUDE = -I ../src
LFLAGS = -L.. -lmagi
+# Specification of library file to produce it, if not provided:
MAGI = ../libmagi.a
+# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
+# Targets
+# 'make' produces all examples by default:
default: $(EXAMPLES)
-$(MAGI):
- cd ..; $(MAKE)
+# Cleaning means removing everything automatically produced:
+clean:
+ rm -f $(EXAMPLES)
+
+# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
+# Compilation
+# Compile executables from corresponding sources and library:
%: %.c $(MAGI)
$(CC) $(CFLAGS) $(INCLUDE) $< $(LFLAGS) -o $@
-clean:
- rm -f $(EXAMPLES)
+# Run make for library to produce it:
+$(MAGI):
+ cd ..; $(MAKE)
diff --git a/examples/echo.c b/examples/echo.c
index 81bdcf4..f665cd0 100644
--- a/examples/echo.c
+++ b/examples/echo.c
@@ -16,10 +16,6 @@ void proceed_cookies(magi_cookie_list *cookies, magi_response *response)
magi_response_add(response, "] for domain [");
magi_response_add(response, cookies->item.domain);
}
- if (cookies->item.port) {
- magi_response_add(response, "] for port [");
- magi_response_add(response, cookies->item.port);
- }
if (cookies->item.path) {
magi_response_add(response, "] for path [");
magi_response_add(response, cookies->item.path);
diff --git a/examples/upload.c b/examples/upload.c
index 6a3a7a4..19e045c 100644
--- a/examples/upload.c
+++ b/examples/upload.c
@@ -43,6 +43,7 @@ int main(int argc, char const *argv[])
} else {
magi_error_cgi(request.error);
}
+ magi_tempfiles_destroy(&tmps);
magi_request_destroy(&request);
return 0;
}