This is zend.h in view mode; [Download] [Up]
/* $Id: zend.h,v 1.12 1993/02/21 13:06:13 gerben Exp $ */
/*
Zend --- a mail transport program for large files and directories
Copyright (C) 1992 Gerben C. Th. Wierda
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
Gerben Wierda
Goudriaanstraat 1
1222 SG Hilversum
The Netherlands
gerben@rna.indiv.nluug.nl
*/
/*
*
* zend.h -- data structures for zend.c and zendutil.c
*
* All variables are kept as strings. They are identified with a "prompt" and a
* "type".
*
*/
#define _POSIX2_SOURCE /* order draft Posix.2 functions. */
#include "p-stdio.h"
#include "p-stat.h"
#include "p-fcntl.h"
#include "p-stdarg.h"
#include "p-time.h"
#include "p-unistd.h"
#include "p-wait.h"
#include "p-stdlib.h"
#include "p-string.h"
#include "p-errno.h"
#include "p-pwd.h"
#include <assert.h>
/* The following are traditional UNIX functions. */
extern char * mktemp __(( char *_(template) ));
#ifdef HAVE_RANDOM /* Better random generator. */
extern int srandom __(( int _(seed) ));
extern long random __(( void ));
#else
extern void srand __(( unsigned int _(seed) ));
extern int rand __(( void ));
# define srandom(s) srand(s)
# define random() ((long) rand())
#endif
/* This should be defined in <string.h> */
#ifndef HAVE_STRERROR /* ...so roll our own. */
# if _ANSI_LIBRARY_
# define HAVE_STRERROR 1
# endif
#endif
#if !HAVE_STRERROR
# define strerror Zstrerror
#endif
extern char * strerror __(( int _(errnum) ));
/* further assumptions: dup2(), rename(), v[fs]printf() are available. */
#include "policy.h"
#if BINMAIL && USRUCBMAIL
You are out of luck.
#endif
#if !BINMAIL && !USRUCBMAIL
You are out of luck.
#endif
#if BINMAIL
# define MAILPROG "/bin/mail"
#else
# define MAILPROG "/usr/ucb/mail"
#endif
#ifdef FALSE
# undef FALSE
#endif
#ifdef TRUE
# undef TRUE
#endif
#ifdef NIL
# undef NIL
#endif
#ifdef NUL
# undef NUL
#endif
#define NUL '\000'
#if __STDC__
# define NIL (void *)0
#else
# define NIL NULL
#endif
#if __STDC__
typedef enum { FALSE=0, TRUE} Boolean;
#else
typedef int Boolean;
# define FALSE 0
# define TRUE 1
#endif
#define ROOT 0 /* root uid. */
/*
* Parsing a stream will give either a varno or a status < 0:
*/
#define PARSEEOF -1
#define PARSEUNKNOWN -2
#define PARSEDELIMITER -3
#define BOOLFALSESTRING "FALSE"
#define BOOLTRUESTRING "TRUE"
typedef unsigned long Ulong;
typedef unsigned short Ushort;
typedef char *StringPointer;
typedef enum { NONE=0, STRING, ULONG, USHORT, BOOLEAN } ValueType;
typedef struct {
ValueType type;
StringPointer prompt;
#if _ANSI_UNION_ /* ANSI C allows static initialisation of unions. */
union
#else /* ...but traditional C doesn't. */
struct
#endif
{
Ulong ulong;
Ushort ushort;
Boolean bool;
StringPointer string;
} value;
} Variable;
/*
* Logicals for the global variable prompts, that are used in read/write
* operations and logicals for their possible (default) values:
*/
#define ZENDDELIMITER "Z-ZEND-DELIMITER"
#define ZENDIDPROMPT "Z-ZendId:"
#define UUCPMODEPROMPT "Z-UUCPMode:"
#define SYSTEMNAMEPROMPT "Z-SystemName:"
#define SENDINGUSERPROMPT "Z-Sender:"
#define RECEIVINGUSERPROMPT "Z-Receiver:"
#define LINESPROMPT "Z-Lines:"
#define ZENDSIZEPROMPT "Z-ZendSize:"
#define ZENDTRUESIZEPROMPT "Z-ZendTrueSize:"
#define RECEIVESIZEPROMPT "Z-ReceiveSize:"
#define RECEIVETRUESIZEPROMPT "Z-ReceiveTrueSize:"
#define ACTIONPROMPT "Z-Action:"
#define SENDINGJOBIDPROMPT "Z-SenderJobId:"
#define RECEIVINGJOBIDPROMPT "Z-ReceiverJobId:"
#define FILEPROMPT "Z-File:"
#define DIRPROMPT "Z-Directory:"
#define COMPRESSEDPROMPT "Z-Compressed:"
#define TYPEPROMPT "Z-Type:"
#define CHUNKNRPROMPT "Z-ChunkNr:"
#define NROFCHUNKSPROMPT "Z-NrOfChunks:"
#define REASONPROMPT "Z-Reason:"
#define ROLEPROMPT "Z-Role:"
#define DUMMYULONGPROMPT "Z-Dummy:"
#define SPOOLDIRPROMPT "Z-SpoolDir:"
#define PACKETTIMEOUTPROMPT "Z-PacketTimeout:" /* in days. */
#define JOBTIMEOUTPROMPT "Z-JobTimeout:" /* ,, */
#define TIMESTAMPPROMPT "Z-TimeStamp:"
#define SENDINGSYSTEMPROMPT "Z-SendingSystem:"
#define ALLOWUSERSPROMPT "Z-AllowUsers:"
#define EXCLUDEUSERSPROMPT "Z-ExcludeUsers:"
#define ALLOWSYSTEMSPROMPT "Z-AllowSystems:"
#define EXCLUDESYSTEMSPROMPT "Z-ExcludeSystems:"
/*
* Standard mail headers:
*/
#define MAILFROMPROMPT "From:"
#define MAILTOPROMPT "To:"
#define MAILSUBJECTPROMPT "Subject:"
#define MAILDATEPROMPT "Date:"
#define MAILREPLYTOPROMPT "Reply-To:"
#ifdef ACTIONPROMPT
# define ACTION_AYT "Are You There?"
# define ACTION_UAR "I Am Up And Running!"
# define ACTION_CNK "Chunk"
# define ACTION_ACK "Acknowledge"
# define ACTION_RSN "Resend"
# define ACTION_ERR "ERROR"
#endif
#ifdef ROLEPROMPT
# define ROLE_SENDER "Sender"
# define ROLE_RECEIVER "Receiver"
#endif
#ifdef TYPEPROMPT
# define TYPE_FILE "File"
# define TYPE_DIR "Directory"
#endif
#define RESERVEDID 0L
/*
* one at a time types. these are used to prevent read-write overlaps and
* having only one chunk delivering.
*/
#define FILE_DELIVER 'A'
#define RDWR_JOBFILE 'B'
/*
* Some more-or-less arbitrary limits.
*/
#define RETRY_LIMIT 100 /* max. nr. of retries in creating job dir. */
#define JOB_TIMEOUT 14 /* default Job timeout in number of days */
/*
* The variable and function declarations:
*/
extern Variable global[], remoteglobal[];
extern int nrOfGlobalVariables;
extern StringPointer mailUser;
extern Boolean verboseMode;
extern uid_t sendinguser_uid;
extern unsigned int process_id;
extern time_t timestamp;
extern Boolean logErrors;
#if DEBUG
extern Boolean dump;
# define DUMP dump = TRUE
# define NODUMP dump = FALSE
#else
# define DUMP
# define NODUMP
#endif
/* Function prototypes. */
extern void init __(( void ));
extern int read_config __(( void ));
extern int parsebuftoglob __(( Variable *_(globs), const char *_(buf) ));
extern int writeglobtobuf __(( Variable *_(globs), const char *_(prompt), char *_(buf) ));
extern int parsestreamtoglob __(( Variable *_(globs), FILE *_(stream) ));
extern int writeglobtostream __(( Variable *_(globs), const char *_(prompt), FILE *_(stream) ));
extern Boolean starttransfer __(( const char *_(remoteUser), const char *_(localFile) ));
extern void receive __(( void ));
extern int set_global __(( Variable *_(globs), const char *_(prompt), ... ));
extern StringPointer get_global_string __(( Variable *_(globs), const char *_(prompt) ));
extern Ulong get_global_ulong __(( Variable *_(globs), const char *_(prompt) ));
extern Ushort get_global_ushort __(( Variable *_(globs), const char *_(prompt) ));
extern Boolean get_global_boolean __(( Variable *_(globs), const char *_(prompt) ));
extern void handle_ayt __(( void ));
extern void handle_uar __(( void ));
extern void handle_cnk __(( void ));
extern void handle_ack __(( void ));
extern void handle_rsn __(( void ));
extern void handle_err __(( void ));
extern void mail_message __(( void ));
extern void mail_chunk __(( void ));
extern void mail_resend __(( void ));
extern Boolean write_globs_to_jobfile __(( Variable *_(globs), Ulong _(jobId) ));
extern int read_jobfile_to_globs __(( Variable *_(globs), Ulong _(jobId) ));
extern int one_at_a_time __(( Ulong _(jobId), char _(type) ));
extern int end_one_at_a_time __(( Ulong _(jobId), char _(type) ));
extern void zlog __(( const char *_(format), ... ));
extern void zerr __(( const char *_(s), ... ));
extern void mail_err __(( const char *_(format), ... ));
extern void check_timeout __(( void ));
extern Ulong new_job __(( void ));
extern void kill_job __(( Ulong _(jobId) ));
extern Boolean str_listed __(( const char *_(str), const char *_(list) ));
extern void cleanup_stale_locks __(( void ));
extern void add_file_to_cleanup __(( const char *_(name), Boolean _(isDirectory) ));
extern void remove_file_to_cleanup __(( const char *_(name) ));
extern void file_cleanup __(( void ));
extern int system_as __(( const char *_(command), uid_t _(uid), gid_t _(gid) ));
extern FILE * popen_as __(( const char *_(command), const char *_(mode), uid_t _(uid), gid_t _(gid) ));
extern int pclose_as __(( FILE *_(stream) ));
extern char * basename __(( const char *_(filename) ));
extern char * quote_for_sh __(( const char *_(str) ));
extern void_* safecalloc __(( size_t _(n), size_t _(size) ));
/* some macros to make ownership of subprocesses explicit. */
#define system_as_user(cmd) system_as((cmd), getuid(), getgid())
#define system_as_zend(cmd) system_as((cmd), geteuid(), getegid())
#define system system_as_zend /* use our own. */
#define popen_as_user(cmd,mode) popen_as((cmd), (mode), getuid(), getgid())
#define popen_as_zend(cmd,mode) popen_as((cmd), (mode), geteuid(), getegid())
#define popen popen_as_zend /* use our own. */
#define pclose pclose_as /* use our own. */
/*======================================================================
* $Log: zend.h,v $
* Revision 1.12 1993/02/21 13:06:13 gerben
* mail_err() is global function since we mail an error if the job timout is there.
*
* Revision 1.11 1993/02/02 21:00:00 gerben
* *** empty log message ***
*
* Revision 1.10 1993/01/28 15:57:53 tom
* allow zend to be installed setuid non-root. Plug some more security holes
* (environment; umask; subprogram execution as real user; be more careful with
* file access modes; create spoolfile through a pipe so user process does not
* have to access the spool directory.)
*
* Revision 1.9 1993/01/10 19:44:18 tom
* shell-quote user-supplied names; Posixate access modes.
*
* Revision 1.8 1992/12/22 15:11:58 tom
* revision of HAVE_STRERROR.
*
* Revision 1.7 1992/12/10 05:27:34 tom
* adapt function prototypes.
*
*======================================================================*/
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.