]> git.ipfire.org Git - thirdparty/HylaFAX.git/commitdiff
configure fix for linux to find the socklen_t type correctly. v40pl2-rjc11
authorRobert Colquhoun <rjc@trump.net.au>
Thu, 17 Jun 1999 11:05:36 +0000 (11:05 +0000)
committerRobert Colquhoun <rjc@trump.net.au>
Thu, 17 Jun 1999 11:05:36 +0000 (11:05 +0000)
Also some code formatting fixes(there seems to be a nasty mix
of tabs and spaces in the code).

configure
util/FaxClient.c++
util/FaxClient.h
util/FaxConfig.h
util/SendFaxClient.h

index 730de4099930f9dcfc14d3e310e7e60f90a6f131..8e7d9d2d604f084b976e0f7e6db0ea1217eb4654 100755 (executable)
--- a/configure
+++ b/configure
@@ -2290,7 +2290,7 @@ BuildPortDotH()
        *)              CONFIG_SOCKARGLENTYPE=int;;
        esac
     }
-    TYPES_H="$TYPES_H socketbits.h"
+    TYPES_H="$TYPES_H sys/socket.h"
     CheckVarDecl socklen_t "typedef $CONFIG_SOCKARGLENTYPE socklen_t;" $TYPES_H
 
     #
index 4f5d8bfc7c80da2e7f43a5e01aad5399b42f032e..420f8d4d50fa154f98cf44307d84256cf4252e89 100644 (file)
@@ -464,19 +464,18 @@ bool
 FaxClient::setTimeZone(u_int v)
 {
     if (!isLoggedIn()) {               // set and mark pending accordingly
-       if (0 < v && v < N(tzoneNames)) {
-           tzone = v;
-           if (v == TZ_GMT)
-               state &= ~FS_TZPEND;
-           else
-               state |= FS_TZPEND;
-       } else {
-           printError("Bad time zone parameter value %u.", v);
-           return (false);
-       }
-       return (true);
-    } else                             // pass directly to server
-       return setCommon(tzoneParam, v);
+        if (0 < v && v < N(tzoneNames)) {
+            tzone = v;
+            if (v == TZ_GMT) state &= ~FS_TZPEND;
+            else state |= FS_TZPEND;
+        } else {
+            printError("Bad time zone parameter value %u.", v);
+            return (false);
+        }
+        return (true);
+    } else {                           // pass directly to server
+        return setCommon(tzoneParam, v);
+    }
 }
 
 /*
@@ -507,11 +506,12 @@ FaxClient::initDataConn(fxStr& emsg)
 {
     closeDataConn();
     if (transport) {
-       if (!transport->initDataConn(emsg)) {
-           if (emsg == "")
-               emsg = "Unable to initialize data connection to server";
-           return (false);
-       }
+        if (!transport->initDataConn(emsg)) {
+            if (emsg == "") {
+                emsg = "Unable to initialize data connection to server";
+            }
+            return (false);
+        }
     }
     return (true);
 }
@@ -520,11 +520,12 @@ bool
 FaxClient::openDataConn(fxStr& emsg)
 {
     if (transport) {
-       if (!transport->openDataConn(emsg)) {
-           if (emsg == "")
-               emsg = "Unable to open data connection to server";
-           return (false);
-       }
+        if (!transport->openDataConn(emsg)) {
+            if (emsg == "") {
+               emsg = "Unable to open data connection to server";
+            }
+               return (false);
+        }
     }
     return (true);
 }
@@ -533,8 +534,8 @@ void
 FaxClient::closeDataConn(void)
 {
     if (fdData >= 0) {
-       transport->closeDataConn(fdData);
-       fdData = -1;
+        transport->closeDataConn(fdData);
+        fdData = -1;
     }
 }
 
@@ -542,32 +543,32 @@ bool
 FaxClient::abortDataConn(fxStr& emsg)
 {
     if (fdData >= 0 && transport) {
-       fflush(fdOut);
-       if (!transport->abortCmd(emsg)) {
-           if (emsg == "")
-               emsg = "Unable to abort data connection to server";
-           return (false);
-       }
+        fflush(fdOut);
+        if (!transport->abortCmd(emsg)) {
+            if (emsg == "") {
+               emsg = "Unable to abort data connection to server";
+            }
+               return (false);
+        }
 #ifdef notdef
-       /*
-        * Flush data from data connection.
-        */
-       int flags = fcntl(fdData, F_GETFL, 0);
-       fcntl(fdData, F_SETFL, flags | FNONBLK);
-       while (Sys::read(fdData, buf, sizeof (buf)) > 0)
-           ;
-       fcntl(fdData, F_SETFL, flags);
+        /*
+         * Flush data from data connection.
+         */
+        int flags = fcntl(fdData, F_GETFL, 0);
+        fcntl(fdData, F_SETFL, flags | FNONBLK);
+        while (Sys::read(fdData, buf, sizeof (buf)) > 0);
+        fcntl(fdData, F_SETFL, flags);
 #endif
