📄 hylafaxserver.h
字号:
/* $Id: HylaFAXServer.h,v 1.17 2006/06/12 18:28:54 aidan Exp $ *//* * Copyright (c) 1995-1996 Sam Leffler * Copyright (c) 1995-1996 Silicon Graphics, Inc. * HylaFAX is a trademark of Silicon Graphics * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */#ifndef _HylaFAXServer_#define _HylaFAXServer_#include "FaxConfig.h"#include "IOHandler.h"#include "Dictionary.h"#include "StrArray.h"#include "FaxRequest.h"#include "FaxRecvInfo.h"#include "manifest.h"#include "FileCache.h"#include "Trace.h"#include "Trigger.h"#include "SystemLog.h"#include "config.h"#ifdef HAVE_PAMextern "C" {#include <security/pam_appl.h>#include <grp.h>}#endif // HAVE_PAM#include <sys/types.h>#include <sys/socket.h>#include <dirent.h>#include <setjmp.h>#include <errno.h>/* * In-memory copy of a job description file. */struct Job : public FaxRequest { time_t lastmod; // last file modify time, for updates bool queued; // for SNPP Job(const fxStr& qf, int fd = -1); ~Job(); bool checkDocument(const char* pathname);};fxDECLARE_StrKeyDictionary(JobDict, Job*)/* * Received facsimile information. */struct RecvInfo : public FaxRecvInfo { bool beingReceived; // currently being received time_t recvTime; // time receive operation started RecvInfo(); RecvInfo(const char* qfile); ~RecvInfo();};fxDECLARE_StrKeyDictionary(RecvInfoDict, RecvInfo*)#ifdef T_USER#undef T_USER // XXX FreeBSD defines this#endif/* * Parser tokens; also used to identify protocol commands/operations. */enum Token { /* * Syntactic items. */ T_SP, T_CRLF, T_COMMA, T_STRING, T_NUMBER, T_NIL, T_LEXERR, /* * Commands. */ T_ABOR, T_ACCT, T_ADDMODEM, T_ADDUSER, T_ADMIN, T_ALLO, T_ANSWER, T_APPE, T_CHMOD, T_CHOWN, T_CONFIG, T_CWD, T_CDUP, T_DELE, T_DELUSER, T_DELMODEM, T_DISABLE, T_ENABLE, T_FILEFMT, T_FORM, T_HELP, T_IDLE, T_JDELE, T_JGDELE, T_JGINTR, T_JGKILL, T_JGNEW, T_JGPARM, T_JGREST, T_JGRP, T_JGSUB, T_JGSUSP, T_JGWAIT, T_JINTR, T_JKILL, T_JNEW, T_JOB, T_JOBFMT, T_JPARM, T_JREST, T_JSUB, T_JSUSP, T_JWAIT, T_LIST, T_MDTM, T_MODE, T_MODEMFMT, T_NLST, T_NOOP, T_PASS, T_PASV, T_PORT, T_PWD, T_QUIT, T_RCVFMT, T_REIN, T_REST, T_RETP, T_RETR, T_RNFR, T_RNTO, T_SHUT, T_SITE, T_SIZE, T_STAT, T_STOR, T_STOT, T_STOU, T_STRU, T_SYST, T_TRIGGER, T_TYPE, T_TZONE, T_USER, T_VRFY, /* * Job state parameters. */ T_ACCTINFO, T_BEGBR, T_BEGST, T_CHOPTHRESH, T_CLIENT, T_COMMENTS, T_COMMID, T_COVER, T_DATAFORMAT, T_DIALSTRING, T_DOCUMENT, T_DONEOP, T_EXTERNAL, T_FAXNUMBER, T_FROM_COMPANY, T_FROM_LOCATION, T_FROM_USER, T_FROM_VOICE, T_GROUPID, T_HRES, T_JOBID, T_JOBINFO, T_JOBTYPE, T_LASTTIME, T_MAXDIALS, T_MAXPAGES, T_MAXTRIES, T_MINBR, T_MODEM, T_NDIALS, T_NOTIFY, T_NOTIFYADDR,T_NPAGES, T_NTRIES, T_OWNER, T_PAGECHOP, T_PAGELENGTH,T_PAGEWIDTH, T_PASSWD, T_POLL, T_REGARDING, T_RETRYTIME, T_SCHEDPRI, T_SENDTIME, T_STATE, T_STATUS, T_SUBADDR, T_TAGLINE, T_TOTDIALS, T_TOTPAGES, T_TOTTRIES, T_TO_COMPANY,T_TO_LOCATION, T_TO_USER, T_TO_VOICE, T_TSI, T_USE_CONTCOVER, T_USE_ECM, T_USE_TAGLINE, T_USE_XVRES, T_USRKEY, T_VRES, /* * SNPP tokens. */ T_2WAY, T_ACKREAD, T_ALERT, T_CALLERID, T_COVERAGE, T_DATA, T_EXPTAG, T_HOLDUNTIL, T_JQUEUE, T_KTAG, T_LEVEL, T_LOGIN, T_MCRESPONSE, T_MESSAGE, T_MSTATUS, T_NOQUEUEING,T_PAGER, T_PING, T_RTYPE, T_SEND, T_SUBJECT};struct tab { // protocol command table entry const char* name; Token token; bool checklogin; // if true, must be logged in first bool implemented; // false if command is not implemented const char* help;};class SpoolDir;struct ParamProtection;struct stat;typedef struct tiff TIFF;class JobExt;class ModemExt;class ModemConfig;class IDCache;extern const char* fmtTime(time_t t);/* * An instance of a fax server process. */class HylaFAXServer : public SystemLog, public FaxConfig, public IOHandler {public: struct stringtag { const char* name; fxStr HylaFAXServer::* p; const char* def; // NULL is shorthand for "" }; struct numbertag { const char* name; u_int HylaFAXServer::*p; u_int def; };protected: u_int state;#define S_LOGGEDIN 0x0001 // client is logged in#define S_PRIVILEGED 0x0002 // client has administrative privileges#define S_LREPLIES 0x0004 // using continuation msgs in replies#define S_WAITFIFO 0x0008 // waiting on response to FIFO msg#define S_USEGMT 0x0010 // process times in GMT or local TZ#define S_WAITPASS 0x0020 // had user command, waiting for passwd#define S_TRANSFER 0x0040 // actively transferring data#define S_WAITDATA 0x0080 // scanner is waiting for data#define S_WAITTRIG 0x0100 // trigger is active#define S_LOGTRIG 0x0200 // write trigger events to data conn#define S_CHECKGID 0x0400 // check if file GID is set correctly#define S_SETGID 0x0800 // must explicitly force GID on files u_int tracingLevel; // server tracing control flags fxStr logFacility; // name of syslog facility for logging fxStr userAccessFile; // user access control file fxStr xferfaxLogFile; // log file for data transfers fxStr faxContact; // email account for inquiries fxStr systemType; // system ID string returned for SYST fxStr faxqFIFOName; // faxq FIFO name fxStr clientFIFOName; // client FIFO name int faxqFd; // faxq FIFO open descriptor int clientFd; // client FIFO open descriptor fxStr fifoResponse; // response received to FIFO msg u_int idleTimeout; // client inactivity timeout u_int maxIdleTimeout; // upper bound on idle timeout int data; // current data connection (socket) int pdata; // passive mode data connect (socket) fxStr hostname; // name of machine server is running on fxStr hostaddr; // primary address for hostname fxStr remotehost; // name of peer's machine fxStr remoteaddr; // address of peer's machine fxStr autospout; // text to send with next reply fxStr shutdownFile; // file with shutdown information fxStr shutdownMsg; // text of shutdown message time_t lastModTime; // last mod. time of shutdown file time_t lastTime; // time of last shutdown notification time_t discTime; // time to disconnect service time_t denyTime; // time to deny service u_int jobProtection; // Protection to use on Jobs /* * User authentication and login-related state. */#ifdef HAVE_PAM pam_handle_t *pamh; // handle to current pam session bool pam_chrooted; // if already chrooted, PAM gets disabled#endif fxStr passwd; // encrypted user password fxStr adminwd; // encrypted passwd for admin privileges u_int uid; // client's ID u_int loginAttempts; // number of failed login attempts u_int maxLoginAttempts; // login failures before server exits u_int adminAttempts; // number of failed admin attempts u_int maxAdminAttempts; // admin failures before server exits fxStr the_user; // name of user fxStr admingroup; // name of local user group that is allowed // to administer the fax server IDCache* idcache; // fax UID -> name mapping table /* * File and file-transfer related state. */ off_t restart_point; // file offset for restarting transfers jmp_buf urgcatch; // throw location for transfer interrupt off_t file_size; // size of file being transferred off_t byte_count; // amount of data currently sent int xferfaxlog; // open transfer log file int mode; // data transfer mode int form; // data transfer format int type; // data transfer type int stru; // file structure SpoolDir* cwd; // current working directory fxStrArray tempFiles; // files created with STOT fxStr fileFormat; // format string for directory listings TIFF* cachedTIFF; // cached open TIFF file /* * Parser-related state. */ Token pushedToken; // lexical token push back fxStr tokenBody; // string body of current lexical token char cbuf[512]; // current input line int cpos; // position in cbuf int ctrlFlags; // file descriptor flags for control int recvCC; // amount of data remaining in recvBuf int recvNext; // next byte for scanner char recvBuf[1024]; // input data buffer u_int consecutiveBadCmds; // # consecutive invalid control cmds u_int maxConsecutiveBadCmds; // max # before forced disconnect /* * Job-related state. */ Job defJob; // default job state information JobDict jobs; // non-default jobs Job* curJob; // current job fxStr jobFormat; // job status format string JobDict blankJobs; // jobs created during this session but not submitted /* * Receive queue-related state. */ RecvInfoDict recvq; // cache of info about received fax fxStr recvFormat; // received fax status format string /* * Trigger-related state. */ fxStr trigSpec; // specification for active trigger u_int tid; // current active trigger ID /* * Modem-related state. */ fxStr modemFormat; // modem status format string static gid_t faxuid; // system gid of fax user = our uid#if HAS_TM_ZONE const char* tzname[2]; // local timezone name#endif time_t gmtoff; // time_t offset btwn GMT and local time void userCmd(const char* name); // USER void adminCmd(const char* name); // ADMIN void passCmd(const char* passwd); // PASS void statusCmd(void); // STAT void formCmd(const char* name); // FORM void formHelpCmd(void); // FORM void typeCmd(const char* name); // TYPE void modeCmd(const char* name); // MODE void struCmd(const char* name); // STRU void deleCmd(const char* name); // DELE void mdtmCmd(const char* name); // MDTM void cwdCmd(const char *path); // CWD void pwdCmd(void); // PWD void retrieveCmd(const char* name); // RETR void retrievePageCmd(const char* name);// RETP void listCmd(const char* name); // LIST void nlstCmd(const char* name); // NLST void storeCmd(const char*, const char*);// STOR+APPE void storeUniqueCmd(bool isTemp); // STOU+STOT
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -