From: Sami Kerola Date: Sat, 24 Nov 2012 11:43:35 +0000 (+0000) Subject: includes: make inclusions clean X-Git-Tag: cronie1.4.10~12 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=17660c928417e4cf0e7f446a24c321c02dccb7ea;p=cronie includes: make inclusions clean This change makes files to include what they need, instead of having generic inclusion headers which will include everything to everywhere. Also the local headers havee ifndef & define protection, which makes them to be save to include in any file, without one having to think in which order the inclusions happen at compile time. Signed-off-by: Sami Kerola --- diff --git a/src/Makefile.am b/src/Makefile.am index 60dd103..86e7dc3 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -7,7 +7,7 @@ crond_SOURCES = \ cron.c database.c user.c job.c do_command.c popen.c \ $(common_src) crontab_SOURCES = crontab.c $(common_src) -common_src = entry.c env.c misc.c pw_dup.c security.c cron.h \ +common_src = entry.c env.c misc.c pw_dup.c security.c \ externs.h funcs.h globals.h macros.h pathnames.h structs.h \ bitstring.h common_nodist = cron-paths.h diff --git a/src/cron.c b/src/cron.c index cd36a90..47444a2 100644 --- a/src/cron.c +++ b/src/cron.c @@ -24,9 +24,33 @@ * to add clustering support. */ +#include "config.h" + #define MAIN_PROGRAM -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef WITH_INOTIFY +# include +#endif + +#ifdef HAVE_SYS_FCNTL_H +# include +#endif + +#include "funcs.h" +#include "globals.h" +#include "pathnames.h" #if defined WITH_INOTIFY int inotify_enabled; diff --git a/src/cron.h b/src/cron.h deleted file mode 100644 index dff8fc1..0000000 --- a/src/cron.h +++ /dev/null @@ -1,51 +0,0 @@ -/* Copyright 1988,1990,1993,1994 by Paul Vixie - * All rights reserved - */ - -/* - * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") - * Copyright (c) 1997,2000 by Internet Software Consortium, Inc. - * - * 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 ISC DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC 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. - */ - -/* cron.h - header for vixie's cron - * - * $Id: cron.h,v 1.6 2004/01/23 18:56:42 vixie Exp $ - * - * vix 14nov88 [rest of log is in RCS] - * vix 14jan87 [0 or 7 can be sunday; thanks, mwm@berkeley] - * vix 30dec86 [written] - */ - -#include "../config.h" -#include "externs.h" - -#ifdef WITH_SELINUX -#include -#endif - -#ifdef WITH_PAM -#include -#endif - -#ifdef WITH_INOTIFY -#include -#endif - -#include "pathnames.h" -#include "macros.h" -#include "structs.h" -#include "funcs.h" -#include "globals.h" - diff --git a/src/crontab.c b/src/crontab.c index baec62c..ce4664d 100644 --- a/src/crontab.c +++ b/src/crontab.c @@ -29,15 +29,41 @@ * to add clustering support. */ +#include "config.h" + #define MAIN_PROGRAM -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef WITH_PAM +# include +#endif + #ifdef WITH_SELINUX # include # include # include #endif +#include "bitstring.h" +#include "externs.h" +#include "funcs.h" +#include "globals.h" +#include "macros.h" +#include "pathnames.h" +#include "structs.h" + #define NHEADER_LINES 0 enum opt_t {opt_unknown, opt_list, opt_delete, opt_edit, opt_replace, opt_hostset, opt_hostget}; diff --git a/src/database.c b/src/database.c index 52f033c..c3b922f 100644 --- a/src/database.c +++ b/src/database.c @@ -27,7 +27,25 @@ * to add clustering support. */ -#include +#include "config.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef WITH_INOTIFY +# include +#endif + +#include "funcs.h" +#include "globals.h" +#include "pathnames.h" #define TMAX(a,b) ((a)>(b)?(a):(b)) diff --git a/src/do_command.c b/src/do_command.c index be261a9..bde800f 100644 --- a/src/do_command.c +++ b/src/do_command.c @@ -19,7 +19,26 @@ * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include +#include "config.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "externs.h" +#include "funcs.h" +#include "globals.h" +#include "structs.h" + +#ifndef isascii +# define isascii(c) ((unsigned)(c)<=0177) +#endif static int child_process(entry *, char **); static int safe_p(const char *, const char *); diff --git a/src/entry.c b/src/entry.c index f6a45bb..78c8a85 100644 --- a/src/entry.c +++ b/src/entry.c @@ -26,7 +26,21 @@ * vix 30dec86 [written] */ -#include +#include "config.h" + +#include +#include +#include +#include +#include +#include +#include + +#include "bitstring.h" +#include "funcs.h" +#include "globals.h" +#include "macros.h" +#include "pathnames.h" typedef enum ecode { e_none, e_minute, e_hour, e_dom, e_month, e_dow, diff --git a/src/env.c b/src/env.c index 61ae74c..037d7c8 100644 --- a/src/env.c +++ b/src/env.c @@ -19,7 +19,15 @@ * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include +#include "config.h" + +#include +#include +#include +#include + +#include "globals.h" +#include "funcs.h" char **env_init(void) { char **p = (char **) malloc(sizeof (char *)); diff --git a/src/externs.h b/src/externs.h index 9c01d2c..c79ca3b 100644 --- a/src/externs.h +++ b/src/externs.h @@ -21,40 +21,8 @@ /* reorder these #include's at your peril */ -#include -#include -#include -#include -#ifdef HAVE_SYS_FCNTL_H -#include -#endif -#include -/* stat is used even, when --with-inotify */ -#include - -#include -#include -#ifndef isascii -#define isascii(c) ((unsigned)(c)<=0177) -#endif -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#if defined(SYSLOG) -# include -#endif +#ifndef CRONIE_EXTERNS_H +#define CRONIE_EXTERNS_H #if defined(LOGIN_CAP) # include @@ -64,12 +32,6 @@ # include #endif /*BSD_AUTH*/ -/* include locale stuff for mailer "Content-Type": - */ -#include -#include -#include - #define DIR_T struct dirent #define WAIT_T int #define SIG_T sig_t @@ -125,3 +87,5 @@ extern int flock(int, int); #ifndef WCOREDUMP # define WCOREDUMP(st) (((st) & 0200) != 0) #endif + +#endif /* CRONIE_EXTERNS_H */ diff --git a/src/funcs.h b/src/funcs.h index e796574..d16d40e 100644 --- a/src/funcs.h +++ b/src/funcs.h @@ -20,10 +20,17 @@ */ /* Notes: - * This file has to be included by cron.h after data structure defs. * We should reorg this into sections by module. */ +#ifndef CRONIE_FUNCS_H +#define CRONIE_FUNCS_H + +#include + +#include "externs.h" +#include "structs.h" + void set_cron_uid(void), check_spool_dir(void), open_logfile(void), @@ -111,3 +118,5 @@ int crontab_security_access(void); /* PAM */ int cron_start_pam(struct passwd *pw); void cron_close_pam(void); + +#endif /* CRONIE_FUNCS_H */ diff --git a/src/globals.h b/src/globals.h index 8abdb73..4370974 100644 --- a/src/globals.h +++ b/src/globals.h @@ -24,6 +24,13 @@ * to add clustering support. */ +#ifndef CRONIE_GLOBALS_H +#define CRONIE_GLOBALS_H + +#include + +#include "macros.h" + #ifdef MAIN_PROGRAM # define XTRN # define INIT(x) = x @@ -88,3 +95,5 @@ XTRN const char *DebugFlagNames[] #else #define DebugFlags 0 #endif /* DEBUGGING */ + +#endif /* CRONIE_GLOBALS_H */ diff --git a/src/job.c b/src/job.c index 5ea7d98..8ad14db 100644 --- a/src/job.c +++ b/src/job.c @@ -19,7 +19,12 @@ * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include +#include "config.h" + +#include + +#include "funcs.h" +#include "globals.h" typedef struct _job { struct _job *next; diff --git a/src/macros.h b/src/macros.h index 4981a01..fbf40b1 100644 --- a/src/macros.h +++ b/src/macros.h @@ -18,6 +18,10 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ + +#ifndef CRONIE_MACROS_H +#define CRONIE_MACROS_H + #ifdef HAVE_LIMITS_H #include #endif @@ -130,3 +134,5 @@ #ifndef O_NOFOLLOW #define O_NOFOLLOW 0 #endif + +#endif /* CRONIE_MACROS_H */ diff --git a/src/misc.c b/src/misc.c index a9b7103..106f10e 100644 --- a/src/misc.c +++ b/src/misc.c @@ -23,7 +23,22 @@ * vix 30dec86 [written] */ -#include +#include "config.h" + +#include "globals.h" + +#include +#include +#include +#include +#include +#include +#include + +#if defined(SYSLOG) +# include +#endif + #ifdef WITH_AUDIT # include #endif @@ -37,7 +52,10 @@ #ifdef HAVE_FLOCK /* flock(2) */ # include #endif -#include + +#include "funcs.h" +#include "macros.h" +#include "pathnames.h" #if defined(SYSLOG) && defined(LOG_FILE) # undef LOG_FILE @@ -619,7 +637,7 @@ char *first_word(const char *s, const char *t) { /* warning: * heavily ascii-dependent. */ -void mkprint(char *dst, unsigned char *src, int len) { +static void mkprint(char *dst, unsigned char *src, int len) { /* * XXX * We know this routine can't overflow the dst buffer because mkprints() diff --git a/src/popen.c b/src/popen.c index caa7e8a..aa36ff7 100644 --- a/src/popen.c +++ b/src/popen.c @@ -30,11 +30,24 @@ * */ +#include "config.h" + +#include +#include +#include +#include +#include +#include +#include + +#include "funcs.h" +#include "globals.h" +#include "macros.h" + #ifdef HAVE_SYS_CDEFS_H # include #endif -#include #include /* diff --git a/src/pw_dup.c b/src/pw_dup.c index 23da57e..ea787cd 100644 --- a/src/pw_dup.c +++ b/src/pw_dup.c @@ -30,7 +30,8 @@ * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include +#include "config.h" + #include #if !defined(OpenBSD) || OpenBSD < 200105 @@ -40,6 +41,9 @@ #include #include +#include "funcs.h" +#include "globals.h" + struct passwd * pw_dup(const struct passwd *pw) { char *cp; diff --git a/src/security.c b/src/security.c index e27bddc..405dd5d 100644 --- a/src/security.c +++ b/src/security.c @@ -19,7 +19,20 @@ * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include +#include "config.h" + +#include +#include +#include +#include +#include + +#include "funcs.h" +#include "globals.h" + +#ifdef WITH_PAM +# include +#endif #ifdef WITH_SELINUX # include diff --git a/src/structs.h b/src/structs.h index 16cd180..99d050e 100644 --- a/src/structs.h +++ b/src/structs.h @@ -19,6 +19,13 @@ * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifndef CRONIE_STRUCTS_H +#define CRONIE_STRUCTS_H + +#include +#include "macros.h" +#include "bitstring.h" + typedef struct _entry { struct _entry *next; struct passwd *pwd; @@ -75,3 +82,5 @@ typedef struct _cron_db { * variables for the main program, just * extern them elsewhere. */ + +#endif /* CRONIE_STRUCTS_H */ diff --git a/src/user.c b/src/user.c index 367f963..9b11d01 100644 --- a/src/user.c +++ b/src/user.c @@ -22,7 +22,15 @@ /* vix 26jan87 [log is in RCS file] */ -#include +#include "config.h" + +#include +#include +#include +#include + +#include "funcs.h" +#include "globals.h" static const char *FileName;