Adding a "--dry-run" commandline option

Ramkumar Chinchani <[email protected]>
Newsgroups gmane.comp.web.privoxy.devel
Message-ID <20121106123305.2887c51e@raspberrypi>
Hi all,

(I am non-subscribed poster)

One of the components of the freedombox project is the privoxy with
updated frequently from Adblock-plus and https_everywhere
projects. 

http://www.freedomboxfoundation.org/news/freedombox-privoxy/

Give the frequent updates, it is most useful if privoxy had a
way to validate the rules so that one could recover if failure.


Please consider the following patch (tested on Linux only)

diff --git a/jcc.c b/jcc.c
index 721d187..3cbdc3d 100644
--- a/jcc.c
+++ b/jcc.c
@@ -2700,7 +2700,7 @@ static void usage(const char *myname)
 #if defined(unix)
           "[--no-daemon] [--pidfile pidfile] [--pre-chroot-nslookup
hostname] [--user user[.group]] "
 #endif /* defined(unix) */
-          "[--version] [configfile]\n"
+          "[--version] [--dry-run] [configfile]\n"
           "Aborting\n", myname);
 
    exit(2);
@@ -2883,6 +2883,7 @@ int main(int argc, char **argv)
 {
    int argc_pos = 0;
    unsigned int random_seed;
+   int do_dry_run = 0;
 #ifdef unix
    struct passwd *pw = NULL;
    struct group *grp = NULL;
@@ -2954,6 +2955,11 @@ int main(int argc, char **argv)
          exit(0);
       }
 
+      else if (strcmp(argv[argc_pos], "--dry-run") == 0)
+      {
+         do_dry_run = 1;
+      }
+
 #if defined(unix)
 
       else if (strcmp(argv[argc_pos], "--no-daemon" ) == 0)
@@ -3072,6 +3078,15 @@ int main(int argc, char **argv)
    files->next = NULL;
    clients->next = NULL;
 
+   if (do_dry_run) {
+      if (load_config()) {
+         return EXIT_SUCCESS;
+      } 
+      else {
+         return EXIT_FAILURE;
+      }
+   } /* not reached if dry_run */
+
    /* XXX: factor out initialising after the next stable release. */
 #ifdef AMIGA
    InitAmiga();



------------------------------------------------------------------------------
LogMeIn Central: Instant, anywhere, Remote PC access and management.
Stay in control, update software, and manage PCs from one command center
Diagnose problems and improve visibility into emerging IT issues
Automate, monitor and manage. Do more in less time with Central
http://p.sf.net/sfu/logmein12331_d2d
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.