summaryrefslogtreecommitdiff
path: root/examples/hello_compatlib
diff options
context:
space:
mode:
Diffstat (limited to 'examples/hello_compatlib')
-rw-r--r--examples/hello_compatlib/Makefile5
-rw-r--r--examples/hello_compatlib/Makefile.inc1
-rw-r--r--examples/hello_compatlib/expect.out90
-rw-r--r--examples/hello_compatlib/libcmpt/Makefile3
-rw-r--r--examples/hello_compatlib/prog1/Makefile7
-rw-r--r--examples/hello_compatlib/prog1/prog1.c38
-rw-r--r--examples/hello_compatlib/prog2/Makefile7
-rw-r--r--examples/hello_compatlib/prog2/prog2.c24
-rw-r--r--examples/hello_compatlib/test.mk14
9 files changed, 189 insertions, 0 deletions
diff --git a/examples/hello_compatlib/Makefile b/examples/hello_compatlib/Makefile
new file mode 100644
index 0000000..82ec6b0
--- /dev/null
+++ b/examples/hello_compatlib/Makefile
@@ -0,0 +1,5 @@
+LIBDEPS = libcmpt:prog1 libcmpt:prog2
+COMPATLIB = libcmpt
+
+.include "test.mk"
+.include <mkc.subprj.mk>
diff --git a/examples/hello_compatlib/Makefile.inc b/examples/hello_compatlib/Makefile.inc
new file mode 100644
index 0000000..de1cf0d
--- /dev/null
+++ b/examples/hello_compatlib/Makefile.inc
@@ -0,0 +1 @@
+MKC_FEATURES = strlcpy strlcat getline progname fgetln err
diff --git a/examples/hello_compatlib/expect.out b/examples/hello_compatlib/expect.out
new file mode 100644
index 0000000..de509d4
--- /dev/null
+++ b/examples/hello_compatlib/expect.out
@@ -0,0 +1,90 @@
+=========== all ============
+/objdir/Makefile
+/objdir/Makefile.inc
+/objdir/_mkc_compiler_type.err
+/objdir/_mkc_compiler_type.res
+/objdir/_mkc_func0_getexecname_stdlib_h.c
+/objdir/_mkc_func0_getexecname_stdlib_h.err
+/objdir/_mkc_func0_getexecname_stdlib_h.res
+/objdir/_mkc_func0_getprogname_stdlib_h.c
+/objdir/_mkc_func0_getprogname_stdlib_h.err
+/objdir/_mkc_func0_getprogname_stdlib_h.res
+/objdir/_mkc_func1_setprogname_stdlib_h.c
+/objdir/_mkc_func1_setprogname_stdlib_h.err
+/objdir/_mkc_func1_setprogname_stdlib_h.res
+/objdir/_mkc_func3_err_err_h.c
+/objdir/_mkc_func3_err_err_h.err
+/objdir/_mkc_func3_err_err_h.res
+/objdir/_mkc_func3_errx_err_h.c
+/objdir/_mkc_func3_errx_err_h.err
+/objdir/_mkc_func3_errx_err_h.res
+/objdir/_mkc_func3_fgetln_stdio_h.c
+/objdir/_mkc_func3_fgetln_stdio_h.err
+/objdir/_mkc_func3_fgetln_stdio_h.res
+/objdir/_mkc_func3_getline_stdio_h.c
+/objdir/_mkc_func3_getline_stdio_h.err
+/objdir/_mkc_func3_getline_stdio_h.res
+/objdir/_mkc_func3_strlcat_string_h.c
+/objdir/_mkc_func3_strlcat_string_h.err
+/objdir/_mkc_func3_strlcat_string_h.res
+/objdir/_mkc_func3_strlcpy_string_h.c
+/objdir/_mkc_func3_strlcpy_string_h.err
+/objdir/_mkc_func3_strlcpy_string_h.res
+/objdir/_mkc_func3_verr_err_h.c
+/objdir/_mkc_func3_verr_err_h.err
+/objdir/_mkc_func3_verr_err_h.res
+/objdir/_mkc_func3_verrx_err_h.c
+/objdir/_mkc_func3_verrx_err_h.err
+/objdir/_mkc_func3_verrx_err_h.res
+/objdir/_mkc_funclib_err.c
+/objdir/_mkc_funclib_err.err
+/objdir/_mkc_funclib_err.res
+/objdir/_mkc_funclib_errx.c
+/objdir/_mkc_funclib_errx.err
+/objdir/_mkc_funclib_errx.res
+/objdir/_mkc_funclib_fgetln.c
+/objdir/_mkc_funclib_fgetln.err
+/objdir/_mkc_funclib_fgetln.res
+/objdir/_mkc_funclib_getline.c
+/objdir/_mkc_funclib_getline.err
+/objdir/_mkc_funclib_getline.res
+/objdir/_mkc_funclib_getprogname.c
+/objdir/_mkc_funclib_getprogname.err
+/objdir/_mkc_funclib_getprogname.res
+/objdir/_mkc_funclib_setprogname.c
+/objdir/_mkc_funclib_setprogname.err
+/objdir/_mkc_funclib_setprogname.res
+/objdir/_mkc_funclib_strlcat.c
+/objdir/_mkc_funclib_strlcat.err
+/objdir/_mkc_funclib_strlcat.res
+/objdir/_mkc_funclib_strlcpy.c
+/objdir/_mkc_funclib_strlcpy.err
+/objdir/_mkc_funclib_strlcpy.res
+/objdir/_mkc_funclib_verr.c
+/objdir/_mkc_funclib_verr.err
+/objdir/_mkc_funclib_verr.res
+/objdir/_mkc_funclib_verrx.c
+/objdir/_mkc_funclib_verrx.err
+/objdir/_mkc_funclib_verrx.res
+/objdir/_mkc_header_err_h.c
+/objdir/_mkc_header_err_h.err
+/objdir/_mkc_header_err_h.res
+/objdir/_mkc_prog_cc.err
+/objdir/_mkc_prog_cc.res
+/objdir/_mkc_variable_program_invocation_short_name_errno_h.c
+/objdir/_mkc_variable_program_invocation_short_name_errno_h.err
+/objdir/_mkc_variable_program_invocation_short_name_errno_h.res
+/objdir/expect.out
+/objdir/hello_compatlib.test.out.tmp
+/objdir/libcmpt/Makefile
+/objdir/libcmpt/libcmpt.a
+/objdir/libcmpt/libcmpt_pic.a
+/objdir/prog1/Makefile
+/objdir/prog1/prog1
+/objdir/prog1/prog1.c
+/objdir/prog1/prog1.o
+/objdir/prog2/Makefile
+/objdir/prog2/prog2
+/objdir/prog2/prog2.c
+/objdir/prog2/prog2.o
+/objdir/test.mk
diff --git a/examples/hello_compatlib/libcmpt/Makefile b/examples/hello_compatlib/libcmpt/Makefile
new file mode 100644
index 0000000..a0d0bda
--- /dev/null
+++ b/examples/hello_compatlib/libcmpt/Makefile
@@ -0,0 +1,3 @@
+LIB = cmpt
+
+.include <mkc.lib.mk>
diff --git a/examples/hello_compatlib/prog1/Makefile b/examples/hello_compatlib/prog1/Makefile
new file mode 100644
index 0000000..4a343d0
--- /dev/null
+++ b/examples/hello_compatlib/prog1/Makefile
@@ -0,0 +1,7 @@
+PROG = prog1
+
+WARNS = 4
+
+MKC_REQD = 0.27.0
+
+.include <mkc.prog.mk>
diff --git a/examples/hello_compatlib/prog1/prog1.c b/examples/hello_compatlib/prog1/prog1.c
new file mode 100644
index 0000000..b662024
--- /dev/null
+++ b/examples/hello_compatlib/prog1/prog1.c
@@ -0,0 +1,38 @@
+#include <stdio.h>
+#include <string.h>
+
+#include <mkc_strlcpy.h>
+#include <mkc_strlcat.h>
+#include <mkc_getline.h>
+#include <mkc_progname.h>
+
+static const char message [] = "Theo de Raadt said: \"The strlcpy() and strlcat() functions provide a consistent, unambiguous API to help the programmer write more bullet-proof code.\"";
+
+int main (int argc, char ** argv)
+{
+ char *buf = NULL;
+ size_t size = 0;
+ ssize_t len = 0;
+ char small_buf [15];
+ char said [19];
+
+ setprogname (argv [0]);
+
+ while (len = getline (&buf, &size, stdin), len != -1){
+ len = strlen (buf);
+ if (len > 0 && buf [len-1] == '\n')
+ buf [len-1] = 0;
+
+ strlcpy (small_buf, "foo17", sizeof (small_buf));
+ strlcat (small_buf, buf, sizeof (small_buf));
+ puts (small_buf);
+ }
+
+ strlcpy (said, message, sizeof (said));
+ puts (said);
+
+ printf ("short progname=%s\n", getprogname ());
+ printf ("full progname=%s\n", argv [0]);
+
+ return 0;
+}
diff --git a/examples/hello_compatlib/prog2/Makefile b/examples/hello_compatlib/prog2/Makefile
new file mode 100644
index 0000000..6cde3eb
--- /dev/null
+++ b/examples/hello_compatlib/prog2/Makefile
@@ -0,0 +1,7 @@
+PROG = prog2
+
+WARNS = 4
+
+MKC_REQD = 0.27.0
+
+.include <mkc.prog.mk>
diff --git a/examples/hello_compatlib/prog2/prog2.c b/examples/hello_compatlib/prog2/prog2.c
new file mode 100644
index 0000000..8a4f0fb
--- /dev/null
+++ b/examples/hello_compatlib/prog2/prog2.c
@@ -0,0 +1,24 @@
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+
+#include <mkc_fgetln.h>
+#include <mkc_err.h>
+
+int main (int argc, char ** argv)
+{
+ char *buf, *lbuf;
+ size_t len;
+
+ while ((lbuf = buf = fgetln (stdin, &len)) != NULL) {
+ if (len > 0 && buf [len - 1] == '\n')
+ buf[len - 1] = '\0';
+ else if ((lbuf = strndup (buf, len + 1)) == NULL)
+ err (1, NULL);
+ printf ("%s\n", lbuf);
+
+ if (lbuf != buf)
+ free (lbuf);
+ }
+ return 0;
+}
diff --git a/examples/hello_compatlib/test.mk b/examples/hello_compatlib/test.mk
new file mode 100644
index 0000000..425ad83
--- /dev/null
+++ b/examples/hello_compatlib/test.mk
@@ -0,0 +1,14 @@
+FUNCS_RE=(fgetln|progname|strlcat|strlcpy|getline)[.]o
+
+.PHONY : test_output
+test_output :
+ @set -e; \
+ echo =========== all ============; \
+ find ${.OBJDIR} -type f | grep -Ev '${FUNCS_RE}' | \
+ grep -vE 'libcmpt/.*[.]os?$$' | \
+ mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \
+ \
+ true =========== cleandir ============; \
+ ${MAKE} ${MAKEFLAGS} distclean > /dev/null
+
+.include <mkc.minitest.mk>