root/anacron/global.h

/* [previous][next][first][last][top][bottom][index][help]  */

INCLUDED FROM


   1 /*
   2     Anacron - run commands periodically
   3     Copyright (C) 1998  Itai Tzur <itzur@actcom.co.il>
   4     Copyright (C) 1999  Sean 'Shaleh' Perry <shaleh@debian.org>
   5     Copyright (C) 2004  Pascal Hakim <pasc@redellipse.net>
   6 
   7     This program is free software; you can redistribute it and/or modify
   8     it under the terms of the GNU General Public License as published by
   9     the Free Software Foundation; either version 2 of the License, or
  10     (at your option) any later version.
  11 
  12     This program is distributed in the hope that it will be useful,
  13     but WITHOUT ANY WARRANTY; without even the implied warranty of
  14     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15     GNU General Public License for more details.
  16 
  17     You should have received a copy of the GNU General Public License along
  18     with this program; if not, write to the Free Software Foundation, Inc.,
  19     51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  20 
  21     The GNU General Public License can also be found in the file
  22     `COPYING' that comes with the Anacron source distribution.
  23 */
  24 
  25 #ifndef _ANACRON_GLOBAL_H
  26 #define _ANACRON_GLOBAL_H
  27 
  28 /* Syslog facility and priorities messages will be logged to (see syslog(3)).
  29  * If you change these, please update the man page. */
  30 #define SYSLOG_FACILITY LOG_CRON
  31 #define EXPLAIN_LEVEL LOG_NOTICE  /* informational messages */
  32 #define COMPLAIN_LEVEL LOG_ERR    /* error messages */
  33 #define DEBUG_LEVEL LOG_DEBUG     /* only used when DEBUG is defined */
  34 
  35 /* Mail interface.  (All MTAs should supply this command) */
  36 #define SENDMAIL "/usr/sbin/sendmail"
  37 
  38 /* End of user-configurable section */
  39 
  40 
  41 #define FAILURE_EXIT 1
  42 #define MAX_MSG 150
  43 
  44 #include <signal.h>
  45 #include <time.h>
  46 #include "anacron-paths.h"
  47 #include "cronie_common.h"
  48 
  49 /* Some declarations */
  50 
  51 struct env_rec1 {
  52    char *assign;
  53 
  54    struct env_rec1 *next;
  55 };
  56 typedef struct env_rec1 env_rec;
  57 
  58 struct job_rec1 {
  59    int period;
  60    int named_period;
  61    int delay;
  62    char *ident;
  63    char *command;
  64    char *mailto;
  65 
  66    int tab_line;
  67    int arg_num;
  68    int timestamp_fd;
  69    int input_fd;
  70    int output_fd;
  71    off_t mail_header_size;
  72    pid_t job_pid;
  73    pid_t mailer_pid;
  74    int drop_job;
  75 
  76    struct job_rec1 *next;
  77    env_rec *prev_env_rec;
  78 };
  79 typedef struct job_rec1 job_rec;
  80 
  81 /* Global variables */
  82 
  83 extern pid_t primary_pid;
  84 extern char *program_name;
  85 extern char *anacrontab;
  86 extern char *spooldir;
  87 extern int old_umask;
  88 extern sigset_t old_sigmask;
  89 extern int serialize,force,update_only,now,no_daemon,quiet,testing_only;
  90 extern int day_now;
  91 extern int year,month,day_of_month;
  92 extern int in_background;
  93 
  94 extern job_rec *first_job_rec;
  95 extern env_rec *first_env_rec;
  96 
  97 extern char **job_args;
  98 extern int job_nargs;
  99 
 100 extern int njobs;
 101 extern job_rec **job_array;
 102 
 103 extern int running_jobs,running_mailers;
 104 
 105 extern int complaints;
 106 
 107 extern time_t start_sec;
 108 
 109 /* time ranges for START_HOURS_RANGE */
 110 extern int range_start;
 111 extern int range_stop;
 112 
 113 /* preferred hour for jobs */
 114 extern int preferred_hour;
 115 
 116 /* Function prototypes */
 117 
 118 /* main.c */
 119 int xopen(int fd, const char *file_name, int flags);
 120 void xclose(int fd);
 121 pid_t xfork(void);
 122 
 123 #ifdef __GNUC__
 124 #define PRINTF_FORMAT(n, m) \
 125    __attribute__ ((format (printf, n, m)))
 126 #else
 127 #define PRINTF_FORMAT(n, m)
 128 #endif
 129 
 130 /* log.c */
 131 void explain(const char *fmt, ...)PRINTF_FORMAT(1,2);
 132 void explain_e(const char *fmt, ...)PRINTF_FORMAT(1,2);
 133 void complain(const char *fmt, ...)PRINTF_FORMAT(1,2);
 134 void complain_e(const char *fmt, ...)PRINTF_FORMAT(1,2);
 135 void die(const char *fmt, ...)PRINTF_FORMAT(1,2) ATTRIBUTE_NORETURN;
 136 void die_e(const char *fmt, ...)PRINTF_FORMAT(1,2) ATTRIBUTE_NORETURN;
 137 void xdebug(const char *fmt, ...)PRINTF_FORMAT(1,2);
 138 void xdebug_e(const char *fmt, ...)PRINTF_FORMAT(1,2);
 139 void xcloselog(void);
 140 
 141 #ifdef DEBUG
 142 #define Debug(args) xdebug args
 143 #define Debug_e(args) xdebug_e args
 144 #else /* not DEBUG */
 145 #define Debug(args) (void)(0)
 146 #define Debug_e(args) (void)(0)
 147 #endif /* not DEBUG */
 148 
 149 /* readtab.c */
 150 void read_tab(int cwd);
 151 void arrange_jobs(void);
 152 
 153 /* lock.c */
 154 int consider_job(job_rec *jr);
 155 void unlock(job_rec *jr);
 156 void update_timestamp(job_rec *jr);
 157 void fake_job(job_rec *jr);
 158 
 159 /* runjob.c */
 160 void tend_children();
 161 void launch_job(job_rec *jr);
 162 
 163 #endif

/* [previous][next][first][last][top][bottom][index][help]  */