12,000 line patch removes the fxBool class from the source tree.
Replaces with the C++ standard type 'bool'. Also replaced the 'TRUE' &
'FALSE' defines with C++ standard true & false.
#define SNPP_DEFPORT 444 /* port to use if service is unknown */
#define SNPP_DEFHOST "localhost" /* default host for SNPP service */
/* default values for SNPP job scheduling and handling */
-#define SNPP_DEFQUEUE FALSE /* default is synchronous delivery */
+#define SNPP_DEFQUEUE false /* default is synchronous delivery */
#define SNPP_DEFLEVEL 1 /* default service level */
#define SNPP_DEFRETRIES 3 /* number times to retry send */
#define SNPP_DEFREDIALS 12 /* number times to dial phone */
class faxAlterApp : public FaxClient {
private:
- fxBool groups; // group or job id's
+ bool groups; // group or job id's
fxStr script; // commands to send for each job
void addToScript(const char* fmt ...);
void run(int argc, char** argv);
};
-faxAlterApp::faxAlterApp() { groups = FALSE; }
+faxAlterApp::faxAlterApp() { groups = false; }
faxAlterApp::~faxAlterApp() {}
void
addToScript("SENDTIME NOW");
break;
case 'g': // apply to groups, not jobs
- groups = TRUE;
+ groups = true;
break;
case 'h': // server's host
setHost(optarg);
addToScript("MAXDIALS %s", optarg);
break;
case 'v': // trace protocol
- setVerbose(TRUE);
+ setVerbose(true);
break;
case '?':
usage();
{
}
-fxBool
+bool
Class0Modem::setupModem()
{
if (!selectBaudRate(conf.maxRate, conf.flowControl, conf.flowControl))
- return (FALSE);
+ return (false);
// Query service support information
fxStr s;
if (doQuery(conf.classQueryCmd, s, 500) && parseRange(s, modemServices))
traceBits(modemServices & SERVICE_ALL, serviceNames);
if ((modemServices & SERVICE_DATA) == 0)
- return (FALSE);
+ return (false);
atCmd(conf.class0Cmd);
setupFlowControl(flowControl);
if (modemRevision != "")
modemCapability("Revision " | modemRevision);
- return (TRUE);
+ return (true);
}
/*
* Send the modem any commands needed to force use of
* the specified flow control scheme.
*/
-fxBool
+bool
Class0Modem::setupFlowControl(FlowControl fc)
{
switch (fc) {
case FLOW_XONXOFF: return atCmd(conf.softFlowCmd);
case FLOW_RTSCTS: return atCmd(conf.hardFlowCmd);
}
- return (TRUE);
+ return (true);
}
CallStatus
return (FAILURE);
}
-fxBool Class0Modem::isFaxModem() const { return FALSE; }
+bool Class0Modem::isFaxModem() const { return false; }
Class0Modem(ModemServer&, const ModemConfig&);
~Class0Modem();
- fxBool setupModem();
- virtual fxBool setupFlowControl(FlowControl fc);
+ bool setupModem();
+ virtual bool setupFlowControl(FlowControl fc);
CallStatus dial(const char* number, fxStr& emsg);
CallStatus dialResponse(fxStr& emsg);
- fxBool isFaxModem() const; // XXX safe to cast
+ bool isFaxModem() const; // XXX safe to cast
};
#endif /* _Class0Modem_ */
* least at 12000 and 14400.
*/
const Class1Cap Class1Modem::basicCaps[15] = {
- { 3, 0, 0, V21, FALSE }, // v.21
- { 24, BR_2400, DCSSIGRATE_2400V27, V27FB, FALSE }, // v.27 ter
- { 48, BR_4800, DCSSIGRATE_4800V27, V27, FALSE }, // v.27 ter
- { 72, BR_7200, DCSSIGRATE_7200V29, V29, FALSE }, // v.29
- { 73, BR_7200, DCSSIGRATE_7200V17, V17, FALSE }, // v.17
- { 74, BR_7200, DCSSIGRATE_7200V17, V17, FALSE }, // v.17 w/st
- { 96, BR_9600, DCSSIGRATE_9600V29, V29, FALSE }, // v.29
- { 97, BR_9600, DCSSIGRATE_9600V17, V17, FALSE }, // v.17
- { 98, BR_9600, DCSSIGRATE_9600V17, V17, FALSE }, // v.17 w/st
- { 121, BR_12000, DCSSIGRATE_12000V33, V33, FALSE }, // v.33
- { 121, BR_12000, DCSSIGRATE_12000V17, V17, FALSE }, // v.17
- { 122, BR_12000, DCSSIGRATE_12000V17, V17, FALSE }, // v.17 w/st
- { 145, BR_14400, DCSSIGRATE_14400V33, V33, FALSE }, // v.33
- { 145, BR_14400, DCSSIGRATE_14400V17, V17, FALSE }, // v.17
- { 146, BR_14400, DCSSIGRATE_14400V17, V17, FALSE }, // v.17 w/st
+ { 3, 0, 0, V21, false }, // v.21
+ { 24, BR_2400, DCSSIGRATE_2400V27, V27FB, false }, // v.27 ter
+ { 48, BR_4800, DCSSIGRATE_4800V27, V27, false }, // v.27 ter
+ { 72, BR_7200, DCSSIGRATE_7200V29, V29, false }, // v.29
+ { 73, BR_7200, DCSSIGRATE_7200V17, V17, false }, // v.17
+ { 74, BR_7200, DCSSIGRATE_7200V17, V17, false }, // v.17 w/st
+ { 96, BR_9600, DCSSIGRATE_9600V29, V29, false }, // v.29
+ { 97, BR_9600, DCSSIGRATE_9600V17, V17, false }, // v.17
+ { 98, BR_9600, DCSSIGRATE_9600V17, V17, false }, // v.17 w/st
+ { 121, BR_12000, DCSSIGRATE_12000V33, V33, false }, // v.33
+ { 121, BR_12000, DCSSIGRATE_12000V17, V17, false }, // v.17
+ { 122, BR_12000, DCSSIGRATE_12000V17, V17, false }, // v.17 w/st
+ { 145, BR_14400, DCSSIGRATE_14400V33, V33, false }, // v.33
+ { 145, BR_14400, DCSSIGRATE_14400V17, V17, false }, // v.17
+ { 146, BR_14400, DCSSIGRATE_14400V17, V17, false }, // v.17 w/st
};
#define NCAPS (sizeof (basicCaps) / sizeof (basicCaps[0]))
* Check if the modem is a Class 1 modem and,
* if so, configure it for use.
*/
-fxBool
+bool
Class1Modem::setupModem()
{
if (!selectBaudRate(conf.maxRate, conf.flowControl, conf.flowControl))
- return (FALSE);
+ return (false);
// Query service support information
fxStr s;
if (doQuery(conf.classQueryCmd, s, 500) && FaxModem::parseRange(s, modemServices))
traceBits(modemServices & SERVICE_ALL, serviceNames);
if ((modemServices & SERVICE_CLASS1) == 0)
- return (FALSE);
+ return (false);
atCmd(conf.class1Cmd);
/*
*/
if (!class1Query("AT+FTM=?", xmitCaps)) {
serverTrace("Error parsing \"+FTM\" query response: \"%s\"", rbuf);
- return (FALSE);
+ return (false);
}
modemParams.br = 0;
u_int i;
*/
if (!class1Query("AT+FRM=?", recvCaps)) {
serverTrace("Error parsing \"+FRM\" query response: \"%s\"", rbuf);
- return (FALSE);
+ return (false);
}
u_int mods = 0;
for (i = 1; i < NCAPS; i++)
frameRev = TIFFGetBitRevTable(conf.frameFillOrder == FILLORDER_LSB2MSB);
setupClass1Parameters();
- return (TRUE);
+ return (true);
}
/*
* Send the modem the Class 1 configuration commands.
*/
-fxBool
+bool
Class1Modem::setupClass1Parameters()
{
if (modemServices & SERVICE_CLASS1) {
setupFlowControl(flowControl);
atCmd(conf.setupAACmd);
}
- return (TRUE);
+ return (true);
}
/*
* Setup receive-specific parameters.
*/
-fxBool
+bool
Class1Modem::setupReceive()
{
- return (TRUE); // nothing to do
+ return (true); // nothing to do
}
/*
* Send the modem any commands needed to force use of
* the specified flow control scheme.
*/
-fxBool
+bool
Class1Modem::setupFlowControl(FlowControl fc)
{
switch (fc) {
case FLOW_XONXOFF: return atCmd(conf.class1SFLOCmd);
case FLOW_RTSCTS: return atCmd(conf.class1HFLOCmd);
}
- return (TRUE);
+ return (true);
}
/*
* Place the modem into the appropriate state
* for sending/received facsimile.
*/
-fxBool
+bool
Class1Modem::faxService()
{
return (atCmd(conf.class1Cmd) && setupFlowControl(flowControl));
encodeTSI(lid, number);
}
-fxBool
+bool
Class1Modem::supportsPolling() const
{
- return (TRUE);
+ return (true);
}
/*
n = 20;
ascii.resize(n);
u_int d = 0;
- fxBool seenDigit = FALSE;
+ bool seenDigit = false;
for (const u_char* cp = binary.getFrameData() + n-1; n > 0; cp--, n--) {
/*
* Accept any printable ascii.
u_char c = frameRev[*cp];
if (isprint(c) || c == ' ') {
if (c != ' ')
- seenDigit = TRUE;
+ seenDigit = true;
if (seenDigit)
ascii[d++] = c;
}
* optionally including the end-of-data
* marker <DLE><ETX>.
*/
-fxBool
+bool
Class1Modem::sendClass1Data(const u_char* data, u_int cc,
- const u_char* bitrev, fxBool eod)
+ const u_char* bitrev, bool eod)
{
if (!putModemDLEData(data, cc, bitrev, getDataTimeout()))
- return (FALSE);
+ return (false);
if (eod) {
u_char buf[2];
buf[0] = DLE;
buf[1] = ETX;
return (putModemData(buf, 2));
} else
- return (TRUE);
+ return (true);
}
/*
void
Class1Modem::abortReceive()
{
- fxBool b = wasTimeout();
+ bool b = wasTimeout();
char c = CAN; // anything other than DC1/DC3
putModem(&c, 1, 1);
/*
* is not received before the timeout, the receive
* is aborted.
*/
-fxBool
+bool
Class1Modem::recvRawFrame(HDLCFrame& frame)
{
int c;
}
if (wasTimeout()) {
abortReceive();
- return (FALSE);
+ return (false);
}
traceHDLCFrame("-->", frame);
/*
if (!waitFor(AT_OK)) {
if (lastResponse == AT_ERROR)
protoTrace("FCS error");
- return (FALSE);
+ return (false);
}
if (frame.getFrameDataLength() < 1) {
protoTrace("HDLC frame too short (%u bytes)", frame.getLength());
- return (FALSE);
+ return (false);
}
if ((frame[1]&0xf7) != 0xc0) {
protoTrace("HDLC frame with bad control field %#x", frame[1]);
- return (FALSE);
+ return (false);
}
- frame.setOK(TRUE);
- return (TRUE);
+ frame.setOK(true);
+ return (true);
}
#include "StackBuffer.h"
* The T.30 max frame length is enforced with a 3 second
* timeout on the send.
*/
-fxBool
+bool
Class1Modem::sendRawFrame(HDLCFrame& frame)
{
traceHDLCFrame("<--", frame);
if (frame.getLength() < 3) {
protoTrace("HDLC frame too short (%u bytes)", frame.getLength());
- return (FALSE);
+ return (false);
}
if (frame[0] != 0xff) {
protoTrace("HDLC frame with bad address field %#x", frame[0]);
- return (FALSE);
+ return (false);
}
if ((frame[1]&0xf7) != 0xc0) {
protoTrace("HDLC frame with bad control field %#x", frame[1]);
- return (FALSE);
+ return (false);
}
static u_char buf[2] = { DLE, ETX };
return (putModemDLEData(frame, frame.getLength(), frameRev, 0) &&
/*
* Send a single byte frame.
*/
-fxBool
-Class1Modem::sendFrame(u_char fcf, fxBool lastFrame)
+bool
+Class1Modem::sendFrame(u_char fcf, bool lastFrame)
{
HDLCFrame frame(conf.class1FrameOverhead);
frame.put(0xff);
/*
* Send a frame with DCS/DIS.
*/
-fxBool
-Class1Modem::sendFrame(u_char fcf, u_int dcs, u_int xinfo, fxBool lastFrame)
+bool
+Class1Modem::sendFrame(u_char fcf, u_int dcs, u_int xinfo, bool lastFrame)
{
HDLCFrame frame(conf.class1FrameOverhead);
frame.put(0xff);
/*
* Send a frame with TSI/CSI/PWD/SUB/SEP.
*/
-fxBool
-Class1Modem::sendFrame(u_char fcf, const fxStr& tsi, fxBool lastFrame)
+bool
+Class1Modem::sendFrame(u_char fcf, const fxStr& tsi, bool lastFrame)
{
HDLCFrame frame(conf.class1FrameOverhead);
frame.put(0xff);
return (sendRawFrame(frame));
}
-fxBool
-Class1Modem::transmitFrame(u_char fcf, fxBool lastFrame)
+bool
+Class1Modem::transmitFrame(u_char fcf, bool lastFrame)
{
startTimeout(2550); // 3.0 - 15% = 2.55 secs
- fxBool frameSent =
+ bool frameSent =
atCmd(thCmd, AT_NOTHING) &&
atResponse(rbuf, 0) == AT_CONNECT &&
sendFrame(fcf, lastFrame);
return (frameSent);
}
-fxBool
-Class1Modem::transmitFrame(u_char fcf, u_int dcs, u_int xinfo, fxBool lastFrame)
+bool
+Class1Modem::transmitFrame(u_char fcf, u_int dcs, u_int xinfo, bool lastFrame)
{
/*
* The T.30 spec says no frame can take more than 3 seconds
* and guard against the send exceeding the lower bound.
*/
startTimeout(2550); // 3.0 - 15% = 2.55 secs
- fxBool frameSent =
+ bool frameSent =
atCmd(thCmd, AT_NOTHING) &&
atResponse(rbuf, 0) == AT_CONNECT &&
sendFrame(fcf, dcs, xinfo, lastFrame);
return (frameSent);
}
-fxBool
-Class1Modem::transmitFrame(u_char fcf, const fxStr& tsi, fxBool lastFrame)
+bool
+Class1Modem::transmitFrame(u_char fcf, const fxStr& tsi, bool lastFrame)
{
startTimeout(3000); // give more time than others
- fxBool frameSent =
+ bool frameSent =
atCmd(thCmd, AT_NOTHING) &&
atResponse(rbuf, 0) == AT_CONNECT &&
sendFrame(fcf, tsi, lastFrame);
/*
* Send data using the specified signalling rate.
*/
-fxBool
+bool
Class1Modem::transmitData(int br, u_char* data, u_int cc,
- const u_char* bitrev, fxBool eod)
+ const u_char* bitrev, bool eod)
{
if (flowControl == FLOW_XONXOFF)
setXONXOFF(FLOW_XONXOFF, FLOW_NONE, ACT_FLUSH);
fxStr tmCmd(br, tmCmdFmt);
- fxBool ok = (atCmd(tmCmd, AT_CONNECT) &&
+ bool ok = (atCmd(tmCmd, AT_CONNECT) &&
sendClass1Data(data, cc, bitrev, eod) &&
- (eod ? waitFor(AT_OK) : TRUE));
+ (eod ? waitFor(AT_OK) : true));
if (flowControl == FLOW_XONXOFF)
setXONXOFF(FLOW_NONE, FLOW_NONE, ACT_DRAIN);
return (ok);
* is not received before the timeout, the receive
* is aborted.
*/
-fxBool
+bool
Class1Modem::recvFrame(HDLCFrame& frame, long ms)
{
frame.reset();
startTimeout(ms);
- fxBool readPending = atCmd(rhCmd, AT_NOTHING);
+ bool readPending = atCmd(rhCmd, AT_NOTHING);
if (readPending && waitFor(AT_CONNECT,0))
return recvRawFrame(frame); // NB: stops inherited timeout
stopTimeout("waiting for v.21 carrier");
if (readPending && wasTimeout())
abortReceive();
- return (FALSE);
+ return (false);
}
/*
* Receive TCF data using the specified signalling rate.
*/
-fxBool
+bool
Class1Modem::recvTCF(int br, HDLCFrame& buf, const u_char* bitrev, long ms)
{
buf.reset();
/*
* Loop waiting for carrier or timeout.
*/
- fxBool readPending, gotCarrier;
+ bool readPending, gotCarrier;
fxStr rmCmd(br, rmCmdFmt);
do {
readPending = atCmd(rmCmd, AT_NOTHING);
/*
* If carrier was recognized, collect the data.
*/
- fxBool gotData = FALSE;
+ bool gotData = false;
if (gotCarrier) {
int c = getModemChar(0); // NB: timeout is to first byte
stopTimeout("receiving TCF");
if (c == DLE) {
c = getModemChar(0);
if (c == ETX) {
- gotData = TRUE;
+ gotData = true;
break;
}
}
/*
* Reset a Class 1 modem.
*/
-fxBool
+bool
Class1Modem::reset(long ms)
{
return (FaxModem::reset(ms) && setupClass1Parameters());
/*
* Wait (carefully) for some response from the modem.
*/
-fxBool
+bool
Class1Modem::waitFor(ATResponse wanted, long ms)
{
for (;;) {
ATResponse response = atResponse(rbuf, ms);
if (response == wanted)
- return (TRUE);
+ return (true);
switch (response) {
case AT_TIMEOUT:
case AT_EMPTYLINE:
modemTrace("MODEM %s", ATresponses[response]);
/* fall thru... */
case AT_FCERROR:
- return (FALSE);
+ return (false);
}
}
}
/*
* Send <what>=? and get a range response.
*/
-fxBool
+bool
Class1Modem::class1Query(const char* what, Class1Cap caps[])
{
char response[1024];
sync(5000);
return (parseQuery(response, caps));
}
- return (FALSE);
+ return (false);
}
/*
/*
* Parse a Class 1 parameter string.
*/
-fxBool
+bool
Class1Modem::parseQuery(const char* cp, Class1Cap caps[])
{
while (cp[0]) {
continue;
}
if (!isdigit(cp[0]))
- return (FALSE);
+ return (false);
int v = 0;
do {
v = v*10 + (cp[0] - '0');
} while (isdigit((++cp)[0]));
for (u_int i = 0; i < NCAPS; i++)
if (caps[i].value == v) {
- caps[i].ok = TRUE;
+ caps[i].ok = true;
break;
}
if (cp[0] == COMMA) // <item>,<item>...
cp++;
}
- return (TRUE);
+ return (true);
}
u_char br; // Class 2 bit rate parameter
u_short sr; // T.30 DCS signalling rate
u_char mod; // modulation technique
- fxBool ok; // true if modem is capable
+ bool ok; // true if modem is capable
} Class1Cap;
#define HasShortTraining(c) \
((c)->mod == V17 && ((c)->value & 1) && (c)[1].ok)
Class1Cap recvCaps[15]; // modem recv capabilities
const Class1Cap* curcap; // capabilities being used
u_int discap; // DIS signalling rate capabilities
- fxBool prevPage; // a previous page was received
- fxBool pageGood; // quality of last page received
- fxBool recvdDCN; // received DCN frame
- fxBool messageReceived; // expect/don't expect message carrier
+ bool prevPage; // a previous page was received
+ bool pageGood; // quality of last page received
+ bool recvdDCN; // received DCN frame
+ bool messageReceived; // expect/don't expect message carrier
u_int lastPPM; // last PPM during receive
static const u_int modemPFMCodes[8];// map T.30 FCF to Class 2 PFM
static const char* modulationNames[6];
// modem setup stuff
- virtual fxBool setupModem();
- virtual fxBool setupClass1Parameters();
- virtual fxBool setupFlowControl(FlowControl fc);
+ virtual bool setupModem();
+ virtual bool setupClass1Parameters();
+ virtual bool setupFlowControl(FlowControl fc);
// transmission support
- fxBool sendPrologue(u_int dcs, u_int xinfo, const fxStr& tsi);
- fxBool dropToNextBR(Class2Params&);
- fxBool raiseToNextBR(Class2Params&);
- fxBool sendTraining(Class2Params&, int, fxStr& emsg);
- fxBool sendTCF(const Class2Params&, u_int ms);
- fxBool sendPage(TIFF* tif, const Class2Params&, u_int, fxStr& emsg);
- fxBool sendPageData(u_char* data, u_int cc, const u_char* bitrev);
- fxBool sendRTC(fxBool is2D);
- fxBool sendPPM(u_int ppm, HDLCFrame& mcf, fxStr& emsg);
- fxBool decodePPM(const fxStr& pph, u_int& ppm, fxStr& emsg);
+ bool sendPrologue(u_int dcs, u_int xinfo, const fxStr& tsi);
+ bool dropToNextBR(Class2Params&);
+ bool raiseToNextBR(Class2Params&);
+ bool sendTraining(Class2Params&, int, fxStr& emsg);
+ bool sendTCF(const Class2Params&, u_int ms);
+ bool sendPage(TIFF* tif, const Class2Params&, u_int, fxStr& emsg);
+ bool sendPageData(u_char* data, u_int cc, const u_char* bitrev);
+ bool sendRTC(bool is2D);
+ bool sendPPM(u_int ppm, HDLCFrame& mcf, fxStr& emsg);
+ bool decodePPM(const fxStr& pph, u_int& ppm, fxStr& emsg);
// reception support
const AnswerMsg* findAnswer(const char*);
- fxBool recvIdentification(
+ bool recvIdentification(
u_int f1, const fxStr& pwd,
u_int f2, const fxStr& addr,
u_int f3, const fxStr& id,
u_int f4, u_int dics, u_int xinfo,
u_int timer, fxStr& emsg);
- fxBool recvDCSFrames(HDLCFrame& frame);
- fxBool recvTraining();
- fxBool recvPPM(int& ppm, fxStr& emsg);
- fxBool recvPageData(TIFF*, fxStr& emsg);
+ bool recvDCSFrames(HDLCFrame& frame);
+ bool recvTraining();
+ bool recvPPM(int& ppm, fxStr& emsg);
+ bool recvPageData(TIFF*, fxStr& emsg);
void recvData(TIFF*, u_char* buf, int n);
void processDCSFrame(const HDLCFrame& frame);
void abortPageRecv();
AT_FCERROR = 100 // "+FCERROR"
};
virtual ATResponse atResponse(char* buf, long ms = 30*1000);
- virtual fxBool waitFor(ATResponse wanted, long ms = 30*1000);
+ virtual bool waitFor(ATResponse wanted, long ms = 30*1000);
void encodeTSI(fxStr& binary, const fxStr& ascii);
const fxStr& decodeTSI(fxStr& ascii, const HDLCFrame& binary);
void encodePWD(fxStr& binary, const fxStr& ascii);
const Class1Cap* findSRCapability(u_short sr, const Class1Cap[]);
const Class1Cap* findBRCapability(u_short br, const Class1Cap[]);
// class 1 HDLC frame support
- fxBool transmitFrame(u_char fcf, fxBool lastFrame = TRUE);
- fxBool transmitFrame(u_char fcf, u_int, u_int, fxBool lastFrame = TRUE);
- fxBool transmitFrame(u_char fcf, const fxStr&, fxBool lastFrame=TRUE);
- fxBool transmitData(int br, u_char* data, u_int cc,
- const u_char* bitrev, fxBool eod);
- fxBool sendFrame(u_char fcf, fxBool lastFrame = TRUE);
- fxBool sendFrame(u_char fcf, u_int, u_int, fxBool lastFrame = TRUE);
- fxBool sendFrame(u_char fcf, const fxStr&, fxBool lastFrame = TRUE);
- fxBool sendRawFrame(HDLCFrame& frame);
- fxBool sendClass1Data(const u_char* data, u_int cc,
- const u_char* bitrev, fxBool eod);
- fxBool recvFrame(HDLCFrame& frame, long ms = 10*1000);
- fxBool recvTCF(int br, HDLCFrame&, const u_char* bitrev, long ms);
- fxBool recvRawFrame(HDLCFrame& frame);
+ bool transmitFrame(u_char fcf, bool lastFrame = true);
+ bool transmitFrame(u_char fcf, u_int, u_int, bool lastFrame = true);
+ bool transmitFrame(u_char fcf, const fxStr&, bool lastFrame=true);
+ bool transmitData(int br, u_char* data, u_int cc,
+ const u_char* bitrev, bool eod);
+ bool sendFrame(u_char fcf, bool lastFrame = true);
+ bool sendFrame(u_char fcf, u_int, u_int, bool lastFrame = true);
+ bool sendFrame(u_char fcf, const fxStr&, bool lastFrame = true);
+ bool sendRawFrame(HDLCFrame& frame);
+ bool sendClass1Data(const u_char* data, u_int cc,
+ const u_char* bitrev, bool eod);
+ bool recvFrame(HDLCFrame& frame, long ms = 10*1000);
+ bool recvTCF(int br, HDLCFrame&, const u_char* bitrev, long ms);
+ bool recvRawFrame(HDLCFrame& frame);
void abortReceive();
void traceHDLCFrame(const char* direction, const HDLCFrame& frame);
// class 1 command support routines
- fxBool class1Query(const char* what, Class1Cap caps[]);
- fxBool parseQuery(const char*, Class1Cap caps[]);
+ bool class1Query(const char* what, Class1Cap caps[]);
+ bool parseQuery(const char*, Class1Cap caps[]);
public:
Class1Modem(FaxServer&, const ModemConfig&);
virtual ~Class1Modem();
// send support
- fxBool sendSetup(FaxRequest&, const Class2Params&, fxStr& emsg);
+ bool sendSetup(FaxRequest&, const Class2Params&, fxStr& emsg);
CallStatus dialResponse(fxStr& emsg);
- FaxSendStatus getPrologue(Class2Params&, fxBool&, fxStr&);
+ FaxSendStatus getPrologue(Class2Params&, bool&, fxStr&);
void sendBegin();
void sendSetupPhaseB(const fxStr& pwd, const fxStr& sub);
FaxSendStatus sendPhaseB(TIFF* tif, Class2Params&, FaxMachineInfo&,
CallType answerCall(AnswerType, fxStr& emsg);
u_int modemDIS() const;
u_int modemXINFO() const;
- fxBool setupReceive();
- fxBool recvBegin(fxStr& emsg);
- fxBool recvPage(TIFF*, int& ppm, fxStr& emsg);
- fxBool recvEnd(fxStr& emsg);
+ bool setupReceive();
+ bool recvBegin(fxStr& emsg);
+ bool recvPage(TIFF*, int& ppm, fxStr& emsg);
+ bool recvEnd(fxStr& emsg);
void recvAbort();
// polling support
- fxBool requestToPoll(fxStr&);
- fxBool pollBegin(const fxStr& cig, const fxStr& sep, const fxStr& pwd,
+ bool requestToPoll(fxStr&);
+ bool pollBegin(const fxStr& cig, const fxStr& sep, const fxStr& pwd,
fxStr& emsg);
// miscellaneous
- fxBool faxService(); // switch to fax mode
- fxBool reset(long ms); // reset modem
+ bool faxService(); // switch to fax mode
+ bool reset(long ms); // reset modem
void setLID(const fxStr& number); // set local id string
- fxBool supportsPolling() const; // modem capability
+ bool supportsPolling() const; // modem capability
};
#endif /* _CLASS1_ */
#include "HDLCFrame.h"
#include "t.30.h"
-fxBool
+bool
Class1Modem::requestToPoll(fxStr&)
{
- return TRUE;
+ return true;
}
-fxBool
+bool
Class1Modem::pollBegin(const fxStr& cig0,
const fxStr& sep0, const fxStr& pwd0, fxStr& emsg)
{
send |= DIS_PWD;
}
- setInputBuffering(FALSE);
- prevPage = FALSE; // no previous page received
- pageGood = FALSE; // quality of received page
+ setInputBuffering(false);
+ prevPage = false; // no previous page received
+ pageGood = false; // quality of received page
return atCmd(thCmd, AT_NOTHING) &&
atResponse(rbuf, 2550) == AT_CONNECT &&
/*
* Begin the receive protocol.
*/
-fxBool
+bool
Class1Modem::recvBegin(fxStr& emsg)
{
- setInputBuffering(FALSE);
- prevPage = FALSE; // no previous page received
- pageGood = FALSE; // quality of received page
- messageReceived = FALSE; // expect message carrier
- recvdDCN = FALSE; // haven't seen DCN
+ setInputBuffering(false);
+ prevPage = false; // no previous page received
+ pageGood = false; // quality of received page
+ messageReceived = false; // expect message carrier
+ recvdDCN = false; // haven't seen DCN
lastPPM = FCF_DCN; // anything will do
return FaxModem::recvBegin(emsg) && recvIdentification(
* Transmit local identification and wait for the
* remote side to respond with their identification.
*/
-fxBool
+bool
Class1Modem::recvIdentification(
u_int f1, const fxStr& pwd,
u_int f2, const fxStr& addr,
u_int trecovery = howmany(conf.class1TrainingRecovery, 1000);
time_t start = Sys::now();
HDLCFrame frame(conf.class1FrameOverhead);
- fxBool framesSent;
+ bool framesSent;
emsg = "No answer (T.30 T1 timeout)";
/*
*/
if (f1) {
startTimeout(3000);
- framesSent = sendFrame(f1, pwd, FALSE);
+ framesSent = sendFrame(f1, pwd, false);
stopTimeout("sending PWD frame");
} else if (f2) {
startTimeout(3000);
- framesSent = sendFrame(f2, addr, FALSE);
+ framesSent = sendFrame(f2, addr, false);
stopTimeout("sending SUB/SEP frame");
} else {
startTimeout(3000);
- framesSent = sendFrame(f3, id, FALSE);
+ framesSent = sendFrame(f3, id, false);
stopTimeout("sending CSI/CIG frame");
}
for (;;) {
if (framesSent) {
if (f1) {
startTimeout(2550);
- framesSent = sendFrame(f2, addr, FALSE);
+ framesSent = sendFrame(f2, addr, false);
stopTimeout("sending SUB/SEP frame");
}
if (framesSent && f2) {
startTimeout(2550);
- framesSent = sendFrame(f3, id, FALSE);
+ framesSent = sendFrame(f3, id, false);
stopTimeout("sending CSI/CIG frame");
}
if (framesSent) {
if (!recvDCSFrames(frame)) {
if (frame.getFCF() == FCF_DCN) {
emsg = "RSPREC error/got DCN";
- recvdDCN = TRUE;
+ recvdDCN = true;
} else // XXX DTC/DIS not handled
emsg = "RSPREC invalid response received";
break;
}
if (recvTraining()) {
emsg = "";
- return (TRUE);
+ return (true);
}
emsg = "Failure to train modems";
/*
* Retransmit ident frames.
*/
if (f1)
- framesSent = transmitFrame(f1, pwd, FALSE);
+ framesSent = transmitFrame(f1, pwd, false);
else if (f2)
- framesSent = transmitFrame(f2, addr, FALSE);
+ framesSent = transmitFrame(f2, addr, false);
else
- framesSent = transmitFrame(f3, id, FALSE);
+ framesSent = transmitFrame(f3, id, false);
}
- return (FALSE);
+ return (false);
}
/*
* Receive DCS preceded by any optional frames.
*/
-fxBool
+bool
Class1Modem::recvDCSFrames(HDLCFrame& frame)
{
fxStr s;
/*
* Receive training and analyze TCF.
*/
-fxBool
+bool
Class1Modem::recvTraining()
{
protoTrace("RECV training at %s %s",
modulationNames[curcap->mod],
Class2Params::bitRateNames[curcap->br]);
HDLCFrame buf(conf.class1FrameOverhead);
- fxBool ok = recvTCF(curcap->value, buf, frameRev, conf.class1TCFRecvTimeout);
+ bool ok = recvTCF(curcap->value, buf, frameRev, conf.class1TCFRecvTimeout);
if (ok) { // check TCF data
u_int n = buf.getLength();
u_int nonzero = 0;
if (nonzero > conf.class1TCFMaxNonZero) {
protoTrace("RECV: reject TCF (too many non-zero, max %u%%)",
conf.class1TCFMaxNonZero);
- ok = FALSE;
+ ok = false;
}
if (zerorun < minrun) {
protoTrace("RECV: reject TCF (zero run too short, min %u)", minrun);
- ok = FALSE;
+ ok = false;
}
(void) waitFor(AT_NOCARRIER); // wait for message carrier to drop
}
* This routine is called after receiving training or after
* sending a post-page response in a multi-page document.
*/
-fxBool
+bool
Class1Modem::recvPage(TIFF* tif, int& ppm, fxStr& emsg)
{
top:
/*
* Look for message carrier and receive Phase C data.
*/
- setInputBuffering(TRUE);
+ setInputBuffering(true);
if (flowControl == FLOW_XONXOFF)
(void) setXONXOFF(FLOW_NONE, FLOW_XONXOFF, ACT_FLUSH);
/*
*/
messageReceived = waitFor(AT_NOCARRIER, 2*1000);
if (messageReceived)
- prevPage = TRUE;
+ prevPage = true;
timer = conf.t1Timer; // wait longer for PPM
}
}
if (flowControl == FLOW_XONXOFF)
(void) setXONXOFF(FLOW_NONE, FLOW_NONE, ACT_DRAIN);
- setInputBuffering(FALSE);
+ setInputBuffering(false);
if (!messageReceived && rmResponse != AT_FCERROR) {
/*
* One of many things may have happened:
if (abortRequested()) {
// XXX no way to purge TIFF directory
emsg = "Receive aborted due to operator intervention";
- return (FALSE);
+ return (false);
}
/*
* Do command received logic.
case FCF_DIS: // XXX no support
protoTrace("RECV DIS/DTC");
emsg = "Can not continue after DIS/DTC";
- return (FALSE);
+ return (false);
case FCF_PWD:
case FCF_SUB:
case FCF_NSS:
* was received--this violates the protocol.
*/
emsg = "COMREC invalid response received";
- return (FALSE);
+ return (false);
}
/*
* [Re]transmit post page response.
*/
messageReceived = (lastPPM == FCF_EOM);
ppm = modemPPMCodes[lastPPM&7];
- return (TRUE);
+ return (true);
}
} else {
/*
* writes will overwrite the previous data.
*/
recvResetPage(tif);
- messageReceived = TRUE; // expect DCS next
+ messageReceived = true; // expect DCS next
}
break;
case FCF_DCN: // DCN
protoTrace("RECV recv DCN");
emsg = "COMREC received DCN";
- recvdDCN = TRUE;
- return (FALSE);
+ recvdDCN = true;
+ return (false);
default:
emsg = "COMREC invalid response received";
- return (FALSE);
+ return (false);
}
}
} while (!wasTimeout() && lastResponse != AT_EMPTYLINE);
goto top;
} else
emsg = "T.30 T2 timeout, expected page not received";
- return (FALSE);
+ return (false);
}
void
/*
* Receive Phase C data w/ or w/o copy quality checking.
*/
-fxBool
+bool
Class1Modem::recvPageData(TIFF* tif, fxStr& emsg)
{
- fxBool pageRecvd = recvPageDLEData(tif, checkQuality(), params, emsg);
+ bool pageRecvd = recvPageDLEData(tif, checkQuality(), params, emsg);
TIFFSetField(tif, TIFFTAG_IMAGELENGTH, getRecvEOLCount());
TIFFSetField(tif, TIFFTAG_CLEANFAXDATA, getRecvBadLineCount() ?
CLEANFAXDATA_REGENERATED : CLEANFAXDATA_CLEAN);
/*
* Complete a receive session.
*/
-fxBool
+bool
Class1Modem::recvEnd(fxStr&)
{
if (!recvdDCN) {
} while (Sys::now()-start < t1 &&
(!frame.isOK() || frame.getFCF() == FCF_EOP));
}
- setInputBuffering(TRUE);
- return (TRUE);
+ setInputBuffering(true);
+ return (true);
}
/*
Class1Modem::recvAbort()
{
transmitFrame(FCF_DCN|FCF_RCVR);
- recvdDCN = TRUE; // don't hang around in recvEnd
+ recvdDCN = true; // don't hang around in recvEnd
}
/*
* Force the tty into a known flow control state.
*/
-fxBool
+bool
Class1Modem::sendSetup(FaxRequest& req, const Class2Params& dis, fxStr& emsg)
{
if (flowControl == FLOW_XONXOFF)
Class1Modem::sendBegin()
{
FaxModem::sendBegin();
- setInputBuffering(FALSE);
+ setInputBuffering(false);
// polling accounting?
params.br = (u_int) -1; // force initial training
}
* Get the initial DIS command.
*/
FaxSendStatus
-Class1Modem::getPrologue(Class2Params& params, fxBool& hasDoc, fxStr& emsg)
+Class1Modem::getPrologue(Class2Params& params, bool& hasDoc, fxStr& emsg)
{
u_int t1 = howmany(conf.t1Timer, 1000); // T1 timer in seconds
time_t start = Sys::now();
HDLCFrame frame(conf.class1FrameOverhead);
startTimeout(conf.t2Timer);
- fxBool framerecvd = recvRawFrame(frame);
+ bool framerecvd = recvRawFrame(frame);
stopTimeout("receiving id frame");
for (;;) {
if (framerecvd) {
FCF_EOP, // 7 ??? XXX
};
-fxBool
+bool
Class1Modem::decodePPM(const fxStr& pph, u_int& ppm, fxStr& emsg)
{
if (FaxModem::decodePPM(pph, ppm, emsg)) {
ppm = modemPFMCodes[ppm];
- return (TRUE);
+ return (true);
} else
- return (FALSE);
+ return (false);
}
/*
fxStr& pph, fxStr& emsg)
{
int ntrys = 0; // # retraining/command repeats
- fxBool morePages = TRUE; // more pages still to send
+ bool morePages = true; // more pages still to send
HDLCFrame frame(conf.class1FrameOverhead);
do {
}
if (!sendTraining(params, 3, emsg))
return (send_retry);
- morePages = TRUE; // force continuation
+ morePages = true; // force continuation
next = params; // avoid retraining above
break;
case FCF_PIN: // nak, retry w/ operator intervention
* Note that we send real zero data here rather than using
* the Class 1 modem facility to do zero fill.
*/
-fxBool
+bool
Class1Modem::sendTCF(const Class2Params& params, u_int ms)
{
u_int tcfLen = params.transferSize(ms);
u_char* tcf = new u_char[tcfLen];
memset(tcf, 0, tcfLen);
- fxBool ok = transmitData(curcap->value, tcf, tcfLen, frameRev, TRUE);
+ bool ok = transmitData(curcap->value, tcf, tcfLen, frameRev, true);
delete tcf;
return ok;
}
* TSI transmitter subscriber id
* DCS digital command signal
*/
-fxBool
+bool
Class1Modem::sendPrologue(u_int dcs, u_int dcs_xinfo, const fxStr& tsi)
{
- fxBool frameSent = (
+ bool frameSent = (
atCmd(thCmd, AT_NOTHING) &&
atResponse(rbuf, 2550) == AT_CONNECT
);
if (!frameSent)
- return (FALSE);
+ return (false);
if (pwd != fxStr::null) {
startTimeout(2550); // 3.0 - 15% = 2.55 secs
- fxBool frameSent = sendFrame(FCF_PWD|FCF_SNDR, pwd, FALSE);
+ bool frameSent = sendFrame(FCF_PWD|FCF_SNDR, pwd, false);
stopTimeout("sending PWD frame");
if (!frameSent)
- return (FALSE);
+ return (false);
}
if (sub != fxStr::null) {
startTimeout(2550); // 3.0 - 15% = 2.55 secs
- fxBool frameSent = sendFrame(FCF_SUB|FCF_SNDR, sub, FALSE);
+ bool frameSent = sendFrame(FCF_SUB|FCF_SNDR, sub, false);
stopTimeout("sending SUB frame");
if (!frameSent)
- return (FALSE);
+ return (false);
}
startTimeout(2550); // 3.0 - 15% = 2.55 secs
- frameSent = sendFrame(FCF_TSI|FCF_SNDR, tsi, FALSE);
+ frameSent = sendFrame(FCF_TSI|FCF_SNDR, tsi, false);
stopTimeout("sending TSI frame");
if (!frameSent)
- return (FALSE);
+ return (false);
startTimeout(2550); // 3.0 - 15% = 2.55 secs
frameSent = sendFrame(FCF_DCS|FCF_SNDR, dcs, dcs_xinfo);
stopTimeout("sending DCS frame");
* Return whether or not the previously received DIS indicates
* the remote side is capable of the T.30 DCS signalling rate.
*/
-static fxBool
+static bool
isCapable(u_int sr, u_int dis)
{
dis = (dis & DIS_SIGRATE) >> 10;
switch (sr) {
case DCSSIGRATE_2400V27:
if (dis == DISSIGRATE_V27FB)
- return (TRUE);
+ return (true);
/* fall thru... */
case DCSSIGRATE_4800V27:
return ((dis & DISSIGRATE_V27) != 0);
case DCSSIGRATE_14400V33:
case DCSSIGRATE_12000V33:
if (dis == DISSIGRATE_V33)
- return (TRUE);
+ return (true);
/* fall thru... */
case DCSSIGRATE_14400V17:
case DCSSIGRATE_12000V17:
case DCSSIGRATE_7200V17:
return (dis == DISSIGRATE_V17);
}
- return (FALSE);
+ return (false);
}
/*
* Send capabilities and do training.
*/
-fxBool
+bool
Class1Modem::sendTraining(Class2Params& params, int tries, fxStr& emsg)
{
if (tries == 0) {
emsg = "DIS/DTC received 3 times; DCS not recognized";
- return (FALSE);
+ return (false);
}
u_int dcs = params.getDCS(); // NB: 24-bit DCS and
u_int dcs_xinfo = params.getXINFO(); // 32-bit extension
case FCF_CFR: // training confirmed
protoTrace("TRAINING succeeded");
setDataTimeout(60, params.br);
- return (TRUE);
+ return (true);
case FCF_FTT: // failure to train, retry
break;
case FCF_DIS: // new capabilities, maybe
emsg = "Failure to train remote modem at 2400 bps or minimum speed";
done:
protoTrace("TRAINING failed");
- return (FALSE);
+ return (false);
}
/*
* Select the next lower signalling rate that's
* acceptable to both local and remote machines.
*/
-fxBool
+bool
Class1Modem::dropToNextBR(Class2Params& params)
{
for (;;) {
if (params.br == minsp)
- return (FALSE);
+ return (false);
// get ``best capability'' of modem at this baud rate
curcap = findBRCapability(--params.br, xmitCaps);
if (curcap) {
// hunt for compatibility with remote at this baud rate
do {
if (isCapable(curcap->sr, dis))
- return (TRUE);
+ return (true);
curcap--;
} while (curcap->br == params.br);
}
* Select the next higher signalling rate that's
* acceptable to both local and remote machines.
*/
-fxBool
+bool
Class1Modem::raiseToNextBR(Class2Params& params)
{
for (;;) {
if (params.br == BR_14400) // highest speed
- return (FALSE);
+ return (false);
// get ``best capability'' of modem at this baud rate
curcap = findBRCapability(++params.br, xmitCaps);
if (curcap) {
// hunt for compatibility with remote at this baud rate
do {
if (isCapable(curcap->sr, dis))
- return (TRUE);
+ return (true);
curcap--;
} while (curcap->br == params.br);
}
/*
* Send data for the current page.
*/
-fxBool
+bool
Class1Modem::sendPageData(u_char* data, u_int cc, const u_char* bitrev)
{
beginTimedTransfer();
- fxBool rc = sendClass1Data(data, cc, bitrev, FALSE);
+ bool rc = sendClass1Data(data, cc, bitrev, false);
endTimedTransfer();
protoTrace("SENT %u bytes of data", cc);
return rc;
* seems that some Class 1 modems do not immediately
* send all the data they are presented.
*/
-fxBool
-Class1Modem::sendRTC(fxBool is2D)
+bool
+Class1Modem::sendRTC(bool is2D)
{
static const u_char RTC1D[9+20] =
{ 0x00,0x10,0x01,0x00,0x10,0x01,0x00,0x10,0x01 };
{ 0x00,0x18,0x00,0xC0,0x06,0x00,0x30,0x01,0x80,0x0C };
protoTrace("SEND %s RTC", is2D ? "2D" : "1D");
if (is2D)
- return sendClass1Data(RTC2D, sizeof (RTC2D), frameRev, TRUE);
+ return sendClass1Data(RTC2D, sizeof (RTC2D), frameRev, true);
else
- return sendClass1Data(RTC1D, sizeof (RTC1D), frameRev, TRUE);
+ return sendClass1Data(RTC1D, sizeof (RTC1D), frameRev, true);
}
#define EOLcheck(w,mask,code) \
- if ((w & mask) == code) { w |= mask; return (TRUE); }
+ if ((w & mask) == code) { w |= mask; return (true); }
/*
* Check the last 24 bits of received T.4-encoded
* to insure future calls do not re-recognize an
* EOL code.
*/
-static fxBool
+static bool
EOLcode(u_long& w)
{
if ((w & 0x00f00f) == 0) {
EOLcheck(w, 0xfc3f00, 0x002000);
EOLcheck(w, 0xfe1f00, 0x001000);
}
- return (FALSE);
+ return (false);
}
#undef EOLcheck
/*
* Send a page of data.
*/
-fxBool
+bool
Class1Modem::sendPage(TIFF* tif, const Class2Params& params, u_int pageChop, fxStr& emsg)
{
/*
fxStr tmCmd(curcap[HasShortTraining(curcap)].value, tmCmdFmt);
if (!atCmd(tmCmd, AT_CONNECT)) {
emsg = "Unable to establish message carrier";
- return (FALSE);
+ return (false);
}
- fxBool rc = TRUE;
+ bool rc = true;
protoTrace("SEND begin page");
if (flowControl == FLOW_XONXOFF)
setXONXOFF(FLOW_XONXOFF, FLOW_NONE, ACT_FLUSH);
/*
* Setup tag line processing.
*/
- fxBool doTagLine = setupTagLineSlop(params);
+ bool doTagLine = setupTagLineSlop(params);
u_int ts = getTagLineSlop();
/*
* Calculate total amount of space needed to read
/*
* Send the post-page-message and wait for a response.
*/
-fxBool
+bool
Class1Modem::sendPPM(u_int ppm, HDLCFrame& mcf, fxStr& emsg)
{
for (int t = 0; t < 3; t++) {
tracePPM("SEND send", ppm);
if (transmitFrame(ppm|FCF_SNDR) && recvFrame(mcf, conf.t4Timer))
- return (TRUE);
+ return (true);
if (abortRequested())
- return (FALSE);
+ return (false);
}
emsg = "No response to MPS or EOP repeated 3 tries";
- return (FALSE);
+ return (false);
}
/*
Class1Modem::sendEnd()
{
transmitFrame(FCF_DCN|FCF_SNDR); // disconnect
- setInputBuffering(TRUE);
+ setInputBuffering(true);
}
/*
* the manufacturer-specific bogosity here and leave
* the remainder of the Class 2 support fairly generic.
*/
-fxBool
+bool
Class2Modem::setupModem()
{
if (!selectBaudRate(conf.maxRate, conf.flowControl, conf.flowControl))
- return (FALSE);
+ return (false);
// Query service support information
fxStr s;
if (doQuery(conf.classQueryCmd, s, 500) && FaxModem::parseRange(s, modemServices))
traceBits(modemServices & SERVICE_ALL, serviceNames);
if ((modemServices & serviceType) == 0)
- return (FALSE);
+ return (false);
atCmd(classCmd);
/*
fxStr t30parms;
if (!doQuery(dccQueryCmd, t30parms, 500)) {
serverTrace("Error getting modem capabilities");
- return (FALSE);
+ return (false);
}
/*
* Syntax: (vr),(br),(wd),(ln),(df),(ec),(bf),(st)
if (!parseRange(t30parms, modemParams)) {
serverTrace("Error parsing " | dccQueryCmd | " response: "
"\"" | t30parms | "\"");
- return (FALSE);
+ return (false);
}
traceModemParams();
/*
* during a transmission. This went away in SP-2388-B and in
* the final Class 2.0 spec. Consequently we configure the
* modem either to ignore it (Class 2.0) or to use whatever
- * is configured (it defaults to TRUE).
+ * is configured (it defaults to true).
*/
if (serviceType == SERVICE_CLASS20)
- xmitWaitForXON = FALSE;
+ xmitWaitForXON = false;
else
xmitWaitForXON = conf.class2XmitWaitForXON;
setupClass2Parameters(); // send parameters to the modem
- return (TRUE);
+ return (true);
}
/*
* 0. This interface is used only for outbound use or when
* followed by setup of receive-specific parameters.
*/
-fxBool
+bool
Class2Modem::setupClass2Parameters()
{
if (modemServices & serviceType) { // when resetting at startup
*/
setupDCC();
}
- return (TRUE);
+ return (true);
}
/*
* Setup receive-specific parameters.
*/
-fxBool
+bool
Class2Modem::setupReceive()
{
/*
* Send the modem any commands needed to force use of
* the specified flow control scheme.
*/
-fxBool
+bool
Class2Modem::setupFlowControl(FlowControl fc)
{
switch (fc) {
case FLOW_XONXOFF: return atCmd(softFlowCmd);
case FLOW_RTSCTS: return atCmd(hardFlowCmd);
}
- return (TRUE);
+ return (true);
}
/*
* Setup DCC to reflect best capabilities of the server.
*/
-fxBool
+bool
Class2Modem::setupDCC()
{
params.vr = getBestVRes();
* Parse a ``capabilities'' string from the modem and
* return the values through the params parameter.
*/
-fxBool
+bool
Class2Modem::parseClass2Capabilities(const char* cap, Class2Params& params)
{
int n = sscanf(cap, "%d,%d,%d,%d,%d,%d,%d,%d",
if (params.bf > BF_ENABLE)
params.bf = BF_DISABLE;
params.st = fxmin(params.st, (u_int) ST_40MS);
- return (TRUE);
+ return (true);
} else {
protoTrace("MODEM protocol botch, can not parse \"%s\"", cap);
- return (FALSE);
+ return (false);
}
}
* Place the modem into the appropriate state
* for sending/received facsimile.
*/
-fxBool
+bool
Class2Modem::faxService()
{
return setupClass2Parameters() && class2Cmd(lidCmd, lid);
}
-fxBool
+bool
Class2Modem::setupRevision(fxStr& revision)
{
if (FaxModem::setupRevision(revision)) {
modemRevision.remove(0, pos);
}
}
- return (TRUE);
+ return (true);
} else
- return (FALSE);
+ return (false);
}
-fxBool
+bool
Class2Modem::setupModel(fxStr& model)
{
if (FaxModem::setupModel(model)) {
*/
if (modemMfr == "ZYXEL")
modemModel.resize(modemModel.next(0, ' ')); // model is first word
- return (TRUE);
+ return (true);
} else
- return (FALSE);
+ return (false);
}
-fxBool
+bool
Class2Modem::supportsPolling() const
{
return (hasPolling);
/*
* Reset a Class 2 modem.
*/
-fxBool
+bool
Class2Modem::reset(long ms)
{
return (FaxModem::reset(ms) && setupClass2Parameters());
* us an unsolicited NO CARRIER message. Isn't life
* wondeful?
*/
-fxBool
+bool
Class2Modem::waitFor(ATResponse wanted, long ms)
{
for (;;) {
ATResponse response = atResponse(rbuf, ms);
if (response == wanted)
- return (TRUE);
+ return (true);
switch (response) {
case AT_TIMEOUT:
case AT_EMPTYLINE:
case AT_NODIALTONE:
case AT_NOANSWER:
modemTrace("MODEM %s", ATresponses[response]);
- return (FALSE);
+ return (false);
case AT_FHNG:
// return hangup status, but try to wait for requested response
{ char buf[1024]; (void) atResponse(buf, 2*1000); }
/*
* Send <cmd>=<a0> and wait for response.
*/
-fxBool
+bool
Class2Modem::class2Cmd(const fxStr& cmd, int a0, ATResponse r, long ms)
{
return atCmd(cmd | fxStr(a0, "=%u"), r, ms);
/*
* Send <cmd>=<t.30 parameters> and wait response.
*/
-fxBool
+bool
Class2Modem::class2Cmd(const fxStr& cmd, const Class2Params& p, ATResponse r, long ms)
{
return atCmd(cmd | "=" | p.cmd(), r, ms);
/*
* Send <cmd>="<s>" and wait for response.
*/
-fxBool
+bool
Class2Modem::class2Cmd(const fxStr& cmd, const fxStr& s, ATResponse r, long ms)
{
return atCmd(cmd | "=\"" | s | "\"", r, ms); // XXX handle escapes
* Parse a Class 2 parameter specification
* and return the resulting bit masks.
*/
-fxBool
+bool
Class2Modem::parseRange(const char* cp, Class2Params& p)
{
if (!vparseRange(cp, 8, &p.vr,&p.br,&p.wd,&p.ln,&p.df,&p.ec,&p.bf,&p.st))
- return (FALSE);
+ return (false);
p.vr &= VR_ALL;
p.br &= BR_ALL;
p.wd &= WD_ALL;
p.ec &= EC_ALL;
p.bf &= BF_ALL;
p.st &= ST_ALL;
- return TRUE;
+ return true;
}
const char*
* that the remote side hung up the phone in a
* "normal and proper way".
*/
-fxBool
+bool
Class2Modem::isNormalHangup()
{
// normal hangup is "", "0", or "00"
u_int serviceType; // modem service required
u_int modemCQ; // copy quality capabilities mask
- fxBool xmitWaitForXON; // if true, wait for XON when sending
- fxBool hostDidCQ; // if true, copy quality done on host
- fxBool hasPolling; // if true, modem does polled recv
+ bool xmitWaitForXON; // if true, wait for XON when sending
+ bool hostDidCQ; // if true, copy quality done on host
+ bool hasPolling; // if true, modem does polled recv
char recvDataTrigger; // char to send to start recv'ing data
char hangupCode[4]; // hangup reason (from modem)
- fxBool hadHangup; // true if +FHNG:/+FHS: received
+ bool hadHangup; // true if +FHNG:/+FHS: received
const u_char* rtcRev; // bit reversal table for RTC
fxStr lid; // prepared local identifier string
// modem setup stuff
void setupDefault(fxStr&, const fxStr&, const char*);
- virtual fxBool setupModem();
- virtual fxBool setupModel(fxStr& model);
- virtual fxBool setupRevision(fxStr& rev);
- virtual fxBool setupDCC();
- virtual fxBool setupClass2Parameters();
- virtual fxBool setupFlowControl(FlowControl fc);
+ virtual bool setupModem();
+ virtual bool setupModel(fxStr& model);
+ virtual bool setupRevision(fxStr& rev);
+ virtual bool setupDCC();
+ virtual bool setupClass2Parameters();
+ virtual bool setupFlowControl(FlowControl fc);
// transmission support
- fxBool dataTransfer();
- fxBool sendRTC(fxBool is2D);
- fxBool sendPageData(TIFF* tif, u_int pageChop);
+ bool dataTransfer();
+ bool sendRTC(bool is2D);
+ bool sendPageData(TIFF* tif, u_int pageChop);
- virtual fxBool sendPage(TIFF* tif, u_int pageChop) = 0;
- virtual fxBool pageDone(u_int ppm, u_int& ppr) = 0;
+ virtual bool sendPage(TIFF* tif, u_int pageChop) = 0;
+ virtual bool pageDone(u_int ppm, u_int& ppr) = 0;
// reception support
const AnswerMsg* findAnswer(const char*);
- fxBool recvDCS(const char*);
- fxBool recvPageData(TIFF*, fxStr& emsg);
- fxBool recvPPM(TIFF*, int& ppr);
- fxBool parseFPTS(TIFF*, const char* cp, int& ppr);
+ bool recvDCS(const char*);
+ bool recvPageData(TIFF*, fxStr& emsg);
+ bool recvPPM(TIFF*, int& ppr);
+ bool parseFPTS(TIFF*, const char* cp, int& ppr);
void abortPageRecv();
// miscellaneous
enum { // Class 2-specific AT responses
AT_FPW = 114 // password status
};
virtual ATResponse atResponse(char* buf, long ms = 30*1000) = 0;
- fxBool waitFor(ATResponse wanted, long ms = 30*1000);
+ bool waitFor(ATResponse wanted, long ms = 30*1000);
fxStr stripQuotes(const char*);
// hangup processing
void processHangup(const char*);
- fxBool isNormalHangup();
+ bool isNormalHangup();
const char* hangupCause(const char* code);
void tracePPR(const char* dir, u_int ppr);
void tracePPM(const char* dir, u_int ppm);
// class 2 command support routines
- fxBool class2Cmd(const fxStr& cmd, int a0,
+ bool class2Cmd(const fxStr& cmd, int a0,
ATResponse = AT_OK, long ms = 30*1000);
- fxBool class2Cmd(const fxStr& cmd, const fxStr& a0,
+ bool class2Cmd(const fxStr& cmd, const fxStr& a0,
ATResponse = AT_OK, long ms = 30*1000);
- fxBool class2Cmd(const fxStr& cmd, const Class2Params&,
+ bool class2Cmd(const fxStr& cmd, const Class2Params&,
ATResponse =AT_OK, long ms = 30*1000);
// parsing routines for capability¶meter strings
- fxBool parseClass2Capabilities(const char* cap, Class2Params&);
- fxBool parseRange(const char*, Class2Params&);
+ bool parseClass2Capabilities(const char* cap, Class2Params&);
+ bool parseRange(const char*, Class2Params&);
const char* skipStatus(const char*);
Class2Modem(FaxServer&, const ModemConfig&);
virtual ~Class2Modem();
// send support
- fxBool sendSetup(FaxRequest&, const Class2Params&, fxStr& emsg);
+ bool sendSetup(FaxRequest&, const Class2Params&, fxStr& emsg);
CallStatus dialResponse(fxStr& emsg);
- FaxSendStatus getPrologue(Class2Params&, fxBool&, fxStr&);
+ FaxSendStatus getPrologue(Class2Params&, bool&, fxStr&);
FaxSendStatus sendPhaseB(TIFF* tif, Class2Params&, FaxMachineInfo&,
fxStr& pph, fxStr& emsg);
void sendAbort();
// receive support
- fxBool setupReceive();
- fxBool recvBegin(fxStr& emsg);
- fxBool recvPage(TIFF*, int& ppm, fxStr& emsg);
- fxBool recvEnd(fxStr& emsg);
+ bool setupReceive();
+ bool recvBegin(fxStr& emsg);
+ bool recvPage(TIFF*, int& ppm, fxStr& emsg);
+ bool recvEnd(fxStr& emsg);
void recvAbort();
// polling support
- fxBool requestToPoll(fxStr& emsg);
- fxBool pollBegin(const fxStr& cig, const fxStr& sep, const fxStr& pwd,
+ bool requestToPoll(fxStr& emsg);
+ bool pollBegin(const fxStr& cig, const fxStr& sep, const fxStr& pwd,
fxStr& emsg);
// miscellaneous
- fxBool faxService(); // switch to fax mode
- fxBool reset(long ms); // reset modem
+ bool faxService(); // switch to fax mode
+ bool reset(long ms); // reset modem
void setLID(const fxStr& number); // set local id string
- fxBool supportsPolling() const; // modem capability
+ bool supportsPolling() const; // modem capability
};
#endif /* _CLASS2_ */
if (strneq(buf, "+FHS:", 5)) {
processHangup(buf+5);
lastResponse = AT_FHNG;
- hadHangup = TRUE;
+ hadHangup = true;
} else if (strneq(buf, "+FCO", 4))
lastResponse = AT_FCON;
else if (strneq(buf, "+FPO", 4))
/*
* Send a page of data using the ``stream interface''.
*/
-fxBool
+bool
Class20Modem::sendPage(TIFF* tif, u_int pageChop)
{
protoTrace("SEND begin page");
if (flowControl == FLOW_XONXOFF)
setXONXOFF(FLOW_XONXOFF, FLOW_NONE, ACT_FLUSH);
- fxBool rc = sendPageData(tif, pageChop);
+ bool rc = sendPageData(tif, pageChop);
if (!rc)
abortDataTransfer();
else
* instead synthesize codes, ignoring whether or not the
* modem does retraining on the next page transfer.
*/
-fxBool
+bool
Class20Modem::pageDone(u_int ppm, u_int& ppr)
{
static char ppmCodes[3] = { 0x2C, 0x3B, 0x2E };
switch (atResponse(rbuf, conf.pageDoneTimeout)) {
case AT_FHNG:
if (!isNormalHangup())
- return (FALSE);
+ return (false);
/* fall thru... */
case AT_OK: // page data good
ppr = PPR_MCF; // could be PPR_RTP/PPR_PIP
- return (TRUE);
+ return (true);
case AT_ERROR: // page data bad
ppr = PPR_RTN; // could be PPR_PIN
- return (TRUE);
+ return (true);
case AT_EMPTYLINE:
case AT_TIMEOUT:
case AT_NOCARRIER:
}
bad:
processHangup("50"); // Unspecified Phase D error
- return (FALSE);
+ return (false);
}
/*
class Class20Modem : public Class2Modem {
protected:
// transmission support
- fxBool sendPage(TIFF* tif, u_int pageChop);
- fxBool pageDone(u_int ppm, u_int& ppr);
+ bool sendPage(TIFF* tif, u_int pageChop);
+ bool pageDone(u_int ppm, u_int& ppr);
void abortDataTransfer();
// reception support
if (strneq(buf, "+FHNG:", 6)) {
processHangup(buf+6);
lastResponse = AT_FHNG;
- hadHangup = TRUE;
+ hadHangup = true;
} else if (strneq(buf, "+FCON", 5))
lastResponse = AT_FCON;
else if (strneq(buf, "+FPOLL", 6))
/*
* Handle the page-end protocol.
*/
-fxBool
+bool
Class2ErsatzModem::pageDone(u_int ppm, u_int& ppr)
{
ppr = 0; // something invalid
if (sscanf(rbuf+6, "%u", &ppr) != 1) {
protoTrace("MODEM protocol botch (\"%s\"), %s",
rbuf, "can not parse PPR");
- return (FALSE); // force termination
+ return (false); // force termination
}
/*
* (In some firmware revisions...) The ZyXEL modem
* page is good (i.e. we would hang up immediately anyway).
*/
if (ppm == PPM_EOP && ppr == PPR_MCF)
- return (TRUE);
+ return (true);
break;
case AT_OK: // normal result code
case AT_ERROR: // possible if page retransmit
- return (TRUE);
+ return (true);
case AT_FHNG:
/*
* Certain modems respond +FHNG:0 on the final page
*/
if (ppm == PPM_EOP && ppr == 0 && isNormalHangup()) {
ppr = PPR_MCF;
- return (TRUE);
+ return (true);
}
return (isNormalHangup());
case AT_EMPTYLINE:
}
bad:
processHangup("50"); // Unspecified Phase D error
- return (FALSE);
+ return (false);
}
/*
/*
* Send an end-of-transmission signal to the modem.
*/
-fxBool
+bool
Class2ErsatzModem::sendEOT()
{
static char EOT[] = { DLE, ETX };
/*
* Send a page of data using the ``stream interface''.
*/
-fxBool
+bool
Class2ErsatzModem::sendPage(TIFF* tif, u_int pageChop)
{
protoTrace("SEND begin page");
if (flowControl == FLOW_XONXOFF)
setXONXOFF(FLOW_XONXOFF, FLOW_NONE, ACT_FLUSH);
- fxBool rc = sendPageData(tif, pageChop);
+ bool rc = sendPageData(tif, pageChop);
if (rc && conf.class2SendRTC)
rc = sendRTC(params.is2D());
if (rc)
class Class2ErsatzModem : public Class2Modem {
protected:
// transmission support
- fxBool sendPage(TIFF* tif, u_int pageChop);
- fxBool pageDone(u_int ppm, u_int& ppr);
+ bool sendPage(TIFF* tif, u_int pageChop);
+ bool pageDone(u_int ppm, u_int& ppr);
- fxBool sendEOT();
+ bool sendEOT();
void abortDataTransfer();
// miscellaneous
virtual ATResponse atResponse(char* buf, long ms = 30*1000);
/*
* Request to poll remote documents.
*/
-fxBool
+bool
Class2Modem::requestToPoll(fxStr& emsg)
{
if (!class2Cmd(splCmd, 1)) {
emsg = "Unable to request polling operation"
" (modem may not support polling)";
- return (FALSE);
+ return (false);
} else
- return (TRUE);
+ return (true);
}
/*
* Startup a polled receive operation.
*/
-fxBool
+bool
Class2Modem::pollBegin(const fxStr& cig, const fxStr& sep, const fxStr& pwd, fxStr& emsg)
{
const char* cmdFailed = "Unable to setup %s (modem command failed)";
if (!class2Cmd(cigCmd, cig)) { // set polling ID
emsg = fxStr::format(cmdFailed, "polling identifer");
- return (FALSE);
+ return (false);
}
if (sep != "" && paCmd != "" && !class2Cmd(paCmd, sep)) {
emsg = fxStr::format(cmdFailed, "selective polling address");
- return (FALSE);
+ return (false);
}
if (pwd != "" && pwCmd != "" && !class2Cmd(pwCmd, pwd)) {
emsg = fxStr::format(cmdFailed, "polling password");
- return (FALSE);
+ return (false);
}
- return (TRUE);
+ return (true);
}
/*
* Begin a fax receive session.
*/
-fxBool
+bool
Class2Modem::recvBegin(fxStr& emsg)
{
- fxBool status = FALSE;
+ bool status = false;
hangupCode[0] = '\0';
- hadHangup = FALSE;
+ hadHangup = false;
ATResponse r;
do {
switch (r = atResponse(rbuf, 3*60*1000)) {
case AT_EMPTYLINE:
processHangup("70");
emsg = hangupCause(hangupCode);
- return (FALSE);
+ return (false);
case AT_FNSS:
// XXX parse and pass on to server
break;
status = recvDCS(rbuf);
break;
case AT_FHNG:
- status = FALSE;
+ status = false;
break;
}
} while (r != AT_OK);
/*
* Process a received DCS.
*/
-fxBool
+bool
Class2Modem::recvDCS(const char* cp)
{
if (parseClass2Capabilities(skipStatus(cp), params)) {
setDataTimeout(60, params.br);
FaxModem::recvDCS(params); // announce session params
- return (TRUE);
+ return (true);
} else { // protocol botch
processHangup("72"); // XXX "COMREC error"
- return (FALSE);
+ return (false);
}
}
* and then collect the data. Return the
* received post-page-message.
*/
-fxBool
+bool
Class2Modem::recvPage(TIFF* tif, int& ppm, fxStr& emsg)
{
int ppr;
if (abortRequested()) {
// XXX no way to purge TIFF directory
emsg = "Receive aborted due to operator intervention";
- return (FALSE);
+ return (false);
}
// XXX deal with PRI interrupts
/*
recvResetPage(tif); // reset to overwrite data
tracePPR("RECV send", ppr);
if (ppr & 1) // page good, work complete
- return (TRUE);
+ return (true);
} while (!hostDidCQ || class2Cmd(ptsCmd, ppr));
bad:
if (hangupCode[0] == 0)
processHangup("90"); // "Unspecified Phase C error"
emsg = hangupCause(hangupCode);
- return (FALSE);
+ return (false);
}
void
/*
* Receive Phase C data using the Class 2 ``stream interface''.
*/
-fxBool
+bool
Class2Modem::recvPageData(TIFF* tif, fxStr& emsg)
{
if (flowControl == FLOW_XONXOFF)
* parameters indicate CQ checking is to be done.
*/
hostDidCQ = (modemCQ && BIT(params.df)) == 0 && checkQuality();
- fxBool pageRecvd = recvPageDLEData(tif, hostDidCQ, params, emsg);
+ bool pageRecvd = recvPageDLEData(tif, hostDidCQ, params, emsg);
// be careful about flushing here -- otherwise we lose +FPTS codes
if (flowControl == FLOW_XONXOFF)
return (pageRecvd);
}
-fxBool
+bool
Class2Modem::recvPPM(TIFF* tif, int& ppr)
{
for (;;) {
case AT_NOANSWER:
case AT_ERROR:
processHangup("50");
- return (FALSE);
+ return (false);
case AT_FPTS:
return parseFPTS(tif, skipStatus(rbuf), ppr);
case AT_FET:
protoTrace("MODEM protocol botch: +FET: without +FPTS:");
processHangup("100"); // "Unspecified Phase D error"
- return (FALSE);
+ return (false);
case AT_FHNG:
waitFor(AT_OK); // resynchronize modem
- return (FALSE);
+ return (false);
}
}
}
-fxBool
+bool
Class2Modem::parseFPTS(TIFF* tif, const char* cp, int& ppr)
{
int lc = 0;
TIFFSetField(tif, TIFFTAG_BADFAXLINES, (u_long) blc);
TIFFSetField(tif, TIFFTAG_CONSECUTIVEBADFAXLINES, cblc);
}
- return (TRUE);
+ return (true);
} else {
protoTrace("MODEM protocol botch: \"%s\"; can not parse line count",
cp);
processHangup("100"); // "Unspecified Phase D error"
- return (FALSE);
+ return (false);
}
}
/*
* Complete a receive session.
*/
-fxBool
+bool
Class2Modem::recvEnd(fxStr&)
{
if (!hadHangup) {
} else
(void) atCmd(abortCmd); // abort session
}
- return (TRUE);
+ return (true);
}
/*
* Send Protocol for Class-2-style modems.
*/
-fxBool
+bool
Class2Modem::sendSetup(FaxRequest& req, const Class2Params& dis, fxStr& emsg)
{
const char* cmdFailed = " (modem command failed)";
*/
if (req.passwd != "" && pwCmd != "" && !class2Cmd(pwCmd, req.passwd)) {
emsg = fxStr::format("Unable to send password%s", cmdFailed);
- return (FALSE);
+ return (false);
}
if (req.subaddr != "" && saCmd != "" && !class2Cmd(saCmd, req.subaddr)) {
emsg = fxStr::format("Unable to send subaddress%s", cmdFailed);
- return (FALSE);
+ return (false);
}
if (minsp != BR_2400 && !class2Cmd(minspCmd, minsp)) {
emsg = fxStr::format("Unable to restrict minimum transmit speed to %s",
Class2Params::bitRateNames[req.minsp], cmdFailed);
- return (FALSE);
+ return (false);
}
if (conf.class2DDISCmd != "") {
if (!class2Cmd(conf.class2DDISCmd, dis)) {
emsg = fxStr::format("Unable to setup session parameters "
"prior to call%s", cmdFailed);
- return (FALSE);
+ return (false);
}
params = dis;
}
- hadHangup = FALSE;
+ hadHangup = false;
return (FaxModem::sendSetup(req, dis, emsg));
}
* sent to the caller on connecting to a fax machine.
*/
FaxSendStatus
-Class2Modem::getPrologue(Class2Params& dis, fxBool& hasDoc, fxStr& emsg)
+Class2Modem::getPrologue(Class2Params& dis, bool& hasDoc, fxStr& emsg)
{
- fxBool gotParams = FALSE;
- hasDoc = FALSE;
+ bool gotParams = false;
+ hasDoc = false;
for (;;) {
switch (atResponse(rbuf, conf.t1Timer)) {
case AT_FPOLL:
- hasDoc = TRUE;
+ hasDoc = true;
protoTrace("REMOTE has document to POLL");
break;
case AT_FDIS:
* wait for an XON from the modem in response to the +FDT,
* before actually sending any data.
*/
-fxBool
+bool
Class2Modem::dataTransfer()
{
- fxBool status;
+ bool status;
if (xmitWaitForXON) {
/*
* Wait for XON (DC1) from the modem after receiving
return (status);
}
-static fxBool
+static bool
pageInfoChanged(const Class2Params& a, const Class2Params& b)
{
return (a.vr != b.vr || a.wd != b.wd || a.ln != b.ln || a.df != b.df || a.br != b.br);
setDataTimeout(60, next.br); // 60 seconds for 1024 byte writes
hangupCode[0] = '\0';
- fxBool transferOK;
- fxBool morePages = FALSE;
+ bool transferOK;
+ bool morePages = false;
do {
- transferOK = FALSE;
+ transferOK = false;
if (abortRequested())
goto failed;
/*
return (status);
}
}
- transferOK = TRUE;
+ transferOK = true;
break;
case PPR_RTN: // page bad, retrain requested
if (++ntrys >= 3) {
break;
}
next.br--;
- morePages = TRUE; // retransmit page
- transferOK = TRUE;
+ morePages = true; // retransmit page
+ transferOK = true;
break;
case PPR_PIN: // page bad, interrupt requested
emsg = "Unable to transmit page"
* +FHNG:0). Setup an error return so that the job will
* be retried.
*/
- transferOK = FALSE;
+ transferOK = false;
emsg = "Communication failure during Phase B/C (modem protocol botch)";
}
return (transferOK ? send_ok : send_retry);
* is done to avoid timing problems when the document
* is comprised of multiple strips.
*/
-fxBool
+bool
Class2Modem::sendPageData(TIFF* tif, u_int pageChop)
{
- fxBool rc = TRUE;
+ bool rc = true;
tstrip_t nstrips = TIFFNumberOfStrips(tif);
if (nstrips > 0) {
/*
* Setup tag line processing.
*/
- fxBool doTagLine = setupTagLineSlop(params);
+ bool doTagLine = setupTagLineSlop(params);
u_int ts = getTagLineSlop();
/*
* Calculate total amount of space needed to read
/*
* Send RTC to terminate a page.
*/
-fxBool
-Class2Modem::sendRTC(fxBool is2D)
+bool
+Class2Modem::sendRTC(bool is2D)
{
static const u_char RTC1D[9] =
{ 0x00,0x10,0x01,0x00,0x10,0x01,0x00,0x10,0x01 };
* Default methods for modem driver interface.
*/
-fxBool
+bool
ClassModem::dataService()
{
return atCmd(conf.class0Cmd);
/*
* Status messages to ignore when dialing.
*/
-fxBool
+bool
ClassModem::isNoise(const char* s)
{
static const char* noiseMsgs[] = {
for (u_int i = 0; i < NNOISE; i++)
if (strneq(s, noiseMsgs[i], strlen(noiseMsgs[i])))
- return (TRUE);
- return (FALSE);
+ return (true);
+ return (false);
}
#undef NNOISE
int ClassModem::getModemChar(long ms) { return server.getModemChar(ms); }
int ClassModem::getModemDataChar() { return server.getModemChar(dataTimeout); }
-fxBool
+bool
ClassModem::putModemDLEData(const u_char* data, u_int cc, const u_char* bitrev, long ms)
{
u_char dlebuf[2*1024];
while (cc > 0) {
if (wasTimeout() || abortRequested())
- return (FALSE);
+ return (false);
/*
* Copy to temp buffer, doubling DLE's.
*/
dlebuf[++j] = DLE;
}
if (!putModem(dlebuf, j, ms))
- return (FALSE);
+ return (false);
data += n;
cc -= n;
}
- return (TRUE);
+ return (true);
}
void ClassModem::flushModemInput()
{ server.modemFlushInput(); }
-fxBool ClassModem::putModem(void* d, int n, long ms)
+bool ClassModem::putModem(void* d, int n, long ms)
{ return server.putModem(d, n, ms); }
-fxBool ClassModem::putModemData(void* d, int n)
+bool ClassModem::putModemData(void* d, int n)
{ return server.putModem(d, n, dataTimeout); }
-fxBool
+bool
ClassModem::putModemLine(const char* cp)
{
u_int cc = strlen(cp);
/*
* Reset the modem and set the DTE-DCE rate.
*/
-fxBool
+bool
ClassModem::selectBaudRate(BaudRate br, FlowControl i, FlowControl o)
{
rate = br;
return (reset(5*1000) || reset(5*1000)); // NB: try at most twice
}
-fxBool ClassModem::sendBreak(fxBool pause)
+bool ClassModem::sendBreak(bool pause)
{ return server.sendBreak(pause); }
-fxBool
+bool
ClassModem::setBaudRate(BaudRate r)
{
if (server.setBaudRate(r)) {
if (conf.baudRateDelay)
pause(conf.baudRateDelay);
- return (TRUE);
+ return (true);
} else
- return (FALSE);
+ return (false);
}
-fxBool
+bool
ClassModem::setBaudRate(BaudRate r, FlowControl i, FlowControl o)
{
iFlow = i;
if (server.setBaudRate(r,i,o)) {
if (conf.baudRateDelay)
pause(conf.baudRateDelay);
- return (TRUE);
+ return (true);
} else
- return (FALSE);
+ return (false);
}
-fxBool
+bool
ClassModem::setXONXOFF(FlowControl i, FlowControl o, SetAction a)
{
iFlow = i;
return server.setXONXOFF(i, o, a);
}
-fxBool ClassModem::setDTR(fxBool onoff)
+bool ClassModem::setDTR(bool onoff)
{ return server.setDTR(onoff); }
-fxBool ClassModem::setInputBuffering(fxBool onoff)
+bool ClassModem::setInputBuffering(bool onoff)
{ return server.setInputBuffering(onoff); }
-fxBool ClassModem::modemStopOutput()
+bool ClassModem::modemStopOutput()
{ return server.modemStopOutput(); }
/*
* Miscellaneous server interfaces hooks.
*/
-fxBool ClassModem::abortRequested()
+bool ClassModem::abortRequested()
{ return server.abortRequested(); }
-void ClassModem::beginTimedTransfer() { server.timeout = FALSE; }
+void ClassModem::beginTimedTransfer() { server.timeout = false; }
void ClassModem::endTimedTransfer() {}
-fxBool ClassModem::wasTimeout() { return server.timeout; }
-void ClassModem::setTimeout(fxBool b) { server.timeout = b; }
+bool ClassModem::wasTimeout() { return server.timeout; }
+void ClassModem::setTimeout(bool b) { server.timeout = b; }
/*
* Parsing support routines.
/*
* Hayes-style modem manipulation support.
*/
-fxBool
+bool
ClassModem::reset(long ms)
{
- setDTR(FALSE);
+ setDTR(false);
pause(conf.resetDelay); // pause so modem can do reset
- setDTR(TRUE);
+ setDTR(true);
#ifndef CONFIG_NOREOPEN
/*
* On some systems lowering and raising DTR is not done
server.reopenDevice();
#endif
if (!setBaudRate(rate, iFlow, oFlow))
- return (FALSE);
+ return (false);
flushModemInput();
return atCmd(resetCmds, AT_OK, ms);
}
-fxBool
+bool
ClassModem::sync(long ms)
{
return waitFor(AT_OK, ms);
ATResponse
ClassModem::atResponse(char* buf, long ms)
{
- fxBool prevTimeout = wasTimeout();
+ bool prevTimeout = wasTimeout();
int n = getModemLine(buf, sizeof (rbuf), ms);
if (!prevTimeout && wasTimeout())
lastResponse = AT_TIMEOUT;
* changing the DCE-DTE communication rate and/or host-modem
* flow control scheme are also recognized and handled.
*/
-fxBool
+bool
ClassModem::atCmd(const fxStr& cmd, ATResponse r, long ms)
{
u_int cmdlen = cmd.length();
u_int pos = 0;
- fxBool respPending = FALSE;
+ bool respPending = false;
/*
* Scan string for line breaks and escape codes (byte w/ 0x80 set).
if (conf.atCmdDelay)
pause(conf.atCmdDelay);
if (!putModemLine(cmd.extract(pos, i-pos)))
- return (FALSE);
+ return (false);
pos = ++i; // next segment starts after line break
if (r != AT_NOTHING) {
if (!waitFor(r, ms))
- return (FALSE);
+ return (false);
} else {
if (!waitFor(AT_OK, ms))
- return (FALSE);
+ return (false);
}
- respPending = FALSE;
+ respPending = false;
} else if (isEscape(cmd[i])) {
/*
* Escape code; flush any partial line, process
* translated to \r).
*/
if (!putModemLine(cmd.extract(pos, i-1-pos)))
- return (FALSE);
+ return (false);
// setup for expected response
resp = (r != AT_NOTHING ? r : AT_OK);
} else {
const char* cp = &cmd[pos];
server.traceStatus(FAXTRACE_MODEMCOM, "<-- [%u:%s]", cc,cp);
if (!server.putModem1(cp, cc))
- return (FALSE);
+ return (false);
}
- respPending = TRUE;
+ respPending = true;
}
/*
* Process escape codes.
if (resp != AT_NOTHING) {
// XXX check return?
(void) waitFor(resp, ms); // XXX ms
- respPending = FALSE;
+ respPending = false;
}
break;
case ESC_FLUSH: // flush input
* does not get lost.
*/
if (resp != AT_NOTHING && !waitFor(resp, ms))
- return (FALSE);
- respPending = FALSE;
+ return (false);
+ respPending = false;
}
} else
i++;
if (conf.atCmdDelay)
pause(conf.atCmdDelay);
if (!putModemLine(cmd.extract(pos, i-pos)))
- return (FALSE);
- respPending = TRUE;
+ return (false);
+ respPending = true;
}
/*
* Wait for any pending response.
*/
if (respPending) {
if (r != AT_NOTHING && !waitFor(r, ms))
- return (FALSE);
+ return (false);
}
- return (TRUE);
+ return (true);
}
#undef isEscape
#undef isLineBreak
/*
* Wait (carefully) for some response from the modem.
*/
-fxBool
+bool
ClassModem::waitFor(ATResponse wanted, long ms)
{
for (;;) {
ATResponse response = atResponse(rbuf, ms);
if (response == wanted)
- return (TRUE);
+ return (true);
switch (response) {
case AT_TIMEOUT:
case AT_EMPTYLINE:
case AT_NOANSWER:
case AT_OFFHOOK:
modemTrace("MODEM %s", ATresponses[response]);
- return (FALSE);
+ return (false);
}
}
}
/*
* Process a manufacturer/model/revision query.
*/
-fxBool
+bool
ClassModem::doQuery(const fxStr& queryCmd, fxStr& result, long ms)
{
if (queryCmd == "")
- return (TRUE);
+ return (true);
if (queryCmd[0] == '!') {
/*
* ``!mumble'' is interpreted as "return mumble";
* this means that you can't send ! to the modem.
*/
result = queryCmd.tail(queryCmd.length()-1);
- return (TRUE);
+ return (true);
}
return (atQuery(queryCmd, result, ms));
}
/*
* Return modem manufacturer.
*/
-fxBool
+bool
ClassModem::setupManufacturer(fxStr& mfr)
{
return doQuery(mfrQueryCmd, mfr);
/*
* Return modem model identification.
*/
-fxBool
+bool
ClassModem::setupModel(fxStr& model)
{
return doQuery(modelQueryCmd, model);
/*
* Return modem firmware revision.
*/
-fxBool
+bool
ClassModem::setupRevision(fxStr& rev)
{
return doQuery(revQueryCmd, rev);
/*
* Send AT<what>? and get a string response.
*/
-fxBool
+bool
ClassModem::atQuery(const char* what, fxStr& v, long ms)
{
ATResponse r = AT_ERROR;
/*
* Send AT<what>? and get a range response.
*/
-fxBool
+bool
ClassModem::atQuery(const char* what, u_int& v, long ms)
{
char response[1024];
sync(ms);
return parseRange(response, v);
}
- return (FALSE);
+ return (false);
}
/*
* in the parsed range so that modems like the ZyXEL 2864
* that indicate they support ``Class Z'' are handled.
*/
-fxBool
+bool
ClassModem::vparseRange(const char* cp, int nargs ... )
{
- fxBool b = TRUE;
+ bool b = true;
va_list ap;
va_start(ap, nargs);
while (nargs-- > 0) {
while (cp[0] == SPACE)
cp++;
char matchc;
- fxBool acceptList;
+ bool acceptList;
if (cp[0] == OPAREN) { // (<items>)
matchc = CPAREN;
- acceptList = TRUE;
+ acceptList = true;
cp++;
} else if (isalnum(cp[0])) { // <item>
matchc = COMMA;
acceptList = (nargs == 0);
} else { // skip to comma
- b = FALSE;
+ b = false;
break;
}
int mask = 0;
continue;
}
if (!isalnum(cp[0])) {
- b = FALSE;
+ b = false;
goto done;
}
int v;
if (cp[0] == '-') { // <low>-<high>
cp++;
if (!isdigit(cp[0])) {
- b = FALSE;
+ b = false;
goto done;
}
r = 0;
* Parse a single Class X range specification
* and return the resulting bit mask.
*/
-fxBool
+bool
ClassModem::parseRange(const char* cp, u_int& a0)
{
return vparseRange(cp, 1, &a0);
atCmd(conf.onHookCmd, AT_OK, 5000);
}
-fxBool
+bool
ClassModem::waitForRings(u_int n, CallType& type, CallerID& cinfo)
{
if (n > 0) {
case AT_NOCARRIER:
case AT_NODIALTONE:
case AT_ERROR:
- return (FALSE);
+ return (false);
}
} while (n > 0 && Sys::now()-start < timeout);
}
ClassModem(ModemServer&, const ModemConfig&);
// setup and configuration
- virtual fxBool selectBaudRate(BaudRate max, FlowControl i, FlowControl o);
- virtual fxBool setupManufacturer(fxStr& mfr);
- virtual fxBool setupModel(fxStr& model);
- virtual fxBool setupRevision(fxStr& rev);
+ virtual bool selectBaudRate(BaudRate max, FlowControl i, FlowControl o);
+ virtual bool setupManufacturer(fxStr& mfr);
+ virtual bool setupModel(fxStr& model);
+ virtual bool setupRevision(fxStr& rev);
- fxBool doQuery(const fxStr& queryCmd, fxStr& result, long ms = 30*1000);
+ bool doQuery(const fxStr& queryCmd, fxStr& result, long ms = 30*1000);
// dial/answer interactions with derived classes
virtual const AnswerMsg* findAnswer(const char* s);
virtual CallType answerResponse(fxStr& emsg);
virtual CallStatus dialResponse(fxStr& emsg) = 0;
- virtual fxBool isNoise(const char*);
+ virtual bool isNoise(const char*);
// miscellaneous
void modemSupports(const char* fmt, ...);
void modemCapability(const char* fmt, ...);
public:
virtual ~ClassModem();
- virtual fxBool setupModem() = 0;
- virtual fxBool isFaxModem() const = 0; // XXX safe to cast
+ virtual bool setupModem() = 0;
+ virtual bool isFaxModem() const = 0; // XXX safe to cast
- virtual fxBool sync(long ms = 0); // synchronize (wait for "OK")
- virtual fxBool reset(long ms = 5*1000); // reset modem state
+ virtual bool sync(long ms = 0); // synchronize (wait for "OK")
+ virtual bool reset(long ms = 5*1000); // reset modem state
virtual void hangup(); // hangup the phone
// configuration controls
// support to write to modem w/ timeout
void beginTimedTransfer();
void endTimedTransfer();
- fxBool wasTimeout();
- void setTimeout(fxBool);
+ bool wasTimeout();
+ void setTimeout(bool);
void flushModemInput();
- fxBool putModem(void* data, int n, long ms = 0);
- fxBool putModemData(void* data, int n);
- fxBool putModemDLEData(const u_char* data, u_int,
+ bool putModem(void* data, int n, long ms = 0);
+ bool putModemData(void* data, int n);
+ bool putModemDLEData(const u_char* data, u_int,
const u_char* brev, long ms);
- fxBool putModemLine(const char* cp);
+ bool putModemLine(const char* cp);
int getModemChar(long ms = 0);
int getModemDataChar();
void startTimeout(long ms);
void stopTimeout(const char* whichdir);
// host-modem protocol parsing support
virtual ATResponse atResponse(char* buf, long ms = 30*1000);
- fxBool waitFor(ATResponse wanted, long ms = 30*1000);
- fxBool atCmd(const fxStr& cmd, ATResponse = AT_OK, long ms = 30*1000);
- fxBool atQuery(const char* what, fxStr& v, long ms = 30*1000);
- fxBool atQuery(const char* what, u_int& v, long ms = 30*1000);
- fxBool parseRange(const char*, u_int&);
- fxBool vparseRange(const char*, int nargs ...);
+ bool waitFor(ATResponse wanted, long ms = 30*1000);
+ bool atCmd(const fxStr& cmd, ATResponse = AT_OK, long ms = 30*1000);
+ bool atQuery(const char* what, fxStr& v, long ms = 30*1000);
+ bool atQuery(const char* what, u_int& v, long ms = 30*1000);
+ bool parseRange(const char*, u_int&);
+ bool vparseRange(const char*, int nargs ...);
// modem line control
- fxBool sendBreak(fxBool pause);
- fxBool setBaudRate(BaudRate rate);
- fxBool setBaudRate(BaudRate rate, FlowControl i, FlowControl o);
- fxBool setXONXOFF(FlowControl i, FlowControl o, SetAction);
- fxBool setDTR(fxBool on);
- fxBool setInputBuffering(fxBool on);
- fxBool modemStopOutput();
+ bool sendBreak(bool pause);
+ bool setBaudRate(BaudRate rate);
+ bool setBaudRate(BaudRate rate, FlowControl i, FlowControl o);
+ bool setXONXOFF(FlowControl i, FlowControl o, SetAction);
+ bool setDTR(bool on);
+ bool setInputBuffering(bool on);
+ bool modemStopOutput();
FlowControl getInputFlow();
FlowControl getOutputFlow();
// server-related stuff
- fxBool abortRequested();
+ bool abortRequested();
/*
* Send support:
* }
* hangup();
*/
- virtual fxBool dataService();
+ virtual bool dataService();
virtual CallStatus dial(const char* number, fxStr& emsg);
/*
* with recvAbort available to abort a receive
* at any time in this procedure.
*/
- virtual fxBool waitForRings(u_int rings, CallType&, CallerID&);
+ virtual bool waitForRings(u_int rings, CallType&, CallerID&);
virtual CallType answerCall(AnswerType, fxStr& emsg);
virtual void answerCallCmd(CallType);
};
* Receive Phase C data with or without copy
* quality checking and erroneous row fixup.
*/
-fxBool
-FaxModem::recvPageDLEData(TIFF* tif, fxBool checkQuality,
+bool
+FaxModem::recvPageDLEData(TIFF* tif, bool checkQuality,
const Class2Params& params, fxStr& emsg)
{
setupDecoder(conf.recvFillOrder, params.is2D());
abortPageRecv();
emsg = "Missing EOL after 5 seconds";
recvTrace("%s", (const char*) emsg);
- return (FALSE);
+ return (false);
}
if (checkQuality) {
/*
u_char* curGood = buf; // last good row
memset(curGood, 0, rowSize); // initialize to all white
recvBuf = NULL; // don't need raw data
- lastRowBad = FALSE; // no previous row
+ lastRowBad = false; // no previous row
cblc = 0; // current bad line run
if (!RTCraised()) {
for (;;) {
* later for deciding whether or not the page quality
* is acceptable.
*/
- fxBool decodeOK = decodeRow(recvRow, rowpixels);
+ bool decodeOK = decodeRow(recvRow, rowpixels);
if (seenRTC()) // seen RTC, flush everything
continue;
if (decodeOK) {
curGood = recvRow; // reset last good
if (lastRowBad) { // reset run statistics
- lastRowBad = FALSE;
+ lastRowBad = false;
if (cblc > recvConsecutiveBadLineCount)
recvConsecutiveBadLineCount = cblc;
cblc = 0;
memcpy(recvRow, curGood, rowSize);// replicate last good
recvBadLineCount++;
cblc++;
- lastRowBad = TRUE;
+ lastRowBad = true;
}
/*
* Advance forward a scanline and if necessary
TIFFSetField(tif, TIFFTAG_FAXRECVTIME,
(uint32) server.getPageTransferTime());
#endif
- return (TRUE);
+ return (true);
}
/*
* Check if the configuration parameters indicate if
* copy quality checking should be done on recvd pages.
*/
-fxBool
+bool
FaxModem::checkQuality()
{
return (conf.percentGoodLines != 0 && conf.maxConsecutiveBadLines != 0);
* against the configuration parameters and return an
* indication of whether or not the page quality is acceptable.
*/
-fxBool
+bool
FaxModem::isQualityOK(const Class2Params& params)
{
if (conf.percentGoodLines != 0 && recvEOLCount != 0) {
if (percent < conf.percentGoodLines) {
serverTrace("RECV: REJECT page quality, %u%% good lines (%u%% required)",
percent, conf.percentGoodLines);
- return (FALSE);
+ return (false);
}
}
u_int cblc = conf.maxConsecutiveBadLines;
if (recvConsecutiveBadLineCount > cblc) {
serverTrace("RECV: REJECT page quality, %u-line run (max %u)",
recvConsecutiveBadLineCount, cblc);
- return (FALSE);
+ return (false);
}
}
- return (TRUE);
+ return (true);
}
/*
}
}
-fxBool
+bool
DestControl::readLine(FILE* fp, char line[], u_int cc)
{
if (fgets(line, cc, fp) == NULL)
- return (FALSE);
+ return (false);
lineno++;
char* cp;
if (cp = strchr(line, '#'))
*cp = '\0';
if (cp = strchr(line, '\n'))
*cp = '\0';
- return (TRUE);
+ return (true);
}
-static fxBool
+static bool
isContinued(FILE* fp)
{
int c = getc(fp);
if (c == EOF)
- return (FALSE);
+ return (false);
ungetc(c, fp);
return (isspace(c) || c == '#');
}
s.resize(cp - (char*) s);
}
-fxBool
+bool
DestControl::parseEntry(FILE* fp)
{
char line[1024];
for (;;) {
if (!readLine(fp, line, sizeof (line)-1))
- return (FALSE);
+ return (false);
char* cp;
for (cp = line; *cp && !isspace(*cp); cp++)
;
if (cp == line) {
parseError("Missing regular expression.");
skipEntry(fp, line, sizeof (line)-1);
- return (TRUE);
+ return (true);
}
*cp++ = '\0';
DestControlInfo dci(line);
re.getError(emsg);
parseError("Bad regular expression: %s: " | emsg, re.pattern());
skipEntry(fp, line, sizeof (line)-1);
- return (TRUE);
+ return (true);
}
for (;;) {
while (isspace(*cp))
crackArgv(dci.args);
if (!isContinued(fp)) {
info.append(dci);
- return (TRUE);
+ return (true);
}
if (!readLine(fp, line, sizeof (line)-1)) {
info.append(dci);
- return (FALSE);
+ return (false);
}
cp = line;
continue; // go back and skip whitespace
DestControlInfoArray info; // control information
void readContents();
- fxBool parseEntry(FILE* fp);
- fxBool readLine(FILE* fp, char line[], u_int cc);
+ bool parseEntry(FILE* fp);
+ bool readLine(FILE* fp, char line[], u_int cc);
void skipEntry(FILE*, char line[], u_int cc);
void parseError(const char* fmt ...);
public:
info.writeConfig(); // update as necessary
}
-fxBool
+bool
DestInfo::isActive(Job& job) const
{
if (running == NULL)
- return (FALSE);
+ return (false);
else if (running == &job)
- return (TRUE);
+ return (true);
else {
for (Job* jp = running->dnext; jp != NULL; jp = jp->dnext)
if (jp == &job)
- return (TRUE);
- return (FALSE);
+ return (true);
+ return (false);
}
}
u_int getActive() const; // return count of active jobs
u_int getCount() const; // return count of active+blocked jobs
- fxBool isEmpty() const; // TRUE if any jobs referenced
+ bool isEmpty() const; // true if any jobs referenced
- fxBool isActive(Job&) const; // TRUE if job is considered active
+ bool isActive(Job&) const; // true if job is considered active
void active(Job&); // set job active to destination
void done(Job&); // remove job from active set
void block(Job&); // add job to blocked queue
inline u_int DestInfo::getActive() const { return activeCount; }
inline u_int DestInfo::getCount() const
{ return activeCount + blockedCount; }
-inline fxBool DestInfo::isEmpty() const { return getCount() == 0; }
+inline bool DestInfo::isEmpty() const { return getCount() == 0; }
fxDECLARE_StrKeyDictionary(DestInfoDict, DestInfo)
#endif /* _DestInfo_ */
/*
* Record an activity in the transfer log file.
*/
-fxBool
+bool
FaxAcctInfo::record(const char* cmd) const
{
- fxBool ok = FALSE;
+ bool ok = false;
int fd = Sys::open(FAX_XFERLOG, O_RDWR|O_CREAT|O_APPEND, 0644);
if (fd >= 0) {
fxStackBuffer record;
u_int params; // encoded transfer parameters
const char* status; // status info (optional)
- fxBool record(const char* cmd) const;
+ bool record(const char* cmd) const;
};
#endif /* _FaxAcctInfo_ */
FaxFont::FaxFont()
{
- ready = FALSE; // font not ready for use
+ ready = false; // font not ready for use
fontAscent = fontDescent = 0;
}
class FaxFont {
protected:
- fxBool ready; // font ready to use
+ bool ready; // font ready to use
short fontAscent; // font ascent metric
short fontDescent; // font descent metric
public:
virtual ~FaxFont();
- virtual fxBool read(const char* filename) = 0;
+ virtual bool read(const char* filename) = 0;
- fxBool isReady() const;
+ bool isReady() const;
u_int fontHeight() const;
virtual u_int charWidth(u_int) const = 0;
virtual void strWidth(const char* text, u_int& w, u_int& h) const = 0;
virtual void print(FILE*) const = 0;
};
-inline fxBool FaxFont::isReady() const { return ready; }
+inline bool FaxFont::isReady() const { return ready; }
inline u_int FaxFont::fontHeight() const { return fontAscent+fontDescent; }
#endif /* _Font_ */
FaxMachineInfo::FaxMachineInfo()
{
- changed = FALSE;
+ changed = false;
resetConfig();
}
FaxMachineInfo::FaxMachineInfo(const FaxMachineInfo& other)
#include <ctype.h>
-fxBool
+bool
FaxMachineInfo::updateConfig(const fxStr& number)
{
fxStr canon(number);
void
FaxMachineInfo::resetConfig()
{
- supportsHighRes = TRUE; // assume 196 lpi support
- supports2DEncoding = TRUE; // assume 2D-encoding support
- supportsPostScript = FALSE; // no support for Adobe protocol
- calledBefore = FALSE; // never called before
+ supportsHighRes = true; // assume 196 lpi support
+ supports2DEncoding = true; // assume 2D-encoding support
+ supportsPostScript = false; // no support for Adobe protocol
+ calledBefore = false; // never called before
maxPageWidth = 2432; // max required width
maxPageLength = -1; // infinite page length
maxSignallingRate = BR_14400; // T.17 14.4KB
#define setLocked(b,ix) locked |= b<<ix
-fxBool
+bool
FaxMachineInfo::setConfigItem(const char* tag, const char* value)
{
int b = (tag[0] == '&' ? 1 : 0); // locked down indicator
} else if (streq(tag, "pagersetupcmds")) {
pagerSetupCmds = value;
} else
- return (FALSE);
- return (TRUE);
+ return (false);
+ return (true);
}
#define isLocked(b) (locked & (1<<b))
#define checkLock(ix, member, value) \
if (!isLocked(ix)) { \
member = value; \
- changed = TRUE; \
+ changed = true; \
}
-void FaxMachineInfo::setSupportsHighRes(fxBool b)
+void FaxMachineInfo::setSupportsHighRes(bool b)
{ checkLock(HIRES, supportsHighRes, b); }
-void FaxMachineInfo::setSupports2DEncoding(fxBool b)
+void FaxMachineInfo::setSupports2DEncoding(bool b)
{ checkLock(G32D, supports2DEncoding, b); }
-void FaxMachineInfo::setSupportsPostScript(fxBool b)
+void FaxMachineInfo::setSupportsPostScript(bool b)
{ checkLock(PS, supportsPostScript, b); }
void FaxMachineInfo::setMaxPageWidthInPixels(int v)
{ checkLock(WD, maxPageWidth, v); }
{ checkLock(ST, minScanlineTime, v); }
void
-FaxMachineInfo::setCalledBefore(fxBool b)
+FaxMachineInfo::setCalledBefore(bool b)
{
calledBefore = b;
- changed = TRUE;
+ changed = true;
}
#define checkChanged(member, value) \
if (member != value) { \
member = value; \
- changed = TRUE; \
+ changed = true; \
}
void FaxMachineInfo::setCSI(const fxStr& v)
Sys::close(fd);
} else
error("open: %m");
- changed = FALSE;
+ changed = false;
}
}
static void
-putBoolean(fxStackBuffer& buf, const char* tag, fxBool locked, fxBool b)
+putBoolean(fxStackBuffer& buf, const char* tag, bool locked, bool b)
{
buf.fput("%s%s:%s\n", locked ? "&" : "", tag, b ? "yes" : "no");
}
static void
-putDecimal(fxStackBuffer& buf, const char* tag, fxBool locked, int v)
+putDecimal(fxStackBuffer& buf, const char* tag, bool locked, int v)
{
buf.fput("%s%s:%d\n", locked ? "&" : "", tag, v);
}
static void
-putString(fxStackBuffer& buf, const char* tag, fxBool locked, const char* v)
+putString(fxStackBuffer& buf, const char* tag, bool locked, const char* v)
{
buf.fput("%s%s:\"%s\"\n", locked ? "&" : "", tag, v);
}
static void
-putIfString(fxStackBuffer& buf, const char* tag, fxBool locked, const char* v)
+putIfString(fxStackBuffer& buf, const char* tag, bool locked, const char* v)
{
if (*v != '\0')
buf.fput("%s%s:\"%s\"\n", locked ? "&" : "", tag, v);
putBoolean(buf, "supportsHighRes", isLocked(HIRES), supportsHighRes);
putBoolean(buf, "supports2DEncoding", isLocked(G32D),supports2DEncoding);
putBoolean(buf, "supportsPostScript", isLocked(PS), supportsPostScript);
- putBoolean(buf, "calledBefore", FALSE, calledBefore);
+ putBoolean(buf, "calledBefore", false, calledBefore);
putDecimal(buf, "maxPageWidth", isLocked(WD), maxPageWidth);
putDecimal(buf, "maxPageLength", isLocked(LN), maxPageLength);
putString(buf, "maxSignallingRate", isLocked(BR),
brnames[fxmin(maxSignallingRate, BR_14400)]);
putString(buf, "minScanlineTime", isLocked(ST),
stnames[fxmin(minScanlineTime, ST_40MS)]);
- putString(buf, "remoteCSI", FALSE, csi);
- putDecimal(buf, "sendFailures", FALSE, sendFailures);
- putIfString(buf, "lastSendFailure", FALSE, lastSendFailure);
- putDecimal(buf, "dialFailures", FALSE, dialFailures);
- putIfString(buf, "lastDialFailure", FALSE, lastDialFailure);
+ putString(buf, "remoteCSI", false, csi);
+ putDecimal(buf, "sendFailures", false, sendFailures);
+ putIfString(buf, "lastSendFailure", false, lastSendFailure);
+ putDecimal(buf, "dialFailures", false, dialFailures);
+ putIfString(buf, "lastDialFailure", false, lastDialFailure);
if (pagerMaxMsgLength != (u_int) -1)
- putDecimal(buf, "pagerMaxMsgLength", TRUE, pagerMaxMsgLength);
- putIfString(buf, "pagerPassword", TRUE, pagerPassword);
- putIfString(buf, "pagerTTYParity", TRUE, pagerTTYParity);
- putIfString(buf, "pagingProtocol", TRUE, pagingProtocol);
- putIfString(buf, "pageSource", TRUE, pageSource);
- putIfString(buf, "pagerSetupCmds", TRUE, pagerSetupCmds);
+ putDecimal(buf, "pagerMaxMsgLength", true, pagerMaxMsgLength);
+ putIfString(buf, "pagerPassword", true, pagerPassword);
+ putIfString(buf, "pagerTTYParity", true, pagerTTYParity);
+ putIfString(buf, "pagingProtocol", true, pagingProtocol);
+ putIfString(buf, "pageSource", true, pageSource);
+ putIfString(buf, "pagerSetupCmds", true, pagerSetupCmds);
}
private:
fxStr file; // pathname to info file
u_int locked; // bit vector of locked items
- fxBool changed; // changed since restore
- fxBool supportsHighRes; // capable of 7.7 line/mm vres
- fxBool supports2DEncoding; // handles Group 3 2D
- fxBool supportsPostScript; // handles Adobe NSF protocol
- fxBool calledBefore; // successfully called before
+ bool changed; // changed since restore
+ bool supportsHighRes; // capable of 7.7 line/mm vres
+ bool supports2DEncoding; // handles Group 3 2D
+ bool supportsPostScript; // handles Adobe NSF protocol
+ bool calledBefore; // successfully called before
int maxPageWidth; // max capable page width
int maxPageLength; // max capable page length
int maxSignallingRate; // max capable signalling rate
void writeConfig(fxStackBuffer&);
- fxBool setConfigItem(const char* tag, const char* value);
+ bool setConfigItem(const char* tag, const char* value);
void vconfigError(const char* fmt0, va_list ap);
void configError(const char* fmt0 ...);
void configTrace(const char* fmt0 ...);
FaxMachineInfo(const FaxMachineInfo& other);
virtual ~FaxMachineInfo();
- virtual fxBool updateConfig(const fxStr& filename);
+ virtual bool updateConfig(const fxStr& filename);
virtual void writeConfig();
virtual void resetConfig();
- fxBool getSupportsHighRes() const;
- fxBool getSupports2DEncoding() const;
- fxBool getSupportsPostScript() const;
- fxBool getCalledBefore() const;
+ bool getSupportsHighRes() const;
+ bool getSupports2DEncoding() const;
+ bool getSupportsPostScript() const;
+ bool getCalledBefore() const;
int getMaxPageWidthInPixels() const;
int getMaxPageWidthInMM() const;
int getMaxPageLengthInMM() const;
const fxStr& getLastSendFailure() const;
const fxStr& getLastDialFailure() const;
- void setSupportsHighRes(fxBool);
- void setSupports2DEncoding(fxBool);
- void setSupportsPostScript(fxBool);
- void setCalledBefore(fxBool);
+ void setSupportsHighRes(bool);
+ void setSupports2DEncoding(bool);
+ void setSupportsPostScript(bool);
+ void setCalledBefore(bool);
void setMaxPageWidthInPixels(int);
void setMaxPageLengthInMM(int);
void setMaxSignallingRate(int);
const fxStr& getPagerSetupCmds() const;
};
-inline fxBool FaxMachineInfo::getSupportsHighRes() const
+inline bool FaxMachineInfo::getSupportsHighRes() const
{ return supportsHighRes; }
-inline fxBool FaxMachineInfo::getSupports2DEncoding() const
+inline bool FaxMachineInfo::getSupports2DEncoding() const
{ return supports2DEncoding; }
-inline fxBool FaxMachineInfo::getSupportsPostScript() const
+inline bool FaxMachineInfo::getSupportsPostScript() const
{ return supportsPostScript; }
-inline fxBool FaxMachineInfo::getCalledBefore() const
+inline bool FaxMachineInfo::getCalledBefore() const
{ return calledBefore; }
inline int FaxMachineInfo::getMaxPageWidthInPixels() const
{ return maxPageWidth; }
/*
* Do setup work prior to placing the call.
*/
-fxBool
+bool
FaxModem::sendSetup(FaxRequest& req, const Class2Params&, fxStr&)
{
minsp = fxmax((u_int) req.minsp, conf.minSpeed);
else
setupTagLine(req, req.tagline);
curreq = &req;
- return (TRUE);
+ return (true);
}
/*
* Do work at the beginning of a send operation;
void FaxModem::sendSetupPhaseB(const fxStr&, const fxStr&){}
void FaxModem::sendEnd() {}
-fxBool
+bool
FaxModem::recvBegin(fxStr&)
{
optFrames = 0;
- return (TRUE);
+ return (true);
}
-fxBool
+bool
FaxModem::pollBegin(const fxStr&, const fxStr&, const fxStr&, fxStr&)
{
optFrames = 0;
- return (TRUE);
+ return (true);
}
static void
protoTrace("REMOTE CSI \"%s\"", (const char*) tsi);
optFrames |= 0x1;
}
-fxBool
+bool
FaxModem::getRecvTSI(fxStr& s)
{
if (optFrames & 0x1) {
s = tsi;
- return (TRUE);
+ return (true);
} else
- return (FALSE);
+ return (false);
}
-fxBool FaxModem::getSendCSI(fxStr& s) { return getRecvTSI(s); }
+bool FaxModem::getSendCSI(fxStr& s) { return getRecvTSI(s); }
void
FaxModem::recvPWD(const fxStr& s)
protoTrace("REMOTE PWD \"%s\"", (const char*) pwd);
optFrames |= 0x2;
}
-fxBool
+bool
FaxModem::getRecvPWD(fxStr& s)
{
if (optFrames & 0x2) {
s = pwd;
- return (TRUE);
+ return (true);
} else
- return (FALSE);
+ return (false);
}
void
FaxModem::recvSUB(const fxStr& s)
protoTrace("REMOTE SUB \"%s\"", (const char*) sub);
optFrames |= 0x4;
}
-fxBool
+bool
FaxModem::getRecvSUB(fxStr& s)
{
if (optFrames & 0x4) {
s = sub;
- return (TRUE);
+ return (true);
} else
- return (FALSE);
+ return (false);
}
void
FaxModem::recvNSF(const fxStr& s)
nsf = s;
protoTrace("REMOTE NSF \"%s\"", (const char*) nsf);
}
-fxBool
+bool
FaxModem::getSendNSF(fxStr& s)
{
if (optFrames & 0x8) {
s = nsf;
- return (TRUE);
+ return (true);
} else
- return (FALSE);
+ return (false);
}
void
* the next page. See FaxServer::sendPrepareFax for the
* construction of this string.
*/
-fxBool
+bool
FaxModem::decodePPM(const fxStr& pph, u_int& ppm, fxStr& emsg)
{
const char* what;
if (pph.length() >= 3 && (pph[2] != 'Z' || pph.length() >= 2+5+1)) {
switch (pph[pph[2] == 'Z' ? 2+5 : 2+0]) {
- case 'P': ppm = PPM_EOP; return (TRUE);
- case 'M': ppm = PPM_EOM; return (TRUE);
- case 'S': ppm = PPM_MPS; return (TRUE);
+ case 'P': ppm = PPM_EOP; return (true);
+ case 'M': ppm = PPM_EOM; return (true);
+ case 'S': ppm = PPM_MPS; return (true);
}
what = "unknown";
} else
what = "bad";
emsg = fxStr::format( "Internal botch; %s post-page handling string \"%s\"",
what, (const char*) pph);
- return (FALSE);
+ return (false);
}
/*
/*
* Return whether or not the modem supports 2DMR.
*/
-fxBool
+bool
FaxModem::supports2D() const
{
return (modemParams.df & BIT(DF_2DMR)) != 0;
/*
* Return whether or not received EOLs are byte aligned.
*/
-fxBool
+bool
FaxModem::supportsEOLPadding() const
{
- return FALSE;
+ return false;
}
/*
* Return whether or not the modem is capable of polling.
*/
-fxBool
+bool
FaxModem::supportsPolling() const
{
- return FALSE;
+ return false;
}
/*
* Return whether or not the modem supports
* the optional Error Correction Mode (ECM).
*/
-fxBool
+bool
FaxModem::supportsECM() const
{
return (modemParams.ec &~ BIT(EC_DISABLE)) != 0;
* problems and general sloppiness on the part of
* applications writing TIFF files.
*/
-fxBool
+bool
FaxModem::supportsVRes(float res) const
{
if (3.0 <= res && res < 4.75)
else if (5.9 <= res && res < 9.8)
return (modemParams.vr & BIT(VR_FINE)) != 0;
else
- return FALSE;
+ return false;
}
/*
* Return whether or not the modem supports the
* specified page width.
*/
-fxBool
+bool
FaxModem::supportsPageWidth(u_int w) const
{
switch (w) {
case 1216: return (modemParams.wd & BIT(WD_1216)) != 0;
case 864: return (modemParams.wd & BIT(WD_864)) != 0;
}
- return FALSE;
+ return false;
}
/*
* specified page length. As above for vertical
* resolution we're lenient in what we accept.
*/
-fxBool
+bool
FaxModem::supportsPageLength(u_int l) const
{
// XXX probably need to be more forgiving with values
/*
* Miscellaneous server interfaces hooks.
*/
-fxBool FaxModem::isFaxModem() const { return TRUE; }
+bool FaxModem::isFaxModem() const { return true; }
-fxBool FaxModem::getHDLCTracing()
+bool FaxModem::getHDLCTracing()
{ return (server.getSessionTracing() & FAXTRACE_HDLC) != 0; }
FaxSendStatus
void setupTagLine(const FaxRequest&, const fxStr& tagLineFmt);
// phase c data receive & copy quality checking
u_int cblc; // current count of consecutive bad lines
- fxBool lastRowBad; // last decoded row was bad
+ bool lastRowBad; // last decoded row was bad
u_long recvEOLCount; // EOL count for received page
u_long recvBadLineCount;
void tracePPR(const char* dir, u_int ppr);
void tracePPM(const char* dir, u_int ppm);
// server-related stuff
- fxBool getHDLCTracing();
+ bool getHDLCTracing();
FaxSendStatus sendSetupParams(TIFF*, Class2Params&,
FaxMachineInfo&, fxStr&);
void recvTSI(const fxStr&);
void recvStartPage(TIFF* tif);
void recvResetPage(TIFF* tif);
u_int decodePageChop(const fxStr& pph, const Class2Params&);
- fxBool decodePPM(const fxStr& pph, u_int& ppm, fxStr& emsg);
+ bool decodePPM(const fxStr& pph, u_int& ppm, fxStr& emsg);
void notifyPageSent(TIFF*);
// phase c data receive & copy quality checking
- fxBool recvPageDLEData(TIFF* tif, fxBool checkQuality,
+ bool recvPageDLEData(TIFF* tif, bool checkQuality,
const Class2Params& params, fxStr& emsg);
virtual void abortPageRecv() = 0;
virtual int nextByte();
- fxBool checkQuality();
- fxBool isQualityOK(const Class2Params&);
+ bool checkQuality();
+ bool isQualityOK(const Class2Params&);
u_long getRecvEOLCount() const;
u_long getRecvBadLineCount() const;
u_long getRecvConsecutiveBadLineCount() const;
// tag line support
- fxBool setupTagLineSlop(const Class2Params&);
+ bool setupTagLineSlop(const Class2Params&);
u_int getTagLineSlop() const;
u_char* imageTagLine(u_char* buf, u_int fillorder, const Class2Params&);
public:
virtual ~FaxModem();
- fxBool isFaxModem() const;
+ bool isFaxModem() const;
// configuration controls
virtual void setLID(const fxStr& number) = 0;
u_int getCapabilities() const;
// methods for querying modem capabilities
- virtual fxBool supports2D() const;
- virtual fxBool supportsEOLPadding() const;
- virtual fxBool supportsVRes(float res) const;
- virtual fxBool supportsPageWidth(u_int w) const;
- virtual fxBool supportsPageLength(u_int l) const;
- virtual fxBool supportsPolling() const;
- virtual fxBool supportsECM() const;
+ virtual bool supports2D() const;
+ virtual bool supportsEOLPadding() const;
+ virtual bool supportsVRes(float res) const;
+ virtual bool supportsPageWidth(u_int w) const;
+ virtual bool supportsPageLength(u_int l) const;
+ virtual bool supportsPolling() const;
+ virtual bool supportsECM() const;
virtual int selectSignallingRate(int br) const;
u_int getBestSignallingRate() const;
* for doing things like keeping cover pages & documents in a
* single T.30 document.
*/
- virtual fxBool faxService() = 0;
- virtual fxBool sendSetup(FaxRequest&, const Class2Params& dis, fxStr& emsg);
+ virtual bool faxService() = 0;
+ virtual bool sendSetup(FaxRequest&, const Class2Params& dis, fxStr& emsg);
virtual void sendBegin();
virtual FaxSendStatus getPrologue(Class2Params&,
- fxBool& hasDoc, fxStr& emsg) = 0;
+ bool& hasDoc, fxStr& emsg) = 0;
virtual void sendSetupPhaseB(const fxStr& pwd, const fxStr& sub);
virtual FaxSendStatus sendPhaseB(TIFF*, Class2Params&, FaxMachineInfo&,
fxStr& pph, fxStr& emsg) = 0;
virtual void sendEnd();
virtual void sendAbort() = 0;
// query interfaces for optional state
- virtual fxBool getSendCSI(fxStr&);
- virtual fxBool getSendNSF(fxStr&);
+ virtual bool getSendCSI(fxStr&);
+ virtual bool getSendNSF(fxStr&);
/*
* Fax receive protocol. The expected sequence is:
* }
* }
*/
- virtual fxBool setupReceive() = 0;
- virtual fxBool recvBegin(fxStr& emsg);
- virtual fxBool recvPage(TIFF*, int& ppm, fxStr& em) = 0;
- virtual fxBool recvEnd(fxStr& emsg) = 0;
+ virtual bool setupReceive() = 0;
+ virtual bool recvBegin(fxStr& emsg);
+ virtual bool recvPage(TIFF*, int& ppm, fxStr& em) = 0;
+ virtual bool recvEnd(fxStr& emsg) = 0;
virtual void recvAbort() = 0;
// query interfaces for optional state
- virtual fxBool getRecvPWD(fxStr&);
- virtual fxBool getRecvTSI(fxStr&);
- virtual fxBool getRecvSUB(fxStr&);
+ virtual bool getRecvPWD(fxStr&);
+ virtual bool getRecvTSI(fxStr&);
+ virtual bool getRecvSUB(fxStr&);
virtual const Class2Params& getRecvParams() const;
/*
*
* (i.e. it's just like a receive operation.)
*/
- virtual fxBool requestToPoll(fxStr& emsg) = 0;
- virtual fxBool pollBegin(
+ virtual bool requestToPoll(fxStr& emsg) = 0;
+ virtual bool pollBegin(
const fxStr& cig, const fxStr& sep, const fxStr& pwd,
fxStr& emsg);
};
/*
* Initiate a polling receive and invoke the receiving protocol.
*/
-fxBool
+bool
FaxServer::pollFaxPhaseB(const fxStr& sep, const fxStr& pwd, FaxRecvInfoArray& docs, fxStr& emsg)
{
- fxBool pollOK = FALSE;
+ bool pollOK = false;
changeState(RECEIVING);
traceProtocol("POLL FAX: begin (SEP \"%s\", PWD \"%s\")",
(const char*) sep, (const char*) pwd);
* FAX Server Reception Protocol.
*/
-fxBool
+bool
FaxServer::recvFax()
{
traceProtocol("RECV FAX: begin");
fxStr emsg;
FaxRecvInfoArray docs;
FaxRecvInfo info;
- fxBool faxRecognized = FALSE;
- abortCall = FALSE;
+ bool faxRecognized = false;
+ abortCall = false;
/*
* Create the first file ahead of time to avoid timing
/*
* Receive one or more documents.
*/
-fxBool
+bool
FaxServer::recvDocuments(TIFF* tif, FaxRecvInfo& info, FaxRecvInfoArray& docs, fxStr& emsg)
{
- fxBool recvOK;
+ bool recvOK;
int ppm;
pageStart = Sys::now();
for (;;) {
* NB: Caller-ID access control is done elsewhere; prior
* to answering a call.
*/
- fxBool okToRecv = isTSIOk(info.sender);
+ bool okToRecv = isTSIOk(info.sender);
traceServer("%s TSI \"%s\"", okToRecv ? "ACCEPT" : "REJECT",
(const char*) info.sender);
if (!okToRecv) {
info.reason = emsg;
notifyDocumentRecvd(info);
TIFFClose(tif);
- return (FALSE);
+ return (false);
}
}
setServerStatus("Receiving from \"%s\"", (const char*) info.sender);
*/
tif = setupForRecv(info, docs, emsg);
if (tif == NULL)
- return (FALSE);
+ return (false);
fileStart = pageStart = Sys::now();
}
/*NOTREACHED*/
/*
* Receive Phase B protocol processing.
*/
-fxBool
+bool
FaxServer::recvFaxPhaseD(TIFF* tif, FaxRecvInfo& info, int& ppm, fxStr& emsg)
{
ppm = PPM_EOP;
do {
if (++recvPages > maxRecvPages) {
emsg = "Maximum receive page count exceeded, job terminated";
- return (FALSE);
+ return (false);
}
if (!modem->recvPage(tif, ppm, emsg))
- return (FALSE);
+ return (false);
info.npages++;
info.time = (u_int) getPageTransferTime();
info.params = modem->getRecvParams();
notifyPageRecvd(tif, info, ppm);
if (PPM_PRI_MPS <= ppm && ppm <= PPM_PRI_EOP) {
emsg = "Procedure interrupt received, job terminated";
- return (FALSE);
+ return (false);
}
pageStart = Sys::now(); // reset for next page
} while (ppm == PPM_MPS || ppm == PPM_PRI_MPS);
- return (TRUE);
+ return (true);
}
void
desiredtl = 0;
totdials = 0, maxdials = (u_short) FAX_REDIALS;
tottries = 0, maxtries = (u_short) FAX_RETRIES;
- useccover = TRUE;
+ useccover = true;
pagechop = chop_default;
chopthreshold = -1;
notify = no_notice;
/*
* Parse the contents of a job description file.
*/
-fxBool
-FaxRequest::readQFile(fxBool& rejectJob)
+bool
+FaxRequest::readQFile(bool& rejectJob)
{
- rejectJob = FALSE;
+ rejectJob = false;
lineno = 0;
lseek(fd, 0L, SEEK_SET); // XXX should only for re-read
/*
Sys::fstat(fd, sb);
if (sb.st_size < 2) {
error("Corrupted file (too small)");
- return (FALSE);
+ return (false);
}
char stackbuf[2048];
char* buf = stackbuf;
error("Read error: %s", strerror(errno));
if (bp != buf)
delete bp;
- return (FALSE);
+ return (false);
}
/*
* Force \n-termination of the last line in the
*/
if (state < state_suspended || state > state_done) {
error("Invalid scheduler state %u in job request", state);
- rejectJob = TRUE;
+ rejectJob = true;
}
#define isNull(s) ((s).length() == 0)
if (isNull(number) || isNull(mailaddr) || isNull(sender) || isNull(jobid)
|| isNull(modem) || isNull(client) || isNull(owner)) {
- rejectJob = TRUE;
+ rejectJob = true;
error("Null or missing %s in job request",
isNull(number) ? "number" :
isNull(mailaddr) ? "mailaddr" :
if (desireddf > DF_2DMMR) desireddf = DF_2DMMR;
if (buf != stackbuf) // dynamically allocated buffer
delete buf;
- return (TRUE);
+ return (true);
}
/*
* allocated and appended to. If you don't believe
* this, enable the code notdef'd out below.
*/
-fxBool
-FaxRequest::reReadQFile(fxBool& rejectJob)
+bool
+FaxRequest::reReadQFile(bool& rejectJob)
{
#ifdef notdef
reset(); // non-string items
* Does the specified document (assumed to be send_fax)
* appear to have any potential source references?
*/
-fxBool
+bool
FaxRequest::isUnreferenced(u_int fi)
{
if (fi > 0 && requests[fi-1].isSavedOp()) {
struct stat sb;
if (Sys::stat(mkbasedoc(requests[fi-1].item), sb) < 0 ||
sb.st_nlink == 1)
- return (TRUE);
+ return (true);
}
- return (FALSE);
+ return (false);
}
-static fxBool
+static bool
hasDotDot(const char* pathname)
{
const char* cp = pathname;
while (cp) {
if (cp[0] == '.') // NB: good enough
- return (TRUE);
+ return (true);
if (cp = strchr(cp, '/'))
cp++;
}
- return (FALSE);
+ return (false);
}
-fxBool
+bool
FaxRequest::checkDocument(const char* pathname)
{
/*
*/
if (pathname[0] == '/' || hasDotDot(pathname)) {
error("Invalid document file \"%s\"", pathname);
- return (FALSE);
+ return (false);
}
int fd = Sys::open(pathname, 0);
if (fd == -1) {
error("Can not access document file \"%s\": %s",
pathname, strerror(errno));
- return (FALSE);
+ return (false);
}
Sys::close(fd);
- return (TRUE);
+ return (true);
}
/*
* Add a request entry and verify the document is valid.
*/
void
-FaxRequest::addRequest(FaxSendOp op, char* tag, fxBool& rejectJob)
+FaxRequest::addRequest(FaxSendOp op, char* tag, bool& rejectJob)
{
char* cp = tag;
while (*cp && *cp != ':')
else
cp = tag, tag = "";
if (!checkDocument(cp))
- rejectJob = TRUE;
+ rejectJob = true;
else
requests.append(faxRequest(op, dirnum, tag, cp));
}
-fxBool
+bool
FaxRequest::isStrCmd(const char* cmd, u_int& ix)
{
for (int i = N(strvals)-1; i >= 0; i--)
if (strcmp(strvals[i].name, cmd) == 0) {
ix = i;
- return (TRUE);
+ return (true);
}
- return (FALSE);
+ return (false);
}
-fxBool
+bool
FaxRequest::isShortCmd(const char* cmd, u_int& ix)
{
for (int i = N(shortvals)-1; i >= 0; i--)
if (strcmp(shortvals[i].name, cmd) == 0) {
ix = i;
- return (TRUE);
+ return (true);
}
- return (FALSE);
+ return (false);
}
void
class FaxRequest {
protected:
void reset(void);
- virtual fxBool checkDocument(const char* pathname);
+ virtual bool checkDocument(const char* pathname);
virtual void error(const char* fmt, ...);
public:
enum {
FaxRequest(const fxStr& qf, int fd = -1);
virtual ~FaxRequest();
- fxBool readQFile(fxBool& rejectJob);
- fxBool reReadQFile(fxBool& rejectJob);
+ bool readQFile(bool& rejectJob);
+ bool reReadQFile(bool& rejectJob);
void writeQFile();
u_int findRequest(FaxSendOp, u_int start = 0) const;
- fxBool isNotify(u_int what) const;
+ bool isNotify(u_int what) const;
- static fxBool isStrCmd(const char* cmd, u_int& ix);
- static fxBool isShortCmd(const char* cmd, u_int& ix);
+ static bool isStrCmd(const char* cmd, u_int& ix);
+ static bool isShortCmd(const char* cmd, u_int& ix);
void insertFax(u_int ix, const fxStr& file);
void addRequest(FaxSendOp op, char* tag);
- void addRequest(FaxSendOp op, char* tag, fxBool& rejectJob);
+ void addRequest(FaxSendOp op, char* tag, bool& rejectJob);
void checkNotifyValue(const char* tag);
void checkChopValue(const char* tag);
static fxStr mkbasedoc(const fxStr& file);
void renameSaved(u_int fi);
- fxBool isUnreferenced(u_int fi);
+ bool isUnreferenced(u_int fi);
};
-inline fxBool FaxRequest::isNotify(u_int what) const
+inline bool FaxRequest::isNotify(u_int what) const
{ return (notify & (u_short) what) != 0; }
#endif /* _FaxRequest_ */
* time to settle. We want a handle on the modem so that we
* can be prepared to answer incoming phone calls.
*/
- discardModem(TRUE);
+ discardModem(true);
changeState(MODEMWAIT, 5);
} else {
sendFailed(fax, send_retry, "Can not setup modem", 4*pollModemWait);
- discardModem(TRUE);
+ discardModem(true);
changeState(MODEMWAIT, pollModemWait);
}
endSession();
fax.ndials = 0; // consec. failed dial attempts
fax.tottries++; // total answered calls
fax.totdials++; // total attempted calls
- clientInfo.setCalledBefore(TRUE);
+ clientInfo.setCalledBefore(true);
clientInfo.setDialFailures(0);
modem->sendBegin();
- fxBool remoteHasDoc = FALSE;
+ bool remoteHasDoc = false;
notifyConnected(fax);
FaxSendStatus status = modem->getPrologue(
clientCapabilities, remoteHasDoc, notice);
break;
case ClassModem::NOFCON: // carrier seen, but handshake failed
case ClassModem::DATACONN: // data connection established
- clientInfo.setCalledBefore(TRUE);
+ clientInfo.setCalledBefore(true);
/* fall thru... */
case ClassModem::BUSY: // busy signal
case ClassModem::NOANSWER: // no answer or ring back
* Process a polling request.
*/
void
-FaxServer::sendPoll(FaxRequest& fax, fxBool remoteHasDoc)
+FaxServer::sendPoll(FaxRequest& fax, bool remoteHasDoc)
{
u_int ix = fax.findRequest(FaxRequest::send_poll);
if (ix == fx_invalidArrayIndex) {
/*
* Phase B of Group 3 protocol.
*/
-fxBool
+bool
FaxServer::sendFaxPhaseB(FaxRequest& fax, faxRequest& freq, FaxMachineInfo& clientInfo)
{
fax.status = send_failed; // assume failure
* Check client's capabilities (DIS) against those of the
* modem and select the parameters that are best for us.
*/
-fxBool
+bool
FaxServer::sendClientCapabilitiesOK(FaxRequest& fax, FaxMachineInfo& clientInfo, fxStr& emsg)
{
/*
fxmin(clientInfo.getMaxSignallingRate(), fax.desiredbr));
if (signallingRate == -1) {
emsg = "Modem does not support negotiated signalling rate";
- return (FALSE);
+ return (false);
}
clientParams.br = signallingRate;
fxmax(clientInfo.getMinScanlineTime(), fax.desiredst));
if (minScanlineTime == -1) {
emsg = "Modem does not support negotiated min scanline time";
- return (FALSE);
+ return (false);
}
clientParams.st = minScanlineTime;
traceProtocol("USE %s", clientParams.scanlineTimeName());
if (clientParams.ec == EC_ENABLE)
traceProtocol("USE error correction mode");
- return (TRUE);
+ return (true);
}
/*
* just by yanking the cable and then swapping the
* config file before hooking up the new modem.
*/
-fxBool
+bool
FaxServer::setupModem()
{
modem = NULL;
if (!ModemServer::setupModem())
- return (FALSE);
+ return (false);
if (getModem()->isFaxModem()) {
modem = (FaxModem*) ModemServer::getModem();
modem->setLID(localIdentifier);
}
- return (TRUE);
+ return (true);
}
void
-FaxServer::discardModem(fxBool dropDTR)
+FaxServer::discardModem(bool dropDTR)
{
ModemServer::discardModem(dropDTR);
modem = NULL;
* are selected so that any imaged facsimile should
* still be sendable.
*/
-fxBool FaxServer::modemSupports2D() const
- { return modem ? modem->supports2D() : FALSE; }
-fxBool FaxServer::modemSupportsEOLPadding() const
- { return modem ? modem->supportsEOLPadding() : FALSE; }
-fxBool FaxServer::modemSupportsVRes(float res) const
- { return modem ? modem->supportsVRes(res) : TRUE; }
-fxBool FaxServer::modemSupportsPageWidth(u_int w) const
- { return modem ? modem->supportsPageWidth(w) : TRUE; }
-fxBool FaxServer::modemSupportsPageLength(u_int l) const
- { return modem ? modem->supportsPageLength(l) : TRUE; }
-
-fxBool FaxServer::modemSupportsPolling() const
- { return modem ? modem->supportsPolling() : FALSE; }
+bool FaxServer::modemSupports2D() const
+ { return modem ? modem->supports2D() : false; }
+bool FaxServer::modemSupportsEOLPadding() const
+ { return modem ? modem->supportsEOLPadding() : false; }
+bool FaxServer::modemSupportsVRes(float res) const
+ { return modem ? modem->supportsVRes(res) : true; }
+bool FaxServer::modemSupportsPageWidth(u_int w) const
+ { return modem ? modem->supportsPageWidth(w) : true; }
+bool FaxServer::modemSupportsPageLength(u_int l) const
+ { return modem ? modem->supportsPageLength(l) : true; }
+
+bool FaxServer::modemSupportsPolling() const
+ { return modem ? modem->supportsPolling() : false; }
fxStr
FaxServer::getModemCapabilities() const
// FAX transmission protocol support
void sendFax(FaxRequest& fax, FaxMachineInfo&, const fxStr& number);
- fxBool sendClientCapabilitiesOK(FaxRequest&, FaxMachineInfo&, fxStr&);
- fxBool sendFaxPhaseB(FaxRequest&, faxRequest&, FaxMachineInfo&);
- void sendPoll(FaxRequest& fax, fxBool remoteHasDoc);
+ bool sendClientCapabilitiesOK(FaxRequest&, FaxMachineInfo&, fxStr&);
+ bool sendFaxPhaseB(FaxRequest&, faxRequest&, FaxMachineInfo&);
+ void sendPoll(FaxRequest& fax, bool remoteHasDoc);
FaxSendStatus sendSetupParams(TIFF*,
Class2Params&, const FaxMachineInfo&, fxStr&);
FaxSendStatus sendSetupParams1(TIFF*,
// FAX reception support
int getRecvFile(fxStr& qfile, fxStr& emsg);
TIFF* setupForRecv(FaxRecvInfo&, FaxRecvInfoArray&, fxStr& emsg);
- fxBool recvDocuments(TIFF*, FaxRecvInfo&, FaxRecvInfoArray&,
+ bool recvDocuments(TIFF*, FaxRecvInfo&, FaxRecvInfoArray&,
fxStr& emsg);
- fxBool recvFaxPhaseD(TIFF* tif, FaxRecvInfo&, int& ppm, fxStr& emsg);
- fxBool pollFaxPhaseB(const fxStr& sep, const fxStr& pwd,
+ bool recvFaxPhaseD(TIFF* tif, FaxRecvInfo&, int& ppm, fxStr& emsg);
+ bool pollFaxPhaseB(const fxStr& sep, const fxStr& pwd,
FaxRecvInfoArray&, fxStr& emsg);
protected:
FaxServer(const fxStr& deviceName, const fxStr& devID);
- fxBool setupModem();
+ bool setupModem();
ClassModem* deduceModem();
- void discardModem(fxBool dropDTR);
+ void discardModem(bool dropDTR);
fxStr getModemCapabilities() const;
void readConfig(const fxStr& filename);
void setLocalIdentifier(const fxStr& lid);
void sendFax(FaxRequest&, FaxMachineInfo&, FaxAcctInfo&);
- fxBool recvFax();
+ bool recvFax();
time_t getFileTransferTime() const;
time_t getPageTransferTime() const;
const fxStr& getLocalIdentifier() const;
- fxBool modemSupports2D() const;
- fxBool modemSupportsEOLPadding() const;
- fxBool modemSupportsVRes(float res) const;
- fxBool modemSupportsPageWidth(u_int w) const;
- fxBool modemSupportsPageLength(u_int l) const;
- fxBool modemSupportsPolling() const;
+ bool modemSupports2D() const;
+ bool modemSupportsEOLPadding() const;
+ bool modemSupportsVRes(float res) const;
+ bool modemSupportsPageWidth(u_int w) const;
+ bool modemSupportsPageLength(u_int l) const;
+ bool modemSupportsPolling() const;
};
#endif /* _FaxServer_ */
G3Decoder::~G3Decoder() {}
void
-G3Decoder::setupDecoder(u_int recvFillOrder, fxBool is2d)
+G3Decoder::setupDecoder(u_int recvFillOrder, bool is2d)
{
/*
* The G3 decoding state tables are constructed for
}
}
-fxBool
+bool
G3Decoder::isNextRow1D()
{
DECLARE_STATE_EOL();
CACHE_STATE();
SYNC_EOL(Nop);
- fxBool is1D;
+ bool is1D;
if (is2D) {
NeedBits8(1, Nop);
is1D = (GetBits(1) != 0); // 1D/2D-encoding tag bit
// NB: we don't clear the tag bit
} else {
- is1D = TRUE;
+ is1D = true;
}
// now reset state for next decoded row
BitAcc = (BitAcc<<1)|1; // EOL bit
#define unexpected(table, a0) do { \
invalidCode(table, a0); \
- rowgood = FALSE; \
+ rowgood = false; \
} while (0)
#define extension(a0) do { \
invalidCode("2D", a0); \
- rowgood = FALSE; \
+ rowgood = false; \
} while (0)
#define prematureEOF(a0) // never happens 'cuz of longjmp
#define SWAP(t,a,b) { t x; x = (a); (a) = (b); (b) = x; }
* Decode a single row of pixels and return
* the decoded data in the scanline buffer.
*/
-fxBool
+bool
G3Decoder::decodeRow(void* scanline, u_int lastx)
{
DECLARE_STATE_2D();
- fxBool rowgood = TRUE;
- fxBool nullrow = FALSE;
+ bool rowgood = true;
+ bool nullrow = false;
CACHE_STATE();
a0 = 0;
RunLength = 0;
pa = thisrun = curruns;
SYNC_EOL(Nop);
- fxBool is1D;
+ bool is1D;
if (is2D) {
NeedBits8(1, Nop);
is1D = (GetBits(1) != 0); // 1D/2D-encoding tag bit
ClrBits(1);
} else
- is1D = TRUE;
+ is1D = true;
if (!is1D) {
pb = refruns;
b1 = *pb++;
#define badlength(a0,lastx) do { \
badPixelCount("2D", a0, lastx); \
- rowgood = FALSE; \
+ rowgood = false; \
} while (0)
EXPAND2D(Nop2d);
Nop2d:;
if (nullrow && ++RTCrun == 6 && RTCrow == -1) \
RTCrow = rowref-6; \
badPixelCount("1D", a0, lastx); \
- rowgood = FALSE; \
+ rowgood = false; \
} while (0)
EXPAND1D(Nop1d);
Nop1d:;
class G3Decoder {
private:
- fxBool is2D; // whether or not data is 2d-encoded
+ bool is2D; // whether or not data is 2d-encoded
uint32 data; // current input/output byte
int bit; // current bit in input/output byte
int EOLcnt; // EOL code recognized during decoding (1/0)
virtual ~G3Decoder();
- void setupDecoder(u_int fillorder, fxBool is2D);
+ void setupDecoder(u_int fillorder, bool is2D);
void setRuns(uint16*, uint16*, int);
uint16* lastRuns();
void decode(void* raster, u_int w, u_int h);
- fxBool decodeRow(void* scanline, u_int w);
- fxBool isNextRow1D();
+ bool decodeRow(void* scanline, u_int w);
+ bool isNextRow1D();
int getPendingBits() const;
- fxBool seenRTC() const;
+ bool seenRTC() const;
int getRTCRow() const;
int getReferenceRow() const;
};
inline uint16* G3Decoder::lastRuns() { return is2D ? refruns : curruns; }
inline const u_char* G3Decoder::getBitmap() { return bitmap; }
inline int G3Decoder::getPendingBits() const { return bit; }
-inline fxBool G3Decoder::seenRTC() const { return (RTCrow != -1); }
+inline bool G3Decoder::seenRTC() const { return (RTCrow != -1); }
inline int G3Decoder::getRTCRow() const { return RTCrow; }
inline int G3Decoder::getReferenceRow() const { return rowref; }
#endif /* _G3Decoder_ */
* Reset encoding state.
*/
void
-G3Encoder::setupEncoder(u_int fillOrder, fxBool is2d)
+G3Encoder::setupEncoder(u_int fillOrder, bool is2d)
{
is2D = is2d;
/*
class G3Encoder {
private:
- fxBool is2D; // data is to be 1d/2d-encoded
+ bool is2D; // data is to be 1d/2d-encoded
const u_char* bitmap; // bit reversal table
short data; // current input/output byte
short bit; // current bit in input/output byte
G3Encoder(fxStackBuffer&);
virtual ~G3Encoder();
- void setupEncoder(u_int fillOrder, fxBool);
+ void setupEncoder(u_int fillOrder, bool);
void encode(const void* raster, u_int w, u_int h);
};
#endif /* _G3Encoder_ */
* the child.
*/
void
-Getty::run(int fd, fxBool parentIsInit)
+Getty::run(int fd, bool parentIsInit)
{
if (Sys::chdir(_PATH_DEV) < 0)
fatal("chdir: %m");
fatal("Unable to dup stdin to stderr: %m");
}
-fxBool
-Getty::wait(int& status, fxBool block)
+bool
+Getty::wait(int& status, bool block)
{
return (Sys::waitpid(pid, status, block ? 0 : WNOHANG) == pid);
}
void setupArgv(const char* args); // setup arguments for getty process
// run getty process
- virtual void run(int fd, fxBool parentIsInit);
- virtual fxBool wait(int& status, fxBool block = FALSE);
+ virtual void run(int fd, bool parentIsInit);
+ virtual bool wait(int& status, bool block = false);
virtual void hangup(); // cleanup state after hangup
pid_t getPID() const; // getty pid
Getty::hangup();
}
-fxBool
-SysVGetty::wait(int& status, fxBool block)
+bool
+SysVGetty::wait(int& status, bool block)
{
if (Getty::wait(status, block)) {
exitStatus = status;
- return (TRUE);
+ return (true);
} else
- return (FALSE);
+ return (false);
}
/*
~SysVGetty();
void hangup();
- fxBool wait(int& status, fxBool block = FALSE);
+ bool wait(int& status, bool block = false);
};
#endif /* _SYSVGETTY_ */
base = next = buf;
end = &buf[sizeof(buf)];
amountToGrowBy = 1024;
- ok = FALSE;
+ ok = false;
}
HDLCFrame::~HDLCFrame()
u_char& operator[](u_int i) const; // NB: no bounds checking
u_char& operator[](int i) const; // NB: no bounds checking
- fxBool moreFrames() const; // more frames follow
- fxBool isOK() const; // frame has good FCS
- void setOK(fxBool b); // set frame FCS indicator
+ bool moreFrames() const; // more frames follow
+ bool isOK() const; // frame has good FCS
+ void setOK(bool b); // set frame FCS indicator
u_int getRawFCF() const; // raw FCF in frame
u_int getFCF() const; // FCF &~ (FCF_SNDR|FCF_RCVR)
const u_char* getFrameData() const; // data following FCF
u_char* base;
u_short amountToGrowBy;
u_short frameOverhead; // # bytes for leader & FCS
- fxBool ok; // FCS correct
+ bool ok; // FCS correct
void addc(u_char c); // make room & add a char to the buffer
void grow(u_int amount); // make more room in the buffer
inline void HDLCFrame::put(u_char c)
{ if (next < end) *next++ = c; else addc(c); }
-inline void HDLCFrame::reset() { next = base; ok = FALSE; }
+inline void HDLCFrame::reset() { next = base; ok = false; }
inline u_int HDLCFrame::getLength() const { return next - base; }
inline HDLCFrame::operator u_char*() { return base; }
inline u_char& HDLCFrame::operator[](u_int i) const { return base[i]; }
inline u_char& HDLCFrame::operator[](int i) const { return base[i]; }
-inline fxBool HDLCFrame::moreFrames() const
+inline bool HDLCFrame::moreFrames() const
{ return ((*this)[1]&0x08) == 0; }
-inline fxBool HDLCFrame::isOK() const { return ok; }
-inline void HDLCFrame::setOK(fxBool b) { ok = b; }
+inline bool HDLCFrame::isOK() const { return ok; }
+inline void HDLCFrame::setOK(bool b) { ok = b; }
inline u_int HDLCFrame::getRawFCF() const { return (*this)[2]; }
inline u_int HDLCFrame::getFCF() const { return (*this)[2]&0x7f; }
inline const u_char* HDLCFrame::getFrameData() const { return &((*this)[3]); }
refs = 0;
seqnum = 0;
lrunum = lruseq;
- reap = FALSE;
+ reap = false;
clients[fn] = this;
}
* client is scheduled to be purged at the next
* opportune time.
*/
-fxBool
+bool
HylaClient::send(const char* msg, u_int msgLen)
{
if (reap) // ignore if marked for reaping
- return (FALSE);
+ return (false);
seqnum++; // count message
again:
if (fifo < 0) {
logError("HylaClient::send: %s: Cannot open FIFO: %m",
(const char*) fifoName);
schedReap();
- return (FALSE);
+ return (false);
}
/*
* NB: We mark the descriptor for non-blocking i/o; this
if (n == -1 && (errno == EBADF || errno == EPIPE)) {
Sys::close(fifo), fifo = -1;
schedReap();
- return (FALSE);
+ return (false);
}
if (n != msgLen)
logError(
(const char*) fifoName, seqnum, n);
lrunum = lruseq++; // update last use seqnum
}
- return (TRUE);
+ return (true);
}
/*
* the oldest trigger with an open descriptor and
* reclaim it.
*/
-fxBool
+bool
HylaClient::reapFIFO()
{
HylaClient* cand = NULL;
if (cand) {
Sys::close(cand->fifo);
cand->fifo = -1;
- return (TRUE);
+ return (true);
} else
- return (FALSE);
+ return (false);
}
void
void
HylaClient::schedReap()
{
- reap = TRUE;
+ reap = true;
schedReaper.start();
}
* "delete this".
*/
-HylaClient::SchedReaper::SchedReaper() { started = FALSE; }
+HylaClient::SchedReaper::SchedReaper() { started = false; }
HylaClient::SchedReaper::~SchedReaper() {}
void
HylaClient::SchedReaper::timerExpired(long, long)
{
- started = FALSE;
+ started = false;
/*
* Reclaim clients that have gone away.
*
{
if (!started) {
Dispatcher::instance().startTimer(0,1, this);
- started = TRUE;
+ started = true;
}
}
public:
class SchedReaper : public IOHandler {
private:
- fxBool started;
+ bool started;
public:
SchedReaper();
~SchedReaper();
u_short refs; // # of Triggers referencing this client
tseq_t seqnum; // per-client message sequence number
tseq_t lrunum; // sequence number for LRU reclaim of fd's
- fxBool reap; // client should be reaped
+ bool reap; // client should be reaped
static tseq_t lruseq; // master sequence # generator for LRU
static HylaClientDict clients; // master table of clients
HylaClient(const fxStr& fifoName);
- static fxBool reapFIFO();
+ static bool reapFIFO();
void schedReap();
public:
~HylaClient();
void dec();
tseq_t getSeqnum() const;
- fxBool send(const char* msg, u_int msgLen);
+ bool send(const char* msg, u_int msgLen);
};
inline void HylaClient::inc() { refs++; }
inline void HylaClient::dec() { if (--refs == 0) delete this; }
dnext = NULL;
modem = NULL;
- suspendPending = FALSE;
+ suspendPending = false;
registry[jobid] = this;
}
u_short pagewidth; // desired output page width (mm)
u_short pagelength; // desired output page length (mm)
u_short resolution; // desired vertical resolution (lpi)
- fxBool willpoll; // job has polling request
- fxBool suspendPending; // suspend state change pending for job
+ bool willpoll; // job has polling request
+ bool suspendPending; // suspend state change pending for job
fxStr file; // queue file name
fxStr jobid; // job identifier
operator Job&() const { return *(Job*)ql; }
operator Job*() const { return (Job*) ql; }
Job& job() const { return *(Job*)ql; }
- fxBool notDone() { return ql != head; }
+ bool notDone() { return ql != head; }
};
#endif /* _Job_ */
, lockHandler(*this)
{
state = DOWN; // modem down until notified otherwise
- canpoll = TRUE; // be optimistic
+ canpoll = true; // be optimistic
fd = -1; // force open on first use
priority = 255; // lowest priority
insert(list); // place at end of master list
/*
* Is the modem capable of handling the job.
*/
-fxBool
+bool
Modem::isCapable(const Job& job) const
{
if (job.willpoll && !canpoll)
- return (FALSE);
+ return (false);
if (job.pagewidth && !supportsPageWidthInMM(job.pagewidth))
- return (FALSE);
+ return (false);
if (job.pagelength && !supportsPageLengthInMM(job.pagelength))
- return (FALSE);
+ return (false);
if (job.resolution && !supportsVRes(job.resolution))
- return (FALSE);
- return (TRUE);
+ return (false);
+ return (true);
}
/*
/*
* Assign a modem for use by a job.
*/
-fxBool
+bool
Modem::assign(Job& job)
{
if (lock->lock()) { // lock modem for use
state = BUSY; // mark in use
job.modem = this; // assign modem to job
- return (TRUE);
+ return (true);
} else {
/*
* Modem is locked for use by an outbound task.
* to re-assign it in findModem.
*/
state = BUSY; // mark in use
- return (FALSE);
+ return (false);
}
}
* (but then the caller would need to know in order
* to pad the image to the appropriate width).
*/
-fxBool
+bool
Modem::supportsPageWidthInMM(u_int w) const
{
if (w <= 110) // 864 pixels + slop
else if (w <= 306) // 2432 pixels + slop
return caps.wd & BIT(WD_2432);
else
- return FALSE;
+ return false;
}
-fxBool
+bool
Modem::supportsPageWidthInPixels(u_int w) const
{
if (w <= 880) // 864 pixels + slop
else if (w <= 2448) // 2432 pixels + slop
return caps.wd & BIT(WD_2432);
else
- return FALSE;
+ return false;
}
/*
* problems and general sloppiness on the part of
* applications writing TIFF files.
*/
-fxBool
+bool
Modem::supportsVRes(float res) const
{
if (75 <= res && res < 120)
else if (150 <= res && res < 250)
return caps.vr & BIT(VR_FINE);
else
- return FALSE;
+ return false;
}
/*
* Return whether or not the modem supports 2DMR.
*/
-fxBool
+bool
Modem::supports2D() const
{
return caps.df & BIT(DF_2DMR);
* specified page length. As above for vertical
* resolution we're lenient in what we accept.
*/
-fxBool
+bool
Modem::supportsPageLengthInMM(u_int l) const
{
// XXX probably need to be more forgiving with values
* NB: We rarely send msgs, so for now close after each use.
* +1 here is so the \0 is included in the message.
*/
- iter.modem().send(msg, msg.length()+1, FALSE);
+ iter.modem().send(msg, msg.length()+1, false);
}
}
/*
* Send a message to the process managing a modem.
*/
-fxBool
-Modem::send(const char* msg, u_int msgLen, fxBool cacheFd)
+bool
+Modem::send(const char* msg, u_int msgLen, bool cacheFd)
{
- fxBool retry = TRUE;
+ bool retry = true;
again:
if (fd < 0) {
fd = Sys::open(fifoName, O_WRONLY|O_NDELAY);
*/
logError("MODEM " | devID | ": Cannot open FIFO: %m");
#endif
- return (FALSE);
+ return (false);
}
}
int n = Sys::write(fd, msg, msgLen);
if (n == -1) {
if (errno == EBADF && retry) { // cached descriptor bad, retry
- retry = FALSE;
+ retry = false;
Sys::close(fd), fd = -1;
goto again;
}
fxStr number; // modem phone number
fxStr commid; // communication identifier
ModemState state; // modem state
- fxBool canpoll; // modem is capable of polling
+ bool canpoll; // modem is capable of polling
u_short priority; // modem priority
Class2Params caps; // modem capabilities
UUCPLock* lock; // UUCP lockfile support
static Modem* modemExists(const fxStr& id);
static Modem* findModem(const Job& job);
- fxBool assign(Job&); // assign modem
+ bool assign(Job&); // assign modem
void release(); // release modem
void startLockPolling(long sec); // initiate polling thread
u_int getPriority() const; // return modem scheduling priority
const fxStr& getCommID() const; // return communication ID
- fxBool isCapable(const Job& job) const;
- fxBool supports2D() const; // modem supports 2D-encoded fax
- fxBool supportsVRes(float) const; // modem supports vertical resolution
+ bool isCapable(const Job& job) const;
+ bool supports2D() const; // modem supports 2D-encoded fax
+ bool supportsVRes(float) const; // modem supports vertical resolution
// modem support fax page width
- fxBool supportsPageWidthInMM(u_int) const;
- fxBool supportsPageWidthInPixels(u_int) const;
+ bool supportsPageWidthInMM(u_int) const;
+ bool supportsPageWidthInPixels(u_int) const;
// modem supports fax page length
- fxBool supportsPageLengthInMM(u_int) const;
- fxBool supportsPolling() const; // modem supports fax polling
+ bool supportsPageLengthInMM(u_int) const;
+ bool supportsPolling() const; // modem supports fax polling
// send message to modem FIFO
- fxBool send(const char* msg, u_int len, fxBool cacheFd = TRUE);
+ bool send(const char* msg, u_int len, bool cacheFd = true);
static void broadcast(const fxStr&); // broadcast msg to all FIFOs
void encode(fxStackBuffer&) const; // encode for ModemExt
};
-inline fxBool Modem::supportsPolling() const { return canpoll; }
+inline bool Modem::supportsPolling() const { return canpoll; }
inline const fxStr& Modem::getDeviceID() const { return devID; }
inline const fxStr& Modem::getNumber() const { return number; }
inline ModemState Modem::getState() const { return state; }
operator Modem&() const { return *(Modem*)ql; }
operator Modem*() const { return (Modem*) ql; }
Modem& modem() const { return *(Modem*)ql; }
- fxBool notDone() { return ql != head; }
+ bool notDone() { return ql != head; }
};
#endif /* _Modem_ */
flowControl = ClassModem::FLOW_NONE;// no flow control
maxRate = ClassModem::BR19200; // reasonable for most modems
minSpeed = BR_2400; // minimum transmit speed
- waitForConnect = FALSE; // unique modem answer response
- class2XmitWaitForXON = TRUE; // default per Class 2 spec
- class2SendRTC = FALSE; // default per Class 2 spec
+ waitForConnect = false; // unique modem answer response
+ class2XmitWaitForXON = true; // default per Class 2 spec
+ class2SendRTC = false; // default per Class 2 spec
setVolumeCmds("ATM0 ATL0M1 ATL1M1 ATL2M1 ATL3M1");
recvDataFormat = DF_ALL; // default to no transcoding
}
#define valeq(a,b) (strcasecmp(a,b)==0)
-fxBool
+bool
ModemConfig::findRate(const char* cp, BaudRate& br)
{
static const struct {
for (int i = N(rates)-1; i >= 0; i--)
if (streq(cp, rates[i].name)) {
br = rates[i].b;
- return (TRUE);
+ return (true);
}
- return (FALSE);
+ return (false);
}
BaudRate
return (br);
}
-fxBool
+bool
ModemConfig::findATResponse(const char* cp, ATResponse& resp)
{
static const struct {
for (u_int i = 0; i < N(responses); i++)
if (valeq(cp, responses[i].name)) {
resp = responses[i].r;
- return (TRUE);
+ return (true);
}
- return (FALSE);
+ return (false);
}
u_int
}
}
-fxBool
+bool
ModemConfig::findFlow(const char* cp, FlowControl& fc)
{
static const struct {
for (u_int i = 0; i < N(fcnames); i++)
if (valeq(cp, fcnames[i].name)) {
fc = fcnames[i].f;
- return (TRUE);
+ return (true);
}
- return (FALSE);
+ return (false);
}
FlowControl
return (BR_2400);
}
-fxBool
+bool
ModemConfig::findDataFormat(const char* cp, u_int& df)
{
static const struct {
for (i = 0; i < N(dfnames); i++)
if (valeq(v, dfnames[i].name)) {
df = dfnames[i].d;
- return (TRUE);
+ return (true);
}
- return (FALSE);
+ return (false);
}
u_int
cid.number = rbuf+cidNumber.length();
}
-fxBool
+bool
ModemConfig::setConfigItem(const char* tag, const char* value)
{
u_int ix;
else if (streq(tag, "recvdataformat"))
recvDataFormat = getDataFormat(value);
else
- return (FALSE);
- return (TRUE);
+ return (false);
+ return (true);
}
#undef N
u_int getSpeed(const char* value);
u_int getDataFormat(const char* value);
- static fxBool findRate(const char*, BaudRate&);
- static fxBool findATResponse(const char*, ATResponse&);
- static fxBool findFlow(const char*, FlowControl&);
- static fxBool findDataFormat(const char*, u_int&);
+ static bool findRate(const char*, BaudRate&);
+ static bool findATResponse(const char*, ATResponse&);
+ static bool findFlow(const char*, FlowControl&);
+ static bool findDataFormat(const char*, u_int&);
protected:
ModemConfig();
void setupConfig();
virtual void resetConfig();
- virtual fxBool setConfigItem(const char* tag, const char* value);
+ virtual bool setConfigItem(const char* tag, const char* value);
virtual void configError(const char* fmt, ...) = 0;
virtual void configTrace(const char* fmt, ...) = 0;
fxStr parseATCmd(const char*);
fxStr class2HFLOCmd; // cmd to setup hardware flow control
fxStr class2MINSPCmd; // cmd to setup min transmit speed
fxStr class2RecvDataTrigger; // send to start recv
- fxBool class2XmitWaitForXON; // wait for XON before send
- fxBool class2SendRTC; // append RTC to page data on transmit
+ bool class2XmitWaitForXON; // wait for XON before send
+ bool class2SendRTC; // append RTC to page data on transmit
// for class 2.0:
fxStr class2PIECmd; // cmd to set proc interrupt handling
fxStr class2NRCmd; // cmd to set status reporting
u_int percentGoodLines; // required % of good lines in page
u_int maxConsecutiveBadLines; // max consecutive bad lines in page
u_int minSpeed; // minimum speed for fax transmits
- fxBool waitForConnect; // modem sends multiple answer responses
+ bool waitForConnect; // modem sends multiple answer responses
fxStr tagLineFmt; // format string for tag lines
fxStr tagLineFontFile; // font file for imaging tag lines
u_int recvDataFormat; // received facsimile data format
{
state = BASE;
statusFile = NULL;
- abortCall = FALSE;
- deduceComplain = TRUE; // first failure causes complaint
- changePriority = TRUE;
- delayConfig = FALSE;
+ abortCall = false;
+ deduceComplain = true; // first failure causes complaint
+ changePriority = true;
+ delayConfig = false;
modemFd = -1;
modem = NULL;
setupAttempts = 0;
rcvCC = rcvNext = 0;
- timeout = FALSE;
+ timeout = false;
log = NULL;
}
for (GetoptIter iter(argc, argv, faxApp::getOpts()); iter.notDone(); iter++)
switch (iter.option()) {
case 'p':
- changePriority = FALSE;
+ changePriority = false;
break;
case 'x':
tracingMask &= ~(FAXTRACE_MODEMIO|FAXTRACE_TIMEOUTS);
ModemServer::open()
{
if (lockModem()) {
- fxBool modemReady = setupModem();
+ bool modemReady = setupModem();
unlockModem();
if (!modemReady)
changeState(MODEMWAIT, pollModemWait);
if (lockModem()) {
if (modem)
modem->hangup();
- discardModem(TRUE);
+ discardModem(true);
unlockModem();
}
}
ModemServer::resetConfig()
{
if (modem)
- discardModem(TRUE);
+ discardModem(true);
ServerConfig::resetConfig();
}
/*
* Setup the modem; if needed.
*/
-fxBool
+bool
ModemServer::setupModem()
{
if (!modem) {
const char* dev = modemDevice;
if (!openDevice(dev))
- return (FALSE);
+ return (false);
/*
* Deduce modem type and setup configuration info.
* The deduceComplain cruft is just to reduce the
*/
modem = deduceModem();
if (!modem) {
- discardModem(TRUE);
+ discardModem(true);
if (deduceComplain) {
traceServer("%s: Can not initialize modem.", dev);
- deduceComplain = FALSE;
+ deduceComplain = false;
}
- return (FALSE);
+ return (false);
} else {
- deduceComplain = TRUE;
+ deduceComplain = true;
traceServer("MODEM "
| modem->getManufacturer() | " "
| modem->getModel() | "/"
* business in the modem class.
*/
modem->setSpeakerVolume(speakerVolume);
- return (TRUE);
+ return (true);
}
/*
* and change the device file to be owned by us
* and with a protected file mode.
*/
-fxBool
+bool
ModemServer::openDevice(const char* dev)
{
/*
uid_t euid = geteuid();
if (seteuid(0) < 0) {
traceServer("%s: seteuid root failed (%m)", dev);
- return (FALSE);
+ return (false);
}
#ifdef O_NDELAY
/*
if (modemFd < 0) {
seteuid(euid);
traceServer("%s: Can not open modem (%m)", dev);
- return (FALSE);
+ return (false);
}
int flags = fcntl(modemFd, F_GETFL, 0);
if (fcntl(modemFd, F_SETFL, flags &~ O_NDELAY) < 0) {
traceServer("%s: fcntl: %m", dev);
Sys::close(modemFd), modemFd = -1;
- return (FALSE);
+ return (false);
}
#else
startTimeout(3*1000);
"%s: Can not open modem (timed out)." :
"%s: Can not open modem (%m)."),
dev, errno);
- return (FALSE);
+ return (false);
}
#endif
/*
#endif
traceServer("%s: chmod: %m", dev);
seteuid(euid);
- return (TRUE);
+ return (true);
}
-fxBool
+bool
ModemServer::reopenDevice()
{
if (modemFd >= 0)
* Discard any handle on the modem.
*/
void
-ModemServer::discardModem(fxBool dropDTR)
+ModemServer::discardModem(bool dropDTR)
{
if (modemFd >= 0) {
if (dropDTR)
- (void) setDTR(FALSE); // force hangup
+ (void) setDTR(false); // force hangup
Sys::close(modemFd), modemFd = -1; // discard open file
}
delete modem, modem = NULL;
* abort request was made or if an external abort
* message is dispatched during our processing.
*/
-fxBool
+bool
ModemServer::abortRequested()
{
#ifndef SERVERABORTBUG
void
ModemServer::abortSession()
{
- abortCall = TRUE;
+ abortCall = true;
traceServer("ABORT: job abort requested");
}
* so cause jobs to be requeued).
*/
if (lockModem()) {
- fxBool modemReady = setupModem();
+ bool modemReady = setupModem();
unlockModem();
if (modemReady)
changeState(RUNNING, 0);
* are selected so that any imaged facsimile should
* still be sendable.
*/
-fxBool ModemServer::modemReady() const
+bool ModemServer::modemReady() const
{ return modem != NULL; }
-fxBool ModemServer::serverBusy() const
+bool ModemServer::serverBusy() const
{ return state != RUNNING; }
-fxBool ModemServer::modemWaitForRings(u_int rings, CallType& type, CallerID& cid)
+bool ModemServer::modemWaitForRings(u_int rings, CallType& type, CallerID& cid)
{ return modem->waitForRings(rings, type, cid); }
CallType ModemServer::modemAnswerCall(AnswerType atype, fxStr& emsg)
{ return modem->answerCall(atype, emsg); }
ModemServer::readConfig(const fxStr& filename)
{
dialRulesFile = "";
- delayConfig = TRUE;
+ delayConfig = true;
ServerConfig::readConfig(filename);
- delayConfig = FALSE;
+ delayConfig = false;
if (dialRulesFile != "")
setDialRules(dialRulesFile);
if (localIdentifier == "")
}
}
-fxBool
+bool
ModemServer::tcsetattr(int op, struct termios& term)
{
- fxBool ok;
+ bool ok;
if (clocalAsRoot) {
/*
* Gag, IRIX 5.2 and beyond permit only the super-user to
return ok;
}
-fxBool
+bool
ModemServer::tcgetattr(const char* method, struct termios& term)
{
if (::tcgetattr(modemFd, &term) != 0) {
traceModemOp("%s::tcgetattr: %m", method);
- return (FALSE);
+ return (false);
} else
- return (TRUE);
+ return (true);
}
/*
* Set tty port baud rate and flow control.
*/
-fxBool
+bool
ModemServer::setBaudRate(BaudRate rate, FlowControl iFlow, FlowControl oFlow)
{
if (rate >= NBAUDS)
baudRates[rate], flowNames[iFlow], flowNames[oFlow]);
struct termios term;
if (!tcgetattr("setBaudRate", term))
- return (FALSE);
+ return (false);
curRate = rate; // NB: for use elsewhere
term.c_oflag = 0;
term.c_lflag = 0;
/*
* Set tty port baud rate and leave flow control state unchanged.
*/
-fxBool
+bool
ModemServer::setBaudRate(BaudRate rate)
{
if (rate >= NBAUDS)
baudRates[rate]);
struct termios term;
if (!tcgetattr("setBaudRate", term))
- return (FALSE);
+ return (false);
curRate = rate; // NB: for use elsewhere
term.c_oflag = 0;
term.c_lflag = 0;
/*
* Set tty port parity and number of data bits
*/
-fxBool
+bool
ModemServer::setParity(Parity parity)
{
traceModemOp("set parity: %s", parityNames[parity]);
struct termios term;
if (!tcgetattr("setParity", term))
- return (FALSE);
+ return (false);
setParity(term, parity);
curParity = parity; // used above
flushModemInput();
* setting the baud rate to zero on some systems can cause
* strange side effects.
*/
-fxBool
-ModemServer::setDTR(fxBool onoff)
+bool
+ModemServer::setDTR(bool onoff)
{
traceModemOp("set DTR %s", onoff ? "ON" : "OFF");
#if defined(MCGETA) && defined(MCSETAF) && defined(MDTR)
else
mstat &= ~MDTR;
if (ioctl(modemFd, MCSETAF, &mstat) >= 0)
- return (TRUE);
+ return (true);
}
#elif defined(TIOCMBIS)
int mctl = TIOCM_DTR;
#else
if (ioctl(modemFd, onoff ? TIOCMBIS : TIOCMBIC, (char *)mctl) >= 0)
#endif
- return (TRUE);
+ return (true);
/*
* Sigh, Sun seems to support this ioctl only on *some*
* devices (e.g. on-board duarts, but not the ALM-2 card);
* on the usual way of doing things...
*/
#endif /* TIOCMBIS */
- return (onoff ? TRUE : setBaudRate(ClassModem::BR0));
+ return (onoff ? true : setBaudRate(ClassModem::BR0));
}
static const char* actNames[] = { "NOW", "DRAIN", "FLUSH" };
* XON/XOFF handling should be enabled so that any
* XON/XOFF from/to the modem will be interpreted.
*/
-fxBool
+bool
ModemServer::setXONXOFF(FlowControl iFlow, FlowControl oFlow, SetAction act)
{
traceModemOp("set XON/XOFF/%s: input %s, output %s",
);
struct termios term;
if (!tcgetattr("setXONXOFF", term))
- return (FALSE);
+ return (false);
setFlow(term, iFlow, oFlow);
if (act == ClassModem::ACT_FLUSH)
flushModemInput();
* that delays the delivery of input data from the UART module
* upstream to the tty module.
*/
-fxBool
-ModemServer::setInputBuffering(fxBool on)
+bool
+ModemServer::setInputBuffering(bool on)
{
traceModemOp("input buffering %s", on ? "enabled" : "disabled");
#ifdef SIOC_ITIMER
* the ALM-2, however, you are just plain out of luck unless
* you have source code.
*/
- static fxBool zsunbuf_push_tried = FALSE;
- static fxBool zsunbuf_push_ok = FALSE;
+ static bool zsunbuf_push_tried = false;
+ static bool zsunbuf_push_ok = false;
if (on) { // pop zsunbuf if present to turn on buffering
char topmodule[FMNAMESZ+1];
if (zsunbuf_push_ok && ioctl(modemFd, I_LOOK, topmodule) >= 0 &&
zsunbuf_push_ok = (ioctl(modemFd, I_PUSH, "zsunbuf") >= 0);
traceModemOp("initial push zsunbuf %s",
zsunbuf_push_ok ? "succeeded" : "failed");
- zsunbuf_push_tried = TRUE;
+ zsunbuf_push_tried = true;
} else if (zsunbuf_push_ok) {
if (ioctl(modemFd, I_PUSH, "zsunbuf") < 0)
traceModemOp("push zsunbuf failed: %m");
return (tcsetattr(TCSANOW, term));
}
-fxBool
-ModemServer::sendBreak(fxBool pause)
+bool
+ModemServer::sendBreak(bool pause)
{
traceModemOp("send break%s", pause ? " (pause)" : "");
flushModemInput();
}
if (tcsendbreak(modemFd, 0) != 0) {
traceModemOp("tcsendbreak: %m");
- return (FALSE);
+ return (false);
} else
- return (TRUE);
+ return (true);
}
void
ModemServer::startTimeout(long ms)
{
timer.startTimeout(ms);
- timeout = FALSE;
+ timeout = false;
}
void
traceModemOp("tcflush: %m");
}
-fxBool
+bool
ModemServer::modemStopOutput()
{
if (tcflow(modemFd, TCOOFF) != 0) {
traceModemOp("tcflow: %m");
- return (FALSE);
+ return (false);
} else
- return (TRUE);
+ return (true);
}
void
rcvCC = rcvNext = 0;
}
-fxBool
+bool
ModemServer::putModem(const void* data, int n, long ms)
{
traceStatus(FAXTRACE_MODEMCOM, "<-- data [%d]", n);
return (putModem1(data, n, ms));
}
-fxBool
+bool
ModemServer::putModem1(const void* data, int n, long ms)
{
if (ms)
startTimeout(ms);
else
- timeout = FALSE;
+ timeout = false;
int cc = Sys::write(modemFd, (const char*) data, n);
if (ms)
stopTimeout("writing to modem");
};
private:
FILE* statusFile; // server status file
- fxBool deduceComplain; // if true, complain when can't deduce
- fxBool changePriority; // change process priority by state
- fxBool delayConfig; // suppress effects while reading config
+ bool deduceComplain; // if true, complain when can't deduce
+ bool changePriority; // change process priority by state
+ bool delayConfig; // suppress effects while reading config
fxStr dialRulesFile; // dial string rules filename
fxStr commid; // communication ID
// generic modem-related stuff
fxStr modemDevID; // device identifier
ClassModem* modem; // modem driver
Timeout timer; // timeout support class
- fxBool timeout; // timeout during i/o operations
+ bool timeout; // timeout during i/o operations
fxStr configFile; // pathname to configuration file
BaudRate curRate; // current termio baud rate
Parity curParity; // current termio parity setting
static const char* stateNames[9];
static const char* stateStatus[9];
- fxBool openDevice(const char* dev);
- fxBool reopenDevice();
- fxBool tcsetattr(int op, struct termios& term);
- fxBool tcgetattr(const char* method, struct termios& term);
+ bool openDevice(const char* dev);
+ bool reopenDevice();
+ bool tcsetattr(int op, struct termios& term);
+ bool tcgetattr(const char* method, struct termios& term);
static void setFlow(struct termios&, FlowControl iflow, FlowControl oflow);
static void setParity(struct termios&, Parity);
LISTENING = 8
};
ModemServerState state;
- fxBool abortCall; // abort current send/receive
+ bool abortCall; // abort current send/receive
// logging and tracing
FaxMachineLog* log; // current log device
ModemServer(const fxStr& deviceName, const fxStr& devID);
// modem driver setup+teardown interfaces
- virtual fxBool setupModem();
- virtual void discardModem(fxBool dropDTR);
+ virtual bool setupModem();
+ virtual void discardModem(bool dropDTR);
virtual ClassModem* deduceModem();
// low-level modem interfaces
int getModemFd(); // XXX
int getModemLine(char buf[], u_int bufSize, long ms = 0);
int getModemChar(long ms = 0);
void flushModemInput();
- fxBool putModem(const void* data, int n, long ms = 0);
- fxBool putModem1(const void* data, int n, long ms = 0);
+ bool putModem(const void* data, int n, long ms = 0);
+ bool putModem1(const void* data, int n, long ms = 0);
void startTimeout(long ms);
void stopTimeout(const char* whichdir);
// modem line control
- fxBool sendBreak(fxBool pause);
- fxBool setBaudRate(BaudRate rate);
- fxBool setBaudRate(BaudRate rate, FlowControl i, FlowControl o);
- fxBool setParity(Parity parity);
- fxBool setXONXOFF(FlowControl i, FlowControl o, SetAction act);
- fxBool setDTR(fxBool on);
- fxBool setInputBuffering(fxBool on);
- fxBool modemStopOutput();
+ bool sendBreak(bool pause);
+ bool setBaudRate(BaudRate rate);
+ bool setBaudRate(BaudRate rate, FlowControl i, FlowControl o);
+ bool setParity(Parity parity);
+ bool setXONXOFF(FlowControl i, FlowControl o, SetAction act);
+ bool setDTR(bool on);
+ bool setInputBuffering(bool on);
+ bool modemStopOutput();
// modem driver interfaces
- fxBool modemWaitForRings(u_int rings, CallType&, CallerID&);
+ bool modemWaitForRings(u_int rings, CallType&, CallerID&);
CallType modemAnswerCall(AnswerType, fxStr&);
void modemAnswerCallCmd(CallType);
void modemFlushInput();
void traceModemOp(const char* fmt ...);
void traceStatus(int kind, const char* fmt ...);
// modem locking interfaces implemented in derived class
- virtual fxBool lockModem() = 0;
+ virtual bool lockModem() = 0;
virtual void unlockModem() = 0;
// notification interfaces implemented in derived class
virtual void notifyModemReady() = 0;
void endSession();
// abort send/receive session
virtual void abortSession();
- fxBool abortRequested();
+ bool abortRequested();
public:
virtual ~ModemServer();
int getServerTracing() const;
void vtraceStatus(int kind, const char* fmt, va_list ap);
- fxBool modemReady() const;
- fxBool serverBusy() const;
+ bool modemReady() const;
+ bool serverBusy() const;
};
inline ClassModem* ModemServer::getModem() { return modem; }
inline int ModemServer::getModemFd() { return modemFd; }
#define CONFIG_GLYPH 2 // glyphs must be word-aligned
#define CONFIG_GLYPH_IX 1 // index for word-aligned glyphs
-inline fxBool PCFFont::isFormat(u_long f) const
+inline bool PCFFont::isFormat(u_long f) const
{ return ((format&PCF_FORMAT_MASK) == f); }
inline u_int PCFFont::byteOrder() const
{ return ((format&PCF_BYTE_MASK) ? MSBFirst : LSBFirst); }
{
if (file != NULL)
fclose(file), file = NULL;
- ready = FALSE;
+ ready = false;
delete toc, toc = NULL;
delete encoding, encoding = NULL;
delete bitmaps, bitmaps = NULL;
* font metrics, font bitmaps, font encoding, and
* some of the accelerator info.
*/
-fxBool
+bool
PCFFont::read(const char* name)
{
cleanup();
file = fopen(filename, "r");
if (file == NULL) {
error("Can not open file");
- return (FALSE);
+ return (false);
}
if (!readTOC())
- return (FALSE);
+ return (false);
if (seekToTable(PCF_METRICS)) {
format = getLSB32();
if (isFormat(PCF_DEFAULT_FORMAT))
numGlyphs = getINT16();
else {
error("Bad font metric format 0x%lx", format);
- return (FALSE);
+ return (false);
}
metrics = new charInfo[numGlyphs];
if (!metrics) {
error("No space for font metric information");
- return (FALSE);
+ return (false);
}
for (int i = 0; i < numGlyphs; i++) {
if (isFormat(PCF_DEFAULT_FORMAT))
}
} else {
error("Can not seek to font metric information");
- return (FALSE);
+ return (false);
}
if (seekToTable(PCF_BITMAPS)) {
format = getLSB32();
if (!isFormat(PCF_DEFAULT_FORMAT)) {
error("Bad bitmap data format 0x%lx", format);
- return (FALSE);
+ return (false);
}
u_long nbitmaps = getINT32();
u_long* offsets = new u_long[nbitmaps];
if (!offsets) {
error("No space for bitmap offsets array");
- return (FALSE);
+ return (false);
}
int i;
for (i = 0; i < nbitmaps; i++)
if (!bitmaps) {
error("No space for bitmap data array");
delete offsets;
- return (FALSE);
+ return (false);
}
if (fread(bitmaps, (u_int) sizebitmaps, 1, file) != 1) {
error("Error reading bitmap data");
delete offsets;
- return (FALSE);
+ return (false);
}
if (bitOrder() != CONFIG_BIT)
TIFFReverseBits(bitmaps, sizebitmaps);
if (!padbitmaps) {
error("No space for padded bitmap data array");
delete offsets;
- return (FALSE);
+ return (false);
}
int newoff = 0;
for (i = 0; i < nbitmaps; i++) {
if ((unsigned) metrics[i].bits & 1) {
error("Internal error, bitmap data not word-aligned");
delete offsets;
- return (FALSE);
+ return (false);
}
}
delete offsets;
} else {
error("Can not seek to bitmap data");
- return (FALSE);
+ return (false);
}
if (seekToTable(PCF_BDF_ENCODINGS)) {
format = getLSB32();
if (!isFormat(PCF_DEFAULT_FORMAT)) {
error("Bad encodings format 0x%lx", format);
- return (FALSE);
+ return (false);
}
firstCol = getINT16();
lastCol = getINT16();
encoding = new charInfo*[nencoding];
if (!encoding) {
error("No space for character encoding vector");
- return (FALSE);
+ return (false);
}
for (int i = 0; i < nencoding; i++) {
int encodingOffset = getINT16();
}
} else {
error("Can not seek to encoding data");
- return (FALSE);
+ return (false);
}
if (seekToTable(PCF_BDF_ACCELERATORS)) {
if (!isFormat(PCF_DEFAULT_FORMAT) &&
!isFormat(PCF_ACCEL_W_INKBOUNDS)) {
error("Bad BDF accelerator format 0x%lx", format);
- return (FALSE);
+ return (false);
}
fseek(file, 8, SEEK_CUR); // skip a bunch of junk
fontAscent = (short) getINT32();
// more stuff...
} else {
error("Can not seek to BDF accelerator information");
- return (FALSE);
+ return (false);
}
fclose(file), file = NULL;
filename = NULL;
- return (ready = TRUE);
+ return (ready = true);
}
u_long
/*
* Position to the begining of the specified table.
*/
-fxBool
+bool
PCFFont::seekToTable(u_long type)
{
for (int i = 0; i < tocSize; i++)
if (toc[i].type == type) {
if (fseek(file, toc[i].offset, SEEK_SET) == -1) {
error("Can not seek; fseek failed");
- return (FALSE);
+ return (false);
}
format = toc[i].format;
- return (TRUE);
+ return (true);
}
error("Can not seek; no such entry in the TOC");
- return (FALSE);
+ return (false);
}
/*
* Read the table-of-contents for the font file.
*/
-fxBool
+bool
PCFFont::readTOC()
{
u_long version = getLSB32();
if (version != PCF_FILE_VERSION) {
error("Cannot read TOC; bad version number %lu", version);
- return (FALSE);
+ return (false);
}
tocSize = getLSB32();
toc = new PCFTableRec[tocSize];
if (!toc) {
error("Cannot read TOC; no space for %lu records", tocSize);
- return (FALSE);
+ return (false);
}
for (int i = 0; i < tocSize; i++) {
toc[i].type = getLSB32();
toc[i].size = getLSB32();
toc[i].offset = getLSB32();
}
- return (TRUE);
+ return (true);
}
int
u_long format; // format for current portion being read
PCFTableRec* toc; // table of contents
u_long tocSize; // number of entries in TOC
- fxBool isBigEndian; // host byte order
+ bool isBigEndian; // host byte order
void cleanup();
- fxBool readTOC();
- fxBool seekToTable(u_long type);
+ bool readTOC();
+ bool seekToTable(u_long type);
void getMetric(charInfo& metric);
void getCompressedMetric(charInfo& metric);
int repadBitmap(u_char* src, u_char* dst,
int getINT16();
int getINT8();
- fxBool isFormat(u_long f) const;
+ bool isFormat(u_long f) const;
u_int byteOrder() const;
u_int bitOrder() const;
u_int glyphPadIndex() const;
PCFFont();
~PCFFont();
- fxBool read(const char* filename);
+ bool read(const char* filename);
u_int charWidth(u_int) const;
void strWidth(const char* text, u_int& w, u_int& h) const;
void remove(void);
void insert(QLink& after);
- int isEmpty(void) const; // TRUE if list is empty (used on head)
- int isOnList(void) const; // TRUE if item is on list
+ int isEmpty(void) const; // true if list is empty (used on head)
+ int isOnList(void) const; // true if item is on list
};
inline int QLink::isEmpty(void) const { return next == this; }
inline int QLink::isOnList(void) const { return next != this; }
speakerVolume = ClassModem::QUIET; // default speaker volume
#ifdef sgi
- clocalAsRoot = TRUE; // under IRIX must be root to set CLOCAL
+ clocalAsRoot = true; // under IRIX must be root to set CLOCAL
#else
- clocalAsRoot = FALSE; // everywhere else anyone can do it
+ clocalAsRoot = false; // everywhere else anyone can do it
#endif
requeueTTS[ClassModem::OK] = 0;
requeueTTS[ClassModem::BUSY] = FAX_REQBUSY;
uucpLockDir, deviceName, uucpLockMode);
}
-fxBool
+bool
ServerConfig::checkACL(const fxStr& id, RegExArray* pats, fxBoolArray& accept)
{
if (pats != NULL) {
if ((*pats)[i]->Find(id))
return (accept[i]);
}
- return (FALSE); // NB: reject if no patterns!
+ return (false); // NB: reject if no patterns!
}
-fxBool
+bool
ServerConfig::isTSIOk(const fxStr& tsi)
{
updatePatterns(qualifyTSI, tsiPats, acceptTSI, lastTSIModTime);
- return (qualifyTSI == "" ? TRUE : checkACL(tsi, tsiPats, *acceptTSI));
+ return (qualifyTSI == "" ? true : checkACL(tsi, tsiPats, *acceptTSI));
}
/*
continue;
RegEx* re;
if (line[0] == '!') {
- accept->append(FALSE);
+ accept->append(false);
pats->append(re = new RegEx(line+1));
} else {
- accept->append(TRUE);
+ accept->append(true);
pats->append(re = new RegEx(line));
}
if (re->getErrorCode() > REG_NOMATCH) {
vlogWarning(fmt, ap);
}
-fxBool
+bool
ServerConfig::setConfigItem(const char* tag, const char* value)
{
u_int ix;
requeueTTS[ClassModem::DATACONN] = getNumber(value);
else
return ModemConfig::setConfigItem(tag, value);
- return (TRUE);
+ return (true);
}
#undef N
ServerConfig();
void setupConfig();
- virtual fxBool setConfigItem(const char* tag, const char* value);
+ virtual bool setConfigItem(const char* tag, const char* value);
// pattern access control list support
void updatePatterns(const fxStr& file,
RegExArray*& pats, fxBoolArray*& accept,
time_t& lastModTime);
void readPatterns(FILE*, RegExArray*&, fxBoolArray*&);
- fxBool checkACL(const fxStr& id, RegExArray*, fxBoolArray&);
+ bool checkACL(const fxStr& id, RegExArray*, fxBoolArray&);
// methods for parameters whose assignment may have side effects
virtual void setDialRules(const char* name);
virtual void setLocalIdentifier(const fxStr& lid);
u_int tracingLevel; // tracing level w/o session
u_int logTracingLevel; // tracing level during session
u_int tracingMask; // tracing level control mask
- fxBool clocalAsRoot; // set CLOCAL as root
+ bool clocalAsRoot; // set CLOCAL as root
u_int requeueTTS[9]; // requeue intervals[CallStatus code]
u_int requeueProto; // requeue interval after protocol error
u_int requeueOther; // requeue interval after other problem
UUCPLock* getUUCPLock(const fxStr& deviceName);
- fxBool isTSIOk(const fxStr& tsi);
+ bool isTSIOk(const fxStr& tsi);
virtual void vconfigError(const char* fmt, va_list ap) = 0;
virtual void vconfigTrace(const char* fmt, va_list ap) = 0;
* being cropped at the bottom; probably together with a decoding
* error of one row at the receiver.
*/
-fxBool
+bool
FaxModem::setupTagLineSlop(const Class2Params& params)
{
if (tagLineFont->isReady() && tagLineFields > 0) {
tagLineSlop = (tagLineFont->fontHeight()+MARGIN_TOP+MARGIN_BOT+3) *
howmany(params.pageWidth(),8);
- return (TRUE);
+ return (true);
} else {
tagLineSlop = 0;
- return (FALSE);
+ return (false);
}
}
* notified when job 1932 is requeued or completes one would
* use ``J<1932>4c60''.
*/
-fxBool
+bool
Trigger::parse(const char* spec0)
{
const char* spec = spec0;
for (tp = ++cp; *tp != '>'; tp++)
if (*tp == '\0') { // XXX syntax error
syntaxError(spec0, "missing '>'");
- return (FALSE);
+ return (false);
}
id = fxStr(cp, tp-cp);
cp = tp+1;
u_short& m = interests[base>>4];
if (m != 0) {
syntaxError(spec0, "interests conflict");
- return (FALSE);
+ return (false);
}
if (c == '*') {
m = 0xffff;
m = v;
} else {
syntaxError(spec0, "non-hex event mask");
- return (FALSE);
+ return (false);
}
TriggerRef* tr = new TriggerRef(*this);
/*
Job* job = Job::getJobByID(id);
if (!job) {
logError("TRIGGER: job %s does not exist", (const char*) id);
- return (FALSE);
+ return (false);
}
tr->insert(job->triggers);
}
spec = cp;
}
- return (TRUE);
+ return (true);
}
void
Trigger::syntaxError(const char* spec, const char* msg)
/*
* Cancel (delete) the trigger with the specified id.
*/
-fxBool
+bool
Trigger::cancel(const char* cp)
{
trid_t tid = (trid_t) strtoul(cp, NULL, 10);
if (t) {
if (t->cancel())
delete t;
- return (TRUE);
+ return (true);
}
}
- return (FALSE);
+ return (false);
}
/*
* posted to the client) and wait for the object holding
* the reference to go away.
*/
-fxBool
+bool
Trigger::cancel()
{
purgeWildRefs(); // wildcard references
if (refs == 0)
- return (TRUE);
+ return (true);
if (interests[MODEM_BASE>>4] != 0) {
/*
* Must explicitly search and purge references
for (ModemIter iter(Modem::list); iter.notDone(); iter++) {
TriggerRef::purge(iter.modem().triggers, this);
if (refs == 0)
- return (TRUE);
+ return (true);
}
}
// clear interests so no more messages are sent
memset(interests, 0, sizeof (interests));
- return (FALSE);
+ return (false);
}
/*
Trigger(trid_t, const fxStr& fifoName);
- fxBool parse(const char*); // parse trigger spec
+ bool parse(const char*); // parse trigger spec
static void syntaxError(const char* spec, const char* msg);
void purgeWildRefs(); // purge all wildcard references
- fxBool cancel();
+ bool cancel();
static void post(TriggerEvent, const QLink&, const QLink&, fxStackBuffer&);
void send(const char* fmt ...);
static void purgeClient(HylaClient*);// purge all triggers for client
static void create(const fxStr& id, const char* spec);
- static fxBool cancel(const char* tid);
+ static bool cancel(const char* tid);
static void post(TriggerEvent, const Job&, const char* = NULL);
static void post(TriggerEvent, const Modem&, const char* = NULL);
fxStr data; // data to write record in lock file
void setPID(pid_t);
- fxBool writeData(int fd);
- fxBool readData(int fd, pid_t& pid);
+ bool writeData(int fd);
+ bool readData(int fd, pid_t& pid);
public:
AsciiUUCPLock(const fxStr&, mode_t);
~AsciiUUCPLock();
pid_t data; // data to write record in lock file
void setPID(pid_t);
- fxBool writeData(int fd);
- fxBool readData(int fd, pid_t& pid);
+ bool writeData(int fd);
+ bool readData(int fd, pid_t& pid);
public:
BinaryUUCPLock(const fxStr&, mode_t);
~BinaryUUCPLock();
UUCPLock::UUCPLock(const fxStr& pathname, mode_t m) : file(pathname)
{
mode = m;
- locked = FALSE;
+ locked = false;
setupIDs();
}
/*
* Create a lock file.
*/
-fxBool
+bool
UUCPLock::create()
{
/*
* Check if the lock file is
* newer than the specified age.
*/
-fxBool
+bool
UUCPLock::isNewer(time_t age)
{
struct stat sb;
- return (Sys::stat(file, sb) != 0 ? FALSE : Sys::now() - sb.st_mtime < age);
+ return (Sys::stat(file, sb) != 0 ? false : Sys::now() - sb.st_mtime < age);
}
/*
* If it is older, an attempt is made to unlink it and
* create a new one.
*/
-fxBool
+bool
UUCPLock::lock()
{
if (locked)
- return (FALSE);
+ return (false);
uid_t ouid = geteuid();
seteuid(0); // need to be root
- fxBool ok = create();
+ bool ok = create();
if (!ok)
ok = check() && create();
seteuid(ouid);
seteuid(0); // need to be root
Sys::unlink(file);
seteuid(ouid);
- locked = FALSE;
+ locked = false;
}
}
* Set a particular owner process
* pid for an already locked device.
*/
-fxBool
+bool
UUCPLock::setOwner(pid_t pid)
{
- fxBool ok = FALSE;
+ bool ok = false;
if (locked) {
uid_t ouid = geteuid();
seteuid(0); // need to be root
/*
* Check if the owning process exists.
*/
-fxBool
+bool
UUCPLock::ownerExists(int fd)
{
pid_t pid;
* UUCPLock::lockTimeout seconds if the process owner
* is no longer around.
*/
-fxBool
+bool
UUCPLock::check()
{
int fd = Sys::open(file, O_RDONLY);
if (lockTimeout > 0) {
if (isNewer(lockTimeout) || ownerExists(fd)) {
Sys::close(fd);
- return (FALSE);
+ return (false);
}
Sys::close(fd);
logInfo("Purge stale UUCP lock %s", (const char*) file);
return (Sys::unlink(file) == 0);
} else {
Sys::close(fd);
- return (FALSE);
+ return (false);
}
}
- return (TRUE);
+ return (true);
}
/*
sprintf((char*) data, "%*d\n", UUCP_PIDDIGITS, pid);
}
-fxBool
+bool
AsciiUUCPLock::writeData(int fd)
{
return (Sys::write(fd, data, UUCP_PIDDIGITS+1) == (UUCP_PIDDIGITS+1));
}
-fxBool
+bool
AsciiUUCPLock::readData(int fd, pid_t& pid)
{
char buf[UUCP_PIDDIGITS+1];
if (Sys::read(fd, buf, UUCP_PIDDIGITS) == UUCP_PIDDIGITS) {
buf[UUCP_PIDDIGITS] = '\0';
pid = atol(buf); // NB: assumes pid_t is <= 32-bits
- return (TRUE);
+ return (true);
} else
- return (FALSE);
+ return (false);
}
/*
data = pid; // binary pid of lock holder
}
-fxBool
+bool
BinaryUUCPLock::writeData(int fd)
{
return (Sys::write(fd, (char*) &data, sizeof (data)) == sizeof (data));
}
-fxBool
+bool
BinaryUUCPLock::readData(int fd, pid_t& pid)
{
pid_t data;
if (Sys::read(fd, (char*) &data, sizeof (data)) == sizeof (data)) {
pid = data;
- return (TRUE);
+ return (true);
} else
- return (FALSE);
+ return (false);
}
private:
fxStr file; // lock file pathname
mode_t mode; // lock file mode
- fxBool locked; // is lock currently held
+ bool locked; // is lock currently held
static uid_t UUCPuid;
static gid_t UUCPgid;
static time_t lockTimeout;
- fxBool create(); // create lock file
- fxBool isNewer(time_t age); // is lock file newer than age
- fxBool ownerExists(int fd); // does owning process exist
+ bool create(); // create lock file
+ bool isNewer(time_t age); // is lock file newer than age
+ bool ownerExists(int fd); // does owning process exist
protected:
UUCPLock(const fxStr& pathname, mode_t mode);
virtual void setPID(pid_t) = 0;
- virtual fxBool writeData(int fd) = 0;
- virtual fxBool readData(int fd, pid_t& pid) = 0;
+ virtual bool writeData(int fd) = 0;
+ virtual bool readData(int fd, pid_t& pid) = 0;
public:
virtual ~UUCPLock();
const fxStr& device, // device pathname
mode_t mode); // file creation mode
- fxBool isLocked() const; // device is locked
- fxBool lock(); // lock device
+ bool isLocked() const; // device is locked
+ bool lock(); // lock device
void unlock(); // unlock device
- fxBool check(); // check if lock exists
- fxBool setOwner(pid_t); // force process owner identity
+ bool check(); // check if lock exists
+ bool setOwner(pid_t); // force process owner identity
};
-inline fxBool UUCPLock::isLocked() const { return locked; }
+inline bool UUCPLock::isLocked() const { return locked; }
#endif /* _UUCPLOCK_ */
return (*bp++);
}
-static fxBool
+static bool
isBlank(uint16* runs, u_int rowpixels)
{
u_int x = 0;
if ((x += *runs++) >= rowpixels)
break;
if (runs[0] != 0)
- return (FALSE);
+ return (false);
if ((x += *runs++) >= rowpixels)
break;
}
- return (TRUE);
+ return (true);
}
void
extern char* optarg;
float minChop = 3.0; // chop if >= 3" white space at bottom
u_int minRows;
- fxBool doAll = FALSE;
+ bool doAll = false;
int c;
appName = argv[0];
while ((c = getopt(argc, argv, "t:a")) != -1)
switch (c) {
case 'a':
- doAll = TRUE;
+ doAll = true;
break;
case 't':
minChop = atof(optarg);
struct CQDecoder : public G3Decoder {
u_int cblc; // current count of consecutive bad lines
- fxBool lastRowBad; // last decoded row was bad
+ bool lastRowBad; // last decoded row was bad
u_long recvEOLCount; // EOL count for received page
u_long recvBadLineCount;
void serverTrace(const char* fmt ...);
void copyQualityTrace(const char* fmt, ...);
- fxBool recvPageDLEData(TIFF* tif, fxBool checkQuality,
+ bool recvPageDLEData(TIFF* tif, bool checkQuality,
const Class2Params& params, fxStr& emsg);
void abortPageRecv();
int nextByte();
- fxBool checkQuality();
- fxBool isQualityOK(const Class2Params&);
+ bool checkQuality();
+ bool isQualityOK(const Class2Params&);
CQDecoder();
~CQDecoder();
* Receive Phase C data with or without copy
* quality checking and erroneous row fixup.
*/
-fxBool
-CQDecoder::recvPageDLEData(TIFF* tif, fxBool checkQuality,
+bool
+CQDecoder::recvPageDLEData(TIFF* tif, bool checkQuality,
const Class2Params& params, fxStr& emsg)
{
setupDecoder(recvFillOrder, params.is2D());
abortPageRecv();
emsg = "Missing EOL after 5 seconds";
recvTrace("%s", (const char*) emsg);
- return (FALSE);
+ return (false);
}
if (checkQuality) {
/*
memset(curGood, 0, rowSize); // initialize to all white
recvBuf = NULL; // don't need raw data
- lastRowBad = FALSE; // no previous row
+ lastRowBad = false; // no previous row
cblc = 0; // current bad line run
if (!RTCraised()) {
for (;;) {
* later for deciding whether or not the page quality
* is acceptable.
*/
- fxBool decodeOK = decodeRow(recvRow, rowpixels);
+ bool decodeOK = decodeRow(recvRow, rowpixels);
if (seenRTC()) // seen RTC, flush everything
continue;
if (decodeOK) {
curGood = recvRow; // reset last good
if (lastRowBad) { // reset run statistics
- lastRowBad = FALSE;
+ lastRowBad = false;
if (cblc > recvConsecutiveBadLineCount)
recvConsecutiveBadLineCount = cblc;
cblc = 0;
memcpy(recvRow, curGood, rowSize);// replicate last good
recvBadLineCount++;
cblc++;
- lastRowBad = TRUE;
+ lastRowBad = true;
}
/*
* Advance forward a scanline and if necessary
recvEOLCount = getRTCRow();
}
}
- return (TRUE);
+ return (true);
}
void
* Check if the configuration parameters indicate if
* copy quality checking should be done on recvd pages.
*/
-fxBool
+bool
CQDecoder::checkQuality()
{
return (percentGoodLines != 0 && maxConsecutiveBadLines != 0);
* against the configuration parameters and return an
* indication of whether or not the page quality is acceptable.
*/
-fxBool
+bool
CQDecoder::isQualityOK(const Class2Params& params)
{
if (percentGoodLines != 0 && recvEOLCount != 0) {
if (percent < percentGoodLines) {
serverTrace("RECV: REJECT page quality, %u%% good lines (%u%% required)",
percent, percentGoodLines);
- return (FALSE);
+ return (false);
}
}
u_int cblc = maxConsecutiveBadLines;
if (recvConsecutiveBadLineCount > cblc) {
serverTrace("RECV: REJECT page quality, %u-line run (max %u)",
recvConsecutiveBadLineCount, cblc);
- return (FALSE);
+ return (false);
}
}
- return (TRUE);
+ return (true);
}
int
faxApp::faxApp()
{
- running = FALSE;
+ running = false;
faxqfifo = -1;
setLogFacility(LOG_FAX); // default
#ifdef LC_CTYPE
{
openFIFOs();
}
-void faxApp::open(void) { running = TRUE; }
+void faxApp::open(void) { running = true; }
void
faxApp::close(void)
{
- running = FALSE;
+ running = false;
if (faxqfifo != -1)
Sys::close(faxqfifo);
}
* Open the specified FIFO file.
*/
int
-faxApp::openFIFO(const char* fifoName, int mode, fxBool okToExist)
+faxApp::openFIFO(const char* fifoName, int mode, bool okToExist)
{
if (Sys::mkfifo(fifoName, mode & 0777) < 0) {
if (errno != EEXIST || !okToExist)
/*
* Send a message to the central queuer process.
*/
-fxBool
+bool
faxApp::vsendQueuer(const char* fmt, va_list ap)
{
if (faxqfifo == -1) {
faxqfifo = Sys::open(fifoName, O_WRONLY|O_NDELAY);
#endif
if (faxqfifo == -1)
- return (FALSE);
+ return (false);
/*
* Turn off O_NDELAY so that write will block if FIFO is full.
*/
Sys::close(faxqfifo), faxqfifo = -1;
else
logError("FIFO write failed: %m");
- return (FALSE);
+ return (false);
} else
- return (TRUE);
+ return (true);
}
/*
* Send a message to the central queuer process.
*/
-fxBool
+bool
faxApp::sendQueuer(const char* fmt ...)
{
va_list ap;
va_start(ap, fmt);
- fxBool ok = vsendQueuer(fmt, ap);
+ bool ok = vsendQueuer(fmt, ap);
va_end(ap);
return (ok);
}
/*
* Send a modem status message to the central queuer process.
*/
-fxBool
+bool
faxApp::sendModemStatus(const char* devid, const char* fmt0 ...)
{
char fmt[2*1024];
sprintf(fmt, "+%s:%s", devid, fmt0);
va_list ap;
va_start(ap, fmt0);
- fxBool ok = vsendQueuer(fmt, ap);
+ bool ok = vsendQueuer(fmt, ap);
va_end(ap);
return (ok);
}
/*
* Send a job status message to the central queuer process.
*/
-fxBool
+bool
faxApp::sendJobStatus(const char* jobid, const char* fmt0 ...)
{
char fmt[2*1024];
sprintf(fmt, "*%s:%s", jobid, fmt0);
va_list ap;
va_start(ap, fmt0);
- fxBool ok = vsendQueuer(fmt, ap);
+ bool ok = vsendQueuer(fmt, ap);
va_end(ap);
return (ok);
}
/*
* Send a receive status message to the central queuer process.
*/
-fxBool
+bool
faxApp::sendRecvStatus(const char* devid, const char* fmt0 ...)
{
char fmt[2*1024];
sprintf(fmt, "@%s:%s", devid, fmt0);
va_list ap;
va_start(ap, fmt0);
- fxBool ok = vsendQueuer(fmt, ap);
+ bool ok = vsendQueuer(fmt, ap);
va_end(ap);
return (ok);
}
* is so that programs like sendmail show an informative
* from address.
*/
-fxBool
-faxApp::runCmd(const char* cmd, fxBool changeIDs)
+bool
+faxApp::runCmd(const char* cmd, bool changeIDs)
{
pid_t pid = fork();
switch (pid) {
_exit(127);
case -1:
logError("Can not fork for \"%s\"", cmd);
- return (FALSE);
+ return (false);
default:
{ int status = 0;
Sys::waitpid(pid, status);
if (status != 0) {
logError("Bad exit status %#o for \"%s\"", status, cmd);
- return (FALSE);
+ return (false);
}
}
- return (TRUE);
+ return (true);
}
}
private:
static fxStr getopts; // main arguments
- fxBool running; // server running
+ bool running; // server running
int faxqfifo; // cached descriptor to faxq
protected:
int openFIFO(const char* fifoName, int mode,
- fxBool okToExist = FALSE);
+ bool okToExist = false);
public:
faxApp();
virtual ~faxApp();
virtual void open(void);
virtual void close(void);
- fxBool isRunning(void) const;
+ bool isRunning(void) const;
virtual void openFIFOs(void);
virtual void closeFIFOs(void);
virtual int FIFOInput(int);
virtual void FIFOMessage(const char* mesage);
- fxBool sendModemStatus(const char* devid, const char* fmt ...);
- fxBool sendJobStatus(const char* jobid, const char* fmt ...);
- fxBool sendRecvStatus(const char* devid, const char* fmt ...);
- fxBool sendQueuer(const char* fmt ...);
- fxBool vsendQueuer(const char* fmt, va_list ap);
+ bool sendModemStatus(const char* devid, const char* fmt ...);
+ bool sendJobStatus(const char* jobid, const char* fmt ...);
+ bool sendRecvStatus(const char* devid, const char* fmt ...);
+ bool sendQueuer(const char* fmt ...);
+ bool vsendQueuer(const char* fmt, va_list ap);
static void setOpts(const char*);
static const fxStr& getOpts(void);
static const fxStr quote;
static const fxStr enquote;
- fxBool runCmd(const char* cmd, fxBool changeIDs = FALSE);
+ bool runCmd(const char* cmd, bool changeIDs = false);
};
-inline fxBool faxApp::isRunning(void) const { return running; }
+inline bool faxApp::isRunning(void) const { return running; }
class GetoptIter {
private:
void operator++();
void operator++(int);
int option() const;
- fxBool notDone() const;
+ bool notDone() const;
const char* optArg() const;
const char* getArg();
const char* nextArg();
};
inline int GetoptIter::option() const { return c; }
-inline fxBool GetoptIter::notDone() const { return c != -1; }
+inline bool GetoptIter::notDone() const { return c != -1; }
extern const char* fmtTime(time_t);
#endif
}
}
-fxBool faxGettyApp::lockModem() { return modemLock->lock(); }
+bool faxGettyApp::lockModem() { return modemLock->lock(); }
void faxGettyApp::unlockModem() { modemLock->unlock(); }
-fxBool faxGettyApp::isModemLocked() { return modemLock->isLocked(); }
+bool faxGettyApp::isModemLocked() { return modemLock->isLocked(); }
-fxBool
+bool
faxGettyApp::setupModem()
{
/*
* If the server is configured, listen for incoming calls.
*/
setRingsBeforeAnswer(ringsBeforeAnswer);
- return (TRUE);
+ return (true);
} else
- return (FALSE);
+ return (false);
}
/*
* Discard any handle on the modem.
*/
void
-faxGettyApp::discardModem(fxBool dropDTR)
+faxGettyApp::discardModem(bool dropDTR)
{
int fd = getModemFd();
if (fd >= 0) {
* state where we wait for the modem to come available again.
*/
traceServer("ANSWER: Can not lock modem device");
- discardModem(FALSE);
+ discardModem(false);
changeState(LOCKWAIT, pollLockWait);
sendModemStatus("U");
}
* Discard our handle on the modem and change to LOCKWAIT
* state where we wait for the modem to come available again.
*/
- discardModem(FALSE);
+ discardModem(false);
changeState(LOCKWAIT, pollLockWait);
sendModemStatus("U");
}
* adaptive-answer is enabled and ``any'' is requested,
* then rotate through the set of possibilities.
*/
- fxBool callResolved;
- fxBool advanceRotary = TRUE;
+ bool callResolved;
+ bool advanceRotary = true;
fxStr emsg;
if (!isCIDOk(cid.number)) { // check Caller ID if present
/*
* Call was rejected based on Caller ID information.
*/
traceServer("ANSWER: CID REJECTED");
- callResolved = FALSE;
- advanceRotary = FALSE;
+ callResolved = false;
+ advanceRotary = false;
} else if (ctype != ClassModem::CALLTYPE_UNKNOWN) {
/*
* Distinctive ring or other means has already identified
"but told to answer as %s; call ignored",
ClassModem::callTypes[ctype],
ClassModem::answerTypes[atype]);
- callResolved = FALSE;
- advanceRotary = FALSE;
+ callResolved = false;
+ advanceRotary = false;
} else {
// NB: answer based on ctype, not atype
ctype = modemAnswerCall(ctype, emsg);
{
if (modemReady()) {
modemHangup();
- discardModem(TRUE);
+ discardModem(true);
}
- fxBool isSetup;
+ bool isSetup;
if (isModemLocked() || lockModem()) {
isSetup = setupModem();
unlockModem();
} else
- isSetup = FALSE;
+ isSetup = false;
if (isSetup)
changeState(RUNNING);
else
* comes up with. Otherwise we use whatever deduction
* the modem layer arrives at as the call type.
*/
-fxBool
+bool
faxGettyApp::answerCall(AnswerType atype, CallType& ctype, fxStr& emsg)
{
- fxBool callResolved;
+ bool callResolved;
if (atype == ClassModem::ANSTYPE_EXTERN) {
if (egettyArgs != "") {
/*
* then we take action based on the returned call type.
*/
ctype = runGetty("EXTERN GETTY", OSnewEGetty,
- egettyArgs, emsg, lockExternCalls, TRUE);
+ egettyArgs, emsg, lockExternCalls, true);
if (ctype == ClassModem::CALLTYPE_DONE) // NB: call completed
- return (TRUE);
+ return (true);
if (ctype != ClassModem::CALLTYPE_ERROR)
modemAnswerCallCmd(ctype);
} else
* it removes the modem lock file and reconditions the modem for
* incoming calls (if configured).
*/
-fxBool
+bool
faxGettyApp::processCall(CallType ctype, fxStr& emsg)
{
- fxBool callHandled = FALSE;
+ bool callHandled = false;
switch (ctype) {
case ClassModem::CALLTYPE_FAX:
sendModemStatus("e");
} else
traceServer("ANSWER: Data connections are not permitted");
- callHandled = TRUE;
+ callHandled = true;
break;
case ClassModem::CALLTYPE_VOICE:
traceServer("ANSWER: VOICE CONNECTION");
sendModemStatus("w");
} else
traceServer("ANSWER: Voice connections are not permitted");
- callHandled = TRUE;
+ callHandled = true;
break;
case ClassModem::CALLTYPE_ERROR:
traceServer("ANSWER: %s", (const char*) emsg);
Getty* (*newgetty)(const fxStr&, const fxStr&),
const char* args,
fxStr& emsg,
- fxBool keepLock,
- fxBool keepModem
+ bool keepLock,
+ bool keepModem
)
{
fxStr prefix(_PATH_DEV);
*/
if (!keepLock)
unlockModem();
- fxBool parentIsInit = (getppid() == 1);
+ bool parentIsInit = (getppid() == 1);
pid_t pid = fork();
if (pid == -1) {
emsg = fxStr::format("%s: can not fork: %s", what, strerror(errno));
* SIGHUP on last close.
*/
if (!keepModem)
- discardModem(FALSE);
+ discardModem(false);
changeState(GETTYWAIT);
int status;
- getty->wait(status, TRUE); // wait for getty/login work to complete
+ getty->wait(status, true); // wait for getty/login work to complete
/*
* Retake ownership of the modem. Note that there's
* a race in here (another process could come along
}
}
-fxBool
+bool
faxGettyApp::isCIDOk(const fxStr& cid)
{
updatePatterns(qualifyCID, cidPats, acceptCID, lastCIDModTime);
- return (qualifyCID == "" ? TRUE : checkACL(cid, cidPats, *acceptCID));
+ return (qualifyCID == "" ? true : checkACL(cid, cidPats, *acceptCID));
}
/*
);
traceServer("RECV FAX: %s", (const char*) cmd);
setProcessPriority(BASE); // lower priority
- runCmd(cmd, TRUE);
+ runCmd(cmd, true);
setProcessPriority(state); // restore priority
}
/*
* Send a modem status message to the central queuer process.
*/
-fxBool
+bool
faxGettyApp::sendModemStatus(const char* msg)
{
return faxApp::sendModemStatus(getModemDeviceID(), msg);
void
faxGettyApp::openFIFOs()
{
- devfifo = openFIFO(fifoName | "." | getModemDeviceID(), 0600, TRUE);
+ devfifo = openFIFO(fifoName | "." | getModemDeviceID(), 0600, true);
Dispatcher::instance().link(devfifo, Dispatcher::ReadMask, this);
}
{ "answerbias", &faxGettyApp::answerBias, (u_int) -1 },
};
const faxGettyApp::booltag faxGettyApp::booleans[] = {
-{ "adaptiveanswer", &faxGettyApp::adaptiveAnswer, FALSE },
-{ "lockdatacalls", &faxGettyApp::lockDataCalls, TRUE },
-{ "lockvoicecalls", &faxGettyApp::lockVoiceCalls, TRUE },
-{ "lockexterncalls", &faxGettyApp::lockExternCalls, TRUE },
+{ "adaptiveanswer", &faxGettyApp::adaptiveAnswer, false },
+{ "lockdatacalls", &faxGettyApp::lockDataCalls, true },
+{ "lockvoicecalls", &faxGettyApp::lockVoiceCalls, true },
+{ "lockexterncalls", &faxGettyApp::lockExternCalls, true },
};
void
setAnswerRotary("any"); // answer calls as ``any''
}
-fxBool
+bool
faxGettyApp::setConfigItem(const char* tag, const char* value)
{
u_int ix;
}
} else
return (FaxServer::setConfigItem(tag, value));
- return (TRUE);
+ return (true);
}
#undef N
};
struct booltag {
const char* name;
- fxBool faxGettyApp::*p;
+ bool faxGettyApp::*p;
u_int def;
};
private:
fxStr gettyArgs; // getty arguments
fxStr vgettyArgs; // voice getty arguments
fxStr egettyArgs; // extern getty arguments
- fxBool adaptiveAnswer; // answer as data if fax answer fails
- fxBool lockDataCalls; // hold uucp lock for getty
- fxBool lockVoiceCalls; // hold uucp lock for vgetty
- fxBool lockExternCalls; // hold uucp lock for egetty
+ bool adaptiveAnswer; // answer as data if fax answer fails
+ bool lockDataCalls; // hold uucp lock for getty
+ bool lockVoiceCalls; // hold uucp lock for vgetty
+ bool lockExternCalls; // hold uucp lock for egetty
u_int answerBias; // rotor bias applied after good calls
u_short answerRotor; // rotor into possible selections
u_short answerRotorSize; // rotor table size
// configuration support
void setupConfig();
void resetConfig();
- fxBool setConfigItem(const char* tag, const char* value);
+ bool setConfigItem(const char* tag, const char* value);
void setAnswerRotary(const fxStr& value);
// modem handling
- fxBool isModemLocked();
- fxBool lockModem();
+ bool isModemLocked();
+ bool lockModem();
void unlockModem();
- fxBool setupModem();
- void discardModem(fxBool dropDTR);
+ bool setupModem();
+ void discardModem(bool dropDTR);
// inbound call handling
- fxBool isCIDOk(const fxStr& cid);
- fxBool processCall(CallType ctype, fxStr& emsg);
+ bool isCIDOk(const fxStr& cid);
+ bool processCall(CallType ctype, fxStr& emsg);
CallType runGetty(const char* what,
Getty* (*newgetty)(const fxStr&, const fxStr&),
const char* args, fxStr &emsg,
- fxBool keepLock, fxBool keepModem = FALSE);
+ bool keepLock, bool keepModem = false);
void setRingsBeforeAnswer(int rings);
void listenBegin();
void listenForRing();
void answerPhoneCmd(AnswerType);
void answerPhone(AnswerType, CallType, const CallerID&);
void answerCleanup();
- fxBool answerCall(AnswerType atype, CallType& ctype, fxStr& emsg);
+ bool answerCall(AnswerType atype, CallType& ctype, fxStr& emsg);
friend void AnswerTimeoutHandler::timerExpired(long, long);
// miscellaneous stuff
- fxBool sendModemStatus(const char* msg);
+ bool sendModemStatus(const char* msg);
// FIFO-related stuff
void openFIFOs();
void closeFIFOs();
class faxQCleanApp : public faxApp {
private:
- fxBool archiving; // enable archival support
- fxBool verbose; // trace interesting actions
- fxBool trace; // trace all actions
- fxBool nowork; // do not carry out actions
+ bool archiving; // enable archival support
+ bool verbose; // trace interesting actions
+ bool trace; // trace all actions
+ bool nowork; // do not carry out actions
time_t minJobAge; // threshold for processing done jobs
time_t minDocAge; // threshold for purging unref'd docs
void setJobAge(const char*);
void setDocAge(const char*);
- void setArchiving(fxBool);
- void setVerbose(fxBool);
- void setTracing(fxBool);
- void setNoWork(fxBool);
+ void setArchiving(bool);
+ void setVerbose(bool);
+ void setTracing(bool);
+ void setNoWork(bool);
};
const fxStr faxQCleanApp::archDir = FAX_ARCHDIR;
{
minJobAge = 15*60; // jobs kept max 15 minutes in doneq
minDocAge = 60*60; // 1 hour threshold on keeping unref'd documents
- archiving = FALSE; // default is to disable job archiving
- verbose = FALSE; // log actions to stdout
- nowork = FALSE; // default is to carry out work
- trace = FALSE; // trace work
+ archiving = false; // default is to disable job archiving
+ verbose = false; // log actions to stdout
+ nowork = false; // default is to carry out work
+ trace = false; // trace work
qFilePrefix = FAX_SENDDIR "/q";
}
{ minJobAge = (time_t) strtoul(s, NULL, 0); }
void faxQCleanApp::setDocAge(const char* s)
{ minDocAge = (time_t) strtoul(s, NULL, 0); }
-void faxQCleanApp::setArchiving(fxBool b) { archiving = b; }
-void faxQCleanApp::setVerbose(fxBool b) { verbose = b; }
-void faxQCleanApp::setTracing(fxBool b) { trace = b; }
-void faxQCleanApp::setNoWork(fxBool b) { nowork = b; }
+void faxQCleanApp::setArchiving(bool b) { archiving = b; }
+void faxQCleanApp::setVerbose(bool b) { verbose = b; }
+void faxQCleanApp::setTracing(bool b) { trace = b; }
+void faxQCleanApp::setNoWork(bool b) { nowork = b; }
void
faxQCleanApp::run(void)
{
if (trace)
- verbose = TRUE;
+ verbose = true;
scanDirectory();
expungeCruft();
}
if (fd >= 0) {
if (flock(fd, LOCK_SH|LOCK_NB) >= 0) {
FaxRequest* req = new FaxRequest(filename, fd);
- fxBool reject;
+ bool reject;
if (req->readQFile(reject) && !reject) {
if (now - sb.st_mtime < minJobAge) {
/*
fxStr queueDir(FAX_SPOOLDIR);
for (GetoptIter iter(argc, argv, faxApp::getOpts()); iter.notDone(); iter++)
switch (iter.option()) {
- case 'a': app.setArchiving(TRUE); break;
+ case 'a': app.setArchiving(true); break;
case 'j': app.setJobAge(optarg); break;
case 'd': app.setDocAge(optarg); break;
- case 'n': app.setNoWork(TRUE); break;
+ case 'n': app.setNoWork(true); break;
case 'q': queueDir = iter.optArg(); break;
- case 't': app.setTracing(TRUE); break;
- case 'v': app.setVerbose(TRUE); break;
+ case 't': app.setTracing(true); break;
+ case 'v': app.setVerbose(true); break;
case '?': usage(appName);
}
if (Sys::chdir(queueDir) < 0) {
#define JOBHASH(pri) (((pri) >> 4) & (NQHASH-1))
-faxQueueApp::SchedTimeout::SchedTimeout() { started = FALSE; }
+faxQueueApp::SchedTimeout::SchedTimeout() { started = false; }
faxQueueApp::SchedTimeout::~SchedTimeout() {}
void
faxQueueApp::SchedTimeout::timerExpired(long, long)
{
- started = FALSE;
+ started = false;
faxQueueApp::instance().runScheduler();
}
{
if (!started) {
Dispatcher::instance().startTimer(0,1, this);
- started = TRUE;
+ started = true;
}
}
: configFile(FAX_CONFIG)
{
fifo = -1;
- quit = FALSE;
+ quit = false;
dialRules = NULL;
setupConfig();
}
for (dirent* dp = readdir(dir); dp; dp = readdir(dir)) {
if (dp->d_name[0] == 'q')
- submitJob(&dp->d_name[1], TRUE);
+ submitJob(&dp->d_name[1], true);
}
closedir(dir);
}
if (!prepareJobNeeded(job, *req, status)) {
if (status != Job::done) {
job.state = FaxRequest::state_done;
- deleteRequest(job, req, status, TRUE);
+ deleteRequest(job, req, status, true);
setDead(job);
} else
sendJobStart(job, req, dci);
* cover page must be crafted (i.e. the work may take
* a while).
*/
-fxBool
+bool
faxQueueApp::prepareJobNeeded(Job& job, FaxRequest& req, JobStatus& status)
{
for (u_int i = 0, n = req.requests.length(); i < n; i++)
case FaxRequest::send_postscript: // convert PostScript
case FaxRequest::send_pcl: // convert PCL
case FaxRequest::send_tiff: // verify&possibly convert TIFF
- return (TRUE);
+ return (true);
case FaxRequest::send_poll: // verify modem is capable
if (!job.modem->supportsPolling()) {
req.notice = "Modem does not support polling";
status = Job::rejected;
jobError(job, "SEND REJECT: " | req.notice);
- return (FALSE);
+ return (false);
}
break;
}
{
signal(s, fxSIGHANDLER(faxQueueApp::prepareCleanup));
logError("CAUGHT SIGNAL %d, ABORT JOB PREPARATION", s);
- faxQueueApp::instance().abortPrepare = TRUE;
+ faxQueueApp::instance().abortPrepare = true;
}
/*
FaxMachineInfo& info, const DestControlInfo& dci)
{
traceQueue(job, "PREPARE START");
- abortPrepare = FALSE;
+ abortPrepare = false;
pid_t pid = fork();
switch (pid) {
case 0: // child, do work
} else
status >>= 8;
if (job.suspendPending) { // co-thread waiting
- job.suspendPending = FALSE;
+ job.suspendPending = false;
releaseModem(job);
return;
}
sendJobStart(job, req, destCtrls[job.dest]);
break;
default: // problem preparing job
- deleteRequest(job, req, status, TRUE);
+ deleteRequest(job, req, status, true);
setDead(job);
break;
}
* using the parameter selected above.
*/
JobStatus status = Job::done;
- fxBool updateQFile = FALSE;
+ bool updateQFile = false;
fxStr tmp; // NB: here to avoid compiler complaint
u_int i = 0;
while (i < req.requests.length() && status == Job::done && !abortPrepare) {
req.insertFax(i+1, tmp);
} else
Sys::unlink(tmp); // bail out
- updateQFile = TRUE;
+ updateQFile = true;
break;
}
i++;
* fatal; perhaps this should be configurable?
*/
makeCoverPage(job, req, params, dci);
- updateQFile = TRUE;
+ updateQFile = true;
}
if (req.pagehandling == "" && !abortPrepare) {
/*
status = Job::rejected; // XXX
req.notice.insert("Document preparation failed: ");
}
- updateQFile = TRUE;
+ updateQFile = true;
}
}
if (updateQFile)
* be slow and there can be timing problems if this
* is done during transmission.
*/
-fxBool
+bool
faxQueueApp::preparePageHandling(FaxRequest& req,
const FaxMachineInfo& info, const DestControlInfo& dci, fxStr& emsg)
{
}
done:
req.pagehandling.append('P'); // EOP
- return (TRUE);
+ return (true);
bad:
if (tif)
TIFFClose(tif);
- return (FALSE);
+ return (false);
}
/*
return (*bp++);
}
-static fxBool
+static bool
isBlank(uint16* runs, u_int rowpixels)
{
u_int x = 0;
if ((x += *runs++) >= rowpixels)
break;
if (runs[0] != 0)
- return (FALSE);
+ return (false);
if ((x += *runs++) >= rowpixels)
break;
}
- return (TRUE);
+ return (true);
}
void
* is an error -- this is sent back to the user that
* submitted the job.
*/
-fxBool
+bool
faxQueueApp::runConverter1(Job& job, int fd, fxStr& output)
{
int n;
if (timer.wasTimeout()) {
jobError(job, "CONVERT DOCUMENT: job time limit exceeded");
output.append("\n[Job time limit exceeded]\n");
- return (FALSE);
+ return (false);
} else
- return (TRUE);
+ return (true);
}
/*
| " " | freq.item
);
traceQueue(job, "COVER PAGE: " | cmd);
- if (runCmd(cmd, TRUE)) {
+ if (runCmd(cmd, true)) {
fxStr emsg;
fxStr tmp = freq.item | ";" | params.encodePage();
if (convertDocument(job, freq, tmp, params, dci, emsg)) {
*/
fxAssert(!job.suspendPending, "Interrupted job timed out");
job.state = FaxRequest::state_done;
- deleteRequest(job, req, Job::timedout, TRUE);
+ deleteRequest(job, req, Job::timedout, true);
setDead(job);
} else if (req->status == send_retry) {
/*
setReadyToRun(job); // NB: job.tts will be <= now
}
} else // signal waiting co-thread
- job.suspendPending = FALSE;
+ job.suspendPending = false;
delete req; // implicit unlock of q file
} else {
job.state = FaxRequest::state_done;
Trigger::post(Trigger::SEND_DONE, job);
// NB: always notify client if job failed
if (req->status == send_failed)
- deleteRequest(job, req, Job::failed, TRUE, fmtTime(duration));
+ deleteRequest(job, req, Job::failed, true, fmtTime(duration));
else
- deleteRequest(job, req, Job::done, FALSE, fmtTime(duration));
+ deleteRequest(job, req, Job::done, false, fmtTime(duration));
setDead(job);
}
}
faxQueueApp::setDead(Job& job)
{
job.state = FaxRequest::state_done;
- job.suspendPending = FALSE;
+ job.suspendPending = false;
traceJob(job, "DEAD");
Trigger::post(Trigger::JOB_DEAD, job);
DestInfo& di = destJobs[job.dest];
* appropriate queue. A kill timer is also setup
* for the job.
*/
-fxBool
-faxQueueApp::submitJob(FaxRequest& req, fxBool checkState)
+bool
+faxQueueApp::submitJob(FaxRequest& req, bool checkState)
{
Job* job = new Job(req);
traceJob(*job, "CREATE");
return (submitJob(*job, req, checkState));
}
-fxBool
-faxQueueApp::submitJob(Job& job, FaxRequest& req, fxBool checkState)
+bool
+faxQueueApp::submitJob(Job& job, FaxRequest& req, bool checkState)
{
/*
* Check various submission parameters. We setup the
req.external = req.number;
rejectSubmission(job, req,
"REJECT: Unable to convert dial string to canonical format");
- return (FALSE);
+ return (false);
}
time_t now = Sys::now();
if (req.killtime <= now) {
timeoutJob(job, req);
- return (FALSE);
+ return (false);
}
if (!Modem::modemExists(req.modem) && !ModemGroup::find(req.modem)) {
rejectSubmission(job, req,
"REJECT: Requested modem " | req.modem | " is not registered");
- return (FALSE);
+ return (false);
}
if (req.requests.length() == 0) {
rejectSubmission(job, req, "REJECT: No work found in job file");
- return (FALSE);
+ return (false);
}
if (req.pagewidth > 303) {
rejectSubmission(job, req,
fxStr::format("REJECT: Page width (%u) appears invalid",
req.pagewidth));
- return (FALSE);
+ return (false);
}
/*
* Verify the killtime is ``reasonable''; otherwise
rejectSubmission(job, req,
fxStr::format("REJECT: Job expiration time (%u) appears invalid",
req.killtime));
- return (FALSE);
+ return (false);
}
if (checkState) {
/*
switch (req.state) {
case FaxRequest::state_suspended:
setSuspend(job);
- return (TRUE);
+ return (true);
case FaxRequest::state_done:
setDead(job);
- return (TRUE);
+ return (true);
}
}
/*
rejectSubmission(job, req,
fxStr::format("REJECT: Time-to-send (%u) appears invalid",
req.tts));
- return (FALSE);
+ return (false);
}
job.startKillTimer(req.killtime);
job.state = FaxRequest::state_pending;
setReadyToRun(job);
}
updateRequest(req, job);
- return (TRUE);
+ return (true);
}
/*
req.status = send_failed;
req.notice = reason;
traceServer("JOB " | job.jobid | ": " | reason);
- deleteRequest(job, req, Job::rejected, TRUE);
+ deleteRequest(job, req, Job::rejected, true);
setDead(job); // dispose of job
}
* and we wait for the process to stop before
* returning to the caller.
*/
-fxBool
-faxQueueApp::suspendJob(Job& job, fxBool abortActive)
+bool
+faxQueueApp::suspendJob(Job& job, bool abortActive)
{
if (job.suspendPending) // already being suspended
- return (FALSE);
+ return (false);
switch (job.state) {
case FaxRequest::state_active:
/*
* to terminate the process completion work will not
* mistakenly terminate the job (see sendJobDone).
*/
- job.suspendPending = TRUE; // mark thread waiting
+ job.suspendPending = true; // mark thread waiting
if (abortActive)
(void) kill(job.pid, SIGTERM); // signal subprocess
job.stopKillTimer();
break;
/* fall thru... */
case FaxRequest::state_done:
- return (FALSE);
+ return (false);
case FaxRequest::state_sleeping:
case FaxRequest::state_pending:
job.stopTTSTimer(); // cancel timeout
}
job.remove(); // remove from old queue
job.stopKillTimer(); // clear kill timer
- return (TRUE);
+ return (true);
}
/*
* This control is used by clients that want to modify
* the state of a job (i.e. suspend, modify, submit).
*/
-fxBool
-faxQueueApp::suspendJob(const fxStr& jobid, fxBool abortActive)
+bool
+faxQueueApp::suspendJob(const fxStr& jobid, bool abortActive)
{
Job* job = Job::getJobByID(jobid);
if (job && suspendJob(*job, abortActive)) {
updateRequest(*req, *job);
delete req;
}
- return (TRUE);
+ return (true);
} else
- return (FALSE);
+ return (false);
}
/*
* the appropriate queue and any associated resources
* are purged.
*/
-fxBool
+bool
faxQueueApp::terminateJob(const fxStr& jobid, JobStatus why)
{
Job* job = Job::getJobByID(jobid);
- if (job && suspendJob(*job, TRUE)) {
+ if (job && suspendJob(*job, true)) {
job->state = FaxRequest::state_done;
Trigger::post(Trigger::JOB_KILL, *job);
FaxRequest* req = readRequest(*job);
if (req)
deleteRequest(*job, req, why, why != Job::removed);
setDead(*job);
- return (TRUE);
+ return (true);
} else
- return (FALSE);
+ return (false);
}
/*
job.state = FaxRequest::state_done;
FaxRequest* req = readRequest(job);
if (req)
- deleteRequest(job, req, Job::timedout, TRUE);
+ deleteRequest(job, req, Job::timedout, true);
setDead(job);
} else
job.killtime = 0; // mark job to be removed
job.state = FaxRequest::state_done;
traceQueue(job, "KILL TIME EXPIRED");
Trigger::post(Trigger::JOB_TIMEDOUT, job);
- deleteRequest(job, req, Job::timedout, TRUE);
+ deleteRequest(job, req, Job::timedout, true);
setDead(job);
}
* Resubmit an existing job or create a new job
* using the specified job description file.
*/
-fxBool
-faxQueueApp::submitJob(const fxStr& jobid, fxBool checkState)
+bool
+faxQueueApp::submitJob(const fxStr& jobid, bool checkState)
{
Job* job = Job::getJobByID(jobid);
if (job) {
- fxBool ok = FALSE;
+ bool ok = false;
if (job->state == FaxRequest::state_suspended) {
job->remove(); // remove from suspend queue
FaxRequest* req = readRequest(*job);// XXX need better mechanism
} else if (job->state == FaxRequest::state_done)
jobError(*job, "Cannot resubmit a completed job");
else
- ok = TRUE; // other, nothing to do
+ ok = true; // other, nothing to do
return (ok);
}
/*
if (!Sys::isRegularFile(filename)) {
logError("JOB %s: qfile %s is not a regular file.",
(const char*) jobid, (const char*) filename);
- return (FALSE);
+ return (false);
}
- fxBool status = FALSE;
+ bool status = false;
int fd = Sys::open(filename, O_RDWR);
if (fd >= 0) {
if (flock(fd, LOCK_SH) >= 0) {
* 4. Insufficient information was obtained to purge
* the job; just skip it.
*/
- fxBool reject;
+ bool reject;
if (req.readQFile(reject) && !reject &&
req.state != FaxRequest::state_done) {
status = submitJob(req, checkState);
req.notice = "Invalid or corrupted job description file";
traceServer("JOB " | jobid | ": " | req.notice);
// NB: this may not work, but we try...
- deleteRequest(job, req, Job::rejected, TRUE);
+ deleteRequest(job, req, Job::rejected, true);
} else if (req.state == FaxRequest::state_done) {
logError("JOB %s: Cannot resubmit a completed job",
(const char*) jobid);
rejectJob(job, *req, fxStr::format(
"REJECT: Too many attempts to dial: %u, max %u",
req->totdials, maxdials));
- deleteRequest(job, req, Job::rejected, TRUE);
+ deleteRequest(job, req, Job::rejected, true);
continue;
}
u_short maxtries = fxmin((u_short) dci.getMaxTries(),req->maxtries);
rejectJob(job, *req, fxStr::format(
"REJECT: Too many attempts to transmit: %u, max %u",
req->tottries, maxtries));
- deleteRequest(job, req, Job::rejected, TRUE);
+ deleteRequest(job, req, Job::rejected, true);
continue;
}
// NB: repeat this check so changes in max pages are applied
rejectJob(job, *req, fxStr::format(
"REJECT: Too many pages in submission: %u, max %u",
req->totpages, maxpages));
- deleteRequest(job, req, Job::rejected, TRUE);
+ deleteRequest(job, req, Job::rejected, true);
continue;
}
if (dci.getRejectNotice() != "") {
* a specified reason that we return to the sender.
*/
rejectJob(job, *req, "REJECT: " | dci.getRejectNotice());
- deleteRequest(job, req, Job::rejected, TRUE);
+ deleteRequest(job, req, Job::rejected, true);
continue;
}
time_t now = Sys::now();
* do not get information about when modems are in
* use from faxgetty processes.
*/
-fxBool
+bool
faxQueueApp::assignModem(Job& job)
{
fxAssert(job.modem == NULL, "Assigning modem to job that already has one");
- fxBool retryModemLookup;
+ bool retryModemLookup;
do {
- retryModemLookup = FALSE;
+ retryModemLookup = false;
Modem* modem = Modem::findModem(job);
if (modem) {
if (modem->assign(job)) {
Trigger::post(Trigger::MODEM_ASSIGN, *modem);
- return (TRUE);
+ return (true);
}
/*
* Modem could not be assigned to job. The
(const char*) modem->getDeviceID());
modem->startLockPolling(pollLockWait);
traceModem(*modem, "BUSY (begin polling)");
- retryModemLookup = TRUE;
+ retryModemLookup = true;
} else
traceJob(job, "No assignable modem located");
} while (retryModemLookup);
- return (FALSE);
+ return (false);
}
/*
if (fd >= 0) {
if (flock(fd, LOCK_EX) >= 0) {
FaxRequest* req = new FaxRequest(job.file, fd);
- fxBool reject;
+ bool reject;
if (req->readQFile(reject) && !reject) {
if (req->external == "")
req->external = job.dest;
*/
void
faxQueueApp::deleteRequest(Job& job, FaxRequest* req, JobStatus why,
- fxBool force, const char* duration)
+ bool force, const char* duration)
{
deleteRequest(job, *req, why, force, duration);
delete req;
void
faxQueueApp::deleteRequest(Job& job, FaxRequest& req, JobStatus why,
- fxBool force, const char* duration)
+ bool force, const char* duration)
{
fxStr dest = FAX_DONEDIR |
req.qfile.tail(req.qfile.length() - (sizeof (FAX_SENDDIR)-1));
void
faxQueueApp::openFIFOs()
{
- fifo = openFIFO(fifoName, 0600, TRUE);
+ fifo = openFIFO(fifoName, 0600, true);
Dispatcher::instance().link(fifo, Dispatcher::ReadMask, this);
}
void
faxQueueApp::FIFOMessage(char cmd, const fxStr& id, const char* args)
{
- fxBool status = FALSE;
+ bool status = false;
switch (cmd) {
case '+': // modem status msg
FIFOModemMessage(id, args);
return;
case 'Q': // quit
traceServer("QUIT");
- quit = TRUE;
+ quit = true;
pokeScheduler();
return; // NB: no return value expected
case 'T': // create new trigger
case 'U': // unreference file
traceServer("UNREF DOC %s", args);
unrefDoc(args);
- status = TRUE;
+ status = true;
break;
case 'X': // suspend job
traceServer("SUSPEND JOB %s", args);
- if (status = suspendJob(args, FALSE))
+ if (status = suspendJob(args, false))
pokeScheduler();
break;
case 'Y': // interrupt job
traceServer("INTERRUPT JOB %s", args);
- if (status = suspendJob(args, TRUE))
+ if (status = suspendJob(args, true))
pokeScheduler();
break;
case 'N': // noop
- status = TRUE;
+ status = true;
break;
default:
logError("Bad FIFO cmd '%c' from client %s", cmd, (const char*) id);
| quote | dev | enquote
);
traceServer("MODEM WEDGED: %s", (const char*) cmd);
- runCmd(cmd, TRUE);
+ runCmd(cmd, true);
}
void
for (i = N(numbers)-1; i >= 0; i--)
(*this).*numbers[i].p = numbers[i].def;
tod.reset(); // any day, any time
- use2D = TRUE; // ok to use 2D data
+ use2D = true; // ok to use 2D data
uucpLockMode = UUCP_LOCKMODE;
delete dialRules, dialRules = NULL;
ModemGroup::reset(); // clear+add ``any modem'' class
vlogWarning(fmt, ap);
}
-fxBool
+bool
faxQueueApp::setConfigItem(const char* tag, const char* value)
{
u_int ix;
} else if (streq(tag, "pagechopthreshold"))
pageChopThreshold = atof(value);
else
- return (FALSE);
- return (TRUE);
+ return (false);
+ return (true);
}
/*
cmd.append(buf);
}
traceServer("NOTIFY: %s", (const char*) cmd);
- runCmd(cmd, TRUE);
+ runCmd(cmd, true);
}
void
faxApp::setOpts("q:D");
- fxBool detach = TRUE;
+ bool detach = true;
fxStr queueDir(FAX_SPOOLDIR);
for (GetoptIter iter(argc, argv, faxApp::getOpts()); iter.notDone(); iter++)
switch (iter.option()) {
case 'q': queueDir = iter.optArg(); break;
- case 'D': detach = FALSE; break;
+ case 'D': detach = false; break;
case '?': usage(appName);
}
if (Sys::chdir(queueDir) < 0)
private:
class SchedTimeout : public IOHandler {
private:
- fxBool started;
+ bool started;
public:
SchedTimeout();
~SchedTimeout();
u_int tracingMask; // tracing level control mask
fxStr logFacility; // syslog facility to direct trace msgs
u_int requeueInterval; // job requeue interval
- fxBool use2D; // ok to use 2D-encoded data
+ bool use2D; // ok to use 2D-encoded data
u_int pageChop; // default page chop handling
float pageChopThreshold; // minimum space before page chop
fxStr notifyCmd; // external command for notification
static const stringtag strings[];
static const numbertag numbers[];
// runtime state
- fxBool timeout; // timeout occurred
- fxBool abortPrepare; // job preparation should be aborted
- fxBool quit; // terminate server
+ bool timeout; // timeout occurred
+ bool abortPrepare; // job preparation should be aborted
+ bool quit; // terminate server
int fifo; // fifo job queue interface
#define NQHASH 16
QLink runqs[NQHASH]; // jobs ready to run
// configuration support
void setupConfig();
void resetConfig();
- fxBool setConfigItem(const char* tag, const char* value);
+ bool setConfigItem(const char* tag, const char* value);
void configError(const char* fmt, ...);
void configTrace(const char* fmt, ...);
void setDialRules(const char* name);
fxStr canonicalizePhoneNumber(const fxStr& ds);
// modem support
void scanForModems();
- fxBool assignModem(Job& job);
+ bool assignModem(Job& job);
void releaseModem(Job& job);
void notifyModemWedged(Modem&);
void pollForModemLock(Modem& modem);
FaxRequest* readRequest(Job&);
void updateRequest(FaxRequest& req, Job& job);
void deleteRequest(Job&, FaxRequest* req, JobStatus why,
- fxBool force, const char* duration = "");
+ bool force, const char* duration = "");
void deleteRequest(Job&, FaxRequest& req, JobStatus why,
- fxBool force, const char* duration = "");
+ bool force, const char* duration = "");
void notifySender(Job&, JobStatus, const char* = "");
// job management interfaces
void processJob(Job& job);
void blockJob(Job&, FaxRequest&, const char*);
void delayJob(Job&, FaxRequest&, const char*, time_t);
void rejectJob(Job& job, FaxRequest& req, const fxStr& reason);
- fxBool submitJob(const fxStr& jobid, fxBool checkState = FALSE);
- fxBool suspendJob(const fxStr& jobid, fxBool abortActive);
+ bool submitJob(const fxStr& jobid, bool checkState = false);
+ bool suspendJob(const fxStr& jobid, bool abortActive);
void rejectSubmission(Job&, FaxRequest&, const fxStr& reason);
void setReadyToRun(Job& job);
void setDead(Job& job);
void setActive(Job& job);
void setSuspend(Job& job);
- fxBool submitJob(FaxRequest&, fxBool checkState = FALSE);
- fxBool submitJob(Job& job, FaxRequest& req, fxBool checkState = FALSE);
- fxBool suspendJob(Job& job, fxBool abortActive);
- fxBool terminateJob(const fxStr& filename, JobStatus why);
+ bool submitJob(FaxRequest&, bool checkState = false);
+ bool submitJob(Job& job, FaxRequest& req, bool checkState = false);
+ bool suspendJob(Job& job, bool abortActive);
+ bool terminateJob(const fxStr& filename, JobStatus why);
void timeoutJob(Job& job);
void timeoutJob(Job& job, FaxRequest&);
void runJob(Job& job);
void runScheduler();
void pokeScheduler();
// job preparation stuff
- fxBool prepareJobNeeded(Job&, FaxRequest&, JobStatus&);
+ bool prepareJobNeeded(Job&, FaxRequest&, JobStatus&);
static void prepareCleanup(int s);
void prepareJobStart(Job&, FaxRequest*,
FaxMachineInfo&, const DestControlInfo&);
const DestControlInfo& dci, fxStr& emsg);
JobStatus runConverter(Job& job, const char* app, char* const* argv,
fxStr& emsg);
- fxBool runConverter1(Job& job, int fd, fxStr& output);
+ bool runConverter1(Job& job, int fd, fxStr& output);
void makeCoverPage(Job&, FaxRequest&, const Class2Params&,
const DestControlInfo&);
- fxBool preparePageHandling(FaxRequest&,
+ bool preparePageHandling(FaxRequest&,
const FaxMachineInfo&, const DestControlInfo&, fxStr& emsg);
void preparePageChop(const FaxRequest&,
TIFF*, const Class2Params&, fxStr&);
int faxRequest::compare(faxRequest const*) const { return 0; }
-fxBool
+bool
faxRequest::isSavedOp() const
{
return (op == FaxRequest::send_tiff_saved ||
int compare(faxRequest const *a) const; // XXX needed for array
- fxBool isSavedOp() const;
+ bool isSavedOp() const;
};
fxDECLARE_ObjArray(faxRequestArray, faxRequest)
#endif /* _faxRequest_ */
faxSendApp::faxSendApp(const fxStr& devName, const fxStr& devID)
: FaxServer(devName, devID)
{
- ready = FALSE;
+ ready = false;
modemLock = NULL;
setupConfig();
req->desiredec = desiredEC;
if (desiredST != (u_int) -1)
req->desiredst = desiredST;
- fxBool reject;
+ bool reject;
if (req->readQFile(reject) && !reject) {
FaxMachineInfo info;
info.updateConfig(canonicalizePhoneNumber(req->number));
* Modem locking support.
*/
-fxBool
+bool
faxSendApp::lockModem()
{
- return (modemLock ? modemLock->lock() : TRUE);
+ return (modemLock ? modemLock->lock() : true);
}
void
void
faxSendApp::notifyModemReady()
{
- ready = TRUE;
+ ready = true;
}
/*
);
traceServer("RECV POLL: %s", (const char*) cmd);
setProcessPriority(BASE); // lower priority
- runCmd(cmd, TRUE);
+ runCmd(cmd, true);
setProcessPriority(state); // restore previous priority
}
(*this).*numbers[i].p = numbers[i].def;
}
-fxBool
+bool
faxSendApp::setConfigItem(const char* tag, const char* value)
{
u_int ix;
(*this).*numbers[ix].p = getNumber(value);
} else
return (FaxServer::setConfigItem(tag, value));
- return (TRUE);
+ return (true);
}
#undef N
};
private:
// runtime state
- fxBool ready; // modem ready for use
+ bool ready; // modem ready for use
UUCPLock* modemLock; // uucp lockfile handle
fxStr pollRcvdCmd; // command for docs received by polling
u_int desiredBR; // desired signalling rate
// configuration support
void setupConfig();
void resetConfig();
- fxBool setConfigItem(const char* tag, const char* value);
+ bool setConfigItem(const char* tag, const char* value);
// modem handling
- fxBool lockModem();
+ bool lockModem();
void unlockModem();
// notification interfaces used by FaxServer
void notifyModemReady();
FaxSendStatus send(const char* filename);
- fxBool isReady() const;
+ bool isReady() const;
};
-inline fxBool faxSendApp::isReady() const { return ready; }
+inline bool faxSendApp::isReady() const { return ready; }
#endif
pageSendApp::pageSendApp(const fxStr& devName, const fxStr& devID)
: ModemServer(devName, devID)
{
- ready = FALSE;
+ ready = false;
modemLock = NULL;
setupConfig();
if (fd >= 0) {
if (flock(fd, LOCK_EX) >= 0) {
FaxRequest* req = new FaxRequest(filename, fd);
- fxBool reject;
+ bool reject;
if (req->readQFile(reject) && !reject) {
if (req->findRequest(FaxRequest::send_page) != fx_invalidArrayIndex) {
FaxMachineInfo info;
changeState(MODEMWAIT); // ...sort of...
} else
sendFailed(req, send_retry, "Can not setup modem", 4*pollModemWait);
- discardModem(TRUE);
+ discardModem(true);
endSession();
unlockModem();
} else {
}
}
-fxBool
+bool
pageSendApp::prepareMsg(FaxRequest& req, FaxMachineInfo& info, fxStr& msg)
{
u_int i = req.findRequest(FaxRequest::send_data);
if (i == fx_invalidArrayIndex) // page w/o text
- return (TRUE);
+ return (true);
int fd = Sys::open(req.requests[i].item, O_RDONLY);
if (fd < 0) {
sendFailed(req, send_failed,
"Internal error: unable to open text message file");
- return (FALSE);
+ return (false);
}
struct stat sb;
(void) Sys::fstat(fd, sb);
if (Sys::read(fd, &msg[0], (u_int) sb.st_size) != sb.st_size) {
sendFailed(req, send_failed,
"Internal error: unable to read text message file");
- return (FALSE);
+ return (false);
}
Sys::close(fd);
msg.length(), maxMsgLen);
msg.resize(maxMsgLen);
}
- return (TRUE);
+ return (true);
}
void
req.ndials = 0; // consec. failed dial attempts
req.tottries++; // total answered calls
req.totdials++; // total attempted calls
- info.setCalledBefore(TRUE);
+ info.setCalledBefore(true);
info.setDialFailures(0);
req.status = send_ok; // be optimistic
* as PageNet intersperse protocol messages and
* verbose text messages.
*/
-static fxBool
+static bool
scanForCode(const u_char*& cp, u_int& len)
{
if (len > 0) {
return (len > 0);
}
-fxBool
+bool
pageSendApp::pagePrologue(FaxRequest& req, const FaxMachineInfo& info, fxStr& emsg)
{
fxStackBuffer buf;
*/
traceIXO("EXPECT ID (paging central identification)");
start = Sys::now();
- fxBool gotID = FALSE;
+ bool gotID = false;
do {
putModem("\r", 1);
if (getResponse(buf, ixoIDProbe) >= 3) {
if (!gotID) {
emsg = "No initial ID response from paging central";
req.status = send_retry;
- return (FALSE);
+ return (false);
}
flushModemInput(); // paging central may send multiple ID=
/*
if (--ntries == 0) {
emsg = "Login failed multiple times";
req.status = send_retry;
- return (FALSE);
+ return (false);
}
/*
* Resend the login request.
emsg =
"Paging central responded with forced disconnect";
req.status = send_failed;
- return (FALSE);
+ return (false);
}
// check for go-ahead message
if (len > 2 && cp[1] == '[' && cp[2] == 'p') {
traceIXO("RECV ACK (login successful & got go-ahead)");
- return (TRUE);
+ return (true);
}
}
break;
(unknown ?
"timeout waiting for response" : "too many unknown responses"));
req.status = send_retry;
- return (FALSE);
+ return (false);
}
-fxBool
+bool
pageSendApp::pageGoAhead(FaxRequest& req, const FaxMachineInfo&, fxStr& emsg)
{
fxStackBuffer buf;
while (len > 0) {
if (len > 2 && cp[0] == ESC && cp[1] == '[' && cp[2] == 'p') {
traceIXO("RECV go-ahead (prologue done)");
- return (TRUE);
+ return (true);
}
(void) scanForCode(cp, len);
}
emsg = fxStr::format("Protocol failure: %s waiting for go-ahead message",
unknown ? "timeout" : "too many unknown responses");
req.status = send_retry;
- return (FALSE);
+ return (false);
}
/*
buf.put(check, 3);
}
-fxBool
+bool
pageSendApp::sendPagerMsg(FaxRequest& req, faxRequest& preq, const fxStr& msg, fxStr& emsg)
{
/*
switch (cp[0]) {
case ACK:
traceIXO("RECV ACK (message block accepted)");
- return (TRUE);
+ return (true);
case NAK:
traceIXO("RECV NAK (message block rejected)");
if (--ntries == 0) {
req.status = send_retry;
emsg = "Message block not acknowledged by paging central "
"after multiple tries";
- return (FALSE);
+ return (false);
}
/*
* Retransmit the packet to paging central.
req.status = send_failed;
emsg = "Message block transmit failed; "
"paging central rejected it";
- return (FALSE);
+ return (false);
case ESC:
if (len > 1 && cp[1] == EOT) {
traceIXO("RECV EOT (forced disconnect)");
req.status = send_failed;
emsg = "Protocol failure: paging central responded to "
"message block transmit with forced disconnect";
- return (FALSE);
+ return (false);
}
/* fall thru... */
default: // unrecognized response
(unknown ?
"timeout waiting for response" : "too many unknown responses"));
req.status = send_retry;
- return (FALSE);
+ return (false);
}
-fxBool
+bool
pageSendApp::pageEpilogue(FaxRequest& req, const FaxMachineInfo&, fxStr& emsg)
{
putModem("\4\r", 2); // EOT then <CR>
case ESC:
if (len > 1 && cp[1] == EOT) {
traceIXO("RECV EOT (disconnect)");
- return (TRUE);
+ return (true);
}
break;
case RS:
traceIXO("RECV RS (message content rejected)");
emsg = "Paging central rejected content; check PIN";
req.status = send_failed;
- return (FALSE);
+ return (false);
}
(void) scanForCode(cp, len);
}
req.status = send_retry;
emsg = "Protocol failure: timeout waiting for transaction ACK/NAK "
"from paging central";
- return (FALSE);
+ return (false);
}
void
}
}
-fxBool
+bool
pageSendApp::sendUcpMsg(FaxRequest& req, faxRequest& preq, const fxStr& msg, fxStr& emsg, FaxMachineInfo& info)
{
/*
switch( N_ACK[0]) {
case 'A': // positive result (ACK)
traceIXO("RECV ACK (message block accepted)");
- return(TRUE);
+ return(true);
case 'N': // Negative result (NACK)
traceIXO("RECV NACK (message block rejected)");
if(--ntries==0) {
req.status = send_retry;
emsg="Message block not acknowledged by paging central"
"after multiple tries";
- return(FALSE);
+ return(false);
}
traceIXO("SEND message block (retransmit)");
putModem((const char*) buf, buf.getLength());
}
}
} while (Sys::now()-start < ixoXmitTimeout && unknown < ixoMaxUnknown);
- return FALSE;
+ return false;
}
/*
* END UCP Support
*/
-fxBool
+bool
pageSendApp::putModem(const void* data, int n, long ms)
{
traceIXOCom("<--", (const u_char*) data, n);
(*this).*numbers[i].p = numbers[i].def;
}
-fxBool
+bool
pageSendApp::setConfigItem(const char* tag, const char* value)
{
u_int ix;
(*this).*numbers[ix].p = getNumber(value);
} else
return (ModemServer::setConfigItem(tag, value));
- return (TRUE);
+ return (true);
}
#undef N
/*
* Modem and TTY setup
*/
-fxBool
+bool
pageSendApp::setupModem()
{
return (ModemServer::setupModem() &&
* Modem locking support.
*/
-fxBool
+bool
pageSendApp::lockModem()
{
- return (modemLock ? modemLock->lock() : TRUE);
+ return (modemLock ? modemLock->lock() : true);
}
void
void
pageSendApp::notifyModemReady()
{
- ready = TRUE;
+ ready = true;
}
/*
};
private:
// runtime state
- fxBool ready; // modem ready for use
+ bool ready; // modem ready for use
UUCPLock* modemLock; // uucp lockfile handle
time_t connTime; // time connected to peer
// configuration support
void setupConfig();
void resetConfig();
- fxBool setConfigItem(const char* tag, const char* value);
+ bool setConfigItem(const char* tag, const char* value);
u_int getConfigParity(const char* value) const;
// page transmission support (independent of paging protocol)
void sendPage(FaxRequest&, FaxMachineInfo&);
const fxStr&);
// IXO transmission support
void sendIxoPage(FaxRequest&, FaxMachineInfo&, const fxStr&, fxStr&);
- fxBool sendPagerMsg(FaxRequest&, faxRequest&, const fxStr&, fxStr&);
+ bool sendPagerMsg(FaxRequest&, faxRequest&, const fxStr&, fxStr&);
u_int getResponse(fxStackBuffer& buf, long secs);
- fxBool prepareMsg(FaxRequest&, FaxMachineInfo&, fxStr&);
- fxBool pagePrologue(FaxRequest&, const FaxMachineInfo&, fxStr&);
- fxBool pageGoAhead(FaxRequest&, const FaxMachineInfo&, fxStr&);
- fxBool pageEpilogue(FaxRequest&, const FaxMachineInfo&, fxStr&);
+ bool prepareMsg(FaxRequest&, FaxMachineInfo&, fxStr&);
+ bool pagePrologue(FaxRequest&, const FaxMachineInfo&, fxStr&);
+ bool pageGoAhead(FaxRequest&, const FaxMachineInfo&, fxStr&);
+ bool pageEpilogue(FaxRequest&, const FaxMachineInfo&, fxStr&);
void sendFailed(FaxRequest&, FaxSendStatus, const char*, u_int = 0);
void notifyPageSent(FaxRequest& req, u_int fi);
time_t getConnectTime() const;
// UCP transmission support
- void sendUcpPage(FaxRequest&, FaxMachineInfo&, const fxStr&, fxStr&); fxBool sendUcpMsg(FaxRequest&, faxRequest&, const fxStr&, fxStr&,
+ void sendUcpPage(FaxRequest&, FaxMachineInfo&, const fxStr&, fxStr&); bool sendUcpMsg(FaxRequest&, faxRequest&, const fxStr&, fxStr&,
FaxMachineInfo&);
// modem handling
- fxBool lockModem();
+ bool lockModem();
void unlockModem();
- fxBool setupModem();
+ bool setupModem();
// notification interfaces used by ModemServer
void notifyModemReady();
void notifyModemWedged();
// miscellaneous
- fxBool putModem(const void* data, int n, long ms = 0);
+ bool putModem(const void* data, int n, long ms = 0);
void traceResponse(const fxStackBuffer& buf);
void traceIXO(const char* fmt ...);
void traceIXOCom(const char* dir, const u_char* data, u_int cc);
FaxSendStatus send(const char* filename);
- fxBool isReady() const;
+ bool isReady() const;
};
-inline fxBool pageSendApp::isReady() const { return ready; }
+inline bool pageSendApp::isReady() const { return ready; }
#endif
#define MARGIN_LEFT 2
#define MARGIN_RIGHT 2
-fxBool
+bool
setupTagLineSlop(const Class2Params& params)
{
if (tagLineFont->isReady()) {
tagLineSlop = (tagLineFont->fontHeight()+MARGIN_TOP+MARGIN_BOT+3) *
howmany(params.pageWidth(),8);
- return (TRUE);
+ return (true);
} else
- return (FALSE);
+ return (false);
}
class MemoryDecoder : public G3Decoder {
uint32* stripbytecount;
(void) TIFFGetField(tif, TIFFTAG_STRIPBYTECOUNTS, &stripbytecount);
- fxBool firstStrip = setupTagLineSlop(params);
+ bool firstStrip = setupTagLineSlop(params);
u_int ts = tagLineSlop;
for (u_int strip = 0; strip < TIFFNumberOfStrips(tif); strip++) {
u_int totbytes = (u_int) stripbytecount[strip];
*/
dp = imageTagLine(data+ts, fillorder, params);
totbytes = totbytes+ts - (dp-data);
- firstStrip = FALSE;
+ firstStrip = false;
} else
dp = data;
if (fillorder != FILLORDER_LSB2MSB)
#include "config.h"
-fxBool verbose = FALSE;
+bool verbose = false;
static int
openFIFO(const char* name, int mode)
exit(-1);
}
if (argc == 3) {
- verbose = TRUE;
+ verbose = true;
argc--, argv++;
}
if (chdir(FAX_SPOOLDIR) == -1) {
continue;
RegEx* re;
if (line[0] == '!') {
- accept->append(FALSE);
+ accept->append(false);
pats->append(re = new RegEx(line+1));
} else {
- accept->append(TRUE);
+ accept->append(true);
pats->append(re = new RegEx(line));
}
if (re->getErrorCode() > REG_NOMATCH) {
int
main(int argc, char* argv[])
{
- fxBool verbose = TRUE;
+ bool verbose = true;
extern int optind, opterr;
extern char* optarg;
int c;
while ((c = getopt(argc, argv, ":q")) != -1)
switch (c) {
case 'q':
- verbose = FALSE;
+ verbose = false;
break;
case '?':
usage();
MIMEState::MIMEState(const char* t, const char* st) : type(t), subtype(st)
{
parent = NULL;
- lastPart = FALSE;
+ lastPart = false;
encode = ENC_7BIT;
charset = CS_USASCII;
blen = (u_int) -1; // NB: should insure no matches
type = "message", subtype = "rfc822";
else
type = "text", subtype = "plain";
- lastPart = FALSE;
+ lastPart = false;
encode = other.encode;
charset = other.charset;
blen = other.blen;
, subtype(st)
, boundary(other.boundary)
{
- lastPart = FALSE;
+ lastPart = false;
encode = other.encode;
charset = other.charset;
blen = other.blen;
);
}
-fxBool
+bool
MIMEState::parseToken(const char*& cp, const char delimeter, fxStr& result)
{
while (*cp && isspace(*cp))
result = fxStr(bp, cp-bp);
while (isspace(*cp)) // remove trailing ws
cp++;
- return (TRUE);
+ return (true);
} else
- return (FALSE);
+ return (false);
}
/*
* Extract MIME-related information from a set of
* message headers and fillin the MIME state block.
*/
-fxBool
+bool
MIMEState::parse(const MsgFmt& msg, fxStr& emsg)
{
const fxStr* s = msg.findHeader("Content-Type");
} else {
emsg = "Syntax error parsing MIME Content-Type: " | *s;
type = "text"; // reset on parsing error
- return (FALSE);
+ return (false);
}
}
s = msg.findHeader("Content-Transfer-Encoding");
s = msg.findHeader("Content-ID");
if (s)
cid = *s;
- return (TRUE);
+ return (true);
}
/*
/*
* Set a MIME parameter used by the decoder.
*/
-fxBool
+bool
MIMEState::setParameter(const fxStr& p, const fxStr& value)
{
fxStr param(p);
} else if (param.length() == 8 && param == "boundary") {
setBoundary(value); // part boundary marker
} else
- return (FALSE);
- return (TRUE);
+ return (false);
+ return (true);
}
/*
* Return a line of data according to the current
* setting of the content-transfer-encoding and
* the body part boundary. If the boundary marker
- * or EOF is reached FALSE is returned, otherwise
- * this method returns TRUE and the decoded line.
+ * or EOF is reached false is returned, otherwise
+ * this method returns true and the decoded line.
* If the data is encoded with a text-oriented
* scheme (7bit, 8bit, binary, or quoted-printable)
* then the trailing newline character is returned
* in the buffer. Otherwise any trailing newline
* is discarded and only the decoded data is returned.
*/
-fxBool
+bool
MIMEState::getLine(FILE* fd, fxStackBuffer& buf)
{
buf.reset();
u_int cc = buf.getLength();
if (cc >= blen && buf[0] == '-') {
if (cc == blen && strneq(buf, boundary, blen))
- return (FALSE);
+ return (false);
if (cc == blen+2 && strneq(buf, boundary, blen+2)) {
- lastPart = TRUE;
- return (FALSE);
+ lastPart = true;
+ return (false);
}
}
buf.put('\n');
- return (TRUE);
+ return (true);
}
buf.put(c);
}
u_int cc = buf.getLength();
if (cc >= blen && buf[0] == '-') {
if (cc == blen && strneq(buf, boundary, blen))
- return (FALSE);
+ return (false);
if (cc == blen+2 && strneq(buf, boundary, blen+2)) {
- lastPart = TRUE;
- return (FALSE);
+ lastPart = true;
+ return (false);
}
}
buf.put('\n');
- return (TRUE);
+ return (true);
}
buf.put(c);
}
}
fxFatal("Internal error, unsupported Content-Transfer-Encoding %u", encode);
/*NOTREACHED*/
- return (FALSE);
+ return (false);
}
static int
/*
* Return a decoded line of quoted-printable text.
*/
-fxBool
+bool
MIMEState::getQuotedPrintableLine(FILE* fd, fxStackBuffer& buf)
{
char line[80]; // spec says never more than 76
}
if (cc >= blen && line[0] == '-') {
if (cc == blen && strneq(line, boundary, blen))
- return (FALSE);
+ return (false);
if (cc == blen+2 && strneq(line, boundary, blen+2)) {
- lastPart = TRUE;
- return (FALSE);
+ lastPart = true;
+ return (false);
}
}
copyQP(buf, line, cc);
buf.put('\n');
- return (TRUE);
+ return (true);
}
if (cc < sizeof (line)-1)
line[cc++] = c;
/*
* Return a decoded line of base64 data.
*/
-fxBool
+bool
MIMEState::getBase64Line(FILE* fd, fxStackBuffer& buf)
{
char line[80]; // spec says never more than 76
lineno++;
if (cc >= blen && line[0] == '-') {
if (cc == blen && strneq(line, boundary, blen))
- return (FALSE);
+ return (false);
if (cc == blen+2 && strneq(line, boundary, blen+2)) {
- lastPart = TRUE;
- return (FALSE);
+ lastPart = true;
+ return (false);
}
}
copyBase64(buf, line, cc);
- return (TRUE);
+ return (true);
}
if (cc < sizeof (line)-1)
line[cc++] = c;
/*
* Return a decoded line of uuencode'd data.
*/
-fxBool
+bool
MIMEState::getUUDecodeLine(FILE* fd, fxStackBuffer& buf)
{
char line[80]; // spec says never more than 62
lineno++;
if (cc >= blen && line[0] == '-') { // check for boundary marker
if (cc == blen && strneq(line, boundary, blen))
- return (FALSE);
+ return (false);
if (cc == blen+2 && strneq(line, boundary, blen+2)) {
- lastPart = TRUE;
- return (FALSE);
+ lastPart = true;
+ return (false);
}
} else if (cc >= 6 && strneq(line, "begin ", 6)) {
return (getUUDecodeLine(fd, buf));
// consume to boundary marker
while (getUUDecodeLine(fd, buf))
;
- return (FALSE);
+ return (false);
}
copyUUDecode(buf, line, cc);
- return (TRUE);
+ return (true);
}
if (cc < sizeof (line)-1)
line[cc++] = c;
fxStr cid; // content ID
fxStr boundary; // multipart boundary marker
u_int blen; // adjusted boundary length
- fxBool lastPart; // TRUE if last multipart boundary seen
+ bool lastPart; // true if last multipart boundary seen
Encoding encode; // content transfer encoding
Charset charset; // text character set
- static fxBool parseToken(const char*&, const char delimeter, fxStr& result);
+ static bool parseToken(const char*&, const char delimeter, fxStr& result);
void parseParameters(const char*);
protected:
- virtual fxBool setParameter(const fxStr& param, const fxStr& value);
+ virtual bool setParameter(const fxStr& param, const fxStr& value);
- fxBool getQuotedPrintableLine(FILE* fd, fxStackBuffer& buf);
- fxBool getBase64Line(FILE* fd, fxStackBuffer& buf);
- fxBool getUUDecodeLine(FILE* fd, fxStackBuffer& buf);
+ bool getQuotedPrintableLine(FILE* fd, fxStackBuffer& buf);
+ bool getBase64Line(FILE* fd, fxStackBuffer& buf);
+ bool getUUDecodeLine(FILE* fd, fxStackBuffer& buf);
public:
MIMEState(const char* type, const char* subtype);
MIMEState(MIMEState& parent);
~MIMEState();
u_int lineno; // input line number
- fxBool parse(const MsgFmt&, fxStr& emsg);
+ bool parse(const MsgFmt&, fxStr& emsg);
const fxStr& getType(void) const;
const fxStr& getSubType(void) const;
- fxBool isParent(const char* type) const;
- fxBool isParent(const char* type, const char* subtype) const;
+ bool isParent(const char* type) const;
+ bool isParent(const char* type, const char* subtype) const;
const fxStr& getDescription(void) const;
const fxStr& getContentID(void) const;
void setBoundary(const char*);
const fxStr& getBoundary(void) const;
- virtual fxBool getLine(FILE*, fxStackBuffer&);
- fxBool isLastPart(void) const;
+ virtual bool getLine(FILE*, fxStackBuffer&);
+ bool isLastPart(void) const;
virtual void trace(FILE*);
};
inline Charset MIMEState::getCharset(void) const { return charset; }
inline Encoding MIMEState::getEncoding(void) const { return encode; }
inline const fxStr& MIMEState::getBoundary(void) const { return boundary; }
-inline fxBool MIMEState::isLastPart(void) const { return lastPart; }
-inline fxBool MIMEState::isParent(const char* t) const
+inline bool MIMEState::isLastPart(void) const { return lastPart; }
+inline bool MIMEState::isParent(const char* t) const
{ return (parent && parent->type == t); }
-inline fxBool MIMEState::isParent(const char* t, const char* st) const
+inline bool MIMEState::isParent(const char* t, const char* st) const
{ return (parent && parent->type == t && parent->subtype == st); }
inline const fxStr& MIMEState::getType(void) const { return type; }
inline const fxStr& MIMEState::getSubType(void) const { return subtype; }
return (name);
}
-fxBool
+bool
MsgFmt::getLine(FILE* fd, fxStackBuffer& buf)
{
buf.reset();
break;
buf.put(c);
}
- return (TRUE);
+ return (true);
}
void
void
MsgFmt::setupConfig()
{
- verbose = FALSE;
+ verbose = false;
boldFont = "Helvetica-Bold";
italicFont = "Helvetica-Oblique";
#undef streq
#define streq(a,b) (strcasecmp(a,b)==0)
-fxBool
+bool
MsgFmt::setConfigItem(const char* tag, const char* value)
{
if (streq(tag, "headers")) {
} else if (streq(tag, "verbose")) {
verbose = FaxConfig::getBoolean(tag);
} else
- return (FALSE);
- return (TRUE);
+ return (false);
+ return (true);
}
#undef streq
TextCoord headerStop; // tab stop for headers
fxStr boldFont; // bold font family name
fxStr italicFont; // italic font family name
- fxBool verbose; // trace header handling
+ bool verbose; // trace header handling
fxStrArray fields; // header tags
fxStrArray headers; // header values
virtual ~MsgFmt();
void setupConfig();
- virtual fxBool setConfigItem(const char* tag, const char* value);
+ virtual bool setConfigItem(const char* tag, const char* value);
- static fxBool getLine(FILE* fd, fxStackBuffer& buf);
+ static bool getLine(FILE* fd, fxStackBuffer& buf);
const fxStr* findHeader(const fxStr& name) const;
u_int headerCount(void);
MySendFaxClient();
~MySendFaxClient();
- void setup(fxBool);
- fxBool setConfigItem(const char* tag, const char* value);
+ void setup(bool);
+ bool setConfigItem(const char* tag, const char* value);
void fatal(const char* fmt ...);
};
MySendFaxClient::MySendFaxClient() {}
MySendFaxClient::~MySendFaxClient() {}
void
-MySendFaxClient::setup(fxBool b)
+MySendFaxClient::setup(bool b)
{
resetConfig();
readConfig(FAX_SYSCONF);
setVerbose(b);
FaxClient::setVerbose(b);
}
-fxBool MySendFaxClient::setConfigItem(const char* tag, const char* value)
+bool MySendFaxClient::setConfigItem(const char* tag, const char* value)
{ return SendFaxClient::setConfigItem(tag, value); }
class faxMailApp : public TextFmt, public MsgFmt {
private:
- fxBool markDiscarded; // mark MIME parts not handled
- fxBool withinFile; // between beginFile() & endFile()
+ bool markDiscarded; // mark MIME parts not handled
+ bool withinFile; // between beginFile() & endFile()
fxStr mimeConverters; // pathname to MIME converter scripts
fxStr mailProlog; // site-specific prologue definitions
fxStr clientProlog; // client-specific prologue info
MySendFaxClient* client; // for direct delivery
SendFaxJob* job; // reference to outbound job
fxStr mailUser; // user ID for contacting server
- fxBool autoCoverPage; // make cover page for direct delivery
+ bool autoCoverPage; // make cover page for direct delivery
void formatMIME(FILE* fd, MIMEState& mime, MsgFmt& msg);
void formatText(FILE* fd, MIMEState& mime);
void formatMessage(FILE* fd, MIMEState& mime, MsgFmt& msg);
void formatApplication(FILE* fd, MIMEState& mime);
void formatDiscarded(MIMEState& mime);
- fxBool formatWithExternal(FILE* fd, const fxStr& app, MIMEState& mime);
+ bool formatWithExternal(FILE* fd, const fxStr& app, MIMEState& mime);
void emitClientPrologue(FILE*);
void discardPart(FILE* fd, MIMEState& mime);
- fxBool copyPart(FILE* fd, MIMEState& mime, fxStr& tmpFile);
- fxBool runConverter(const fxStr& app, const fxStr& tmp, MIMEState& mime);
+ bool copyPart(FILE* fd, MIMEState& mime, fxStr& tmpFile);
+ bool runConverter(const fxStr& app, const fxStr& tmp, MIMEState& mime);
void copyFile(FILE* fd, const char* filename);
void resetConfig();
void setupConfig();
- fxBool setConfigItem(const char* tag, const char* value);
+ bool setConfigItem(const char* tag, const char* value);
void usage(void);
public:
void run(int argc, char** argv);
- void setVerbose(fxBool b) { verbose = b; }
+ void setVerbose(bool b) { verbose = b; }
void setBoldFont(const char* cp) { boldFont = cp; }
void setItalicFont(const char* cp) { italicFont = cp; }
};
readConfig(FAX_LIBDATA "/faxmail.conf");
readConfig(FAX_USERCONF);
- fxBool deliver = FALSE;
+ bool deliver = false;
while ((c = Sys::getopt(argc, argv, "12b:cdf:H:i:M:np:rRs:u:vW:")) != -1)
switch (c) {
case '1': case '2': // format in 1 or 2 columns
setBoldFont(optarg);
break;
case 'c': // truncate lines
- setLineWrapping(FALSE);
+ setLineWrapping(false);
break;
case 'd': // enable direct delivery
- deliver = TRUE;
+ deliver = true;
break;
case 'f': // default font for text body
setTextFont(optarg);
setPageMargins(optarg);
break;
case 'n': // suppress cover page
- autoCoverPage = FALSE;
+ autoCoverPage = false;
break;
case 'p': // point size
setTextPointSize(TextFmt::inch(optarg));
setPageWidth(atof(optarg));
break;
case 'v': // trace work
- setVerbose(TRUE);
+ setVerbose(true);
break;
case '?':
usage();
const fxStr* version = findHeader("MIME-Version");
if (version && *version == "1.0") {
beginFile();
- withinFile = TRUE;
+ withinFile = true;
formatHeaders(*this); // format top-level headers
formatMIME(stdin, mime, *this); // parse MIME format
if (withinFile) endFile();
- withinFile = FALSE;
+ withinFile = false;
} else {
beginFile();
- withinFile = TRUE;
+ withinFile = true;
formatHeaders(*this); // format top-level headers
formatText(stdin, mime); // treat body as text/plain
if (withinFile) endFile();
- withinFile = FALSE;
+ withinFile = false;
}
endFormatting();
if (client) { // complete direct delivery
- fxBool status = FALSE;
+ bool status = false;
fxStr emsg;
const char* user = mailUser;
if (user[0] == '\0') // null user =>'s use real uid
{
if (mime.getSubType() == "postscript") { // copy PS straight thru
if (withinFile) endFile();
- withinFile = FALSE;
+ withinFile = false;
FILE* fout = getOutputFile();
fxStackBuffer buf;
while (mime.getLine(fd, buf))
fwrite((const char*) buf, buf.getLength(), 1, fout);
if (!withinFile) beginFile();
- withinFile = TRUE;
+ withinFile = true;
} else if (mime.getSubType() == "x-faxmail-prolog") {
copyPart(fd, mime, clientProlog); // save client PS prologue
} else {
* Format a MIME part using an external conversion
* script to convert the decoded body to PostScript.
*/
-fxBool
+bool
faxMailApp::formatWithExternal(FILE* fd, const fxStr& app, MIMEState& mime)
{
- fxBool ok = FALSE;
+ bool ok = false;
if (verbose)
fprintf(stderr, "CONVERT: run %s\n", (const char*) app);
fxStr tmp;
* The latter is used, for example, to accumulate
* client-specified prologue data.
*/
-fxBool
+bool
faxMailApp::copyPart(FILE* fd, MIMEState& mime, fxStr& tmpFile)
{
int ftmp;
ftmp = Sys::open(tmpFile, O_WRONLY|O_APPEND);
if (ftmp >= 0) {
fxStackBuffer buf;
- fxBool ok = TRUE;
+ bool ok = true;
while (mime.getLine(fd, buf) && ok)
ok = (Sys::write(ftmp, buf, buf.getLength()) == buf.getLength());
if (ok) {
Sys::close(ftmp);
- return (TRUE);
+ return (true);
}
error("%s: write error: %s", (const char*) tmpFile, strerror(errno));
Sys::close(ftmp);
} else
error("%s: Can not create temporary file", (const char*) tmpFile);
discardPart(fd, mime);
- return (FALSE);
+ return (false);
}
/*
* Run an external converter program.
*/
-fxBool
+bool
faxMailApp::runConverter(const fxStr& app, const fxStr& tmp, MIMEState& mime)
{
const char* av[3];
default:
int status;
if (Sys::waitpid(pid, status) == pid && status == 0)
- return (TRUE);
+ return (true);
error("Error converting %s/%s; command was \"%s %s\"; exit status %x"
, (const char*) mime.getType()
, (const char*) mime.getSubType()
);
break;
}
- return (FALSE);
+ return (false);
}
/*
void
faxMailApp::setupConfig()
{
- markDiscarded = TRUE;
+ markDiscarded = true;
mimeConverters = FAX_LIBEXEC "/faxmail";
mailProlog = FAX_LIBDATA "/faxmail.ps";
msgDivider = "";
mailUser = ""; // default to real uid
- autoCoverPage = TRUE; // a la sendfax
+ autoCoverPage = true; // a la sendfax
- setPageHeaders(FALSE); // disable normal page headers
+ setPageHeaders(false); // disable normal page headers
setNumberOfColumns(1); // 1 input page per output page
- setLineWrapping(TRUE);
- setISO8859(TRUE);
+ setLineWrapping(true);
+ setISO8859(true);
MsgFmt::setupConfig();
}
#undef streq
#define streq(a,b) (strcasecmp(a,b)==0)
-fxBool
+bool
faxMailApp::setConfigItem(const char* tag, const char* value)
{
if (streq(tag, "markdiscarded"))
else if (TextFmt::setConfigItem(tag, value))
;
else
- return (FALSE);
- return (TRUE);
+ return (false);
+ return (true);
}
#undef streq
private:
void usage();
- fxBool removeJob(const char* id, fxStr& emsg);
- fxBool deleteDoc(const char* id);
+ bool removeJob(const char* id, fxStr& emsg);
+ bool deleteDoc(const char* id);
public:
faxRmApp();
~faxRmApp();
readConfig(FAX_SYSCONF);
readConfig(FAX_USERCONF);
- fxBool jobs = TRUE;
- fxBool docs = FALSE;
- fxBool useadmin = FALSE;
+ bool jobs = true;
+ bool docs = false;
+ bool useadmin = false;
while ((c = getopt(argc, argv, "ah:dv")) != -1)
switch (c) {
case 'a':
- useadmin = TRUE;
+ useadmin = true;
break;
case 'd': // treat args as document names
- jobs = FALSE;
- docs = TRUE;
+ jobs = false;
+ docs = true;
break;
case 'h': // server's host
setHost(optarg);
break;
case 'v':
- setVerbose(TRUE);
+ setVerbose(true);
break;
case '?':
usage();
printError(emsg);
}
-fxBool
+bool
faxRmApp::removeJob(const char* id, fxStr& emsg)
{
if (jobKill(id)) {
printf("Job %s removed.\n", id);
- return (TRUE);
+ return (true);
}
emsg = getLastResponse();
if (getLastCode() == 504 && jobDelete(id)) {
printf("Job %s removed (from doneq).\n", id);
emsg = "";
- return (TRUE);
+ return (true);
}
- return (FALSE);
+ return (false);
}
-fxBool
+bool
faxRmApp::deleteDoc(const char* id)
{
return (command("DELE %s%s"
private:
fxStr header;
- fxBool listWithHeader(const fxStr& dir, fxStr& emsg);
+ bool listWithHeader(const fxStr& dir, fxStr& emsg);
public:
faxStatApp();
~faxStatApp();
faxStatApp::faxStatApp() {}
faxStatApp::~faxStatApp() {}
-static fxBool
+static bool
writeStdout(void*, const char* buf, int cc, fxStr&)
{
(void) Sys::write(STDOUT_FILENO, buf, cc);
- return (TRUE);
+ return (true);
}
void
fxStrArray dirs;
dirs.append(FAX_STATUSDIR); // server status
- fxBool checkInfo = FALSE;
+ bool checkInfo = false;
int c;
while ((c = getopt(argc, argv, "h:adgfilrsv")) != -1)
switch (c) {
setHost(optarg);
break;
case 'i': // display any.info file
- checkInfo = TRUE;
+ checkInfo = true;
break;
case 'l': // use local timezone for dates & times
setTimeZone(TZ_LOCAL);
dirs.append(FAX_SENDDIR);
break;
case 'v': // enable protocol tracing
- setVerbose(TRUE);
+ setVerbose(true);
break;
case '?':
fxFatal("usage: faxstat [-h server-host] [-adfglrsv]");
printError(emsg);
}
-fxBool
+bool
faxStatApp::listWithHeader(const fxStr& dir, fxStr& emsg)
{
if (!setMode(MODE_S))
int cc = read(getDataFd(), buf, sizeof (buf));
if (cc == 0) {
closeDataConn();
- return (getReply(FALSE) == COMPLETE);
+ return (getReply(false) == COMPLETE);
}
if (cc < 0) {
emsg = fxStr::format("Data Connection: %s", strerror(errno));
- (void) getReply(FALSE);
+ (void) getReply(false);
break;
}
if (byte_count == 0 && header.length() > 0)
}
bad:
closeDataConn();
- return (FALSE);
+ return (false);
}
int
/*
* Create the client FIFO and open it for use.
*/
-fxBool
+bool
HylaFAXServer::initClientFIFO(fxStr& emsg)
{
clientFIFOName = fxStr::format(FAX_CLIENTDIR "/%u", getpid());
if (Sys::mkfifo(clientFIFOName, 0622) < 0 && errno != EEXIST) {
emsg = fxStr::format("Could not create %s: %s",
(const char*) clientFIFOName, strerror(errno));
- return (FALSE);
+ return (false);
}
clientFd = Sys::open(clientFIFOName, CONFIG_OPENFIFO|O_NDELAY);
if (clientFd == -1) {
emsg = fxStr::format("Could not open FIFO file %s: %s",
(const char*) clientFIFOName, strerror(errno));
- return (FALSE);
+ return (false);
}
if (!Sys::isFIFOFile(clientFd)) {
emsg = clientFIFOName | " is not a FIFO special file";
- return (FALSE);
+ return (false);
}
// open should set O_NDELAY, but just to be sure...
if (fcntl(clientFd, F_SETFL, fcntl(clientFd, F_GETFL, 0) | O_NDELAY) < 0)
logError("initClientFIFO %s: fcntl: %m", (const char*) clientFIFOName);
Dispatcher::instance().link(clientFd, Dispatcher::ReadMask, this);
- return (TRUE);
+ return (true);
}
/*
/*
* Send a message to the central queuer process.
*/
-fxBool
+bool
HylaFAXServer::sendQueuerMsg(fxStr& emsg, const fxStr& msg)
{
- fxBool retry = FALSE;
+ bool retry = false;
again:
if (faxqFd == -1) {
#ifdef FIFOSELECTBUG
if (faxqFd == -1) {
emsg = fxStr::format("Unable to open scheduler FIFO: %s",
strerror(errno));
- return (FALSE);
+ return (false);
}
/*
* Turn off O_NDELAY so that write will block if FIFO is full.
*/
Sys::close(faxqFd), faxqFd = -1;
if (!retry) {
- retry = TRUE;
+ retry = true;
goto again;
}
}
emsg = fxStr::format("FIFO write failed: %s", strerror(errno));
logError(emsg);
- return (FALSE);
+ return (false);
} else
- return (TRUE);
+ return (true);
}
/*
* Send a message to the central queuer process.
*/
-fxBool
+bool
HylaFAXServer::sendQueuer(fxStr& emsg, const char* fmt ...)
{
va_list ap;
va_start(ap, fmt);
- fxBool ok = sendQueuerMsg(emsg, fxStr::vformat(fmt, ap));
+ bool ok = sendQueuerMsg(emsg, fxStr::vformat(fmt, ap));
va_end(ap);
return (ok);
}
* Send a message to the central queuer process
* and wait for a response on our client FIFO.
*/
-fxBool
+bool
HylaFAXServer::sendQueuerACK(fxStr& emsg, const char* fmt, ...)
{
va_list ap;
va_start(ap, fmt);
- fxBool b = vsendQueuerACK(emsg, fmt, ap);
+ bool b = vsendQueuerACK(emsg, fmt, ap);
va_end(ap);
return (b);
}
-fxBool
+bool
HylaFAXServer::vsendQueuerACK(fxStr& emsg, const char* fmt, va_list ap)
{
if (clientFd == -1) {
emsg = "Bad server state, client FIFO is not open";
- return (FALSE);
+ return (false);
}
fxStr msg = fxStr::vformat(fmt, ap);
if (msg.length() < 2) { // sanity check
emsg = "Bad FIFO message, too short to be valid";
- return (FALSE);
+ return (false);
}
msg.insert(clientFIFOName | ":", 1); // insert FIFO name for reply
- fxBool ok = sendQueuerMsg(emsg, msg);
+ bool ok = sendQueuerMsg(emsg, msg);
if (ok) {
Dispatcher& disp = Dispatcher::instance();
for (state |= S_WAITFIFO; IS(WAITFIFO); disp.dispatch())
;
if (fifoResponse.length() < 2) { // too short to be valid
emsg = "Unexpected response from scheduler: \"" |fifoResponse| "\"";
- ok = FALSE;
+ ok = false;
} else if (fifoResponse[0] == msg[0]) { // response to our request
ok = (fifoResponse[1] == '*');
if (!ok)
emsg = "Unspecified reason (scheduler NAK'd request)";
} else // user abort
- ok = FALSE;
+ ok = false;
}
return (ok);
}
/*
* Send a message to a modem process via the per-modem FIFO.
*/
-fxBool
+bool
HylaFAXServer::sendModem(const char* modem, fxStr& emsg, const char* fmt ...)
{
fxStr fifoName(modem);
if (fd == -1) {
emsg = fxStr::format("Unable to open %s: %s",
(const char*) fifoName, strerror(errno));
- return (FALSE);
+ return (false);
}
va_list ap;
va_start(ap, fmt);
emsg = fxStr::format("write to %s failed: %s",
(const char*) fifoName, strerror(errno));
logError(emsg);
- return (FALSE);
+ return (false);
} else
- return (TRUE);
+ return (true);
}
return (h % CACHESIZE);
}
-fxBool
-FileCache::lookup(const char* pathname, struct stat& sb, fxBool addToCache)
+bool
+FileCache::lookup(const char* pathname, struct stat& sb, bool addToCache)
{
lookups++;
u_int h = hash(pathname);
fi->serial = master++;
sb = fi->sb;
hits++;
- return (TRUE);
+ return (true);
}
if (fi->serial < oldest->serial)
oldest = fi;
* Pathname not found in the cache.
*/
if (Sys::stat(pathname, sb) < 0)
- return (FALSE);
+ return (false);
if (addToCache && pathname[0] != '.') {
if (fi) {
fi = oldest;
fi->serial = master++;
fi->sb = sb;
}
- return (TRUE);
+ return (true);
}
/*
* Update the file mode for any in-cache entry.
*/
-fxBool
+bool
FileCache::chmod(const char* pathname, mode_t mode)
{
if (Sys::chmod(pathname, mode) < 0)
- return (FALSE);
+ return (false);
lookups++;
u_int h = hash(pathname);
u_int maxprobes = 5;
h = (u_int)(h*h) % CACHESIZE;
fi = cache[h];
}
- return (TRUE);
+ return (true);
}
/*
* Update the file ownership for any in-cache entry.
*/
-fxBool
+bool
FileCache::chown(const char* pathname, uid_t uid, gid_t gid)
{
/*
*/
uid_t ouid = geteuid();
(void) seteuid(0);
- fxBool ok = (Sys::chown(pathname, uid, gid) >= 0);
+ bool ok = (Sys::chown(pathname, uid, gid) >= 0);
(void) seteuid(ouid);
if (ok) {
lookups++;
/*
* Like lookup, but if found in the cache, re-do the stat.
*/
-fxBool
-FileCache::update(const char* pathname, struct stat& sb, fxBool addToCache)
+bool
+FileCache::update(const char* pathname, struct stat& sb, bool addToCache)
{
lookups++;
u_int h = hash(pathname);
hits++;
fi->serial = master++;
fi->sb = sb;
- return (TRUE);
+ return (true);
} else {
flushed++;
cache[h] = NULL;
delete fi;
- return (FALSE);
+ return (false);
}
}
if (fi->serial < oldest->serial)
* Pathname not found in the cache.
*/
if (Sys::stat(pathname, sb) < 0)
- return (FALSE);
+ return (false);
if (addToCache && pathname[0] != '.') {
if (fi) {
fi = oldest;
fi->serial = master++;
fi->sb = sb;
}
- return (TRUE);
+ return (true);
}
void
static u_int hash(const char* pathname);
- static fxBool lookup(const char* pathname, struct stat& sb,
- fxBool addToCache = TRUE);
- static fxBool update(const char* pathname, struct stat& sb,
- fxBool addToCache = TRUE);
+ static bool lookup(const char* pathname, struct stat& sb,
+ bool addToCache = true);
+ static bool update(const char* pathname, struct stat& sb,
+ bool addToCache = true);
static void flush(const char* pathname);
- static fxBool chmod(const char* pathname, mode_t mode);
- static fxBool chown(const char* pathname, uid_t uid, gid_t gid);
+ static bool chmod(const char* pathname, mode_t mode);
+ static bool chown(const char* pathname, uid_t uid, gid_t gid);
static void reset(void);
};
#endif /* _FileCache_ */
* NB: this array is ordered by expected frequency of access.
*/
SpoolDir HylaFAXServer::dirs[] = {
-{ "/status/", FALSE, FALSE, FALSE, 0,
- HylaFAXServer::isVisibleTRUE,
+{ "/status/", false, false, false, 0,
+ HylaFAXServer::isVisibletrue,
&HylaFAXServer::listStatus, &HylaFAXServer::listStatusFile,
&HylaFAXServer::nlstStatus, &HylaFAXServer::nlstUnixFile, },
-{ "/sendq/", FALSE, FALSE, FALSE, 0,
+{ "/sendq/", false, false, false, 0,
HylaFAXServer::isVisibleSendQFile,
&HylaFAXServer::listSendQ, &HylaFAXServer::listSendQFile,
&HylaFAXServer::nlstSendQ, &HylaFAXServer::nlstSendQFile, },
-{ "/doneq/", FALSE, FALSE, FALSE, 0,
+{ "/doneq/", false, false, false, 0,
HylaFAXServer::isVisibleSendQFile,
&HylaFAXServer::listSendQ, &HylaFAXServer::listSendQFile,
&HylaFAXServer::nlstSendQ, &HylaFAXServer::nlstSendQFile, },
-{ "/docq/", FALSE, TRUE, TRUE, 0,
+{ "/docq/", false, true, true, 0,
HylaFAXServer::isVisibleDocQFile,
&HylaFAXServer::listDirectory, &HylaFAXServer::listUnixFile,
&HylaFAXServer::nlstDirectory, &HylaFAXServer::nlstUnixFile, },
-{ "/tmp/", FALSE, TRUE, TRUE, 0,
- HylaFAXServer::isVisibleTRUE,
+{ "/tmp/", false, true, true, 0,
+ HylaFAXServer::isVisibletrue,
&HylaFAXServer::listDirectory, &HylaFAXServer::listUnixFile,
&HylaFAXServer::nlstDirectory, &HylaFAXServer::nlstUnixFile, },
-{ "/log/", FALSE, FALSE, FALSE, 0,
- HylaFAXServer::isVisibleTRUE,
+{ "/log/", false, false, false, 0,
+ HylaFAXServer::isVisibletrue,
&HylaFAXServer::listDirectory, &HylaFAXServer::listUnixFile,
&HylaFAXServer::nlstDirectory, &HylaFAXServer::nlstUnixFile, },
-{ "/recvq/", FALSE, FALSE, TRUE, 0,
+{ "/recvq/", false, false, true, 0,
HylaFAXServer::isVisibleRecvQFile,
&HylaFAXServer::listRecvQ, &HylaFAXServer::listRecvQFile,
&HylaFAXServer::nlstDirectory, &HylaFAXServer::nlstUnixFile, },
-{ "/archive/", FALSE, FALSE, FALSE, 0,
- HylaFAXServer::isVisibleTRUE,
+{ "/archive/", false, false, false, 0,
+ HylaFAXServer::isVisibletrue,
&HylaFAXServer::listDirectory, &HylaFAXServer::listUnixFile,
&HylaFAXServer::nlstDirectory, &HylaFAXServer::nlstUnixFile, },
-{ "/pollq/", FALSE, TRUE, TRUE, 0,
+{ "/pollq/", false, true, true, 0,
HylaFAXServer::isVisibleRecvQFile,
&HylaFAXServer::listRecvQ, &HylaFAXServer::listRecvQFile,
&HylaFAXServer::nlstDirectory, &HylaFAXServer::nlstUnixFile, },
-{ "/", FALSE, FALSE, FALSE, 0,
+{ "/", false, false, false, 0,
HylaFAXServer::isVisibleRootFile,
&HylaFAXServer::listDirectory, &HylaFAXServer::listUnixFile,
&HylaFAXServer::nlstDirectory, &HylaFAXServer::nlstUnixFile, },
-{ "/etc/", TRUE, FALSE, FALSE, 0,
- HylaFAXServer::isVisibleTRUE,
+{ "/etc/", true, false, false, 0,
+ HylaFAXServer::isVisibletrue,
&HylaFAXServer::listDirectory, &HylaFAXServer::listUnixFile,
&HylaFAXServer::nlstDirectory, &HylaFAXServer::nlstUnixFile, },
-{ "/info/", FALSE, FALSE, FALSE, 0,
- HylaFAXServer::isVisibleTRUE,
+{ "/info/", false, false, false, 0,
+ HylaFAXServer::isVisibletrue,
&HylaFAXServer::listDirectory, &HylaFAXServer::listUnixFile,
&HylaFAXServer::nlstDirectory, &HylaFAXServer::nlstUnixFile, },
-{ "/bin/", TRUE, FALSE, FALSE, 0,
- HylaFAXServer::isVisibleTRUE,
+{ "/bin/", true, false, false, 0,
+ HylaFAXServer::isVisibletrue,
&HylaFAXServer::listDirectory, &HylaFAXServer::listUnixFile,
&HylaFAXServer::nlstDirectory, &HylaFAXServer::nlstUnixFile, },
-{ "/config/", FALSE, FALSE, FALSE, 0,
- HylaFAXServer::isVisibleTRUE,
+{ "/config/", false, false, false, 0,
+ HylaFAXServer::isVisibletrue,
&HylaFAXServer::listDirectory, &HylaFAXServer::listUnixFile,
&HylaFAXServer::nlstDirectory, &HylaFAXServer::nlstUnixFile, },
-{ "/client/", TRUE, FALSE, FALSE, 0,
- HylaFAXServer::isVisibleTRUE,
+{ "/client/", true, false, false, 0,
+ HylaFAXServer::isVisibletrue,
&HylaFAXServer::listDirectory, &HylaFAXServer::listUnixFile,
&HylaFAXServer::nlstDirectory, &HylaFAXServer::nlstUnixFile, },
};
/*
* Is the specified file visible to the client.
*/
-fxBool
+bool
HylaFAXServer::fileVisible(const SpoolDir& dir, const char* filename, const struct stat& sb)
{
return (IS(PRIVILEGED) || (*dir.isVisibleFile)(filename, sb));
}
-fxBool
-HylaFAXServer::isVisibleTRUE(const char*, const struct stat&)
- { return (TRUE); }
-fxBool
+bool
+HylaFAXServer::isVisibletrue(const char*, const struct stat&)
+ { return (true); }
+bool
HylaFAXServer::isVisibleDocQFile(const char* filename, const struct stat&)
{ return (strncmp(filename, "doc", 3) == 0); }
-fxBool
+bool
HylaFAXServer::isVisibleRootFile(const char*, const struct stat& sb)
{ return (S_ISREG(sb.st_mode) || S_ISDIR(sb.st_mode)); }
}
void
-HylaFAXServer::makeProt(const struct stat& sb, fxBool withGrp, char prot[10])
+HylaFAXServer::makeProt(const struct stat& sb, bool withGrp, char prot[10])
{
char* pp = prot;
*pp++ = S_ISREG(sb.st_mode) ? '-' :
fprintf(fd, "%s", filename);
}
-static fxBool
+static bool
isTIFF(const TIFFHeader& h)
{
if (h.tiff_magic != TIFF_BIGENDIAN && h.tiff_magic != TIFF_LITTLEENDIAN)
- return (FALSE);
+ return (false);
union {
int32 i;
char c[4];
return (version == TIFF_VERSION);
}
-fxBool
+bool
HylaFAXServer::docType(const char* docname, FaxSendOp& op)
{
op = FaxRequest::send_unknown;
#endif
#endif /* CHAR_BIT */
-#define HAVE_PSLEVEL2 FALSE
-#define HAVE_PCL5 FALSE
+#define HAVE_PSLEVEL2 false
+#define HAVE_PCL5 false
static struct {
const char* name; // protocol token name
- fxBool supported; // TRUE if format is supported
+ bool supported; // true if format is supported
const char* suffix; // file suffix
const char* help; // help string for HELP FORM command
} formats[] = {
-{ "TIFF", TRUE, "tif", "Tagged Image File Format, Class F only" },
-{ "PS", TRUE, "ps", "Adobe PostScript Level I" },
+{ "TIFF", true, "tif", "Tagged Image File Format, Class F only" },
+{ "PS", true, "ps", "Adobe PostScript Level I" },
{ "PS2", HAVE_PSLEVEL2, "ps", "Adobe PostScript Level II" },
{ "PCL", HAVE_PCL5, "pcl", "HP Printer Control Language (PCL), Version 5"},
};
(void) Sys::write(xferfaxlog, msg, msg.length());
}
-fxBool
+bool
HylaFAXServer::restartSend(FILE* fd, off_t marker)
{
if (type == TYPE_A) { // restart based on line count
int c;
while ((c = getc(fd)) != EOF)
if (c == '\n' && --marker == 0)
- return (TRUE);
- return (FALSE);
+ return (true);
+ return (false);
} else // restart based on file offset
return (lseek(fileno(fd), marker, SEEK_SET) == marker);
}
/*
* Tranfer the current directory's contents of "tif" to "fdout".
*/
-fxBool
+bool
HylaFAXServer::sendTIFFData(TIFF* tif, FILE* fdout)
{
state |= S_TRANSFER;
if (setjmp(urgcatch) != 0) {
state &= ~S_TRANSFER;
- return (FALSE);
+ return (false);
}
#define PACK(a,b) (((a)<<8)|(b))
switch (PACK(type,mode)) {
if (sendTIFFHeader(tif, fileno(fdout)) &&
sendITIFFData(tif, fileno(fdout))) {
state &= ~S_TRANSFER;
- return (TRUE);
+ return (true);
}
break;
default:
}
#undef PACK
state &= ~S_TRANSFER;
- return (FALSE);
+ return (false);
}
static void
* immediately after this data) and it is assumed that
* all image data is concatenated into a single strip.
*/
-fxBool
+bool
HylaFAXServer::sendTIFFHeader(TIFF* tif, int fdout)
{
static DirTemplate templ = {
memcpy(buf.dirstuff, &templ, sizeof (templ));
if (write(fdout, (const char*) &buf, sizeof (buf)) != sizeof (buf)) {
perror_reply(426, "Data connection", errno);
- return (FALSE);
+ return (false);
} else {
byte_count += sizeof (buf);
- return (TRUE);
+ return (true);
}
#undef NTAGS
#undef offsetof
* consideration for any padding that might be present
* or might be needed.
*/
-fxBool
+bool
HylaFAXServer::sendITIFFData(TIFF* tif, int fdout)
{
uint32* sb;
}
if (buf == NULL) {
reply(551, "Error allocating intermediate buffer");
- return (FALSE);
+ return (false);
}
if (TIFFReadRawStrip(tif, s, buf, cc) != cc) {
reply(551, "Error reading input file at strip %u", s);
byte_count += cc;
}
_TIFFfree(buf);
- return (TRUE);
+ return (true);
bad:
_TIFFfree(buf);
- return (FALSE);
+ return (false);
}
const char*
* be shared across multiple sessions.
*/
void
-HylaFAXServer::storeUniqueCmd(fxBool isTemp)
+HylaFAXServer::storeUniqueCmd(bool isTemp)
{
fxStr emsg;
u_int seqnum = getDocumentNumbers(1, emsg);
/*
* Tranfer the contents of "fdin" to "fdout".
*/
-fxBool
+bool
HylaFAXServer::sendData(FILE* fdin, FILE* fdout)
{
state |= S_TRANSFER;
if (setjmp(urgcatch) != 0) {
state &= ~S_TRANSFER;
- return (FALSE);
+ return (false);
}
#define PACK(a,b) (((a)<<8)|(b))
switch (PACK(type,mode)) {
case PACK(TYPE_L,MODE_S):
if (sendIData(fileno(fdin), fileno(fdout))) {
state &= ~S_TRANSFER;
- return (TRUE);
+ return (true);
}
break;
case PACK(TYPE_I,MODE_Z):
case PACK(TYPE_L,MODE_Z):
if (sendZData(fileno(fdin), fileno(fdout))) {
state &= ~S_TRANSFER;
- return (TRUE);
+ return (true);
}
break;
case PACK(TYPE_A,MODE_S):
break;
}
state &= ~S_TRANSFER;
- return (TRUE);
+ return (true);
}
byte_count++;
if (c == '\n') { // \n -> \r\n
}
#undef PACK
state &= ~S_TRANSFER;
- return (FALSE);
+ return (false);
}
-fxBool
+bool
HylaFAXServer::sendIData(int fdin, int fdout)
{
char buf[16*1024];
for (;;) {
int cc = read(fdin, buf, sizeof (buf));
if (cc == 0)
- return (TRUE);
+ return (true);
if (cc < 0) {
perror_reply(551, "Error reading input file", errno);
break;
}
byte_count += cc;
}
- return (FALSE);
+ return (false);
}
-fxBool
+bool
HylaFAXServer::sendZData(int fdin, int fdout)
{
z_stream zstream;
}
} while (state != Z_STREAM_END);
deflateEnd(&zstream);
- return (TRUE);
+ return (true);
bad:
deflateEnd(&zstream);
} else
reply(452, "Can not initialize compression library: %s", zstream.msg);
- return (FALSE);
+ return (false);
}
/*
* Transfer data from peer to file.
*/
-fxBool
+bool
HylaFAXServer::recvData(FILE* fdin, FILE* fdout)
{
state |= S_TRANSFER;
if (setjmp(urgcatch) != 0) {
state &= ~S_TRANSFER;
- return (FALSE);
+ return (false);
}
#define PACK(a,b) (((a)<<8)|(b))
switch (PACK(type,mode)) {
case PACK(TYPE_L,MODE_S):
if (recvIData(fileno(fdin), fileno(fdout))) {
state &= ~S_TRANSFER;
- return (TRUE);
+ return (true);
}
break;
case PACK(TYPE_I,MODE_Z):
case PACK(TYPE_L,MODE_Z):
if (recvZData(fileno(fdin), fileno(fdout))) {
state &= ~S_TRANSFER;
- return (TRUE);
+ return (true);
}
break;
case PACK(TYPE_A,MODE_S):
break;
}
state &= ~S_TRANSFER;
- return (TRUE);
+ return (true);
}
byte_count++;
if (c == '\r') { // \r\n -> \n
}
#undef PACK
state &= ~S_TRANSFER;
- return (FALSE);
+ return (false);
}
-fxBool
+bool
HylaFAXServer::recvIData(int fdin, int fdout)
{
char buf[16*1024]; // XXX better if page-aligned
for (;;) {
int cc = read(fdin, buf, sizeof (buf));
if (cc == 0)
- return (TRUE);
+ return (true);
if (cc < 0) {
perror_reply(426, "Data Connection", errno);
break;
}
byte_count += cc;
}
- return (FALSE);
+ return (false);
}
-fxBool
+bool
HylaFAXServer::recvZData(int fdin, int fdout)
{
z_stream zstream;
break;
}
(void) inflateEnd(&zstream);
- return (TRUE);
+ return (true);
}
if (cc < 0) {
perror_reply(426, "Data Connection", errno);
(void) inflateEnd(&zstream);
} else
reply(452, "Can not initialize decoder: %s", zstream.msg);
- return (FALSE);
+ return (false);
}
void
dologout(-1);
}
ctrlFlags = fcntl(STDIN_FILENO, F_GETFL); // for parser
- if (isShutdown(TRUE))
+ if (isShutdown(true))
reply(220, "%s HylaFAX server shut down; available only for admin use.",
(const char*) hostname);
else
return (!IS(LOGGEDIN) && file[0] == '/' ? file+1 : file);
}
-fxBool
+bool
HylaFAXServer::readShutdownFile(void)
{
- fxBool ok = FALSE;
+ bool ok = false;
FILE* fd = fopen(fixPathname(shutdownFile), "r");
if (fd != NULL) {
struct tm tm;
char buf[1024];
while (fgets(buf, sizeof (buf), fd))
shutdownMsg.append(buf);
- ok = TRUE;
+ ok = true;
} else
logError("%s: Invalid shutdown time, mktime conversion failed;"
"Year=%d Mon=%d Day=%d Hour=%d Min=%d"
return (ok);
}
-fxBool
-HylaFAXServer::isShutdown(fxBool quiet)
+bool
+HylaFAXServer::isShutdown(bool quiet)
{
struct stat sb;
if (shutdownFile == "" || Sys::stat(fixPathname(shutdownFile), sb) < 0)
- return (FALSE);
+ return (false);
if (sb.st_mtime != lastModTime) {
if (!readShutdownFile())
- return (FALSE);
+ return (false);
lastModTime = sb.st_mtime;
}
time_t now = Sys::now();
if (!quiet) { // possibly send client shutdown msg
time_t timeToDisconnect = discTime - now;
time_t lastMsg = now-lastTime;
- fxBool sendShutDownMsg =
+ bool sendShutDownMsg =
(lastTime == 0) // first time
|| (timeToDisconnect < 60) // <60 seconds, warn continuously
// <15 minutes, warn ever 5 minutes
}
}
-fxBool
+bool
HylaFAXServer::setConfigItem(const char* tag, const char* value)
{
u_int ix;
} else if (findTag(tag, (const tags*) numbers, N(numbers), ix)) {
(*this).*numbers[ix].p = getNumber(value);
} else
- return (FALSE);
- return (TRUE);
+ return (false);
+ return (true);
}
#undef N
*/
struct Job : public FaxRequest {
time_t lastmod; // last file modify time, for updates
- fxBool queued; // for SNPP
+ bool queued; // for SNPP
Job(const fxStr& qf, int fd = -1);
~Job();
- fxBool checkDocument(const char* pathname);
+ bool checkDocument(const char* pathname);
};
fxDECLARE_StrKeyDictionary(JobDict, Job*)
* Received facsimile information.
*/
struct RecvInfo : public FaxRecvInfo {
- fxBool beingReceived; // currently being received
+ bool beingReceived; // currently being received
time_t recvTime; // time receive operation started
RecvInfo();
struct tab { // protocol command table entry
const char* name;
Token token;
- fxBool checklogin; // if TRUE, must be logged in first
- fxBool implemented; // FALSE if command is not implemented
+ bool checklogin; // if true, must be logged in first
+ bool implemented; // false if command is not implemented
const char* help;
};
*/
struct SpoolDir {
const char* pathname;
- fxBool adminOnly; // accessible by unprivileged clients
- fxBool storAble; // unprivileged clients may STOR files
- fxBool deleAble; // unprivileged clients may DELE files
+ bool adminOnly; // accessible by unprivileged clients
+ bool storAble; // unprivileged clients may STOR files
+ bool deleAble; // unprivileged clients may DELE files
ino_t ino; // directory inode number
- fxBool (*isVisibleFile)(const char*, const struct stat&);
+ bool (*isVisibleFile)(const char*, const struct stat&);
void (HylaFAXServer::*listDirectory)(FILE*, const SpoolDir&, DIR*);
void (HylaFAXServer::*listFile)(FILE*, const SpoolDir&,
const char*, const struct stat&);
void listCmd(const char* name); // LIST
void nlstCmd(const char* name); // NLST
void storeCmd(const char*, const char*);// STOR+APPE
- void storeUniqueCmd(fxBool isTemp); // STOU+STOT
+ void storeUniqueCmd(bool isTemp); // STOU+STOT
void statFileCmd(const char* name); // STAT
void chownCmd(const char*, const char*);// CHOWN
void chmodCmd(const char*, u_int); // CHMOD
void configCmd(const char* where, const char* info);
virtual void initServer(void);
- fxBool readShutdownFile(void);
- fxBool isShutdown(fxBool quiet);
+ bool readShutdownFile(void);
+ bool isShutdown(bool quiet);
void fatal(const char *fmt, ...);
void reply(int code, const char* fmt, ...);
void vreply(int code, const char* fmt, va_list ap);
void setFileOwner(const char* filename);
void loginRefused(const char* why);
- fxBool checkUser(const char*);
- fxBool checkuser(FILE*, const char *name);
+ bool checkUser(const char*);
+ bool checkuser(FILE*, const char *name);
void login(void);
void end_login(void);
virtual void dologout(int status);
const char* fixPathname(const char* file);
const char* userName(u_int uid);
- fxBool userID(const char*, u_int& id);
+ bool userID(const char*, u_int& id);
void fillIDCache(void);
- fxBool cvtPasswd(const char* type, const char* pass, fxStr& result);
- fxBool findUser(FILE* db, const char* user, u_int& newuid);
- fxBool addUser(FILE* db, const char* user, u_int uid,
+ bool cvtPasswd(const char* type, const char* pass, fxStr& result);
+ bool findUser(FILE* db, const char* user, u_int& newuid);
+ bool addUser(FILE* db, const char* user, u_int uid,
const char* upass, const char* apass);
- fxBool deleteUser(FILE* db, const char* user);
+ bool deleteUser(FILE* db, const char* user);
/*
* Configuration file support.
void setupConfig();
void configError(const char* fmt, ...);
void configTrace(const char* fmt, ...);
- fxBool setConfigItem(const char* tag, const char* value);
+ bool setConfigItem(const char* tag, const char* value);
- fxBool restartSend(FILE* fd, off_t marker);
+ bool restartSend(FILE* fd, off_t marker);
static SpoolDir dirs[];
static SpoolDir* dirLookup(ino_t ino);
SpoolDir* dirAccess(const char* path);
SpoolDir* fileAccess(const char* path, int op, struct stat&);
- fxBool fileVisible(const SpoolDir&, const char*, const struct stat&);
+ bool fileVisible(const SpoolDir&, const char*, const struct stat&);
- static fxBool isVisibleRecvQFile(const char*, const struct stat&);
+ static bool isVisibleRecvQFile(const char*, const struct stat&);
void listRecvQ(FILE* fd, const SpoolDir& sd, DIR* dir);
void listRecvQFile(FILE*, const SpoolDir&, const char*, const struct stat&);
- static fxBool isVisibleSendQFile(const char*, const struct stat&);
+ static bool isVisibleSendQFile(const char*, const struct stat&);
void listSendQ(FILE* fd, const SpoolDir& sd, DIR* dir);
void listSendQFile(FILE*, const SpoolDir&, const char*, const struct stat&);
void nlstSendQ(FILE* fd, const SpoolDir& sd, DIR* dir);
void listStatusFile(FILE*, const SpoolDir&, const char*, const struct stat&);
void nlstStatus(FILE* fd, const SpoolDir& sd, DIR* dir);
- static fxBool isVisibleTRUE(const char*, const struct stat&);
- static fxBool isVisibleDocQFile(const char*, const struct stat&);
- static fxBool isVisibleRootFile(const char*, const struct stat&);
+ static bool isVisibletrue(const char*, const struct stat&);
+ static bool isVisibleDocQFile(const char*, const struct stat&);
+ static bool isVisibleRootFile(const char*, const struct stat&);
void listDirectory(FILE* fd, const SpoolDir& sd, DIR* dir);
void listUnixFile(FILE*, const SpoolDir&, const char*, const struct stat&);
- void makeProt(const struct stat& sb, fxBool withGrp, char prot[10]);
+ void makeProt(const struct stat& sb, bool withGrp, char prot[10]);
void Fprintf(FILE*, const char* fmt, const char*, const struct stat&);
void nlstDirectory(FILE* fd, const SpoolDir& sd, DIR* dir);
static const char* dataConnMsg(int code);
virtual void closeDataConn(FILE*);
- fxBool sendData(FILE* fdin, FILE* fdout);
- fxBool sendIData(int fdin, int fdout);
- fxBool sendZData(int fdin, int fdout);
- fxBool recvData(FILE* instr, FILE* outstr);
- fxBool recvIData(int fdin, int fdout);
- fxBool recvZData(int fdin, int fdout);
+ bool sendData(FILE* fdin, FILE* fdout);
+ bool sendIData(int fdin, int fdout);
+ bool sendZData(int fdin, int fdout);
+ bool recvData(FILE* instr, FILE* outstr);
+ bool recvIData(int fdin, int fdout);
+ bool recvZData(int fdin, int fdout);
TIFF* openTIFF(const char* name);
- fxBool sendTIFFData(TIFF* tif, FILE* fdout);
- fxBool sendTIFFHeader(TIFF* tif, int fdout);
- fxBool sendITIFFData(TIFF* tif, int fdout);
+ bool sendTIFFData(TIFF* tif, FILE* fdout);
+ bool sendTIFFHeader(TIFF* tif, int fdout);
+ bool sendITIFFData(TIFF* tif, int fdout);
void logTransfer(const char*, const SpoolDir&, const char*, time_t);
virtual int parse(void);
- fxBool cmd(Token t);
- fxBool site_cmd(Token t);
- fxBool param_cmd(Token t);
- fxBool string_param(fxStr&, const char* what = NULL);
- fxBool number_param(long&);
- fxBool boolean_param(fxBool&);
- fxBool file_param(fxStr& pathname);
- fxBool pwd_param(fxStr& s);
- fxBool timespec_param(int ndigits, time_t& t);
- fxBool pathname_param(fxStr& pathname);
- fxBool job_param(fxStr& jid);
- fxBool jgrp_param(fxStr& jgid);
- fxBool pathname(fxStr& s);
- fxBool CRLF();
- fxBool SP();
- fxBool COMMA();
- fxBool TIMESPEC(u_int len, time_t& result);
- fxBool BOOLEAN(fxBool& b);
- fxBool STRING(fxStr& s, const char* what = NULL);
- fxBool NUMBER(long& n);
- fxBool checkNUMBER(const char* s);
- fxBool opt_CRLF();
- fxBool opt_STRING(fxStr& s);
- fxBool multi_STRING(fxStr& s);
+ bool cmd(Token t);
+ bool site_cmd(Token t);
+ bool param_cmd(Token t);
+ bool string_param(fxStr&, const char* what = NULL);
+ bool number_param(long&);
+ bool boolean_param(bool&);
+ bool file_param(fxStr& pathname);
+ bool pwd_param(fxStr& s);
+ bool timespec_param(int ndigits, time_t& t);
+ bool pathname_param(fxStr& pathname);
+ bool job_param(fxStr& jid);
+ bool jgrp_param(fxStr& jgid);
+ bool pathname(fxStr& s);
+ bool CRLF();
+ bool SP();
+ bool COMMA();
+ bool TIMESPEC(u_int len, time_t& result);
+ bool BOOLEAN(bool& b);
+ bool STRING(fxStr& s, const char* what = NULL);
+ bool NUMBER(long& n);
+ bool checkNUMBER(const char* s);
+ bool opt_CRLF();
+ bool opt_STRING(fxStr& s);
+ bool multi_STRING(fxStr& s);
static u_int twodigits(const char* cp, u_int range);
static u_int fourdigits(const char* cp);
virtual void syntaxError(const char* msg);
virtual void netStatus(FILE*) = 0; // depends on transport
- virtual fxBool hostPort() = 0; // depends on transport
+ virtual bool hostPort() = 0; // depends on transport
- int getChar(fxBool waitForInput);
+ int getChar(bool waitForInput);
void pushCmdData(const char* data, int n);
- fxBool getCmdLine(char* s, int n, fxBool waitForInput = FALSE);
+ bool getCmdLine(char* s, int n, bool waitForInput = false);
void pushToken(Token t);
Token nextToken(void);
- fxBool checkToken(Token);
- fxBool getToken(Token, const char*);
+ bool checkToken(Token);
+ bool getToken(Token, const char*);
void helpCmd(const tab* ctab, const char* s);
void logcmd(Token t, const char* fmt = NULL, ...);
void cmdFailure(Token t, const char* why);
- fxBool checklogin(Token);
- fxBool checkadmin(Token);
+ bool checklogin(Token);
+ bool checkadmin(Token);
static const char* version;
virtual const char* siteToken(Token t);
static const char* parmToken(Token t);
- fxBool initClientFIFO(fxStr& emsg);
+ bool initClientFIFO(fxStr& emsg);
int FIFOInput(int fd);
void FIFOMessage(const char* cp, u_int len);
- fxBool sendModem(const char* modem, fxStr& emsg, const char* fmt ...);
- fxBool sendQueuerMsg(fxStr& emsg, const fxStr& msg);
- fxBool sendQueuer(fxStr& emsg, const char* fmt ...);
- fxBool sendQueuerACK(fxStr& emsg, const char* fmt, ...);
- fxBool vsendQueuerACK(fxStr& emsg, const char* fmt, va_list ap);
-
- fxBool newTrigger(fxStr& emsg, const char* fmt, ...);
- fxBool vnewTrigger(fxStr& emsg, const char* fmt, va_list ap);
- fxBool loadTrigger(fxStr& emsg);
- fxBool cancelTrigger(fxStr& emsg);
+ bool sendModem(const char* modem, fxStr& emsg, const char* fmt ...);
+ bool sendQueuerMsg(fxStr& emsg, const fxStr& msg);
+ bool sendQueuer(fxStr& emsg, const char* fmt ...);
+ bool sendQueuerACK(fxStr& emsg, const char* fmt, ...);
+ bool vsendQueuerACK(fxStr& emsg, const char* fmt, va_list ap);
+
+ bool newTrigger(fxStr& emsg, const char* fmt, ...);
+ bool vnewTrigger(fxStr& emsg, const char* fmt, va_list ap);
+ bool loadTrigger(fxStr& emsg);
+ bool cancelTrigger(fxStr& emsg);
void triggerEvent(const TriggerMsgHeader& h, const char* data);
void logEventMsg(const TriggerMsgHeader&h, fxStr& msg);
void logJobEventMsg(const TriggerMsgHeader&, const JobExt&);
virtual void initDefaultJob(void);
void parmBotch(Token t);
- fxBool checkAccess(const Job& job, Token t, u_int op);
- fxBool checkParm(Job&, Token t, u_int op);
- fxBool checkJobState(Job*);
+ bool checkAccess(const Job& job, Token t, u_int op);
+ bool checkParm(Job&, Token t, u_int op);
+ bool checkJobState(Job*);
void replyJobParamValue(Job&, int code, Token t);
- void replyBoolean(int code, fxBool b);
- fxBool setValue(u_short& v, const char* value, const char* what,
+ void replyBoolean(int code, bool b);
+ bool setValue(u_short& v, const char* value, const char* what,
const char* valNames[], u_int nValNames);
void flushPreparedDocuments(Job& job);
- fxBool setJobParameter(Job&, Token t, const fxStr& value);
- fxBool setJobParameter(Job&, Token t, u_short value);
- fxBool setJobParameter(Job&, Token t, time_t value);
- fxBool setJobParameter(Job&, Token t, fxBool b);
- fxBool setJobParameter(Job&, Token t, float value);
- fxBool docType(const char* docname, FaxSendOp& op);
- fxBool checkAddDocument(Job&, Token type, const char* docname, FaxSendOp&);
+ bool setJobParameter(Job&, Token t, const fxStr& value);
+ bool setJobParameter(Job&, Token t, u_short value);
+ bool setJobParameter(Job&, Token t, time_t value);
+ bool setJobParameter(Job&, Token t, bool b);
+ bool setJobParameter(Job&, Token t, float value);
+ bool docType(const char* docname, FaxSendOp& op);
+ bool checkAddDocument(Job&, Token type, const char* docname, FaxSendOp&);
void addCoverDocument(Job&, const char* docname);
void addDocument(Job&, const char* docname);
void addPollOp(Job&, const char* sep, const char* pwd);
void newJobCmd(void);
- fxBool newJob(fxStr& emsg);
+ bool newJob(fxStr& emsg);
Job* findJob(const char* jobid, fxStr& emsg);
Job* findJobInMemmory(const char* jobid);
Job* findJobOnDisk(const char* jobid, fxStr& emsg);
- fxBool updateJobFromDisk(Job& job);
+ bool updateJobFromDisk(Job& job);
void replyCurrentJob(const char* leader);
void setCurrentJob(const char* jobid);
Job* preJobCmd(const char* op, const char* jobid, fxStr& emsg);
void suspendJob(const char* jobid);
void submitJob(const char* jobid);
void waitForJob(const char* jobid);
- fxBool updateJobOnDisk(Job& req, fxStr& emsg);
- fxBool lockJob(Job& job, int how, fxStr& emsg);
- fxBool lockJob(Job& job, int how);
+ bool updateJobOnDisk(Job& req, fxStr& emsg);
+ bool lockJob(Job& job, int how, fxStr& emsg);
+ bool lockJob(Job& job, int how);
void unlockJob(Job& job);
#ifdef OLDPROTO_SUPPORT
void readJobs(void);
u_int getJobNumber(fxStr&);
u_int getDocumentNumbers(u_int count, fxStr&);
- fxBool getRecvDocStatus(RecvInfo& ri);
+ bool getRecvDocStatus(RecvInfo& ri);
RecvInfo* getRecvInfo(const fxStr& qfile, const struct stat& sb);
const char* compactRecvTime(time_t t);
void Rprintf(FILE*, const char*, const RecvInfo&, const struct stat&);
{}
InetSuperServer::~InetSuperServer() {}
-fxBool
+bool
InetSuperServer::startServer(void)
{
int s = socket(AF_INET, SOCK_STREAM, 0);
if (Socket::bind(s, &sin, sizeof (sin)) >= 0) {
(void) listen(s, getBacklog());
Dispatcher::instance().link(s, Dispatcher::ReadMask, this);
- return (TRUE); // success
+ return (true); // success
}
Sys::close(s);
logError("HylaFAX %s: bind (port %u): %m",
getKind(), ntohs(sin.sin_port));
} else
logError("HylaFAX %s: socket: %m", getKind());
- return (FALSE);
+ return (false);
}
HylaFAXServer* InetSuperServer::newChild(void) { return new InetFaxServer; }
InetFaxServer::InetFaxServer()
{
- usedefault = TRUE;
+ usedefault = true;
swaitmax = 90; // wait at most 90 seconds
swaitint = 5; // interval between retries
InetFaxServer::initServer(void)
{
HylaFAXServer::initServer();
- usedefault = TRUE;
+ usedefault = true;
}
void
* assume that the host is local, as it will be
* interpreted as such.
*/
-fxBool
+bool
InetFaxServer::isLocalDomain(const fxStr& h)
{
const char* p1 = topDomain(hostname);
* look up the name and check that the peer's address
* corresponds to the host name.
*/
-fxBool
+bool
InetFaxServer::checkHostIdentity(hostent*& hp)
{
if (!isLocalDomain(hp->h_name)) // not local, don't check
- return (TRUE);
+ return (true);
fxStr name(hp->h_name); // must copy static value
hp = Socket::gethostbyname(name);
if (hp) {
for (const char** cpp = (const char**) hp->h_addr_list; *cpp; cpp++)
if (memcmp(*cpp, &peer_addr.sin_addr, hp->h_length) == 0)
- return (TRUE);
+ return (true);
reply(130, "Warning, client address \"%s\" is not listed for host name \"%s\".",
(const char*) remoteaddr, hp->h_name);
} else
reply(130, "Warning, no inverse address mapping for client host name \"%s\".",
(const char*) name);
- return (FALSE);
+ return (false);
}
void
}
void InetFaxServer::sigPIPE(int) { InetFaxServer::instance().lostConnection(); }
-static fxBool
+static bool
setupPassiveDataSocket(int pdata, struct sockaddr_in& pasv_addr)
{
socklen_t len = sizeof (pasv_addr);
return (NULL);
}
-fxBool
+bool
InetFaxServer::dataConnect(void)
{
return Socket::connect(data, &data_dest,sizeof (data_dest)) >= 0;
return (file);
}
-fxBool
+bool
InetFaxServer::hostPort()
{
long a0, a1, a2, a3;
long p0, p1;
- fxBool syntaxOK =
+ bool syntaxOK =
NUMBER(a0)
&& COMMA() && NUMBER(a1)
&& COMMA() && NUMBER(a2)
u_char* p = (u_char*) &data_dest.sin_port;
a[0] = UC(a0); a[1] = UC(a1); a[2] = UC(a2); a[3] = UC(a3);
p[0] = UC(p0); p[1] = UC(p1);
- return (TRUE);
+ return (true);
} else
- return (FALSE);
+ return (false);
}
void
InetFaxServer::portCmd(void)
{
logcmd(T_PORT, "%s;%u", inet_ntoa(data_dest.sin_addr), data_dest.sin_port);
- usedefault = FALSE;
+ usedefault = false;
if (pdata >= 0)
(void) Sys::close(pdata), pdata = -1;
ack(200, cmdToken(T_PORT));
sockaddr_in data_source; // source of data connection
sockaddr_in data_dest; // destination of data connection
sockaddr_in pasv_addr; // local end of passive connections
- fxBool usedefault; // for data transfers
+ bool usedefault; // for data transfers
/*
* Timeout intervals for retrying connections
* to hosts that don't accept PORT cmds.
int swaitmax; // wait at most 90 seconds
int swaitint; // interval between retries
- fxBool isLocalDomain(const fxStr& h);
- fxBool checkHostIdentity(hostent*& hp);
+ bool isLocalDomain(const fxStr& h);
+ bool checkHostIdentity(hostent*& hp);
void setupNetwork(int fd);
void handleUrgentData(void);
void passiveCmd(void);
void netStatus(FILE*);
void printaddr(FILE*, const char* leader, const struct sockaddr_in& sin);
- fxBool hostPort();
+ bool hostPort();
void portCmd(void);
- fxBool dataConnect(void);
+ bool dataConnect(void);
FILE* getDataSocket(const char* mode);
FILE* openDataConn(const char* mode, int& code);
private:
fxStr port;
protected:
- fxBool startServer(void);
+ bool startServer(void);
HylaFAXServer* newChild(void);
public:
InetSuperServer(const char* port, int backlog = 5);
Job::Job(const fxStr& qf, int f) : FaxRequest(qf,f)
{
lastmod = 0;
- queued = FALSE;
+ queued = false;
}
Job::~Job() {}
* check for ``..'' and ``/'' being used to reference
* files outside the spooling area.
*/
-fxBool
+bool
Job::checkDocument(const char* pathname)
{
struct stat sb;
* ownership is based on login account and not fax uid;
* this may need to be rethought.
*/
-fxBool
+bool
HylaFAXServer::checkAccess(const Job& job, Token t, u_int op)
{
u_int n = N(params)-1;
i++;
u_int m = params[i].protect;
if (m&op) // other/public access
- return (TRUE);
+ return (true);
if (IS(PRIVILEGED) && ((m>>3)&op)) // administrative access
- return (TRUE);
+ return (true);
if (job.owner == the_user && ((m>>6)&op)) // owner access
- return (TRUE);
- return (FALSE);
+ return (true);
+ return (false);
}
static const struct {
};
static const char*
-boolString(fxBool b)
+boolString(bool b)
{
return (b ? "YES" : "NO");
}
void
-HylaFAXServer::replyBoolean(int code, fxBool b)
+HylaFAXServer::replyBoolean(int code, bool b)
{
reply(code, "%s", boolString(b));
}
* and send the client an error reply. This method is used
* before each place a job's state is access.
*/
-fxBool
+bool
HylaFAXServer::checkJobState(Job* job)
{
/*
if (job == curJob) // make default job current
curJob = &defJob;
delete job, job = NULL;
- return (FALSE);
+ return (false);
}
if (job->lastmod < sb.st_mtime) {
(void) updateJobFromDisk(*job);
job->lastmod = sb.st_mtime;
}
- return (TRUE);
+ return (true);
}
/*
* could be lost (in our case they will be lost due to the
* way that things work).
*/
-fxBool
+bool
HylaFAXServer::checkParm(Job& job, Token t, u_int op)
{
if (!checkJobState(&job)) { // insure consistent state
reply(500, "Cannot access job %s state; job deleted by another party.",
(const char*) job.jobid);
- return (FALSE);
+ return (false);
} else if (!checkAccess(job, t, op)) {
reply(503, "Permission denied: no %s access to job parameter %s."
, (op == A_READ ? "read" : "write")
, parmToken(t)
);
- return (FALSE);
+ return (false);
} else if ((op & (A_WRITE|A_MODIFY)) &&
job.state != FaxRequest::state_suspended && job.jobid != "default") {
reply(503, "Suspend the job with JSUSP first.");
- return (FALSE);
+ return (false);
} else
- return (TRUE);
+ return (true);
}
/*
* array. Parameter names are case-insensitive.
* Unknown values cause an error reply.
*/
-fxBool
+bool
HylaFAXServer::setValue(u_short& v, const char* value, const char* what,
const char* valNames[], u_int nValNames)
{
for (u_int i = 0; i < nValNames; i++)
if (strcasecmp(value, valNames[i]) == 0) {
v = i;
- return (TRUE);
+ return (true);
}
reply(503, "Unknown %s value %s.", what, value);
- return (FALSE);
+ return (false);
}
void
/*
* Set a job state parameter that has a string value.
*/
-fxBool
+bool
HylaFAXServer::setJobParameter(Job& job, Token t, const fxStr& value)
{
if (checkParm(job, t, A_WRITE|A_MODIFY)) {
if (setValue(job.pagechop, value, parmToken(t),
chopVals, N(chopVals))) {
job.pagehandling = ""; // force recalculation
- return (TRUE);
+ return (true);
} else
- return (FALSE);
+ return (false);
case T_DATAFORMAT:
if (setValue(job.desireddf, value, parmToken(t),
dataVals, N(dataVals))) {
flushPreparedDocuments(job);
- return (TRUE);
+ return (true);
} else
- return (FALSE);
+ return (false);
}
for (u_int i = 0, n = N(strvals); i < n; i++)
if (strvals[i].t == t) {
job.*strvals[i].p = value;
- return (TRUE);
+ return (true);
}
parmBotch(t);
}
- return (FALSE);
+ return (false);
}
/*
* Set a job state parameter that has a integer value.
*/
-fxBool
+bool
HylaFAXServer::setJobParameter(Job& job, Token t, u_short value)
{
if (checkParm(job, t, A_WRITE|A_MODIFY)) {
break;
}
}
- return (TRUE);
+ return (true);
}
parmBotch(t);
}
- return (FALSE);
+ return (false);
}
/*
* Set a job state parameter that has a time value.
*/
-fxBool
+bool
HylaFAXServer::setJobParameter(Job& job, Token t, time_t value)
{
if (checkParm(job, t, A_WRITE|A_MODIFY)) {
if (value != 0) { // explicit time
if (value < now) {
reply(503, "Bad time to send; time in the past."); // XXX
- return (FALSE);
+ return (false);
}
job.tts = value;
} else // ``NOW''
job.tts = now;
- return (TRUE);
+ return (true);
case T_LASTTIME:
/*
* Convert client-specified kill time (as a relative number)
* value may be installed for LASTTIME.
*/
job.killtime = value + (job.tts == 0 ? now : job.tts);
- return (TRUE);
+ return (true);
case T_RETRYTIME:
job.retrytime = value;
- return (TRUE);
+ return (true);
}
parmBotch(t);
}
- return (FALSE);
+ return (false);
}
/*
* Set a job state parameter that has a boolean value.
*/
-fxBool
-HylaFAXServer::setJobParameter(Job& job, Token t, fxBool b)
+bool
+HylaFAXServer::setJobParameter(Job& job, Token t, bool b)
{
if (checkParm(job, t, A_WRITE|A_MODIFY)) {
switch (t) {
case T_USE_ECM:
job.desiredec = b;
- return (TRUE);
+ return (true);
case T_USE_TAGLINE:
job.desiredtl = b;
- return (TRUE);
+ return (true);
case T_USE_CONTCOVER:
job.useccover = b;
- return (TRUE);
+ return (true);
}
parmBotch(t);
}
- return (TRUE);
+ return (true);
}
/*
* Set a job state parameter that has a float value.
*/
-fxBool
+bool
HylaFAXServer::setJobParameter(Job& job, Token t, float value)
{
if (checkParm(job, t, A_WRITE|A_MODIFY)) {
job.chopthreshold = value;
job.pagehandling = ""; // force recalculation
}
- return (TRUE);
+ return (true);
}
parmBotch(t);
}
- return (FALSE);
+ return (false);
}
/*
defJob.desiredst = ST_0MS;
defJob.desiredec = EC_ENABLE;
defJob.desireddf = DF_2DMMR;
- defJob.desiredtl = FALSE;
- defJob.useccover = TRUE;
+ defJob.desiredtl = false;
+ defJob.useccover = true;
defJob.pagechop = FaxRequest::chop_default;
defJob.notify = FaxRequest::no_notice;// FAX_DEFNOTIFY
defJob.chopthreshold= 3.0;
* information in dial strings and passwords to be
* transmitted with polling requests.
*/
-fxBool
+bool
HylaFAXServer::newJob(fxStr& emsg)
{
if (!IS(PRIVILEGED) && the_user != curJob->owner) {
emsg = "Permission denied; cannot inherit from job " | curJob->jobid;
- return (FALSE);
+ return (false);
}
u_int id = getJobNumber(emsg); // allocate unique job ID
if (id == (u_int) -1)
- return (FALSE);
+ return (false);
fxStr jobid = fxStr::format("%u", id);
Job* job = new Job(FAX_SENDDIR "/" FAX_QFILEPREF | jobid);
job->jobid = jobid;
job->queued = curJob->queued;
jobs[jobid] = job;
curJob = job;
- return (TRUE);
+ return (true);
}
/*
* Update the job's state on disk.
*/
-fxBool
+bool
HylaFAXServer::updateJobOnDisk(Job& job, fxStr& emsg)
{
if (lockJob(job, LOCK_EX|LOCK_NB, emsg)) {
// XXX don't update in place, use temp file and rename
job.writeQFile();
unlockJob(job);
- return (TRUE);
+ return (true);
} else
- return (FALSE);
+ return (false);
}
/*
if (fd >= 0) {
// XXX should we lock here???
Job* req = new Job(&filename[1], fd);
- fxBool reject;
+ bool reject;
if (req->readQFile(reject) && !reject) {
Sys::close(req->fd), req->fd = -1;
return (req);
/*
* Update a job's state from the on-disk copy.
*/
-fxBool
+bool
HylaFAXServer::updateJobFromDisk(Job& job)
{
- fxBool status = FALSE;
+ bool status = false;
if (lockJob(job, LOCK_SH|LOCK_NB)) {
- fxBool reject;
+ bool reject;
status = (job.reReadQFile(reject) && !reject);
unlockJob(job);
}
* occurs a descriptive message is returned for
* transmission to the client.
*/
-fxBool
+bool
HylaFAXServer::lockJob(Job& job, int how, fxStr& emsg)
{
if (job.fd < 0) {
job.fd = Sys::open("/" | job.qfile, O_RDWR|O_CREAT, 0600);
if (job.fd < 0) {
emsg = "Cannot open/create job description file /" | job.qfile;
- return (FALSE);
+ return (false);
}
}
if (flock(job.fd, how) < 0) {
emsg = fxStr::format("Job file lock failed: %s", strerror(errno));
Sys::close(job.fd), job.fd = -1;
- return (FALSE);
+ return (false);
} else
- return (TRUE);
+ return (true);
}
/*
* Like above, but no error message is returned.
*/
-fxBool
+bool
HylaFAXServer::lockJob(Job& job, int how)
{
if (job.fd < 0)
* Do common work used in adding a document to a
* job's set of documents that are to be sent.
*/
-fxBool
+bool
HylaFAXServer::checkAddDocument(Job& job, Token type,
const char* docname, FaxSendOp& op)
{
else if (!docType(docname, op))
reply(550, "%s: Document type not recognized.", docname);
else
- return (TRUE);
+ return (true);
}
- return (FALSE);
+ return (false);
}
/*
* Directory interface support for querying job status.
*/
-fxBool
+bool
HylaFAXServer::isVisibleSendQFile(const char* filename, const struct stat&)
{
return (filename[0] == 'q');
* implies read access to anything else in the
* job state that is protected.
*/
- fxBool haveAccess = checkAccess(job, T_DIALSTRING, A_READ);
+ bool haveAccess = checkAccess(job, T_DIALSTRING, A_READ);
for (const char* cp = fmt; *cp; cp++) {
if (*cp == '%') {
#define MAXSPEC 20
uid_t ouid = geteuid();
(void) seteuid(0);
- fxBool isSetup = (chroot(".") >= 0 && chdir("/") >= 0);
+ bool isSetup = (chroot(".") >= 0 && chdir("/") >= 0);
/*
* Install the client's fax-uid as the effective gid
* so that created files automatically are given the
end_login();
return;
}
- (void) isShutdown(FALSE); // display any shutdown messages
+ (void) isShutdown(false); // display any shutdown messages
reply(230, "User %s logged in.", (const char*) the_user);
if (TRACE(LOGIN))
logInfo("FAX LOGIN FROM %s [%s], %s"
{}
OldProtocolSuperServer::~OldProtocolSuperServer() {}
-fxBool
+bool
OldProtocolSuperServer::startServer(void)
{
int s = socket(AF_INET, SOCK_STREAM, 0);
if (Socket::bind(s, &sin, sizeof (sin)) >= 0) {
(void) listen(s, getBacklog());
Dispatcher::instance().link(s, Dispatcher::ReadMask, this);
- return (TRUE); // success
+ return (true); // success
}
Sys::close(s);
logError("HylaFAX %s: bind (port %u): %m",
getKind(), ntohs(sin.sin_port));
} else
logError("HylaFAX %s: socket: %m", getKind());
- return (FALSE);
+ return (false);
}
HylaFAXServer* OldProtocolSuperServer::newChild(void)
{ return new OldProtocolServer; }
OldProtocolServer::OldProtocolServer()
{
version = 0;
- alreadyChecked = FALSE;
+ alreadyChecked = false;
codetab = NULL;
}
OldProtocolServer::~OldProtocolServer() {}
(const char*) remotehost, (const char*) remoteaddr);
fxStr emsg;
- if (isShutdown(TRUE)) {
+ if (isShutdown(true)) {
logInfo("HylaFAX Old connection refused (server shut down) from %s [%s]",
(const char*) remotehost, (const char*) remoteaddr);
dologout(-1);
* look up the name and check that the peer's address
* corresponds to the host name.
*/
-fxBool
+bool
OldProtocolServer::checkHostIdentity(hostent*& hp)
{
if (!isLocalDomain(hp->h_name)) // not local, don't check
- return (TRUE);
+ return (true);
fxStr name(hp->h_name); // must copy static value
hp = Socket::gethostbyname(name);
if (hp) {
for (const char** cpp = (const char**) hp->h_addr_list; *cpp; cpp++)
if (memcmp(*cpp, &peer_addr.sin_addr, hp->h_length) == 0)
- return (TRUE);
+ return (true);
sendError("Client address %s is not listed for host name %s.",
(const char*) remoteaddr, hp->h_name);
} else
sendError("No inverse address mapping for client host name %s.",
(const char*) name);
- return (FALSE);
+ return (false);
}
void
// NB: there is no support for the old style data transfer
const OldProtocolServer::protoCmd OldProtocolServer::cmds[] = {
-{ "begin", TRUE, &OldProtocolServer::submitJob },
-{ "checkPerm", TRUE, &OldProtocolServer::ackPermission },
-{ "tiff", TRUE, &OldProtocolServer::getTIFFData },
-{ "postscript", TRUE, &OldProtocolServer::getPostScriptData },
-{ "zpostscript", TRUE, &OldProtocolServer::getZPostScriptData },
-{ "opaque", TRUE, &OldProtocolServer::getOpaqueData },
-{ "zopaque", TRUE, &OldProtocolServer::getZOpaqueData },
-{ "poll", TRUE, &OldProtocolServer::newPollID },
-{ "userID", FALSE, &OldProtocolServer::setUserID },
-{ "version", FALSE, &OldProtocolServer::setProtoVersion },
-{ "serverStatus", FALSE, &OldProtocolServer::sendServerStatus },
-{ "serverInfo", FALSE, &OldProtocolServer::sendServerInfo },
-{ "allStatus", FALSE, &OldProtocolServer::sendAllStatus },
-{ "userStatus", FALSE, &OldProtocolServer::sendUserStatus },
-{ "jobStatus", FALSE, &OldProtocolServer::sendJobStatus },
-{ "recvStatus", FALSE, &OldProtocolServer::sendRecvStatus },
-{ "remove", TRUE, &OldProtocolServer::removeJob },
-{ "removeGroup", TRUE, &OldProtocolServer::removeJobGroup },
-{ "kill", TRUE, &OldProtocolServer::killJob },
-{ "killGroup", TRUE, &OldProtocolServer::killJobGroup },
-{ "alterTTS", TRUE, &OldProtocolServer::alterJobTTS },
-{ "alterGroupTTS", TRUE, &OldProtocolServer::alterJobGroupTTS },
-{ "alterKillTime", TRUE, &OldProtocolServer::alterJobKillTime },
-{ "alterGroupKillTime", TRUE, &OldProtocolServer::alterJobGroupKillTime },
-{ "alterMaxDials", TRUE, &OldProtocolServer::alterJobMaxDials },
-{ "alterGroupMaxDials", TRUE, &OldProtocolServer::alterJobGroupMaxDials },
-{ "alterNotify", TRUE, &OldProtocolServer::alterJobNotification },
-{ "alterGroupNotify", TRUE, &OldProtocolServer::alterJobGroupNotification },
-{ "alterModem", TRUE, &OldProtocolServer::alterJobModem },
-{ "alterGroupModem", TRUE, &OldProtocolServer::alterJobGroupModem },
-{ "alterPriority", TRUE, &OldProtocolServer::alterJobPriority },
-{ "alterGroupPriority", TRUE, &OldProtocolServer::alterJobGroupPriority },
+{ "begin", true, &OldProtocolServer::submitJob },
+{ "checkPerm", true, &OldProtocolServer::ackPermission },
+{ "tiff", true, &OldProtocolServer::getTIFFData },
+{ "postscript", true, &OldProtocolServer::getPostScriptData },
+{ "zpostscript", true, &OldProtocolServer::getZPostScriptData },
+{ "opaque", true, &OldProtocolServer::getOpaqueData },
+{ "zopaque", true, &OldProtocolServer::getZOpaqueData },
+{ "poll", true, &OldProtocolServer::newPollID },
+{ "userID", false, &OldProtocolServer::setUserID },
+{ "version", false, &OldProtocolServer::setProtoVersion },
+{ "serverStatus", false, &OldProtocolServer::sendServerStatus },
+{ "serverInfo", false, &OldProtocolServer::sendServerInfo },
+{ "allStatus", false, &OldProtocolServer::sendAllStatus },
+{ "userStatus", false, &OldProtocolServer::sendUserStatus },
+{ "jobStatus", false, &OldProtocolServer::sendJobStatus },
+{ "recvStatus", false, &OldProtocolServer::sendRecvStatus },
+{ "remove", true, &OldProtocolServer::removeJob },
+{ "removeGroup", true, &OldProtocolServer::removeJobGroup },
+{ "kill", true, &OldProtocolServer::killJob },
+{ "killGroup", true, &OldProtocolServer::killJobGroup },
+{ "alterTTS", true, &OldProtocolServer::alterJobTTS },
+{ "alterGroupTTS", true, &OldProtocolServer::alterJobGroupTTS },
+{ "alterKillTime", true, &OldProtocolServer::alterJobKillTime },
+{ "alterGroupKillTime", true, &OldProtocolServer::alterJobGroupKillTime },
+{ "alterMaxDials", true, &OldProtocolServer::alterJobMaxDials },
+{ "alterGroupMaxDials", true, &OldProtocolServer::alterJobGroupMaxDials },
+{ "alterNotify", true, &OldProtocolServer::alterJobNotification },
+{ "alterGroupNotify", true, &OldProtocolServer::alterJobGroupNotification },
+{ "alterModem", true, &OldProtocolServer::alterJobModem },
+{ "alterGroupModem", true, &OldProtocolServer::alterJobGroupModem },
+{ "alterPriority", true, &OldProtocolServer::alterJobPriority },
+{ "alterGroupPriority", true, &OldProtocolServer::alterJobGroupPriority },
};
#define NCMDS (sizeof (cmds) / sizeof (cmds[0]))
);
dologout(-1);
}
- alreadyChecked = TRUE;
+ alreadyChecked = true;
}
}
(this->*cmds[i].cmdFunc)(tag);
*/
#include <pwd.h>
-fxBool
+bool
OldProtocolServer::_checkUser(const char* requestor, struct passwd* pwd)
{
char buf[1024];
return (strcmp(requestor, buf) == 0);
}
-fxBool
+bool
OldProtocolServer::isAdmin(const char* requestor)
{
- static fxBool checked = FALSE;
- static fxBool isadmin = FALSE;
+ static bool checked = false;
+ static bool isadmin = false;
if (!checked) {
struct passwd* pwd = getpwuid(getuid());
}
if (!pwd) {
logError("getpwuid failed for effective uid %d: %m", geteuid());
- isadmin = FALSE;
+ isadmin = false;
}
isadmin = _checkUser(requestor, pwd);
if (!isadmin) { /* not fax user */
pwd = getpwnam("root");
if (!pwd) {
logError("getpwnam failed for \"root\": %m");
- isadmin = FALSE;
+ isadmin = false;
} else
isadmin = _checkUser(requestor, pwd); /* root user */
}
- checked = TRUE;
+ checked = true;
}
return (isadmin);
}
void OldProtocolServer::alterJobGroup##param(const char* tag) \
{ applyToJobGroup(tag, "alter", &OldProtocolServer::reallyAlterJob##param); }
-fxBool
+bool
OldProtocolServer::alterSuspend(Job& job)
{
if (job.state == FaxRequest::state_active) {
sendClient("jobLocked", job.jobid); // NB: maintain old semantics
- return (FALSE);
+ return (false);
}
fxStr emsg;
if (!sendQueuerACK(emsg, "X%s", (const char*) job.jobid)) {
sendError("Unable to suspend job: %s", (const char*) emsg);
- return (FALSE);
+ return (false);
}
- return (TRUE);
+ return (true);
}
void
sendClientJobLocked(job);
}
-fxBool
+bool
OldProtocolServer::modemMatch(const fxStr& a, const fxStr& b)
{
return (a == MODEM_ANY || b == MODEM_ANY || a == b);
public:
struct protoCmd {
const char* cmd; // command to match
- fxBool check; // if true, checkPermission first
+ bool check; // if true, checkPermission first
void (OldProtocolServer::*cmdFunc)(const char*);
};
private:
faxRequestArray reqs;
char line[1024]; // current input line
int version;
- fxBool alreadyChecked;
+ bool alreadyChecked;
code_ent* codetab;
fxStr modem; // selected modem
static const protoCmd cmds[];
- fxBool checkHostIdentity(hostent*& hp);
+ bool checkHostIdentity(hostent*& hp);
void setupNetwork(int fd);
void doProtocol(void);
void getCommandLine(char line[1024], char*& tag);
void newPollID(const char* tag);
void setProtoVersion(const char* tag);
void ackPermission(const char*);
- fxBool _checkUser(const char* requestor, struct passwd* pwd);
- fxBool isAdmin(const char* requestor);
+ bool _checkUser(const char* requestor, struct passwd* pwd);
+ bool isAdmin(const char* requestor);
void applyToJob(const char* tag, const char* op,
void (OldProtocolServer::*f)(Job&, const char*));
void applyToJobGroup(const char* tag, const char* op,
void (OldProtocolServer::*f)(Job&, const char*));
- fxBool alterSuspend(Job&);
+ bool alterSuspend(Job&);
void alterResubmit(Job&);
void alterJobTTS(const char*);
void alterJobGroupTTS(const char*);
void getZPostScriptData(const char* tag);
void getZOpaqueData(const char* tag);
void dologout(int status);
- fxBool modemMatch(const fxStr& a, const fxStr& b);
+ bool modemMatch(const fxStr& a, const fxStr& b);
void sendServerStatus(const char*);
void sendServerInfo1(const char* name);
void sendServerInfo(const char*);
private:
fxStr port;
protected:
- fxBool startServer(void);
+ bool startServer(void);
HylaFAXServer* newChild(void);
public:
OldProtocolSuperServer(const char* port, int backlog = 5);
* Standard protocol commands.
*/
static const tab cmdtab[] = {
-{ "ABOR", T_ABOR, FALSE, TRUE, "[modem] (abort operation)" },
-{ "ACCT", T_ACCT, FALSE,FALSE, "(specify account)" },
-{ "ADMIN", T_ADMIN, TRUE, TRUE, "password" },
-{ "ALLO", T_ALLO, FALSE,FALSE, "(allocate disk space)" },
-{ "ANSWER", T_ANSWER, TRUE, TRUE, "modem [DATA|VOICE|FAX]" },
-{ "APPE", T_APPE, TRUE, TRUE, "file-name" },
-{ "CWD", T_CWD, TRUE, TRUE, "[directory-name]" },
-{ "CDUP", T_CDUP, TRUE, TRUE, "(change directory up one level)"},
-{ "CHMOD", T_CHMOD, TRUE, TRUE, "file-name mode" },
-{ "CHOWN", T_CHOWN, TRUE, TRUE, "file-name user" },
-{ "DELE", T_DELE, TRUE, TRUE, "file-name" },
-{ "DISABLE", T_DISABLE, TRUE, TRUE, "modem [reason]" },
-{ "ENABLE", T_ENABLE, TRUE, TRUE, "modem" },
-{ "HELP", T_HELP, FALSE, TRUE, "[<string>]" },
-{ "FILEFMT", T_FILEFMT, TRUE, TRUE, "[format-string]" },
-{ "FORM", T_FORM, TRUE, TRUE, "format-type" },
-{ "IDLE", T_IDLE, TRUE, TRUE, "[max-idle-timeout]" },
-{ "JDELE", T_JDELE, TRUE, TRUE, "[job-id]" },
-{ "JINTR", T_JINTR, TRUE, TRUE, "[job-id]" },
-{ "JKILL", T_JKILL, TRUE, TRUE, "[job-id]" },
-{ "JNEW", T_JNEW, TRUE, TRUE, "" },
-{ "JOB", T_JOB, TRUE, TRUE, "[job-id]" },
-{ "JOBFMT", T_JOBFMT, TRUE, TRUE, "[format-string]" },
-{ "JPARM", T_JPARM, TRUE, TRUE, "[parm-name [parm-value]]" },
-{ "JREST", T_JREST, TRUE, TRUE, "(reset current job state)" },
-{ "JSUBM", T_JSUB, TRUE, TRUE, "[job-id]" },
-{ "JSUSP", T_JSUSP, TRUE, TRUE, "[job-id]" },
-{ "JWAIT", T_JWAIT, TRUE, TRUE, "[job-id]" },
-{ "JGDELE", T_JGDELE, TRUE,FALSE, "[jobgroup-id]" },
-{ "JGINTR", T_JGINTR, TRUE,FALSE, "[jobgroup-id]" },
-{ "JGKILL", T_JGKILL, TRUE,FALSE, "[jobgroup-id]" },
-{ "JGNEW", T_JGNEW, TRUE, TRUE, "" },
-{ "JGPARM", T_JGPARM, TRUE,FALSE, "parm-name [parm-value]" },
-{ "JGREST", T_JGREST, TRUE,FALSE, "(reset current job group state)"},
-{ "JGRP", T_JGRP, TRUE,FALSE, "[jobgroup-id]" },
-{ "JGSUBM", T_JGSUB, TRUE,FALSE, "[jobgroup-id]" },
-{ "JGSUSP", T_JGSUSP, TRUE,FALSE, "[jobgroup-id]" },
-{ "JGWAIT", T_JGWAIT, TRUE,FALSE, "[jobgroup-id]" },
-{ "LIST", T_LIST, TRUE, TRUE, "[path-name]" },
-{ "MDTM", T_MDTM, TRUE, TRUE, "path-name" },
-{ "MODE", T_MODE, FALSE, TRUE, "(specify transfer mode)" },
-{ "MDMFMT", T_MODEMFMT, TRUE, TRUE, "[format-string]" },
-{ "NLST", T_NLST, TRUE, TRUE, "[path-name]" },
-{ "NOOP", T_NOOP, FALSE, TRUE, "" },
-{ "PASS", T_PASS, FALSE, TRUE, "password" },
-{ "PASV", T_PASV, TRUE, TRUE, "(set server in passive mode)" },
-{ "PORT", T_PORT, TRUE, TRUE, "a0,a1,a2,a3,p0,p1" },
-{ "PWD", T_PWD, TRUE, TRUE, "(print working directory)" },
-{ "QUIT", T_QUIT, FALSE, TRUE, "(terminate service)", },
-{ "RCVFMT", T_RCVFMT, TRUE, TRUE, "[format-string]" },
-{ "REIN", T_REIN, FALSE, TRUE, "(reinitialize server state)" },
-{ "REST", T_REST, TRUE, TRUE, "restart-marker" },
-{ "RETP", T_RETP, TRUE, TRUE, "file-name" },
-{ "RETR", T_RETR, TRUE, TRUE, "file-name" },
-{ "RNFR", T_RNFR, TRUE,FALSE, "file-name" },
-{ "RNTO", T_RNTO, TRUE,FALSE, "file-name" },
-{ "SHUT", T_SHUT, TRUE, TRUE, "NOW|HHSS|YYYYMMDDHHSS [reason]" },
-{ "SITE", T_SITE, TRUE, TRUE, "site-cmd [arguments]" },
-{ "SIZE", T_SIZE, TRUE, TRUE, "path-name" },
-{ "STAT", T_STAT, FALSE, TRUE, "[path-name]" },
-{ "STOR", T_STOR, TRUE, TRUE, "file-name" },
-{ "STOT", T_STOT, TRUE, TRUE, "(store unique temporary)" },
-{ "STOU", T_STOU, TRUE, TRUE, "(store unique)" },
-{ "STRU", T_STRU, FALSE, TRUE, "file-structure" },
-{ "SYST", T_SYST, TRUE, TRUE, "(return system type)" },
-{ "TZONE", T_TZONE, TRUE, TRUE, "[GMT|LOCAL]" },
-{ "TYPE", T_TYPE, FALSE, TRUE, "transfer-type" },
-{ "USER", T_USER, FALSE, TRUE, "username" },
-{ "VRFY", T_VRFY, FALSE, TRUE, "dialstring" },
+{ "ABOR", T_ABOR, false, true, "[modem] (abort operation)" },
+{ "ACCT", T_ACCT, false,false, "(specify account)" },
+{ "ADMIN", T_ADMIN, true, true, "password" },
+{ "ALLO", T_ALLO, false,false, "(allocate disk space)" },
+{ "ANSWER", T_ANSWER, true, true, "modem [DATA|VOICE|FAX]" },
+{ "APPE", T_APPE, true, true, "file-name" },
+{ "CWD", T_CWD, true, true, "[directory-name]" },
+{ "CDUP", T_CDUP, true, true, "(change directory up one level)"},
+{ "CHMOD", T_CHMOD, true, true, "file-name mode" },
+{ "CHOWN", T_CHOWN, true, true, "file-name user" },
+{ "DELE", T_DELE, true, true, "file-name" },
+{ "DISABLE", T_DISABLE, true, true, "modem [reason]" },
+{ "ENABLE", T_ENABLE, true, true, "modem" },
+{ "HELP", T_HELP, false, true, "[<string>]" },
+{ "FILEFMT", T_FILEFMT, true, true, "[format-string]" },
+{ "FORM", T_FORM, true, true, "format-type" },
+{ "IDLE", T_IDLE, true, true, "[max-idle-timeout]" },
+{ "JDELE", T_JDELE, true, true, "[job-id]" },
+{ "JINTR", T_JINTR, true, true, "[job-id]" },
+{ "JKILL", T_JKILL, true, true, "[job-id]" },
+{ "JNEW", T_JNEW, true, true, "" },
+{ "JOB", T_JOB, true, true, "[job-id]" },
+{ "JOBFMT", T_JOBFMT, true, true, "[format-string]" },
+{ "JPARM", T_JPARM, true, true, "[parm-name [parm-value]]" },
+{ "JREST", T_JREST, true, true, "(reset current job state)" },
+{ "JSUBM", T_JSUB, true, true, "[job-id]" },
+{ "JSUSP", T_JSUSP, true, true, "[job-id]" },
+{ "JWAIT", T_JWAIT, true, true, "[job-id]" },
+{ "JGDELE", T_JGDELE, true,false, "[jobgroup-id]" },
+{ "JGINTR", T_JGINTR, true,false, "[jobgroup-id]" },
+{ "JGKILL", T_JGKILL, true,false, "[jobgroup-id]" },
+{ "JGNEW", T_JGNEW, true, true, "" },
+{ "JGPARM", T_JGPARM, true,false, "parm-name [parm-value]" },
+{ "JGREST", T_JGREST, true,false, "(reset current job group state)"},
+{ "JGRP", T_JGRP, true,false, "[jobgroup-id]" },
+{ "JGSUBM", T_JGSUB, true,false, "[jobgroup-id]" },
+{ "JGSUSP", T_JGSUSP, true,false, "[jobgroup-id]" },
+{ "JGWAIT", T_JGWAIT, true,false, "[jobgroup-id]" },
+{ "LIST", T_LIST, true, true, "[path-name]" },
+{ "MDTM", T_MDTM, true, true, "path-name" },
+{ "MODE", T_MODE, false, true, "(specify transfer mode)" },
+{ "MDMFMT", T_MODEMFMT, true, true, "[format-string]" },
+{ "NLST", T_NLST, true, true, "[path-name]" },
+{ "NOOP", T_NOOP, false, true, "" },
+{ "PASS", T_PASS, false, true, "password" },
+{ "PASV", T_PASV, true, true, "(set server in passive mode)" },
+{ "PORT", T_PORT, true, true, "a0,a1,a2,a3,p0,p1" },
+{ "PWD", T_PWD, true, true, "(print working directory)" },
+{ "QUIT", T_QUIT, false, true, "(terminate service)", },
+{ "RCVFMT", T_RCVFMT, true, true, "[format-string]" },
+{ "REIN", T_REIN, false, true, "(reinitialize server state)" },
+{ "REST", T_REST, true, true, "restart-marker" },
+{ "RETP", T_RETP, true, true, "file-name" },
+{ "RETR", T_RETR, true, true, "file-name" },
+{ "RNFR", T_RNFR, true,false, "file-name" },
+{ "RNTO", T_RNTO, true,false, "file-name" },
+{ "SHUT", T_SHUT, true, true, "NOW|HHSS|YYYYMMDDHHSS [reason]" },
+{ "SITE", T_SITE, true, true, "site-cmd [arguments]" },
+{ "SIZE", T_SIZE, true, true, "path-name" },
+{ "STAT", T_STAT, false, true, "[path-name]" },
+{ "STOR", T_STOR, true, true, "file-name" },
+{ "STOT", T_STOT, true, true, "(store unique temporary)" },
+{ "STOU", T_STOU, true, true, "(store unique)" },
+{ "STRU", T_STRU, false, true, "file-structure" },
+{ "SYST", T_SYST, true, true, "(return system type)" },
+{ "TZONE", T_TZONE, true, true, "[GMT|LOCAL]" },
+{ "TYPE", T_TYPE, false, true, "transfer-type" },
+{ "USER", T_USER, false, true, "username" },
+{ "VRFY", T_VRFY, false, true, "dialstring" },
};
/*
* Job parameter commands/keys.
*/
static const tab parmtab[] = {
-{ "ACCTINFO", T_ACCTINFO, FALSE,FALSE, "[<string>]" },
-{ "BEGBR", T_BEGBR, FALSE, TRUE, "[ANY|bit-rate]" },
-{ "BEGST", T_BEGST, FALSE, TRUE, "[ANY|scanline-time]" },
-{ "CHOPTHRESHOLD",T_CHOPTHRESH, FALSE, TRUE, "[inches]" },
-{ "CLIENT", T_CLIENT, FALSE, TRUE, "[<string>]" },
-{ "COMMENTS", T_COMMENTS, FALSE,FALSE, "[<string>]" },
-{ "COMMID", T_COMMID, FALSE, TRUE, "(communication identifier)" },
-{ "COVER", T_COVER, FALSE, TRUE, "path-name" },
-{ "DATAFORMAT", T_DATAFORMAT, FALSE, TRUE, "[ANY|G31D|G32D|G4]" },
-{ "DIALSTRING", T_DIALSTRING, FALSE, TRUE, "[<string>]" },
-{ "DOCUMENT", T_DOCUMENT, FALSE, TRUE, "path-name" },
-{ "DONEOP", T_DONEOP, FALSE, TRUE, "[<string>]" },
-{ "EXTERNAL", T_EXTERNAL, FALSE, TRUE, "[<string>]" },
-{ "FROMCOMPANY", T_FROM_COMPANY, FALSE,FALSE, "[<string>]" },
-{ "FROMLOCATION", T_FROM_LOCATION,FALSE,FALSE, "[<string>]" },
-{ "FROMUSER", T_FROM_USER, FALSE, TRUE, "[<string>]" },
-{ "FROMVOICE", T_FROM_VOICE, FALSE,FALSE, "[<string>]" },
-{ "GROUPID", T_GROUPID, FALSE, TRUE, "(job group identifier)" },
-{ "HRES", T_HRES, FALSE,FALSE, "[dots-per-inch]" },
-{ "JOBID", T_JOBID, FALSE, TRUE, "(job identifier)" },
-{ "JOBINFO", T_JOBINFO, FALSE, TRUE, "[<string>]" },
-{ "JOBTYPE", T_JOBTYPE, FALSE, TRUE, "(job type)" },
-{ "LASTTIME", T_LASTTIME, FALSE, TRUE, "[DDHHSS]" },
-{ "MAXDIALS", T_MAXDIALS, FALSE, TRUE, "[<number>]" },
-{ "MAXPAGES", T_MAXPAGES, FALSE, TRUE, "[<number>]" },
-{ "MAXTRIES", T_MAXTRIES, FALSE, TRUE, "[<number>]" },
-{ "MINBR", T_MINBR, FALSE, TRUE, "[ANY|bit-rate]" },
-{ "MODEM", T_MODEM, FALSE, TRUE, "[device|class]" },
-{ "NDIALS", T_NDIALS, FALSE, TRUE, "[<number>]" },
-{ "NOTIFY", T_NOTIFY, FALSE, TRUE, "[NONE|DONE|REQUEUE|DONE+REQUEUE]" },
-{ "NOTIFYADDR", T_NOTIFYADDR, FALSE, TRUE, "[email-address]" },
-{ "NPAGES", T_NPAGES, FALSE, TRUE, "[<number>]" },
-{ "NTRIES", T_NTRIES, FALSE, TRUE, "[<number>]" },
-{ "OWNER", T_OWNER, FALSE, TRUE, "[<name>|<number>]" },
-{ "PAGECHOP", T_PAGECHOP, FALSE, TRUE, "[DEFAULT|NONE|ALL|LAST]" },
-{ "PAGELENGTH", T_PAGELENGTH, FALSE, TRUE, "[millimeters]" },
-{ "PAGEWIDTH", T_PAGEWIDTH, FALSE, TRUE, "[millimeters]" },
-{ "PASSWD", T_PASSWD, FALSE, TRUE, "[<string>]" },
-{ "POLL", T_POLL, FALSE, TRUE, "selector [passwd]" },
-{ "REGARDING", T_REGARDING, FALSE,FALSE, "[<string>]" },
-{ "RETRYTIME", T_RETRYTIME, FALSE, TRUE, "[HHSS]" },
-{ "SCHEDPRI", T_SCHEDPRI, FALSE, TRUE, "[<number>]" },
-{ "SENDTIME", T_SENDTIME, FALSE, TRUE, "[NOW|YYYYMMDDHHSS]" },
-{ "STATE", T_STATE, FALSE, TRUE, "(job state)" },
-{ "STATUS", T_STATUS, FALSE, TRUE, "[<string>" },
-{ "SUBADDR", T_SUBADDR, FALSE, TRUE, "[<string>]" },
-{ "TAGLINE", T_TAGLINE, FALSE, TRUE, "[<string>]" },
-{ "TOCOMPANY", T_TO_COMPANY, FALSE, TRUE, "[<string>]" },
-{ "TOLOCATION", T_TO_LOCATION, FALSE, TRUE, "[<string>]" },
-{ "TOTDIALS", T_TOTDIALS, FALSE, TRUE, "[<number>]" },
-{ "TOTPAGES", T_TOTPAGES, FALSE, TRUE, "[<number>]" },
-{ "TOTTRIES", T_TOTTRIES, FALSE, TRUE, "[<number>]" },
-{ "TOUSER", T_TO_USER, FALSE, TRUE, "[<string>]" },
-{ "TOVOICE", T_TO_VOICE, FALSE,FALSE, "[<string>]" },
-{ "USECONTCOVER", T_USE_CONTCOVER,FALSE, TRUE, "[YES|NO]" },
-{ "USEECM", T_USE_ECM, FALSE, TRUE, "[YES|NO]" },
-{ "USETAGLINE", T_USE_TAGLINE, FALSE, TRUE, "[YES|NO]" },
-{ "USRKEY", T_USRKEY, FALSE, TRUE, "[<string>]" },
-{ "VRES", T_VRES, FALSE, TRUE, "[lines-per-inch]" },
+{ "ACCTINFO", T_ACCTINFO, false,false, "[<string>]" },
+{ "BEGBR", T_BEGBR, false, true, "[ANY|bit-rate]" },
+{ "BEGST", T_BEGST, false, true, "[ANY|scanline-time]" },
+{ "CHOPTHRESHOLD",T_CHOPTHRESH, false, true, "[inches]" },
+{ "CLIENT", T_CLIENT, false, true, "[<string>]" },
+{ "COMMENTS", T_COMMENTS, false,false, "[<string>]" },
+{ "COMMID", T_COMMID, false, true, "(communication identifier)" },
+{ "COVER", T_COVER, false, true, "path-name" },
+{ "DATAFORMAT", T_DATAFORMAT, false, true, "[ANY|G31D|G32D|G4]" },
+{ "DIALSTRING", T_DIALSTRING, false, true, "[<string>]" },
+{ "DOCUMENT", T_DOCUMENT, false, true, "path-name" },
+{ "DONEOP", T_DONEOP, false, true, "[<string>]" },
+{ "EXTERNAL", T_EXTERNAL, false, true, "[<string>]" },
+{ "FROMCOMPANY", T_FROM_COMPANY, false,false, "[<string>]" },
+{ "FROMLOCATION", T_FROM_LOCATION,false,false, "[<string>]" },
+{ "FROMUSER", T_FROM_USER, false, true, "[<string>]" },
+{ "FROMVOICE", T_FROM_VOICE, false,false, "[<string>]" },
+{ "GROUPID", T_GROUPID, false, true, "(job group identifier)" },
+{ "HRES", T_HRES, false,false, "[dots-per-inch]" },
+{ "JOBID", T_JOBID, false, true, "(job identifier)" },
+{ "JOBINFO", T_JOBINFO, false, true, "[<string>]" },
+{ "JOBTYPE", T_JOBTYPE, false, true, "(job type)" },
+{ "LASTTIME", T_LASTTIME, false, true, "[DDHHSS]" },
+{ "MAXDIALS", T_MAXDIALS, false, true, "[<number>]" },
+{ "MAXPAGES", T_MAXPAGES, false, true, "[<number>]" },
+{ "MAXTRIES", T_MAXTRIES, false, true, "[<number>]" },
+{ "MINBR", T_MINBR, false, true, "[ANY|bit-rate]" },
+{ "MODEM", T_MODEM, false, true, "[device|class]" },
+{ "NDIALS", T_NDIALS, false, true, "[<number>]" },
+{ "NOTIFY", T_NOTIFY, false, true, "[NONE|DONE|REQUEUE|DONE+REQUEUE]" },
+{ "NOTIFYADDR", T_NOTIFYADDR, false, true, "[email-address]" },
+{ "NPAGES", T_NPAGES, false, true, "[<number>]" },
+{ "NTRIES", T_NTRIES, false, true, "[<number>]" },
+{ "OWNER", T_OWNER, false, true, "[<name>|<number>]" },
+{ "PAGECHOP", T_PAGECHOP, false, true, "[DEFAULT|NONE|ALL|LAST]" },
+{ "PAGELENGTH", T_PAGELENGTH, false, true, "[millimeters]" },
+{ "PAGEWIDTH", T_PAGEWIDTH, false, true, "[millimeters]" },
+{ "PASSWD", T_PASSWD, false, true, "[<string>]" },
+{ "POLL", T_POLL, false, true, "selector [passwd]" },
+{ "REGARDING", T_REGARDING, false,false, "[<string>]" },
+{ "RETRYTIME", T_RETRYTIME, false, true, "[HHSS]" },
+{ "SCHEDPRI", T_SCHEDPRI, false, true, "[<number>]" },
+{ "SENDTIME", T_SENDTIME, false, true, "[NOW|YYYYMMDDHHSS]" },
+{ "STATE", T_STATE, false, true, "(job state)" },
+{ "STATUS", T_STATUS, false, true, "[<string>" },
+{ "SUBADDR", T_SUBADDR, false, true, "[<string>]" },
+{ "TAGLINE", T_TAGLINE, false, true, "[<string>]" },
+{ "TOCOMPANY", T_TO_COMPANY, false, true, "[<string>]" },
+{ "TOLOCATION", T_TO_LOCATION, false, true, "[<string>]" },
+{ "TOTDIALS", T_TOTDIALS, false, true, "[<number>]" },
+{ "TOTPAGES", T_TOTPAGES, false, true, "[<number>]" },
+{ "TOTTRIES", T_TOTTRIES, false, true, "[<number>]" },
+{ "TOUSER", T_TO_USER, false, true, "[<string>]" },
+{ "TOVOICE", T_TO_VOICE, false,false, "[<string>]" },
+{ "USECONTCOVER", T_USE_CONTCOVER,false, true, "[YES|NO]" },
+{ "USEECM", T_USE_ECM, false, true, "[YES|NO]" },
+{ "USETAGLINE", T_USE_TAGLINE, false, true, "[YES|NO]" },
+{ "USRKEY", T_USRKEY, false, true, "[<string>]" },
+{ "VRES", T_VRES, false, true, "[lines-per-inch]" },
-{ "HELP", T_HELP, FALSE, TRUE, "[<string>]" },
+{ "HELP", T_HELP, false, true, "[<string>]" },
};
/*
* Site-specific commands.
*/
static const tab sitetab[] = {
-{ "ADDMODEM", T_ADDMODEM, FALSE,FALSE, "modem [speed]"},
-{ "ADDUSER", T_ADDUSER, FALSE, TRUE, "user-spec [passwd [adminwd]]"},
-{ "CONFIG", T_CONFIG, FALSE, TRUE, "[parm-name [parm-value]]" },
-{ "DELMODEM", T_DELMODEM, FALSE,FALSE, "modem" },
-{ "DELUSER", T_DELUSER, FALSE, TRUE, "user-spec" },
-{ "TRIGGER", T_TRIGGER, FALSE, TRUE, "spec" },
-{ "HELP", T_HELP, FALSE, TRUE, "[<string>]" },
+{ "ADDMODEM", T_ADDMODEM, false,false, "modem [speed]"},
+{ "ADDUSER", T_ADDUSER, false, true, "user-spec [passwd [adminwd]]"},
+{ "CONFIG", T_CONFIG, false, true, "[parm-name [parm-value]]" },
+{ "DELMODEM", T_DELMODEM, false,false, "modem" },
+{ "DELUSER", T_DELUSER, false, true, "user-spec" },
+{ "TRIGGER", T_TRIGGER, false, true, "spec" },
+{ "HELP", T_HELP, false, true, "[<string>]" },
};
static const tab*
(cp[2]-'0')*10 +
(cp[3]-'0');
}
-inline fxBool
+inline bool
isLoginToken(Token t)
{
return (t == T_USER || t == T_PASS || t == T_ADMIN);
/*
* Protocol command (one line).
*/
-fxBool
+bool
HylaFAXServer::cmd(Token t)
{
fxStr s;
if (string_param(s, "user name")) {
logcmd(t, "%s", (const char*) s);
userCmd(s);
- return (TRUE);
+ return (true);
}
break;
case T_PASS: // user password
if (string_param(s, "password")) {
logcmd(t, "<password>");
passCmd(s);
- return (TRUE);
+ return (true);
}
break;
case T_ADMIN: // administrator password
break;
logcmd(t, "<password>");
adminCmd(s);
- return (TRUE);
+ return (true);
case T_REIN: // reinitialize server
logcmd(t);
if (IS(LOGGEDIN))
restart_point = n;
reply(350, "Data transfer will restart at %lu, "
"send transfer command", n);
- return (TRUE);
+ return (true);
}
break;
case T_SYST: // system identification
logcmd(t);
// this is what we *emulate*
reply(215, "%s", (const char*) systemType);
- return (TRUE);
+ return (true);
}
break;
case T_PORT: // port for data transfer
if (SP() && hostPort() && CRLF()) {
portCmd();
- return (TRUE);
+ return (true);
}
break;
case T_PASV: // enable passive mode
if (CRLF()) {
logcmd(t);
passiveCmd();
- return (TRUE);
+ return (true);
}
break;
case T_FORM: // document format
if (string_param(s, "document format")) {
logcmd(t, "%s", (const char*) s);
formCmd(s);
- return (TRUE);
+ return (true);
}
break;
case T_MODE: // data transfer mode
if (string_param(s, "transfer mode")) {
logcmd(t, "%s", (const char*) s);
modeCmd(s);
- return (TRUE);
+ return (true);
}
break;
case T_STRU: // data transfer file structure
if (string_param(s, "file structure")) {
logcmd(t, "%s", (const char*) s);
struCmd(s);
- return (TRUE);
+ return (true);
}
break;
case T_TYPE: // data transfer type
if (string_param(s, "transfer type")) {
logcmd(t, "%s", (const char*) s);
typeCmd(s);
- return (TRUE);
+ return (true);
}
break;
case T_RETP: // retrieve next page of document/file
if (pathname_param(s)) {
logcmd(t, "%s", (const char*) s);
retrievePageCmd(s);
- return (TRUE);
+ return (true);
}
break;
case T_RETR: // retrieve document/file
if (pathname_param(s)) {
logcmd(t, "%s", (const char*) s);
retrieveCmd(s);
- return (TRUE);
+ return (true);
}
break;
case T_STOR: // store document/file
logcmd(t, "%s", (const char*) s);
// XXX file must exist if not admin, check for bad chars in pathname
storeCmd(s, "w");
- return (TRUE);
+ return (true);
}
break;
case T_APPE: // append to document/file
if (pathname_param(s)) {
logcmd(t, "%s", (const char*) s);
storeCmd(s, "a");
- return (TRUE);
+ return (true);
}
break;
case T_STOT: // store uniquely named document/file
if (CRLF()) {
logcmd(t);
- storeUniqueCmd(TRUE);
- return (TRUE);
+ storeUniqueCmd(true);
+ return (true);
}
break;
case T_STOU: // store uniquely named document/file
if (CRLF()) {
logcmd(t);
- storeUniqueCmd(FALSE);
- return (TRUE);
+ storeUniqueCmd(false);
+ return (true);
}
break;
case T_LIST: // list directory/file
listCmd(".");
else
nlstCmd(".");
- return (TRUE);
+ return (true);
} else if (pathname_param(s)) {
logcmd(t, "%s", (const char*) s);
if (t == T_LIST)
listCmd(s);
else
nlstCmd(s);
- return (TRUE);
+ return (true);
}
break;
case T_CWD: // change working directory
if (opt_CRLF()) {
logcmd(t);
cwdCmd("/");
- return (TRUE);
+ return (true);
} else if (pathname_param(s)) {
logcmd(t, "%s", (const char*) s);
cwdCmd(s);
- return (TRUE);
+ return (true);
}
break;
case T_CDUP: // CWD ..
logcmd(t);
cwdCmd("..");
- return (TRUE);
+ return (true);
case T_PWD: // print working directory
if (CRLF()) {
logcmd(t);
pwdCmd();
- return (TRUE);
+ return (true);
}
break;
case T_STAT: // stat file/server status
if (opt_CRLF()) {
logcmd(t);
statusCmd();
- return (TRUE);
+ return (true);
} else if (checklogin(T_STAT) && pathname_param(s)) {
logcmd(t, "%s", (const char*) s);
statFileCmd(s);
- return (TRUE);
+ return (true);
}
break;
case T_SIZE: // return file size
reply(550, "%s: not a plain file.", (const char*) s);
else
reply(213, "%lu", (u_long) sb.st_size);
- return (TRUE);
+ return (true);
}
break;
case T_CHMOD: // set file protection
if (SP() && STRING(s, "filename") && SP() && NUMBER(n)) {
chmodCmd(s, (u_int) n);
- return (TRUE);
+ return (true);
}
break;
case T_MDTM: // return file last modification time
if (pathname_param(s)) {
logcmd(t, "%s", (const char*) s);
mdtmCmd(s);
- return (TRUE);
+ return (true);
}
break;
case T_DELE: // delete file/document
if (pathname_param(s)) {
logcmd(t, "%s", (const char*) s);
deleCmd(s);
- return (TRUE);
+ return (true);
}
break;
case T_ABOR: // abort active command/incoming call
if (opt_CRLF()) {
logcmd(t);
ack(225, cmdToken(t));
- return (TRUE);
+ return (true);
} else if (checkadmin(T_ABOR) && string_param(s, "modem")) {
abortCallCmd(s);
- return (TRUE);
+ return (true);
}
break;
case T_HELP: // return help
if (opt_CRLF()) {
logcmd(t);
helpCmd(cmdtab, (char*) NULL);
- return (TRUE);
+ return (true);
} else if (string_param(s, "command name")) {
logcmd(t, "%s", (const char*) s);
s.raisecase();
helpCmd(parmtab, NULL);
else
helpCmd(cmdtab, s);
- return (TRUE);
+ return (true);
}
break;
case T_JNEW: // create new job
if (CRLF()) {
newJobCmd();
- return (TRUE);
+ return (true);
}
break;
case T_JOB: // select current job
if (job_param(s)) {
setCurrentJob(s);
- return (TRUE);
+ return (true);
}
break;
case T_JREST: // reset job state
if (job_param(s)) {
resetJob(s);
- return (TRUE);
+ return (true);
}
break;
case T_JDELE: // delete job
if (job_param(s)) {
deleteJob(s);
- return (TRUE);
+ return (true);
}
break;
case T_JINTR: // interrupt job
if (job_param(s)) {
interruptJob(s);
- return (TRUE);
+ return (true);
}
break;
case T_JKILL: // kill job
if (job_param(s)) {
killJob(s);
- return (TRUE);
+ return (true);
}
break;
case T_JSUSP: // suspend job
if (job_param(s)) {
suspendJob(s);
- return (TRUE);
+ return (true);
}
break;
case T_JSUB: // submit job
if (job_param(s)) {
submitJob(s);
- return (TRUE);
+ return (true);
}
break;
case T_JWAIT: // wait for job
if (job_param(s)) {
waitForJob(s);
- return (TRUE);
+ return (true);
}
break;
case T_JGNEW: // create job group
if (CRLF()) {
curJob->groupid = curJob->jobid;
ack(200, cmdToken(t));
- return (TRUE);
+ return (true);
}
break;
case T_JGREST: // reset current job group state
if (CRLF()) {
- return (TRUE);
+ return (true);
}
break;
case T_JGRP: // select current job group
if (jgrp_param(s)) {
- return (TRUE);
+ return (true);
}
break;
case T_JGDELE: // delete job group
if (jgrp_param(s)) {
- return (TRUE);
+ return (true);
}
break;
case T_JGINTR: // interrupt job group
if (jgrp_param(s)) {
- return (TRUE);
+ return (true);
}
break;
case T_JGKILL: // kill job group
if (jgrp_param(s)) {
- return (TRUE);
+ return (true);
}
break;
case T_JGSUSP: // suspend job group
if (jgrp_param(s)) {
- return (TRUE);
+ return (true);
}
break;
case T_JGSUB: // submit job group
if (jgrp_param(s)) {
- return (TRUE);
+ return (true);
}
break;
case T_JGWAIT: // wait for job group
if (jgrp_param(s)) {
- return (TRUE);
+ return (true);
}
break;
case T_NOOP: // no-op
if (CRLF()) {
logcmd(t);
ack(200, cmdToken(t));
- return (TRUE);
+ return (true);
}
break;
case T_IDLE: // set/query idle timeout
if (opt_CRLF()) {
logcmd(t);
reply(213, "%u seconds.", idleTimeout);
- return (TRUE);
+ return (true);
} else if (number_param(n)) {
logcmd(t, "%lu", n);
if (n > maxIdleTimeout && !IS(PRIVILEGED)) {
idleTimeout = (int) n;
reply(213, "Idle timeout set to %u.", idleTimeout);
}
- return (TRUE);
+ return (true);
}
break;
case T_QUIT: // terminate session
logcmd(t);
reply(221, "Goodbye.");
dologout(0);
- return (TRUE);
+ return (true);
}
break;
case T_TZONE: // set/query timezone usage
if (opt_CRLF()) {
reply(200, "Time values are handled in %s.",
IS(USEGMT) ? "GMT" : tzname[0]);
- return (TRUE);
+ return (true);
} else if (string_param(s, "timezone specification")) {
logcmd(t, "%s", (const char*) s);
s.raisecase();
reply(503, "Unknown timezone specification %s.",
(const char*) s);
}
- return (TRUE);
+ return (true);
}
break;
case T_JOBFMT: // query/specify job format string
t == T_MODEMFMT ? (const char*) modemFormat :
(const char*) fileFormat
);
- return (TRUE);
+ return (true);
} else if (string_param(s, "format-string")) {
if (t == T_JOBFMT)
jobFormat = s;
else if (t == T_FILEFMT)
fileFormat = s;
ack(200, cmdToken(t));
- return (TRUE);
+ return (true);
}
break;
case T_JPARM: // set/query job parameter
logcmd(T_JPARM);
if (checkJobState(curJob))
jstatCmd(*curJob);
- return (TRUE);
+ return (true);
} else if (SP() && getToken(T_STRING, "parameter name")) {
tokenBody.raisecase();
const tab* p = lookup(parmtab, N(parmtab), tokenBody);
else if (!string_param(how, "answer-how"))
break;
answerCallCmd(s, how);
- return (TRUE);
+ return (true);
}
break;
case T_CHOWN: // assign file ownership
fxStr who;
if (string_param(who, "user")) {
chownCmd(s, who);
- return (TRUE);
+ return (true);
}
}
break;
else if (!SP() || !multi_STRING(reason))
break;
disableModemCmd(s, reason);
- return (TRUE);
+ return (true);
}
break;
case T_ENABLE: // enable outbound-usage of modem
if (checkadmin(T_ENABLE) && string_param(s, "modem")) {
enableModemCmd(s);
- return (TRUE);
+ return (true);
}
break;
case T_SHUT: // shutdown server
if (s.length() == 3 && strcasecmp(cp, "NOW") == 0) {
time_t t = Sys::now();
shutCmd(*localtime(&t), reason);
- return (TRUE);
+ return (true);
} else if (s.length() == 4 && checkNUMBER(cp)) {
time_t t = Sys::now();
struct tm tm = *localtime(&t);
tm.tm_hour = 60*60*twodigits(cp, 60);
tm.tm_min = 60*twodigits(cp+2, 60);
shutCmd(tm, reason);
- return (TRUE);
+ return (true);
} else if (s.length() == 12 && checkNUMBER(cp)) {
struct tm tm;
tm.tm_sec = 0;
tm.tm_mon = twodigits(cp+4, 12) -1;
tm.tm_year = fourdigits(cp+0) - 1900;
shutCmd(tm, reason);
- return (TRUE);
+ return (true);
} else
syntaxError("bad time specification");
}
, (const char*) hostname
, (const char*) hostaddr
);
- return (TRUE);
+ return (true);
}
break;
}
- return (FALSE);
+ return (false);
}
/*
* Site-specific protocol commands (one line).
*/
-fxBool
+bool
HylaFAXServer::site_cmd(Token t)
{
fxStr s;
fxStr pass;
if (opt_CRLF()) {
addUserCmd(s, "", "");
- return (TRUE);
+ return (true);
} else if (SP() && STRING(pass, "password")) {
fxStr apass;
if (opt_CRLF()) {
addUserCmd(s, pass, "");
- return (TRUE);
+ return (true);
} else if (string_param(apass, "admin-password")) {
addUserCmd(s, pass, apass);
- return (TRUE);
+ return (true);
}
}
}
case T_DELUSER:
if (checkadmin(T_DELUSER) && string_param(s, "user-spec")) {
delUserCmd(s);
- return (TRUE);
+ return (true);
}
break;
case T_DELMODEM:
if (checkadmin(T_DELMODEM) && string_param(s, "modem")) {
delModemCmd(s);
- return (TRUE);
+ return (true);
}
break;
case T_ADDMODEM:
if (checkadmin(T_ADDMODEM) && string_param(s, "modem")) {
addModemCmd(s);
- return (TRUE);
+ return (true);
}
break;
case T_CONFIG:
fxStr config;
if (opt_CRLF()) {
configQueryCmd(s);
- return (TRUE);
+ return (true);
} else if (SP() && multi_STRING(config)) {
configCmd(s, config);
- return (TRUE);
+ return (true);
}
}
break;
if (string_param(s, "trigger-spec")) {
logcmd(t, s);
triggerCmd("%s", (const char*) s);
- return (TRUE);
+ return (true);
}
break;
case T_HELP: // return help
if (opt_CRLF()) {
helpCmd(sitetab, (char*) NULL);
- return (TRUE);
+ return (true);
} else if (string_param(s, "command name")) {
logcmd(T_SITE, "HELP %s", (const char*) s);
s.raisecase();
helpCmd(sitetab, s);
- return (TRUE);
+ return (true);
}
break;
}
- return (FALSE);
+ return (false);
}
-fxBool
+bool
HylaFAXServer::param_cmd(Token t)
{
fxStr s;
long n;
time_t ticks;
- fxBool b;
+ bool b;
switch (t) {
case T_SENDTIME: // time to send job
if (opt_CRLF()) {
replyJobParamValue(*curJob, 213, t);
- return (TRUE);
+ return (true);
} else if (SP() && getToken(T_STRING, "time specification")) {
tokenBody.raisecase();
if (tokenBody == "NOW") {
if (CRLF() && setJobParameter(*curJob, t, (time_t) 0)) {
reply(213, "%s set to NOW.", parmToken(t));
- return (TRUE);
+ return (true);
}
} else {
pushToken(T_STRING); // XXX
);
} else
reply(213, "%s set to NOW.", parmToken(t));
- return (TRUE);
+ return (true);
}
}
}
case T_LASTTIME: // time to kill job
if (opt_CRLF()) {
replyJobParamValue(*curJob, 213, t);
- return (TRUE);
+ return (true);
} else if (timespec_param(6, ticks) &&
setJobParameter(*curJob, t, ticks)) {
reply(213, "%s set to %02d%02d%02d."
, (ticks/(60*60))%24
, (ticks/60)%60
);
- return (TRUE);
+ return (true);
}
break;
case T_RETRYTIME: // retry interval for job
if (opt_CRLF()) {
replyJobParamValue(*curJob, 213, t);
- return (TRUE);
+ return (true);
} else if (timespec_param(4, ticks) &&
setJobParameter(*curJob, t, ticks)) {
reply(213, "%s set to %02d%02d."
, ticks/60
, ticks%60
);
- return (TRUE);
+ return (true);
}
break;
case T_MAXDIALS:
case T_TOTDIALS:
if (opt_CRLF()) {
replyJobParamValue(*curJob, 213, t);
- return (TRUE);
+ return (true);
} else if (number_param(n) &&
setJobParameter(*curJob, t, (u_short) n)) {
reply(213, "%s set to %u.", parmToken(t), n);
- return (TRUE);
+ return (true);
}
break;
case T_NOTIFYADDR:
case T_COMMID:
if (opt_CRLF()) {
replyJobParamValue(*curJob, 213, t);
- return (TRUE);
+ return (true);
} else if (SP() && multi_STRING(s) && CRLF() &&
setJobParameter(*curJob, t, s)) {
reply(213, "%s set to \"%s\".", parmToken(t), (const char*) s);
- return (TRUE);
+ return (true);
}
break;
case T_USE_ECM:
case T_USE_CONTCOVER:
if (opt_CRLF()) {
replyJobParamValue(*curJob, 213, t);
- return (TRUE);
+ return (true);
} else if (boolean_param(b) &&
setJobParameter(*curJob, t, b)) {
reply(213, "%s set to %s.", parmToken(t), b ? "YES" : "NO");
- return (TRUE);
+ return (true);
}
break;
case T_CHOPTHRESH:
if (opt_CRLF()) {
replyJobParamValue(*curJob, 213, t);
- return (TRUE);
+ return (true);
} else if (string_param(s, "floating point number") &&
setJobParameter(*curJob, t, (float) atof(s))) {
reply(213, "%s set to %g.", parmToken(t), (float) atof(s));
- return (TRUE);
+ return (true);
}
break;
case T_COVER: // specify/query cover page document
if (opt_CRLF()) {
replyJobParamValue(*curJob, 213, t);
- return (TRUE);
+ return (true);
} else if (pathname_param(s)) {
addCoverDocument(*curJob, s);
- return (TRUE);
+ return (true);
}
break;
case T_DOCUMENT: // specify/query normal document
if (opt_CRLF()) {
replyJobParamValue(*curJob, 213, t);
- return (TRUE);
+ return (true);
} else if (pathname_param(s)) {
addDocument(*curJob, s);
- return (TRUE);
+ return (true);
}
break;
case T_POLL: // specify/query poll operation
if (opt_CRLF()) {
replyJobParamValue(*curJob, 213, t);
- return (TRUE);
+ return (true);
} else if (SP() && STRING(s, "polling selector")) {
fxStr pwd;
if (opt_CRLF()) {
addPollOp(*curJob, s, ""); // sep but no pwd
- return (TRUE);
+ return (true);
} else if (SP() && pwd_param(pwd) && CRLF()) {
addPollOp(*curJob, s, pwd); // sep & pwd
- return (TRUE);
+ return (true);
}
}
break;
case T_HELP: // return help
if (opt_CRLF()) {
helpCmd(parmtab, (char*) NULL);
- return (TRUE);
+ return (true);
} else if (string_param(s, "parameter name")) {
s.raisecase();
logcmd(T_JPARM, "HELP %s", (const char*) s);
helpCmd(parmtab, s);
- return (TRUE);
+ return (true);
}
break;
}
- return (FALSE);
+ return (false);
}
/*
* Collect a single string parameter.
*/
-fxBool
+bool
HylaFAXServer::string_param(fxStr& s, const char* what)
{
return SP() && STRING(s, what) && CRLF();
/*
* Collect a single number parameter.
*/
-fxBool
+bool
HylaFAXServer::number_param(long& n)
{
return SP() && NUMBER(n) && CRLF();
/*
* Collect a single boolean parameter.
*/
-fxBool
-HylaFAXServer::boolean_param(fxBool& b)
+bool
+HylaFAXServer::boolean_param(bool& b)
{
return SP() && BOOLEAN(b) && CRLF();
}
/*
* Collect a single time parameter.
*/
-fxBool
+bool
HylaFAXServer::timespec_param(int ndigits, time_t& t)
{
return SP() && TIMESPEC(ndigits, t) && CRLF();
/*
* File manipulation command.
*/
-fxBool
+bool
HylaFAXServer::pathname_param(fxStr& s)
{
return SP() && pathname(s) && CRLF();
/*
* Job control commands.
*/
-fxBool
+bool
HylaFAXServer::job_param(fxStr& jid)
{
if (opt_CRLF()) {
jid = curJob->jobid;
- return (TRUE);
+ return (true);
} else if (SP() && STRING(jid, "job identifer") && CRLF()) {
jid.lowercase();
- return (TRUE);
+ return (true);
}
- return (FALSE);
+ return (false);
}
/*
* Job group control commands.
*/
-fxBool
+bool
HylaFAXServer::jgrp_param(fxStr& jgid)
{
if (opt_CRLF()) {
jgid = curJob->groupid;
- return (TRUE);
+ return (true);
} else if (SP() && STRING(jgid, "job group identifier") && CRLF()) {
jgid.lowercase();
- return (TRUE);
+ return (true);
}
- return (FALSE);
+ return (false);
}
-fxBool
+bool
HylaFAXServer::pwd_param(fxStr& s)
{
return STRING(s, "polling password");
}
-fxBool
+bool
HylaFAXServer::pathname(fxStr& s)
{
return STRING(s, "pathname");
}
-fxBool
+bool
HylaFAXServer::TIMESPEC(u_int len, time_t& result)
{
if (getToken(T_STRING, "time specification")) {
result = 60*twodigits(cp, 60)
+ twodigits(cp+2, 60);
}
- return (TRUE);
+ return (true);
}
} else
syntaxError(fxStr::format(
"bad time specification (expecting %d digits)", len));
}
- return (FALSE);
+ return (false);
}
-fxBool
-HylaFAXServer::BOOLEAN(fxBool& b)
+bool
+HylaFAXServer::BOOLEAN(bool& b)
{
if (getToken(T_STRING, "boolean")) {
tokenBody.raisecase();
if (tokenBody == "YES") {
- b = TRUE;
- return (TRUE);
+ b = true;
+ return (true);
} else if (tokenBody == "NO") {
- b = FALSE;
- return (TRUE);
+ b = false;
+ return (true);
} else
syntaxError("invalid boolean value, use YES or NO");
}
- return (FALSE);
+ return (false);
}
-fxBool
+bool
HylaFAXServer::checkToken(Token wanted)
{
Token t = nextToken();
if (t != wanted) {
pushToken(t);
- return (FALSE);
+ return (false);
} else
- return (TRUE);
+ return (true);
}
-fxBool
+bool
HylaFAXServer::getToken(Token wanted, const char* expected)
{
Token t = nextToken();
syntaxError("unmatched quote mark");
else
syntaxError(fxStr::format("expecting %s", expected));
- return (FALSE);
+ return (false);
} else
- return (TRUE);
+ return (true);
}
-fxBool HylaFAXServer::SP() { return getToken(T_SP, "<SP>"); }
-fxBool HylaFAXServer::COMMA() { return getToken(T_COMMA, "\",\""); }
-fxBool HylaFAXServer::CRLF() { return getToken(T_CRLF, "<CRLF>"); }
-fxBool HylaFAXServer::opt_CRLF() { return checkToken(T_CRLF); }
+bool HylaFAXServer::SP() { return getToken(T_SP, "<SP>"); }
+bool HylaFAXServer::COMMA() { return getToken(T_COMMA, "\",\""); }
+bool HylaFAXServer::CRLF() { return getToken(T_CRLF, "<CRLF>"); }
+bool HylaFAXServer::opt_CRLF() { return checkToken(T_CRLF); }
-fxBool
+bool
HylaFAXServer::opt_STRING(fxStr& s)
{
if (checkToken(T_STRING)) {
s = tokenBody;
- return (TRUE);
+ return (true);
} else
- return (FALSE);
+ return (false);
}
-fxBool
+bool
HylaFAXServer::STRING(fxStr& s, const char* what)
{
if (getToken(T_STRING, what != NULL ? what : "<STRING>")) {
s = tokenBody;
- return (TRUE);
+ return (true);
} else
- return (FALSE);
+ return (false);
}
-fxBool
+bool
HylaFAXServer::multi_STRING(fxStr& s)
{
if (!STRING(s))
- return (FALSE);
+ return (false);
for (;;) {
switch (nextToken()) {
case T_CRLF:
pushToken(T_CRLF);
- return (TRUE);
+ return (true);
case T_COMMA:
s.append(',');
break;
break;
case T_LEXERR:
syntaxError("unmatched quote mark");
- return (FALSE);
+ return (false);
}
}
}
-fxBool
+bool
HylaFAXServer::checkNUMBER(const char* cp)
{
if (cp[0] == '-' || cp[0] == '+')
for (; *cp; cp++)
if (!isdigit(*cp)) {
syntaxError("invalid number");
- return (FALSE);
+ return (false);
}
- return (TRUE);
+ return (true);
}
-fxBool
+bool
HylaFAXServer::NUMBER(long& n)
{
if (!getToken(T_STRING, "decimal number")) {
- return (FALSE);
+ return (false);
} else if (!checkNUMBER(tokenBody)) {
- return (FALSE);
+ return (false);
} else {
n = strtol(tokenBody, NULL, 0);
- return (TRUE);
+ return (true);
}
}
* be received or return EOF.
*/
int
-HylaFAXServer::getChar(fxBool waitForInput)
+HylaFAXServer::getChar(bool waitForInput)
{
if (recvCC <= 0) {
// enable non-blocking i/o on control channel
* Return the next line of data received on the control
* channel, ignoring any Telnet protocol command sequences.
*/
-fxBool
-HylaFAXServer::getCmdLine(char* s, int n, fxBool waitForInput)
+bool
+HylaFAXServer::getCmdLine(char* s, int n, bool waitForInput)
{
char* cp = s;
cpos = 0;
while (n > 1) {
int c = getChar(cp != s || waitForInput);
if (c == EOF)
- return (FALSE);
+ return (false);
if (c == IAC) { // telnet protocol command
- c = getChar(TRUE);
+ c = getChar(true);
if (c == EOF)
- return (FALSE);
+ return (false);
switch (c&0377) {
case WILL:
case WONT:
- c = getChar(TRUE); // telnet option
+ c = getChar(true); // telnet option
if (c == EOF)
- return (FALSE);
+ return (false);
printf("%c%c%c", IAC, DONT, c&0377);
(void) fflush(stdout);
continue;
case DO:
case DONT:
- c = getChar(TRUE); // telnet option
+ c = getChar(true); // telnet option
if (c == EOF)
- return (FALSE);
+ return (false);
printf("%c%c%c", IAC, WONT, c&0377);
(void) fflush(stdout);
continue;
*cp = '\0';
if (TRACE(PROTOCOL))
logDebug("command: %s", s);
- return (TRUE);
+ return (true);
}
void
}
}
-fxBool
+bool
HylaFAXServer::checklogin(Token t)
{
if (!IS(LOGGEDIN)) {
cmdFailure(t, "not logged in");
reply(530, "Please login with USER and PASS.");
- return (FALSE);
+ return (false);
} else
- return (TRUE);
+ return (true);
}
-fxBool
+bool
HylaFAXServer::checkadmin(Token t)
{
if (checklogin(t)) {
if (IS(PRIVILEGED))
- return (TRUE);
+ return (true);
cmdFailure(t, "user is not privileged");
reply(530, "Please use ADMIN to establish administrative privileges.");
}
- return (FALSE);
+ return (false);
}
RecvInfo::RecvInfo()
{
- beingReceived = FALSE;
+ beingReceived = false;
recvTime = 0;
}
RecvInfo::RecvInfo(const char* qf)
{
qfile = qf;
- beingReceived = FALSE;
+ beingReceived = false;
recvTime = 0;
}
RecvInfo::~RecvInfo() {}
fxIMPLEMENT_StrKeyPtrValueDictionary(RecvInfoDict, RecvInfo*)
-static fxBool
+static bool
isFAXImage(TIFF* tif)
{
uint16 w;
if (TIFFGetField(tif, TIFFTAG_SAMPLESPERPIXEL, &w) && w != 1)
- return (FALSE);
+ return (false);
if (TIFFGetField(tif, TIFFTAG_BITSPERSAMPLE, &w) && w != 1)
- return (FALSE);
+ return (false);
if (!TIFFGetField(tif, TIFFTAG_COMPRESSION, &w) ||
(w != COMPRESSION_CCITTFAX3 && w != COMPRESSION_CCITTFAX4))
- return (FALSE);
+ return (false);
if (!TIFFGetField(tif, TIFFTAG_PHOTOMETRIC, &w) ||
(w != PHOTOMETRIC_MINISWHITE && w != PHOTOMETRIC_MINISBLACK))
- return (FALSE);
- return (TRUE);
+ return (false);
+ return (true);
}
/*
* Construct receive information from a file's contents.
*/
-fxBool
+bool
HylaFAXServer::getRecvDocStatus(RecvInfo& ri)
{
int fd = Sys::open(ri.qfile, O_RDWR); // RDWR for flock emulation
if (fd < 0)
- return (FALSE);
+ return (false);
/*
* Files that are being received are locked
* for exclusive use by faxgetty.
*/
if (!isFAXImage(tif)) {
TIFFClose(tif);
- return (FALSE);
+ return (false);
}
/*
* Should be a received facsimile, build up status.
#endif
} while (TIFFReadDirectory(tif));
TIFFClose(tif);
- return (TRUE);
+ return (true);
}
-fxBool
+bool
HylaFAXServer::isVisibleRecvQFile(const char* filename, const struct stat&)
{
return (strncmp(filename, "fax", 3) == 0);
{}
SNPPSuperServer::~SNPPSuperServer() {}
-fxBool
+bool
SNPPSuperServer::startServer(void)
{
/*
(void) listen(s, getBacklog());
(void) seteuid(ouid);
Dispatcher::instance().link(s, Dispatcher::ReadMask, this);
- return (TRUE); // success
+ return (true); // success
}
Sys::close(s);
logError("HylaFAX %s: bind (port %u): %m",
} else
logError("HylaFAX %s: socket: %m", getKind());
(void) seteuid(ouid);
- return (FALSE);
+ return (false);
}
HylaFAXServer* SNPPSuperServer::newChild(void) { return new SNPPServer; }
dologout(-1);
}
ctrlFlags = fcntl(STDIN_FILENO, F_GETFL); // for parser
- if (isShutdown(TRUE)) {
+ if (isShutdown(true)) {
reply(421, "%s SNPP server unavailable; try again later.",
(const char*) hostname);
dologout(-1);
void
SNPPServer::initSNPPJob(void)
{
- defJob.queued = FALSE; // jobs not queued--per protocol
+ defJob.queued = false; // jobs not queued--per protocol
defJob.maxdials = SNPP_DEFREDIALS; // configuration defaults...
defJob.maxtries = SNPP_DEFRETRIES;
defJob.killtime = 60*killMap[SNPP_DEFLEVEL];
{
initDefaultJob(); // default job state
msgFile = "";
- haveText = FALSE; // no message text yet
+ haveText = false; // no message text yet
msgs.resize(0); // purge any message refs
}
InetFaxServer::dologout(status);
}
-static inline fxBool
+static inline bool
isMagic(char c)
{
return (c == '[' || c == ']' || c == '*' || c == '.' || c == '^' ||
* to dial of the service provider and the PIN to supply
* to the provider when talking IXO/TAP (for aliases).
*/
-fxBool
+bool
SNPPServer::mapPagerID(const char* pagerID, fxStr& number, fxStr& pin, fxStr& emsg)
{
if (pagerIDMapFile != "") {
* that begin with '#' are ignored (i.e. comments).
*/
const char* pattern = cp;
- fxBool isRE = FALSE;
+ bool isRE = false;
for (; *cp != '\0' && !isspace(*cp); cp++)
if (isMagic(*cp))
- isRE = TRUE;
+ isRE = true;
if (*cp != '\0') // \0-term. <pattern>
*cp++ = '\0';
- fxBool match;
+ bool match;
RegEx* re;
if (isRE) {
re = new RegEx(pattern);
s.raisecase();
if (s == "REJECT") {
emsg = fxStr::format("Invalid pager ID %s",pagerID);
- return (FALSE);
+ return (false);
} else
- return (TRUE);
+ return (true);
}
}
delete re;
emsg = "No pager ID mapping file found";
logError("%s", (const char*) emsg);
}
- return (FALSE);
+ return (false);
}
/*
* Standard protocol commands.
*/
static const tab cmdtab[] = {
-{ "2WAY", T_2WAY, TRUE,FALSE, "(preface 2-way transaction)" },
-{ "ABOR", T_ABOR, FALSE, TRUE, "(abort operation)" },
-{ "ACKR", T_ACKREAD, TRUE,FALSE, "0|1" },
-{ "ALER", T_ALERT, TRUE,FALSE, "alert-level" },
-{ "CALL", T_CALLERID, TRUE,FALSE, "caller-ID" },
-{ "COVE", T_COVERAGE, TRUE,FALSE, "alternate-area" },
-{ "DATA", T_DATA, TRUE, TRUE, "(specify multi-line message)" },
-{ "EXPT", T_EXPTAG, TRUE,FALSE, "hours" },
-{ "HELP", T_HELP, FALSE, TRUE, "[<string>]" },
-{ "HOLD", T_HOLDUNTIL, TRUE, TRUE, "YYYYMMDDHHMMSS [+/-GMT-diff]" },
-{ "KTAG", T_KTAG, TRUE,FALSE, "message-tag pass-code" },
-{ "LEVE", T_LEVEL, TRUE, TRUE, "service-level" },
-{ "LOGI", T_LOGIN, FALSE, TRUE, "username [password]" },
-{ "MCRE", T_MCRESPONSE, TRUE,FALSE, "2-byte-code response-text" },
-{ "MESS", T_MESSAGE, TRUE, TRUE, "message" },
-{ "MSTA", T_MSTATUS, TRUE,FALSE, "message-tag pass-code" },
-{ "NOQU", T_NOQUEUEING, TRUE,FALSE, "(disable message queueing)" },
-{ "PAGE", T_PAGER, TRUE, TRUE, "pager-ID|alias [PIN]" },
-{ "PING", T_PING, TRUE, TRUE, "pager-ID|alias" },
-{ "QUIT", T_QUIT, FALSE, TRUE, "(terminate service)" },
-{ "RESE", T_REST, TRUE, TRUE, "(reset state)" },
-{ "RTYP", T_RTYPE, TRUE,FALSE, "reply-type-code" },
-{ "SEND", T_SEND, TRUE, TRUE, "(send message)" },
-{ "SITE", T_SITE, TRUE, TRUE, "site-cmd [arguments]" },
-{ "STAT", T_STAT, FALSE, TRUE, "(return server status)" },
-{ "SUBJ", T_SUBJECT, TRUE, TRUE, "message-subject" },
+{ "2WAY", T_2WAY, true,false, "(preface 2-way transaction)" },
+{ "ABOR", T_ABOR, false, true, "(abort operation)" },
+{ "ACKR", T_ACKREAD, true,false, "0|1" },
+{ "ALER", T_ALERT, true,false, "alert-level" },
+{ "CALL", T_CALLERID, true,false, "caller-ID" },
+{ "COVE", T_COVERAGE, true,false, "alternate-area" },
+{ "DATA", T_DATA, true, true, "(specify multi-line message)" },
+{ "EXPT", T_EXPTAG, true,false, "hours" },
+{ "HELP", T_HELP, false, true, "[<string>]" },
+{ "HOLD", T_HOLDUNTIL, true, true, "YYYYMMDDHHMMSS [+/-GMT-diff]" },
+{ "KTAG", T_KTAG, true,false, "message-tag pass-code" },
+{ "LEVE", T_LEVEL, true, true, "service-level" },
+{ "LOGI", T_LOGIN, false, true, "username [password]" },
+{ "MCRE", T_MCRESPONSE, true,false, "2-byte-code response-text" },
+{ "MESS", T_MESSAGE, true, true, "message" },
+{ "MSTA", T_MSTATUS, true,false, "message-tag pass-code" },
+{ "NOQU", T_NOQUEUEING, true,false, "(disable message queueing)" },
+{ "PAGE", T_PAGER, true, true, "pager-ID|alias [PIN]" },
+{ "PING", T_PING, true, true, "pager-ID|alias" },
+{ "QUIT", T_QUIT, false, true, "(terminate service)" },
+{ "RESE", T_REST, true, true, "(reset state)" },
+{ "RTYP", T_RTYPE, true,false, "reply-type-code" },
+{ "SEND", T_SEND, true, true, "(send message)" },
+{ "SITE", T_SITE, true, true, "site-cmd [arguments]" },
+{ "STAT", T_STAT, false, true, "(return server status)" },
+{ "SUBJ", T_SUBJECT, true, true, "message-subject" },
};
/*
* Site-specific commands.
*/
static const tab sitetab[] = {
-{ "FROMUSER", T_FROM_USER, TRUE, TRUE, "[<string>]" },
-{ "HELP", T_HELP, FALSE, TRUE, "[<string>]" },
-{ "IDLE", T_IDLE, TRUE, TRUE, "[max-idle-timeout]" },
-{ "JPARM", T_JPARM, TRUE, TRUE, "(print job parameter status)" },
-{ "JQUEUE", T_JQUEUE, TRUE, TRUE, "[on|off]" },
-{ "LASTTIME", T_LASTTIME, FALSE, TRUE, "[DDHHSS]" },
-{ "MAXDIALS", T_MAXDIALS, TRUE, TRUE, "[<number>]" },
-{ "MAXTRIES", T_MAXTRIES, TRUE, TRUE, "[<number>]" },
-{ "MODEM", T_MODEM, TRUE, TRUE, "[device|class]" },
-{ "NOTIFY", T_NOTIFY, TRUE, TRUE, "[NONE|DONE|REQUEUE|DONE+REQUEUE]"},
-{ "MAILADDR", T_NOTIFYADDR, TRUE, TRUE, "[email-address]" },
-{ "RETRYTIME", T_RETRYTIME, TRUE, TRUE, "[HHSS]" },
-{ "SCHEDPRI", T_SCHEDPRI, TRUE, TRUE, "[<number>]" },
+{ "FROMUSER", T_FROM_USER, true, true, "[<string>]" },
+{ "HELP", T_HELP, false, true, "[<string>]" },
+{ "IDLE", T_IDLE, true, true, "[max-idle-timeout]" },
+{ "JPARM", T_JPARM, true, true, "(print job parameter status)" },
+{ "JQUEUE", T_JQUEUE, true, true, "[on|off]" },
+{ "LASTTIME", T_LASTTIME, false, true, "[DDHHSS]" },
+{ "MAXDIALS", T_MAXDIALS, true, true, "[<number>]" },
+{ "MAXTRIES", T_MAXTRIES, true, true, "[<number>]" },
+{ "MODEM", T_MODEM, true, true, "[device|class]" },
+{ "NOTIFY", T_NOTIFY, true, true, "[NONE|DONE|REQUEUE|DONE+REQUEUE]"},
+{ "MAILADDR", T_NOTIFYADDR, true, true, "[email-address]" },
+{ "RETRYTIME", T_RETRYTIME, true, true, "[HHSS]" },
+{ "SCHEDPRI", T_SCHEDPRI, true, true, "[<number>]" },
};
static const tab*
return tokenName(sitetab, N(sitetab), t);
}
-fxBool
+bool
SNPPServer::checklogin(Token t)
{
if (!IS(LOGGEDIN)) {
cmdFailure(t, "not logged in");
reply(530, "Please login with LOGIN.");
- return (FALSE);
+ return (false);
} else
- return (TRUE);
+ return (true);
}
/*
/*
* Protocol command (one line).
*/
-fxBool
+bool
SNPPServer::cmd(Token t)
{
fxStr s;
if (CRLF()) {
logcmd(t);
ack(250, cmdToken(t));
- return (TRUE);
+ return (true);
}
break;
case T_DATA: // submit multi-line message data
if (CRLF()) {
logcmd(t);
dataCmd();
- return (TRUE);
+ return (true);
}
break;
case T_HELP: // return help
if (opt_CRLF()) {
logcmd(t);
helpCmd(cmdtab, (char*) NULL);
- return (TRUE);
+ return (true);
} else if (string_param(s, "command name")) {
logcmd(t, "%s", (const char*) s);
s.raisecase();
helpCmd(sitetab, NULL);
else
helpCmd(cmdtab, s);
- return (TRUE);
+ return (true);
}
break;
case T_HOLDUNTIL: // set time to send
if (SP() && SNPPTime(tv)) {
if (opt_CRLF()) {
holdCmd(tv);
- return (TRUE);
+ return (true);
} else if (string_param(s, "GMT-difference")) {
// conver GMT offset to numeric value
int sign = 1;
cp++;
time_t off = (time_t) (strtoul(cp, 0, 10)*60 / 100);
holdCmd(tv + sign*off);
- return (TRUE);
+ return (true);
}
}
break;
if (number_param(n)) {
logcmd(t, "%lu", n);
serviceLevel((u_int) n);
- return (TRUE);
+ return (true);
}
break;
case T_LOGIN: // login as user
if (opt_CRLF()) {
logcmd(t, (const char*) s);
loginCmd(s);
- return (TRUE);
+ return (true);
} else if (string_param(pwd, "password")) {
logcmd(t, "%s <passwd>", (const char*) s);
loginCmd(s, pwd);
- return (TRUE);
+ return (true);
}
}
break;
if (SP() && multi_STRING(s) && CRLF()) {
logcmd(t, "%s", (const char*) s);
messageCmd(s);
- return (TRUE);
+ return (true);
}
break;
case T_PAGER: // specify destination pager ID
if (opt_CRLF()) {
logcmd(t, "%s", (const char*) s);
pagerCmd(s);
- return (TRUE);
+ return (true);
} else if (string_param(pwd, "password/PIN")) {
logcmd(t, "%s <passwd/PIN>", (const char*) s);
pagerCmd(s, pwd);
- return (TRUE);
+ return (true);
}
}
break;
if (string_param(s, "pager-ID")) {
logcmd(t, "%s", (const char*) s);
pingCmd(s);
- return (TRUE);
+ return (true);
}
break;
case T_QUIT: // terminate session
logcmd(t);
reply(221, "Goodbye.");
dologout(0);
- return (TRUE);
+ return (true);
}
break;
case T_REST: // reset server state
if (CRLF()) {
logcmd(t);
sendCmd();
- return (TRUE);
+ return (true);
}
break;
case T_SITE: // site-specific command
if (CRLF()) {
logcmd(t);
statusCmd();
- return (TRUE);
+ return (true);
}
break;
case T_SUBJECT: // message subject
if (SP() && multi_STRING(s) && CRLF()) {
logcmd(t, "%s", (const char*) s);
subjectCmd(s);
- return (TRUE);
+ return (true);
}
break;
}
- return (FALSE);
+ return (false);
}
/*
* Site-specific protocol commands (one line).
*/
-fxBool
+bool
SNPPServer::site_cmd(Token t)
{
fxStr s;
long n;
time_t tv;
- fxBool b;
+ bool b;
switch (t) {
case T_IDLE: // set/query idle timeout
if (opt_CRLF()) {
logcmd(t);
reply(250, "%u seconds.", idleTimeout);
- return (TRUE);
+ return (true);
} else if (number_param(n)) {
logcmd(t, "%lu", n);
if (n > maxIdleTimeout && !IS(PRIVILEGED)) {
idleTimeout = (int) n;
reply(250, "Idle timeout set to %u.", idleTimeout);
}
- return (TRUE);
+ return (true);
}
break;
case T_HELP: // return help
if (opt_CRLF()) {
helpCmd(sitetab, (char*) NULL);
- return (TRUE);
+ return (true);
} else if (string_param(s, "command name")) {
logcmd(T_SITE, "HELP %s", (const char*) s);
s.raisecase();
helpCmd(sitetab, s);
- return (TRUE);
+ return (true);
}
break;
case T_JQUEUE:
logcmd(t, "%s", b ? "YES" : "NO");
defJob.queued = b;
reply(250, "Job will%s be queued.", b ? "" : " not");
- return (TRUE);
+ return (true);
}
break;
case T_FROM_USER:
if (SP() && multi_STRING(s) && CRLF() && setJobParameter(defJob, t, s)) {
logcmd(t, "%s", (const char*) s);
reply(250, "%s set to \"%s\".", parmToken(t), (const char*) s);
- return (TRUE);
+ return (true);
}
break;
case T_MAXDIALS:
if (number_param(n) && setJobParameter(defJob, t, (u_short) n)) {
logcmd(t, "%lu", n);
reply(250, "%s set to %u.", parmToken(t), n);
- return (TRUE);
+ return (true);
}
break;
case T_LASTTIME: // time to kill job
reply(250, "%s set to %02d%02d%02d."
, parmToken(t)
, tv/(24*60*60) , (tv/(60*60))%24 , (tv/60)%60);
- return (TRUE);
+ return (true);
}
break;
case T_RETRYTIME: // retry interval for job
if (timespec_param(4, tv) && setJobParameter(defJob, t, tv)) {
logcmd(t, "%02d%02d" , tv/60, tv%60);
reply(250, "%s set to %02d%02d.", parmToken(t), tv/60, tv%60);
- return (TRUE);
+ return (true);
}
break;
case T_JPARM: // query job parameters
if (CRLF()) {
logcmd(t);
jstatCmd(defJob);
- return (TRUE);
+ return (true);
}
break;
}
- return (FALSE);
+ return (false);
}
/*
* Parse an SNPP time specification.
*/
-fxBool
+bool
SNPPServer::SNPPTime(time_t& result)
{
if (getToken(T_STRING, "time specification") && checkNUMBER(tokenBody)) {
* client will then be applied to this result.
*/
result = mktime(&tm) - gmtoff;
- return (TRUE);
+ return (true);
}
syntaxError(fxStr::format(
"bad time specification (expecting 10/12 digits, got %u)", tlen));
}
- return (FALSE);
+ return (false);
}
void
char buf[1024];
u_int len = 0;
for (;;) {
- if (getCmdLine(buf, sizeof (buf), TRUE)) {
+ if (getCmdLine(buf, sizeof (buf), true)) {
const char* bp = buf;
if (bp[0] == '.') {
if ((bp[1] == '\n' && bp[2] == '\0') || bp[1] == '\0')
perror_reply(554, msgFile, errno);
Sys::unlink(msgFile);
} else {
- haveText = TRUE;
+ haveText = true;
reply(250, "Message text OK.");
}
} else
perror_reply(554, msgFile, errno);
Sys::unlink(msgFile);
} else {
- haveText = TRUE;
+ haveText = true;
reply(250, "Message text OK.");
}
} else
reply(550, "%s.", (const char*) emsg);
}
-static fxBool
+static bool
notPresent(faxRequestArray& a, const char* name)
{
for (u_int i = 0, n = a.length(); i < n; i++)
if (a[i].op == FaxRequest::send_data && a[i].item == name)
- return (FALSE);
- return (TRUE);
+ return (false);
+ return (true);
}
/*
*/
fxStr emsg;
u_int i, n = msgs.length();
- fxBool waitForJobs = FALSE;
+ bool waitForJobs = false;
for (i = 0; i < n; i++) {
Job* job = findJob(msgs[i], emsg);
if (!job)
msgs.remove(i), n--;
else if (!job->queued)
- waitForJobs = TRUE;
+ waitForJobs = true;
}
if (waitForJobs) {
state &= ~S_LOGTRIG; // just process events
if (setjmp(urgcatch) == 0) {
Dispatcher& disp = Dispatcher::instance();
state |= S_WAITTRIG|S_SENDWAIT;
- fxBool jobsPending;
+ bool jobsPending;
do {
disp.dispatch();
/*
* monitor the job state(s) after each event we
* receive.
*/
- jobsPending = FALSE;
+ jobsPending = false;
for (i = 0; i < n; i++) {
Job* job = findJob(msgs[i], emsg);
if (!job)
msgs.remove(i), n--;
else if (!job->queued && job->state != FaxRequest::state_done)
- jobsPending = TRUE;
+ jobsPending = true;
}
} while (IS(WAITTRIG) && jobsPending);
reply(250, "Message processing completed.");
}
}
-fxBool
+bool
SNPPServer::setConfigItem(const char* tag, const char* value)
{
if (streq(tag, "maxmsglength")) {
} else if (streq(tag, "retrytimemap")) {
setTimeMap(retryMap, value);
} else if (!InetFaxServer::setConfigItem(tag, value))
- return (FALSE);
- return (TRUE);
+ return (false);
+ return (true);
}
#endif /* SNPP_SUPPORT */
class SNPPServer : public InetFaxServer {
private:
fxStr msgFile; // file with message text
- fxBool haveText; // client specified message text
+ bool haveText; // client specified message text
fxStrArray msgs; // jobs pending SEND (jobids)
#define S_SENDWAIT 0x10000 // in SEND waiting for jobs
virtual void resetConfig();
void setupConfig();
- virtual fxBool setConfigItem(const char* tag, const char* value);
+ virtual bool setConfigItem(const char* tag, const char* value);
int parse(void);
- fxBool cmd(Token t);
- fxBool site_cmd(Token t);
- fxBool checklogin(Token);
- fxBool SNPPTime(time_t& result);
+ bool cmd(Token t);
+ bool site_cmd(Token t);
+ bool checklogin(Token);
+ bool SNPPTime(time_t& result);
virtual void syntaxError(const char* msg);
virtual const char* cmdToken(Token t);
void statusCmd(void);
void subjectCmd(const char*);
- fxBool mapPagerID(const char* pagerID,
+ bool mapPagerID(const char* pagerID,
fxStr& number, fxStr& pid, fxStr& emsg);
public:
SNPPServer();
private:
fxStr port;
protected:
- fxBool startServer(void);
+ bool startServer(void);
HylaFAXServer* newChild(void);
public:
SNPPSuperServer(const char* port, int backlog = 5);
fxStr localIdentifier; // to use in place of FAXNumber
fxStr FAXNumber; // phone number
fxStr modemName; // canonical modem name
- fxBool isGettyRunning; // TRUE if faxgetty responds via FIFO
+ bool isGettyRunning; // true if faxgetty responds via FIFO
fxStr status; // from status file
ModemConfig(const char* name);
~ModemConfig() {};
- fxBool setConfigItem(const char* tag, const char* value);
+ bool setConfigItem(const char* tag, const char* value);
void configError(const char* fmt, ...);
void configTrace(const char* fmt, ...);
isGettyRunning = (fifo != -1);
}
-fxBool
+bool
ModemConfig::setConfigItem(const char* tag, const char* value)
{
if (streq(tag, "faxnumber"))
logTracingLevel = getNumber(value);
else if (streq(tag, "maxrecvpages"))
maxRecvPages = getNumber(value);
- return (TRUE); // avoid complaints
+ return (true); // avoid complaints
}
void
SuperServer(const char* kind, int backlog);
virtual HylaFAXServer* newChild(void) = 0;
- virtual fxBool startServer(void) = 0;
+ virtual bool startServer(void) = 0;
int inputReady(int fd);
void timerExpired(long, long);
* and return the identifier sent back by the
* scheduler.
*/
-fxBool
+bool
HylaFAXServer::newTrigger(fxStr& emsg, const char* fmt, ...)
{
va_list ap;
va_start(ap, fmt);
- fxBool b = vnewTrigger(emsg, fmt, ap);
+ bool b = vnewTrigger(emsg, fmt, ap);
va_end(ap);
return (b);
}
-fxBool
+bool
HylaFAXServer::vnewTrigger(fxStr& emsg, const char* fmt, va_list ap)
{
trigSpec = fxStr::vformat(fmt, ap);
* create triggers the first time as well as to re-load an
* active trigger if the scheduler is restarted.
*/
-fxBool
+bool
HylaFAXServer::loadTrigger(fxStr& emsg)
{
if (sendQueuerACK(emsg, "T%s", (const char*) trigSpec) &&
fifoResponse.length() > 2) {
tid = atoi(&fifoResponse[2]);
- return (TRUE);
+ return (true);
} else
- return (FALSE);
+ return (false);
}
/*
* Inform the spooler that it should cancel
* a previously created trigger.
*/
-fxBool
+bool
HylaFAXServer::cancelTrigger(fxStr& emsg)
{
trigSpec = ""; // avoid spontaneous reloads
if (rip->recvTime == 0)
rip->recvTime = h.tstamp;
if (h.event == Trigger::RECV_END) {
- rip->beingReceived = FALSE;
+ rip->beingReceived = false;
rip->reason = ri.reason;
} else
- rip->beingReceived = TRUE;
+ rip->beingReceived = true;
rip->sender = ri.sender;
rip->subaddr = ri.subaddr;
rip->npages = ri.npages;
Sys::unlink(fileName);
}
-fxBool
+bool
UnixSuperServer::startServer(void)
{
int s = socket(AF_UNIX, SOCK_STREAM, 0);
#endif
(void) listen(s, getBacklog());
Dispatcher::instance().link(s, Dispatcher::ReadMask, this);
- return (TRUE);
+ return (true);
}
Sys::close(s);
logError("%s HylaFAX: bind (port %s): %m",
fileName = ""; // don't try to unlink file
} else
logError("%s HylaFAX: socket: %m", getKind());
- return (FALSE);
+ return (false);
}
HylaFAXServer* UnixSuperServer::newChild(void) { return new UnixFaxServer; }
UnixFaxServer::UnixFaxServer()
{
- usedefault = TRUE;
+ usedefault = true;
}
UnixFaxServer::~UnixFaxServer() {}
UnixFaxServer::initServer(void)
{
HylaFAXServer::initServer();
- usedefault = TRUE;
+ usedefault = true;
}
void
return (NULL);
}
-fxBool
+bool
UnixFaxServer::dataConnect(void)
{
return Socket::connect(data, &data_dest,sizeof (data_dest)) >= 0;
return (file);
}
-fxBool
+bool
UnixFaxServer::hostPort()
{
fxStr s;
if (pathname(s)) {
data_dest.sun_family = AF_UNIX;
strncpy(data_dest.sun_path, s, sizeof (data_dest.sun_path));
- return (TRUE);
+ return (true);
} else
- return (FALSE);
+ return (false);
}
void
UnixFaxServer::portCmd(void)
{
logcmd(T_PORT, "%s", data_dest.sun_path);
- usedefault = FALSE;
+ usedefault = false;
if (pdata >= 0)
(void) Sys::close(pdata), pdata = -1;
reply(200, "PORT command successful.");
sockaddr_un data_source; // source of data connection
sockaddr_un data_dest; // destination of data connection
sockaddr_un peer_addr; // destination of control connection
- fxBool usedefault; // for data transfers
+ bool usedefault; // for data transfers
void passiveCmd(void);
void netStatus(FILE*);
- fxBool hostPort();
+ bool hostPort();
void portCmd(void);
virtual void initServer(void);
FILE* getDataSocket(const char* mode);
- fxBool dataConnect(void);
+ bool dataConnect(void);
FILE* openDataConn(const char* mode, int& code);
void send_data(FILE* instr, FILE* outstr, off_t blksize);
- fxBool receive_data(FILE* instr, FILE* outstr);
+ bool receive_data(FILE* instr, FILE* outstr);
public:
UnixFaxServer();
virtual ~UnixFaxServer();
private:
fxStr fileName; // UNIX domain socket filename
protected:
- fxBool startServer(void);
+ bool startServer(void);
HylaFAXServer* newChild(void);
public:
UnixSuperServer(const char* filename, int backlog = 5);
gid_t HylaFAXServer::faxuid = 0; // reserved fax uid
#define FAXUID_RESV HylaFAXServer::faxuid // reserved fax uid
-fxBool
+bool
HylaFAXServer::checkUser(const char* name)
{
- fxBool check = FALSE;
+ bool check = false;
FILE* db = fopen(fixPathname(userAccessFile), "r");
if (db != NULL) {
check = checkuser(db, name);
return (check);
}
-static fxBool
+static bool
nextRecord(FILE* db, char line[], u_int size)
{
while (fgets(line, size-1, db)) {
if (cp = strchr(line, '\n'))
*cp = '\0';
if (line[0] != '\0')
- return (TRUE);
+ return (true);
}
- return (FALSE);
+ return (false);
}
/*
* the list of users and hosts that are permitted to
* user the server and setup password handling.
*/
-fxBool
+bool
HylaFAXServer::checkuser(FILE* db, const char* name)
{
struct stat sb;
if (Sys::fstat(fileno(db), sb) < 0)
- return (FALSE);
+ return (false);
if (sb.st_mode&077) { // file must not be publicly readable
logError("Access control file not mode 600; access denied.");
- return (FALSE);
+ return (false);
}
uid = FAXUID_ANON; // anonymous user
adminwd = "*"; // disallow privileged access
RegEx pat(base, cp-base);
if (line[0] == '!') { // disallow access on match
if (pat.Find(dotform) || pat.Find(hostform))
- return (FALSE);
+ return (false);
} else { // allow access on match
if (pat.Find(dotform) || pat.Find(hostform)) {
passwd = ""; // no password required
} else
passwd = ""; // no password required
}
- return (TRUE);
+ return (true);
}
}
}
* folks that probe the server looking for valid accounts.
*/
passwd = "*";
- return (TRUE);
+ return (true);
}
fxDECLARE_PtrKeyDictionary(IDCache, u_int, fxStr)
/*
* Map user name to fax UID.
*/
-fxBool
+bool
HylaFAXServer::userID(const char* name, u_int& id)
{
if (name == the_user)
for (IDCacheIter iter(*idcache); iter.notDone(); iter++)
if (iter.value() == name) {
id = iter.key();
- return (TRUE);
+ return (true);
}
- return (FALSE);
+ return (false);
}
- return (TRUE);
+ return (true);
}
-static fxBool
+static bool
isAllLower(const char* cp)
{
while (*cp) {
if (!islower(*cp))
- return (FALSE);
+ return (false);
cp++;
}
- return (TRUE);
+ return (true);
}
static void
}
}
-fxBool
+bool
HylaFAXServer::cvtPasswd(const char* type, const char* pass, fxStr& result)
{
if (*pass == '\0') { // null password *IS* permitted
result = "";
- return (TRUE);
+ return (true);
}
if (strlen(pass) <= 5) {
reply(500, "%s password is too short; use 5-8 characters.", type);
- return (FALSE);
+ return (false);
}
if (isAllLower(pass)) {
reply(500, "%s password is all lower-case; use something more.", type);
- return (FALSE);
+ return (false);
}
srandom((int) Sys::now());
char salt[9];
to64(&salt[0], random(), 2);
#endif
result = crypt(pass, salt);
- return (TRUE);
+ return (true);
}
#define NBPL (sizeof (u_long) * CHAR_BIT) // bits/u_long
#endif
#define N(a) (sizeof (a) / sizeof (a[0]))
-fxBool
+bool
HylaFAXServer::findUser(FILE* db, const char* user, u_int& newuid)
{
rewind(db);
for (cp = line; *cp && *cp != ':'; cp++)
;
if (strncmp(user, line, cp-line) == 0)
- return (TRUE);
+ return (true);
if (*cp == ':' && isdigit(cp[1])) { // mark uid as in-use
u_int uid = (u_int) atoi(cp+1);
SetBit(uid);
for (u_long mask = 1; allocated[l] & mask; mask <<= 1)
b++;
newuid = (u_int) (l*NBPL + b);
- return (FALSE);
+ return (false);
}
newuid = (u_int) -1; // no more space
- return (FALSE);
+ return (false);
}
-fxBool
+bool
HylaFAXServer::addUser(FILE* db, const char* user, u_int uid, const char* upass, const char* apass)
{
fxStr templ("/" FAX_TMPDIR "/uaddXXXXXX");
if (fd < 0) {
reply(550, "Error creating temp file %s: %s.",
(const char*) templ, strerror(errno));
- return (FALSE);
+ return (false);
}
rewind(db);
char buf[8*1024];
perror_reply(550, "Write error", errno);
Sys::close(fd);
(void) Sys::unlink(templ);
- return (FALSE);
+ return (false);
}
fxStr line;
if (*apass != '\0')
perror_reply(550, "Write error", errno);
Sys::close(fd);
(void) Sys::unlink(templ);
- return (FALSE);
+ return (false);
}
Sys::close(fd);
if (Sys::rename(templ, fixPathname(userAccessFile)) < 0) {
perror_reply(550, "Rename of temp file failed", errno);
(void) Sys::unlink(templ);
- return (FALSE);
+ return (false);
}
- return (TRUE);
+ return (true);
}
/*
(const char*) userAccessFile, strerror(errno));
}
-fxBool
+bool
HylaFAXServer::deleteUser(FILE* db, const char* user)
{
fxStr templ("/" FAX_TMPDIR "/udelXXXXXX");
if (fd < 0 || (ftmp = fdopen(fd, "w")) == NULL) {
reply(550, "Error creating temp file %s: %s.",
(const char*) templ, strerror(errno));
- return (FALSE);
+ return (false);
}
/*
* Scan the existing file for the specified user
* scanning line-by-line and just block-copy the
* remaining part of the file.
*/
- fxBool found = FALSE;
+ bool found = false;
rewind(db);
char line[8*1024];
while (fgets(line, sizeof (line)-1, db)) {
for (cp = line; *cp && *cp != '\n' && *cp != ':'; cp++)
;
if (strncmp(user, line, cp-line) == 0) {
- found = TRUE;
+ found = true;
break;
}
}
int cc;
while ((cc = fread(line, 1, sizeof (line), db)) > 0)
fwrite(line, cc, 1, ftmp);
- fxBool ioError = (fclose(ftmp) != 0);
+ bool ioError = (fclose(ftmp) != 0);
if (found) {
if (ioError)
perror_reply(550, "I/O error", errno);
else if (Sys::rename(templ, fixPathname(userAccessFile)) < 0)
perror_reply(550, "Rename of temp file failed", errno);
else
- return (TRUE);
+ return (true);
} else
reply(500, "User %s not found in access file.", user);
(void) Sys::unlink(templ);
- return (FALSE);
+ return (false);
}
/*
switch (c) {
case 'h': case 'i': case 'o': case 's': case 'u':
if (detach == -1) // detach unless explicitly specified
- detach = TRUE;
+ detach = true;
break;
case 'H': case 'I': case 'O': case 'S':
if (detach == -1) // don't detach when invoked by inetd
- detach = FALSE;
+ detach = false;
break;
- case 'd': detach = FALSE; break;
+ case 'd': detach = false; break;
case 'q': queueDir = optarg; break;
case '?': usage(appName);
}
if (detach == -1) // no protocol options means -I
- detach = FALSE;
+ detach = false;
if (Sys::chdir(queueDir) < 0)
fatal(queueDir | ": Can not change directory");
CheckSpoolingSetup();
sendFaxApp();
~sendFaxApp();
- fxBool run(int argc, char** argv);
+ bool run(int argc, char** argv);
};
fxStr sendFaxApp::dbName("~/.faxdb");
delete db;
}
-fxBool
+bool
sendFaxApp::run(int argc, char** argv)
{
extern int optind;
readConfig(FAX_LIBDATA "/sendfax.conf");
readConfig(FAX_USERCONF);
- fxBool waitForJob = FALSE;
+ bool waitForJob = false;
int verbose = 0;
SendFaxJob& proto = getProtoJob();
db = new FaxDB(tildeExpand(dbName));
addDestination(optarg);
break;
case 'E': // disable use of ECM
- proto.setDesiredEC(FALSE);
+ proto.setDesiredEC(false);
break;
case 'F': // override tag line format string
proto.setTagLineFormat(optarg);
proto.setVResolution(196.);
break;
case 'n': // no cover sheet
- proto.setAutoCoverPage(FALSE);
+ proto.setAutoCoverPage(false);
break;
case 'N': // no notification
proto.setNotification("none");
case 'v': // verbose mode
verbose++;
setvbuf(stdout, NULL, _IOLBF, BUFSIZ);
- SendFaxClient::setVerbose(TRUE); // type rules & basic operation
+ SendFaxClient::setVerbose(true); // type rules & basic operation
FaxClient::setVerbose(verbose > 1); // protocol tracing
break;
case 'V': // cover sheet: voice number field
proto.setCoverVoiceNumber(optarg);
break;
case 'w': // wait for job to complete
- waitForJob = TRUE;
+ waitForJob = true;
break;
case 'x': // cover page: to's company
proto.setCoverCompany(optarg);
copyToTemporary(fileno(stdin), stdinTemp);
addFile(stdinTemp);
}
- fxBool status = FALSE;
+ bool status = false;
fxStr emsg;
if (callServer(emsg)) {
status = login(NULL, emsg)
sendPageApp();
~sendPageApp();
- fxBool run(int argc, char** argv);
+ bool run(int argc, char** argv);
};
sendPageApp::sendPageApp()
Sys::unlink(msgFile);
}
-fxBool
+bool
sendPageApp::run(int argc, char** argv)
{
extern int optind;
readConfig(FAX_USERCONF);
fxStr emsg;
- fxBool noText = FALSE; // default is to assume message text
+ bool noText = false; // default is to assume message text
SNPPJob& proto = getProtoJob();
while ((c = Sys::getopt(argc, argv, "a:De:f:h:i:I:l:nNp:qRs:t:T:v")) != -1)
switch (c) {
proto.setServiceLevel(atoi(optarg));
break;
case 'n': // numeric-only page, no message text
- noText = TRUE;
+ noText = true;
break;
case 'N': // no notification
proto.setNotification("none");
addJob().setPIN(optarg);
break;
case 'q': // queue job and don't wait
- proto.setQueued(TRUE);
+ proto.setQueued(true);
break;
case 'R': // notify when requeued or done
proto.setNotification("when requeued");
break;
case 'v': // client-server protocol tracing
setvbuf(stdout, NULL, _IOLBF, BUFSIZ);
- setVerbose(TRUE);
+ setVerbose(true);
break;
case '?':
usage();
setPagerMsgFile(msgFile);
}
}
- fxBool status = FALSE;
+ bool status = false;
if (callServer(emsg)) {
status = login(NULL, emsg)
&& prepareForJobSubmissions(emsg)
fxAddress() { ptr = 0; }
fxAddress(void* p) { ptr = (char*) p; }
fxAddress operator+(u_long offset) const { return ptr + offset; }
- fxBool operator==(const fxAddress& r) const { return ptr == r.ptr; }
- fxBool operator!=(const fxAddress& r) const { return ptr != r.ptr; }
+ bool operator==(const fxAddress& r) const { return ptr == r.ptr; }
+ bool operator!=(const fxAddress& r) const { return ptr != r.ptr; }
// NB: operator const void*() const does not work
operator void*() const { return ptr; }
protected:
#endif
#define streq(a,b,n) (strncasecmp(a,b,n) == 0)
-static fxBool checkDay(const char*& cp, int& day);
+static bool checkDay(const char*& cp, int& day);
static void adjustDay(struct tm& at, int day, const struct tm&);
-static fxBool checkMonth(const char*& cp, int& month);
-static fxBool parseMonthAndYear(const char*&, const struct tm& ref,
+static bool checkMonth(const char*& cp, int& month);
+static bool parseMonthAndYear(const char*&, const struct tm& ref,
struct tm& at, fxStr& emsg);
-static fxBool parseMultiplier(const char* cp, struct tm& at, fxStr& emsg);
+static bool parseMultiplier(const char* cp, struct tm& at, fxStr& emsg);
static const char* whitespace(const char* cp);
static void fixup(struct tm& at);
int min = 10*(cp[1]-'0') + (cp[2]-'0');
if (min >= 60) {
_atError(emsg, "Illegal minutes value %u", min);
- return (FALSE);
+ return (false);
}
v += min;
cp += 3;
} else {
_atSyntax(emsg, "expecting HH:MM");
- return (FALSE);
+ return (false);
}
}
cp = whitespace(cp);
if (streq(cp, "am", 2)) {
if (v >= HALFDAY+HOUR) {
_atError(emsg, "%u:%02u is not an AM value", v/HOUR, v%HOUR);
- return (FALSE);
+ return (false);
}
if (HALFDAY <= v && v < HALFDAY+HOUR)
v -= HALFDAY;
} else if (streq(cp, "pm", 2)) {
if (v >= HALFDAY+HOUR) {
_atError(emsg, "%u:%02u is not a PM value", v/HOUR, v%HOUR);
- return (FALSE);
+ return (false);
}
if (v < HALFDAY)
v += HALFDAY;
cp += 4;
} else {
_atSyntax(emsg, "unrecognized symbolic time \"%s\"", cp);
- return (FALSE);
+ return (false);
}
}
if ((unsigned) v >= FULLDAY) {
_atError(emsg, "Illegal time value; out of range");
- return (FALSE);
+ return (false);
}
at.tm_hour = v/HOUR;
at.tm_min = v%HOUR;
if (checkMonth(cp, v)) {
at.tm_mon = v;
if (!parseMonthAndYear(cp, ref, at, emsg))
- return (FALSE);
+ return (false);
} else if (checkDay(cp, v)) {
adjustDay(at, v, ref);
} else {
cp += 8;
} else if (cp[0] != '\0' && cp[0] != '+') {
_atSyntax(emsg, "expecting \"+\" after time");
- return (FALSE);
+ return (false);
}
/*
* Adjust the date according to whether it is before ``now''.
* Process any increment expression.
*/
if (cp[0] == '+' && !parseMultiplier(++cp, at, emsg))
- return (FALSE);
+ return (false);
fixup(at);
if (at < ref) {
_atError(emsg, "Invalid date/time; time must be in the future");
- return (FALSE);
+ return (false);
}
at0 = at;
- return (TRUE);
+ return (true);
}
/*
* return the day number [0..6] and update
* the character pointer.
*/
-static fxBool
+static bool
checkDay(const char*& cp, int& day)
{
static const char* days[] = {
if (streq(cp, days[i], len)) {
cp += len;
day = i;
- return (TRUE);
+ return (true);
}
if (len != 3) { // an Algol-style for loop...
len = 3;
goto again;
}
}
- return (FALSE);
+ return (false);
}
/*
* return the month index [0..11] and update
* the character pointer.
*/
-static fxBool
+static bool
checkMonth(const char*& cp, int& month)
{
for (u_int i = 0; i < N(months); i++) {
if (streq(cp, months[i], len)) {
cp += len;
month = i;
- return (TRUE);
+ return (true);
}
if (len != 3) { // an Algol-style for loop...
len = 3;
goto again;
}
}
- return (FALSE);
+ return (false);
}
/*
/*
* Parse an expected day [, year] expression.
*/
-static fxBool
+static bool
parseMonthAndYear(const char*& cp, const struct tm& ref, struct tm& at, fxStr& emsg)
{
char* tp;
at.tm_mday = (u_int) strtoul(cp, &tp, 10);
if (tp == cp) {
_atSyntax(emsg, "missing or invalid day of month");
- return (FALSE);
+ return (false);
}
at.tm_mday--; // tm_mday is [0..31]
tp = (char*) whitespace(tp);
u_int year = (u_int) strtoul(++tp, &xp, 10);
if (tp == xp) {
_atSyntax(emsg, "missing year");
- return (FALSE);
+ return (false);
}
if (year < TM_YEAR_BASE) {
_atError(emsg, "Sorry, cannot handle dates before %u",
TM_YEAR_BASE);
- return (FALSE);
+ return (false);
}
at.tm_year = year - TM_YEAR_BASE;
adjustYDay(at);
if (at.tm_mday > days[at.tm_mon]) {
_atError(emsg, "Invalid day of month, %s has only %u days",
months[at.tm_mon], days[at.tm_mon]);
- return (FALSE);
+ return (false);
}
cp = tp;
- return (TRUE);
+ return (true);
}
/*
* Parse an expected multiplier expression.
*/
-static fxBool
+static bool
parseMultiplier(const char* cp, struct tm& at, fxStr& emsg)
{
cp = whitespace(cp);
if (!isdigit(cp[0])) {
_atSyntax(emsg, "expecting number after \"+\"");
- return (FALSE);
+ return (false);
}
int v = 0;
for (; isdigit(*cp); cp++)
cp = whitespace(cp);
if (*cp == '\0') {
_atSyntax(emsg, "\"+%u\" without unit", v);
- return (FALSE);
+ return (false);
}
if (streq(cp, "minute", 6))
at.tm_min += v;
at.tm_year += v;
else {
_atError(emsg, "Unknown increment unit \"%s\"", cp);
- return (FALSE);
+ return (false);
}
- return (TRUE);
+ return (true);
}
/*
at.tm_hour++, at.tm_min -= HOUR;
while (at.tm_hour >= FULLDAY)
at.tm_yday++, at.tm_hour -= FULLDAY;
- fxBool leap;
+ bool leap;
int daysinyear;
for (;;) {
leap = isLeapYear(at);
*/
#include "BoolArray.h"
-fxIMPLEMENT_PrimArray(fxBoolArray, fxBool)
+fxIMPLEMENT_PrimArray(fxBoolArray, bool)
#include "Array.h"
-fxDECLARE_PrimArray(fxBoolArray, fxBool)
+fxDECLARE_PrimArray(fxBoolArray, bool)
#endif /* _BoolArray_ */
return fxStr(buf);
}
-fxBool
+bool
Class2Params::is2D() const
{
return (DF_2DMR <= df && df <= DF_2DMRUNCOMP);
void setFromDCS(u_int dcs, u_int xinfo = 0);
u_int getDCS() const;
u_int getXINFO() const;
- fxBool is2D() const;
+ bool is2D() const;
u_int transferSize(u_int ms) const;
u_int minScanlineSize() const;
DialStringRules::DialStringRules(const char* file) : filename(file)
{
- verbose = FALSE;
+ verbose = false;
fp = NULL;
vars = new VarDict;
regex = new RegExArray;
delete vars;
}
-void DialStringRules::setVerbose(fxBool b) { verbose = b; }
+void DialStringRules::setVerbose(bool b) { verbose = b; }
/*
* Parse the dialing string rules file
* to create the in-memory rules.
*/
-fxBool
-DialStringRules::parse(fxBool shouldExist)
+bool
+DialStringRules::parse(bool shouldExist)
{
- fxBool ok = FALSE;
+ bool ok = false;
lineno = 0;
fp = fopen(filename, "r");
if (fp) {
vars->remove(var);
}
-fxBool
+bool
DialStringRules::parseRules()
{
char line[1024];
// collect token
if (!isalpha(*cp)) {
parseError("Syntax error, expecting identifier");
- return (FALSE);
+ return (false);
}
const char* tp = cp;
for (cp++; isalnum(*cp); cp++)
for (cp += 2; *cp != '['; cp++)
if (*cp == '\0') {
parseError("Missing '[' while parsing rule set");
- return (FALSE);
+ return (false);
}
if (verbose)
traceParse("%s := [", (const char*) var);
RuleArray* ra = new RuleArray;
if (!parseRuleSet(*ra)) {
delete ra;
- return (FALSE);
+ return (false);
}
(*rules)[var] = ra;
if (verbose)
} else if (*cp == '=') { // variable definition
fxStr value;
if (parseToken(cp+1, value) == NULL)
- return (FALSE);
+ return (false);
def(var, value);
} else { // an error
parseError("Missing '=' or ':=' after \"%s\"", (const char*) var);
- return (FALSE);
+ return (false);
}
}
if (verbose) {
if (ra == 0)
traceParse("Warning, no \"DialString\" rules.");
}
- return (TRUE);
+ return (true);
}
/*
u_int l = v.next(i, '}');
if (l >= v.length()) {
parseError("Missing '}' for variable reference");
- return (FALSE);
+ return (NULL);
}
fxStr var = v.cut(i+2,l-(i+2));// variable name
v.remove(i, 3); // remove ${}
* Parse a set of rules and construct the array of
* rules (regular expressions + replacement strings).
*/
-fxBool
+bool
DialStringRules::parseRuleSet(RuleArray& rules)
{
for (;;) {
const char* cp = nextLine(line, sizeof (line));
if (!cp) {
parseError("Missing ']' while parsing rule set");
- return (FALSE);
+ return (false);
}
if (*cp == ']')
- return (TRUE);
+ return (true);
// new rule
fxStr pat;
if ((cp = parseToken(cp, pat)) == NULL)
- return (FALSE);
+ return (false);
while (isspace(*cp))
cp++;
if (*cp != '=') {
parseError("Rule pattern without '='");
- return (FALSE);
+ return (false);
}
DialRule r;
if (parseToken(cp+1, r.replace) == NULL)
- return (FALSE);
+ return (false);
if (verbose)
traceParse(" \"%s\" = \"%s\"",
(const char*) pat, (const char*) r.replace);
u_int lineno; // current line number during parsing
FILE* fp; // open file during parsing
VarDict* vars; // defined variables during parsing
- fxBool verbose; // trace parsing of rules file
+ bool verbose; // trace parsing of rules file
RegExArray* regex; // regular expressions
RulesDict* rules; // rules defined in the file
- fxBool parseRules();
- fxBool parseRuleSet(RuleArray& rules);
+ bool parseRules();
+ bool parseRuleSet(RuleArray& rules);
const char* parseToken(const char* cp, fxStr& v);
char* nextLine(char* line, int lineSize);
void subRHS(fxStr& v);
DialStringRules(const char* filename);
virtual ~DialStringRules();
- void setVerbose(fxBool b);
+ void setVerbose(bool b);
u_int getLineno() const;
const fxStr& getFilename() const;
void def(const fxStr& var, const fxStr& value);
void undef(const fxStr& var);
- fxBool parse(fxBool shouldExist = TRUE);
+ bool parse(bool shouldExist = true);
fxStr applyRules(const fxStr& name, const fxStr& s);
fxStr canonicalNumber(const fxStr&);
for (i=0; i < l; i++) {
iters[i]->dict = 0;
iters[i]->node = 0;
- iters[i]->invalid = TRUE;
+ iters[i]->invalid = true;
}
}
fxDictIter* di = iters[i];
if (di->node == db) {
(*di)++;
- if (di->dict) di->invalid = TRUE;
+ if (di->dict) di->invalid = true;
}
}
}
fxDictIter::fxDictIter()
{
- invalid = FALSE;
+ invalid = false;
dict = 0;
bucket = 0;
node = 0;
fxDictIter::fxDictIter(fxDictionary& d)
{
- invalid = FALSE;
+ invalid = false;
dict = &d;
bucket = 0;
node = d.buckets[bucket];
dict = &d;
bucket = 0;
node = d.buckets[bucket];
- invalid = FALSE;
+ invalid = false;
d.addIter(this);
if (!node) advanceToValid();
}
{
if (!dict) return;
if (invalid) {
- invalid = FALSE;
+ invalid = false;
return;
}
node = node->next;
if (bucket == len) {
dict->removeIter(this); // it's done with us
dict = 0;
- invalid = TRUE;
+ invalid = true;
break;
}
if (n = dict->buckets[bucket]) { // NB: intentional =
node = n;
- invalid = FALSE;
+ invalid = false;
break;
}
}
operator KEY const &() const
KEY const& key() const;
VALUE& value() const;
- fxBool removed();
- fxBool notDone();
+ bool removed();
+ bool notDone();
}
*******************************************/
void operator=(fxDictionary&); // not a const argument!
void operator++() { increment(); }
void operator++(int) { increment(); }
- fxBool removed() const { return invalid; }
- fxBool notDone() const { return node != 0; }
+ bool removed() const { return invalid; }
+ bool notDone() const { return node != 0; }
protected:
void* getKey() const;
void* getValue() const;
return delta;
}
-fxBool operator>(timeval src1, timeval src2) {
+bool operator>(timeval src1, timeval src2) {
if (src1.tv_sec > src2.tv_sec) {
- return TRUE;
+ return true;
} else if (src1.tv_sec == src2.tv_sec && src1.tv_usec > src2.tv_usec) {
- return TRUE;
+ return true;
} else {
- return FALSE;
+ return false;
}
}
-fxBool operator<(timeval src1, timeval src2) {
+bool operator<(timeval src1, timeval src2) {
if (src1.tv_sec < src2.tv_sec) {
- return TRUE;
+ return true;
} else if (src1.tv_sec == src2.tv_sec && src1.tv_usec < src2.tv_usec) {
- return TRUE;
+ return true;
} else {
- return FALSE;
+ return false;
}
}
TimerQueue();
virtual ~TimerQueue();
- fxBool isEmpty() const;
+ bool isEmpty() const;
static timeval zeroTime();
timeval earliestTime() const;
static timeval currentTime();
}
}
-inline fxBool TimerQueue::isEmpty() const {
+inline bool TimerQueue::isEmpty() const {
return _first == NULL;
}
ChildQueue();
virtual ~ChildQueue();
- fxBool isEmpty() const;
- fxBool isReady() const;
+ bool isEmpty() const;
+ bool isReady() const;
void insert(pid_t, IOHandler*);
void remove(IOHandler*);
void setStatus(pid_t, int status);
private:
Child* _first; // queue head
- fxBool _ready; // something is ready
+ bool _ready; // something is ready
};
Child::Child(pid_t p, IOHandler* h, Child* n)
ChildQueue::ChildQueue()
{
_first = NULL;
- _ready = FALSE;
+ _ready = false;
}
ChildQueue::~ChildQueue() {
}
}
-inline fxBool ChildQueue::isEmpty() const { return _first == NULL; }
-inline fxBool ChildQueue::isReady() const { return _ready; }
+inline bool ChildQueue::isEmpty() const { return _first == NULL; }
+inline bool ChildQueue::isReady() const { return _ready; }
void ChildQueue::insert(pid_t p, IOHandler* handler) {
/*
for (Child* c = _first; c != NULL; c = c->next)
if (c->pid == p) {
c->status = status;
- _ready = TRUE;
+ _ready = true;
break;
}
}
} else
prev = &c->next;
}
- _ready = FALSE;
+ _ready = false;
}
Dispatcher::Dispatcher() {
_cqueue->remove(handler);
}
-fxBool Dispatcher::setReady(int fd, DispatcherMask mask) {
+bool Dispatcher::setReady(int fd, DispatcherMask mask) {
if (handler(fd, mask) == NULL) {
- return FALSE;
+ return false;
}
if (mask == ReadMask) {
FD_SET(fd, &_rmaskready);
} else if (mask == ExceptMask) {
FD_SET(fd, &_emaskready);
} else {
- return FALSE;
+ return false;
}
- return TRUE;
+ return true;
}
void Dispatcher::dispatch() {
dispatch(NULL);
}
-fxBool Dispatcher::dispatch(long& sec, long& usec) {
+bool Dispatcher::dispatch(long& sec, long& usec) {
timeval howlong;
timeval prevTime;
timeval elapsedTime;
howlong.tv_usec = usec;
prevTime = TimerQueue::currentTime();
- fxBool success = dispatch(&howlong);
+ bool success = dispatch(&howlong);
elapsedTime = TimerQueue::currentTime() - prevTime;
if (howlong > elapsedTime) {
return success;
}
-fxBool Dispatcher::dispatch(timeval* howlong) {
+bool Dispatcher::dispatch(timeval* howlong) {
fd_set rmask;
fd_set wmask;
fd_set emask;
return (nfound != 0);
}
-fxBool Dispatcher::anyReady() const {
+bool Dispatcher::anyReady() const {
if (!_cqueue->isEmpty()) {
Dispatcher::sigCLD(0); // poll for pending children
return _cqueue->isReady();
for (int i = 0; i < _nfds; i++) {
if (FD_ISSET(i, &_rmaskready) ||
FD_ISSET(i, &_wmaskready) || FD_ISSET(i, &_emaskready)) {
- return TRUE;
+ return true;
}
}
- return FALSE;
+ return false;
}
int Dispatcher::fillInReady(
extern void fxFatal(const char* fmt, ...);
-fxBool Dispatcher::handleError() {
+bool Dispatcher::handleError() {
switch (errno) {
case EBADF:
checkConnections();
break;
case EINTR:
if (_cqueue->isReady())
- return TRUE;
+ return true;
break;
default:
fxFatal("Dispatcher: select: %s", strerror(errno));
/*NOTREACHED*/
}
- return FALSE; // retry select
+ return false; // retry select
}
void Dispatcher::checkConnections() {
virtual void startChild(pid_t pid, IOHandler*);
virtual void stopChild(IOHandler*);
- virtual fxBool setReady(int fd, DispatcherMask);
+ virtual bool setReady(int fd, DispatcherMask);
virtual void dispatch();
- virtual fxBool dispatch(long& sec, long& usec);
+ virtual bool dispatch(long& sec, long& usec);
static Dispatcher& instance();
static void instance(Dispatcher*);
protected:
virtual void attach(int fd, DispatcherMask, IOHandler*);
virtual void detach(int fd);
- virtual fxBool dispatch(timeval*);
- virtual fxBool anyReady() const;
+ virtual bool dispatch(timeval*);
+ virtual bool anyReady() const;
virtual int fillInReady(fd_set&, fd_set&, fd_set&);
virtual int waitFor(fd_set&, fd_set&, fd_set&, timeval*);
virtual void notify(int, fd_set&, fd_set&, fd_set&);
virtual timeval* calculateTimeout(timeval*) const;
- virtual fxBool handleError();
+ virtual bool handleError();
virtual void checkConnections();
protected:
int _nfds;
void FaxClient::setModem(const char* modemarg) { modem = modemarg; }
void
-FaxClient::setVerbose(fxBool v)
+FaxClient::setVerbose(bool v)
{
if (v)
state |= FS_VERBOSE;
state &= ~FS_VERBOSE;
}
-fxBool
+bool
FaxClient::setupUserIdentity(fxStr& emsg)
{
struct passwd* pwd = NULL;
emsg = fxStr::format(
"Can not locate your password entry (account name %s, uid %lu).",
(name ? name : "<unspecified>"), (u_long) getuid());
- return (FALSE);
+ return (false);
}
userName = pwd->pw_name;
if (pwd->pw_gecos && pwd->pw_gecos[0] != '\0') {
if (senderName.length() == 0) {
emsg = "Bad (null) user name; your password file entry"
" probably has bogus GECOS field information.";
- return (FALSE);
+ return (false);
} else
- return (TRUE);
+ return (true);
}
/*
}
}
-fxBool
+bool
FaxClient::setConfigItem(const char* tag, const char* value)
{
u_int ix;
} else if (streq(tag, "filefmt")) {
setFileStatusFormat(value);
} else
- return (FALSE);
- return (TRUE);
+ return (false);
+ return (true);
}
-fxBool
+bool
FaxClient::callServer(fxStr& emsg)
{
if (host.length() == 0) { // if host not specified by -h
* Transport code is expected to call back through
* setCtrlFds so fdIn should be properly setup...
*/
- return (fdIn != NULL && getReply(FALSE) == COMPLETE);
+ return (fdIn != NULL && getReply(false) == COMPLETE);
} else
- return (FALSE);
+ return (false);
}
-fxBool
+bool
FaxClient::hangupServer(void)
{
if (fdIn != NULL) {
*/
delete transport, transport = NULL;
initServerState();
- return (TRUE);
+ return (true);
}
void
/*
* Do login procedure.
*/
-fxBool
+bool
FaxClient::login(const char* user, fxStr& emsg)
{
if (user == NULL) {
(void) setTimeZone(tz);
state &= ~FS_TZPEND;
}
- return (TRUE);
+ return (true);
} else {
emsg = "Login failed: " | lastResponse;
- return (FALSE);
+ return (false);
}
}
/*
* Do admin login procedure.
*/
-fxBool
+bool
FaxClient::admin(const char* pass, fxStr& emsg)
{
if (command("ADMIN %s", pass ? pass : getpass("Password:")) != COMPLETE) {
emsg = "Admin failed: " | lastResponse;
- return (FALSE);
+ return (false);
} else
- return (TRUE);
+ return (true);
}
-fxBool
+bool
FaxClient::setCommon(const FaxParam& parm, u_int v)
{
if (v != this->*parm.pv) {
if (0 < v && v < parm.NparmNames) {
if (command("%s %s", parm.cmd, parm.parmNames[v]) != COMPLETE) {
printError("%s", (const char*) lastResponse);
- return (FALSE);
+ return (false);
}
} else {
printError("Bad %s parameter value %u.", parm.cmd, v);
- return (FALSE);
+ return (false);
}
this->*parm.pv = v;
}
- return (TRUE);
+ return (true);
}
static const char* typeNames[] = { "", "A", "E", "I", "L" };
const FaxClient::FaxParam FaxClient::typeParam =
{ "TYPE", typeNames, N(typeNames), &FaxClient::type };
-fxBool FaxClient::setType(u_int v) { return setCommon(typeParam, v); }
+bool FaxClient::setType(u_int v) { return setCommon(typeParam, v); }
static const char* modeNames[] = { "", "S", "B", "C", "Z" };
const FaxClient::FaxParam FaxClient::modeParam =
{ "MODE", modeNames, N(modeNames), &FaxClient::mode };
-fxBool FaxClient::setMode(u_int v) { return setCommon(modeParam, v); }
+bool FaxClient::setMode(u_int v) { return setCommon(modeParam, v); }
static const char* struNames[] = { "", "F", "R", "P", "T" };
const FaxClient::FaxParam FaxClient::struParam =
{ "STRU", struNames, N(struNames), &FaxClient::stru };
-fxBool FaxClient::setStruct(u_int v) { return setCommon(struParam, v); }
+bool FaxClient::setStruct(u_int v) { return setCommon(struParam, v); }
static const char* formNames[] = { "", "PS", "PS2", "TIFF", "PCL" };
const FaxClient::FaxParam FaxClient::formParam =
{ "FORM", formNames, N(formNames), &FaxClient::format };
-fxBool FaxClient::setFormat(u_int v) { return setCommon(formParam, v); }
+bool FaxClient::setFormat(u_int v) { return setCommon(formParam, v); }
static const char* tzoneNames[] = { "", "GMT", "LOCAL" };
const FaxClient::FaxParam FaxClient::tzoneParam =
{ "TZONE", tzoneNames, N(tzoneNames), &FaxClient::tzone };
-fxBool
+bool
FaxClient::setTimeZone(u_int v)
{
if (!isLoggedIn()) { // set and mark pending accordingly
state |= FS_TZPEND;
} else {
printError("Bad time zone parameter value %u.", v);
- return (FALSE);
+ return (false);
}
- return (TRUE);
+ return (true);
} else // pass directly to server
return setCommon(tzoneParam, v);
}
* is provided for this use.
*/
-fxBool
+bool
FaxClient::initDataConn(fxStr& emsg)
{
closeDataConn();
if (!transport->initDataConn(emsg)) {
if (emsg == "")
emsg = "Unable to initialize data connection to server";
- return (FALSE);
+ return (false);
}
}
- return (TRUE);
+ return (true);
}
-fxBool
+bool
FaxClient::openDataConn(fxStr& emsg)
{
if (transport) {
if (!transport->openDataConn(emsg)) {
if (emsg == "")
emsg = "Unable to open data connection to server";
- return (FALSE);
+ return (false);
}
}
- return (TRUE);
+ return (true);
}
void
}
}
-fxBool
+bool
FaxClient::abortDataConn(fxStr& emsg)
{
if (fdData >= 0 && transport) {
if (!transport->abortCmd(emsg)) {
if (emsg == "")
emsg = "Unable to abort data connection to server";
- return (FALSE);
+ return (false);
}
#ifdef notdef
/*
* existing operation is aborted followed by an ack
* of the ABOR command itself.
*/
- if (getReply(FALSE) != TRANSIENT || // 4xx operation aborted
- getReply(FALSE) != COMPLETE) { // 2xx abort successful
+ if (getReply(false) != TRANSIENT || // 4xx operation aborted
+ getReply(false) != COMPLETE) { // 2xx abort successful
unexpectedResponse(emsg);
- return (FALSE);
+ return (false);
}
}
- return (TRUE);
+ return (true);
}
void
* handled but not collected.
*/
int
-FaxClient::getReply(fxBool expecteof)
+FaxClient::getReply(bool expecteof)
{
int firstCode = 0;
- fxBool continuation = FALSE;
+ bool continuation = false;
do {
lastResponse.resize(0);
int c;
if (lastResponse[3] == '-') { // continuation line
if (firstCode == 0) // first line of reponse
firstCode = code;
- continuation = TRUE;
+ continuation = true;
} else if (code == firstCode) // end of continued reply
- continuation = FALSE;
+ continuation = false;
}
} while (continuation || code == 0);
* case was). The resulting string is checked to
* make sure that it is not null.
*/
-fxBool
+bool
FaxClient::extract(u_int& pos, const char* pattern, fxStr& result,
const char* cmd, fxStr& emsg)
{
if (l == lastResponse.length()) {
protocolBotch(emsg, ": No \"%s\" in %s response: %s",
pattern, cmd, (const char*) lastResponse);
- return (FALSE);
+ return (false);
}
l = lastResponse.skip(l+pat.length(), ' ');// skip white space
result = lastResponse.extract(l, lastResponse.next(l, ' ')-l);
if (result == "") {
protocolBotch(emsg, ": Null %s in %s response: %s",
pattern, cmd, (const char*) lastResponse);
- return (FALSE);
+ return (false);
}
pos = l; // update position
- return (TRUE);
+ return (true);
}
/*
* Create a new job and return its job-id
* and group-id, parsed from the reply.
*/
-fxBool
+bool
FaxClient::newJob(fxStr& jobid, fxStr& groupid, fxStr& emsg)
{
if (command("JNEW") == COMPLETE) {
jobid.resize(jobid.skip(0, "0123456789"));
groupid.resize(groupid.skip(0, "0123456789"));
curjob = jobid;
- return (TRUE);
+ return (true);
}
} else
unexpectedResponse(emsg);
} else
emsg = lastResponse;
- return (FALSE);
+ return (false);
}
/*
* Set the current job on the server.
*/
-fxBool
+bool
FaxClient::setCurrentJob(const char* jobid)
{
if (strcasecmp(jobid, curjob) != 0) {
if (command("JOB %s", jobid) != COMPLETE)
- return (FALSE);
+ return (false);
curjob = jobid;
}
- return (TRUE);
+ return (true);
}
-fxBool
+bool
FaxClient::jobParm(const char* name, const fxStr& value)
{
return jobParm(name, (const char*) value);
}
-fxBool
+bool
FaxClient::jobParm(const char* name, const char* value)
{
return (command("JPARM %s \"%s\"", name, value) == COMPLETE);
}
-fxBool
-FaxClient::jobParm(const char* name, fxBool b)
+bool
+FaxClient::jobParm(const char* name, bool b)
{
return (command("JPARM %s %s", name, b ? "YES" : "NO") == COMPLETE);
}
-fxBool
+bool
FaxClient::jobParm(const char* name, u_int v)
{
return (command("JPARM %s %u", name, v) == COMPLETE);
}
-fxBool
+bool
FaxClient::jobParm(const char* name, float v)
{
return (command("JPARM %s %g", name, v) == COMPLETE);
}
-fxBool
+bool
FaxClient::jobSendTime(const struct tm tm)
{
return (command("JPARM SENDTIME %d%02d%02d%02d%02d"
, tm.tm_min
) == COMPLETE);
}
-fxBool
+bool
FaxClient::jobLastTime(u_long tv)
{
return (command("JPARM LASTTIME %02d%02d%02d",
tv/(24*60*60), (tv/(60*60))%24, (tv/60)%60) == COMPLETE);
}
-fxBool
+bool
FaxClient::jobRetryTime(u_long tv)
{
return (command("JPARM RETRYTIME %02d%02d", tv/60, tv%60) == COMPLETE);
}
-fxBool
+bool
FaxClient::jobCover(const char* docname)
{
return (command("JPARM COVER %s", docname) == COMPLETE);
}
-fxBool
+bool
FaxClient::jobDocument(const char* docname)
{
return (command("JPARM DOCUMENT %s", docname) == COMPLETE);
}
-fxBool
+bool
FaxClient::jobPollRequest(const char* sep, const char* pwd)
{
return (command("JPARM POLL \"%s\" \"%s\"", sep, pwd) == COMPLETE);
}
-fxBool
+bool
FaxClient::jobOp(const char* op, const char* jobid)
{
return (command(jobid == curjob ? "%s" : "%s %s", op, jobid) == COMPLETE);
}
-fxBool FaxClient::jobSubmit(const char* jobid) { return jobOp("JSUBM",jobid); }
-fxBool FaxClient::jobSuspend(const char* jobid) { return jobOp("JSUSP",jobid); }
-fxBool FaxClient::jobKill(const char* jobid) { return jobOp("JKILL",jobid); }
-fxBool FaxClient::jobDelete(const char* jobid) { return jobOp("JDELE",jobid); }
-fxBool FaxClient::jobWait(const char* jobid) { return jobOp("JWAIT",jobid); }
+bool FaxClient::jobSubmit(const char* jobid) { return jobOp("JSUBM",jobid); }
+bool FaxClient::jobSuspend(const char* jobid) { return jobOp("JSUSP",jobid); }
+bool FaxClient::jobKill(const char* jobid) { return jobOp("JKILL",jobid); }
+bool FaxClient::jobDelete(const char* jobid) { return jobOp("JDELE",jobid); }
+bool FaxClient::jobWait(const char* jobid) { return jobOp("JWAIT",jobid); }
-fxBool FaxClient::jgrpSubmit(const char* jgrpid)
+bool FaxClient::jgrpSubmit(const char* jgrpid)
{ return (command("JGSUBM %s", jgrpid) == COMPLETE); }
-fxBool FaxClient::jgrpSuspend(const char* jgrpid)
+bool FaxClient::jgrpSuspend(const char* jgrpid)
{ return (command("JGSUSP %s", jgrpid) == COMPLETE); }
-fxBool FaxClient::jgrpKill(const char* jgrpid)
+bool FaxClient::jgrpKill(const char* jgrpid)
{ return (command("JGKILL %s", jgrpid) == COMPLETE); }
-fxBool FaxClient::jgrpWait(const char* jgrpid)
+bool FaxClient::jgrpWait(const char* jgrpid)
{ return (command("JGWAIT %s", jgrpid) == COMPLETE); }
-fxBool
+bool
FaxClient::runScript(const char* filename, fxStr& emsg)
{
- fxBool ok = FALSE;
+ bool ok = false;
FILE* fd = fopen(filename, "r");
if (fd != NULL) {
ok = runScript(fd, filename, emsg);
return (ok);
}
-fxBool
+bool
FaxClient::runScript(FILE* fp, const char* filename, fxStr& emsg)
{
- fxBool ok = FALSE;
+ bool ok = false;
struct stat sb;
(void) Sys::fstat(fileno(fp), sb);
char* addr;
return (ok);
}
-fxBool
+bool
FaxClient::runScript(const char* script, u_long scriptLen,
const char* filename, fxStr& emsg)
{
if (command("%.*s", cmdLen, script) != COMPLETE) {
emsg = fxStr::format("%s: line %u: %s",
filename, lineno, (const char*) lastResponse);
- return (FALSE);
+ return (false);
}
}
if (*ep == '\n')
scriptLen -= ep - script;
script = ep;
}
- return (TRUE);
+ return (true);
}
/*
* Create a uniquely named document on the server
* that is not removed when the server exits.
*/
-fxBool
+bool
FaxClient::storeUnique(fxStr& docname, fxStr& emsg)
{
return storeUnique("STOU", docname, emsg);
* Create a uniquely named document on the server
* that is automatically removed when the server exits.
*/
-fxBool
+bool
FaxClient::storeTemp(fxStr& docname, fxStr& emsg)
{
return storeUnique("STOT", docname, emsg);
* Send a STOU/STOT command and parse the
* response to get the resulting filename.
*/
-fxBool
+bool
FaxClient::storeUnique(const char* cmd, fxStr& docname, fxStr& emsg)
{
if (command(cmd) == PRELIM) {
unexpectedResponse(emsg);
} else
emsg = lastResponse;
- return (FALSE);
+ return (false);
}
/*
* Create/overwrite a file on the server.
*/
-fxBool
+bool
FaxClient::storeFile(fxStr& docname, fxStr& emsg)
{
if (command("STOR " | docname) != PRELIM) {
emsg = lastResponse;
- return (FALSE);
+ return (false);
}
if (code != 150) {
unexpectedResponse(emsg);
- return (FALSE);
+ return (false);
}
- return (TRUE);
+ return (true);
}
/*
* Send a block of raw data on the data
* conenction, interpreting write errors.
*/
-fxBool
+bool
FaxClient::sendRawData(void* buf, int cc, fxStr& emsg)
{
#ifdef __linux__
protocolBotch(emsg, errno == EPIPE ?
" (server closed connection)" : " (server write error: %s).",
strerror(errno));
- return (FALSE);
+ return (false);
}
#else
if (write(fdData, buf, cc) != cc) {
protocolBotch(emsg, errno == EPIPE ?
" (server closed connection)" : " (server write error: %s).",
strerror(errno));
- return (FALSE);
+ return (false);
}
#endif
- return (TRUE);
+ return (true);
}
/*
* and the current transfer parameters. The server-side
* document name where data gets placed is returned.
*/
-fxBool
+bool
FaxClient::sendData(int fd,
- fxBool (FaxClient::*store)(fxStr&, fxStr&), fxStr& docname, fxStr& emsg)
+ bool (FaxClient::*store)(fxStr&, fxStr&), fxStr& docname, fxStr& emsg)
{
char* addr = (char*) -1;
struct stat sb;
if (addr != (char*) -1)
munmap(addr, sb.st_size);
#endif
- return (getReply(FALSE) == 2);
+ return (getReply(false) == 2);
bad:
closeDataConn();
#if HAS_MMAP
if (addr != (char*) -1)
munmap(addr, sb.st_size);
#endif
- return (FALSE);
+ return (false);
}
/*
* and the current transfer parameters. The server-side
* document name where data gets placed is returned.
*/
-fxBool
+bool
FaxClient::sendZData(int fd,
- fxBool (FaxClient::*store)(fxStr&, fxStr&), fxStr& docname, fxStr& emsg)
+ bool (FaxClient::*store)(fxStr&, fxStr&), fxStr& docname, fxStr& emsg)
{
z_stream zstream;
zstream.zalloc = NULL;
munmap(addr, sb.st_size);
#endif
deflateEnd(&zstream);
- return (getReply(FALSE) == COMPLETE);
+ return (getReply(false) == COMPLETE);
bad2:
- (void) getReply(FALSE);
+ (void) getReply(false);
/* fall thru... */
bad:
closeDataConn();
} else
emsg = fxStr::format("Can not initialize compression library: %s",
zstream.msg);
- return (FALSE);
+ return (false);
}
/*
* listing (LIST), trigger event trace log (SITE TRIGGER)
* or other data connection-based transfer.
*/
-fxBool
-FaxClient::recvData(fxBool (*f)(void*, const char*, int, fxStr&),
+bool
+FaxClient::recvData(bool (*f)(void*, const char*, int, fxStr&),
void* arg, fxStr& emsg, u_long restart, const char* fmt, ...)
{
if (!setMode(MODE_S))
int cc = read(fdData, buf, sizeof (buf));
if (cc == 0) {
closeDataConn();
- return (getReply(FALSE) == COMPLETE);
+ return (getReply(false) == COMPLETE);
}
if (cc < 0) {
emsg = fxStr::format("Data Connection: %s", strerror(errno));
- (void) getReply(FALSE);
+ (void) getReply(false);
break;
}
byte_count += cc;
}
bad:
closeDataConn();
- return (FALSE);
+ return (false);
}
/*
* listing (LIST), trigger event trace log (SITE TRIGGER)
* or other data connection-based transfer.
*/
-fxBool
-FaxClient::recvZData(fxBool (*f)(void*, const char*, int, fxStr&),
+bool
+FaxClient::recvZData(bool (*f)(void*, const char*, int, fxStr&),
void* arg, fxStr& emsg, u_long restart, const char* fmt, ...)
{
z_stream zstream;
goto bad;
closeDataConn();
(void) inflateEnd(&zstream);
- return (getReply(FALSE) == COMPLETE);
+ return (getReply(false) == COMPLETE);
}
if (cc < 0) {
emsg = fxStr::format("Data Connection: %s", strerror(errno));
- (void) getReply(FALSE);
+ (void) getReply(false);
goto bad;
}
zstream.next_in = (Bytef*) buf;
inflateEnd(&zstream);
} else
emsg = fxStr::format("Can not initialize decoder: %s", zstream.msg);
- return (FALSE);
+ return (false);
}
/*
* Set the specified status format string
* in the client and the server.
*/
-fxBool
+bool
FaxClient::setStatusFormat(const char* cmd, u_int flag,
fxStr& fmt, const char* value)
{
if (isLoggedIn()) {
if (command("%s \"%s\"", cmd, value) != COMPLETE) {
printError("%s", (const char*) lastResponse);
- return (FALSE);
+ return (false);
}
state &= ~flag;
} else
state |= flag;
fmt = value;
- return (TRUE);
+ return (true);
}
/*
* Set the job status format string in the
* client and the server.
*/
-fxBool
+bool
FaxClient::setJobStatusFormat(const char* cp)
{
return setStatusFormat("JOBFMT", FS_JFMTPEND, jobFmt, cp);
* Set the receive queue status format
* string in the client and the server.
*/
-fxBool
+bool
FaxClient::setRecvStatusFormat(const char* cp)
{
return setStatusFormat("RCVFMT", FS_RFMTPEND, recvFmt, cp);
* Set the modem status format
* string in the client and the server.
*/
-fxBool
+bool
FaxClient::setModemStatusFormat(const char* cp)
{
return setStatusFormat("MDMFMT", FS_MFMTPEND, modemFmt, cp);
* Set the file status format
* string in the client and the server.
*/
-fxBool
+bool
FaxClient::setFileStatusFormat(const char* cp)
{
return setStatusFormat("FILEFMT", FS_FFMTPEND, fileFmt, cp);
void init(void);
- fxBool sendRawData(void* buf, int cc, fxStr& emsg);
- fxBool setCommon(const FaxParam&, u_int);
+ bool sendRawData(void* buf, int cc, fxStr& emsg);
+ bool setCommon(const FaxParam&, u_int);
protected:
FaxClient();
FaxClient(const fxStr& hostarg);
virtual void vtraceServer(const char* fmt, va_list ap);
void initServerState(void);
- fxBool jobOp(const char* op, const char* jobid);
- fxBool extract(u_int& pos, const char* pattern, fxStr& result,
+ bool jobOp(const char* op, const char* jobid);
+ bool extract(u_int& pos, const char* pattern, fxStr& result,
const char* cmd, fxStr& emsg);
- fxBool storeUnique(const char* cmd, fxStr& docname, fxStr& emsg);
+ bool storeUnique(const char* cmd, fxStr& docname, fxStr& emsg);
const fxStr& getStatusFormat(u_int flag, const char* cmd, fxStr& fmt);
- fxBool setStatusFormat(const char* cmd, u_int flag, fxStr&, const char*);
+ bool setStatusFormat(const char* cmd, u_int flag, fxStr&, const char*);
void makeHeader(const char* fmt, const FaxFmtHeader fmts[], fxStr& header);
- virtual fxBool setupUserIdentity(fxStr& emsg);
+ virtual bool setupUserIdentity(fxStr& emsg);
void setupHostModem(const char*);
void setupHostModem(const fxStr&);
virtual void resetConfig(void);
virtual void setupConfig(void);
- virtual fxBool setConfigItem(const char* tag, const char* value);
+ virtual bool setConfigItem(const char* tag, const char* value);
virtual void configError(const char* fmt ...);
virtual void configTrace(const char* fmt ...);
void setModem(const char*);
const fxStr& getModem(void) const;
- virtual fxBool callServer(fxStr& emsg);
- virtual fxBool hangupServer(void);
- fxBool isConnected(void) const;
- fxBool login(const char* user, fxStr& emsg);
- fxBool admin(const char* pass, fxStr& emsg);
+ virtual bool callServer(fxStr& emsg);
+ virtual bool hangupServer(void);
+ bool isConnected(void) const;
+ bool login(const char* user, fxStr& emsg);
+ bool admin(const char* pass, fxStr& emsg);
virtual const char* getPasswd(const char* prompt);
- fxBool isLoggedIn(void) const;
+ bool isLoggedIn(void) const;
void setCtrlFds(int in, int out);
FILE* getCtrlFd(void) const;
- virtual fxBool initDataConn(fxStr& emsg);
- virtual fxBool openDataConn(fxStr& emsg);
+ virtual bool initDataConn(fxStr& emsg);
+ virtual bool openDataConn(fxStr& emsg);
virtual void closeDataConn(void);
- virtual fxBool abortDataConn(fxStr& emsg);
+ virtual bool abortDataConn(fxStr& emsg);
void setDataFd(int fd);
int getDataFd(void) const;
- void setVerbose(fxBool);
- fxBool getVerbose(void) const;
+ void setVerbose(bool);
+ bool getVerbose(void) const;
int getPort(void) const;
const fxStr& getProtoName(void) const;
// output
int command(const char* fmt ...);
int vcommand(const char* fmt, va_list ap);
- int getReply(fxBool expectEOF);
+ int getReply(bool expectEOF);
const fxStr& getLastResponse(void) const;
int getLastCode(void) const;
/*
* Job control support.
*/
const fxStr& getCurrentJob(void) const;
- fxBool setCurrentJob(const char* jobid);
- fxBool newJob(fxStr& jobid, fxStr& groupid, fxStr& emsg);
- fxBool jobSubmit(const char* jobid);
- fxBool jobSuspend(const char* jobid);
- fxBool jobKill(const char* jobid);
- fxBool jobDelete(const char* jobid);
- fxBool jobWait(const char* jobid);
+ bool setCurrentJob(const char* jobid);
+ bool newJob(fxStr& jobid, fxStr& groupid, fxStr& emsg);
+ bool jobSubmit(const char* jobid);
+ bool jobSuspend(const char* jobid);
+ bool jobKill(const char* jobid);
+ bool jobDelete(const char* jobid);
+ bool jobWait(const char* jobid);
/*
* Set various job parameters.
*/
- fxBool jobParm(const char* name, const fxStr& value);
- fxBool jobParm(const char* name, const char* value);
- fxBool jobParm(const char* name, fxBool b);
- fxBool jobParm(const char* name, u_int v);
- fxBool jobParm(const char* name, float v);
- fxBool jobSendTime(const struct tm tm);
- fxBool jobLastTime(u_long);
- fxBool jobRetryTime(u_long);
- fxBool jobCover(const char* docname);
- fxBool jobDocument(const char* docname);
- fxBool jobPollRequest(const char* sep, const char* pwd);
+ bool jobParm(const char* name, const fxStr& value);
+ bool jobParm(const char* name, const char* value);
+ bool jobParm(const char* name, bool b);
+ bool jobParm(const char* name, u_int v);
+ bool jobParm(const char* name, float v);
+ bool jobSendTime(const struct tm tm);
+ bool jobLastTime(u_long);
+ bool jobRetryTime(u_long);
+ bool jobCover(const char* docname);
+ bool jobDocument(const char* docname);
+ bool jobPollRequest(const char* sep, const char* pwd);
/*
* Job group control support.
*/
- fxBool jgrpSubmit(const char* jgrpid);
- fxBool jgrpSuspend(const char* jgrpid);
- fxBool jgrpKill(const char* jgrpid);
- fxBool jgrpWait(const char* jgrpid);
+ bool jgrpSubmit(const char* jgrpid);
+ bool jgrpSuspend(const char* jgrpid);
+ bool jgrpKill(const char* jgrpid);
+ bool jgrpWait(const char* jgrpid);
/*
* Query/set transfer state parameters.
*/
u_int getType(void) const;
- fxBool setType(u_int);
+ bool setType(u_int);
u_int getMode(void) const;
- fxBool setMode(u_int);
+ bool setMode(u_int);
u_int getStruct(void) const;
- fxBool setStruct(u_int);
+ bool setStruct(u_int);
u_int getFormat(void) const;
- fxBool setFormat(u_int);
+ bool setFormat(u_int);
u_int getTimeZone(void) const;
- fxBool setTimeZone(u_int);
+ bool setTimeZone(u_int);
/*
* Send documents to the server.
*/
- fxBool storeUnique(fxStr& docname, fxStr& emsg); // STOU
- fxBool storeTemp(fxStr& docname, fxStr& emsg); // STOT
- fxBool storeFile(fxStr&, fxStr& emsg); // STOR
- fxBool sendData(int fd, fxBool (FaxClient::*store)(fxStr&, fxStr&),
+ bool storeUnique(fxStr& docname, fxStr& emsg); // STOU
+ bool storeTemp(fxStr& docname, fxStr& emsg); // STOT
+ bool storeFile(fxStr&, fxStr& emsg); // STOR
+ bool sendData(int fd, bool (FaxClient::*store)(fxStr&, fxStr&),
fxStr& docname, fxStr& emsg);
- fxBool sendZData(int fd, fxBool (FaxClient::*store)(fxStr&, fxStr&),
+ bool sendZData(int fd, bool (FaxClient::*store)(fxStr&, fxStr&),
fxStr& docname, fxStr& emsg);
/*
* Retrieve information from the server.
*/
- fxBool recvData(fxBool (*f)(void*, const char*, int, fxStr&),
+ bool recvData(bool (*f)(void*, const char*, int, fxStr&),
void* arg, fxStr& emsg, u_long restart, const char* fmt, ...);
- fxBool recvZData(fxBool (*f)(void*, const char*, int, fxStr&),
+ bool recvZData(bool (*f)(void*, const char*, int, fxStr&),
void* arg, fxStr& emsg, u_long restart, const char* fmt, ...);
/*
* Job scripting support.
*/
- fxBool runScript(const char* filename, fxStr& emsg);
- fxBool runScript(FILE*, const char* filename, fxStr& emsg);
- fxBool runScript(const char* script, u_long scriptLen,
+ bool runScript(const char* filename, fxStr& emsg);
+ bool runScript(FILE*, const char* filename, fxStr& emsg);
+ bool runScript(const char* script, u_long scriptLen,
const char* filename, fxStr& emsg);
/*
* Status query support.
static const FaxFmtHeader modemFormats[];
static const FaxFmtHeader fileFormats[];
- fxBool setJobStatusFormat(const char*);
+ bool setJobStatusFormat(const char*);
const fxStr& getJobStatusFormat(void);
- fxBool setRecvStatusFormat(const char*);
+ bool setRecvStatusFormat(const char*);
const fxStr& getRecvStatusFormat(void);
- fxBool setModemStatusFormat(const char*);
+ bool setModemStatusFormat(const char*);
const fxStr& getModemStatusFormat(void);
- fxBool setFileStatusFormat(const char*);
+ bool setFileStatusFormat(const char*);
const fxStr& getFileStatusFormat(void);
void getJobStatusHeader(fxStr& header);
void getRecvStatusHeader(fxStr& header);
inline const fxStr& FaxClient::getHost(void) const { return host; }
inline const fxStr& FaxClient::getModem(void) const { return modem; }
inline const fxStr& FaxClient::getProtoName() const { return proto; }
-inline fxBool FaxClient::getVerbose(void) const
+inline bool FaxClient::getVerbose(void) const
{ return (state&FS_VERBOSE) != 0; }
inline int FaxClient::getPort(void) const { return port; }
inline FILE* FaxClient::getCtrlFd(void) const { return fdOut; }
inline const fxStr& FaxClient::getLastResponse(void) const
{ return lastResponse; }
inline int FaxClient::getLastCode(void) const { return code; }
-inline fxBool FaxClient::isLoggedIn(void) const
+inline bool FaxClient::isLoggedIn(void) const
{ return (state&FS_LOGGEDIN) != 0; }
-inline fxBool FaxClient::isConnected(void) const { return fdIn != NULL; }
+inline bool FaxClient::isConnected(void) const { return fdIn != NULL; }
inline u_int FaxClient::getType(void) const { return type; }
inline u_int FaxClient::getStruct(void) const { return stru; }
inline u_int FaxClient::getMode(void) const { return mode; }
}
void FaxConfig::resetConfig() { lineno = 0; }
-fxBool
+bool
FaxConfig::updateConfig(const fxStr& filename)
{
struct stat sb;
resetConfig();
readConfig(path);
lastModTime = sb.st_mtime;
- return (TRUE);
+ return (true);
} else
- return (FALSE);
+ return (false);
}
/*
return (path);
}
-fxBool
+bool
FaxConfig::findTag(const char* tag, const void* names0, u_int n, u_int& ix)
{
const tags* names = (const tags*) names0;
const char* cp = names[i].name;
if (cp[0] == tag[0] && streq(cp, tag)) {
ix = i;
- return (TRUE);
+ return (true);
}
}
- return (FALSE);
+ return (false);
}
-fxBool
+bool
FaxConfig::findValue(const char* value, const char* values[], u_int n, u_int& ix)
{
for (u_int i = 0; i < n; i++) {
const char* cp = values[i];
if (cp[0] == value[0] && streq(cp, value)) {
ix = i;
- return (TRUE);
+ return (true);
}
}
- return (FALSE);
+ return (false);
}
int
#define valeq(a,b) (strcasecmp(a,b)==0)
-fxBool
+bool
FaxConfig::getBoolean(const char* cp)
{
return (valeq(cp, "on") || valeq(cp, "yes") || valeq(cp, "true"));
}
-fxBool
+bool
FaxConfig::readConfigItem(const char* b)
{
char buf[2048];
for (cp = buf; isspace(*cp); cp++) // skip leading white space
;
if (*cp == '#' || *cp == '\0')
- return (TRUE);
+ return (true);
const char* tag = cp; // start of tag
while (*cp && *cp != ':') { // skip to demarcating ':'
if (isupper(*cp))
if (*cp != ':') {
configError("Syntax error at line %u, missing ':' in \"%s\"",
lineno, b);
- return (FALSE);
+ return (false);
}
for (*cp++ = '\0'; isspace(*cp); cp++) // skip white space again
;
if (c == '\0') { // unmatched quote mark
configError("Syntax error at line %u, missing quote mark in \"%s\"",
lineno, b);
- return (FALSE);
+ return (false);
}
if (c == '\\') {
c = *++cp;
if (!setConfigItem(tag, value)) {
configTrace("Unknown configuration parameter \"%s\" ignored at line %u",
tag, lineno);
- return (FALSE);
+ return (false);
} else {
configTrace("%s = %s (line %u)", tag, value, lineno);
- return (TRUE);
+ return (true);
}
}
FaxConfig();
FaxConfig(const FaxConfig& other);
- virtual fxBool setConfigItem(const char* tag, const char* value) = 0;
+ virtual bool setConfigItem(const char* tag, const char* value) = 0;
virtual void configError(const char* fmt, ...) = 0;
virtual void configTrace(const char* fmt, ...) = 0;
u_int getConfigLineNumber() const;
} tags;
// NB: const void* should be const tags* but gcc can't hack it
- static fxBool findTag(const char*, const void*, u_int, u_int&);
- static fxBool findValue(const char*, const char*[], u_int, u_int&);
+ static bool findTag(const char*, const void*, u_int, u_int&);
+ static bool findValue(const char*, const char*[], u_int, u_int&);
static int getNumber(const char*);
- static fxBool getBoolean(const char*);
+ static bool getBoolean(const char*);
fxStr tildeExpand(const fxStr& filename);
virtual void readConfig(const fxStr& filename);
- virtual fxBool readConfigItem(const char*);
+ virtual bool readConfigItem(const char*);
virtual void resetConfig();
- virtual fxBool updateConfig(const fxStr& filename);
+ virtual bool updateConfig(const fxStr& filename);
};
inline u_int FaxConfig::getConfigLineNumber() const { return lineno; }
#endif /* _FaxConfig_ */
#include "StackBuffer.h"
#include <ctype.h>
-fxBool
+bool
FaxDB::getToken(FILE* fd, fxStr& token)
{
int c;
top:
if ((c = getc(fd)) == EOF)
- return (FALSE);
+ return (false);
while (isspace(c)) {
if (c == '\n')
lineno++;
while ((c = getc(fd)) != EOF && c != '\n')
;
if (c == EOF)
- return (FALSE);
+ return (false);
lineno++;
goto top;
}
buf[0] = c;
buf[1] = '\0';
token = buf;
- return (TRUE);
+ return (true);
}
fxStackBuffer buf;
if (c == '"') {
c = getc(fd);
if (c == EOF) {
fprintf(stderr, "%s: Premature EOF.\n", (char*) filename);
- return (FALSE);
+ return (false);
}
// XXX handle standard escapes
if (c == '\n')
}
buf.set('\0');
token = (char*) buf;
- return (TRUE);
+ return (true);
}
#ifdef notdef
FaxInfoDict dict; // name->record map
void parseDatabase(FILE*, FaxDBRecord* parent);
- fxBool getToken(FILE*, fxStr& token);
+ bool getToken(FILE*, fxStr& token);
public:
FaxDB(const fxStr& filename);
~FaxDB();
);
}
-fxBool
+bool
FaxRecvInfo::decode(const char* cp)
{
char* np;
time = (u_int) strtoul(cp, &np, 16);
if (np == cp)
- return (FALSE);
+ return (false);
npages = (u_short) strtoul(cp = np+1, &np, 16);
if (np == cp)
- return (FALSE);
+ return (false);
params.decode((u_int) strtoul(cp = np+1, &np, 16));
if (np == cp)
- return (FALSE);
+ return (false);
qfile = np+1;
qfile.resize(qfile.next(0,','));
cp = strchr(np+1, ',');
if (cp == NULL)
- return (FALSE);
+ return (false);
commid = cp+1;
commid.resize(commid.next(0,','));
cp = strchr(cp+1, '"');
if (cp == NULL)
- return (FALSE);
+ return (false);
sender = cp+1;
sender.resize(sender.next(0,'"'));
cp = strchr(cp+1, '"');
if (cp == NULL || cp[1] != ',' || cp[2] != '"')
- return (FALSE);
+ return (false);
subaddr = cp+1;
subaddr.resize(subaddr.next(0,'"'));
cp = strchr(cp+1, '"');
if (cp == NULL || cp[1] != ',' || cp[2] != '"')
- return (FALSE);
+ return (false);
reason = cp+3; // +1 for "/+1 for ,/+1 for "
reason.resize(reason.next(0,'"'));
- return (TRUE);
+ return (true);
}
~FaxRecvInfo();
fxStr encode() const;
- fxBool decode(const char*);
+ bool decode(const char*);
};
#endif /* _FaxRecvInfo_ */
);
}
-fxBool
+bool
FaxSendInfo::decode(const char* cp)
{
char* np;
time = (u_int) strtoul(cp, &np, 16);
if (np == cp)
- return (FALSE);
+ return (false);
npages = (u_short) strtoul(cp = np+1, &np, 16);
if (np == cp)
- return (FALSE);
+ return (false);
params.decode((u_int) strtoul(cp = np+1, &np, 16));
if (np == cp)
- return (FALSE);
+ return (false);
commid = np+1;
commid.resize(commid.next(0,','));
np = strchr(np+1, '"');
if (np == NULL)
- return (FALSE);
+ return (false);
qfile = np+1; // +1 for "
qfile.resize(qfile.next(0,'"'));
- return (TRUE);
+ return (true);
}
~FaxSendInfo();
fxStr encode() const;
- fxBool decode(const char*);
+ bool decode(const char*);
};
#endif /* _FaxSendInfo_ */
InetTransport::InetTransport(FaxClient& c) : Transport(c) {}
InetTransport::~InetTransport(){}
-fxBool
+bool
InetTransport::isA(const char*)
{
- return (TRUE); // XXX are there checks we can make?
+ return (true); // XXX are there checks we can make?
}
#if CONFIG_INETTRANSPORT
#include <ctype.h>
#include <errno.h>
-fxBool
+bool
InetTransport::callServer(fxStr& emsg)
{
int port = client.getPort();
struct hostent* hp = Socket::gethostbyname(client.getHost());
if (!hp) {
emsg = client.getHost() | ": Unknown host";
- return (FALSE);
+ return (false);
}
int fd = socket(hp->h_addrtype, SOCK_STREAM, protocol);
if (fd < 0) {
emsg = "Can not create socket to connect to server.";
- return (FALSE);
+ return (false);
}
struct sockaddr_in sin;
memset(&sin, 0, sizeof (sin));
* input and output (sigh).
*/
client.setCtrlFds(fd, dup(fd));
- return (TRUE);
+ return (true);
}
}
emsg = fxStr::format("Can not reach server at host \"%s\", port %u.",
(const char*) client.getHost(), ntohs(sin.sin_port));
Sys::close(fd), fd = -1;
- return (FALSE);
+ return (false);
}
-fxBool
+bool
InetTransport::initDataConn(fxStr& emsg)
{
struct sockaddr_in data_addr;
socklen_t dlen = sizeof (data_addr);
if (Socket::getsockname(fileno(client.getCtrlFd()), &data_addr, &dlen) < 0) {
emsg = fxStr::format("getsockname(ctrl): %s", strerror(errno));
- return (FALSE);
+ return (false);
}
data_addr.sin_port = 0; // let system allocate port
int fd = socket(AF_INET, SOCK_STREAM, 0);
if (fd < 0) {
emsg = fxStr::format("socket: %s", strerror(errno));
- return (FALSE);
+ return (false);
}
if (Socket::bind(fd, &data_addr, sizeof (data_addr)) < 0) {
emsg = fxStr::format("bind: %s", strerror(errno));
if (client.command("PORT %u,%u,%u,%u,%u,%u",
UC(a[0]), UC(a[1]), UC(a[2]), UC(a[3]),
UC(p[0]), UC(p[1])) != FaxClient::COMPLETE)
- return (FALSE);
+ return (false);
#undef UC
client.setDataFd(fd);
- return (TRUE);
+ return (true);
bad:
Sys::close(fd), fd = -1;
- return (FALSE);
+ return (false);
}
-fxBool
+bool
InetTransport::openDataConn(fxStr& emsg)
{
int s = Socket::accept(client.getDataFd(), NULL, NULL);
if (Socket::setsockopt(s, IPPROTO_IP, IP_TOS, &tos, sizeof (tos)) < 0)
client.printWarning("setsockopt(IP_TOS): %s", strerror(errno));
#endif
- return (TRUE);
+ return (true);
} else {
emsg = fxStr::format("accept: %s", strerror(errno));
- return (FALSE);
+ return (false);
}
}
* rather than before as done by most contemporary
* TCP implementations.
*/
-fxBool
+bool
InetTransport::abortCmd(fxStr& emsg)
{
static const char msg[] =
int s = fileno(client.getCtrlFd());
if (send(s, msg, 3, MSG_OOB) != 3) {
emsg = fxStr::format("send(MSG_OOB): %s", strerror(errno));
- return (FALSE);
+ return (false);
}
if (send(s, msg+3, sizeof (msg)-3, 0) != sizeof (msg)-3) {
emsg = fxStr::format("send(<DM>ABOR\\r\\n): %s", strerror(errno));
- return (FALSE);
+ return (false);
}
- return (TRUE);
+ return (true);
}
#else
-fxBool InetTransport::callServer(fxStr& emsg)
- { notConfigured("TCP/IP", emsg); return (FALSE); }
-fxBool InetTransport::initDataConn(fxStr& emsg)
- { notConfigured("TCP/IP", emsg); return (FALSE); }
-fxBool InetTransport::openDataConn(fxStr& emsg)
- { notConfigured("TCP/IP", emsg); return (FALSE); }
-fxBool InetTransport::abortDataConn(fxStr& emsg)
- { notConfigured("TCP/IP", emsg); return (FALSE); }
+bool InetTransport::callServer(fxStr& emsg)
+ { notConfigured("TCP/IP", emsg); return (false); }
+bool InetTransport::initDataConn(fxStr& emsg)
+ { notConfigured("TCP/IP", emsg); return (false); }
+bool InetTransport::openDataConn(fxStr& emsg)
+ { notConfigured("TCP/IP", emsg); return (false); }
+bool InetTransport::abortDataConn(fxStr& emsg)
+ { notConfigured("TCP/IP", emsg); return (false); }
#endif
InetTransport(FaxClient&);
~InetTransport();
- static fxBool isA(const char*);
+ static bool isA(const char*);
- fxBool callServer(fxStr& emsg);
- fxBool abortCmd(fxStr& emsg);
+ bool callServer(fxStr& emsg);
+ bool abortCmd(fxStr& emsg);
- fxBool initDataConn(fxStr& emsg);
- fxBool openDataConn(fxStr& emsg);
+ bool initDataConn(fxStr& emsg);
+ bool openDataConn(fxStr& emsg);
};
#endif /* _InetTransport_ */
fxStr number; // modem phone number
fxStr commid; // communication identifier
char state; // modem state
- fxBool canpoll; // modem is capable of polling
+ bool canpoll; // modem is capable of polling
u_short priority; // scheduling priority
Class2Params caps; // modem capabilities
va_end(ap);
}
-fxBool
+bool
PageSizeInfo::skipws(char*& cp,
const char* file, const char* item, u_int lineno)
{
if (*cp == '\0') {
parseError(file, lineno,
"Unexpected end of line after \"%s\".\n", item);
- return (FALSE);
+ return (false);
} else
- return (TRUE);
+ return (true);
}
PageInfoArray*
pi.info = &(*PageSizeInfo::pageInfo)[i];
return (pi);
}
-fxBool PageSizeInfoIter::notDone()
+bool PageSizeInfoIter::notDone()
{ return i < PageSizeInfo::pageInfo->length(); }
static const PageInfo* getPageInfoByName(const char* name);
static PageInfoArray* readPageInfoFile();
- static fxBool skipws(char*& cp,
+ static bool skipws(char*& cp,
const char* file, const char* item, u_int lineno);
static float toMM(BMU v) { return (v/1200.)*25.4; }
void operator++();
void operator++(int);
operator const PageSizeInfo&();
- fxBool notDone();
+ bool notDone();
};
#else
/*
}
}
-fxBool
+bool
RegEx::Find(const char* text, u_int length, u_int off)
{
if (compResult == 0) {
const char* pattern() const;
- fxBool Find(const char* text, u_int length, u_int off = 0);
- fxBool Find(const fxStr& s, u_int off = 0);
+ bool Find(const char* text, u_int length, u_int off = 0);
+ bool Find(const fxStr& s, u_int off = 0);
int StartOfMatch(u_int subexp = 0) const;
int EndOfMatch(u_int subexp = 0) const;
void init(int flags);
};
-inline fxBool RegEx::Find(const fxStr& s, u_int off)
+inline bool RegEx::Find(const fxStr& s, u_int off)
{ return Find(s, s.length(), off); }
inline const char* RegEx::pattern() const { return _pattern; }
inline int RegEx::getErrorCode() const { return execResult; }
void SNPPClient::setModem(const char* modemarg) { modem = modemarg; }
void
-SNPPClient::setVerbose(fxBool v)
+SNPPClient::setVerbose(bool v)
{
if (v)
state |= SS_VERBOSE;
/*
* Setup the sender's identity.
*/
-fxBool
+bool
SNPPClient::setupSenderIdentity(fxStr& emsg)
{
setupUserIdentity(emsg); // client identity
fxStr mbox;
if (senderName == "" || !getNonBlankMailbox(mbox)) {
emsg = "Malformed (null) sender name or mail address";
- return (FALSE);
+ return (false);
} else
- return (TRUE);
+ return (true);
}
void SNPPClient::setFromIdentity(const char* s) { from = s; }
* Return the first non-null mailbox string
* in the set of jobs.
*/
-fxBool
+bool
SNPPClient::getNonBlankMailbox(fxStr& s)
{
for (u_int i = 0, n = jobs->length(); i < n; i++) {
SNPPJob& job = (*jobs)[i];
if (job.getMailbox() != "") {
s = job.getMailbox();
- return (TRUE);
+ return (true);
}
}
- return (FALSE);
+ return (false);
}
-fxBool
+bool
SNPPClient::setupUserIdentity(fxStr& emsg)
{
struct passwd* pwd = NULL;
emsg = fxStr::format(
"Can not locate your password entry (account name %s, uid %lu).",
(name ? name : "<unspecified>"), (u_long) getuid());
- return (FALSE);
+ return (false);
}
userName = pwd->pw_name;
if (pwd->pw_gecos && pwd->pw_gecos[0] != '\0') {
if (senderName.length() == 0) {
emsg = "Bad (null) user name; your password file entry"
" probably has bogus GECOS field information.";
- return (FALSE);
+ return (false);
} else
- return (TRUE);
+ return (true);
}
void
}
}
-fxBool
+bool
SNPPClient::setConfigItem(const char* tag, const char* value)
{
u_int ix;
} else if (streq(tag, "mailaddr")) {
jproto.setMailbox(value);
} else
- return (FALSE);
- return (TRUE);
+ return (false);
+ return (true);
}
-fxBool
+bool
SNPPClient::callServer(fxStr& emsg)
{
if (host.length() == 0) { // if host not specified by -h
* Transport code is expected to call back through
* setCtrlFds so fdIn should be properly setup...
*/
- return (fdIn != NULL && getReply(FALSE) == COMPLETE);
+ return (fdIn != NULL && getReply(false) == COMPLETE);
} else
- return (FALSE);
+ return (false);
}
#if CONFIG_INETTRANSPORT
#include <netdb.h>
}
-fxBool
+bool
SNPPClient::callInetServer(fxStr& emsg)
{
fxStr proto(getProtoName());
struct hostent* hp = Socket::gethostbyname(getHost());
if (!hp) {
emsg = getHost() | ": Unknown host";
- return (FALSE);
+ return (false);
}
int protocol;
const char* cproto = proto; // XXX for busted include files
int fd = socket(hp->h_addrtype, SOCK_STREAM, protocol);
if (fd < 0) {
emsg = "Can not create socket to connect to server.";
- return (FALSE);
+ return (false);
}
struct sockaddr_in sin;
memset(&sin, 0, sizeof (sin));
strerror(errno));
#endif
setCtrlFds(fd, fd);
- return (TRUE);
+ return (true);
}
}
emsg = fxStr::format("Can not reach server at host \"%s\", port %u.",
(const char*) getHost(), ntohs(sin.sin_port));
close(fd), fd = -1;
- return (FALSE);
+ return (false);
}
#else
-fxBool
+bool
SNPPServer::callInetServer(fxStr& emsg)
{
emsg = "Sorry, no TCP/IP communication support was configured.";
- return (FALSE);
+ return (false);
}
#endif
-fxBool
+bool
SNPPClient::hangupServer(void)
{
if (fdIn != NULL)
if (fdOut != NULL)
fclose(fdOut), fdOut = NULL;
initServerState();
- return (TRUE);
+ return (true);
}
void
/*
* Do login procedure.
*/
-fxBool
+bool
SNPPClient::login(const char* user, fxStr& emsg)
{
if (user == NULL) {
state |= SS_HASSITE;
else
state &= ~SS_HASSITE;
- return (TRUE);
+ return (true);
} else {
emsg = "Login failed: " | lastResponse;
- return (FALSE);
+ return (false);
}
}
* handled but not collected.
*/
int
-SNPPClient::getReply(fxBool expecteof)
+SNPPClient::getReply(bool expecteof)
{
int firstCode = 0;
- fxBool continuation = FALSE;
+ bool continuation = false;
do {
lastResponse.resize(0);
int c;
if (lastResponse[3] == '-') { // continuation line
if (firstCode == 0) // first line of reponse
firstCode = code;
- continuation = TRUE;
+ continuation = true;
} else if (code == firstCode) // end of continued reply
- continuation = FALSE;
+ continuation = false;
}
} while (continuation || code == 0);
* case was). The resulting string is checked to
* make sure that it is not null.
*/
-fxBool
+bool
SNPPClient::extract(u_int& pos, const char* pattern, fxStr& result)
{
fxStr pat(pattern);
l = lastResponse.find(pos, pat);
}
if (l == lastResponse.length())
- return (FALSE);
+ return (false);
l = lastResponse.skip(l+pat.length(), ' ');// skip white space
result = lastResponse.extract(l, lastResponse.next(l, ' ')-l);
if (result == "")
- return (FALSE);
+ return (false);
pos = l; // update position
- return (TRUE);
+ return (true);
}
/*
* parsed from the reply (this is for HylaFAX,
* RFC 1861 says nothing about this).
*/
-fxBool
+bool
SNPPClient::newPage(const fxStr& pin, const fxStr& passwd, fxStr& jobid, fxStr& emsg)
{
int result;
jobid.resize(jobid.skip(0, "0123456789"));
} else
jobid = "unknown";
- return (TRUE);
+ return (true);
} else
unexpectedResponse(emsg);
} else
emsg = lastResponse;
- return (FALSE);
+ return (false);
}
SNPPJob&
jobs->remove(ix);
}
-fxBool
+bool
SNPPClient::prepareForJobSubmissions(fxStr&)
{
// XXX nothing to do right now
- return (TRUE);
+ return (true);
}
-fxBool
+bool
SNPPClient::submitJobs(fxStr& emsg)
{
if (!isLoggedIn()) {
emsg = "Not logged in to server";
- return (FALSE);
+ return (false);
}
/*
* Construct jobs and submit them.
for (u_int i = 0, n = jobs->length(); i < n; i++) {
SNPPJob& job = (*jobs)[i];
if (!job.createJob(*this, emsg))
- return (FALSE);
+ return (false);
notifyNewJob(job); // notify client
}
if (msgFile != "") {
if (!sendData(msgFile, emsg))
- return (FALSE);
+ return (false);
} else if (msg) {
if (!sendMsg(*msg, emsg))
- return (FALSE);
+ return (false);
}
if (command("SEND") != COMPLETE) {
emsg = lastResponse;
- return (FALSE);
+ return (false);
} else
- return (TRUE);
+ return (true);
}
/*
* Send a block of raw data on the data
* conenction, interpreting write errors.
*/
-fxBool
+bool
SNPPClient::sendRawData(void* buf, int cc, fxStr& emsg)
{
#ifdef __linux__
protocolBotch(emsg, errno == EPIPE ?
" (server closed connection)" : " (server write error: %s).",
strerror(errno));
- return (FALSE);
+ return (false);
}
#else
if (write(fileno(fdOut), buf, cc) != cc) {
protocolBotch(emsg, errno == EPIPE ?
" (server closed connection)" : " (server write error: %s).",
strerror(errno));
- return (FALSE);
+ return (false);
}
#endif
- return (TRUE);
+ return (true);
}
-fxBool
+bool
SNPPClient::sendData(int fd, fxStr& emsg)
{
struct stat sb;
size_t n = fxmin(cc, sizeof (buf));
if (read(fd, buf, n) != n) {
protocolBotch(emsg, " (data read: %s).", strerror(errno));
- return (FALSE);
+ return (false);
}
if (!sendRawData(buf, n, emsg))
- return (FALSE);
+ return (false);
cc -= n;
}
if (command(".") == COMPLETE)
- return (TRUE);
+ return (true);
}
emsg = getLastResponse();
- return (FALSE);
+ return (false);
}
-fxBool
+bool
SNPPClient::sendData(const fxStr& filename, fxStr& emsg)
{
- fxBool ok = FALSE;
+ bool ok = false;
int fd = Sys::open(filename, O_RDONLY);
if (fd >= 0) {
ok = sendData(fd, emsg);
return (ok);
}
-fxBool
+bool
SNPPClient::sendMsg(const char* msg, fxStr& emsg)
{
if (command("MESS %s", msg) != COMPLETE) {
emsg = getLastResponse();
- return (FALSE);
+ return (false);
} else
- return (TRUE);
+ return (true);
}
-fxBool
+bool
SNPPClient::siteParm(const char* name, const fxStr& value)
{
if (!hasSiteCmd()) {
printWarning("no SITE %s support; ignoring set request.", name);
- return (TRUE);
+ return (true);
} else
return (command("SITE %s %s", name, (const char*) value) == COMPLETE);
}
-fxBool
+bool
SNPPClient::siteParm(const char* name, u_int value)
{
if (!hasSiteCmd()) {
printWarning("no SITE %s support; ignoring set request.", name);
- return (TRUE);
+ return (true);
} else
return (command("SITE %s %u", name, value) == COMPLETE);
}
-fxBool
+bool
SNPPClient::setHoldTime(u_int t)
{
time_t tv = t;
, tm->tm_min) == COMPLETE);
}
-fxBool
+bool
SNPPClient::setRetryTime(u_int t)
{
return siteParm("RETRYTIME", fxStr::format("%02d%02d", t/60, t%60));
static const S_numbertag numbers[];
void init(void);
- fxBool callInetServer(fxStr& emsg);
+ bool callInetServer(fxStr& emsg);
protected:
SNPPClient();
SNPPClient(const fxStr& hostarg);
virtual void notifyNewJob(const SNPPJob& job);
void initServerState(void);
- fxBool extract(u_int& pos, const char* pattern, fxStr& result);
+ bool extract(u_int& pos, const char* pattern, fxStr& result);
- virtual fxBool setupUserIdentity(fxStr& emsg);
+ virtual bool setupUserIdentity(fxStr& emsg);
void setupHostModem(const char*);
void setupHostModem(const fxStr&);
* Miscellaneous stuff used by setupSenderIdentity.
*/
void setBlankMailboxes(const fxStr&);
- fxBool getNonBlankMailbox(fxStr&);
+ bool getNonBlankMailbox(fxStr&);
/*
* Configuration file support; derived classes may override
*/
virtual void resetConfig(void);
virtual void setupConfig(void);
- virtual fxBool setConfigItem(const char* tag, const char* value);
+ virtual bool setConfigItem(const char* tag, const char* value);
virtual void configError(const char* fmt ...);
virtual void configTrace(const char* fmt ...);
- fxBool sendRawData(void* buf, int cc, fxStr& emsg);
+ bool sendRawData(void* buf, int cc, fxStr& emsg);
void unexpectedResponse(fxStr& emsg);
void protocolBotch(fxStr& emsg, const char* fmt ...);
virtual void lostServer(void);
public:
virtual ~SNPPClient();
// prepare jobs for submission
- virtual fxBool prepareForJobSubmissions(fxStr& emsg);
- virtual fxBool submitJobs(fxStr& emsg); // submit documents & jobs
+ virtual bool prepareForJobSubmissions(fxStr& emsg);
+ virtual bool submitJobs(fxStr& emsg); // submit documents & jobs
/*
* Sender identity controls. There are two separate
* is used by proxy services such as email to pager gateways
* and for folks that submit jobs for other people.
*/
- fxBool setupSenderIdentity(fxStr& emsg); // identity associated with job
+ bool setupSenderIdentity(fxStr& emsg); // identity associated with job
const fxStr& getSenderName() const;
void setFromIdentity(const char*); // identity associated with page
const fxStr& getFromIdentity() const;
void setModem(const char*);
const fxStr& getModem(void) const;
- virtual fxBool callServer(fxStr& emsg);
- virtual fxBool hangupServer(void);
- fxBool isConnected(void) const;
- fxBool login(const char* user, fxStr& emsg);
+ virtual bool callServer(fxStr& emsg);
+ virtual bool hangupServer(void);
+ bool isConnected(void) const;
+ bool login(const char* user, fxStr& emsg);
virtual const char* getPasswd(const char* prompt);
- fxBool isLoggedIn(void) const;
+ bool isLoggedIn(void) const;
void setCtrlFds(int in, int out);
FILE* getCtrlFd(void) const;
- void setVerbose(fxBool);
- fxBool getVerbose(void) const;
+ void setVerbose(bool);
+ bool getVerbose(void) const;
- fxBool hasSiteCmd(void) const; // server has SITE cmd support
+ bool hasSiteCmd(void) const; // server has SITE cmd support
int getPort(void) const;
const fxStr& getProtoName(void) const;
// output
int command(const char* fmt ...);
int vcommand(const char* fmt, va_list ap);
- int getReply(fxBool expectEOF);
+ int getReply(bool expectEOF);
const fxStr& getLastResponse(void) const;
int getLastCode(void) const;
SNPPJob& getProtoJob();
- fxBool setHoldTime(u_int t);
- fxBool setRetryTime(u_int t);
- fxBool siteParm(const char* name, const fxStr& v);
- fxBool siteParm(const char* name, u_int v);
- fxBool newPage(const fxStr& pin, const fxStr& passwd,
+ bool setHoldTime(u_int t);
+ bool setRetryTime(u_int t);
+ bool siteParm(const char* name, const fxStr& v);
+ bool siteParm(const char* name, u_int v);
+ bool newPage(const fxStr& pin, const fxStr& passwd,
fxStr& jobid, fxStr& emsg);
- fxBool sendData(int fd, fxStr& emsg);
- fxBool sendData(const fxStr& filename, fxStr& emsg);
- fxBool sendMsg(const char* msg, fxStr& emsg);
+ bool sendData(int fd, fxStr& emsg);
+ bool sendData(const fxStr& filename, fxStr& emsg);
+ bool sendMsg(const char* msg, fxStr& emsg);
void printError(const char* fmt ...);
void printWarning(const char* fmt ...);
inline const fxStr& SNPPClient::getHost(void) const { return host; }
inline const fxStr& SNPPClient::getModem(void) const { return modem; }
inline const fxStr& SNPPClient::getProtoName() const { return proto; }
-inline fxBool SNPPClient::getVerbose(void) const
+inline bool SNPPClient::getVerbose(void) const
{ return (state&SS_VERBOSE) != 0; }
inline int SNPPClient::getPort(void) const { return port; }
inline FILE* SNPPClient::getCtrlFd(void) const { return fdOut; }
inline const fxStr& SNPPClient::getLastResponse(void) const
{ return lastResponse; }
inline int SNPPClient::getLastCode(void) const { return code; }
-inline fxBool SNPPClient::isLoggedIn(void) const
+inline bool SNPPClient::isLoggedIn(void) const
{ return (state&SS_LOGGEDIN) != 0; }
-inline fxBool SNPPClient::isConnected(void) const { return fdIn != NULL; }
-inline fxBool SNPPClient::hasSiteCmd(void) const
+inline bool SNPPClient::isConnected(void) const { return fdIn != NULL; }
+inline bool SNPPClient::hasSiteCmd(void) const
{ return (state&SS_HASSITE) != 0 ; }
inline SNPPJob& SNPPClient::getProtoJob() { return jproto; }
inline const fxStr* SNPPClient::getPagerMsg() const { return msg; }
#define valeq(a,b) (strcasecmp(a,b)==0)
#define valneq(a,b,n) (strncasecmp(a,b,n)==0)
-fxBool
+bool
SNPPJob::setNotification(const char* v0)
{
const char* v = v0;
else if (valeq(v, "default"))
setNotification(SNPP_DEFNOTIFY);
else
- return (FALSE);
- return (TRUE);
+ return (false);
+ return (true);
}
void SNPPJob::setNotification(PageNotify n) { notify = n; }
/*
extern int
parseAtSyntax(const char* s, const struct tm& ref, struct tm& at0, fxStr& emsg);
-fxBool
+bool
SNPPJob::setHoldTime(const char* s, fxStr& emsg)
{
struct tm tts;
time_t now = Sys::now();
if (!parseAtSyntax(s, *localtime(&now), tts, emsg)) {
emsg.insert(fxStr::format("%s: ", s));
- return (FALSE);
+ return (false);
} else {
setHoldTime((u_int) mktime(&tts));
- return (TRUE);
+ return (true);
}
}
void SNPPJob::setHoldTime(u_int v) { holdTime = v; }
void SNPPJob::setMaxDials(u_int n) { maxDials = n; }
void SNPPJob::setPIN(const char* s) { pin = s; }
void SNPPJob::setPassword(const char* s) { passwd = s; }
-void SNPPJob::setQueued(fxBool v) { queued = v; }
+void SNPPJob::setQueued(bool v) { queued = v; }
void SNPPJob::setSubject(const char* s) { subject = s; }
void SNPPJob::setServiceLevel(u_int n) { serviceLevel = n; }
#define CHECKPARM(a,b) CHECK(client.siteParm(a,b))
#define IFPARM(a,b,v) { if ((b) != (v)) CHECKPARM(a,b) }
-fxBool
+bool
SNPPJob::createJob(SNPPClient& client, fxStr& emsg)
{
if (holdTime != 0 && !client.setHoldTime((u_int) holdTime))
return (client.newPage(pin, passwd, jobid, emsg));
failure:
emsg = client.getLastResponse();
- return (FALSE);
+ return (false);
}
#undef IFPARM
#undef CHECKPARM
u_int maxRetries; // max number times to try send
u_int maxDials; // max number times to dial telephone
u_int serviceLevel; // delivery service type
- fxBool queued; // queued delivery
+ bool queued; // queued delivery
u_int parseTime(const char* v);
public:
SNPPJob(const SNPPJob& other);
virtual ~SNPPJob();
- virtual fxBool createJob(SNPPClient& client, fxStr& emsg);
+ virtual bool createJob(SNPPClient& client, fxStr& emsg);
const fxStr& getJobID(void) const;
/*
* Job notification.
*/
- fxBool setNotification(const char*);// email notification
+ bool setNotification(const char*);// email notification
void setNotification(PageNotify);
PageNotify getNotification() const;
void setMailbox(const char*); // email notification address
/*
* Job scheduling controls.
*/
- void setQueued(fxBool); // queued or synchronous wait
- fxBool getQueued() const;
+ void setQueued(bool); // queued or synchronous wait
+ bool getQueued() const;
void setRetryTime(u_int); // job retry time (seconds)
void setRetryTime(const char* v);
u_int getRetryTime() const;
// time to initiate tranmission
- fxBool setHoldTime(const char*, fxStr& emsg);
+ bool setHoldTime(const char*, fxStr& emsg);
void setHoldTime(u_int);
u_int getHoldTime() const;
void setMaxTries(u_int); // maximum attempts to send
inline u_int SNPPJob::getMaxDials() const { return maxDials; }
inline const fxStr& SNPPJob::getPIN() const { return pin; }
inline const fxStr& SNPPJob::getPasswd() const { return passwd; }
-inline fxBool SNPPJob::getQueued() const { return queued; }
+inline bool SNPPJob::getQueued() const { return queued; }
inline const fxStr& SNPPJob::getSubject(void) const { return subject; }
inline u_int SNPPJob::getServiceLevel() const { return serviceLevel; }
#endif /* _SNPPJob_ */
dialRules = NULL;
files = new FileInfoArray;
polls = new PollRequestArray;
- setup = FALSE;
+ setup = false;
setupConfig();
}
void SendFaxClient::vtraceServer(const char* fmt, va_list ap)
{ FaxClient::vtraceServer(fmt, ap); }
-fxBool
+bool
SendFaxClient::prepareForJobSubmissions(fxStr& emsg)
{
if (senderName == "" && !setupSenderIdentity(from, emsg))
- return (FALSE);
+ return (false);
/*
* Prepare documents for transmission.
*/
typeRules = TypeRules::read(typeRulesFile);
if (!typeRules) {
emsg = "Unable to setup file typing and conversion rules";
- return (FALSE);
+ return (false);
}
}
typeRules->setVerbose(verbose);
* confused by this that the message has been removed so I no
* longer have to explain why it's not a problem.
*/
- (void) dialRules->parse(FALSE);
+ (void) dialRules->parse(false);
} else
dialRules->setVerbose(verbose);
/*
continue;
if (!job.setPageSize(job.getPageSize())) {
emsg = "Unknown page size " | job.getPageSize();
- return (FALSE);
+ return (false);
}
}
/*
totalPages = 0;
for (i = 0, n = files->length(); i < n; i++)
if (!prepareFile((*files)[i], emsg))
- return (FALSE);
+ return (false);
/*
* Prepare cover pages.
*/
if (job.getAutoCoverPage() && getNumberOfFiles() > 0) {
fxStr file;
if (!makeCoverPage(job, file, emsg))
- return (FALSE);
- job.setCoverPageFile(file, TRUE);
+ return (false);
+ job.setCoverPageFile(file, true);
}
}
- return (setup = TRUE);
+ return (setup = true);
}
static fxStr
/*
* Invoke the cover page generation program.
*/
-fxBool
+bool
SendFaxClient::makeCoverPage(const SendFaxJob& job, fxStr& file, fxStr& emsg)
{
tmpFile = _PATH_TMP "/sndfaxXXXXXX";
int status;
if (Sys::waitpid(pid, status) == pid && status == 0) {
file = tmpFile;
- return (TRUE);
+ return (true);
}
emsg = fxStr::format("Error creating cover sheet; "
"command was \"%s\"; exit status %x"
emsg = fxStr::format("%s: Can not create temporary file for cover page",
(const char*) tmpFile);
Sys::unlink(tmpFile);
- return (FALSE);
+ return (false);
}
SendFaxJob&
u_int ix = jobs->length();
jobs->resize(ix+1);
(*jobs)[ix] = proto;
- setup = FALSE;
+ setup = false;
return ((*jobs)[ix]);
}
u_int SendFaxClient::getNumberOfJobs() const { return jobs->length(); }
u_int ix = files->length();
files->resize(ix+1);
(*files)[ix].name = filename;
- setup = FALSE;
+ setup = false;
return (ix);
}
polls->resize(ix+1);
(*polls)[ix].sep = sep;
(*polls)[ix].pwd = pwd;
- setup = FALSE;
+ setup = false;
return (ix);
}
u_int SendFaxClient::getNumberOfPollRequests() const { return polls->length(); }
/*
* Submit documents and jobs to the server.
*/
-fxBool
+bool
SendFaxClient::submitJobs(fxStr& emsg)
{
if (!setup) {
emsg = "Documents not prepared";
- return (FALSE);
+ return (false);
}
if (!isLoggedIn()) {
emsg = "Not logged in to server";
- return (FALSE);
+ return (false);
}
/*
* Transfer documents to the server.
*/
if (!sendDocuments(emsg))
- return (FALSE);
+ return (false);
/*
* Construct jobs and submit them.
*/
for (u_int i = 0, n = jobs->length(); i < n; i++) {
SendFaxJob& job = (*jobs)[i];
if (!job.createJob(*this, emsg))
- return (FALSE);
+ return (false);
if (!jobSubmit(job.getJobID())) {
emsg = getLastResponse();
- return (FALSE);
+ return (false);
}
notifyNewJob(job); // notify client
}
- return (TRUE);
+ return (true);
}
/*
* Transfer the document files to the server and
* record the serve-side documents for job submission.
*/
-fxBool
+bool
SendFaxClient::sendDocuments(fxStr& emsg)
{
emsg = "";
if (fd < 0) {
emsg = fxStr::format(info.temp | ": Can not open: %s",
strerror(errno));
- return (FALSE); // XXX
+ return (false); // XXX
}
- fxBool fileSent;
+ bool fileSent;
if (info.rule->getResult() == TypeRule::TIFF) {
fileSent = setFormat(FORM_TIFF)
&& setType(TYPE_I)
if (!fileSent) {
if (emsg == "")
emsg = "Document transfer failed: " | getLastResponse();
- return (FALSE);
+ return (false);
}
}
- return (TRUE);
+ return (true);
}
/*
{
for (int i = N(strings)-1; i >= 0; i--)
(*this).*strings[i].p = (strings[i].def ? strings[i].def : "");
- verbose = FALSE;
+ verbose = false;
delete typeRules, typeRules = NULL;
delete dialRules, dialRules = NULL;
setupConfig();
}
-fxBool
+bool
SendFaxClient::setConfigItem(const char* tag, const char* value)
{
u_int ix;
} else if (proto.setConfigItem(tag, value)) {
;
} else if (!FaxClient::setConfigItem(tag, value))
- return (FALSE);
- return (TRUE);
+ return (false);
+ return (true);
}
#undef N
/*
* Setup the sender's identity.
*/
-fxBool
+bool
SendFaxClient::setupSenderIdentity(const fxStr& from, fxStr& emsg)
{
FaxClient::setupUserIdentity(emsg); // client identity
fxStr mbox;
if (senderName == "" || !getNonBlankMailbox(mbox)) {
emsg = "Malformed (null) sender name or mail address";
- return (FALSE);
+ return (false);
} else
- return (TRUE);
+ return (true);
}
void SendFaxClient::setFromIdentity(const char* s) { from = s; }
* Return the first non-null mailbox string
* in the set of jobs.
*/
-fxBool
+bool
SendFaxClient::getNonBlankMailbox(fxStr& s)
{
for (u_int i = 0, n = jobs->length(); i < n; i++) {
SendFaxJob& job = (*jobs)[i];
if (job.getMailbox() != "") {
s = job.getMailbox();
- return (TRUE);
+ return (true);
}
}
- return (FALSE);
+ return (false);
}
/*
* Process a file submitted for transmission.
*/
-fxBool
+bool
SendFaxClient::prepareFile(FileInfo& info, fxStr& emsg)
{
info.rule = fileType(info.name, emsg);
if (!info.rule)
- return (FALSE);
+ return (false);
if (info.temp != "" && info.temp != info.name)
Sys::unlink(info.temp);
if (info.rule->getCmd() != "") { // conversion required
Sys::unlink(tmpFile);
emsg = fxStr::format("Error converting data; command was \"%s\"",
(const char*) sysCmd);
- return (FALSE);
+ return (false);
}
info.temp = tmpFile;
} else // already postscript or tiff
estimatePostScriptPages(info.temp);
break;
}
- return (TRUE);
+ return (true);
}
/*
DialStringRules* dialRules; // dial string conversion database
FileInfoArray* files; // files to send (possibly converted)
PollRequestArray* polls; // polling requests
- fxBool verbose; // enable debugging information
- fxBool setup; // if true, then ready to send
+ bool verbose; // enable debugging information
+ bool setup; // if true, then ready to send
fxStr tmpFile; // stuff to cleanup on abort
fxStr from; // command line from information
fxStr senderName; // sender's full name
* Derived classes can override makeCoverPage to supply an
* application-specific cover page generation scheme.
*/
- virtual fxBool makeCoverPage(const SendFaxJob&, fxStr& file, fxStr& emsg);
+ virtual bool makeCoverPage(const SendFaxJob&, fxStr& file, fxStr& emsg);
/*
* These methods are used to count/estimate the number
* of pages in a document that is to be transmitted.
*/
virtual void setupConfig();
virtual void resetConfig();
- virtual fxBool setConfigItem(const char* tag, const char* value);
+ virtual bool setConfigItem(const char* tag, const char* value);
/*
* File typerule support.
*/
const TypeRule* fileType(const char* filename, fxStr& emsg);
- fxBool prepareFile(FileInfo& info, fxStr& emsg);
+ bool prepareFile(FileInfo& info, fxStr& emsg);
/*
* Miscellaneous stuff used by setupSenderIdentity.
*/
void setBlankMailboxes(const fxStr&);
- fxBool getNonBlankMailbox(fxStr&);
+ bool getNonBlankMailbox(fxStr&);
public:
virtual ~SendFaxClient();
// prepare jobs for submission
- virtual fxBool prepareForJobSubmissions(fxStr& emsg);
+ virtual bool prepareForJobSubmissions(fxStr& emsg);
void purgeFileConversions(void); // purge any converted docs
- virtual fxBool submitJobs(fxStr& emsg); // submit documents & jobs
- virtual fxBool sendDocuments(fxStr& emsg); // send prepared documents
+ virtual bool submitJobs(fxStr& emsg); // submit documents & jobs
+ virtual bool sendDocuments(fxStr& emsg); // send prepared documents
/*
* Job manipulation interfaces.
* and for folks people that submit jobs for other people.
*/
// identity associated with job
- fxBool setupSenderIdentity(const fxStr&, fxStr& emsg);
+ bool setupSenderIdentity(const fxStr&, fxStr& emsg);
const fxStr& getSenderName() const;
void setFromIdentity(const char*); // identity associated with fax
const fxStr& getFromIdentity() const;
- fxBool getVerbose() const; // trace operation
- void setVerbose(fxBool);
+ bool getVerbose() const; // trace operation
+ void setVerbose(bool);
};
inline SendFaxJob& SendFaxClient::getProtoJob() { return proto; }
inline const fxStr& SendFaxClient::getFromIdentity() const { return from; }
inline const fxStr& SendFaxClient::getSenderName() const { return senderName;}
-inline void SendFaxClient::setVerbose(fxBool b) { verbose = b; }
-inline fxBool SendFaxClient::getVerbose() const { return verbose; }
+inline void SendFaxClient::setVerbose(bool b) { verbose = b; }
+inline bool SendFaxClient::getVerbose() const { return verbose; }
#endif /* _SendFaxClient_ */
for (i = N(floats)-1; i >= 0; i--)
(*this).*floats[i].p = floats[i].def;
- autoCover = TRUE;
- sendTagLine = FALSE; // default is to use server config
+ autoCover = true;
+ sendTagLine = false; // default is to use server config
notify = FAX_DEFNOTIFY; // default notification
mailbox = "";
priority = FAX_DEFPRIORITY; // default transmit priority
pagechop = chop_default;
}
-fxBool
+bool
SendFaxJob::setConfigItem(const char* tag, const char* value)
{
u_int ix;
if (FaxConfig::findTag(tag, (const FaxConfig::tags*) strings, N(strings), ix)) {
(*this).*strings[ix].p = value;
switch (ix) {
- case 0: sendTagLine = TRUE; break;
+ case 0: sendTagLine = true; break;
}
} else if (FaxConfig::findTag(tag, (const FaxConfig::tags*) numbers, N(numbers), ix)) {
(*this).*numbers[ix].p = atoi(value);
else if (streq(tag, "pagechop"))
setChopHandling(value);
else
- return (FALSE);
- return (TRUE);
+ return (false);
+ return (true);
}
#undef N
#define valeq(a,b) (strcasecmp(a,b)==0)
#define valneq(a,b,n) (strncasecmp(a,b,n)==0)
-fxBool
+bool
SendFaxJob::setNotification(const char* v0)
{
const char* v = v0;
else if (valeq(v, "default"))
notify = FAX_DEFNOTIFY;
else
- return (FALSE);
- return (TRUE);
+ return (false);
+ return (true);
}
void SendFaxJob::setNotification(FaxNotify n) { notify = n; }
/*
void SendFaxJob::setPassword(const char* s) { passwd = s; }
void SendFaxJob::setExternalNumber(const char* s) { external = s; }
-void SendFaxJob::setAutoCoverPage(fxBool b) { autoCover = b; }
+void SendFaxJob::setAutoCoverPage(bool b) { autoCover = b; }
void
-SendFaxJob::setCoverPageFile(const char* s, fxBool removeOnExit)
+SendFaxJob::setCoverPageFile(const char* s, bool removeOnExit)
{
if (coverFile != "" && removeOnExit)
Sys::unlink(coverFile);
void SendFaxJob::setCoverRegarding(const char* s) { regarding = s; }
void SendFaxJob::setCoverVoiceNumber(const char* s) { voicenumber = s; }
-fxBool
+bool
SendFaxJob::setPageSize(const char* name)
{
PageSizeInfo* info = PageSizeInfo::getPageSizeByName(name);
pageLength = info->height();
pageSize = name;
delete info;
- return (TRUE);
+ return (true);
} else
- return (FALSE);
+ return (false);
}
void SendFaxJob::setVResolution(float r) { vres = r; }
void SendFaxJob::setHResolution(float r) { hres = r; }
desiredst = atoi(v);
}
void SendFaxJob::setDesiredMST(int v) { desiredst = v; }
-void SendFaxJob::setDesiredEC(fxBool b) { desiredec = b; }
+void SendFaxJob::setDesiredEC(bool b) { desiredec = b; }
void
SendFaxJob::setDesiredDF(const char* v)
{
SendFaxJob::setTagLineFormat(const char* v)
{
tagline = v;
- sendTagLine = TRUE;
+ sendTagLine = true;
}
void
#define CHECKPARM(a,b) CHECK(client.jobParm(a,b))
#define IFPARM(a,b,v) { if ((b) != (v)) CHECKPARM(a,b) }
-fxBool
+bool
SendFaxJob::createJob(SendFaxClient& client, fxStr& emsg)
{
if (!client.setCurrentJob("DEFAULT")) { // inherit from default
emsg = client.getLastResponse();
- return (FALSE);
+ return (false);
}
if (!client.newJob(jobid, groupid, emsg)) // create new job on server
- return (FALSE);
+ return (false);
time_t now = Sys::now();
if (sendTime != "") {
if (!parseAtSyntax(sendTime, *localtime(&now), tts, emsg)) {
emsg.insert(sendTime | ": ");
- return (FALSE);
+ return (false);
}
now = mktime(&tts);
// NB: must send time relative to GMT
struct tm when;
if (!parseAtSyntax(killTime, tts, when, emsg)) {
emsg.insert(killTime | ": ");
- return (FALSE);
+ return (false);
}
CHECK(client.jobLastTime(mktime(&when) - now))
}
IFPARM("BEGBR", desiredbr, (u_int) -1)
IFPARM("BEGST", desiredst, (u_int) -1)
if (desiredec != (u_int) -1)
- CHECKPARM("USEECM", (fxBool) desiredec)
+ CHECKPARM("USEECM", (bool) desiredec)
if (desireddf != (u_int) -1) {
CHECKPARM("DATAFORMAT",
desireddf == 0 ? "g31d" :
"g31d")
}
if (sendTagLine) {
- CHECKPARM("USETAGLINE", TRUE)
+ CHECKPARM("USETAGLINE", true)
CHECKPARM("TAGLINE", tagline)
}
CHECKPARM("NOTIFY",
if (fd < 0) {
emsg = fxStr::format("%s: Can not open: %s",
(const char*) coverFile, strerror(errno));
- return (FALSE); // XXX
+ return (false); // XXX
}
fxStr coverDoc;
- fxBool fileSent =
+ bool fileSent =
client.setFormat(FaxClient::FORM_PS)
&& client.setType(FaxClient::TYPE_I) // XXX??? TYPE_A
&& client.sendZData(fd, &FaxClient::storeTemp, coverDoc, emsg);
if (!fileSent) {
if (emsg == "")
emsg = "Document transfer failed: " | client.getLastResponse();
- return (FALSE);
+ return (false);
}
CHECK(client.jobCover(coverDoc))
}
client.getPollRequest(i, sep, pwd);
CHECK(client.jobPollRequest(sep, pwd))
}
- return (TRUE);
+ return (true);
failure:
emsg = client.getLastResponse();
- return (FALSE);
+ return (false);
}
#undef CHECKPARM
#undef IFPARM
fxStr passwd; // password (opt)
fxStr external; // displayable version of number (opt)
- fxBool autoCover; // if TRUE, auto-generate cover sheet
- fxBool coverIsTemp; // if TRUE, remove coverFile on exit
+ bool autoCover; // if true, auto-generate cover sheet
+ bool coverIsTemp; // if true, remove coverFile on exit
fxStr coverFile; // cover page file
fxStr coverTemplate; // cover page template file
fxStr name; // receipient for cover page
fxStr comments; // comments for cover page
fxStr regarding; // regarding info for cover page
- fxBool sendTagLine; // if TRUE, use custom tagline format
+ bool sendTagLine; // if true, use custom tagline format
fxStr killTime; // job's time to be killed
fxStr sendTime; // job's time to be sent
u_int retryTime; // retry time for failures (secs)
SendFaxJob(const SendFaxJob& other);
virtual ~SendFaxJob();
- virtual fxBool createJob(SendFaxClient& client, fxStr& emsg);
+ virtual bool createJob(SendFaxClient& client, fxStr& emsg);
virtual void setupConfig();
- virtual fxBool setConfigItem(const char* tag, const char* value);
+ virtual bool setConfigItem(const char* tag, const char* value);
const fxStr& getJobID(void) const;
const fxStr& getGroupID(void) const;
/*
* Job notification.
*/
- fxBool setNotification(const char*);// email notification
+ bool setNotification(const char*);// email notification
void setNotification(FaxNotify);
FaxNotify getNotification() const;
void setMailbox(const char*); // email notification address
* suppressed or an application-specified file can be
* specified instead.
*/
- void setAutoCoverPage(fxBool); // auto-generate cover page
- fxBool getAutoCoverPage() const;
+ void setAutoCoverPage(bool); // auto-generate cover page
+ bool getAutoCoverPage() const;
// cover page file
- void setCoverPageFile(const char*, fxBool removeOnExit);
+ void setCoverPageFile(const char*, bool removeOnExit);
const fxStr& getCoverPageFile() const;
void setCoverTemplate(const char*); // cover page template file
const fxStr& getCoverTemplate() const;
float getPageWidth() const; // sending page width (mm)
float getPageLength() const; // sending page length (mm)
const fxStr& getPageSize() const; // page size by name
- fxBool setPageSize(const char* name);
+ bool setPageSize(const char* name);
void setVResolution(float); // vertical resolution (lines/inch)
float getVResolution() const;
void setHResolution(float); // horizontal resolution (lines/inch)
void setDesiredMST(int); // desired/initial min-scanline time
void setDesiredMST(const char* v);
int getDesiredMST() const;
- void setDesiredEC(fxBool b); // desired use of Error Correction mode
- fxBool getDesiredEC() const;
+ void setDesiredEC(bool b); // desired use of Error Correction mode
+ bool getDesiredEC() const;
void setDesiredDF(int); // desired data format
void setDesiredDF(const char*);
int getDesiredDF() const;
inline const fxStr& SendFaxJob::getSubAddress() const { return subaddr; }
inline const fxStr& SendFaxJob::getPasswd() const { return passwd; }
inline const fxStr& SendFaxJob::getExternalNumber() const{ return external; }
-inline fxBool SendFaxJob::getAutoCoverPage() const { return autoCover; }
+inline bool SendFaxJob::getAutoCoverPage() const { return autoCover; }
inline const fxStr& SendFaxJob::getCoverPageFile() const{ return coverFile; }
inline const fxStr& SendFaxJob::getCoverTemplate() const{ return coverTemplate;}
inline const fxStr& SendFaxJob::getCoverName() const { return name; }
inline int SendFaxJob::getMinSpeed() const { return minsp; }
inline int SendFaxJob::getDesiredSpeed() const { return desiredbr; }
inline int SendFaxJob::getDesiredMST() const { return desiredst; }
-inline fxBool SendFaxJob::getDesiredEC() const { return desiredec; }
+inline bool SendFaxJob::getDesiredEC() const { return desiredec; }
inline int SendFaxJob::getDesiredDF() const { return desireddf; }
inline const fxStr& SendFaxJob::getTagLineFormat() const{ return tagline; }
inline u_int SendFaxJob::getChopHandling() const { return pagechop; }
}
-void fxStr::resize(u_int chars, fxBool)
+void fxStr::resize(u_int chars, bool)
{
resizeInternal(chars);
if (chars != 0) {
data[slength-1] = 0;
}
-fxBool operator==(const fxStr& a,const fxStr& b)
+bool operator==(const fxStr& a,const fxStr& b)
{
return (a.slength == b.slength) && (memcmp(a.data,b.data,a.slength) == 0);
}
-fxBool operator==(const fxStr& a,const char* b)
+bool operator==(const fxStr& a,const char* b)
{
return (a.slength == strlen(b)+1) && (memcmp(a.data,b,a.slength) == 0);
}
-fxBool operator==(const char* b, const fxStr& a)
+bool operator==(const char* b, const fxStr& a)
{
return (a.slength == strlen(b)+1) && (memcmp(a.data,b,a.slength) == 0);
}
-fxBool operator!=(const fxStr& a,const fxStr& b)
+bool operator!=(const fxStr& a,const fxStr& b)
{
return (a.slength != b.slength) || (memcmp(a.data,b.data,a.slength) != 0);
}
-fxBool operator!=(const fxStr& a,const char* b)
+bool operator!=(const fxStr& a,const char* b)
{
return (a.slength != strlen(b)+1) || (memcmp(a.data,b,a.slength) != 0);
}
-fxBool operator!=(const char* b, const fxStr& a)
+bool operator!=(const char* b, const fxStr& a)
{
return (a.slength != strlen(b)+1) || (memcmp(a.data,b,a.slength) != 0);
}
-fxBool operator>=(const fxStr& a,const fxStr& b)
+bool operator>=(const fxStr& a,const fxStr& b)
{
return strcmp(a,b) >= 0;
}
-fxBool operator>=(const fxStr& a,const char* b)
+bool operator>=(const fxStr& a,const char* b)
{
return strcmp(a,b) >= 0;
}
-fxBool operator>=(const char* a, const fxStr& b)
+bool operator>=(const char* a, const fxStr& b)
{
return strcmp(a,b) >= 0;
}
-fxBool operator>(const fxStr& a,const fxStr& b)
+bool operator>(const fxStr& a,const fxStr& b)
{
return strcmp(a,b) > 0;
}
-fxBool operator>(const fxStr& a,const char* b)
+bool operator>(const fxStr& a,const char* b)
{
return strcmp(a,b) > 0;
}
-fxBool operator>(const char* a, const fxStr& b)
+bool operator>(const char* a, const fxStr& b)
{
return strcmp(a,b) > 0;
}
-fxBool operator<=(const fxStr& a,const fxStr& b)
+bool operator<=(const fxStr& a,const fxStr& b)
{
return strcmp(a,b) <= 0;
}
-fxBool operator<=(const fxStr& a,const char* b)
+bool operator<=(const fxStr& a,const char* b)
{
return strcmp(a,b) <= 0;
}
-fxBool operator<=(const char* a, const fxStr& b)
+bool operator<=(const char* a, const fxStr& b)
{
return strcmp(a,b) <= 0;
}
-fxBool operator<(const fxStr& a,const fxStr& b)
+bool operator<(const fxStr& a,const fxStr& b)
{
return strcmp(a,b) < 0;
}
-fxBool operator<(const fxStr& a,const char* b)
+bool operator<(const fxStr& a,const char* b)
{
return strcmp(a,b) < 0;
}
-fxBool operator<(const char* a, const fxStr& b)
+bool operator<(const char* a, const fxStr& b)
{
return strcmp(a,b) < 0;
}
/////////////////////////////////////////////////////
// Comparison
- friend fxBool operator==(fxStr const&, fxStr const&);
- friend fxBool operator==(fxStr const&, char const*);
- friend fxBool operator==(char const*, fxStr const&);
+ friend bool operator==(fxStr const&, fxStr const&);
+ friend bool operator==(fxStr const&, char const*);
+ friend bool operator==(char const*, fxStr const&);
- friend fxBool operator!=(fxStr const&, fxStr const&);
- friend fxBool operator!=(fxStr const&, char const*);
- friend fxBool operator!=(char const*, fxStr const&);
+ friend bool operator!=(fxStr const&, fxStr const&);
+ friend bool operator!=(fxStr const&, char const*);
+ friend bool operator!=(char const*, fxStr const&);
- friend fxBool operator>=(fxStr const&, fxStr const&);
- friend fxBool operator>=(fxStr const&, char const*);
- friend fxBool operator>=(char const*, fxStr const&);
+ friend bool operator>=(fxStr const&, fxStr const&);
+ friend bool operator>=(fxStr const&, char const*);
+ friend bool operator>=(char const*, fxStr const&);
- friend fxBool operator<=(fxStr const&, fxStr const&);
- friend fxBool operator<=(fxStr const&, char const*);
- friend fxBool operator<=(char const*, fxStr const&);
+ friend bool operator<=(fxStr const&, fxStr const&);
+ friend bool operator<=(fxStr const&, char const*);
+ friend bool operator<=(char const*, fxStr const&);
- friend fxBool operator>(fxStr const&, fxStr const&);
- friend fxBool operator>(fxStr const&, char const*);
- friend fxBool operator>(char const*, fxStr const&);
+ friend bool operator>(fxStr const&, fxStr const&);
+ friend bool operator>(fxStr const&, char const*);
+ friend bool operator>(char const*, fxStr const&);
- friend fxBool operator<(fxStr const&, fxStr const&);
- friend fxBool operator<(fxStr const&, char const*);
- friend fxBool operator<(char const*, fxStr const&);
+ friend bool operator<(fxStr const&, fxStr const&);
+ friend bool operator<(fxStr const&, char const*);
+ friend bool operator<(char const*, fxStr const&);
int compare(fxStr const *a) const { return ::compare(*this, *a); }
friend int compare(fxStr const&, fxStr const&);
void remove(u_int posn,u_int len=1);
- void resize(u_int len, fxBool reallocate = FALSE);
+ void resize(u_int len, bool reallocate = false);
void setMaxLength(u_int maxlen);
void append(char a);
* Wrapper functions for C library calls.
*/
-fxBool
+bool
Sys::isRegularFile(const char* filename)
{
struct stat sb;
return (Sys::stat(filename, sb) >= 0 && (sb.st_mode&S_IFMT) == S_IFREG);
}
-fxBool
+bool
Sys::isSocketFile(const char* filename)
{
#ifdef S_IFSOCK
struct stat sb;
return (Sys::stat(filename, sb) >= 0 && (sb.st_mode&S_IFMT) == S_IFSOCK);
#else
- return (FALSE);
+ return (false);
#endif
}
-fxBool
+bool
Sys::isFIFOFile(const char* filename)
{
struct stat sb;
return (Sys::stat(filename, sb) >= 0 && (sb.st_mode&S_IFMT) == S_IFIFO);
}
-fxBool
+bool
Sys::isFIFOFile(int fd)
{
struct stat sb;
return (Sys::fstat(fd, sb) >= 0 && (sb.st_mode&S_IFMT) == S_IFIFO);
}
-fxBool
+bool
Sys::isCharSpecialFile(const char* filename, struct stat& sb)
{
#ifdef S_IFCHR
return (Sys::stat(filename, sb) >= 0 && (sb.st_mode&S_IFMT) == S_IFCHR);
#else
- return (FALSE);
+ return (false);
#endif
}
-fxBool
+bool
Sys::isCharSpecialFile(const char* filename)
{
struct stat sb;
{ return ::stat(file, &sb); }
static int fstat(int fd, struct stat& sb)
{ return ::fstat(fd, &sb); }
- static fxBool isRegularFile(const char* filename);
- static fxBool isFIFOFile(const char* filename);
- static fxBool isSocketFile(const char* filename);
- static fxBool isFIFOFile(int fd);
- static fxBool isCharSpecialFile(const char* filename);
- static fxBool isCharSpecialFile(const char* filename, struct stat&);
+ static bool isRegularFile(const char* filename);
+ static bool isFIFOFile(const char* filename);
+ static bool isSocketFile(const char* filename);
+ static bool isFIFOFile(int fd);
+ static bool isCharSpecialFile(const char* filename);
+ static bool isCharSpecialFile(const char* filename, struct stat&);
static int link(const char* file1, const char* file2)
{ return ::link(file1, file2); }
static int rename(const char* file1, const char* file2)
firstPageNum = 1; // starting page number
column = 1; // current text column # (1..numcol)
pageNum = 1; // current page number
- workStarted = FALSE;
+ workStarted = false;
fonts = new FontDict;
curFont = addFont("Roman", "Courier");
void TextFmt::setOutputFile(FILE* f) { output = f; }
void TextFmt::setNumberOfColumns(u_int n) { numcol = n; }
-void TextFmt::setPageHeaders(fxBool b) { headers = b; }
-void TextFmt::setISO8859(fxBool b) { useISO8859 = b; }
-void TextFmt::setLineWrapping(fxBool b) { wrapLines = b; }
+void TextFmt::setPageHeaders(bool b) { headers = b; }
+void TextFmt::setISO8859(bool b) { useISO8859 = b; }
+void TextFmt::setLineWrapping(bool b) { wrapLines = b; }
void TextFmt::setOutlineMargin(TextCoord o) { outline = o; }
void TextFmt::setTextPointSize(TextCoord p) { pointSize = p; }
void TextFmt::setPageOrientation(u_int o) { landscape = (o == LANDSCAPE); }
void TextFmt::setFilename(const char* cp) { curFile = cp; }
void
-TextFmt::setGaudyHeaders(fxBool b)
+TextFmt::setGaudyHeaders(bool b)
{
if (gaudy = b)
- headers = TRUE;
+ headers = true;
}
-fxBool
+bool
TextFmt::setTextFont(const char* name)
{
if (TextFont::findFont(name)) {
(*fonts)["Roman"]->family = name;
- return (TRUE);
+ return (true);
} else
- return (FALSE);
+ return (false);
}
/*
* Parse margin syntax: l=#,r=#,t=#,b=#
*/
-fxBool
+bool
TextFmt::setPageMargins(const char* s)
{
for (const char* cp = s; cp && cp[0];) {
if (cp[1] != '=')
- return (FALSE);
+ return (false);
TextCoord v = inch(&cp[2]);
switch (tolower(cp[0])) {
case 'b': bm = v; break;
case 'r': rm = v; break;
case 't': tm = v; break;
default:
- return (FALSE);
+ return (false);
}
cp = strchr(cp, ',');
if (cp)
cp++;
}
- return (TRUE);
+ return (true);
}
void
tm = t;
}
-fxBool
+bool
TextFmt::setPageSize(const char* name)
{
PageSizeInfo* info = PageSizeInfo::getPageSizeByName(name);
setPageWidth(info->width() / 25.4);
setPageHeight(info->height() / 25.4);
delete info;
- return (TRUE);
+ return (true);
} else
- return (FALSE);
+ return (false);
}
void TextFmt::setPageWidth(float pw) { physPageWidth = pw; }
*/
if (lineHeight <= 0)
lineHeight = (pointSize * 12L) / 10L;
- workStarted = TRUE;
+ workStarted = true;
}
void
tf = NULL;
emitTrailer();
fflush(output);
- workStarted = FALSE;
+ workStarted = false;
}
/* copy bytes b1..b2 to stdout */
y = pageHeight - tm - lineHeight; // y at page top
level = 0; // string paren level reset
column = 1;
- boc = TRUE;
- bop = TRUE;
+ boc = true;
+ bop = true;
}
void
y = pageHeight - tm - lineHeight; // y at page top
level = 0;
column++;
- boc = TRUE;
+ boc = true;
}
static void
TextFmt::beginLine(void)
{
if (boc)
- beginCol(), boc = FALSE, bop = FALSE;
+ beginCol(), boc = false, bop = false;
fputc('B', tf);
}
{
newPage(); // each file starts on a new page
- bol = TRUE; // force line start
- bot = TRUE; // force text start
+ bol = true; // force line start
+ bot = true; // force text start
xoff = col_width * (column-1);
}
break;
case '\f': // form feed
endTextCol();
- bol = bot = TRUE;
+ bol = bot = true;
break;
case '\n': // line break
if (bol)
break;
}
closeStrings("O\n"); // do overstriking
- bot = TRUE; // start new string
+ bot = true; // start new string
break;
default:
TextCoord hm;
endTextLine();
}
if (bol)
- beginLine(), bol = FALSE;
+ beginLine(), bol = false;
if (c == '\t') { // close open PS string and do motion
if (hm > 0) {
closeStrings("LN");
- bot = TRUE; // force new string
+ bot = true; // force new string
hrMove(hm);
}
} else { // append to open PS string
if (bot)
- beginText(), bot = FALSE;
+ beginText(), bot = false;
if (040 <= c && c <= 0176) {
if (c == '(' || c == ')' || c == '\\')
fputc('\\',tf);
break;
case '\f': // form feed
endTextCol();
- bol = bot = TRUE;
+ bol = bot = true;
break;
case '\n': // line break
if (bol)
break; // collapse \r\n => \n
cp++; // count character
closeStrings("O\n"); // do overstriking
- bot = TRUE; // start new string
+ bot = true; // start new string
break;
default:
TextCoord hm;
endTextLine();
}
if (bol)
- beginLine(), bol = FALSE;
+ beginLine(), bol = false;
if (c == '\t') { // close open PS string and do motion
if (hm > 0) {
closeStrings("LN");
fprintf(tf, " %ld M ", hm);
- bot = TRUE; // force new string
+ bot = true; // force new string
}
} else { // append to open PS string
if (bot)
- beginText(), bot = FALSE;
+ beginText(), bot = false;
if (040 <= c && c <= 0176) {
if (c == '(' || c == ')' || c == '\\')
fputc('\\',tf);
if ((y -= lineHeight) < bm)
endCol();
xoff = col_width * (column-1);
- bol = bot = TRUE;
+ bol = bot = true;
}
void
void
TextFmt::setupConfig()
{
- gaudy = FALSE; // emit gaudy headers
- landscape = FALSE; // horizontal landscape mode output
- useISO8859 = TRUE; // use the ISO 8859-1 character encoding
- reverse = FALSE; // page reversal flag
- wrapLines = TRUE; // wrap/truncate lines
- headers = TRUE; // emit page headers
+ gaudy = false; // emit gaudy headers
+ landscape = false; // horizontal landscape mode output
+ useISO8859 = true; // use the ISO 8859-1 character encoding
+ reverse = false; // page reversal flag
+ wrapLines = true; // wrap/truncate lines
+ headers = true; // emit page headers
pointSize = -1; // font point size in big points
lm = inch("0.25in"); // left margin
#undef streq
#define streq(a,b) (strcasecmp(a,b)==0)
-fxBool
+bool
TextFmt::setConfigItem(const char* tag, const char* value)
{
if (streq(tag, "columns"))
else if (streq(tag, "fontpath"))
setFontPath(value);
else
- return (FALSE);
- return (TRUE);
+ return (false);
+ return (true);
}
#define NCHARS (sizeof (widths) / sizeof (widths[0]))
}
TextFont::~TextFont() {}
-fxBool
+bool
TextFont::decodeFontName(const char* name, fxStr& filename, fxStr& emsg)
{
struct stat junk;
fpath.remove(0, index2);
if (fpath.length() > 0) fpath.remove(0, 1);
}
- fxBool result = stat(filename, &junk) ? FALSE : TRUE;
+ bool result = stat(filename, &junk) ? false : true;
if (!result)
emsg = fxStr::format(
"Warning: %s invalid Fontmap entry - no filename present", (const char*)val);
filename = path.head(index) | "/" | name | ".afm";
path.remove(0, index);
if (path.length() > 0) path.remove(0, 1);
- if (stat(filename, &junk) == 0) return TRUE;
+ if (stat(filename, &junk) == 0) return true;
filename.resize(filename.length()-4); // strip ``.afm''
- if (stat(filename, &junk) == 0) return TRUE;
+ if (stat(filename, &junk) == 0) return true;
index = path.next(0, ':');
}
- return FALSE;
+ return false;
}
-fxBool
+bool
TextFont::findFont(const char* name)
{
fxStr myname, emsg;
";
void
-TextFont::defFont(FILE* fd, TextCoord ps, fxBool useISO8859) const
+TextFont::defFont(FILE* fd, TextCoord ps, bool useISO8859) const
{
if (useISO8859) {
fprintf(fd, defISOFont, (const char*) setproc,
widths[i] = w;
}
-fxBool
+bool
TextFont::getAFMLine(FILE* fp, char* buf, int bsize)
{
if (fgets(buf, bsize, fp) == NULL)
- return (FALSE);
+ return (false);
char* cp = strchr(buf, '\n');
if (cp == NULL) { // line too long, skip it
int c;
while ((c = getc(fp)) != '\n') // skip to end of line
if (c == EOF)
- return (FALSE);
+ return (false);
cp = buf; // force line to be skipped
}
*cp = '\0';
- return (TRUE);
+ return (true);
}
FILE*
return Sys::fopen(fontpath, "r");
}
-fxBool
-TextFont::readMetrics(TextCoord ps, fxBool useISO8859, fxStr& emsg)
+bool
+TextFont::readMetrics(TextCoord ps, bool useISO8859, fxStr& emsg)
{
fxStr file;
FILE *fp = openAFMFile(file);
"%s: Can not open font metrics file; using fixed widths",
(const char*) file);
loadFixedMetrics(625*ps/1000L); // NB: use fixed width metrics
- return (FALSE);
+ return (false);
}
/*
* Since many ISO-encoded fonts don't include metrics for
* (I don't know if this does or does not cause any problem.)
*/
loadFixedMetrics(625*ps/1000L); // NB: use fixed width metrics
- return (FALSE);
+ return (false);
}
lineno++;
} while (strncmp(buf, "StartCharMetrics", 16));
emsg = fxStr::format("%s, line %u: format error",
(const char*) file, lineno);
fclose(fp);
- return (FALSE);
+ return (false);
}
if (ix == -1) // end of unencoded glyphs
break;
widths[ix] = w*ps/1000L;
}
fclose(fp);
- return (TRUE);
+ return (true);
}
void loadFixedMetrics(TextCoord w);
FILE* openAFMFile(fxStr& pathname);
- fxBool getAFMLine(FILE* fp, char* buf, int bsize);
- static fxBool decodeFontName(const char*, fxStr&, fxStr&);
+ bool getAFMLine(FILE* fp, char* buf, int bsize);
+ static bool decodeFontName(const char*, fxStr&, fxStr&);
public:
TextFont(const char*);
~TextFont();
- static fxBool findFont(const char* name);
+ static bool findFont(const char* name);
- void defFont(FILE*, TextCoord pointSize, fxBool useISO8859) const;
+ void defFont(FILE*, TextCoord pointSize, bool useISO8859) const;
void setfont(FILE*) const;
TextCoord show(FILE*, const char*, int len) const;
TextCoord show(FILE*, const fxStr&) const;
const char* getFamily(void) const;
- fxBool readMetrics(TextCoord pointsize, fxBool useISO8859, fxStr& emsg);
+ bool readMetrics(TextCoord pointsize, bool useISO8859, fxStr& emsg);
};
/*
* we have to use unsigned const char
REVERSE
};
private:
- fxBool gaudy; // emit gaudy headers
- fxBool landscape; // horizontal landscape mode output
- fxBool useISO8859; // use the ISO 8859-1 character encoding
- fxBool reverse; // page reversal flag
- fxBool wrapLines; // wrap/truncate lines
- fxBool headers; // emit page headers
- fxBool workStarted; // formatting work begun
+ bool gaudy; // emit gaudy headers
+ bool landscape; // horizontal landscape mode output
+ bool useISO8859; // use the ISO 8859-1 character encoding
+ bool reverse; // page reversal flag
+ bool wrapLines; // wrap/truncate lines
+ bool headers; // emit page headers
+ bool workStarted; // formatting work begun
FILE* output; // output file stream
FILE* tf; // temporary output file
OfftArray* pageOff; // page offset table
TextCoord lm, rm; // left, right margins in local coordinates
TextCoord tm, bm; // top, bottom margin in local coordinates
TextCoord lineHeight; // inter-line spacing
- fxBool boc; // at beginning of a column
- fxBool bop; // at beginning of a page
- fxBool bol; // at beginning of a line
- fxBool bot; // at beginning of a text string
+ bool boc; // at beginning of a column
+ bool bop; // at beginning of a page
+ bool bol; // at beginning of a line
+ bool bot; // at beginning of a text string
int numcol; // number of text columns
int column; // current text column # (1..numcol)
TextCoord col_margin; // inter-column margin
virtual void fatal(const char* fmt ...) const;
virtual void setupConfig(void);
- virtual fxBool setConfigItem(const char* tag, const char* value);
+ virtual bool setConfigItem(const char* tag, const char* value);
virtual void configError(const char* fmt ...);
virtual void configTrace(const char* fmt ...);
public:
static TextCoord inch(const char*);
void setNumberOfColumns(u_int n);
- void setPageHeaders(fxBool);
- fxBool getPageHeaders(void) const;
- void setLineWrapping(fxBool);
- fxBool getLineWrapping(void) const;
- void setISO8859(fxBool);
- fxBool getISO8859(void) const;
- fxBool setTextFont(const char* fontName);
- void setGaudyHeaders(fxBool);
- fxBool setPageMargins(const char*);
+ void setPageHeaders(bool);
+ bool getPageHeaders(void) const;
+ void setLineWrapping(bool);
+ bool getLineWrapping(void) const;
+ void setISO8859(bool);
+ bool getISO8859(void) const;
+ bool setTextFont(const char* fontName);
+ void setGaudyHeaders(bool);
+ bool setPageMargins(const char*);
void setPageMargins(TextCoord l, TextCoord r, TextCoord b, TextCoord t);
void setOutlineMargin(TextCoord);
void setTextPointSize(TextCoord);
TextCoord getTextPointSize(void) const;
void setPageOrientation(u_int);
- fxBool setPageSize(const char*);
+ bool setPageSize(const char*);
void setPageWidth(float);
void setPageHeight(float);
void setPageCollation(u_int);
void reserveVSpace(TextCoord);
};
-inline fxBool TextFmt::getLineWrapping(void) const { return wrapLines; }
-inline fxBool TextFmt::getPageHeaders(void) const { return headers; }
+inline bool TextFmt::getLineWrapping(void) const { return wrapLines; }
+inline bool TextFmt::getPageHeaders(void) const { return headers; }
inline TextCoord TextFmt::getTextPointSize(void) const { return pointSize; }
inline TextCoord TextFmt::getXOff(void) const { return xoff; }
inline TextCoord TextFmt::getRHS(void) const { return right_x; }
inline TextCoord TextFmt::getTextLineHeight(void) const { return lineHeight; }
-inline fxBool TextFmt::getISO8859(void) const { return useISO8859; }
+inline bool TextFmt::getISO8859(void) const { return useISO8859; }
inline const TextFont* TextFmt::getFont(void) const { return curFont; }
inline FILE* TextFmt::getOutputFile(void) { return tf; }
#endif /* _TextFmt_ */
#include <sys/time.h>
#include "Timeout.h"
-fxBool Timeout::timerExpired = FALSE;
+bool Timeout::timerExpired = false;
Timeout::Timeout() {}
Timeout::~Timeout() {}
void
Timeout::sigAlarm(int)
{
- Timeout::timerExpired = TRUE;
+ Timeout::timerExpired = true;
}
#ifndef SA_INTERRUPT
void
Timeout::startTimeout(long ms)
{
- timerExpired = FALSE;
+ timerExpired = false;
#ifdef SV_INTERRUPT /* BSD-style */
static struct sigvec sv;
sv.sv_handler = fxSIGVECHANDLER(Timeout::sigAlarm);
*/
class Timeout {
private:
- static fxBool timerExpired;
+ static bool timerExpired;
static void sigAlarm(int);
protected:
virtual void traceTimer(const char* fmt ...);
void startTimeout(long ms);
void stopTimeout();
- fxBool wasTimeout() const { return Timeout::timerExpired; }
+ bool wasTimeout() const { return Timeout::timerExpired; }
};
#endif /* _Timeout_ */
Transport::Transport(FaxClient& c) : client(c) {}
Transport::~Transport() {}
-fxBool Transport::hangupServer() { return (TRUE); }
+bool Transport::hangupServer() { return (true); }
void
Transport::closeDataConn(int fd)
}
}
-fxBool
+bool
Transport::abortCmd(fxStr& emsg)
{
static const char msg[] = { 'A', 'B', 'O', 'R', '\r', '\n' };
int s = fileno(client.getCtrlFd());
if (Sys::write(s, msg, sizeof (msg)) != sizeof (msg)) {
emsg = fxStr::format("send(ABOR\\r\\n): %s", strerror(errno));
- return (FALSE);
+ return (false);
}
- return (TRUE);
+ return (true);
}
void
static Transport& getTransport(FaxClient&, const char* address);
- virtual fxBool callServer(fxStr& emsg) = 0;
- virtual fxBool hangupServer(void);
- virtual fxBool abortCmd(fxStr& emsg);
+ virtual bool callServer(fxStr& emsg) = 0;
+ virtual bool hangupServer(void);
+ virtual bool abortCmd(fxStr& emsg);
- virtual fxBool initDataConn(fxStr& emsg) = 0;
- virtual fxBool openDataConn(fxStr& emsg) = 0;
+ virtual bool initDataConn(fxStr& emsg) = 0;
+ virtual bool openDataConn(fxStr& emsg) = 0;
virtual void closeDataConn(int);
};
#endif /* _Transport_ */
{ "<any>", "=", "!=", "<", "<=", ">", ">=", "&", "^", "!" };
static const char* resultNames[] = { "tiff", "postscript", "error" };
-fxBool
-TypeRule::match(const void* data, u_int size, fxBool verbose) const
+bool
+TypeRule::match(const void* data, u_int size, bool verbose) const
{
if (verbose) {
printf("rule: %soffset %#lx %s %s",
if (off > size) {
if (verbose)
printf("failed (offset past data)\n");
- return (FALSE);
+ return (false);
}
- fxBool ok = FALSE;
+ bool ok = false;
u_long v = 0;
const u_char* cp = (const u_char*) data;
switch (type) {
if (!isprint(cp[i]) && !isspace(cp[i])) {
if (verbose)
printf("failed (unprintable char %#x)\n", cp[i]);
- return (FALSE);
+ return (false);
}
- ok = TRUE;
+ ok = true;
goto done;
case STRING:
ok = (strncmp((const char*)(cp+off), value.s,
}
if (verbose)
printf("failed (insufficient data)\n");
- return (FALSE);
+ return (false);
case LONG:
if (off + 4 < size) {
memcpy(&v, cp+off, 4);
}
if (verbose)
printf("failed (insufficient data)\n");
- return (FALSE);
+ return (false);
}
/*
* Numeric value, use operation.
*/
switch (op) {
- case ANY: ok = TRUE; break;
+ case ANY: ok = true; break;
case EQ: ok = (v == value.v); break;
case NE: ok = (v != value.v); break;
case LT: ok = (v < value.v); break;
TypeRules::TypeRules()
{
- verbose = FALSE;
+ verbose = false;
rules = new TypeRuleArray;
}
}
void
-TypeRules::setVerbose(fxBool b)
+TypeRules::setVerbose(bool b)
{
verbose = b;
}
#include <ctype.h>
-static fxBool
+static bool
appendLine(fxStr& s, const char* line)
{
const char* cp = line;
if (cp[-1] == '\\') {
if (*cp == '\n') { // continue cmd string on next line
s.append(cmd, cp-1 - cmd);
- return (TRUE);
+ return (true);
} else if (*cp) // accept anything but \\0
cp++;
}
} while (*cp != '\0' && *cp != '\n' && *cp != '#');
s.append(fxStr(cmd, cp-cmd));
}
- return (FALSE);
+ return (false);
}
#include <stdarg.h>
continue;
TypeRule rule;
if (*cp == '>') { // continuation
- rule.cont = TRUE;
+ rule.cont = true;
cp++;
} else
- rule.cont = FALSE;
+ rule.cont = false;
const char *op = cp;
rule.off = strtoul(op, &cp, 0); // file offset
if (cp == op) {
cp++;
const char* cmd = cp; // collect cmd string
if (*cp != '\0' && *cp != '\n' && *cp != '#') {
- fxBool done = FALSE; // XXX workaround compiler limitation
+ bool done = false; // XXX workaround compiler limitation
do {
cp++;
if (cp[-1] == '\\') {
while (fgets(line, sizeof (line), fp) != NULL &&
appendLine(rule.cmd, line))
;
- done = TRUE;
+ done = true;
} else if (*cp) // accept anything but \\0
cp++;
}
* Check secondary matching rules after a primary match.
*/
u_int
-TypeRules::match2(u_int base, const void* data, u_int size, fxBool verb) const
+TypeRules::match2(u_int base, const void* data, u_int size, bool verb) const
{
for (u_int i = 1, n = (*rules).length() - base; i < n; i++) {
TypeRule& rule = (*rules)[base+i];
static TypeRules* read(const fxStr& file); // read rule database
- void setVerbose(fxBool);
+ void setVerbose(bool);
const TypeRule* match(const void* data, u_int size) const;
private:
TypeRuleArray* rules;
- fxBool verbose; // while matching
+ bool verbose; // while matching
- u_int match2(u_int base, const void* data, u_int size, fxBool verb) const;
+ u_int match2(u_int base, const void* data, u_int size, bool verb) const;
};
typedef unsigned int TypeResult; // conversion result
};
private:
off_t off; // byte offset in file
- fxBool cont; // continuation
+ bool cont; // continuation
enum {
ASCII, // ascii-only string
STRING, // byte string
TypeRule(const TypeRule& other);
virtual ~TypeRule();
- fxBool match(const void*, u_int size, fxBool verbose = FALSE) const;
- fxBool isContinuation() const;
+ bool match(const void*, u_int size, bool verbose = false) const;
+ bool isContinuation() const;
TypeResult getResult() const;
const fxStr& getCmd() const;
const fxStr& df,
const fxStr& pname) const;
};
-inline fxBool TypeRule::isContinuation() const { return cont; }
+inline bool TypeRule::isContinuation() const { return cont; }
inline TypeResult TypeRule::getResult() const { return result; }
inline const fxStr& TypeRule::getCmd() const { return cmd; }
inline fxStr TypeRule::getErrMsg() const { return cmd; }
#include "sys/types.h"
#include "port.h"
-// Boolean type
-typedef unsigned char fxBool;
-#undef TRUE
-#define TRUE ((fxBool)1)
-#undef FALSE
-#define FALSE ((fxBool)0)
-
// minimum of two numbers
inline int fxmin(int a, int b) { return (a < b) ? a : b; }
inline u_long fxmin(u_long a, u_long b) { return (a < b) ? a : b; }
UnixTransport::UnixTransport(FaxClient& c) : Transport(c) {}
UnixTransport::~UnixTransport() {}
-fxBool
+bool
UnixTransport::isA(const char* address)
{
return Sys::isSocketFile(address);
#include <sys/un.h>
}
-fxBool
+bool
UnixTransport::callServer(fxStr& emsg)
{
int fd = socket(AF_UNIX, SOCK_STREAM, 0);
if (fd < 0) {
emsg = "Can not create socket to connect to server.";
- return (FALSE);
+ return (false);
}
struct sockaddr_un Sun;
memset(&Sun, 0, sizeof (Sun));
(const char*) client.getHost());
if (Socket::connect(fd, &Sun, sizeof (Sun)) >= 0) {
client.setCtrlFds(fd, dup(fd));
- return (TRUE);
+ return (true);
} else {
emsg = fxStr::format("Can not reach server at Unix domain socket \"%s\".",
(const char*) client.getHost());
Sys::close(fd), fd = -1;
- return (FALSE);
+ return (false);
}
}
-fxBool
+bool
UnixTransport::initDataConn(fxStr&)
{
#ifdef notdef
Socket::socklen_t dlen = sizeof (data_addr);
if (Socket::getsockname(fileno(client.getCtrlFd()), &data_addr, &dlen) < 0) {
emsg = fxStr::format("getsockname(ctrl): %s", strerror(errno));
- return (FALSE);
+ return (false);
}
data_addr.sin_port = 0; // let system allocate port
fd = socket(AF_INET, SOCK_STREAM, 0);
if (fd < 0) {
emsg = fxStr::format("socket: %s", strerror(errno));
- return (FALSE);
+ return (false);
}
if (Socket::bind(fd, &data_addr, sizeof (data_addr)) < 0) {
emsg = fxStr::format("bind: %s", strerror(errno));
if (client.command("PORT %u,%u,%u,%u,%u,%u",
UC(a[0]), UC(a[1]), UC(a[2]), UC(a[3]),
UC(p[0]), UC(p[1])) != COMPLETE)
- return (FALSE);
+ return (false);
#undef UC
client.setDataFd(fd);
- return (TRUE);
+ return (true);
bad:
Sys::close(fd), fd = -1;
#endif
- return (FALSE);
+ return (false);
}
-fxBool
+bool
UnixTransport::openDataConn(fxStr&)
{
#ifdef notdef
int s = Socket::accept(fileno(client.getDataFd()), NULL, NULL);
if (s >= 0) {
client.setDataFd(s);
- return (TRUE);
+ return (true);
} else {
emsg = fxStr::format("accept: %s", strerror(errno));
- return (FALSE);
+ return (false);
}
#else
- return (FALSE);
+ return (false);
#endif
}
#else
-fxBool UnixTransport::callServer(fxStr& emsg)
- { notConfigured("Unix domain", emsg); return (FALSE); }
-fxBool UnixTransport::initDataConn(fxStr& emsg)
- { notConfigured("Unix domain", emsg); return (FALSE); }
-fxBool UnixTransport::openDataConn(fxStr& emsg)
- { notConfigured("Unix domain", emsg); return (FALSE); }
+bool UnixTransport::callServer(fxStr& emsg)
+ { notConfigured("Unix domain", emsg); return (false); }
+bool UnixTransport::initDataConn(fxStr& emsg)
+ { notConfigured("Unix domain", emsg); return (false); }
+bool UnixTransport::openDataConn(fxStr& emsg)
+ { notConfigured("Unix domain", emsg); return (false); }
#endif
UnixTransport(FaxClient&);
~UnixTransport();
- static fxBool isA(const char*);
+ static bool isA(const char*);
- fxBool callServer(fxStr& emsg);
+ bool callServer(fxStr& emsg);
- fxBool initDataConn(fxStr& emsg);
- fxBool openDataConn(fxStr& emsg);
+ bool initDataConn(fxStr& emsg);
+ bool openDataConn(fxStr& emsg);
};
#endif /* _UnixTransport_ */
char* countryCode = "1";
char* internationalPrefix = "011";
char* longDistancePrefix = "1";
- fxBool verbose = FALSE;
+ bool verbose = false;
extern int optind, opterr;
extern char* optarg;
int c;
longDistancePrefix = optarg;
break;
case 'v':
- verbose = TRUE;
+ verbose = true;
break;
case '?':
usage();
if (argc - optind != 1)
usage();
DialStringRules rules(argv[optind]);
- rules.setVerbose(TRUE);
+ rules.setVerbose(true);
rules.def("AreaCode", areaCode);
rules.def("CountryCode", countryCode);
rules.def("InternationalPrefix", internationalPrefix);
faxFetchApp::faxFetchApp() {}
faxFetchApp::~faxFetchApp() {}
-static fxBool
+static bool
writeStdout(void*, const char* buf, int cc, fxStr&)
{
(void) Sys::write(STDOUT_FILENO, buf, cc);
- return (TRUE);
+ return (true);
}
void
mode = MODE_S;
break;
case 'v': // enable protocol tracing
- setVerbose(TRUE);
+ setVerbose(true);
break;
case 'z':
mode = MODE_Z;
extern const char* fmtTime(time_t t);
-static fxBool
+static bool
isFAXImage(TIFF* tif)
{
uint16 w;
if (TIFFGetField(tif, TIFFTAG_SAMPLESPERPIXEL, &w) && w != 1)
- return (FALSE);
+ return (false);
if (TIFFGetField(tif, TIFFTAG_BITSPERSAMPLE, &w) && w != 1)
- return (FALSE);
+ return (false);
if (!TIFFGetField(tif, TIFFTAG_COMPRESSION, &w) ||
(w != COMPRESSION_CCITTFAX3 && w != COMPRESSION_CCITTFAX4))
- return (FALSE);
+ return (false);
if (!TIFFGetField(tif, TIFFTAG_PHOTOMETRIC, &w) ||
(w != PHOTOMETRIC_MINISWHITE && w != PHOTOMETRIC_MINISBLACK))
- return (FALSE);
- return (TRUE);
+ return (false);
+ return (true);
}
static void
int
main(int argc, char** argv)
{
- fxBool showFilename = TRUE;
+ bool showFilename = true;
const char* appName = argv[0];
if (argc > 2 && streq(argv[1], "-n")) {
- showFilename = FALSE;
+ showFilename = false;
argc--, argv++;
}
if (argc != 2) {
printf("Could not open %s; either not TIFF or corrupted.\n", argv[1]);
return (0);
}
- fxBool ok = isFAXImage(tif);
+ bool ok = isFAXImage(tif);
if (!ok) {
printf("Does not look like a facsimile?\n");
return (0);
watchApp::watchApp() {}
watchApp::~watchApp() {}
-static fxBool
+static bool
writeData(void* arg, const char* buf, int cc, fxStr& emsg)
{
if (Sys::write((int) arg, buf, cc) != cc) {
emsg = fxStr::format("write error: %s", strerror(errno));
- return (FALSE);
+ return (false);
} else
- return (TRUE);
+ return (true);
}
void
break;
case 'v': // verbose mode
setvbuf(stdout, NULL, _IOLBF, BUFSIZ);
- FaxClient::setVerbose(TRUE);// protocol tracing
+ FaxClient::setVerbose(true);// protocol tracing
break;
case '?':
usage();
fmt.setNumberOfColumns(c - '0');
break;
case 'B':
- fmt.setPageHeaders(FALSE);
+ fmt.setPageHeaders(false);
break;
case 'c': // clip/cut instead of wrapping lines
- fmt.setLineWrapping(FALSE);
+ fmt.setLineWrapping(false);
break;
case 'D': // don't use ISO 8859-1 encoding
- fmt.setISO8859(FALSE);
+ fmt.setISO8859(false);
break;
case 'f': // body font
if (!fmt.setTextFont(optarg)) {
fmt.setFontPath(optarg);
break;
case 'G': // gaudy mode
- fmt.setGaudyHeaders(TRUE);
+ fmt.setGaudyHeaders(true);
break;
case 'm': // multi-column output
fmt.setNumberOfColumns(atoi(optarg));
fprintf(stderr, "Unable to setup file typing and conversion rules\n");
return (-1);
}
- typeRules->setVerbose(TRUE);
+ typeRules->setVerbose(true);
for (; optind < argc; optind++)
(void) fileType(argv[optind]);
return (0);