Commit 92d14adf 92d14adfcad0aab1359c964c5f123d73c9748f46 by Sergey Poznyakoff

Use util_setenv()

1 parent 0b7f9863
Showing 1 changed file with 14 additions and 24 deletions
...@@ -35,43 +35,33 @@ mail_set (int argc, char **argv) ...@@ -35,43 +35,33 @@ mail_set (int argc, char **argv)
35 else 35 else
36 { 36 {
37 int i = 0; 37 int i = 0;
38 char *value = NULL; 38
39 struct mail_env_entry *entry = NULL;
40 for (i = 1; i < argc; i++) 39 for (i = 1; i < argc; i++)
41 { 40 {
42 if (!strncmp ("no", argv[i], 2)) 41 if (!strncmp ("no", argv[i], 2))
43 { 42 {
44 entry = util_find_env (&argv[i][2]); 43 util_setenv (&argv[i][2], NULL, Mail_env_boolean, 1);
45 if (entry == NULL)
46 return 1;
47 entry->set = 0;
48 if (entry->value)
49 free (entry->value);
50 entry->value = NULL;
51 } 44 }
52 else if (i+1 < argc && argv[i+1][0] == '=') 45 else if (i+1 < argc && argv[i+1][0] == '=')
53 { 46 {
54 entry = util_find_env (argv[i]); 47 int nval;
55 if (entry == NULL) 48 char *name = argv[i];
56 return 1; 49 char *p;
50
57 i += 2; 51 i += 2;
58 if (i >= argc) 52 if (i >= argc)
59 break; 53 break;
60 value = strdup (argv[i]); 54
61 entry->set = 1; 55 nval = strtoul (argv[i], &p, NULL);
62 if (entry->value) 56 if (*p == 0)
63 free (entry->value); 57 util_setenv (name, &nval, Mail_env_number, 1);
64 entry->value = value; 58 else
59 util_setenv (name, argv[i], Mail_env_string, 1);
65 } 60 }
66 else 61 else
67 { 62 {
68 entry = util_find_env(argv[i]); 63 int dummy;
69 if (entry == NULL) 64 util_setenv (argv[i], &dummy, Mail_env_boolean, 1);
70 return 1;
71 entry->set = 1;
72 if (entry->value)
73 free (entry->value);
74 entry->value = NULL;
75 } 65 }
76 } 66 }
77 return 0; 67 return 0;
......