]> git.ipfire.org Git - thirdparty/HylaFAX.git/commitdiff
Bug 503: enhances DynamicLocalID to support all configuration parameters
authorLee Howard <faxguy@howardsilvan.com>
Fri, 18 Jun 2004 20:50:48 +0000 (20:50 +0000)
committerLee Howard <faxguy@howardsilvan.com>
Fri, 18 Jun 2004 20:50:48 +0000 (20:50 +0000)
faxd/Class1.c++
faxd/Class1.h
faxd/Class2.c++
faxd/Class2.h
faxd/FaxModem.h
faxd/FaxServer.c++
faxd/FaxServer.h
faxd/faxGettyApp.c++
man/hylafax-config.4f

index 7204804ce5802d1cbc8e8d95f449982dfaf8b1c3..436f22f004919749cd0df0e1627ae9cab9c0ff51 100644 (file)
@@ -324,7 +324,7 @@ Class1Modem::ready(long ms)
  * Set the local subscriber identification.
  */
 void
-Class1Modem::setLID(const fxStr& number, bool now)
+Class1Modem::setLID(const fxStr& number)
 {
     encodeTSI(lid, number);
 }
index 7ef4bd977b5e9dfa237e84bdf7c0793d464bf12a..716c3a08a92291319b6159fc31f7b5521e1084f3 100644 (file)
@@ -222,7 +222,7 @@ public:
     bool       faxService(bool enableV34);     // switch to fax mode
     bool       reset(long ms);                 // reset modem
     bool       ready(long ms);                 // ready modem
-    void       setLID(const fxStr& number, bool now = false);  // set local id string
+    void       setLID(const fxStr& number);    // set local id string
     bool       supportsPolling() const;        // modem capability
 };
 #endif /* _CLASS1_ */
index 8c32d568f5bec20a00940ac0e7db41aa8468d45f..b81a6394a1cccf2b546d2b21b15795252bac49d7 100644 (file)
@@ -332,12 +332,6 @@ Class2Modem::setupReceive()
     else
        group3opts &= ~GROUP3OPT_FILLBITS;
     atCmd(crCmd);                              // enable receiving
-    /*
-     * Must do this here instead of above because the
-     * station identifier isn't normally setup until
-     * the caller invokes us.
-     */
-    class2Cmd(lidCmd, lid);                    // local station identifier
     /*
      * Enable adaptive-answer support.  If we're configured,
      * we'll act like getty and initiate a login session if
@@ -431,7 +425,7 @@ Class2Modem::parseClass2Capabilities(const char* cap, Class2Params& params)
 bool
 Class2Modem::faxService(bool enableV34)
 {
-    return setupClass2Parameters() && class2Cmd(lidCmd, lid);
+    return setupClass2Parameters();
 }
 
 bool
@@ -499,7 +493,7 @@ Class2Modem::stripQuotes(const char* cp)
  * length is 20 characters (per the spec).
  */
 void
-Class2Modem::setLID(const fxStr& number, bool now)
+Class2Modem::setLID(const fxStr& number)
 {
     lid.resize(0);
     for (u_int i = 0, n = number.length(); i < n; i++) {
@@ -509,7 +503,7 @@ Class2Modem::setLID(const fxStr& number, bool now)
     }
     if (lid.length() > 20)
        lid.resize(20);
-    if (now) class2Cmd(lidCmd, lid);   // for DynamicLocalID
+    class2Cmd(lidCmd, lid);    // for DynamicLocalID
 }
 
 /* 
index 216948e2e8943a72e1552c3a715444839cfdedf7..20fc3acac1d37a3b315667cd542b91fb4fdf3dc8 100644 (file)
@@ -159,7 +159,7 @@ public:
 // miscellaneous
     bool       faxService(bool enableV34);     // switch to fax mode
     bool       reset(long ms);                 // reset modem
-    void       setLID(const fxStr& number, bool now = false);  // set local id string
+    void       setLID(const fxStr& number);    // set local id string
     bool       supportsPolling() const;        // modem capability
     int                lastByte;
 };
index 76ad9548a584559e25c38bccb9cb42de71867baf..cef4feefef5facad830b07dc0ce9a31fa98a65a7 100644 (file)
@@ -171,7 +171,7 @@ public:
     bool isFaxModem() const;
 
 // configuration controls
-    virtual void setLID(const fxStr& number, bool now = false) = 0;
+    virtual void setLID(const fxStr& number) = 0;
     u_int getCapabilities() const;
 // methods for querying modem capabilities
     virtual bool supports2D() const;
index a85fae1e2f5fe94281c417b82f894bd5813eccb5..869af4ddace2e69ad591163b98893593e4aa9a67 100644 (file)
@@ -254,10 +254,10 @@ FaxServer::readConfig(const fxStr& filename)
  * modem (e.g. for Class 2-style modems).
  */
 void
