u_int modemXINFO() const;
bool setupReceive();
bool recvBegin(fxStr& emsg);
- bool recvPage(TIFF*, int& ppm, fxStr& emsg);
+ bool recvPage(TIFF*, u_int& ppm, fxStr& emsg);
bool recvEnd(fxStr& emsg);
void recvAbort();
* sending a post-page response in a multi-page document.
*/
bool
-Class1Modem::recvPage(TIFF* tif, int& ppm, fxStr& emsg)
+Class1Modem::recvPage(TIFF* tif, u_int& ppm, fxStr& emsg)
{
if (/* sendingHDLC */ lastPPM == FCF_MPS && prevPage && pageGood) {
// sendingHDLC = false
*/
break;
}
- } while (Sys::now()-start < t1 &&
+ } while ((unsigned) Sys::now()-start < t1 &&
(!frame.isOK() || frame.getFCF() == FCF_EOP));
}
setInputBuffering(true);
/*
* Wait up to T1 for a valid DIS.
*/
- if (Sys::now()-start >= t1)
+ if ((unsigned) Sys::now()-start >= t1)
break;
framerecvd = recvFrame(frame, conf.t2Timer);
}
// receive support
bool setupReceive();
bool recvBegin(fxStr& emsg);
- bool recvPage(TIFF*, int& ppm, fxStr& emsg);
+ bool recvPage(TIFF*, u_int& ppm, fxStr& emsg);
bool recvEnd(fxStr& emsg);
void recvAbort();
* received post-page-message.
*/
bool
-Class2Modem::recvPage(TIFF* tif, int& ppm, fxStr& emsg)
+Class2Modem::recvPage(TIFF* tif, u_int& ppm, fxStr& emsg)
{
int ppr;
emsg = callStatus[cs];
return (CALLTYPE_ERROR);
}
- } while (Sys::now()-start < conf.answerResponseTimeout);
+ } while ((unsigned) Sys::now()-start < conf.answerResponseTimeout);
emsg = "Ring detected without successful handshake";
return (CALLTYPE_ERROR);
}
buf[cc] = '\0';
}
if (cc > 0) {
- u_int i = 0;
+ int i = 0;
// leading white space
while (i < cc && isspace(buf[i]))
i++;
// NB: these would be enums in the ClassModem class
// if there were a portable way to refer to them!
-typedef unsigned int CallStatus; // return status from dialing op
-typedef unsigned int CallType; // type detected for incoming call
-typedef unsigned int AnswerType; // type of call to answer for
-typedef unsigned int SpeakerVolume;
-typedef unsigned int ATResponse; // response code from AT command
-typedef unsigned int BaudRate; // serial line communication rate
-typedef unsigned int FlowControl; // serial line flow control scheme
-typedef unsigned int SetAction; // how to act when setting line
+typedef u_int CallStatus; // return status from dialing op
+typedef u_int CallType; // type detected for incoming call
+typedef u_int AnswerType; // type of call to answer for
+typedef u_int SpeakerVolume;
+typedef u_int ATResponse; // response code from AT command
+typedef u_int BaudRate; // serial line communication rate
+typedef u_int FlowControl; // serial line flow control scheme
+typedef u_int SetAction; // how to act when setting line
typedef struct {
const char* msg; // string to match
u_short len; // string length
record.fput("\t\"%s\"", status); // $14 = status
record.put('\n');
flock(fd, LOCK_EX);
- ok = (Sys::write(fd, record, record.getLength()) == record.getLength());
+ ok = (Sys::write(fd, record, record.getLength()) == (ssize_t)record.getLength());
Sys::close(fd); // implicit unlock
}
return (ok);
}
FaxMachineInfo::~FaxMachineInfo() { writeConfig(); }
-int
+u_short
FaxMachineInfo::getMaxPageWidthInMM() const
{
- return (int)(maxPageWidth/(204.0f/25.4f));
+ return (u_short)(maxPageWidth/(204.0f/25.4f));
}
#include <ctype.h>
supportsPostScript = false; // no support for Adobe protocol
calledBefore = false; // never called before
maxPageWidth = 2432; // max required width
- maxPageLength = -1; // infinite page length
+ maxPageLength = (u_short) -1; // infinite page length
maxSignallingRate = BR_14400; // T.17 14.4KB
minScanlineTime = ST_0MS; // 0ms/0ms
sendFailures = 0;
fxStackBuffer buf;
writeConfig(buf);
u_int cc = buf.getLength();
- if (Sys::write(fd, buf, cc) != cc) {
+ if (Sys::write(fd, buf, cc) != (ssize_t)cc) {
error("write error: %s", strerror(errno));
Sys::close(fd);
return;
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
- int minScanlineTime; // min scanline time capable
+ u_short maxPageWidth; // max capable page width
+ u_short maxPageLength; // max capable page length
+ u_short maxSignallingRate; // max capable signalling rate
+ u_short minScanlineTime; // min scanline time capable
fxStr csi; // last received CSI
int sendFailures; // count of failed send attempts
int dialFailures; // count of failed dial attempts
bool getSupports2DEncoding() const;
bool getSupportsPostScript() const;
bool getCalledBefore() const;
- int getMaxPageWidthInPixels() const;
- int getMaxPageWidthInMM() const;
- int getMaxPageLengthInMM() const;
- int getMaxSignallingRate() const;
- int getMinScanlineTime() const;
+ u_short getMaxPageWidthInPixels() const;
+ u_short getMaxPageWidthInMM() const;
+ u_short getMaxPageLengthInMM() const;
+ u_short getMaxSignallingRate() const;
+ u_short getMinScanlineTime() const;
const fxStr& getCSI() const;
int getSendFailures() const;
{ return supportsPostScript; }
inline bool FaxMachineInfo::getCalledBefore() const
{ return calledBefore; }
-inline int FaxMachineInfo::getMaxPageWidthInPixels() const
+inline u_short FaxMachineInfo::getMaxPageWidthInPixels() const
{ return maxPageWidth; }
-inline int FaxMachineInfo::getMaxPageLengthInMM() const
+inline u_short FaxMachineInfo::getMaxPageLengthInMM() const
{ return maxPageLength; }
-inline int FaxMachineInfo::getMaxSignallingRate() const
+inline u_short FaxMachineInfo::getMaxSignallingRate() const
{ return maxSignallingRate; }
-inline int FaxMachineInfo::getMinScanlineTime() const
+inline u_short FaxMachineInfo::getMinScanlineTime() const
{ return minScanlineTime; }
inline const fxStr& FaxMachineInfo::getCSI() const
{ return csi; }
*/
virtual bool setupReceive() = 0;
virtual bool recvBegin(fxStr& emsg);
- virtual bool recvPage(TIFF*, int& ppm, fxStr& em) = 0;
+ virtual bool recvPage(TIFF*, u_int& ppm, fxStr& em) = 0;
virtual bool recvEnd(fxStr& emsg) = 0;
virtual void recvAbort() = 0;
// query interfaces for optional state
FaxServer::recvDocuments(TIFF* tif, FaxRecvInfo& info, FaxRecvInfoArray& docs, fxStr& emsg)
{
bool recvOK;
- int ppm;
+ u_int ppm;
pageStart = Sys::now();
for (;;) {
modem->getRecvSUB(info.subaddr); // optional subaddress
* Receive Phase B protocol processing.
*/
bool
-FaxServer::recvFaxPhaseD(TIFF* tif, FaxRecvInfo& info, int& ppm, fxStr& emsg)
+FaxServer::recvFaxPhaseD(TIFF* tif, FaxRecvInfo& info, u_int& ppm, fxStr& emsg)
{
ppm = PPM_EOP;
do {
char stackbuf[2048];
char* buf = stackbuf;
char* bp = buf;
- if (sb.st_size > sizeof (buf)-1) // extra byte for terminating \0
+ if (sb.st_size > (off_t)sizeof(buf)-1) // extra byte for terminating \0
bp = buf = new char[sb.st_size+1];
if (Sys::read(fd, bp, (u_int) sb.st_size) != sb.st_size) {
error("Read error: %s", strerror(errno));
}
uint32 w;
(void) TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &w);
- if (w > clientInfo.getMaxPageWidthInPixels()) {
+ if (w > (uint32)clientInfo.getMaxPageWidthInPixels()) {
emsg = fxStr::format("Client does not support document page width"
", max remote page width %u pixels, image width %lu pixels",
clientInfo.getMaxPageWidthInPixels(), w);
* to take into account sloppy coding practice (e.g.
* using 200 dpi for high-res facsimile.
*/
- if (clientInfo.getMaxPageLengthInMM() != -1) {
+ if (clientInfo.getMaxPageLengthInMM() != (u_short)-1) {
u_long h = 0;
(void) TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &h);
float len = h / yres; // page length in mm
TIFF* setupForRecv(FaxRecvInfo&, FaxRecvInfoArray&, fxStr& emsg);
bool recvDocuments(TIFF*, FaxRecvInfo&, FaxRecvInfoArray&,
fxStr& emsg);
- bool recvFaxPhaseD(TIFF* tif, FaxRecvInfo&, int& ppm, fxStr& emsg);
+ bool recvFaxPhaseD(TIFF* tif, FaxRecvInfo&, u_int& ppm, fxStr& emsg);
bool pollFaxPhaseB(const fxStr& sep, const fxStr& pwd,
FaxRecvInfoArray&, fxStr& emsg);
protected:
schedReap();
return (false);
}
- if (n != msgLen)
+ if ((unsigned) n != msgLen)
logError(
"HylaClient::send: %s: write failed (return %d, seq# %u, %m)",
(const char*) fifoName, seqnum, n);
}
if (!cacheFd)
Sys::close(fd), fd = -1;
- return (n == msgLen);
+ return ((unsigned)n == msgLen);
}
#include "StackBuffer.h"
ModemServer::getModemLine(char rbuf[], u_int bufSize, long ms)
{
int c;
- int cc = 0;
+ u_int cc = 0;
if (ms) startTimeout(ms);
do {
while ((c = getModemChar(0)) != EOF && c != '\n')
struct NSFData {
const char* vendorId;
- static
- const int vendorIdSize; // Country & provider code (T.35)
+ static const u_int vendorIdSize; // Country & provider code (T.35)
const char* vendorName;
bool inverseStationIdOrder;
- int modelIdPos;
- int modelIdSize;
+ u_int modelIdPos;
+ u_int modelIdSize;
const ModelData* knownModels;
};
-const int NSFData::vendorIdSize = 3; // Country & provider code (T.35)
+const u_int NSFData::vendorIdSize = 3; // Country & provider code (T.35)
static const ModelData Canon[] =
{{"\x80\x00\x80\x48\x00", "Faxphone B640"},
error("No space for font metric information");
return (false);
}
- for (int i = 0; i < numGlyphs; i++) {
+ for (u_int i = 0; i < numGlyphs; i++) {
if (isFormat(PCF_DEFAULT_FORMAT))
getMetric(metrics[i]);
else
error("No space for bitmap offsets array");
return (false);
}
- int i;
- for (i = 0; i < nbitmaps; i++)
+ for (u_int i = 0; i < nbitmaps; i++)
offsets[i] = getINT32();
u_long bitmapSizes[4];
bitmapSizes[0] = getINT32();
return (false);
}
int newoff = 0;
- for (i = 0; i < nbitmaps; i++) {
+ for (u_int i = 0; i < nbitmaps; i++) {
off_t old = offsets[i];
offsets[i] = newoff;
const charInfo& metric = metrics[i];
delete bitmaps;
bitmaps = padbitmaps;
}
- for (i = 0; i < nbitmaps; i++) {
+ for (u_int i = 0; i < nbitmaps; i++) {
metrics[i].bits = bitmaps + offsets[i];
if ((unsigned long) metrics[i].bits & 1) {
error("Internal error, bitmap data not word-aligned");
error("No space for character encoding vector");
return (false);
}
- for (int i = 0; i < nencoding; i++) {
+ for (u_int i = 0; i < nencoding; i++) {
int encodingOffset = getINT16();
encoding[i] = (encodingOffset == 0xffff) ?
0 : metrics + encodingOffset;
bool
PCFFont::seekToTable(u_long type)
{
- for (int i = 0; i < tocSize; i++)
+ for (u_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");
error("Cannot read TOC; no space for %lu records", tocSize);
return (false);
}
- for (int i = 0; i < tocSize; i++) {
+ for (u_int i = 0; i < tocSize; i++) {
toc[i].type = getLSB32();
toc[i].format = getLSB32();
toc[i].size = getLSB32();
{
if (!ready)
return (0);
- int rowwords = howmany(w,16);
- int y = tm + fontAscent;
- int x = lm;
+ u_int rowwords = howmany(w,16);
+ u_int y = tm + fontAscent;
+ u_int x = lm;
/*
* The rasterize assumes words have a big-endian
* byte order. For now (rather than fix it) we
}
fxStr msg = fxStr::vformat(fmt, ap);
u_int len = msg.length() + 1;
- if (Sys::write(faxqfifo, (const char*)msg, len) != len) {
+ if (Sys::write(faxqfifo, (const char*)msg, len) != (ssize_t)len) {
if (errno == EBADF || errno == EPIPE) // reader expired
Sys::close(faxqfifo), faxqfifo = -1;
else
* accepting variable-length pages.
*/
u_int pagechop;
- if (info.getMaxPageLengthInMM() == -1) {
+ if (info.getMaxPageLengthInMM() == (unsigned)-1) {
pagechop = req.pagechop;
if (pagechop == FaxRequest::chop_default)
pagechop = pageChop;
* vertical resolution. Note that if the resolution
* info is bogus, we may select the wrong page size.
*/
- if (info.getMaxPageLengthInMM() != -1) {
+ if (info.getMaxPageLengthInMM() != (unsigned)-1) {
uint32 h;
TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &h);
params.setPageLengthInMM((u_int)(h / yres));
static void
crackArgv(fxStr& s)
{
- int i = 0;
+ u_int i = 0;
do {
while (i < s.length() && !isspace(s[i])) i++;
if (i < s.length()) {
s[i++] = '\0';
- int j = i;
+ u_int j = i;
while (j < s.length() && isspace(s[j])) j++;
if (j > i) {
s.remove(i, j - i);
buf.getLength(), (const char*) buf);
} else
traceResponse(buf);
- } while (!gotID && Sys::now() - start < ixoIDTimeout);
+ } while (!gotID && (unsigned) Sys::now() - start < ixoIDTimeout);
if (!gotID) {
emsg = "No initial ID response from paging central";
req.status = send_retry;
if (!scanForCode(cp, len))
traceResponse(buf);
}
- } while (Sys::now()-start < ixoLoginTimeout && --unknown);
+ } while ((unsigned)Sys::now()-start < ixoLoginTimeout && --unknown != 0);
emsg = fxStr::format("Protocol failure: %s from paging central",
(unknown ?
"timeout waiting for response" : "too many unknown responses"));
(void) scanForCode(cp, len);
}
traceResponse(buf);
- } while (Sys::now()-start < ixoGATimeout && --unknown);
+ } while ((unsigned) Sys::now()-start < ixoGATimeout && --unknown != 0);
emsg = fxStr::format("Protocol failure: %s waiting for go-ahead message",
unknown ? "timeout" : "too many unknown responses");
req.status = send_retry;
if (!scanForCode(cp, len))
traceResponse(resp);
}
- } while (Sys::now()-start < ixoXmitTimeout && unknown < ixoMaxUnknown);
+ } while ((unsigned)Sys::now()-start < ixoXmitTimeout && unknown < ixoMaxUnknown);
emsg = fxStr::format("Protocol failure: %s to message block transmit",
(unknown ?
"timeout waiting for response" : "too many unknown responses"));
}
traceResponse(buf);
// NB: ignore unknown responses
- } while (Sys::now() - start < ixoAckTimeout);
+ } while ((unsigned)Sys::now() - start < ixoAckTimeout);
req.status = send_retry;
emsg = "Protocol failure: timeout waiting for transaction ACK/NAK "
"from paging central";
}
}
}
- } while (Sys::now()-start < ixoXmitTimeout && unknown < ixoMaxUnknown);
+ } while ((unsigned)Sys::now()-start < ixoXmitTimeout && unknown < ixoMaxUnknown);
return false;
}
if (fcntl(faxqFd, F_SETFL, fcntl(faxqFd, F_GETFL, 0) &~ O_NDELAY) < 0)
logError("fcntl: %m");
}
- u_int len = msg.length()+1;
+ ssize_t len = msg.length()+1;
if (Sys::write(faxqFd, msg, len) != len) {
if (errno == EBADF || errno == EPIPE) {
/*
va_start(ap, fmt);
fxStr msg = fxStr::vformat(fmt, ap);
va_end(ap);
- u_int len = msg.length()+1;
+ ssize_t len = msg.length()+1;
if (Sys::write(fd, msg, len) != len) {
emsg = fxStr::format("write to %s failed: %s",
(const char*) fifoName, strerror(errno));
char buf[512];
TIFFHeader h;
} b;
- int cc = Sys::read(fd, (char*) &b, sizeof (b));
+ ssize_t cc = Sys::read(fd, (char*) &b, sizeof (b));
if (cc > 2 && b.buf[0] == '%' && b.buf[1] == '!')
op = FaxRequest::send_postscript;
else if (cc > 2 && b.buf[0] == '%' && b.buf[1] == 'P') {
logError("What we have here is a PDF file");
op = FaxRequest::send_pdf;
}
- else if (cc > sizeof (b.h) && isTIFF(b.h))
+ else if (cc > (ssize_t)sizeof (b.h) && isTIFF(b.h))
op = FaxRequest::send_tiff;
else
op = FaxRequest::send_data;
char buf[512];
TIFFHeader h;
} b;
- int cc = Sys::read(fd, (char*) &b, sizeof (b));
- if (cc > sizeof (b.h) && b.h.tiff_version == TIFF_VERSION &&
+ ssize_t cc = Sys::read(fd, (char*) &b, sizeof (b));
+ if (cc > (ssize_t)sizeof (b.h) && b.h.tiff_version == TIFF_VERSION &&
(b.h.tiff_magic == TIFF_BIGENDIAN ||
b.h.tiff_magic == TIFF_LITTLEENDIAN)) {
(void) lseek(fd, 0L, SEEK_SET); // rewind
uint32* sb;
(void) TIFFGetField(tif, TIFFTAG_STRIPBYTECOUNTS, &sb);
tdata_t buf = _TIFFmalloc(sb[0]);
- uint32 bsize = sb[0];
+ tsize_t bsize = sb[0];
for (tstrip_t s = 0, ns = TIFFNumberOfStrips(tif); s < ns; s++) {
tsize_t cc = sb[s];
if (cc > bsize) {
int cc = read(fdin, buf, sizeof (buf));
if (cc == 0) {
size_t occ = sizeof (obuf) - zstream.avail_out;
- if (occ > 0 && write(fdout, obuf, occ) != occ) {
+ if (occ > 0 && write(fdout, obuf, occ) != (ssize_t)occ) {
perror_reply(452, "Error writing output file", errno);
break;
}
goto bad;
}
size_t occ = sizeof (obuf) - zstream.avail_out;
- if (write(fdout, obuf, occ) != occ) {
+ if (write(fdout, obuf, occ) != (ssize_t)occ) {
perror_reply(452, "Error writing output file", errno);
goto bad;
}
void
HylaFAXServer::sanitize(fxStr& s)
{
- for (int i = 0; i < s.length(); i++)
+ for (u_int i = 0; i < s.length(); i++)
if (!isascii(s[i]) || !isprint(s[i]))
s[i] = '?';
}
;
modem = tag;
} else {
- int i;
+ u_int i;
for (i = 0; i < NCMDS && !isCmd(cmds[i].cmd); i++)
;
if (i == NCMDS)
* value to output (written in reverse).
*/
char buf[1024];
- int len = codep->length;
+ u_int len = codep->length;
char* tp = (len > sizeof (buf) ? (char*) malloc(len) : buf) + len;
do {
*--tp = codep->value;
return (true);
} else if (number_param(n)) {
logcmd(t, "%lu", n);
- if (n > maxIdleTimeout && !IS(PRIVILEGED)) {
+ if ((unsigned)n > maxIdleTimeout && !IS(PRIVILEGED)) {
idleTimeout = maxIdleTimeout;
reply(213, "%lu: Idle timeout too large, set to %u.",
n, maxIdleTimeout);
void
HylaFAXServer::pushCmdData(const char* data, int n)
{
- if (recvNext + n > sizeof (recvBuf)) {
+ if ((unsigned) recvNext + n > sizeof (recvBuf)) {
logError("No space to push back urgent data \"%.*s\"", n, data);
return;
}
return (true);
} else if (number_param(n)) {
logcmd(t, "%lu", n);
- if (n > maxIdleTimeout && !IS(PRIVILEGED)) {
+ if ((unsigned)n > maxIdleTimeout && !IS(PRIVILEGED)) {
idleTimeout = maxIdleTimeout;
reply(250, "%lu: Idle timeout too large, set to %u.",
n, maxIdleTimeout);
line = fxStr::format("%s:%u:%s\n", user, uid, upass);
else
line = fxStr::format("%s:%u\n", user, uid);
- if (Sys::write(fd, line, line.length()) != line.length()) {
+ if (Sys::write(fd, line, line.length()) != (ssize_t)line.length()) {
perror_reply(550, "Write error", errno);
Sys::close(fd);
(void) Sys::unlink(tfile);
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
* OF THIS SOFTWARE.
*/
+#include "config.h" //for BR_14400 definition
#include "class2.h" //for BR_14400 definition
#include "SendFaxClient.h"
#include "FaxDB.h"
/*
* The number of days in each month of the year.
*/
-static const u_int nonLeapYear[12] =
+static const int nonLeapYear[12] =
{ 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
-static const u_int leapYear[12] =
+static const int leapYear[12] =
{ 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
-static const u_int* daysInMonth[2] = { nonLeapYear, leapYear };
+static const int* daysInMonth[2] = { nonLeapYear, leapYear };
static void
adjustYDay(struct tm& t)
{
// adjust year day according to month
- const u_int* days = daysInMonth[isLeapYear(t)];
+ const int* days = daysInMonth[isLeapYear(t)];
t.tm_yday = t.tm_mday;
- for (u_int i = 0; i < t.tm_mon; i++)
+ for (int i = 0; i < t.tm_mon; i++)
t.tm_yday += days[i];
}
adjustYDay(at);
}
}
- const u_int* days = daysInMonth[isLeapYear(at)];
+ const int* days = daysInMonth[isLeapYear(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]);
* Now recalculate derivative values
* to insure everything is consistent.
*/
- const u_int* days = daysInMonth[leap];
+ const int* days = daysInMonth[leap];
at.tm_mday = at.tm_yday;
for (at.tm_mon = 0; at.tm_mday >= days[at.tm_mon]; at.tm_mon++)
at.tm_mday -= days[at.tm_mon];
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
* OF THIS SOFTWARE.
*/
+#include "config.h"
#include "Class2Params.h"
#include "Sys.h"
#include "t.30.h"
fxDictionary::fxDictionary(const fxDictionary& a)
{
- for (int i = 0; i < a.buckets.length(); i++) {
+ for (u_int i = 0; i < a.buckets.length(); i++) {
const fxDictBucket* sb = a.buckets[i];
while (sb) {
addInternal(KEY(sb),VALUE(sb));
assert(valuesize == a.getValueSize());
if (this == &a) return;
this->fxDictionary::~fxDictionary(); // NB: need this for HP C++ 3.4
- for (int i = 0; i < a.buckets.length(); i++) {
+ for (u_int i = 0; i < a.buckets.length(); i++) {
const fxDictBucket* db = a.buckets[i];
while (db) {
addInternal(KEY(db), VALUE(db));
{
u_long u = 0;
const u_long* p = (const u_long*)key;
- int l = (int)keysize;
+ u_int l = keysize;
while (l>=sizeof (u_long)) {
u ^= *p++;
l -= sizeof (u_long);
_etable = new IOHandler*[_max_fds];
_queue = new TimerQueue;
_cqueue = new ChildQueue;
- for (int i = 0; i < _max_fds; i++) {
+ for (u_int i = 0; i < _max_fds; i++) {
_rtable[i] = NULL;
_wtable[i] = NULL;
_etable[i] = NULL;
}
void Dispatcher::attach(int fd, DispatcherMask mask, IOHandler* handler) {
+ if (fd < 0)
+ return;
+
if (mask == ReadMask) {
FD_SET(fd, &_rmask);
_rtable[fd] = handler;
} else {
abort();
}
- if (_nfds < fd+1) {
+ if (_nfds < (unsigned)fd+1) {
_nfds = fd+1;
}
}
_wtable[fd] = NULL;
FD_CLR(fd, &_emask);
_etable[fd] = NULL;
- if (_nfds == fd+1) {
+ if (_nfds == (unsigned)fd+1) {
while (_nfds > 0 && _rtable[_nfds-1] == NULL &&
_wtable[_nfds-1] == NULL && _etable[_nfds-1] == NULL
) {
Dispatcher::sigCLD(0); // poll for pending children
return _cqueue->isReady();
}
- for (int i = 0; i < _nfds; i++) {
+ for (u_int i = 0; i < _nfds; i++) {
if (FD_ISSET(i, &_rmaskready) ||
FD_ISSET(i, &_wmaskready) || FD_ISSET(i, &_emaskready)) {
return true;
FD_ZERO(&_wmaskready);
FD_ZERO(&_emaskready);
int n = 0;
- for (int i = 0; i < _nfds; i++) {
+ for (u_int i = 0; i < _nfds; i++) {
if (FD_ISSET(i, &rmaskret)) n++;
if (FD_ISSET(i, &wmaskret)) n++;
if (FD_ISSET(i, &emaskret)) n++;
void Dispatcher::notify(int nfound,
fd_set& rmaskret, fd_set& wmaskret, fd_set& emaskret) {
- for (int i = 0; i < _nfds && nfound > 0; i++) {
+ for (u_int i = 0; i < _nfds && nfound > 0; i++) {
if (FD_ISSET(i, &rmaskret)) {
if (_rtable[i]) {
int status = _rtable[i]->inputReady(i);
FD_ZERO(&rmask);
timeval poll = TimerQueue::zeroTime();
- for (int fd = 0; fd < _nfds; fd++) {
+ for (u_int fd = 0; fd < _nfds; fd++) {
if (_rtable[fd] != NULL) {
FD_SET(fd, &rmask);
#if CONFIG_BADSELECTPROTO
virtual bool handleError();
virtual void checkConnections();
protected:
- int _nfds;
- int _max_fds;
+ u_int _nfds;
+ u_int _max_fds;
fd_set _rmask;
fd_set _wmask;
fd_set _emask;
while (cc > 0) {
char buf[32*1024]; // XXX better if page-aligned
size_t n = fxmin(cc, sizeof (buf));
- if (read(fd, buf, n) != n) {
+ if (read(fd, buf, n) != (ssize_t)n) {
protocolBotch(emsg, " (data read: %s).", strerror(errno));
goto bad;
}
struct FaxParam {
const char* cmd;
const char** parmNames;
- int NparmNames;
+ u_int NparmNames;
u_int FaxClient::*pv;
};
struct FaxFmtHeader {
class PageInfoArray;
-typedef unsigned int BMU; // ISO basic measurement unit
+typedef u_int BMU; // ISO basic measurement unit
struct PageInfo {
const char* name; // page size name
const char* abbr; // abbreviated name
while (cc > 0) {
char buf[32*1024];
size_t n = fxmin(cc, sizeof (buf));
- if (read(fd, buf, n) != n) {
+ if (read(fd, buf, n) != (ssize_t) n) {
protocolBotch(emsg, " (data read: %s).", strerror(errno));
return (false);
}
class SNPPClient;
-typedef unsigned int PageNotify;
+typedef u_int PageNotify;
class SNPPJob : public fxObj {
public:
class SendFaxClient;
-typedef unsigned int FaxNotify;
-typedef unsigned int FaxPageChop;
+typedef u_int FaxNotify;
+typedef u_int FaxPageChop;
class SendFaxJob : public fxObj {
public:
// NB: the buffer is *NOT* null terminated, unless you put one there.
operator char*(); // Return base of buffer
- operator unsigned char*(); // Return base of buffer
+ operator u_char*(); // Return base of buffer
operator const char*(); // Return base of buffer
- operator const unsigned char*(); // Return base of buffer
+ operator const u_char*(); // Return base of buffer
operator const char*() const; // Return base of buffer
- operator const unsigned char*() const;// Return base of buffer
+ operator const u_char*() const;// Return base of buffer
char& operator[](u_int i) const; // Return character in buffer
char& operator[](int i) const; // Return character in buffer
fxStackBuffer& operator=(const fxStackBuffer&);
inline void fxStackBuffer::set(char c) { put(c); next--; }
inline void fxStackBuffer::reset() { next = base; }
inline fxStackBuffer::operator char*() { return base; }
-inline fxStackBuffer::operator unsigned char*() { return (unsigned char*)base; }
+inline fxStackBuffer::operator u_char*() { return (u_char*)base; }
inline fxStackBuffer::operator const char*() { return base; }
-inline fxStackBuffer::operator const unsigned char*()
- { return (unsigned char*)base; }
+inline fxStackBuffer::operator const u_char*()
+ { return (u_char*)base; }
inline fxStackBuffer::operator const char*() const
{ return base; }
-inline fxStackBuffer::operator const unsigned char*() const
- { return (unsigned char*)base; }
+inline fxStackBuffer::operator const u_char*() const
+ { return (u_char*)base; }
inline u_int fxStackBuffer::getLength() const { return next - base; }
inline char& fxStackBuffer::operator[](u_int ix) const { return base[ix]; }
inline char& fxStackBuffer::operator[](int ix) const { return base[ix]; }
{ return ::open(filename, flags, m); }
static int close(int fd) { return ::close(fd); }
// NB: char* param to read+write for implicit cast when using fxStr's
- static int write(int fd, const char *buf, u_int cc)
+ static ssize_t write(int fd, const char *buf, u_int cc)
{ return ::write(fd, buf, cc); }
- static int read(int fd, char* buf, unsigned cc)
+ static ssize_t read(int fd, char* buf, u_int cc)
{ return ::read(fd, buf, cc); }
static time_t now(void) { return ::time(0); }
{
char buf[16*1024];
for (off_t k = b1; k <= b2; k += sizeof (buf)) {
- off_t cc = (off_t)
- fxmin((u_long) (off_t) sizeof (buf), (u_long) (b2-k+1));
+ size_t cc = (size_t) fxmin(sizeof (buf), (unsigned) (b2-k+1));
fseek(tf, (long) k, SEEK_SET); // position to desired block
if (fread(buf, 1, (size_t) cc, tf) != cc)
fatal("Read error during reverse collation: %s", strerror(errno));
{
fputc('(', fd);
for (; *val; val++) {
- unsigned c = *val & 0xff;
+ u_int c = *val & 0xff;
if ((c & 0200) == 0) {
if (c == '(' || c == ')' || c == '\\')
fputc('\\', fd);
{
if (column == 1) { // new page
if (reverse) {
- int k = pageNum-firstPageNum;
+ u_int k = pageNum-firstPageNum;
off_t off = (off_t) ftell(tf);
if (k < pageOff->length())
(*pageOff)[k] = off;
int aliascount = maxaliases;
while (fgets(buf, sizeof(buf), fd) != NULL &&
aliascount > 0) {
- int len = strcspn(buf, "%\n");
+ size_t len = strcspn(buf, "%\n");
if (len == strlen(buf)) {
emsg = fxStr::format(
"Warning:%s - line too long.", (const char*)fontMapFile);
if (len > 0) {
fprintf(fd, "(");
do {
- unsigned c = *val++ & 0xff;
+ u_int c = *val++ & 0xff;
if ((c & 0200) == 0) {
if (c == '(' || c == ')' || c == '\\')
fputc('\\', fd);
fputc(c, fd);
} else
fprintf(fd, "\\%03o", c);
- hm += widths[(unsigned) c]; // Leif Erlingsson <leif@lege.com>
+ hm += widths[c]; // Leif Erlingsson <leif@lege.com>
} while (--len);
fprintf(fd, ")%s ", (const char*) showproc);
}
*/
if (ix > 127)
w = 625; // distrust metrics-file for char > 127
- if (ix < NCHARS)
+ if ((unsigned)ix < NCHARS)
widths[ix] = w*ps/1000L;
}
fclose(fp);
bool readMetrics(TextCoord pointsize, bool useISO8859, fxStr& emsg);
};
/*
- * we have to use unsigned const char
+ * we have to use const u_char
*/
-inline TextCoord TextFont::charwidth(const char c) const { return widths[(unsigned const char) c]; }
+inline TextCoord TextFont::charwidth(const char c) const { return widths[(const u_char) c]; }
inline const char* TextFont::getFamily(void) const { return family; }
class FontDict;
static const char* resultNames[] = { "tiff", "postscript", "error" };
bool
-TypeRule::match(const void* data, u_int size, bool verbose) const
+TypeRule::match(const void* data, size_t size, bool verbose) const
{
if (verbose) {
printf("rule: %soffset %#lx %s %s",
}
printf(" -- ");
}
- if (off > size) {
+ if (off > (off_t)size) {
if (verbose)
printf("failed (offset past data)\n");
return (false);
}
bool ok = false;
- u_long v = 0;
+ long v = 0;
const u_char* cp = (const u_char*) data;
switch (type) {
case ASCII:
v = *cp;
break;
case SHORT:
- if (off + 2 < size) {
+ if (off + 2 < (off_t)size) {
u_short w;
memcpy(&w, cp+off, 2);
v = ntohs(w);
printf("failed (insufficient data)\n");
return (false);
case LONG:
- if (off + 4 < size) {
+ if (off + 4 < (off_t)size) {
memcpy(&v, cp+off, 4);
v = ntohl(v);
break;
u_int match2(u_int base, const void* data, u_int size, bool verb) const;
};
-typedef unsigned int TypeResult; // conversion result
+typedef u_int TypeResult; // conversion result
/*
* Type rules specify how to convert a file that is
// Boolean type
#ifdef NEED_BOOL
-typedef unsigned char bool;
+typedef u_char bool;
#undef true
#define true ((bool)1)
#undef false
#define BIT(i) (1<<(i))
// bit ordering directives +fbor=<n>
-const int BOR_C_DIR = 0; // phase C direct
-const int BOR_C_REV = 1; // phase C reversed
-const int BOR_C = 0x1;
-const int BOR_BD_DIR = (0<<1); // phase B/D direct
-const int BOR_BD_REV = (1<<1); // phase B/D reversed
-const int BOR_BD = 0x2;
+const u_short BOR_C_DIR = 0; // phase C direct
+const u_short BOR_C_REV = 1; // phase C reversed
+const u_short BOR_C = 0x1;
+const u_short BOR_BD_DIR = (0<<1); // phase B/D direct
+const u_short BOR_BD_REV = (1<<1); // phase B/D reversed
+const u_short BOR_BD = 0x2;
// service types returned by +fclass=?
-const int SERVICE_DATA = BIT(0); // data service
-const int SERVICE_CLASS1 = BIT(1); // class 1 interface
-const int SERVICE_CLASS2 = BIT(2); // class 2 interface
-const int SERVICE_CLASS20 = BIT(3); // class 2.0 interface
-const int SERVICE_CLASS10 = BIT(4); // class 1.0 interface
-const int SERVICE_CLASS21 = BIT(5); // class 2.1 interface
-const int SERVICE_VOICE = BIT(8); // voice service (ZyXEL extension)
-const int SERVICE_ALL = BIT(9)-1;
+const u_short SERVICE_DATA = BIT(0); // data service
+const u_short SERVICE_CLASS1 = BIT(1); // class 1 interface
+const u_short SERVICE_CLASS2 = BIT(2); // class 2 interface
+const u_short SERVICE_CLASS20 = BIT(3); // class 2.0 interface
+const u_short SERVICE_CLASS10 = BIT(4); // class 1.0 interface
+const u_short SERVICE_CLASS21 = BIT(5); // class 2.1 interface
+const u_short SERVICE_VOICE = BIT(8); // voice service (ZyXEL extension)
+const u_short SERVICE_ALL = BIT(9)-1;
// t.30 session subparameter codes
// NB: only the first two are used
-const int VR_NORMAL = 0; // 98 lpi
-const int VR_FINE = 1; // 196 lpi
-const int VR_R8 = 2; // R8 x 15.4 l/mm
-const int VR_R16 = 4; // R16 x 15.4 l/mm
-const int VR_200X100 = 8; // 200 dpi x 100 l/25.4mm
-const int VR_200X200 = 10; // 200 dpi x 200 l/25.4mm
-const int VR_200X400 = 20; // 200 dpi x 400 l/25.4mm
-const int VR_300X300 = 40; // 300 dpi x 300 l/25.4mm
-const int VR_ALL = BIT(VR_FINE+1)-1;
+const u_int VR_NORMAL = 0; // 98 lpi
+const u_int VR_FINE = 1; // 196 lpi
+const u_int VR_R8 = 2; // R8 x 15.4 l/mm
+const u_int VR_R16 = 4; // R16 x 15.4 l/mm
+const u_int VR_200X100 = 8; // 200 dpi x 100 l/25.4mm
+const u_int VR_200X200 = 10; // 200 dpi x 200 l/25.4mm
+const u_int VR_200X400 = 20; // 200 dpi x 400 l/25.4mm
+const u_int VR_300X300 = 40; // 300 dpi x 300 l/25.4mm
+const u_int VR_ALL = BIT(VR_FINE+1)-1;
-const int BR_2400 = 0; // 2400 bit/s
-const int BR_4800 = 1; // 4800 bit/s
-const int BR_7200 = 2; // 7200 bit/s
-const int BR_9600 = 3; // 9600 bit/s
-const int BR_12000 = 4; // 12000 bit/s
-const int BR_14400 = 5; // 14400 bit/s
-const int BR_16800 = 6; // 16800 bit/s
-const int BR_19200 = 7; // 19200 bit/s
-const int BR_21600 = 8; // 21600 bit/s
-const int BR_24000 = 9; // 24000 bit/s
-const int BR_26400 = 10; // 26400 bit/s
-const int BR_28800 = 11; // 28800 bit/s
-const int BR_31200 = 12; // 31200 bit/s
-const int BR_33600 = 13; // 33600 bit/s
-const int BR_ALL = BIT(BR_33600+1)-1;
+const u_short BR_2400 = 0; // 2400 bit/s
+const u_short BR_4800 = 1; // 4800 bit/s
+const u_short BR_7200 = 2; // 7200 bit/s
+const u_short BR_9600 = 3; // 9600 bit/s
+const u_short BR_12000 = 4; // 12000 bit/s
+const u_short BR_14400 = 5; // 14400 bit/s
+const u_short BR_16800 = 6; // 16800 bit/s
+const u_short BR_19200 = 7; // 19200 bit/s
+const u_short BR_21600 = 8; // 21600 bit/s
+const u_short BR_24000 = 9; // 24000 bit/s
+const u_short BR_26400 = 10; // 26400 bit/s
+const u_short BR_28800 = 11; // 28800 bit/s
+const u_short BR_31200 = 12; // 31200 bit/s
+const u_short BR_33600 = 13; // 33600 bit/s
+const u_short BR_ALL = BIT(BR_33600+1)-1;
-const int WD_1728 = 0; // 1728 pixels in 215 mm
-const int WD_2048 = 1; // 2048 pixels in 255 mm
-const int WD_2432 = 2; // 2432 pixels in 303 mm
-const int WD_1216 = 3; // 1216 pixels in 151 mm
-const int WD_864 = 4; // 864 pixels in 107 mm
-const int WD_ALL = BIT(WD_864+1)-1;
+const u_short WD_1728 = 0; // 1728 pixels in 215 mm
+const u_short WD_2048 = 1; // 2048 pixels in 255 mm
+const u_short WD_2432 = 2; // 2432 pixels in 303 mm
+const u_short WD_1216 = 3; // 1216 pixels in 151 mm
+const u_short WD_864 = 4; // 864 pixels in 107 mm
+const u_short WD_ALL = BIT(WD_864+1)-1;
-const int LN_A4 = 0; // A4, 297 mm
-const int LN_B4 = 1; // B4, 364 mm
-const int LN_INF = 2; // Unlimited length
-const int LN_ALL = BIT(LN_INF+1)-1;
+const u_short LN_A4 = 0; // A4, 297 mm
+const u_short LN_B4 = 1; // B4, 364 mm
+const u_short LN_INF = 2; // Unlimited length
+const u_short LN_ALL = BIT(LN_INF+1)-1;
-const int LN_LET = 3; // XXX US Letter size (used internally)
+const u_short LN_LET = 3; // XXX US Letter size (used internally)
-const int DF_1DMR = 0; // 1-D Modified Huffman
-const int DF_2DMR = 1; // 2-D Modified Huffman
-const int DF_2DMRUNCOMP = 2; // 2-D Uncompressed Mode
-const int DF_2DMMR = 3; // 2-D Modified Modified Read
-const int DF_ALL = BIT(DF_2DMMR+1)-1;
+const u_short DF_1DMR = 0; // 1-D Modified Huffman
+const u_short DF_2DMR = 1; // 2-D Modified Huffman
+const u_short DF_2DMRUNCOMP = 2; // 2-D Uncompressed Mode
+const u_short DF_2DMMR = 3; // 2-D Modified Modified Read
+const u_short DF_ALL = BIT(DF_2DMMR+1)-1;
-const int EC_DISABLE = 0; // disable ECM
-const int EC_ENABLE = 1; // enable T.30 Annex A, ECM
-const int EC_ECLHALF = 2; // enable T.30 Annex C, half duplex
-const int EC_ECLFULL = 3; // enable T.30 Annex C, full duplex
-const int EC_ALL = 0x3;
+const u_short EC_DISABLE = 0; // disable ECM
+const u_short EC_ENABLE = 1; // enable T.30 Annex A, ECM
+const u_short EC_ECLHALF = 2; // enable T.30 Annex C, half duplex
+const u_short EC_ECLFULL = 3; // enable T.30 Annex C, full duplex
+const u_short EC_ALL = 0x3;
-const int BF_DISABLE = 0; // disable file transfer modes
-const int BF_ENABLE = 1; // select BFT, T.434
-const int BF_DTM = 2; // select Document Transfer Mode
-const int BF_EDI = 4; // select Edifact Mode
-const int BF_BTM = 8; // select Basic Transfer Mode
-const int BF_CM = 10; // select character mode T.4 Annex D
-const int BF_MM = 20; // select Mixed mode, T.4 Annex E
-const int BF_PM = 40; // select Processable mode, T.505
-const int BF_ALL = 0x3;
+const u_short BF_DISABLE = 0; // disable file transfer modes
+const u_short BF_ENABLE = 1; // select BFT, T.434
+const u_short BF_DTM = 2; // select Document Transfer Mode
+const u_short BF_EDI = 4; // select Edifact Mode
+const u_short BF_BTM = 8; // select Basic Transfer Mode
+const u_short BF_CM = 10; // select character mode T.4 Annex D
+const u_short BF_MM = 20; // select Mixed mode, T.4 Annex E
+const u_short BF_PM = 40; // select Processable mode, T.505
+const u_short BF_ALL = 0x3;
-const int ST_0MS = 0; // scan time/line: 0 ms/0 ms
-const int ST_5MS = 1; // scan time/line: 5 ms/5 ms
-const int ST_10MS2 = 2; // scan time/line: 10 ms/5 ms
-const int ST_10MS = 3; // scan time/line: 10 ms/10 ms
-const int ST_20MS2 = 4; // scan time/line: 20 ms/10 ms
-const int ST_20MS = 5; // scan time/line: 20 ms/20 ms
-const int ST_40MS2 = 6; // scan time/line: 40 ms/20 ms
-const int ST_40MS = 7; // scan time/line: 40 ms/40 ms
-const int ST_ALL = BIT(ST_40MS+1)-1;
+const u_short ST_0MS = 0; // scan time/line: 0 ms/0 ms
+const u_short ST_5MS = 1; // scan time/line: 5 ms/5 ms
+const u_short ST_10MS2 = 2; // scan time/line: 10 ms/5 ms
+const u_short ST_10MS = 3; // scan time/line: 10 ms/10 ms
+const u_short ST_20MS2 = 4; // scan time/line: 20 ms/10 ms
+const u_short ST_20MS = 5; // scan time/line: 20 ms/20 ms
+const u_short ST_40MS2 = 6; // scan time/line: 40 ms/20 ms
+const u_short ST_40MS = 7; // scan time/line: 40 ms/40 ms
+const u_short ST_ALL = BIT(ST_40MS+1)-1;
// post page message codes
-const int PPM_MPS = 0; // another page next, same document
-const int PPM_EOM = 1; // another document next
-const int PPM_EOP = 2; // no more pages or documents
-const int PPM_PRI_MPS = 4; // another page, procedure interrupt
-const int PPM_PRI_EOM = 5; // another doc, procedure interrupt
-const int PPM_PRI_EOP = 6; // all done, procedure interrupt
+const u_short PPM_MPS = 0; // another page next, same document
+const u_short PPM_EOM = 1; // another document next
+const u_short PPM_EOP = 2; // no more pages or documents
+const u_short PPM_PRI_MPS = 4; // another page, procedure interrupt
+const u_short PPM_PRI_EOM = 5; // another doc, procedure interrupt
+const u_short PPM_PRI_EOP = 6; // all done, procedure interrupt
// post page response codes
-const int PPR_MCF = 1; // page good
-const int PPR_RTN = 2; // page bad, retrain requested
-const int PPR_RTP = 3; // page good, retrain requested
-const int PPR_PIN = 4; // page bad, interrupt requested
-const int PPR_PIP = 5; // page good, interrupt requested
+const u_short PPR_MCF = 1; // page good
+const u_short PPR_RTN = 2; // page bad, retrain requested
+const u_short PPR_RTP = 3; // page good, retrain requested
+const u_short PPR_PIN = 4; // page bad, interrupt requested
+const u_short PPR_PIP = 5; // page good, interrupt requested
// important stream transfer codes
+// These are actual (char) recived, so thes aren't unsigned int
const int DLE = 16; // transparent character escape
const int SUB = 26; // <DLE><SUB> => <DLE><DLE> for Class 2.0
const int ETX = 3; // <DLE><ETX> means end of transfer
static void
sanitize(fxStr& s)
{
- for(int i = 0; i < s.length(); i++) {
+ for(u_int i = 0; i < s.length(); i++) {
if (!isascii(s[i]) || !isprint(s[i])) s[i] = '?';
}
}
int
main(int argc, char* argv[])
{
- extern int optind, opterr;
+ extern int optind;
extern char* optarg;
int c;
fxStr file;