-       /*
-        * Server should send a reply that acknowledges the
-        * 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
-           unexpectedResponse(emsg);
-           return (false);
-       }
+        /*
+         * Server should send a reply that acknowledges the
+         * 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
+            unexpectedResponse(emsg);
+            return (false);
+        }
     }
     return (true);
 }
@@ -616,26 +617,25 @@ int
 FaxClient::vcommand(const char* fmt, va_list ap)
 {
     if (getVerbose()) {
-       if (strncasecmp("PASS ", fmt, 5) == 0)
-           traceServer("-> PASS XXXX");
-       else if (strncasecmp("ADMIN ", fmt, 6) == 0)
-           traceServer("-> ADMIN XXXX");
-       else {
-           char buf[128];
-           sprintf(buf, "-> %s", fmt);
-           vtraceServer(buf, ap);
-       }
+        if (strncasecmp("PASS ", fmt, 5) == 0) {
+            traceServer("-> PASS XXXX");
+        } else if (strncasecmp("ADMIN ", fmt, 6) == 0) {
+            traceServer("-> ADMIN XXXX");
+        } else {
+            char buf[128];
+            sprintf(buf, "-> %s", fmt);
+            vtraceServer(buf, ap);
+        }
     }
     if (fdOut == NULL) {
-       printError("No control connection for command");
-       code = -1;
-       return (0);
+        printError("No control connection for command");
+        code = -1;
+        return (0);
     }
     vfprintf(fdOut, fmt, ap);
     fputs("\r\n", fdOut);
     (void) fflush(fdOut);
-    int r = getReply(strncmp(fmt, "QUIT", 4) == 0);
-    return (r);
+    return (getReply(strncmp(fmt, "QUIT", 4) == 0));
 }
 
 /*
@@ -650,15 +650,12 @@ FaxClient::vcommand(const char* fmt, va_list ap)
 static int
 getReplyCode(const char* cp)
 {
-    if (!isdigit(cp[0]))
-       return (0);
+    if (!isdigit(cp[0])) return (0);
     int c = (cp[0] - '0');
-    if (!isdigit(cp[1]))
-       return (0);
-    c = 10*c + (cp[1]-'0');
-    if (!isdigit(cp[2]))
-       return (0);
-    c = 10*c + (cp[2]-'0');
+    if (!isdigit(cp[1])) return (0);
+    c = 10 * c + (cp[1] - '0');
+    if (!isdigit(cp[2])) return (0);
+    c = 10 * c + (cp[2] - '0');
     return ((cp[3] == ' ' || cp[3] == '-') ? c : 0);
 }
 
@@ -677,57 +674,58 @@ FaxClient::getReply(bool expecteof)
     int firstCode = 0;
     bool continuation = false;
     do {
-       lastResponse.resize(0);
-       int c;
-       while ((c = getc(fdIn)) != '\n') {
-           if (c == IAC) {     // handle telnet commands
-               switch (c = getc(fdIn)) {
-               case WILL:
-               case WONT:
-                   c = getc(fdIn);
-                   fprintf(fdOut, "%c%c%c", IAC, DONT, c);
-                   (void) fflush(fdOut);
-                   break;
-               case DO:
-               case DONT:
-                   c = getc(fdIn);
-                   fprintf(fdOut, "%c%c%c", IAC, WONT, c);
-                   (void) fflush(fdOut);
-                   break;
-               default:
-                   break;
-               }
-               continue;
-           }
-           if (c == EOF) {
-               if (expecteof) {
-                   code = 221;
-                   return (0);
-               } else {
-                   lostServer();
-                   code = 421;
-                   return (4);
-               }
-           }
-           if (c != '\r')
-               lastResponse.append(c);
-       }
-       if (getVerbose())
-           traceServer("%s", (const char*) lastResponse);
-       code = getReplyCode(lastResponse);
-       if (code != 0) {                        // found valid reply code
-           if (lastResponse[3] == '-') {       // continuation line
-               if (firstCode == 0)             // first line of reponse
-                   firstCode = code;
-               continuation = true;
-           } else if (code == firstCode)       // end of continued reply
-               continuation = false;
-       }
+        lastResponse.resize(0);
+        int c;
+        while ((c = getc(fdIn)) != '\n') {
+            if (c == IAC) {     // handle telnet commands
+               switch (c = getc(fdIn)) {
+               case WILL:
+                case WONT:
+                   c = getc(fdIn);
+                   fprintf(fdOut, "%c%c%c", IAC, DONT, c);
+                    (void) fflush(fdOut);
+                    break;
+                case DO:
+                case DONT:
+                    c = getc(fdIn);
+                    fprintf(fdOut, "%c%c%c", IAC, WONT, c);
+                    (void) fflush(fdOut);
+                    break;
+                default:
+                    break;
+                }
+                continue;
+            }
+            if (c == EOF) {
+               if (expecteof) {
+                    code = 221;
+                    return (0);
+                } else {
+                    lostServer();
+                    code = 421;
+                    return (4);
+                }
+            }
+            if (c != '\r') lastResponse.append(c);
+        }
+        if (getVerbose()) {
+            traceServer("%s", (const char*) lastResponse);
+        }
+        code = getReplyCode(lastResponse);
+        if (code != 0) {                       // found valid reply code
+            if (lastResponse[3] == '-') {      // continuation line
+                if (firstCode == 0)            // first line of reponse
+                    firstCode = code;
+                continuation = true;
+            } else if (code == firstCode)      // end of continued reply
+                continuation = false;
+        }
     } while (continuation || code == 0);
 
-    if (code == 421)                           // server closed connection
-       lostServer();
-    return (code/100);
+    if (code == 421) { // server closed connection
+        lostServer();
+    }
+    return code / 100;
 }
 
 /*
@@ -746,26 +744,27 @@ FaxClient::extract(u_int& pos, const char* pattern, fxStr& result,
     fxStr pat(pattern);
     u_int l = lastResponse.find(pos, pat);
     if (l == lastResponse.length()) {          // try inverse-case version
-       if (isupper(pattern[0]))
-           pat.lowercase();
-       else
-           pat.raisecase();
-       l = lastResponse.find(pos, pat);
+        if (isupper(pattern[0])) {
+            pat.lowercase();
+        } else {
+            pat.raisecase();
+        }
+        l = lastResponse.find(pos, pat);
     }
     if (l == lastResponse.length()) {
-       protocolBotch(emsg, ": No \"%s\" in %s response: %s",
-           pattern, cmd, (const char*) lastResponse);
-       return (false);
+        protocolBotch(emsg, ": No \"%s\" in %s response: %s",
+            pattern, cmd, (const char*) lastResponse);
+        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);
+        protocolBotch(emsg, ": Null %s in %s response: %s",
+            pattern, cmd, (const char*) lastResponse);
+        return false;
     }
     pos = l;                                   // update position
-    return (true);
+    return true;
 }
 
 /*
@@ -776,33 +775,35 @@ bool
 FaxClient::newJob(fxStr& jobid, fxStr& groupid, fxStr& emsg)
 {
     if (command("JNEW") == COMPLETE) {
-       if (code == 200) {
-           /*
-            * The response should be of the form:
-            *
-            * 200 ... jobid: xxxx groupid: yyyy.
-            *
-            * where xxxx is the ID for the new job and yyyy is the
-            * ID of the new job's group.
-            */
-           u_int l = 0;
-           if (extract(l, "jobid:", jobid, "JNEW", emsg) &&
-               extract(l, "groupid:", groupid, "JNEW", emsg)) {
-               /*
-                * Force job and groupd IDs to be numeric;
-                * this deals with servers that want to append
-                * punctuation such as ``,'' or ``.''.
-                */
-               jobid.resize(jobid.skip(0, "0123456789"));
-               groupid.resize(groupid.skip(0, "0123456789"));
-               curjob = jobid;
-               return (true);
-           }
-       } else
-           unexpectedResponse(emsg);
-    } else
-       emsg = lastResponse;
-    return (false);
+        if (code == 200) {
+            /*
+             * The response should be of the form:
+             *
+             * 200 ... jobid: xxxx groupid: yyyy.
+             *
+             * where xxxx is the ID for the new job and yyyy is the
+             * ID of the new job's group.
+             */
+            u_int l = 0;
+            if (extract(l, "jobid:", jobid, "JNEW", emsg) &&
+                    extract(l, "groupid:", groupid, "JNEW", emsg)) {
+                /*
+                 * Force job and groupd IDs to be numeric;
+                 * this deals with servers that want to append
+                 * punctuation such as ``,'' or ``.''.
+                 */
+                jobid.resize(jobid.skip(0, "0123456789"));
+                groupid.resize(groupid.skip(0, "0123456789"));
+                curjob = jobid;
+                return true;
+            }
+        } else {
+            unexpectedResponse(emsg);
+        }
+    } else {
+        emsg = lastResponse;
+    }
+    return false;
 }
 
 /*
@@ -812,11 +813,12 @@ bool
 FaxClient::setCurrentJob(const char* jobid)
 {
     if (strcasecmp(jobid, curjob) != 0) {
-       if (command("JOB %s", jobid) != COMPLETE)
-           return (false);
-       curjob = jobid;
+        if (command("JOB %s", jobid) != COMPLETE) {
+            return false;
+        }
+        curjob = jobid;
     }
-    return (true);
+    return true;
 }
 
 bool
@@ -824,58 +826,68 @@ FaxClient::jobParm(const char* name, const fxStr& value)
 {
     return jobParm(name, (const char*) value);
 }
+
 bool
 FaxClient::jobParm(const char* name, const char* value)
 {
     return (command("JPARM %s \"%s\"", name, value) == COMPLETE);
 }
+
 bool
 FaxClient::jobParm(const char* name, bool b)
 {
     return (command("JPARM %s %s", name, b ? "YES" : "NO") == COMPLETE);
 }
+
 bool
 FaxClient::jobParm(const char* name, u_int v)
 {
     return (command("JPARM %s %u", name, v) == COMPLETE);
 }
+
 bool
 FaxClient::jobParm(const char* name, float v)
 {
     return (command("JPARM %s %g", name, v) == COMPLETE);
 }
+
 bool
 FaxClient::jobSendTime(const struct tm tm)
 {
     return (command("JPARM SENDTIME %d%02d%02d%02d%02d"
-       , tm.tm_year+1900
-       , tm.tm_mon+1
-       , tm.tm_mday
-       , tm.tm_hour
-       , tm.tm_min
-       ) == COMPLETE);
+        , tm.tm_year+1900
+        , tm.tm_mon+1
+        , tm.tm_mday
+        , tm.tm_hour
+        , tm.tm_min
+        ) == COMPLETE);
 }
+
 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);
+        tv/(24*60*60), (tv/(60*60))%24, (tv/60)%60) == COMPLETE);
 }
+
 bool
 FaxClient::jobRetryTime(u_long tv)
 {
     return (command("JPARM RETRYTIME %02d%02d", tv/60, tv%60) == COMPLETE);
 }
+
 bool
 FaxClient::jobCover(const char* docname)
 {
     return (command("JPARM COVER %s", docname) == COMPLETE);
 }
+
 bool
 FaxClient::jobDocument(const char* docname)
 {
     return (command("JPARM DOCUMENT %s", docname) == COMPLETE);
 }
+
 bool
 FaxClient::jobPollRequest(const char* sep, const char* pwd)
 {
index 1541030a1bc0beeadb35d78dce8aea9bf99f9bab..7d0f094422da8994a10480b9170e6ae6bc145d76 100644 (file)
@@ -35,61 +35,61 @@ class Transport;
 class FaxClient : public FaxConfig {
 public:
     enum {                     // command reply codes
-       PRELIM    = 1,          // positive preliminary
-       COMPLETE  = 2,          // positive completion
-       CONTINUE  = 3,          // positive intermediate
-       TRANSIENT = 4,          // transient negative completion
-       ERROR     = 5           // permanent negative completion
+        PRELIM   = 1,          // positive preliminary
+        COMPLETE  = 2,         // positive completion
+        CONTINUE  = 3,         // positive intermediate
+        TRANSIENT = 4,         // transient negative completion
+        ERROR    = 5           // permanent negative completion
     };
     enum {                     // data transfer TYPEs
-       TYPE_A  = 1,            // ASCII
-       TYPE_E  = 2,            // EBCDIC
-       TYPE_I  = 3,            // image
-       TYPE_L  = 4             // local byte size
+        TYPE_A = 1,            // ASCII
+        TYPE_E = 2,            // EBCDIC
+        TYPE_I = 3,            // image
+        TYPE_L = 4             // local byte size
     };
     enum {                     // data transfer file STRUctures
-       STRU_F = 1,             // file (no record structure)
-       STRU_R = 2,             // record structure
-       STRU_P = 3,             // page structure
-       STRU_T = 4              // multi-IFD TIFF
+        STRU_F = 1,            // file (no record structure)
+        STRU_R = 2,            // record structure
+        STRU_P = 3,            // page structure
+        STRU_T = 4             // multi-IFD TIFF
     };
     enum {                     // data transfer MODEs
-       MODE_S = 1,             // stream
-       MODE_B = 2,             // block
-       MODE_C = 3,             // run-length compressed
-       MODE_Z = 4              // zlib compressed
+        MODE_S = 1,            // stream
+        MODE_B = 2,            // block
+        MODE_C = 3,            // run-length compressed
+        MODE_Z = 4             // zlib compressed
     };
     enum {                     // data file FORMats
-       FORM_PS   = 1,          // PostScript Level I
-       FORM_PS2  = 2,          // PostScript Level II
-       FORM_TIFF = 3,          // TIFF
-       FORM_PCL  = 4           // HP PCL5
+        FORM_PS   = 1,         // PostScript Level I
+        FORM_PS2  = 2,         // PostScript Level II
+        FORM_TIFF = 3,         // TIFF
+        FORM_PCL  = 4          // HP PCL5
     };
     enum {
-       TZ_GMT    = 1,          // use GMT timezone for time values
-       TZ_LOCAL  = 2           // use local timezone for time values
+        TZ_GMT   = 1,          // use GMT timezone for time values
+        TZ_LOCAL  = 2          // use local timezone for time values
     };
 
     // NB: the F_ prefixes workaround a bug in the AIX xlC compiler
     struct F_stringtag {
-       const char*      name;
-       fxStr FaxClient::* p;
-       const char*      def;   // NULL is shorthand for ""
+        const char*     name;
+        fxStr FaxClient::* p;
+        const char*     def;   // NULL is shorthand for ""
     };
     struct F_numbertag {
-       const char*      name;
-       u_int FaxClient::*p;
-       u_int            def;
+        const char*     name;
+        u_int FaxClient::*p;
+        u_int           def;
     };
     struct FaxParam {
-       const char* cmd;
-       const char** parmNames;
-       int     NparmNames;
-       u_int   FaxClient::*pv;
+        const char* cmd;
+        const char** parmNames;
+        int    NparmNames;
+        u_int  FaxClient::*pv;
     };
     struct FaxFmtHeader {
-       char    fmt;            // format character used by server
-       const char* title;      // column title to use
+        char   fmt;            // format character used by server
+        const char* title;     // column title to use
     };
 private:
     Transport* transport;      // underlying transport protocol support
@@ -149,7 +149,7 @@ protected:
     void initServerState(void);
     bool jobOp(const char* op, const char* jobid);
     bool extract(u_int& pos, const char* pattern, fxStr& result,
-       const char* cmd, fxStr& emsg);
+        const char* cmd, fxStr& emsg);
     bool storeUnique(const char* cmd, fxStr& docname, fxStr& emsg);
 
     const fxStr& getStatusFormat(u_int flag, const char* cmd, fxStr& fmt);
@@ -275,16 +275,16 @@ public:
      * Retrieve information from the server.
      */
     bool recvData(bool (*f)(void*, const char*, int, fxStr&),
-       void* arg, fxStr& emsg, u_long restart, const char* fmt, ...);
+    void* arg, fxStr& emsg, u_long restart, const char* fmt, ...);
     bool recvZData(bool (*f)(void*, const char*, int, fxStr&),
-       void* arg, fxStr& emsg, u_long restart, const char* fmt, ...);
+    void* arg, fxStr& emsg, u_long restart, const char* fmt, ...);
     /*
      * Job scripting support.
      */
     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);
