Commit 8e183b75 8e183b755dac4b335859e2747a083ae6c178daf4 by Sergey Poznyakoff

New option --clearpath

1 parent 945de1f1
...@@ -28,12 +28,16 @@ mu_list_t mu_sieve_library_path = NULL; ...@@ -28,12 +28,16 @@ mu_list_t mu_sieve_library_path = NULL;
28 28
29 static error_t sieve_argp_parser (int key, char *arg, struct argp_state *state); 29 static error_t sieve_argp_parser (int key, char *arg, struct argp_state *state);
30 30
31 #define CLEARPATH_OPTION 256
32
31 /* Options used by programs that use extended authentication mechanisms. */ 33 /* Options used by programs that use extended authentication mechanisms. */
32 static struct argp_option sieve_argp_option[] = { 34 static struct argp_option sieve_argp_option[] = {
33 { "includedir", 'I', N_("DIR"), 0, 35 { "includedir", 'I', N_("DIR"), 0,
34 N_("Append directory DIR to the list of directories searched for include files"), 0 }, 36 N_("Append directory DIR to the list of directories searched for include files"), 0 },
35 { "libdir", 'L', N_("DIR"), 0, 37 { "libdir", 'L', N_("DIR"), 0,
36 N_("Append directory DIR to the list of directories searched for library files"), 0 }, 38 N_("Append directory DIR to the list of directories searched for library files"), 0 },
39 { "clearpath", CLEARPATH_OPTION, NULL, 0,
40 N_("Clear Sieve load path"), 0 },
37 { NULL, 0, NULL, 0, NULL, 0 } 41 { NULL, 0, NULL, 0, NULL, 0 }
38 }; 42 };
39 43
...@@ -49,6 +53,12 @@ static struct argp_child sieve_argp_child = { ...@@ -49,6 +53,12 @@ static struct argp_child sieve_argp_child = {
49 0 53 0
50 }; 54 };
51 55
56 static void
57 destroy_string (void *str)
58 {
59 free (str);
60 }
61
52 static error_t 62 static error_t
53 sieve_argp_parser (int key, char *arg, struct argp_state *state) 63 sieve_argp_parser (int key, char *arg, struct argp_state *state)
54 { 64 {
...@@ -64,6 +74,10 @@ sieve_argp_parser (int key, char *arg, struct argp_state *state) ...@@ -64,6 +74,10 @@ sieve_argp_parser (int key, char *arg, struct argp_state *state)
64 plist = &mu_sieve_library_path; 74 plist = &mu_sieve_library_path;
65 break; 75 break;
66 76
77 case CLEARPATH_OPTION:
78 mu_list_destroy (&mu_sieve_library_path);
79 break;
80
67 case ARGP_KEY_INIT: 81 case ARGP_KEY_INIT:
68 #ifdef SIEVE_MODDIR 82 #ifdef SIEVE_MODDIR
69 plist = &mu_sieve_library_path; 83 plist = &mu_sieve_library_path;
...@@ -87,9 +101,10 @@ sieve_argp_parser (int key, char *arg, struct argp_state *state) ...@@ -87,9 +101,10 @@ sieve_argp_parser (int key, char *arg, struct argp_state *state)
87 if (rc) 101 if (rc)
88 { 102 {
89 argp_error (state, "can't create list: %s", 103 argp_error (state, "can't create list: %s",
90 mu_strerror (rc)); 104 mu_strerror (rc));
91 exit (1); 105 exit (1);
92 } 106 }
107 mu_list_set_destroy_item (plist, destroy_string);
93 } 108 }
94 mu_list_append (*plist, strdup (arg)); 109 mu_list_append (*plist, strdup (arg));
95 } 110 }
......