]> git.ipfire.org Git - thirdparty/HylaFAX.git/commitdiff
[Bug 260] adds sendfax -z option: destinations in file
authorDarren Nickerson <darren.nickerson@ifax.com>
Sun, 9 Jun 2002 01:23:16 +0000 (01:23 +0000)
committerDarren Nickerson <darren.nickerson@ifax.com>
Sun, 9 Jun 2002 01:23:16 +0000 (01:23 +0000)
Thanks to Dimitry Ketov for this feature, and for Patrice and Lee's fine
work on the cleanup.

man/sendfax.1
sendfax/sendfax.c++

index f30d6d444cfb9b67a135281e34d0218996307916..35ee9f2bc42d434042e58dfdc693e3a7621c3890 100644 (file)
@@ -617,6 +617,20 @@ to the
 .IR faxcover (1)
 program as the sender's company location.
 .TP 12
+.BI \-z " filename"
+Read destinations from
+.I filename
+which contains a list of the destinations formatted identically as 
+destinations for the
+.B \-d
+option, one per line.  Usage of this option is similar to the
+.B \-d
+option and may be done in conjunction with other
+.B \-d
+and
+.B \-z
+options.
+.TP 12
 .B \-v
 Print information on the standard output
 about each conversion and cover sheet
index 07e83ffb9b38f85922070ffccd6c0f9c48ce96e9..c611e414fde37668797fb535296eac52085e9d99 100644 (file)
@@ -44,6 +44,7 @@ private:
     static fxStr dbName;
 
     void addDestination(const char* cp);
+    void addDestinationsFromFile(const char* filename);
     void copyToTemporary(int fin, fxStr& tmpl);
     void fatal(const char* fmt ...);
     void usage();
@@ -87,7 +88,7 @@ sendFaxApp::run(int argc, char** argv)
     int verbose = 0;
     SendFaxJob& proto = getProtoJob();
     db = new FaxDB(tildeExpand(dbName));
-    while ((c = Sys::getopt(argc, argv, "a:b:B:c:C:d:f:F:h:i:I:k:M:P:r:s:t:T:U:V:W:x:X:y:Y:12lmnpvwADENR")) != -1)
+    while ((c = Sys::getopt(argc, argv, "a:b:B:c:C:d:f:F:h:i:I:k:M:P:r:s:t:T:U:V:W:x:X:y:Y:z:12lmnpvwADENR")) != -1)
     switch (c) {
     case '1':                  // restrict to 1D-encoded data
         proto.setDesiredDF(0);
@@ -206,6 +207,9 @@ sendFaxApp::run(int argc, char** argv)
     case 'Y':                  // cover page: sender's location
        proto.setCoverFromLocation(optarg);
        break;
+    case 'z':                  // destinations from file
+       addDestinationsFromFile(optarg);
+       break;
     case '?':
         usage();
         /*NOTREACHED*/
@@ -285,6 +289,28 @@ sendFaxApp::addDestination(const char* cp)
     }
 }
 
+/*
+ * Add a destinations form file
+ */
+void
+sendFaxApp::addDestinationsFromFile(const char* filename)
+{
+    FILE* destfile;
+    char dest[ 256 ];
+
+    if( ( destfile = fopen( filename, "r" ) ) != NULL )
+    {
+       while( fscanf( destfile, "%255s", dest ) != EOF )
+       {
+           addDestination( dest );
+       }
+    }
+    else
+    {
+       fatal("%s: no such file", filename);
+    }
+}
+
 /*
  * Copy data from fin to a temporary file.
  */