added RCSID
[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 * RCSID $Id$
15 */
16
17 #include <stdlib.h>
18 #include <stdarg.h>
19 #include <string.h>
20 #include <stdio.h>
21
22 #include <freeswan.h>
23
24 #include "../pluto/constants.h"
25 #include "../pluto/defs.h"
26 #include "../pluto/log.h"
27
28 #include "exec.h"
29
30 #define BUF_SIZE 2048
31
32 /**
33 * TODO:
34 * o log stdout with LOG_LEVEL_INFO and stderr with LOG_LEVEL_ERR
35 */
36
37 int
38 starter_exec(const char *fmt, ...)
39 {
40 va_list args;
41 static char buf[BUF_SIZE];
42 int r;
43
44 va_start (args, fmt);
45 vsnprintf(buf, BUF_SIZE-1, fmt, args);
46 buf[BUF_SIZE - 1] = '\0';
47 va_end(args);
48 r = system(buf);
49 DBG(DBG_CONTROL,
50 DBG_log("starter_exec(%s) = %d", buf, r)
51 )
52 return r;
53 }
54