summary refs log tree commit diff
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2022-06-18 10:03:57 -0400
committerJune McEnroe <june@causal.agency>2022-06-18 10:03:57 -0400
commit511f999dfab4fce8d31af9c388d616ce45a88398 (patch)
treecb96078d99295f62b1d25af3329b84ac2897df04
parentedit: Validate size is power of two (diff)
downloadpounce-511f999dfab4fce8d31af9c388d616ce45a88398.tar.gz
pounce-511f999dfab4fce8d31af9c388d616ce45a88398.zip
Flatten extras to top-level directory
-rw-r--r--.gitignore3
-rw-r--r--Makefile19
-rwxr-xr-xconfigure6
-rw-r--r--edit.c (renamed from extra/edit/edit.c)0
-rw-r--r--extra/edit/.gitignore3
-rw-r--r--extra/edit/Makefile28
-rwxr-xr-xextra/edit/configure44
-rw-r--r--extra/edit/xdg.c129
-rw-r--r--extra/notify/.gitignore3
-rw-r--r--extra/notify/Makefile28
-rwxr-xr-xextra/notify/configure44
-rw-r--r--extra/palaver/.gitignore3
-rw-r--r--extra/palaver/Makefile30
-rwxr-xr-xextra/palaver/configure45
-rw-r--r--notify.c (renamed from extra/notify/notify.c)0
-rw-r--r--palaver.c (renamed from extra/palaver/notify.c)0
-rw-r--r--pounce-edit.1 (renamed from extra/edit/pounce-edit.1)0
-rw-r--r--pounce-notify.1 (renamed from extra/notify/pounce-notify.1)0
-rw-r--r--pounce-palaver.1 (renamed from extra/palaver/pounce-palaver.1)0
19 files changed, 26 insertions, 359 deletions
diff --git a/.gitignore b/.gitignore
index 882cf40..5249f84 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,4 +4,7 @@ calico
 config.mk
 localhost.pem
 pounce
+pounce-edit
+pounce-notify
+pounce-palaver
 tags
diff --git a/Makefile b/Makefile
index ac9c045..029d184 100644
--- a/Makefile
+++ b/Makefile
@@ -4,7 +4,9 @@ MANDIR ?= ${PREFIX}/man
 
 CFLAGS += -std=c11 -Wall -Wextra -Wpedantic
 LDADD.crypt = -lcrypt
+LDADD.libcurl = -lcurl
 LDADD.libtls = -ltls
+LDADD.sqlite3 = -lsqlite3
 
 BINS = calico pounce
 MANS = ${BINS:=.1}
@@ -13,6 +15,9 @@ MANS = ${BINS:=.1}
 
 LDLIBS.calico =
 LDLIBS.pounce = ${LDADD.crypt} ${LDADD.libtls}
+LDLIBS.pounce-edit = ${LDADD.libtls}
+LDLIBS.pounce-notify = ${LDADD.libtls}
+LDLIBS.pounce-palaver = ${LDADD.libcurl} ${LDADD.libtls} ${LDADD.sqlite3}
 
 OBJS.calico += dispatch.o
 
@@ -25,15 +30,25 @@ OBJS.pounce += server.o
 OBJS.pounce += state.o
 OBJS.pounce += xdg.o
 
-OBJS = ${OBJS.calico} ${OBJS.pounce}
+OBJS.pounce-edit = edit.o xdg.o
+OBJS.pounce-notify = notify.o
+OBJS.pounce-palaver = palaver.o
+
+OBJS += ${OBJS.calico}
+OBJS += ${OBJS.pounce}
+OBJS += ${OBJS.pounce-edit}
+OBJS += ${OBJS.pounce-notify}
+OBJS += ${OBJS.pounce-palaver}
 
 dev: tags all
 
 all: ${BINS}
 
 calico: ${OBJS.calico}
-
 pounce: ${OBJS.pounce}
