Skip to content

Commit 13d8b9f

Browse files
committed
0.2 (19991223)
- Decoupled core file prevention from daemon_init() into its own function, daemon_prevent_core() - Decoupled signal handling from daemon_init() - Cached daemon_started_by_init() and daemon_started_by_inetd() results - Fixed bug when formatting --help message - Added some modules to libprog: conf, list, hsort, map, prop - Added timestamps to msg_out_file() - Included source to GNU getopt_long_only() (if necessary) - Added hdr.h to allow non-ANSI compilers to parse libprog's headers - Moved libprog to a subdirectory using a "Whole Project" Makefile - Converted "Whole Project" Makefile into "Scalable" Makefiles - Added verbosity functions to libprog(prog) - Added -core option to allow core file generation - Added -respawn option to allow client respawn if death not too sudden - Added -syslog option to redirect client stdout and stderr to syslog - Added -log option to specify where daemon stdout and stderr are sent - Fixed bug when constructing data for GNU getopt_long_only() - Fixed bugs in the options table for libprog(prog) - Changed help message format: separated option chunks by a blank line - Fixed bug when obtaining names associated with syslog constants - Added -Config option and /etc/daemon.conf handling - Added pathetic conf/linux and conf/solaris scripts - Revert to real uid/gid if not same as effective uid/gid for safety - Added manpages
1 parent 9515486 commit 13d8b9f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+15881
-5881
lines changed

MANIFEST

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
./Makefile
2+
./daemon.c
3+
./macros.mk
4+
./MANIFEST
5+
./README
6+
./prog
7+
./prog/conf.c
8+
./prog/conf.h
9+
./prog/daemon.c
10+
./prog/daemon.h
11+
./prog/err.c
12+
./prog/err.h
13+
./prog/fifo.c
14+
./prog/fifo.h
15+
./prog/getopt.c
16+
./prog/getopt.h
17+
./prog/hdr.h
18+
./prog/hsort.c
19+
./prog/hsort.h
20+
./prog/lim.c
21+
./prog/lim.h
22+
./prog/list.c
23+
./prog/list.h
24+
./prog/log.c
25+
./prog/log.h
26+
./prog/mem.c
27+
./prog/mem.h
28+
./prog/msg.c
29+
./prog/msg.h
30+
./prog/prog.c
31+
./prog/prog.h
32+
./prog/sig.c
33+
./prog/sig.h
34+
./prog/snprintf.c
35+
./prog/snprintf.h
36+
./prog/opt.c
37+
./prog/opt.h
38+
./prog/rules.mk
39+
./prog/macros.mk
40+
./prog/Makefile
41+
./prog/map.c
42+
./prog/map.h
43+
./prog/prop.c
44+
./prog/prop.h
45+
./rules.mk
46+
./conf
47+
./conf/linux
48+
./conf/solaris

Makefile

Lines changed: 128 additions & 146 deletions
Original file line numberDiff line numberDiff line change
@@ -1,155 +1,137 @@
11
#
22
# daemon: http://www.zip.com.au/~raf2/lib/software/daemon
33
#
4-
# Copyright (c) 1999 raf
4+
# Copyright (C) 1999 raf <raf2@zip.com.au>
5+
#
6+
# This program is free software; you can redistribute it and/or modify
7+
# it under the terms of the GNU General Public License as published by
8+
# the Free Software Foundation; either version 2 of the License, or
9+
# (at your option) any later version.
10+
#
11+
# This program is distributed in the hope that it will be useful,
12+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
# GNU General Public License for more details.
15+
#
16+
# You should have received a copy of the GNU General Public License
17+
# along with this program; if not, write to the Free Software
18+
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19+
# or visit http://www.gnu.org/copyleft/gpl.html
520
#
621

