commit - 873716fa3610403d77fc93fdadb599b66e240f2e
commit + 9981e8e3868ca975b4732becdc01897770c0dfbe
blob - 93b03019f080922a7b1ede96f4a85eaad1db446f
blob + 936a5aaebb079956bc57cd01d75c87d0de697c5b
--- .gitignore
+++ .gitignore
**/Makefile
**/Makefile.in
**/Makefile.linux
+**/autom4te.cache/*
+**/compile
**/core
+**/depcomp
+**/install-sh
+**/missing
**/obj
**/tags
+**/ylwrap
.ccls-cache/*
.deps/*
Makefile.common
aclocal.m4
-autom4te.cache/*
config.log
config.status
configure
blob - /dev/null
blob + cb22b6f52cad3fa05f5724b548c6977192539497 (mode 644)
--- /dev/null
+++ compat/err.c
+/*
+ * Copyright (c) 2021 Omar Polo <op@omarpolo.com>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <errno.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+static void vwarn_impl(const char*, va_list);
+static void vwarnx_impl(const char*, va_list);
+
+static void
+vwarn_impl(const char *fmt, va_list ap)
+{
+ fprintf(stderr, "%s: ", getprogname());
+ vfprintf(stderr, fmt, ap);
+ fprintf(stderr, ": %s\n", strerror(errno));
+}
+
+static void
+vwarnx_impl(const char *fmt, va_list ap)
+{
+ fprintf(stderr, "%s: ", getprogname());
+ vfprintf(stderr, fmt, ap);
+ fprintf(stderr, "\n");
+}
+
+void
+err(int ret, const char *fmt, ...)
+{
+ va_list ap;
+
+ va_start(ap, fmt);
+ vwarn_impl(fmt, ap);
+ va_end(ap);
+ exit(ret);
+}
+
+void
+errx(int ret, const char *fmt, ...)
+{
+ va_list ap;
+
+ va_start(ap, fmt);
+ vwarnx_impl(fmt, ap);
+ va_end(ap);
+ exit(ret);
+}
+
+void
+warn(const char *fmt, ...)
+{
+ va_list ap;
+
+ va_start(ap, fmt);
+ vwarn_impl(fmt, ap);
+ va_end(ap);
+}
+
+void
+warnx(const char *fmt, ...)
+{
+ va_list ap;
+
+ va_start(ap, fmt);
+ vwarnx_impl(fmt, ap);
+ va_end(ap);
+}
blob - bc88ff14ca0d942dc8c318f895e0e738dd31bcc8
blob + c5a53b6ea185332cdf43928dc0fab4be1f31e775
--- configure.ac
+++ configure.ac
AC_USE_SYSTEM_EXTENSIONS
AC_CANONICAL_HOST
+AC_CONFIG_SUBDIRS([template])
+
# When CFLAGS isn't set at this stage and gcc is detected by the macro below,
# autoconf will automatically use CFLAGS="-O2 -g". Prevent that by using an
# empty default.
got/Makefile
gotadmin/Makefile
gotwebd/Makefile
- template/Makefile
tog/Makefile
Makefile.common:Makefile.common.in])
AC_OUTPUT
blob - 3044a18a6e2658e4cdeacda423f6eba7db986eba
blob + 149154cf25f714ed73475c0efb0f743378e7360f
--- template/Makefile.am
+++ template/Makefile.am
noinst_PROGRAMS = template
-include $(top_builddir)/Makefile.common
-
template_SOURCES = template.c \
parse.y
-template_DEPENDENCIES = $(top_builddir)/compat/libopenbsd-compat.a
+EXTRA_DIST = got_compat.h
-LDADD = -L$(top_builddir)/compat -lopenbsd-compat -lpthread -lm
-if HOST_FREEBSD
-LDADD += -lmd
-endif
+LDADD = $(LIBOBJS)
blob - /dev/null
blob + bd7a2184fd73cfb5a1ece5f92428ce2c6d7c726e (mode 644)
--- /dev/null
+++ template/configure.ac
+AC_INIT([template], 1.0, [op@openbsd.org])
+AC_CONFIG_LIBOBJ_DIR(../compat)
+AM_INIT_AUTOMAKE([foreign subdir-objects])
+
+AC_ARG_VAR(HOSTCC, [The C compiler on the host.])
+AC_ARG_VAR(HOSTCFLAGS, [CFLAGS for the host compiler])
+
+# When CFLAGS isn't set at this stage and gcc is detected by the macro below,
+# autoconf will automatically use CFLAGS="-O2 -g". Prevent that by using an
+# empty default.
+: ${CFLAGS=""}
+
+# Save user CPPFLAGS, CFLAGS and LDFLAGS. We need to change them because
+# AC_CHECK_HEADER doesn't give us any other way to update the include
+# paths. But for Makefile.am we want to use AM_CPPFLAGS and friends.
+SAVED_CFLAGS="$CFLAGS"
+
+test -n "$HOSTCC" && export CC="$HOSTCC"
+test -n "$HOSTCFLAGS" && export CFLAGS="$SAVED_CFLAGS $HOSTCFLAGS"
+
+AC_PROG_CC
+AC_PROG_YACC
+
+AM_CPPFLAGS="$CFLAGS"
+
+AC_REPLACE_FUNCS([ \
+ asprintf \
+ err \
+ getprogname \
+ reallocarray \
+])
+
+AC_CHECK_DECL([TAILQ_REMOVE], [],
+ [AC_MSG_ERROR("*** sys/queue.h is missing key defines ***")],
+ [#include <sys/queue.h>])
+
+AC_CONFIG_FILES([Makefile])
+AC_OUTPUT
blob - /dev/null
blob + dd279faa3b8ed1fae16502ebb13b5a59c92c0529 (mode 644)
--- /dev/null
+++ template/got_compat.h
+/*
+ * Copyright (c) 2022 Omar Polo <op@openbsd.org>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifndef COMPAT_H
+#define COMPAT_H
+
+#ifndef __OpenBSD__
+#define pledge(s, p) (0)
+#define unveil(s, p) (0)
+#endif
+
+#ifndef __dead
+#define __dead __attribute__((__noreturn__))
+#endif
+
+#ifndef HAVE_ASPRINTF
+int asprintf(char **, const char *, ...);
+int vasprintf(char **, const char *, va_list);
+#endif
+
+#ifndef HAVE_ERR
+__dead void err(int, const char *, ...);
+__dead void errx(int, const char *, ...);
+void warn(const char *, ...);
+void warnx(const char *, ...);
+#else
+# include <err.h>
+#endif
+
+#ifndef HAVE_GETPROGNAME
+const char *getprogname(void);
+#endif
+
+#ifndef HAVE_REALLOCARRAY
+void *reallocarray(void *, size_t, size_t);
+#endif
+
+#endif
blob - 0c5031c03e0b09bc23862db57030475dcd114da4
blob + 5ef632aa276741156a37a4dee515535102bad542
--- template/template.c
+++ template/template.c
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-#include <err.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>