+        const char* filename, fxStr& emsg);
     /*
      * Status query support.
      */
@@ -306,6 +306,7 @@ public:
     void getModemStatusHeader(fxStr& header);
     void getFileStatusHeader(fxStr& header);
 };
+
 inline const fxStr& FaxClient::getSenderName(void) const{ return senderName; }
 inline const fxStr& FaxClient::getUserName(void) const { return userName; }
 inline const fxStr& FaxClient::getHost(void) const     { return host; }
index 4f110aef2921a8f375aeab346e58cb38cc14629d..b8b32dc14320f7c4719407a1e3901f82c90ad772 100644 (file)
@@ -49,9 +49,9 @@ public:
 
     // generic template for matching names since we can't use a union
     typedef struct {
-       const char* name;               // tag name (lowercase)
-       void* FaxConfig::*p;            // pointer to member of structure
-       void* def;                      // default value
+        const char* name;              // tag name (lowercase)
+        void* FaxConfig::*p;           // pointer to member of structure
+        void* def;                     // default value
     } tags;
 
     // NB: const void* should be const tags* but gcc can't hack it
@@ -68,5 +68,7 @@ public:
     virtual void resetConfig();
     virtual bool updateConfig(const fxStr& filename);
 };
+
 inline u_int FaxConfig::getConfigLineNumber() const { return lineno; }
+
 #endif /* _FaxConfig_ */
index 5b47f6c39b93fb20f075e888433271a285e91572..1b2c739b73c9b614a5b90c308c52d64430cfb2f5 100644 (file)
  * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE 
  * OF THIS SOFTWARE.
  */
+
+/*
+                    SendFaxClient class
+*/
 #ifndef _SendFaxClient_
 #define        _SendFaxClient_
 
@@ -173,9 +177,9 @@ public:
     void setVerbose(bool);
 };
 
-inline SendFaxJob& SendFaxClient::getProtoJob()                   { return proto; }
+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(bool b)             { verbose = b; }
-inline bool SendFaxClient::getVerbose() const             { return verbose; }
+inline const fxStr& SendFaxClient::getSenderName() const { return senderName;}
+inline void SendFaxClient::setVerbose(bool b) { verbose = b; }
+inline bool SendFaxClient::getVerbose() const { return verbose; }
 #endif /* _SendFaxClient_ */