7-
# Uncomment these to override the defines in main.h
8-
# PATH_SEP = /
9-
# ROOT_DIR = /
10-
# PID_DIR = /var/run
11-
# ETC_DIR = /etc
12-
# APP = $(TARGETAPP)
13-
# DEFINES += -DPATH_SEP=\"$(PATH_SEP)\" -DROOT_DIR=\"$(ROOT_DIR)\" -DPID_DIR=\"$(PID_DIR)\" -DETC_DIR=\"$(ETC_DIR)\" -DAPP=\"$(APP)\"
14-
15-
# Uncomment these if your system doesn't have snprintf()
16-
# SNPRINTF = snprintf
17-
# DEFINES += -DNEEDS_SNPRINTF=1
18-
19-
# Uncomment this under SVR4 if not predefined
20-
# DEFINES += -DSVR4
21-
22-
PROJECT = daemon
23-
VERSION = 0.1
24-
TARGETAPP = daemon
25-
TARGETLIBNAME = prog
26-
INSTALLIBNAME = $(TARGETLIBNAME)-$(VERSION)
27-
TARGETLIB = lib$(TARGETLIBNAME).a
28-
INSTALLIB = lib$(INSTALLIBNAME).a
29-
TARGETDIST = $(PROJECT)-$(VERSION).tar.gz
30-
31-
PREFIX = /usr/local
32-
APPINSDIR = $(PREFIX)/bin
33-
LIBINSDIR = $(PREFIX)/lib
34-
MANINSDIR = $(PREFIX)/man
35-
HDRINSDIR = $(PREFIX)/include/$(TARGETLIBNAME)
36-
APPMANSECT = 1
37-
LIBMANSECT = 3
38-
39-
APPFILES = main
40-
APPCFILES = $(patsubst %,%.c,$(APPFILES))
41-
APPOFILES = $(patsubst %,%.o,$(APPFILES))
42-
APPHFILES = # $(patsubst %,%.h,$(APPFILES))
43-
APPMFILES = $(TARGETAPP).$(APPMANSECT)
44-
APPMANDIR = $(MANINSDIR)/man$(APPMANSECT)
45-
APPCATDIR = $(MANINSDIR)/cat$(APPMANSECT)
46-
47-
LIBFILES = daemon prog opt mem msg err sig lim slog fifo $(SNPRINTF)
48-
LIBCFILES = $(patsubst %,%.c,$(LIBFILES))
49-
LIBOFILES = $(patsubst %,%.o,$(LIBFILES))
50-
LIBHFILES = $(patsubst %,%.h,$(LIBFILES))
51-
LIBMFILES = $(patsubst %,%.$(LIBMANSECT),$(LIBFILES)) lib$(TARGETLIBNAME).$(LIBMANSECT)
52-
LIBMANDIR = $(MANINSDIR)/man$(LIBMANSECT)
53-
LIBTESTS = $(patsubst %,%.test,$(LIBFILES))
54-
55-
DEFINES += -DBUILD_PROG
56-
57-
CFLAGS = -g -O2 $(DEFINES) -Wall -pedantic
58-
LDFLAGS = -L. -l$(TARGETLIBNAME)
59-
ARFLAGS = cr
60-
61-
$(TARGETAPP): $(APPOFILES) $(TARGETLIB)
62-
$(CC) $(CFLAGS) -o $(TARGETAPP) $(APPOFILES) $(LDFLAGS)
63-
64-
$(TARGETLIB): $(LIBOFILES)
65-
$(AR) $(ARFLAGS) $(TARGETLIB) $(LIBOFILES)
66-
67-
$(LIBTESTS): $(TARGETLIB)
68-
%.test: %.c
69-
$(CC) $(CFLAGS) -DTEST -o $@ $< $(LDFLAGS)
70-
71-
test: $(LIBTESTS)
72-
@for i in $(LIBTESTS); do ./$$i; echo; done
73-
74-
tags:
75-
@ctags $(APPCFILES) $(APPHFILES) $(LIBCFILES) $(LIBHFILES)
76-
77-
depend dep: $(APPCFILES) $(APPHFILES) $(LIBCFILES) $(LIBHFILES)
78-
@makedepend $(DEFINES) $(APPCFILES) $(LIBCFILES)
79-
80-
clean:
81-
@rm -f $(APPOFILES) $(LIBOFILES) tags core Makefile.bak .makefile.bak
82-
83-
clobber: clean
84-
@rm -f $(TARGETAPP) $(TARGETLIB) $(LIBTESTS)
85-
86-
dist-clobber: clobber
87-
@perl -pi -e 'last if /[D]O NOT DELETE/;' Makefile
88-
89-
dist: dist-clobber
90-
@srcdir=`basename \`pwd\``; cd ..; tar czf $(TARGETDIST) $$srcdir
91-
92-
install: install-app install-lib
93-
install-app: install-app-bin # install-app-man
94-
install-lib: install-lib-bin install-lib-h # install-lib-man
95-
96-
install-app-bin:
97-
install -m 555 $(TARGETAPP) $(APPINSDIR)
98-
#install-app-man:
99-
# install -m 444 $(APPMFILES) $(APPMANDIR)
100-
install-lib-bin:
101-
install -m 555 $(TARGETLIB) $(LIBINSDIR)/$(INSTALLIB)
102-
rm -f $(LIBINSDIR)/$(TARGETLIB)
103-
ln -s $(INSTALLIB) $(LIBINSDIR)/$(TARGETLIB)
104-
install-lib-h:
105-
-[ ! -d $(HDRINSDIR) ] && mkdir -p $(HDRINSDIR)
106-
install -m 444 $(LIBHFILES) $(HDRINSDIR)
107-
#install-lib-man:
108-
# install -m 444 $(LIBMFILES) $(LIBMANDIR)
109-
110-
uninstall: uninstall-app uninstall-lib
111-
uninstall-app: uninstall-app-bin # uninstall-app-man
112-
uninstall-lib: uninstall-lib-bin uninstall-lib-h # uninstall-lib-man
113-
114-
uninstall-app-bin:
115-
-cd $(APPINSDIR) && rm -f $(TARGETAPP)
116-
#uninstall-app-man:
117-
# -cd $(APPMANDIR) && rm -f $(APPMFILES) && cd $(APPCATDIR) && rm -f $(APPMFILES)
118-
uninstall-lib-bin:
119-
-cd $(LIBINSDIR) && rm -f $(TARGETLIB) $(INSTALLIB)
120-
uninstall-lib-h:
121-
-cd $(HDRINSDIR) && rm -f $(LIBHFILES) && cd .. && rmdir $(HDRINSDIR)
122-
#uninstall-lib-man:
123-
# cd $(LIBMANDIR) && rm -f $(LIBMFILES)
124-
125-
help:
22+
CC := gcc
23+
TEST := /usr/bin/test
24+
PREFIX := /usr/local
25+
APP_INSDIR := $(PREFIX)/bin
26+
LIB_INSDIR := $(PREFIX)/lib
27+
MAN_INSDIR := $(PREFIX)/man
28+
HDR_INSDIR := $(PREFIX)/include
29+
APP_MANSECT := 1
30+
LIB_MANSECT := 3
31+
APP_MANDIR := $(MAN_INSDIR)/man$(APP_MANSECT)
32+
APP_CATDIR := $(MAN_INSDIR)/cat$(APP_MANSECT)
33+
LIB_MANDIR := $(MAN_INSDIR)/man$(LIB_MANSECT)
34+
LIB_CATDIR := $(MAN_INSDIR)/cat$(LIB_MANSECT)
35+
APP_MANSECTNAME := User Commands
36+
LIB_MANSECTNAME := C Library Functions - libprog
37+
38+
CCFLAGS += -O2 # -Wall -pedantic
39+
40+
CLEAN_FILES += tags core Makefile.bak .makefile.bak MANIFEST pod2html-*
41+
42+
DAEMON_SRCDIR := .
43+
DAEMON_INCDIRS := prog
44+
DAEMON_LIBDIRS := prog
45+
include $(DAEMON_SRCDIR)/macros.mk
46+
47+
.PHONY: all ready test man html install uninstall
48+
49+
all: ready $(ALL_TARGETS)
50+
ready: $(READY_TARGETS)
51+
test: ready $(TEST_TARGETS)
52+
man: $(MAN_TARGETS)
53+
html: $(HTML_TARGETS)
54+
install: $(INSTALL_TARGETS)
55+
uninstall: $(UNINSTALL_TARGETS)
56+
57+
.PHONY: help help-macros depend dep clean clobber distclean dist
58+
59+
help::
12660
@echo "This makefile provides the following targets."
12761
@echo
128-
@echo "make $(TARGETAPP) -- makes $(TARGETAPP) and $(TARGETLIB) (default)"
129-
@echo "make $(TARGETLIB) -- just makes $(TARGETLIB)"
130-
@echo "make tags -- generates a tags file using ctags"
131-
@echo "make depend -- generates source dependencies using makedepend"
132-
@echo "make dep -- same as depend"
133-
@echo "make clean -- removes object files, tags, core and Makefile.bak"
134-
@echo "make clobber -- same as clean but also removes $(TARGETAPP) and $(TARGETLIB)"
135-
@echo "make dist-clobber -- same as clobber but also removes source dependencies"
136-
@echo "make dist -- creates the distribution: ../$(TARGETDIST)"
137-
@echo "make install -- installs everything under $(PREFIX)"
138-
@echo "make install-app -- installs $(TARGETAPP) and its man page"
139-
@echo "make install-app-bin -- installs $(TARGETAPP) in $(APPINSDIR)"
140-
@echo "make install-app-man -- installs the $(TARGETAPP) man page in $(APPMANDIR)"
141-
@echo "make install-lib -- installs $(TARGETLIB), its headers and man pages"
142-
@echo "make install-lib-bin -- installs $(TARGETLIB) in $(LIBINSDIR)"
143-
@echo "make install-lib-h -- installs $(TARGETLIB) headers in $(HDRINSDIR)"
144-
@echo "make install-lib-man -- installs $(TARGETLIB) man pages in $(LIBMANDIR)"
145-
@echo "make uninstall -- uninstalls everything"
146-
@echo "make uninstall-app -- uninstalls $(TARGETAPP) and its man page"
147-
@echo "make uninstall-app-bin -- uninstalls $(TARGETAPP) from $(APPINSDIR)"
148-
@echo "make uninstall-app-man -- uninstalls the $(TARGETAPP) man page from $(APPMANDIR)"
149-
@echo "make uninstall-lib -- uninstalls $(TARGETLIB), its headers and man pages"
150-
@echo "make uninstall-lib-bin -- uninstalls $(TARGETLIB) from $(LIBINSDIR)"
151-
@echo "make uninstall-lib-h -- uninstalls $(TARGETLIB) headers from $(HDRINSDIR)"
152-
@echo "make uninstall-lib-man -- uninstalls $(TARGETLIB) man pages from $(LIBMANDIR)"
153-
@echo "make help -- shows this list of targets"
62+
@echo "make help -- shows this list of targets"
63+
@echo "make help-macros -- shows the values of all make macros"
64+
@echo "make ready -- prepares the source directory for make"
65+
@echo "make all -- makes $(DAEMON_TARGET) and $(DAEMON_SUBMODULES) (default)"
66+
@echo "make test -- generates and performs library unit tests"
67+
@echo "make man -- generates all manpages"
68+
@echo "make html -- generates all manpages in html"
69+
@echo "make install -- installs everything under $(PREFIX)"
70+
@echo "make uninstall -- uninstalls everything"
71+
@echo "make depend -- generates source dependencies using makedepend"
72+
@echo "make tags -- generates a tags file using ctags"
73+
@echo "make clean -- removes object files, tags, core and Makefile.bak"
74+
@echo "make clobber -- same as clean but also removes $(DAEMON_TARGET), $(DAEMON_SUBMODULES) and tests"
75+
@echo "make distclean -- same as clobber but also removes source dependencies"
76+
@echo "make MANIFEST -- creates the MANIFEST file"
77+
@echo "make dist -- creates the distribution: ../$(DAEMON_DIST)"
78+
@echo
79+
80+
help-macros::
81+
@echo "CC = $(CC)"
82+
@echo "TEST = $(TEST)"
83+
@echo "PREFIX = $(PREFIX)"
84+
@echo "APP_INSDIR = $(APP_INSDIR)"
85+
@echo "LIB_INSDIR = $(LIB_INSDIR)"
86+
@echo "MAN_INSDIR = $(MAN_INSDIR)"
87+
@echo "HDR_INSDIR = $(HDR_INSDIR)"
88+
@echo "APP_MANSECT = $(APP_MANSECT)"
89+
@echo "LIB_MANSECT = $(LIB_MANSECT)"
90+
@echo "APP_MANDIR = $(APP_MANDIR)"
91+
@echo "APP_CATDIR = $(APP_CATDIR)"
92+
@echo "LIB_MANDIR = $(LIB_MANDIR)"
93+
@echo "LIB_CATDIR = $(LIB_CATDIR)"
94+
@echo "TAG_FILES = $(TAG_FILES)"
95+
@echo "DEPEND_CFILES = $(DEPEND_CFILES)"
96+
@echo "DEPEND_HFILES = $(DEPEND_HFILES)"
97+
@echo "CCFLAGS = $(CCFLAGS)"
98+
@echo "READY_TARGETS = $(READY_TARGETS)"
99+
@echo "ALL_TARGETS = $(ALL_TARGETS)"
100+
@echo "TEST_TARGETS = $(TEST_TARGETS)"
101+
@echo "MAN_TARGETS = $(MAN_TARGETS)"
102+
@echo "HTML_TARGETS = $(HTML_TARGETS)"
103+
@echo "INSTALL_TARGETS = $(INSTALL_TARGETS)"
104+
@echo "UNINSTALL_TARGETS = $(UNINSTALL_TARGETS)"
105+
@echo "CLEAN_FILES = $(CLEAN_FILES)"
106+
@echo "CLOBBER_FILES = $(CLOBBER_FILES)"
154107
@echo
155108

109+
MANIFEST:
110+
@find . -name \* -print > MANIFEST
111+
112+
tags: $(TAG_FILES)
113+
@ctags $(TAG_FILES)
114+
115+
depend: ready $(DEPEND_CFILES) $(DEPEND_HFILES)
116+
@makedepend $(DAEMON_CPPFLAGS) $(DEPEND_CFILES)
117+
118+
clean::
119+
@rm -rf $(CLEAN_FILES)
120+
121+
clobber::
122+
@rm -rf $(CLEAN_FILES) $(CLOBBER_FILES)
123+
124+
distclean:: clobber
125+
@perl -pi -e 'last if /[D]O NOT DELETE/;' Makefile
126+
127+
dist: distclean MANIFEST
128+
@src=`basename \`pwd\``; \
129+
dst=$(DAEMON_ID); \
130+
cd ..; \
131+
$(TEST) "$$src" != "$$dst" -a ! -e "$$dst" && ln -s $$src $$dst; \
132+
tar chzf $(DAEMON_DIST) $$dst; \
133+
$(TEST) -L "$$dst" && rm -f $$dst; \
134+
rm $$src/MANIFEST
135+
136+
include $(DAEMON_SRCDIR)/rules.mk
137+

0 commit comments

Comments
 (0)