Rebuild library.lo after changing ./configure options
[strongswan.git] / src / starter / exec.c
1 /* strongSwan IPsec exec helper function
2 * Copyright (C) 2001-2002 Mathieu Lafon - Arkoon Network Security
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
8 *
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
11 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * for more details.
13 */
14
15 #include <stdlib.h>
16 #include <stdarg.h>
17 #include <string.h>
18 #include <stdio.h>
19
20 #include <freeswan.h>
21
22 #include "../pluto/constants.h"
23 #include "../pluto/defs.h"
24 #include "../pluto/log.h"
25
26 #include "exec.h"
27
28 #define BUF_SIZE 2048
29
30 /**
31 * TODO:
32 * o log stdout with LOG_LEVEL_INFO and stderr with LOG_LEVEL_ERR
33 */
34
35 int
36 starter_exec(const char *fmt, ...)
37 {
38 va_list args;
39 static char buf[BUF_SIZE];
40 int r;
41
42 va_start (args, fmt);
43 vsnprintf(buf, BUF_SIZE-1, fmt, args);
44 buf[BUF_SIZE - 1] = '\0';
45 va_end(args);
46 r = system(buf);
47 DBG(DBG_CONTROL,
48 DBG_log("starter_exec(%s) = %d", buf, r)
49 )
50 return r;
51 }
52