1 /* $Id$ */ 2 /* 3 * Copyright (c) 1990-1996 Sam Leffler 4 * Copyright (c) 1991-1996 Silicon Graphics, Inc. 5 * HylaFAX is a trademark of Silicon Graphics 6 * 7 * Permission to use, copy, modify, distribute, and sell this software and 8 * its documentation for any purpose is hereby granted without fee, provided 9 * that (i) the above copyright notices and this permission notice appear in 10 * all copies of the software and related documentation, and (ii) the names of 11 * Sam Leffler and Silicon Graphics may not be used in any advertising or 12 * publicity relating to the software without the specific, prior written 13 * permission of Sam Leffler and Silicon Graphics. 14 * 15 * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, 16 * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY 17 * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. 18 * 19 * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR 20 * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, 21 * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, 22 * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF 23 * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE 24 * OF THIS SOFTWARE. 25 */ 26 #ifndef _ServerConfig_ 27 #define _ServerConfig_ 28 /* 29 * Fax Modem and Protocol Server Configuration. 30 */ 31 #include "ModemConfig.h" 32 33 class DialStringRules; 34 class UUCPLock; 35 class REArray; 36 class fxBoolArray; 37 38 class ServerConfig : public ModemConfig { 39 public: 40 // NB: the S_ prefixes workaround a bug in the AIX xlC compiler 41 struct S_stringtag { 42 const char* name; 43 fxStr ServerConfig::* p; 44 const char* def; // NULL is shorthand for "" 45 }; 46 struct S_booltag { 47 const char* name; 48 bool ServerConfig::* p; 49 bool def; // NULL is shorthand for "" 50 }; 51 struct S_numbertag { 52 const char* name; 53 u_int ServerConfig::*p; 54 u_int def; 55 }; 56 struct S_filemodetag { 57 const char* name; 58 mode_t ServerConfig::*p; 59 // NB: this should be mode_t but causes alignment problems 60 // on systems where it's 16-bits (e.g. m68k-hp-hpux9). 61 u_int def; 62 }; 63 private: 64 fxStr longDistancePrefix; // prefix str for long distance dialing 65 fxStr internationalPrefix; // prefix str for international dialing 66 fxStr areaCode; // local area code 67 fxStr countryCode; // local country code 68 DialStringRules* dialRules; // dial string rules 69 fxStr uucpLockType; // UUCP lock file type 70 fxStr uucpLockDir; // UUCP lock file directory 71 mode_t uucpLockMode; // UUCP lock file creation mode 72 u_int uucpLockTimeout; // UUCP stale lock file timeout 73 time_t lastTSIModTime; // last mod time of TSI patterns file 74 time_t lastPWDModTime; // last mod time of PWD patterns file 75 REArray* tsiPats; // recv tsi patterns 76 REArray* pwdPats; // recv PWD patterns 77 fxBoolArray* acceptTSI; // accept/reject matched tsi 78 fxBoolArray* acceptPWD; // accept/reject matched PWD 79 fxStr logFacility; // syslog facility to direct trace msgs 80 81 static S_booltag bools[]; 82 static S_stringtag strings[]; 83 static S_numbertag numbers[]; 84 static S_filemodetag filemodes[]; 85 86 SpeakerVolume getVolume(const char* cp); 87 protected: 88 ServerConfig(); 89 90 void setupConfig(); 91 virtual bool setConfigItem(const char* tag, const char* value); 92 93 // pattern access control list support 94 void updatePatterns(const fxStr& file, 95 REArray*& pats, fxBoolArray*& accept, 96 time_t& lastModTime); 97 void readPatterns(FILE*, REArray*&, fxBoolArray*&); 98 bool checkACL(const fxStr& id, REArray*, fxBoolArray&); 99 // methods for parameters whose assignment may have side effects 100 virtual void setDialRules(const char* name); 101 virtual void setLocalIdentifier(const fxStr& lid); 102 virtual void setModemSpeakerVolume(SpeakerVolume level); 103 public: 104 SpeakerVolume speakerVolume; // volume control 105 fxStr qualifyTSI; // if set, no recv w/o acceptable tsi 106 fxStr qualifyPWD; // if set, no recv w/o acceptable PWD 107 mode_t recvFileMode; // protection mode for received files 108 mode_t deviceMode; // protection mode for modem device 109 mode_t logMode; // protection mode for log files 110 u_int tracingLevel; // tracing level w/o session 111 u_int logTracingLevel; // tracing level during session 112 u_int tracingMask; // tracing level control mask 113 bool clocalAsRoot; // set CLOCAL as root 114 bool priorityScheduling; // change process priority 115 u_int requeueTTS[9]; // requeue intervals[CallStatus code] 116 u_int requeueProto; // requeue interval after protocol error 117 u_int requeueOther; // requeue interval after other problem 118 u_int retryMAX[9]; // number of retries[CallStatus code] 119 u_int retryOther; // number of retries after other problem 120 u_int pollModemWait; // polling interval in modem wait state 121 u_int pollLockWait; // polling interval in lock wait state 122 bool pollLockPokeModem; // poke modem after polling lock 123 u_int maxRecvPages; // max pages to accept on receive 124 u_int maxConsecutiveBadCalls; // max consecutive bad phone calls 125 fxStr localIdentifier; // to use in place of FAXNumber 126 fxStr FAXNumber; // phone number 127 u_int maxSetupAttempts; // # times to try initializing modem 128 bool batchLogs; // Batch session logs togther or not 129 130 virtual ~ServerConfig(); 131 132 virtual void resetConfig(); 133 134 fxStr canonicalizePhoneNumber(const fxStr& ds); 135 fxStr prepareDialString(const fxStr& ds); 136 137 UUCPLock* getUUCPLock(const fxStr& deviceName); 138 139 bool isTSIOk(const fxStr& tsi); 140 bool isPWDOk(const fxStr& pwd); 141 142 virtual void vconfigError(const char* fmt, va_list ap) = 0; 143 virtual void vconfigTrace(const char* fmt, va_list ap) = 0; 144 virtual void vdialrulesTrace(const char* fmt, va_list ap) = 0; 145 void configError(const char* fmt, ...); 146 void configTrace(const char* fmt, ...); 147 }; 148 #endif /* _ServerConfig_ */ 149