-FaxServer::setLocalIdentifier(const fxStr& lid, bool now)
+FaxServer::setLocalIdentifier(const fxStr& lid)
 {
     ServerConfig::setLocalIdentifier(lid);
     if (modem)
-       modem->setLID(lid, now);
+       modem->setLID(lid);
 }
 const fxStr& FaxServer::getLocalIdentifier() const { return (localIdentifier); }
index 6e49abab350b1776d659600a0d23d5920dc8ab3b..d293b05779380bb8961e53e14bd353d3f2776684 100644 (file)
@@ -88,7 +88,7 @@ protected:
     fxStr      getModemCapabilities() const;
 
     void       readConfig(const fxStr& filename);
-    void       setLocalIdentifier(const fxStr& lid, bool now = false);
+    void       setLocalIdentifier(const fxStr& lid);
 
     void       sendFax(FaxRequest&, FaxMachineInfo&, FaxAcctInfo&, u_int&);
     bool       recvFax(const CallerID& cid);
index 29a294ed1342cba7e6cde3fab53c9f6d35a19926..744a14ec540c3242bbf7dac2d6184665018f4b2c 100644 (file)
@@ -321,7 +321,7 @@ faxGettyApp::answerPhone(AnswerType atype, CallType ctype, const CallerID& cid,
                quote | cid.number | enquote | quote | getModemDevice() | enquote);
            fxStr localid = "";
            int pipefd[2], idlength, status;
-           char dlid[21];      // max CSI size (20) plus '\0'
+           char line[1024];
            pipe(pipefd);
            pid_t pid = fork();
            switch (pid) {
@@ -334,18 +334,21 @@ faxGettyApp::answerPhone(AnswerType atype, CallType ctype, const CallerID& cid,
                    Sys::close(pipefd[1]);
                    execl("/bin/sh", "sh", "-c", (const char*) cmd, (char*) NULL);
                    sleep(1);
-                   exit(0);
+                   exit(1);
                default:
                    Sys::close(pipefd[1]);
-                   idlength = Sys::read(pipefd[0], dlid, sizeof(dlid));
-                   Sys::waitpid(pid, status);
-                   if (status != 0)
-                       logError("Bad exit status %#o for \'%s\'", status, (const char*) cmd);
-                   localid = fxStr(dlid, idlength-1);
-                   FaxServer::setLocalIdentifier(localid, true);       // Class 2 must issue command
+                   {
+                       FILE* fd = fdopen(pipefd[0], "r");
+                       while (fgets(line, sizeof (line)-1, fd)){
+                           line[strlen(line)-1]='\0';          // Nuke \n at end of line
+                           (void) readConfigItem(line);
+                       }
+                       Sys::waitpid(pid, status);
+                       if (status != 0)
+                           logError("Bad exit status %#o for \'%s\'", status, (const char*) cmd);
+                   }
                    break;
            }
-           traceServer("ANSWER: LOCAL ID '%s'", (const char*) localid);
        }
        if (ctype != ClassModem::CALLTYPE_UNKNOWN) {
            /*
index 732b1268c839cfcb56e1a74fbba4e2f441b88947..10c7504ea8eec69110973d5e3c5085233dfd3117 100644 (file)
@@ -131,7 +131,7 @@ CountryCode\(S2     string  \-      local country code
 DestControls\(S1       string  \-      per-destination controls file
 DeviceMode     octal   \s-10600\s+1    protection mode to use for modem device
 DialStringRules\(S2    string  \-      dial string rules file
-DynamicLocalID string  \-      script for dynamic configuration of local ID
+DynamicLocalID string  \-      script for dynamic receive configuration
 FAXNumber      string  \-      facsimile modem phone number
 FaxRcvdCmd     string  \s-1bin/faxrcvd\s+1     notification script for received facsimile
 GettyArgs      string  \-      arguments passed to getty program
@@ -640,16 +640,19 @@ spooling area; e.g.
 .BR etc/dialrules .
 .TP
 .B DynamicLocalID
-The pathname of the optional shell script, e.g. ``etc/localid'', that replaces
-.B LocalIdentifier
+The pathname of the optional shell script, e.g. ``etc/localid'', that 
+makes dynamic configuration changes, i.e., to 
+.B LocalIdentifier,
 based on CIDName, CIDNumber, and device ID.  The script is passed those
 three values as the first, second, and third parameters ($1, $2, $3), 
 respectively when answering an incoming call.  The script can then 
 perform local processing as desired to send on standard output the 
-value with which to replace
-.B LocalIdentifier.
+configuration items to change in a ``parameter:value'' format, i.e.
+``LocalIdentifier: +1.800.555.1212''.  If there are multiple parameters
+to be changed, then each item must be on its own line.
 This is commonly used to dynamically alter the local identification 
-of systems which use DID/DNIS. 
+of systems which use DID/DNIS, but it can also be used to allow different
+modem configurations for different senders.
 Note that this script must be marked as executable by the faxgetty process.
 .TP
 .B FAXNumber