]> git.sur5r.net Git - bacula/bacula/commitdiff
Integrate addition of line count limitation to bsmtp -l from
authorKern Sibbald <kern@sibbald.com>
Mon, 20 Mar 2006 07:13:12 +0000 (07:13 +0000)
committerKern Sibbald <kern@sibbald.com>
Mon, 20 Mar 2006 07:13:12 +0000 (07:13 +0000)
  Sebastian Stark <stark at tuebingen.mpg.de>

git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@2839 91ce42f0-d328-0410-95d8-f526ca767f89

bacula/kes-1.39
bacula/src/tools/bsmtp.c
bacula/src/version.h

index ee005f41c63a329c504b1448fa329fa8bd414618..5d0d8922e5e27aea2c7979a2544ea5a95695cb5b 100644 (file)
@@ -2,6 +2,9 @@
                         Kern Sibbald
 
 General:
+20Mar06
+- Integrate addition of line count limitation to bsmtp -l from
+  Sebastian Stark <stark at tuebingen.mpg.de>
 17Mar06
 - Implement regex test program in tools directory.
 - Attempt to fix time problem with bsmtp with foreign langs.
index cb994bdf20545330d2aa89fe7c4cbff58234a403..5c22b0c830a0833f6fdec6906f31d11180ab85bf 100644 (file)
@@ -125,6 +125,8 @@ _("\n"
 "       -f          set the From: field\n"
 "       -h          use mailhost:port as the SMTP server\n"
 "       -s          set the Subject: field\n"
+"       -r          set the Reply-To: field\n"
+"       -l          set the maximum number of lines that should be sent (default: unlimited)\n"
 "       -?          print this message.\n"
 "\n"), MY_NAME);
 
@@ -142,6 +144,7 @@ int main (int argc, char *argv[])
     struct sockaddr_in sin;
     struct hostent *hp;
     int s, r, i, ch;
+    unsigned long maxlines, lines;
     struct passwd *pwd;
     char *cp, *p;
     time_t now = time(NULL);
@@ -152,8 +155,9 @@ int main (int argc, char *argv[])
    textdomain("bacula");
 
    my_name_is(argc, argv, "bsmtp");
+   maxlines = 0;
 
-   while ((ch = getopt(argc, argv, "c:d:f:h:r:s:?")) != -1) {
+   while ((ch = getopt(argc, argv, "c:d:f:h:r:s:l:?")) != -1) {
       switch (ch) {
       case 'c':
          Dmsg1(20, "cc=%s\n", optarg);
@@ -191,6 +195,11 @@ int main (int argc, char *argv[])
          reply_addr = optarg;
          break;
 
+      case 'l':
+        Dmsg1(20, "maxlines=%s\n", optarg);
+        maxlines = (unsigned long) atol(optarg);
+        break;
+
       case '?':
       default:
          usage();
@@ -359,7 +368,12 @@ hp:
    /*
     *  Send message body
     */
+   lines = 0;
    while (fgets(buf, sizeof(buf), stdin)) {
+      if (maxlines > 0 && ++lines > maxlines) {
+         Dmsg1(20, "skip line because of maxlines limit: %lu\n", maxlines);
+        continue;
+      }
       buf[strlen(buf)-1] = 0;
       if (strcmp(buf, ".") == 0) { /* quote lone dots */
          fprintf(sfp, "..\r\n");
@@ -368,6 +382,11 @@ hp:
       }
    }
 
+   if (lines > maxlines) {
+      Dmsg1(10, "hit maxlines limit: %lu\n", maxlines);
+      fprintf(sfp, "\r\n[maximum of %lu lines exceeded, skipped %lu lines of output]\r\n", maxlines, lines-maxlines);
+   }
+
    /*
     *  Send SMTP quit command
     */
index 575634919145814749fd4ef0442a4fc6822d3ea7..69c46349522a3a90f904b84d4d161858cf6fcc6d 100644 (file)
@@ -4,8 +4,8 @@
 
 #undef  VERSION
 #define VERSION "1.39.6"
-#define BDATE   "17 March 2006"
-#define LSMDATE "17Mar06"
+#define BDATE   "20 March 2006"
+#define LSMDATE "20Mar06"
 
 /* Debug flags */
 #undef  DEBUG