+pounce-edit: ${OBJS.pounce-edit}
+pounce-notify: ${OBJS.pounce-notify}
+pounce-palaver: ${OBJS.pounce-palaver}
 
 ${BINS}:
 	${CC} ${LDFLAGS} ${OBJS.$@} ${LDLIBS.$@} -o $@
diff --git a/configure b/configure
index 1d94084..62a3c1a 100755
--- a/configure
+++ b/configure
@@ -27,6 +27,12 @@ for opt; do
 		(--prefix=*) echo "PREFIX = ${opt#*=}" ;;
 		(--bindir=*) echo "BINDIR = ${opt#*=}" ;;
 		(--mandir=*) echo "MANDIR = ${opt#*=}" ;;
+		(--enable-edit)	echo 'BINS += pounce-edit' ;;
+		(--enable-notify) echo 'BINS += pounce-notify' ;;
+		(--enable-palaver)
+			echo 'BINS += pounce-palaver'
+			config libcurl sqlite3
+			;;
 		(*) echo "warning: unsupported option ${opt}" >&2 ;;
 	esac
 done
diff --git a/extra/edit/edit.c b/edit.c
index 793e413..793e413 100644
--- a/extra/edit/edit.c
+++ b/edit.c
diff --git a/extra/edit/.gitignore b/extra/edit/.gitignore
deleted file mode 100644
index 626888d..0000000
--- a/extra/edit/.gitignore
+++ /dev/null
@@ -1,3 +0,0 @@
-*.o
-config.mk
-pounce-edit
diff --git a/extra/edit/Makefile b/extra/edit/Makefile
deleted file mode 100644
index 8bac3a6..0000000
--- a/extra/edit/Makefile
+++ /dev/null
@@ -1,28 +0,0 @@
-PREFIX ?= /usr/local
-BINDIR ?= ${PREFIX}/bin
-MANDIR ?= ${PREFIX}/man
-
-CFLAGS += -std=c11 -Wall -Wextra -Wpedantic
-LDADD.libtls = -ltls
-
--include config.mk
-
-LDLIBS = ${LDADD.libtls}
-OBJS = edit.o xdg.o
-
-all: pounce-edit
-
-pounce-edit: ${OBJS}
-	${CC} ${LDFLAGS} ${OBJS} ${LDLIBS} -o $@
-
-clean:
-	rm -f ${OBJS} pounce-edit
-
-install: pounce-edit pounce-edit.1
-	install -d ${DESTDIR}${BINDIR} ${DESTDIR}${MANDIR}/man1
-	install pounce-edit ${DESTDIR}${BINDIR}
-	install -m 644 pounce-edit.1 ${DESTDIR}${MANDIR}/man1
-
-uninstall:
-	rm -f ${DESTDIR}${BINDIR}/pounce-edit
-	rm -f ${DESTDIR}${MANDIR}/man1/pounce-edit.1
diff --git a/extra/edit/configure b/extra/edit/configure
deleted file mode 100755
index e180aa5..0000000
--- a/extra/edit/configure
+++ /dev/null
@@ -1,44 +0,0 @@
-#!/bin/sh
-set -eu
-
-cflags() {
-	echo "CFLAGS += $*"
-}
-defstr() {
-	cflags "-D'$1=\"$2\"'"
-}
-defvar() {
-	defstr "$1" "$(pkg-config --variable=$3 $2)${4:-}"
-}
-ldadd() {
-	lib=$1; shift
-	echo "LDADD.${lib} = $*"
-}
-config() {
-	pkg-config --print-errors "$@"
-	cflags $(pkg-config --cflags "$@")
-	for lib; do ldadd $lib $(pkg-config --libs $lib); done
-}
-
-exec >config.mk
-
-for opt; do
-	case "${opt}" in
-		(--prefix=*) echo "PREFIX = ${opt#*=}" ;;
-		(--bindir=*) echo "BINDIR = ${opt#*=}" ;;
-		(--mandir=*) echo "MANDIR = ${opt#*=}" ;;
-		(*) echo "warning: unsupported option ${opt}" >&2 ;;
-	esac
-done
-
-case "$(uname)" in
-	(OpenBSD)
-		;;
-	(Linux)
-		cflags -D_GNU_SOURCE
-		config libtls
-		;;
-	(*)
-		config libtls
-		;;
-esac
diff --git a/extra/edit/xdg.c b/extra/edit/xdg.c
deleted file mode 100644
index b9015b2..0000000
--- a/extra/edit/xdg.c
+++ /dev/null
@@ -1,129 +0,0 @@
-/* Copyright (C) 2019, 2020  June McEnroe <june@causal.agency>
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <https://www.gnu.org/licenses/>.
- *
- * Additional permission under GNU GPL version 3 section 7:
- *
- * If you modify this Program, or any covered work, by linking or
- * combining it with OpenSSL (or a modified version of that library),
- * containing parts covered by the terms of the OpenSSL License and the
- * original SSLeay license, the licensors of this Program grant you
- * additional permission to convey the resulting work. Corresponding
- * Source for a non-source form of such a combination shall include the
- * source code for the parts of OpenSSL used as well as that of the
- * covered work.
- */
-
-#include <err.h>
-#include <errno.h>
-#include <limits.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/stat.h>
-#include <sysexits.h>
-
-#define SUBDIR "pounce"
-
-struct Base {
-	const char *envHome;
-	const char *envDirs;
-	const char *defHome;
-	const char *defDirs;
-};
-
-static const struct Base Config = {
-	.envHome = "XDG_CONFIG_HOME",
-	.envDirs = "XDG_CONFIG_DIRS",
-	.defHome = ".config",
-	.defDirs = "/etc/xdg",
-};
-
-static const struct Base Data = {
-	.envHome = "XDG_DATA_HOME",
-	.envDirs = "XDG_DATA_DIRS",
-	.defHome = ".local/share",
-	.defDirs = "/usr/local/share:/usr/share",
-};
-
-static char *basePath(
-	struct Base base, char *buf, size_t cap, const char *path, int i
-) {
-	if (path[strspn(path, ".")] == '/') {
-		if (i > 0) return NULL;
-		snprintf(buf, cap, "%s", path);
-		return buf;
-	}
-
-	if (i > 0) {
-		const char *dirs = getenv(base.envDirs);
-		if (!dirs) dirs = base.defDirs;
-		for (; i > 1; --i) {
-			dirs += strcspn(dirs, ":");
-			dirs += (*dirs == ':');
-		}
-		if (!*dirs) return NULL;
-		snprintf(
-			buf, cap, "%.*s/" SUBDIR "/%s",
-			(int)strcspn(dirs, ":"), dirs, path
-		);
-		return buf;
-	}
-
-	const char *home = getenv("HOME");
-	const char *baseHome = getenv(base.envHome);
-	if (baseHome) {
-		snprintf(buf, cap, "%s/" SUBDIR "/%s", baseHome, path);
-	} else if (home) {
-		snprintf(buf, cap, "%s/%s/" SUBDIR "/%s", home, base.defHome, path);
-	} else {
-		errx(EX_USAGE, "HOME unset");
-	}
-	return buf;
-}
-
-char *configPath(char *buf, size_t cap, const char *path, int i) {
-	return basePath(Config, buf, cap, path, i);
-}
-
-char *dataPath(char *buf, size_t cap, const char *path, int i) {
-	return basePath(Data, buf, cap, path, i);
-}
-
-FILE *configOpen(const char *path, const char *mode) {
-	char buf[PATH_MAX];
-	for (int i = 0; configPath(buf, sizeof(buf), path, i); ++i) {
-		FILE *file = fopen(buf, mode);
-		if (file) return file;
-		if (errno != ENOENT) warn("%s", buf);
-	}
-	warn("%s", configPath(buf, sizeof(buf), path, 0));
-	return NULL;
-}
-
-FILE *dataOpen(const char *path, const char *mode) {
-	char buf[PATH_MAX];
-	for (int i = 0; dataPath(buf, sizeof(buf), path, i); ++i) {
-		FILE *file = fopen(buf, mode);
-		if (file) return file;
-		if (errno != ENOENT) warn("%s", buf);
-	}
-	if (mode[0] != 'r') {
-		int error = mkdir(dataPath(buf, sizeof(buf), "", 0), S_IRWXU);
-		if (error && errno != EEXIST) warn("%s", buf);
-	}
-	FILE *file = fopen(dataPath(buf, sizeof(buf), path, 0), mode);
-	if (!file) warn("%s", buf);
-	return file;
-}
diff --git a/extra/notify/.gitignore b/extra/notify/.gitignore
deleted file mode 100644
index acd29ee..0000000
--- a/extra/notify/.gitignore
+++ /dev/null
@@ -1,3 +0,0 @@
-*.o
-config.mk
-pounce-notify
diff --git a/extra/notify/Makefile b/extra/notify/Makefile
deleted file mode 100644
index 5e8ed93..0000000
--- a/extra/notify/Makefile
+++ /dev/null
@@ -1,28 +0,0 @@
-PREFIX ?= /usr/local
-BINDIR ?= ${PREFIX}/bin
-MANDIR ?= ${PREFIX}/man
-
-CFLAGS += -std=c11 -Wall -Wextra -Wpedantic
-LDADD.libtls = -ltls
-
--include config.mk
-
-LDLIBS = ${LDADD.libtls}
-OBJS = notify.o
-
-all: pounce-notify
-
-pounce-notify: ${OBJS}
-	${CC} ${LDFLAGS} ${OBJS} ${LDLIBS} -o $@
-
-clean:
-	rm -f ${OBJS} pounce-notify
-
-install: pounce-notify pounce-notify.1
-	install -d ${DESTDIR}${BINDIR} ${DESTDIR}${MANDIR}/man1
-	install pounce-notify ${DESTDIR}${BINDIR}
-	install -m 644 pounce-notify.1 ${DESTDIR}${MANDIR}/man1
-
-uninstall:
-	rm -f ${DESTDIR}${BINDIR}/pounce-notify
-	rm -f ${DESTDIR}${MANDIR}/man1/pounce-notify.1
diff --git a/extra/notify/configure b/extra/notify/configure
deleted file mode 100755
index e180aa5..0000000
--- a/extra/notify/configure
+++ /dev/null
@@ -1,44 +0,0 @@
-#!/bin/sh
-set -eu
-
-cflags() {
-	echo "CFLAGS += $*"
-}
-defstr() {
-	cflags "-D'$1=\"$2\"'"
-}
-defvar() {
-	defstr "$1" "$(pkg-config --variable=$3 $2)${4:-}"
-}
-ldadd() {
-	lib=$1; shift
-	echo "LDADD.${lib} = $*"
-}
-config() {
-	pkg-config --print-errors "$@"
-	cflags $(pkg-config --cflags "$@")
-	for lib; do ldadd $lib $(pkg-config --libs $lib); done
-}
-
-exec >config.mk
-
-for opt; do
-	case "${opt}" in
-		(--prefix=*) echo "PREFIX = ${opt#*=}" ;;
-		(--bindir=*) echo "BINDIR = ${opt#*=}" ;;
-		(--mandir=*) echo "MANDIR = ${opt#*=}" ;;
-		(*) echo "warning: unsupported option ${opt}" >&2 ;;
-	esac
-done
-
-case "$(uname)" in
-	(OpenBSD)
-		;;
-	(Linux)
-		cflags -D_GNU_SOURCE
-		config libtls
-		;;
-	(*)
-		config libtls
-		;;
-esac
diff --git a/extra/palaver/.gitignore b/extra/palaver/.gitignore
deleted file mode 100644
index d92ce2e..0000000
--- a/extra/palaver/.gitignore
+++ /dev/null
@@ -1,3 +0,0 @@
-*.o
-config.mk
-pounce-palaver
diff --git a/extra/palaver/Makefile b/extra/palaver/Makefile
deleted file mode 100644
index fbf10df..0000000
--- a/extra/palaver/Makefile
+++ /dev/null
@@ -1,30 +0,0 @@
-PREFIX ?= /usr/local
-BINDIR ?= ${PREFIX}/bin
-MANDIR ?= ${PREFIX}/man
-
-CFLAGS += -std=c11 -Wall -Wextra -Wpedantic
-LDADD.libcurl = -lcurl
-LDADD.libtls = -ltls
-LDADD.sqlite3 = -lsqlite3
-
--include config.mk
-
-LDLIBS = ${LDADD.libcurl} ${LDADD.libtls} ${LDADD.sqlite3}
-OBJS = notify.o
-
-all: pounce-palaver
-
-pounce-palaver: ${OBJS}
-	${CC} ${LDFLAGS} ${OBJS} ${LDLIBS} -o $@
-
-clean:
-	rm -f ${OBJS} pounce-palaver
-
-install: pounce-palaver pounce-palaver.1
-	install -d ${DESTDIR}${BINDIR} ${DESTDIR}${MANDIR}/man1
-	install pounce-palaver ${DESTDIR}${BINDIR}
-	install -m 644 pounce-palaver.1 ${DESTDIR}${MANDIR}/man1
-
-uninstall:
-	rm -f ${DESTDIR}${BINDIR}/pounce-palaver
-	rm -f ${DESTDIR}${MANDIR}/man1/pounce-palaver.1
diff --git a/extra/palaver/configure b/extra/palaver/configure
deleted file mode 100755
index bce92be..0000000
--- a/extra/palaver/configure
+++ /dev/null
@@ -1,45 +0,0 @@
-#!/bin/sh
-set -eu
-
-cflags() {
-	echo "CFLAGS += $*"
-}
-defstr() {
-	cflags "-D'$1=\"$2\"'"
-}
-defvar() {
-	defstr "$1" "$(pkg-config --variable=$3 $2)${4:-}"
-}
-ldadd() {
-	lib=$1; shift
-	echo "LDADD.${lib} = $*"
-}
-config() {
-	pkg-config --print-errors "$@"
-	cflags $(pkg-config --cflags "$@")
-	for lib; do ldadd $lib $(pkg-config --libs $lib); done
-}
-
-exec >config.mk
-
-for opt; do
-	case "${opt}" in
-		(--prefix=*) echo "PREFIX = ${opt#*=}" ;;
-		(--bindir=*) echo "BINDIR = ${opt#*=}" ;;
-		(--mandir=*) echo "MANDIR = ${opt#*=}" ;;
-		(*) echo "warning: unsupported option ${opt}" >&2 ;;
-	esac
-done
-
-case "$(uname)" in
-	(OpenBSD)
-		config libcurl sqlite3
-		;;
-	(Linux)
-		cflags -D_GNU_SOURCE
-		config libcurl libtls sqlite3
-		;;
-	(*)
-		config libcurl libtls sqlite3
-		;;
-esac
diff --git a/extra/notify/notify.c b/notify.c
index 935ba26..935ba26 100644
--- a/extra/notify/notify.c
+++ b/notify.c
diff --git a/extra/palaver/notify.c b/palaver.c
index 36e4ae1..36e4ae1 100644
--- a/extra/palaver/notify.c
+++ b/palaver.c
diff --git a/extra/edit/pounce-edit.1 b/pounce-edit.1
index 36c59aa..36c59aa 100644
--- a/extra/edit/pounce-edit.1
+++ b/pounce-edit.1
diff --git a/extra/notify/pounce-notify.1 b/pounce-notify.1
index 628bc25..628bc25 100644
--- a/extra/notify/pounce-notify.1
+++ b/pounce-notify.1
diff --git a/extra/palaver/pounce-palaver.1 b/pounce-palaver.1
index da3937a..da3937a 100644
--- a/extra/palaver/pounce-palaver.1
+++ b/pounce-palaver.1