diff options
Diffstat (limited to 'src/mda.c')
-rw-r--r-- | src/mda.c | 26 |
1 files changed, 11 insertions, 15 deletions
@@ -2,7 +2,7 @@ | |||
2 | mda.c | 2 | mda.c |
3 | 3 | ||
4 | This file is part of GNU Anubis. | 4 | This file is part of GNU Anubis. |
5 | Copyright (C) 2005-2014 The Anubis Team. | 5 | Copyright (C) 2005-2024 The Anubis Team. |
6 | 6 | ||
7 | GNU Anubis is free software; you can redistribute it and/or modify it | 7 | GNU Anubis is free software; you can redistribute it and/or modify it |
8 | under the terms of the GNU General Public License as published by the | 8 | under the terms of the GNU General Public License as published by the |
@@ -20,9 +20,6 @@ | |||
20 | 20 | ||
21 | #include "headers.h" | 21 | #include "headers.h" |
22 | #include "extern.h" | 22 | #include "extern.h" |
23 | #define obstack_chunk_alloc malloc | ||
24 | #define obstack_chunk_free free | ||
25 | #include <obstack.h> | ||
26 | 23 | ||
27 | char *from_address; /* Sender address */ | 24 | char *from_address; /* Sender address */ |
28 | 25 | ||
@@ -59,7 +56,7 @@ expand_meta_variable (char *start, size_t size, | |||
59 | /* Expand meta-notations in arguments. */ | 56 | /* Expand meta-notations in arguments. */ |
60 | 57 | ||
61 | static void | 58 | static void |
62 | expand_arg (struct obstack *stk, char *arg) | 59 | expand_arg (struct stringbuf *sb, char *arg) |
63 | { | 60 | { |
64 | char *meta = 0; | 61 | char *meta = 0; |
65 | for (; *arg; arg++) | 62 | for (; *arg; arg++) |
@@ -67,7 +64,7 @@ expand_arg (struct obstack *stk, char *arg) | |||
67 | if (!meta) | 64 | if (!meta) |
68 | { | 65 | { |
69 | if (*arg != '%') | 66 | if (*arg != '%') |
70 | obstack_1grow (stk, *arg); | 67 | stringbuf_add_char (sb, *arg); |
71 | else | 68 | else |
72 | meta = arg; | 69 | meta = arg; |
73 | } | 70 | } |
@@ -79,8 +76,8 @@ expand_arg (struct obstack *stk, char *arg) | |||
79 | size_t size; | 76 | size_t size; |
80 | 77 | ||
81 | expand_meta_variable (meta, arg - meta, &repl, &size); | 78 | expand_meta_variable (meta, arg - meta, &repl, &size); |
82 | obstack_grow (stk, repl, size); | 79 | stringbuf_add (sb, repl, size); |
83 | obstack_1grow (stk, *arg); | 80 | stringbuf_add_char (sb, *arg); |
84 | meta = NULL; | 81 | meta = NULL; |
85 | } | 82 | } |
86 | } | 83 | } |
@@ -92,10 +89,10 @@ expand_arg (struct obstack *stk, char *arg) | |||
92 | size_t size; | 89 | size_t size; |
93 | 90 | ||
94 | expand_meta_variable (meta, arg - meta, &repl, &size); | 91 | expand_meta_variable (meta, arg - meta, &repl, &size); |
95 | obstack_grow (stk, repl, size); | 92 | stringbuf_add (sb, repl, size); |
96 | } | 93 | } |
97 | 94 | ||
98 | obstack_1grow (stk, 0); | 95 | stringbuf_add_char (sb, 0); |
99 | } | 96 | } |
100 | 97 | ||
101 | 98 | ||
@@ -378,24 +375,23 @@ deliver_local_child (const char *recipient, MESSAGE msg) | |||
378 | int i; | 375 | int i; |
379 | char **argv; | 376 | char **argv; |
380 | char *p; | 377 | char *p; |
381 | struct obstack stk; | 378 | struct stringbuf sb = STRINGBUF_INITIALIZER; |
382 | int status; | 379 | int status; |
383 | pid_t pid; | 380 | pid_t pid; |
384 | 381 | ||
385 | /* Create argv vector. | 382 | /* Create argv vector. |
386 | Argv will not be freed. It is no use, since we're going to | 383 | Argv will not be freed. It is no use, since we're going to |
387 | exit anyway. */ | 384 | exit anyway. */ |
388 | obstack_init (&stk); | ||
389 | for (i = 0; session.execargs[i]; i++) | 385 | for (i = 0; session.execargs[i]; i++) |
390 | expand_arg (&stk, session.execargs[i]); | 386 | expand_arg (&sb, session.execargs[i]); |
391 | obstack_1grow (&stk, 0); | ||
392 | 387 | ||
393 | argv = xmalloc (sizeof *argv * (i + 1)); | 388 | argv = xmalloc (sizeof *argv * (i + 1)); |
394 | for (i = 0, p = obstack_finish (&stk); *p; p += strlen (p) + 1, i++) | 389 | for (i = 0, p = stringbuf_finish (&sb); *p; p += strlen (p) + 1, i++) |
395 | argv[i] = p; | 390 | argv[i] = p; |
396 | argv[i] = NULL; | 391 | argv[i] = NULL; |
397 | 392 | ||
398 | remote_server = make_local_connection (session.execpath, argv); | 393 | remote_server = make_local_connection (session.execpath, argv); |
394 | stringbuf_free (&sb); | ||
399 | if (!remote_server) | 395 | if (!remote_server) |
400 | { | 396 | { |
401 | service_unavailable (&remote_client); | 397 | service_unavailable (&remote_client); |