/* cron.h */

#ifndef	_CRON_H
#define	_CRON_H

#ifndef __MINT__
#define __MINT__
#endif

#include <stdio.h>
#include <time.h>

/*
#define DEBUG
*/
#ifndef PROGNAME		/* should be in project- or makefile */ 
#	define PROGNAME	"unknown"
#endif

#define SPOOLDIR	"u:/usr/spool/cron"
#define CRONDIR		SPOOLDIR "/crontabs" 
#define ATDIR		SPOOLDIR "/atjobs" 
#define LOGFILE		"u:/etc/syslog"
#define PIDFILE		"u:/etc/crond.pid"

#define CRONPIPE	"u:/pipe/crond"
#define EXTERNBUILD	50
#define INTERNBUILD	51

#define USERENV		"LOGNAME"	/* "USER" for BSD */

#define SHELLCMD	"u:/bin/mintshel.ttp"
#define DEFPATH		"setenv PATH u:\\bin,u:\\usr\\bin"	/* mintshel */
/*
#define SHELLCMD	"u:/usr/bin/tcsh.ttp"
#define DEFPATH		"setenv PATH u:/bin;u:/usr/bin"		/ * tcsh * /
*/

#define MAILCMD		"u:/bin/cat"
#define MAILARG		"%s >>u:/usr/mail/%s"

#define NICELEVEL	5
#define SLEEPTIME	5	/* seconds */

#define MAX_JOBS	 25	/* max. number of cronjobs in tables */
#define MAX_SIMJOBS	  5	/* max. number of simultaneous running jobs */
#define	MAX_COMMAND	 90	/* max. length of job command (simple shells max. 127) */
#define	MAX_FNAME	100	/* max. length for generated filename */
#define	MAX_UNAME	 15	/* max. length of username */
#define	MAX_TEMPSTR	250	/* max. length for temp. string */

#define MAX_MIN		59
#define MAX_HOUR	23
#define MAX_DAYOFM	31
#define MAX_MONTH	12
#define MAX_DAYOFW	 6

#define ULONG unsigned long
#define UINT  unsigned int
#define UCHAR unsigned char

typedef	struct	_entry
{	ULONG	MinH,MinL;
	ULONG	Hour;
	ULONG	DayOfM;
	UINT	Month;
	UCHAR	DayOfW;
	char	Command[MAX_COMMAND];
	char	User[MAX_UNAME];
	char 	Status;
	char 	Type;
	int		AtId;
}	entry;

typedef struct _active
{	int Pid;
	char Output[MAX_FNAME];
	char User[MAX_UNAME];
	char Status;
}	active;

/* values for Status and Type fields : */

#define CRON	0
#define AT		1

#define SLEEP	0
#define START	1	

#define FREE	 0
#define FINISHED 2
#define BUSY	 4

/* Job error status */
 
#define ERJOB	-1
#define EROUTP	-2
#define EROVFL	-3

#ifdef __MINT__
#	include <mintbind.h>

	struct dirent { long d_ino; char d_name[MAX_FNAME]; } ;

	/* Dreaddir non-standard so not defined */

#	define opendir(a)	Dopendir(a,0)
#	define closedir(a)	Dclosedir(a)
#	define getpid()		Pgetpid()
#	define getppid()	Pgetppid()
#	define fork()		Pfork()
#	define alarm(s)		Talarm(s)		
#	define pause()		Pause()
#	define setpgrp(a,b)	Psetpgrp(a,b)
#	define getpgrp()	Pgetpgrp()
#	define nice(a)		Pnice(a)
#	define setuid(a)	Psetuid(a)
#	define getuid()		Pgetuid()
#	define setgid(a)	Psetgid(a)

#endif	/* __MINT__ */

#define TRUE		1
#define FALSE		0

/* debugging functions */

extern void Debug(char *str, ...);
extern void PrintBin(int nrbits, long value);
extern void DebugPrintTimes(entry *line);

#endif