aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2017-12-11 23:13:37 +0100
committerMattias Andrée <maandree@kth.se>2017-12-11 23:13:37 +0100
commite35ba8684be9951fa2129503477ccd5ed6e4e5fc (patch)
tree756292d5a18ad6011a9311fdea8159f474385b65
parenttypo (diff)
downloadbus-3.1.7.tar.gz
bus-3.1.7.tar.bz2
bus-3.1.7.tar.xz
Simplify, do not install examples or info manual, and change license3.1.7
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to '')
-rw-r--r--.gitignore16
-rw-r--r--LICENSE31
-rw-r--r--Makefile350
-rw-r--r--README3
-rw-r--r--arg.h38
-rw-r--r--bus-broadcast.1 (renamed from doc/man/bus-broadcast.1)13
-rw-r--r--bus-chgrp.1 (renamed from doc/man/bus-chgrp.1)11
-rw-r--r--bus-chmod.1 (renamed from doc/man/bus-chmod.1)11
-rw-r--r--bus-chown.1 (renamed from doc/man/bus-chown.1)13
-rw-r--r--bus-create.1 (renamed from doc/man/bus-create.1)13
-rw-r--r--bus-listen.1 (renamed from doc/man/bus-listen.1)11
-rw-r--r--bus-remove.1 (renamed from doc/man/bus-remove.1)11
-rw-r--r--bus-wait.1 (renamed from doc/man/bus-wait.1)11
-rw-r--r--bus.1 (renamed from doc/man/bus.1)10
-rw-r--r--bus.5 (renamed from doc/man/bus.5)10
-rw-r--r--bus.c (renamed from src/cmdline.c)158
-rw-r--r--bus.h (renamed from src/bus.h)80
-rw-r--r--bus.texinfo (renamed from doc/info/bus.texinfo)0
-rw-r--r--bus_chmod.3 (renamed from doc/man/bus_chmod.3)10
-rw-r--r--bus_chown.3 (renamed from doc/man/bus_chown.3)10
-rw-r--r--bus_close.3 (renamed from doc/man/bus_close.3)10
-rw-r--r--bus_create.3 (renamed from doc/man/bus_create.3)10
-rw-r--r--bus_open.3 (renamed from doc/man/bus_open.3)10
-rw-r--r--bus_poll.3 (renamed from doc/man/bus_poll.3)10
-rw-r--r--bus_read.3 (renamed from doc/man/bus_read.3)10
-rw-r--r--bus_unlink.3 (renamed from doc/man/bus_unlink.3)10
-rw-r--r--bus_write.3 (renamed from doc/man/bus_write.3)10
-rw-r--r--config.mk6
-rw-r--r--dist/arch/stable/.gitignore6
-rw-r--r--dist/arch/stable/PKGBUILD27
-rw-r--r--dist/arch/stable/bus.install20
-rw-r--r--doc/protocol1
-rw-r--r--fdl.texinfo (renamed from doc/info/fdl.texinfo)0
-rw-r--r--libbus.7 (renamed from doc/man/libbus.7)10
-rw-r--r--libbus.c (renamed from src/bus.c)68
35 files changed, 280 insertions, 738 deletions
diff --git a/.gitignore b/.gitignore
index 8350fba..ce4b9c1 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,12 +1,14 @@
-_/
-obj/
-bin/
-\#*\#
-.*
-!.git*
+*\#*
*~
*.o
*.out
*.su
*.gch
-
+*.so
+*.a
+*.lo
+*.log
+*.toc
+*.aux
+*.pdf
+/bus
diff --git a/LICENSE b/LICENSE
index b253b5b..53d4a24 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,22 +1,15 @@
-MIT/X Consortium License
+ISC License
-Copyright © 2015 Mattias Andrée <maandree@member.fsf.org>
+© 2015, 2017 Mattias Andrée <maandree@kth.se>
-Permission is hereby granted, free of charge, to any person obtaining a
-copy of this software and associated documentation files (the "Software"),
-to deal in the Software without restriction, including without limitation
-the rights to use, copy, modify, merge, publish, distribute, sublicense,
-and/or sell copies of the Software, and to permit persons to whom the
-Software is furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
-THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-DEALINGS IN THE SOFTWARE.
+Permission to use, copy, modify, and/or 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.
diff --git a/Makefile b/Makefile
index e75a5a7..5ee0e25 100644
--- a/Makefile
+++ b/Makefile
@@ -1,272 +1,90 @@
-# bus - simple message broadcasting IPC system
-# See LICENSE file for copyright and license details.
-
-PREFIX = /usr
-BIN = /bin
-BINDIR = ${PREFIX}${BIN}
-LIB = /lib
-LIBDIR = ${PREFIX}${LIB}
-INCLUDE = /include
-INCLUDEDIR = ${PREFIX}${INCLUDE}
-DATA = /share
-DATADIR = ${PREFIX}${DATA}
-LICENSEDIR = ${DATADIR}/licenses
-MANDIR = ${DATADIR}/man
-INFODIR = $(DATADIR)/info
-DOCDIR = $(DATADIR)/doc
-
-PKGNAME = bus
-
-
-MAN1 = bus bus-broadcast bus-create bus-listen bus-remove bus-wait bus-chmod bus-chown bus-chgrp
-MAN3 = bus_create bus_unlink bus_open bus_close bus_read bus_write bus_poll bus_chmod bus_chown
-MAN5 = bus
-MAN7 = libbus
-
-EXAMPLES = audio-volume-control daemon-dependencies nonblocking telephony-and-music timed
-EXAMPLE_audio-volume-control = amixer cleanup init monitor README
-EXAMPLE_daemon-dependencies = announce.c await-ready.c await-started.c cleanup.c d-network d-ntp \
- d-ssh init.c Makefile README require.c start-daemon.c test-daemon.c
-EXAMPLE_nonblocking = cleanup.c init.c Makefile poll.c README write.c
-EXAMPLE_telephony-and-music = cleanup.c end-call.c init.c Makefile monitor.c README receive-or-make-call.c
-EXAMPLE_timed = cleanup.c init.c Makefile poll.c read.c README slow-poll.c write.c
-
-
-FLAGS = -std=c99 -Wall -Wextra -pedantic -O2
-
-LIB_MAJOR = 3
-LIB_MINOR = 1
-LIB_VERSION = ${LIB_MAJOR}.${LIB_MINOR}
-VERSION = 3.1.6
-
-
-
-default: bus man info
-all: bus doc
-doc: man info pdf dvi ps
-man: man1 man3 man5 man7
-bus: bin lib
-bin: bin/bus
-lib: so a
-so: bin/libbus.so.${LIB_VERSION} bin/libbus.so.${LIB_MAJOR} bin/libbus.so
-a: bin/libbus.a
-man1: $(foreach M,${MAN1},bin/${M}.1)
-man3: $(foreach M,${MAN3},bin/${M}.3)
-man5: $(foreach M,${MAN5},bin/${M}.5)
-man7: $(foreach M,${MAN7},bin/${M}.7)
-info: bin/bus.info
-pdf: bin/bus.pdf
-dvi: bin/bus.dvi
-ps: bin/bus.ps
-
-bin/%.1: doc/man/%.1
- @echo SED $@
- @mkdir -p bin
- @sed 's/%VERSION%/${VERSION}/g' < $< > $@
-
-bin/%.3: doc/man/%.3
- @echo SED $@
- @mkdir -p bin
- @sed 's/%VERSION%/${VERSION}/g' < $< > $@
-
-bin/%.5: doc/man/%.5
- @echo SED $@
- @mkdir -p bin
- @sed 's/%VERSION%/${VERSION}/g' < $< > $@
-
-bin/%.7: doc/man/%.7
- @echo SED $@
- @mkdir -p bin
- @sed 's/%VERSION%/${VERSION}/g' < $< > $@
-
-bin/libbus.a: obj/bus-fpic.o
- @echo AR $@
- @mkdir -p bin
- @ar rcs $@ $^
-
-bin/bus: obj/cmdline-nofpic.o obj/bus-nofpic.o
- @echo CC -o $@
- @mkdir -p bin
- @${CC} ${FLAGS} -lrt -o $@ $^ ${LDFLAGS}
-
-bin/libbus.so.${LIB_VERSION}: obj/bus-fpic.o
- @echo CC -o $@
- @mkdir -p bin
- @${CC} ${FLAGS} -lrt -shared -Wl,-soname,libbus.so.${LIB_MAJOR} -o $@ $^ ${LDFLAGS}
-
-bin/libbus.so.${LIB_MAJOR}:
- @echo LN -s $@
- @mkdir -p bin
- @ln -sf libbus.so.${LIB_VERSION} $@
-
-bin/libbus.so:
- @echo LN -s $@
- @mkdir -p bin
- @ln -sf libbus.so.${LIB_VERSION} $@
-
-obj/%-nofpic.o: src/%.c src/*.h
- @echo CC -c $@
- @mkdir -p obj
- @${CC} ${FLAGS} -c -o $@ ${CPPFLAGS} ${CFLAGS} $<
-
-obj/%-fpic.o: src/%.c src/*.h
- @echo CC -c $@
- @mkdir -p obj
- @${CC} ${FLAGS} -fPIC -c -o $@ ${CPPFLAGS} ${CFLAGS} $<
-
-bin/%.info: doc/info/%.texinfo
- @echo MAKEINFO $@
- @mkdir -p bin
- @$(MAKEINFO) $<
- @mv $*.info $@
-
-bin/%.pdf: doc/info/%.texinfo
- @echo TEXI2PDF $@
- @! test -d obj/pdf || rm -rf obj/pdf
- @mkdir -p bin obj/pdf
- @cd obj/pdf && texi2pdf ../../"$<" < /dev/null
- @mv obj/pdf/$*.pdf $@
-
-bin/%.dvi: doc/info/%.texinfo
- @echo TEXI2DVI $@
- @! test -d obj/dvi || rm -rf obj/dvi
- @mkdir -p bin obj/dvi
- @cd obj/dvi && $(TEXI2DVI) ../../"$<" < /dev/null
- @mv obj/dvi/$*.dvi $@
-
-bin/%.ps: doc/info/%.texinfo
- @echo TEXI2PS $@
- @! test -d obj/ps || rm -rf obj/ps
- @mkdir -p bin obj/ps
- @cd obj/ps && texi2pdf --ps ../../"$<" < /dev/null
- @mv obj/ps/$*.ps $@
-
-
-
-install: install-bus install-man install-info install-examples
-install-all: install-bus install-doc
-install-lib: install-so install-a install-h
-install-doc: install-man install-info install-pdf install-dvi install-ps install-examples
-install-man: install-man1 install-man3 install-man5 install-man7
-install-bus: install-bin install-lib install-license
-
-install-bin: bin/bus
- @echo INSTALL bus
- @install -dm755 -- "${DESTDIR}${BINDIR}"
- @install -m755 $^ -- "${DESTDIR}${BINDIR}"
-
-install-so: bin/libbus.so.${LIB_VERSION}
- @echo INSTALL libbus.so
- @install -dm755 -- "${DESTDIR}${LIBDIR}"
- @install -m755 $^ -- "${DESTDIR}${LIBDIR}"
- @ln -sf -- "libbus.so.${LIB_VERSION}" "${DESTDIR}${LIBDIR}/libbus.so.${LIB_MAJOR}"
- @ln -sf -- "libbus.so.${LIB_VERSION}" "${DESTDIR}${LIBDIR}/libbus.so"
-
-install-a: bin/libbus.a
- @echo INSTALL libbus.a
- @install -dm755 -- "${DESTDIR}${LIBDIR}"
- @install -m644 $^ -- "${DESTDIR}${LIBDIR}"
-
-install-h:
- @echo INSTALL bus.h
- @install -dm755 -- "${DESTDIR}${INCLUDEDIR}"
- @install -m644 src/bus.h -- "${DESTDIR}${INCLUDEDIR}"
-
-install-license:
- @echo INSTALL LICENSE
- @install -dm755 -- "${DESTDIR}${LICENSEDIR}/${PKGNAME}"
- @install -m644 LICENSE -- "${DESTDIR}${LICENSEDIR}/${PKGNAME}"
-
-install-man1: $(foreach M,${MAN1},bin/${M}.1)
- @echo 'INSTALL *.1'
- @install -dm755 -- "${DESTDIR}${MANDIR}/man1"
- @install -m644 $^ -- "${DESTDIR}${MANDIR}/man1"
-
-install-man3: $(foreach M,${MAN3},bin/${M}.3)
- @echo 'INSTALL *.3'
- @install -dm755 -- "${DESTDIR}${MANDIR}/man3"
- @install -m644 $^ -- "${DESTDIR}${MANDIR}/man3"
- @ln -sf -- "bus_poll.3" "${DESTDIR}${MANDIR}/man3/bus_poll_start.3"
- @ln -sf -- "bus_poll.3" "${DESTDIR}${MANDIR}/man3/bus_poll_stop.3"
- @ln -sf -- "bus_poll.3" "${DESTDIR}${MANDIR}/man3/bus_poll_timed.3"
- @ln -sf -- "bus_read.3" "${DESTDIR}${MANDIR}/man3/bus_read_timed.3"
- @ln -sf -- "bus_write.3" "${DESTDIR}${MANDIR}/man3/bus_write_timed.3"
-
-install-man5: $(foreach M,${MAN5},bin/${M}.5)
- @echo 'INSTALL *.5'
- @install -dm755 -- "${DESTDIR}${MANDIR}/man5"
- @install -m644 $^ -- "${DESTDIR}${MANDIR}/man5"
-
-install-man7: $(foreach M,${MAN7},bin/${M}.7)
- @echo 'INSTALL *.7'
- @install -dm755 -- "${DESTDIR}${MANDIR}/man7"
- @install -m644 $^ -- "${DESTDIR}${MANDIR}/man7"
-
-install-info: bin/bus.info
- @echo INSTALL bus.info
- @install -dm755 -- "$(DESTDIR)$(INFODIR)"
- @install -m644 $< -- "$(DESTDIR)$(INFODIR)/$(PKGNAME).info"
-
-install-pdf: bin/bus.pdf
- @echo INSTALL bus.pdf
- @install -dm755 -- "$(DESTDIR)$(DOCDIR)"
- @install -m644 $< -- "$(DESTDIR)$(DOCDIR)/$(PKGNAME).pdf"
-
-install-dvi: bin/bus.dvi
- @echo INSTALL bus.dvi
- @install -dm755 -- "$(DESTDIR)$(DOCDIR)"
- @install -m644 $< -- "$(DESTDIR)$(DOCDIR)/$(PKGNAME).dvi"
-
-install-ps: bin/bus.ps
- @echo INSTALL bus.ps
- @install -dm755 -- "$(DESTDIR)$(DOCDIR)"
- @install -m644 $< -- "$(DESTDIR)$(DOCDIR)/$(PKGNAME).ps"
-
-install-examples:
- @echo INSTALL examples
- @install -dm755 -- $(foreach E,$(EXAMPLES),"$(DESTDIR)$(DOCDIR)/$(PKGNAME)/examples/$(E)")
- @$(foreach E,$(EXAMPLES),cp -- $(foreach F,$(EXAMPLE_$(E)),doc/examples/$(E)/$(F)) \
- "$(DESTDIR)$(DOCDIR)/$(PKGNAME)/examples/$(E)" &&) true
-
-
+.POSIX:
+
+CONFIGFILE = config.mk
+include $(CONFIGFILE)
+
+LIB_MAJOR = 3
+LIB_MINOR = 1
+LIB_VERSION = $(LIB_MAJOR).$(LIB_MINOR)
+VERSION = 3.1.7
+
+MAN1 = bus.1 bus-broadcast.1 bus-create.1 bus-listen.1 bus-remove.1 bus-wait.1 bus-chmod.1 bus-chown.1 bus-chgrp.1
+MAN3 = bus_create.3 bus_unlink.3 bus_open.3 bus_close.3 bus_read.3 bus_write.3 bus_poll.3 bus_chmod.3 bus_chown.3
+MAN5 = bus.5
+MAN7 = libbus.7
+
+LOBJ = libbus.lo
+OBJ = bus.o libbus.o
+HDR = bus.h arg.h
+
+all: bus libbus.a libbus.so
+
+$(OBJ): $(@:.o=.c) $(HDR)
+$(LOBJ): $(@:.lo=.c) $(HDR)
+
+bus: $(OBJ)
+ $(CC) -o $@ $(OBJ) $(LDFLAGS)
+
+.o.a:
+ $(AR) $(ARFLAGS) $@ $<
+
+.c.lo:
+ $(CC) $(CFLAGS) -fPIC -c -o $@ $<
+
+.lo.so:
+ $(CC) -shared -Wl,-soname,$@.$(LIB_MAJOR) -o $@ $< $(LDFLAGS)
+
+bus.pdf: bus.texinfo fdl.texinfo
+ texi2pdf bus.texinfo < /dev/null
+
+install: bus libbus.a libbus.so
+ mkdir -p -- "$(DESTDIR)$(PREFIX)/bin"
+ mkdir -p -- "$(DESTDIR)$(PREFIX)/lib"
+ mkdir -p -- "$(DESTDIR)$(PREFIX)/include"
+ mkdir -p -- "$(DESTDIR)$(PREFIX)/licenses/bus"
+ mkdir -p -- "$(DESTDIR)$(MANPREFIX)/man1"
+ mkdir -p -- "$(DESTDIR)$(MANPREFIX)/man3"
+ mkdir -p -- "$(DESTDIR)$(MANPREFIX)/man5"
+ mkdir -p -- "$(DESTDIR)$(MANPREFIX)/man7"
+ cp -- bus "$(DESTDIR)$(PREFIX)/bin"
+ cp -- libbus.a "$(DESTDIR)$(PREFIX)/lib"
+ cp -- libbus.so "$(DESTDIR)$(PREFIX)/lib/libbus.so.$(LIB_VERSION)"
+ cp -- bus.h "$(DESTDIR)$(PREFIX)/include"
+ cp -- LICENSE "$(DESTDIR)$(PREFIX)/licenses/bus"
+ ln -sf -- libbus.so.$(LIB_VERSION) "$(DESTDIR)$(PREFIX)/lib/libbus.so.$(LIB_MAJOR)"
+ ln -sf -- libbus.so.$(LIB_VERSION) "$(DESTDIR)$(PREFIX)/lib/libbus.so"
+ cp -- $(MAN1) "$(DESTDIR)$(MANPREFIX)/man1"
+ cp -- $(MAN3) "$(DESTDIR)$(MANPREFIX)/man3"
+ cp -- $(MAN5) "$(DESTDIR)$(MANPREFIX)/man5"
+ cp -- $(MAN7) "$(DESTDIR)$(MANPREFIX)/man7"
+ ln -sf -- bus_poll.3 "$(DESTDIR)$(MANPREFIX)/man3/bus_poll_start.3"
+ ln -sf -- bus_poll.3 "$(DESTDIR)$(MANPREFIX)/man3/bus_poll_stop.3"
+ ln -sf -- bus_poll.3 "$(DESTDIR)$(MANPREFIX)/man3/bus_poll_timed.3"
+ ln -sf -- bus_read.3 "$(DESTDIR)$(MANPREFIX)/man3/bus_read_timed.3"
+ ln -sf -- bus_write.3 "$(DESTDIR)$(MANPREFIX)/man3/bus_write_timed.3"
uninstall:
- -rm -- "${DESTDIR}${BINDIR}/bus"
- -rm -- "${DESTDIR}${LIBDIR}/libbus.so.${LIB_VERSION}"
- -rm -- "${DESTDIR}${LIBDIR}/libbus.so.${LIB_MAJOR}"
- -rm -- "${DESTDIR}${LIBDIR}/libbus.so"
- -rm -- "${DESTDIR}${LIBDIR}/libbus.a"
- -rm -- "${DESTDIR}${INCLUDEDIR}/bus.h"
- -rm -- "${DESTDIR}${LICENSEDIR}/${PKGNAME}/LICENSE"
- -rmdir -- "${DESTDIR}${LICENSEDIR}/${PKGNAME}"
- -rm -- $(foreach M,${MAN1},"${DESTDIR}${MANDIR}/man1/${M}.1")
- -rm -- $(foreach M,${MAN3},"${DESTDIR}${MANDIR}/man3/${M}.3")
- -rm -- "${DESTDIR}${MANDIR}/man3/bus_poll_start.3"
- -rm -- "${DESTDIR}${MANDIR}/man3/bus_poll_stop.3"
- -rm -- "${DESTDIR}${MANDIR}/man3/bus_poll_timed.3"
- -rm -- "${DESTDIR}${MANDIR}/man3/bus_read_timed.3"
- -rm -- "${DESTDIR}${MANDIR}/man3/bus_write_timed.3"
- -rm -- $(foreach M,${MAN5},"${DESTDIR}${MANDIR}/man5/${M}.5")
- -rm -- $(foreach M,${MAN7},"${DESTDIR}${MANDIR}/man7/${M}.7")
- -rm -- "$(DESTDIR)$(INFODIR)/$(PKGNAME).info"
- -rm -- "$(DESTDIR)$(DOCDIR)/$(PKGNAME).pdf"
- -rm -- "$(DESTDIR)$(DOCDIR)/$(PKGNAME).dvi"
- -rm -- "$(DESTDIR)$(DOCDIR)/$(PKGNAME).ps"
- -$(foreach E,$(EXAMPLES),rm -- \
- $(foreach F,$(EXAMPLE_$(E)),"$(DESTDIR)$(DOCDIR)/$(PKGNAME)/examples/$(E)/$(F)");)
- -rmdir -- $(foreach E,$(EXAMPLES),"$(DESTDIR)$(DOCDIR)/$(PKGNAME)/examples/$(E)")
-
-
+ -rm -f -- "$(DESTDIR)$(PREFIX)/bin/bus"
+ -rm -f -- "$(DESTDIR)$(PREFIX)/lib/libbus.a"
+ -rm -f -- "$(DESTDIR)$(PREFIX)/lib/libbus.so.$(LIB_VERSION)"
+ -rm -f -- "$(DESTDIR)$(PREFIX)/lib/libbus.so.$(LIB_MAJOR)"
+ -rm -f -- "$(DESTDIR)$(PREFIX)/lib/libbus.so"
+ -rm -f -- "$(DESTDIR)$(PREFIX)/include/bus.h"
+ -rm -rf -- "$(DESTDIR)$(PREFIX)/licenses/bus"
+ -cd "$(DESTDIR)$(MANPREFIX)/man1" && rm -f -- $(MAN1)
+ -cd "$(DESTDIR)$(MANPREFIX)/man3" && rm -f -- $(MAN3)
+ -cd "$(DESTDIR)$(MANPREFIX)/man5" && rm -f -- $(MAN5)
+ -cd "$(DESTDIR)$(MANPREFIX)/man7" && rm -f -- $(MAN7)
+ -rm -f -- "$(DESTDIR)$(MANPREFIX)/man3/bus_poll_start.3"
+ -rm -f -- "$(DESTDIR)$(MANPREFIX)/man3/bus_poll_stop.3"
+ -rm -f -- "$(DESTDIR)$(MANPREFIX)/man3/bus_poll_timed.3"
+ -rm -f -- "$(DESTDIR)$(MANPREFIX)/man3/bus_read_timed.3"
+ -rm -f -- "$(DESTDIR)$(MANPREFIX)/man3/bus_write_timed.3"
clean:
- @echo cleaning
- @-rm -rf obj bin
-
-
+ -rm -f -- bus *.o *.lo *.a *.so *.log *.toc *.aux *.pdf
-.PHONY: default all doc bin bus lib so a man man1 man3 man5 man7 info pdf dvi \
- ps install install-all install-doc install-man install-bin install-so \
- install-a install-h install-lib install-license install-man1 install-bus \
- install-man3 install-man5 install-man7 install-info install-pdf install-dvi \
- install-ps install-examples uninstall clean
+.SUFFIXES:
+.SUFFIXES: .so .a .o .lo .c .pdf
+.PHONY: all install uninstall clean
diff --git a/README b/README
index 7092f4c..1f6f48f 100644
--- a/README
+++ b/README
@@ -39,6 +39,3 @@ SEE ALSO
pthread_spin_destroy(3), pthread_cond_destroy(3), lockf(3), flock(2),
fcntl(3), ioctl(3), mkfifo(3), rendezvous(2), 9p(2), libdoor(3),
python-bus
-
- Full documentation available locally via: info '(bus)'
-
diff --git a/arg.h b/arg.h
new file mode 100644
index 0000000..09a5350
--- /dev/null
+++ b/arg.h
@@ -0,0 +1,38 @@
+/*
+ * Copy me if you can.
+ * by 20h
+ */
+
+#ifndef ARG_H__
+#define ARG_H__
+
+extern char *argv0;
+
+/* use main(int argc, char *argv[]) */
+#define ARGBEGIN for (argv0 = *argv, argv++, argc--;\
+ argv[0] && argv[0][0] && argv[0][1];\
+ argc--, argv++) {\
+ char argc_;\
+ char **argv_;\
+ int brk_;\
+ if (argv[0][0] == '-') {\
+ if (argv[0][1] == '-' && argv[0][2] == '\0') {\
+ argv++;\
+ argc--;\
+ break;\
+ }\
+ for (brk_ = 0, argv[0]++, argv_ = argv;\
+ argv[0][0] && !brk_;\
+ argv[0]++) {\
+ if (argv_ != argv)\
+ break;\
+ argc_ = argv[0][0];\
+ switch (argc_)
+
+#define ARGEND }\
+ } else {\
+ break;\
+ }\
+ }
+
+#endif
diff --git a/doc/man/bus-broadcast.1 b/bus-broadcast.1
index a4dc76c..94a05ec 100644
--- a/doc/man/bus-broadcast.1
+++ b/bus-broadcast.1
@@ -1,10 +1,9 @@
-.TH BUS-BROADCAST 1 BUS-%VERSION%
+.TH BUS-BROADCAST 1 BUS
.SH NAME
bus broadcast - Broadcast a message on a bus
.SH SYNOPSIS
.B bus broadcast
-.IR [options]
-[--]
+[-n]
.IR pathname
.IR message
.SH DESCRIPTION
@@ -25,11 +24,3 @@ The command failed.
The command is not recognised.
.SH SEE ALSO
.BR bus (5)
-.SH AUTHORS
-Principal author, Mattias Andrée. See the LICENSE file for the full
-list of authors.
-.SH LICENSE
-MIT/X Consortium License.
-.SH BUGS
-Please report bugs to https://github.com/maandree/bus/issues or to
-maandree@member.fsf.org
diff --git a/doc/man/bus-chgrp.1 b/bus-chgrp.1
index d825e32..b871c41 100644
--- a/doc/man/bus-chgrp.1
+++ b/bus-chgrp.1
@@ -1,9 +1,8 @@
-.TH BUS-CHGRP 1 BUS-%VERSION%
+.TH BUS-CHGRP 1 BUS
.SH NAME
bus chgrp - Change group ownership of a bus
.SH SYNOPSIS
.B bus chgrp
-[--]
.IR group
.IR pathname
.SH DESCRIPTION
@@ -28,11 +27,3 @@ The command is not recognised.
.BR bus-chown (1),
.BR bus-chmod (1),
.BR stat (1)
-.SH AUTHORS
-Principal author, Mattias Andrée. See the LICENSE file for the full
-list of authors.
-.SH LICENSE
-MIT/X Consortium License.
-.SH BUGS
-Please report bugs to https://github.com/maandree/bus/issues or to
-maandree@member.fsf.org
diff --git a/doc/man/bus-chmod.1 b/bus-chmod.1
index 3a44423..51ee9b4 100644
--- a/doc/man/bus-chmod.1
+++ b/bus-chmod.1
@@ -1,9 +1,8 @@
-.TH BUS-CHMOD 1 BUS-%VERSION%
+.TH BUS-CHMOD 1 BUS
.SH NAME
bus chmod - Change permissions on a bus
.SH SYNOPSIS
.B bus chmod
-[--]
.IR permissions
.IR pathname
.SH DESCRIPTION
@@ -39,11 +38,3 @@ The command is not recognised.
.BR bus-chown (1),
.BR bus-chgrp (1),
.BR stat (1)
-.SH AUTHORS
-Principal author, Mattias Andrée. See the LICENSE file for the full
-list of authors.
-.SH LICENSE
-MIT/X Consortium License.
-.SH BUGS
-Please report bugs to https://github.com/maandree/bus/issues or to
-maandree@member.fsf.org
diff --git a/doc/man/bus-chown.1 b/bus-chown.1
index 24487a1..c6d9056 100644
--- a/doc/man/bus-chown.1
+++ b/bus-chown.1
@@ -1,10 +1,9 @@
-.TH BUS-CHOWN 1 BUS-%VERSION%
+.TH BUS-CHOWN 1 BUS
.SH NAME
bus chown - Change ownership of a bus
.SH SYNOPSIS
.B bus chown
-[--]
-.IR owner[:group]
+.IR owner [\fB:\fP group ]
.IR pathname
.SH DESCRIPTION
Change the owner, that owns a bus with an associated \fIpathname\fP,
@@ -31,11 +30,3 @@ The command is not recognised.
.BR bus-chgrp (1),
.BR bus-chmod (1),
.BR stat (1)
-.SH AUTHORS
-Principal author, Mattias Andrée. See the LICENSE file for the full
-list of authors.
-.SH LICENSE
-MIT/X Consortium License.
-.SH BUGS
-Please report bugs to https://github.com/maandree/bus/issues or to
-maandree@member.fsf.org
diff --git a/doc/man/bus-create.1 b/bus-create.1
index 91041cf..2d34b83 100644
--- a/doc/man/bus-create.1
+++ b/bus-create.1
@@ -1,10 +1,9 @@
-.TH BUS-CREATE 1 BUS-%VERSION%
+.TH BUS-CREATE 1 BUS
.SH NAME
bus create - Create a bus
.SH SYNOPSIS
.B bus create
-.IR [options]
-[--]
+[-x]
.IR [pathname]
.SH DESCRIPTION
Create a bus with an associated \fIpathname\fP. If \fIpathname\fP
@@ -27,11 +26,3 @@ The command is not recognised.
.SH SEE ALSO
.BR bus (5),
.BR bus-remove (1)
-.SH AUTHORS
-Principal author, Mattias Andrée. See the LICENSE file for the full
-list of authors.
-.SH LICENSE
-MIT/X Consortium License.
-.SH BUGS
-Please report bugs to https://github.com/maandree/bus/issues or to
-maandree@member.fsf.org
diff --git a/doc/man/bus-listen.1 b/bus-listen.1
index 4977ce5..75a6106 100644
--- a/doc/man/bus-listen.1
+++ b/bus-listen.1
@@ -1,9 +1,8 @@
-.TH BUS-LISTEN 1 BUS-%VERSION%
+.TH BUS-LISTEN 1 BUS
.SH NAME
bus listen - Listen for new messages on a bus
.SH SYNOPSIS
.B bus listen
-[--]
.IR pathname
.IR command
.SH DESCRIPTION
@@ -22,11 +21,3 @@ The command failed.
The command is not recognised.
.SH SEE ALSO
.BR bus (5)
-.SH AUTHORS
-Principal author, Mattias Andrée. See the LICENSE file for the full
-list of authors.
-.SH LICENSE
-MIT/X Consortium License.
-.SH BUGS
-Please report bugs to https://github.com/maandree/bus/issues or to
-maandree@member.fsf.org
diff --git a/doc/man/bus-remove.1 b/bus-remove.1
index 95e805c..5905270 100644
--- a/doc/man/bus-remove.1
+++ b/bus-remove.1
@@ -1,9 +1,8 @@
-.TH BUS-REMOVE 1 BUS-%VERSION%
+.TH BUS-REMOVE 1 BUS
.SH NAME
bus remove - Remove a bus
.SH SYNOPSIS
.B bus remove
-[--]
.IR pathname
.SH DESCRIPTION
Remove the bus associated with \fIpathname\fP.
@@ -19,11 +18,3 @@ The command failed.
The command is not recognised.
.SH SEE ALSO
.BR bus (5)
-.SH AUTHORS
-Principal author, Mattias Andrée. See the LICENSE file for the full
-list of authors.
-.SH LICENSE
-MIT/X Consortium License.
-.SH BUGS
-Please report bugs to https://github.com/maandree/bus/issues or to
-maandree@member.fsf.org
diff --git a/doc/man/bus-wait.1 b/bus-wait.1
index 4231cd0..07d5704 100644
--- a/doc/man/bus-wait.1
+++ b/bus-wait.1
@@ -1,9 +1,8 @@
-.TH BUS-WAIT 1 BUS-%VERSION%
+.TH BUS-WAIT 1 BUS
.SH NAME
bus wait - Listen for a new message on a bus
.SH SYNOPSIS
.B bus wait
-[--]
.IR pathname
.IR command
.SH DESCRIPTION
@@ -23,11 +22,3 @@ The command failed.
The command is not recognised.
.SH SEE ALSO
.BR bus (5)
-.SH AUTHORS
-Principal author, Mattias Andrée. See the LICENSE file for the full
-list of authors.
-.SH LICENSE
-MIT/X Consortium License.
-.SH BUGS
-Please report bugs to https://github.com/maandree/bus/issues or to
-maandree@member.fsf.org
diff --git a/doc/man/bus.1 b/bus.1
index afb3925..fc75189 100644
--- a/doc/man/bus.1
+++ b/bus.1
@@ -1,4 +1,4 @@
-.TH BUS 1 BUS-%VERSION%
+.TH BUS 1 BUS
.SH NAME
bus - A simple daemonless system for broadcasting messages locally
.SH SYNOPSIS
@@ -67,11 +67,3 @@ The command is not recognised.
.BR bus-chgrp (1),
.BR bus (5),
.BR libbus (7)
-.SH AUTHORS
-Principal author, Mattias Andrée. See the LICENSE file for the full
-list of authors.
-.SH LICENSE
-MIT/X Consortium License.
-.SH BUGS
-Please report bugs to https://github.com/maandree/bus/issues or to
-maandree@member.fsf.org
diff --git a/doc/man/bus.5 b/bus.5
index 0a5de7e..213f2d2 100644
--- a/doc/man/bus.5
+++ b/bus.5
@@ -1,4 +1,4 @@
-.TH BUS 5 BUS-%VERSION%
+.TH BUS 5 BUS
.SH NAME
bus - A simple daemonless system for broadcasting messages locally
.SH DESCRIPTION
@@ -40,11 +40,3 @@ whence the message originated, followed by a single regular space.
.BR libbus (7),
.BR semop (2),
.BR shmop (2)
-.SH AUTHORS
-Principal author, Mattias Andrée. See the LICENSE file for the full
-list of authors.
-.SH LICENSE
-MIT/X Consortium License.
-.SH BUGS
-Please report bugs to https://github.com/maandree/bus/issues or to
-maandree@member.fsf.org
diff --git a/src/cmdline.c b/bus.c
index 25939cb..dc72a17 100644
--- a/src/cmdline.c
+++ b/bus.c
@@ -1,44 +1,24 @@
-/**
- * MIT/X Consortium License
- *
- * Copyright © 2015 Mattias Andrée <maandree@member.fsf.org>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- */
+/* See LICENSE file for copyright and license details. */
#include "bus.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-#include <errno.h>
-#include <sys/types.h>
#include <sys/stat.h>
+#include <sys/types.h>
+#include <errno.h>
#include <grp.h>
#include <pwd.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include "arg.h"
/**
* Statement wrapper that goes to `fail` on failure
*/
-#define t(inst) if ((inst) == -1) goto fail
+#define t(inst) do { if ((inst) == -1) goto fail; } while (0)
@@ -111,9 +91,9 @@ spawn_break(const char *message, void *user_data)
static int
parse_mode(const char *str, mode_t *andnot, mode_t *or)
{
-#define U S_IRWXU
-#define G S_IRWXG
-#define O S_IRWXO
+#define U S_IRWXU
+#define G S_IRWXG
+#define O S_IRWXO
const char *s = str;
int numerical = 1;
mode_t mode = 0;
@@ -306,114 +286,91 @@ parse_owner(char *str, uid_t *uid, gid_t *gid)
int
main(int argc, char *argv[])
{
+ int xflag = 0;
+ int nflag = 0;
bus_t bus;
char *file;
struct stat attr;
uid_t uid;
gid_t gid;
mode_t mode_andnot, mode_or;
- int opt_x = 0, opt_n = 0;
- const char *arg;
- char **nonoptv = alloca((size_t)argc * sizeof(char*));
- int nonoptc = 0;
-
- argv0 = *argv++;
- argc--;
/* Parse arguments. */
- while (argc) {
- if (!strcmp(*argv, "--")) {
- argv++;
- argc--;
- break;
- } else if (**argv == '-') {
- arg = *argv++;
- argc--;
- for (arg++; *arg; arg++) {
- if (*arg == 'x')
- opt_x = 1;
- else if (*arg == 'n')
- opt_n = 1;
- else
- return -2;
- }
- } else {
- *nonoptv++ = *argv++;
- nonoptc++;
- argc--;
- }
- }
- while (argc) {
- *nonoptv++ = *argv++;
- nonoptc++;
- argc--;
- }
- nonoptv -= nonoptc;
+ ARGBEGIN {
+ case 'x':
+ xflag = 1;
+ break;
+ case 'n':
+ nflag = 1;
+ break;
+ default:
+ return 2;
+ } ARGEND;
/* Check options. */
- if (opt_x && strcmp(nonoptv[0], "create") && (nonoptc != 2))
+ if (xflag && strcmp(argv[0], "create") && (argc != 2))
return 2;
- if (opt_n && strcmp(nonoptv[0], "broadcast") && (nonoptc != 3))
+ if (nflag && strcmp(argv[0], "broadcast") && (argc != 3))
return 2;
/* Create a new bus with selected name. */
- if ((nonoptc == 2) && !strcmp(nonoptv[0], "create")) {
- t(bus_create(nonoptv[1], opt_x * BUS_EXCL, NULL));
+ if ((argc == 2) && !strcmp(argv[0], "create")) {
+ t(bus_create(argv[1], xflag * BUS_EXCL, NULL));
/* Create a new bus with random name. */
- } else if ((nonoptc == 1) && !strcmp(nonoptv[0], "create")) {
+ } else if ((argc == 1) && !strcmp(argv[0], "create")) {
t(bus_create(NULL, 0, &file));
printf("%s\n", file);
free(file);
/* Remove a bus. */
- } else if ((nonoptc == 2) && !strcmp(nonoptv[0], "remove")) {
- t(bus_unlink(nonoptv[1]));
+ } else if ((argc == 2) && !strcmp(argv[0], "remove")) {
+ t(bus_unlink(argv[1]));
/* Listen on a bus in a loop. */
- } else if ((nonoptc == 3) && !strcmp(nonoptv[0], "listen")) {
- command = nonoptv[2];
- t(bus_open(&bus, nonoptv[1], BUS_RDONLY));
+ } else if ((argc == 3) && !strcmp(argv[0], "listen")) {
+ command = argv[2];
+ t(bus_open(&bus, argv[1], BUS_RDONLY));
t(bus_read(&bus, spawn_continue, NULL));
t(bus_close(&bus));
/* Listen on a bus for one message. */
- } else if ((nonoptc == 3) && !strcmp(nonoptv[0], "wait")) {
- command = nonoptv[2];
- t(bus_open(&bus, nonoptv[1], BUS_RDONLY));
+ } else if ((argc == 3) && !strcmp(argv[0], "wait")) {
+ command = argv[2];
+ t(bus_open(&bus, argv[1], BUS_RDONLY));
t(bus_read(&bus, spawn_break, NULL));
t(bus_close(&bus));
/* Broadcast a message on a bus. */
- } else if ((nonoptc == 3) && !strcmp(nonoptv[0], "broadcast")) {
- t(bus_open(&bus, nonoptv[1], BUS_WRONLY));
- t(bus_write(&bus, nonoptv[2], opt_n * BUS_NOWAIT));
+ } else if ((argc == 3) && !strcmp(argv[0], "broadcast")) {
+ t(bus_open(&bus, argv[1], BUS_WRONLY));
+ t(bus_write(&bus, argv[2], nflag * BUS_NOWAIT));
t(bus_close(&bus));
/* Change permissions. */
- } else if ((nonoptc == 3) && !strcmp(nonoptv[0], "chmod")) {
- t(parse_mode(nonoptv[1], &mode_andnot, &mode_or));
- t(stat(nonoptv[2], &attr));
+ } else if ((argc == 3) && !strcmp(argv[0], "chmod")) {
+ t(parse_mode(argv[1], &mode_andnot, &mode_or));
+ t(stat(argv[2], &attr));
attr.st_mode &= ~mode_andnot;
attr.st_mode |= mode_or;
- t(bus_chmod(nonoptv[2], attr.st_mode));
+ t(bus_chmod(argv[2], attr.st_mode));
/* Change ownership. */
- } else if ((nonoptc == 3) && !strcmp(nonoptv[0], "chown")) {
- if (strchr(nonoptv[1], ':')) {
- t(parse_owner(nonoptv[1], &uid, &gid));
- t(bus_chown(nonoptv[2], uid, gid));
+ } else if ((argc == 3) && !strcmp(argv[0], "chown")) {
+ if (strchr(argv[1], ':')) {
+ t(parse_owner(argv[1], &uid, &gid));
+ t(bus_chown(argv[2], uid, gid));
} else {
- t(parse_owner(nonoptv[1], &uid, NULL));
- t(stat(nonoptv[2], &attr));
- t(bus_chown(nonoptv[2], uid, attr.st_gid));
+ t(parse_owner(argv[1], &uid, NULL));
+ t(stat(argv[2], &attr));
+ t(bus_chown(argv[2], uid, attr.st_gid));
}
/* Change group. */
- } else if ((nonoptc == 3) && !strcmp(nonoptv[0], "chgrp")) {
- t(parse_owner(nonoptv[1], NULL, &gid));
- t(stat(nonoptv[2], &attr));
- t(bus_chown(nonoptv[2], attr.st_uid, gid));
+ } else if ((argc == 3) && !strcmp(argv[0], "chgrp")) {
+ t(parse_owner(argv[1], NULL, &gid));
+ t(stat(argv[2], &attr));
+ t(bus_chown(argv[2], attr.st_uid, gid));
} else
return 2;
@@ -421,9 +378,8 @@ main(int argc, char *argv[])
return 0;
fail:
- if (errno == 0)
+ if (!errno)
return 2;
perror(argv0);
return 1;
}
-
diff --git a/src/bus.h b/bus.h
index ff2f1fb..707c9e4 100644
--- a/src/bus.h
+++ b/bus.h
@@ -1,26 +1,4 @@
-/**
- * MIT/X Consortium License
- *
- * Copyright © 2015 Mattias Andrée <maandree@member.fsf.org>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- */
+/* See LICENSE file for copyright and license details. */
#ifndef BUS_H
#define BUS_H
@@ -130,8 +108,8 @@ typedef struct bus
* @param out_file Output parameter for the pathname of the bus
* @return 0 on success, -1 on error
*/
-int bus_create(const char *restrict, int, char **restrict)
- BUS_COMPILER_GCC(__attribute__((__warn_unused_result__)));
+BUS_COMPILER_GCC(__attribute__((__warn_unused_result__)))
+int bus_create(const char *restrict, int, char **restrict);
/**
* Remove a bus
@@ -139,8 +117,8 @@ int bus_create(const char *restrict, int, char **restrict)
* @param file The pathname of the bus
* @return 0 on success, -1 on error
*/
-int bus_unlink(const char *)
- BUS_COMPILER_GCC(__attribute__((__nonnull__)));
+BUS_COMPILER_GCC(__attribute__((__nonnull__)))
+int bus_unlink(const char *);
/**
@@ -152,8 +130,8 @@ int bus_unlink(const char *)
* the value must not be negative
* @return 0 on success, -1 on error
*/
-int bus_open(bus_t *restrict, const char *restrict, int)
- BUS_COMPILER_GCC(__attribute__((__nonnull__, __warn_unused_result__)));
+BUS_COMPILER_GCC(__attribute__((__nonnull__, __warn_unused_result__)))
+int bus_open(bus_t *restrict, const char *restrict, int);
/**
* Close a bus
@@ -161,8 +139,8 @@ int bus_open(bus_t *restrict, const char *restrict, int)
* @param bus Bus information
* @return 0 on success, -1 on error
*/
-int bus_close(bus_t *)
- BUS_COMPILER_GCC(__attribute__((__nonnull__)));
+BUS_COMPILER_GCC(__attribute__((__nonnull__)))
+int bus_close(bus_t *);
/**
@@ -176,8 +154,8 @@ int bus_close(bus_t *)
* procedure
* @return 0 on success, -1 on error
*/
-int bus_write(const bus_t *, const char *, int)
- BUS_COMPILER_GCC(__attribute__((__nonnull__, __warn_unused_result__)));
+BUS_COMPILER_GCC(__attribute__((__nonnull__, __warn_unused_result__)))
+int bus_write(const bus_t *, const char *, int);
/**
* Broadcast a message on a bus
@@ -191,8 +169,8 @@ int bus_write(const bus_t *, const char *, int)
* it most be a predictable clock
* @return 0 on success, -1 on error
*/
-int bus_write_timed(const bus_t *, const char *, const struct timespec *, clockid_t)
- BUS_COMPILER_GCC(__attribute__((__nonnull__(1, 2), __warn_unused_result__)));
+BUS_COMPILER_GCC(__attribute__((__nonnull__(1, 2), __warn_unused_result__)))
+int bus_write_timed(const bus_t *, const char *, const struct timespec *, clockid_t);
/**
@@ -218,8 +196,8 @@ int bus_write_timed(const bus_t *, const char *, const struct timespec *, clocki
* @param user_data Parameter passed to `callback`
* @return 0 on success, -1 on error
*/
-int bus_read(const bus_t *restrict, int (*)(const char *, void *), void *)
- BUS_COMPILER_GCC(__attribute__((__nonnull__(1, 2), __warn_unused_result__)));
+BUS_COMPILER_GCC(__attribute__((__nonnull__(1, 2), __warn_unused_result__)))
+int bus_read(const bus_t *restrict, int (*)(const char *, void *), void *);
/**
* Listen (in a loop, forever) for new message on a bus
@@ -249,9 +227,9 @@ int bus_read(const bus_t *restrict, int (*)(const char *, void *), void *)
* it most be a predictable clock
* @return 0 on success, -1 on error
*/
+BUS_COMPILER_GCC(__attribute__((__nonnull__(1, 2), __warn_unused_result__)))
int bus_read_timed(const bus_t *restrict, int (*)(const char *, void *),
- void *, const struct timespec *, clockid_t)
- BUS_COMPILER_GCC(__attribute__((__nonnull__(1, 2), __warn_unused_result__)));
+ void *, const struct timespec *, clockid_t);
/**
@@ -265,8 +243,8 @@ int bus_read_timed(const bus_t *restrict, int (*)(const char *, void *),
* @param bus Bus information
* @return 0 on success, -1 on error
*/
-int bus_poll_start(bus_t *)
- BUS_COMPILER_GCC(__attribute__((__nonnull__, __warn_unused_result__)));
+BUS_COMPILER_GCC(__attribute__((__nonnull__, __warn_unused_result__)))
+int bus_poll_start(bus_t *);
/**
* Announce that the thread has stopped listening on the bus.
@@ -276,8 +254,8 @@ int bus_poll_start(bus_t *)
* @param bus Bus information
* @return 0 on success, -1 on error
*/
-int bus_poll_stop(const bus_t *)
- BUS_COMPILER_GCC(__attribute__((__nonnull__, __warn_unused_result__)));
+BUS_COMPILER_GCC(__attribute__((__nonnull__, __warn_unused_result__)))
+int bus_poll_stop(const bus_t *);
/**
* Wait for a message to be broadcasted on the bus.
@@ -292,8 +270,8 @@ int bus_poll_stop(const bus_t *)
* `EAGAIN` if there isn't already a message available on the bus
* @return The received message, `NULL` on error
*/
-const char *bus_poll(bus_t *, int)
- BUS_COMPILER_GCC(__attribute__((__nonnull__, __warn_unused_result__)));
+BUS_COMPILER_GCC(__attribute__((__nonnull__, __warn_unused_result__)))
+const char *bus_poll(bus_t *, int);
/**
* Wait for a message to be broadcasted on the bus.
@@ -310,8 +288,8 @@ const char *bus_poll(bus_t *, int)
* it most be a predictable clock
* @return The received message, `NULL` on error
*/
-const char *bus_poll_timed(bus_t *, const struct timespec *, clockid_t)
- BUS_COMPILER_GCC(__attribute__((__nonnull__(1), __warn_unused_result__)));
+BUS_COMPILER_GCC(__attribute__((__nonnull__(1), __warn_unused_result__)))
+const char *bus_poll_timed(bus_t *, const struct timespec *, clockid_t);
/**
@@ -324,8 +302,8 @@ const char *bus_poll_timed(bus_t *, const struct timespec *, clockid_t)
* @param group The group ID of the bus's new group
* @return 0 on success, -1 on error
*/
-int bus_chown(const char *, uid_t, gid_t)
- BUS_COMPILER_GCC(__attribute__((__nonnull__, __warn_unused_result__)));
+BUS_COMPILER_GCC(__attribute__((__nonnull__, __warn_unused_result__)))
+int bus_chown(const char *, uid_t, gid_t);
/**
* Change the permissions for a bus
@@ -338,8 +316,8 @@ int bus_chown(const char *, uid_t, gid_t)
* edit the bus's associated file
* @return 0 on success, -1 on error
*/
-int bus_chmod(const char *, mode_t)
- BUS_COMPILER_GCC(__attribute__((__nonnull__, __warn_unused_result__)));
+BUS_COMPILER_GCC(__attribute__((__nonnull__, __warn_unused_result__)))
+int bus_chmod(const char *, mode_t);
diff --git a/doc/info/bus.texinfo b/bus.texinfo
index be50cea..be50cea 100644
--- a/doc/info/bus.texinfo
+++ b/bus.texinfo
diff --git a/doc/man/bus_chmod.3 b/bus_chmod.3
index c2ac3f9..ab8cb14 100644
--- a/doc/man/bus_chmod.3
+++ b/bus_chmod.3
@@ -1,4 +1,4 @@
-.TH BUS_CHMOD 3 BUS-%VERSION%
+.TH BUS_CHMOD 3 BUS
.SH NAME
bus_chmod - Change bus mode bits
.SH SYNOPSIS
@@ -54,11 +54,3 @@ as well as any errors specified for the \fIIPC_STAT\fP and
.BR bus_open (3),
.BR bus_read (3),
.BR stat (3)
-.SH AUTHORS
-Principal author, Mattias Andrée. See the LICENSE file for the full
-list of authors.
-.SH LICENSE
-MIT/X Consortium License.
-.SH BUGS
-Please report bugs to https://github.com/maandree/bus/issues or to
-maandree@member.fsf.org
diff --git a/doc/man/bus_chown.3 b/bus_chown.3
index c047d83..d90b131 100644
--- a/doc/man/bus_chown.3
+++ b/bus_chown.3
@@ -1,4 +1,4 @@
-.TH BUS_CHOWN 3 BUS-%VERSION%
+.TH BUS_CHOWN 3 BUS
.SH NAME
bus_chown - Change bus owner and group
.SH SYNOPSIS
@@ -41,11 +41,3 @@ as well as any errors specified for the \fIIPC_STAT\fP and
.BR bus_open (3),
.BR bus_read (3),
.BR stat (3)
-.SH AUTHORS
-Principal author, Mattias Andrée. See the LICENSE file for the full
-list of authors.
-.SH LICENSE
-MIT/X Consortium License.
-.SH BUGS
-Please report bugs to https://github.com/maandree/bus/issues or to
-maandree@member.fsf.org
diff --git a/doc/man/bus_close.3 b/bus_close.3
index dc35e6b..13fe22a 100644
--- a/doc/man/bus_close.3
+++ b/bus_close.3
@@ -1,4 +1,4 @@
-.TH BUS_CLOSE 3 BUS-%VERSION%
+.TH BUS_CLOSE 3 BUS
.SH NAME
bus_close - Close a bus
.SH SYNOPSIS
@@ -26,11 +26,3 @@ The bus does not exist.
.BR libbus (7),
.BR bus_open (3),
.BR bus_unlink (3)
-.SH AUTHORS
-Principal author, Mattias Andrée. See the LICENSE file for the full
-list of authors.
-.SH LICENSE
-MIT/X Consortium License.
-.SH BUGS
-Please report bugs to https://github.com/maandree/bus/issues or to
-maandree@member.fsf.org
diff --git a/doc/man/bus_create.3 b/bus_create.3
index 88e6efe..8552b95 100644
--- a/doc/man/bus_create.3
+++ b/bus_create.3
@@ -1,4 +1,4 @@
-.TH BUS_CREATE 3 BUS-%VERSION%
+.TH BUS_CREATE 3 BUS
.SH NAME
bus_create - Create a new bus
.SH SYNOPSIS
@@ -53,11 +53,3 @@ and
.BR bus_open (3),
.BR open (2),
.BR write (2)
-.SH AUTHORS
-Principal author, Mattias Andrée. See the LICENSE file for the full
-list of authors.
-.SH LICENSE
-MIT/X Consortium License.
-.SH BUGS
-Please report bugs to https://github.com/maandree/bus/issues or to
-maandree@member.fsf.org
diff --git a/doc/man/bus_open.3 b/bus_open.3
index 683ae9b..35abb27 100644
--- a/doc/man/bus_open.3
+++ b/bus_open.3
@@ -1,4 +1,4 @@
-.TH BUS_OPEN 3 BUS-%VERSION%
+.TH BUS_OPEN 3 BUS
.SH NAME
bus_open - Open a bus
.SH SYNOPSIS
@@ -57,11 +57,3 @@ specified for the routine
.BR bus_read (3),
.BR bus_poll (3),
.BR open (2)
-.SH AUTHORS
-Principal author, Mattias Andrée. See the LICENSE file for the full
-list of authors.
-.SH LICENSE
-MIT/X Consortium License.
-.SH BUGS
-Please report bugs to https://github.com/maandree/bus/issues or to
-maandree@member.fsf.org
diff --git a/doc/man/bus_poll.3 b/bus_poll.3
index 95271ca..f916237 100644
--- a/doc/man/bus_poll.3
+++ b/bus_poll.3
@@ -1,4 +1,4 @@
-.TH BUS_POLL 3 BUS-%VERSION%
+.TH BUS_POLL 3 BUS
.SH NAME
bus_poll_start, bus_poll_stop, bus_poll, bus_poll_timed - Wait a message to be broadcasted
.SH SYNOPSIS
@@ -77,11 +77,3 @@ function may also set \fIerrno\fP to any of the errors specified for
.BR bus_read (3),
.BR semop (3),
.BR clock_gettime (3)
-.SH AUTHORS
-Principal author, Mattias Andrée. See the LICENSE file for the full
-list of authors.
-.SH LICENSE
-MIT/X Consortium License.
-.SH BUGS
-Please report bugs to https://github.com/maandree/bus/issues or to
-maandree@member.fsf.org
diff --git a/doc/man/bus_read.3 b/bus_read.3
index 1caadfb..36fd4c9 100644
--- a/doc/man/bus_read.3
+++ b/bus_read.3
@@ -1,4 +1,4 @@
-.TH BUS_READ 3 BUS-%VERSION%
+.TH BUS_READ 3 BUS
.SH NAME
bus_read, bus_read_timed - Listen for new messages a bus
.SH SYNOPSIS
@@ -69,11 +69,3 @@ function may also set \fIerrno\fP to any of the errors specified for
.BR bus_poll (3),
.BR semop (3),
.BR clock_gettime (3)
-.SH AUTHORS
-Principal author, Mattias Andrée. See the LICENSE file for the full
-list of authors.
-.SH LICENSE
-MIT/X Consortium License.
-.SH BUGS
-Please report bugs to https://github.com/maandree/bus/issues or to
-maandree@member.fsf.org
diff --git a/doc/man/bus_unlink.3 b/bus_unlink.3
index 83ec760..bd1891a 100644
--- a/doc/man/bus_unlink.3
+++ b/bus_unlink.3
@@ -1,4 +1,4 @@
-.TH BUS_UNLINK 3 BUS-%VERSION%
+.TH BUS_UNLINK 3 BUS
.SH NAME
bus_unlink - Remove a bus
.SH SYNOPSIS
@@ -46,11 +46,3 @@ and
.BR open (2),
.BR semget (3),
.BR shmget (3)
-.SH AUTHORS
-Principal author, Mattias Andrée. See the LICENSE file for the full
-list of authors.
-.SH LICENSE
-MIT/X Consortium License.
-.SH BUGS
-Please report bugs to https://github.com/maandree/bus/issues or to
-maandree@member.fsf.org
diff --git a/doc/man/bus_write.3 b/bus_write.3
index 4513c29..833396e 100644
--- a/doc/man/bus_write.3
+++ b/bus_write.3
@@ -1,4 +1,4 @@
-.TH BUS_WRITE 3 BUS-%VERSION%
+.TH BUS_WRITE 3 BUS
.SH NAME
bus_write, bus_write_timed - Broadcast a message a bus
.SH SYNOPSIS
@@ -54,11 +54,3 @@ function may also set \fIerrno\fP to any of the errors specified for
.BR bus_chown (3),
.BR bus_chmod (3),
.BR clock_gettime (3)
-.SH AUTHORS
-Principal author, Mattias Andrée. See the LICENSE file for the full
-list of authors.
-.SH LICENSE
-MIT/X Consortium License.
-.SH BUGS
-Please report bugs to https://github.com/maandree/bus/issues or to
-maandree@member.fsf.org
diff --git a/config.mk b/config.mk
new file mode 100644
index 0000000..6f9acdb
--- /dev/null
+++ b/config.mk
@@ -0,0 +1,6 @@
+PREFIX = /usr/local
+MANPREFIX = $(PREFIX)/share/man
+
+CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_XOPEN_SOURCE=700 -D_GNU_SOURCE
+CFLAGS = -std=c99 -Wall -Wextra -pedantic -O2 $(CPPFLAGS)
+LDFLAGS = -s -lrt
diff --git a/dist/arch/stable/.gitignore b/dist/arch/stable/.gitignore
deleted file mode 100644
index ccea0b1..0000000
--- a/dist/arch/stable/.gitignore
+++ /dev/null
@@ -1,6 +0,0 @@
-*
-!/.git*
-*~
-!/PKGBUILD
-!/bus.install
-
diff --git a/dist/arch/stable/PKGBUILD b/dist/arch/stable/PKGBUILD
deleted file mode 100644
index 1cfedf5..0000000
--- a/dist/arch/stable/PKGBUILD
+++ /dev/null
@@ -1,27 +0,0 @@
-# Maintainer: Mattias Andrée <`base64 -d`(bWFhbmRyZWUK)@member.fsf.org>
-
-pkgname=bus
-pkgver=3.1.6
-pkgrel=2
-pkgdesc="A simple daemonless system for broadcasting messages locally"
-arch=(i686 x86_64)
-url="https://github.com/maandree/bus"
-license=('MIT')
-depends=()
-makedepends=()
-install=bus.install
-source=($url/archive/$pkgver.tar.gz)
-sha256sums=(79683d48e8bcea44a564510b27d438ebf46a1080e8d51c6d2eeae324b87b087a)
-
-
-build() {
- cd "$srcdir/$pkgname-$pkgver"
- make PREFIX=/usr
-}
-
-
-package() {
- cd "$srcdir/$pkgname-$pkgver"
- make PREFIX=/usr install DESTDIR="$pkgdir"
-}
-
diff --git a/dist/arch/stable/bus.install b/dist/arch/stable/bus.install
deleted file mode 100644
index 6b67f03..0000000
--- a/dist/arch/stable/bus.install
+++ /dev/null
@@ -1,20 +0,0 @@
-_file="bus"
-
-infodir="usr/share/info"
-file="${_file}.info"
-
-
-post_install() {
- [[ -x "usr/bin/install-info" ]] || return 0
- install-info -- "${infodir}/${file}" "${infodir}/dir" 2> /dev/null
-}
-
-post_upgrade() {
- post_install "$1"
-}
-
-pre_remove() {
- [[ -x "usr/bin/install-info" ]] || return 0
- install-info --delete -- "${infodir}/${file}" "${infodir}/dir" 2> /dev/null
-}
-
diff --git a/doc/protocol b/doc/protocol
index f45799e..116c1b2 100644
--- a/doc/protocol
+++ b/doc/protocol
@@ -45,4 +45,3 @@ and `V(a)` is done when exiting the scope. It also means that
these actions [P(a) and V(a)] are undone when the process exits,
or if the call fails.
`with V(a)` is to `V(a)` as `with P(a)` is to `P(a)`.
-
diff --git a/doc/info/fdl.texinfo b/fdl.texinfo
index cb71f05..cb71f05 100644
--- a/doc/info/fdl.texinfo
+++ b/fdl.texinfo
diff --git a/doc/man/libbus.7 b/libbus.7
index 804ee97..3565b50 100644
--- a/doc/man/libbus.7
+++ b/libbus.7
@@ -1,4 +1,4 @@
-.TH LIBBUS 7 BUS-%VERSION%
+.TH LIBBUS 7 BUS
.SH NAME
libbus - A simple daemonless system for broadcasting messages locally
.SH DESCRIPTION
@@ -29,11 +29,3 @@ None.
.BR bus_poll_timed (3),
.BR bus_chown (3),
.BR bus_chmod (3)
-.SH AUTHORS
-Principal author, Mattias Andrée. See the LICENSE file for the full
-list of authors.
-.SH LICENSE
-MIT/X Consortium License.
-.SH BUGS
-Please report bugs to https://github.com/maandree/bus/issues or to
-maandree@member.fsf.org
diff --git a/src/bus.c b/libbus.c
index e9dd789..0a84353 100644
--- a/src/bus.c
+++ b/libbus.c
@@ -1,45 +1,19 @@
-/**
- * MIT/X Consortium License
- *
- * Copyright © 2015 Mattias Andrée <maandree@member.fsf.org>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- */
-#define _XOPEN_SOURCE 700
-#define _GNU_SOURCE
+/* See LICENSE file for copyright and license details. */
#include "bus.h"
-#include <stdlib.h>
-#include <stdio.h>
-#include <time.h>
-#include <errno.h>
-#include <string.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <time.h>
-
#include <sys/ipc.h>
#include <sys/sem.h>
#include <sys/shm.h>
-
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+#include <time.h>
+#include <unistd.h>
#ifdef BUS_SEMAPHORES_ARE_SYNCHRONOUS_ME_EVEN_HARDER
@@ -54,7 +28,6 @@
#endif
-
/**
* Semaphore used to signal `bus_write` that `bus_read` is ready
*/
@@ -79,14 +52,14 @@
/**
* Semaphore used to notify `bus_read` that it may restore `S`
*/
-#define N 4
+# define N 4
/**
* The number of semaphores in the semaphore array
*/
-#define BUS_SEMAPHORES 5
+# define BUS_SEMAPHORES 5
#else
-#define BUS_SEMAPHORES 4
+# define BUS_SEMAPHORES 4
#endif
/**
@@ -197,8 +170,12 @@
*/
#define DELTA \
do { \
- if (absolute_time_to_delta_time(&delta, timeout, clockid) < 0) goto fail; \
- else if ((delta.tv_sec < 0) || (delta.tv_nsec < 0)) { errno = EAGAIN; goto fail; } \
+ if (absolute_time_to_delta_time(&delta, timeout, clockid) < 0) { \
+ goto fail; \
+ } else if ((delta.tv_sec < 0) || (delta.tv_nsec < 0)) { \
+ errno = EAGAIN; \
+ goto fail; \
+ }\
} while (0)
@@ -206,7 +183,7 @@
* If `flags & (bus_flag)`, this macro evalutes to `sys_flag`,
* otherwise this macro evalutes to 0.
*/
-#define F(bus_flag, sys_flag) \
+#define F(bus_flag, sys_flag) \
((flags & (bus_flag)) ? sys_flag : 0)
@@ -215,7 +192,7 @@
* Statement wrapper that goes to `fail` on failure
*/
#define t(inst) \
- if ((inst) == -1) goto fail
+ do { if ((inst) == -1) goto fail; } while (0)
@@ -1194,4 +1171,3 @@ bus_chmod(const char *file, mode_t mode)
fail:
return -1;
}
-