OpenVPN
argv.h
Go to the documentation of this file.
1 /*
2  * OpenVPN -- An application to securely tunnel IP networks
3  * over a single TCP/UDP port, with support for SSL/TLS-based
4  * session authentication and key exchange,
5  * packet encryption, packet authentication, and
6  * packet compression.
7  *
8  * Copyright (C) 2002-2018 OpenVPN Inc <sales@openvpn.net>
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License version 2
12  * as published by the Free Software Foundation.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License along
20  * with this program; if not, write to the Free Software Foundation, Inc.,
21  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22  *
23  *
24  * A printf-like function (that only recognizes a subset of standard printf
25  * format operators) that prints arguments to an argv list instead
26  * of a standard string. This is used to build up argv arrays for passing
27  * to execve.
28  */
29 
30 #ifndef ARGV_H
31 #define ARGV_H
32 
33 #include "buffer.h"
34 
35 struct argv {
36  size_t capacity;
37  size_t argc;
38  char **argv;
39 };
40 
41 struct argv argv_new(void);
42 
43 void argv_reset(struct argv *a);
44 
45 const char *argv_str(const struct argv *a, struct gc_arena *gc, const unsigned int flags);
46 
47 struct argv argv_insert_head(const struct argv *a, const char *head);
48 
49 void argv_msg(const int msglev, const struct argv *a);
50 
51 void argv_msg_prefix(const int msglev, const struct argv *a, const char *prefix);
52 
53 void argv_parse_cmd(struct argv *a, const char *s);
54 
55 void argv_printf(struct argv *a, const char *format, ...)
56 #ifdef __GNUC__
57 #if __USE_MINGW_ANSI_STDIO
58 __attribute__ ((format(gnu_printf, 2, 3)))
59 #else
60 __attribute__ ((format(__printf__, 2, 3)))
61 #endif
62 #endif
63 ;
64 
65 void argv_printf_cat(struct argv *a, const char *format, ...)
66 #ifdef __GNUC__
67 #if __USE_MINGW_ANSI_STDIO
68 __attribute__ ((format(gnu_printf, 2, 3)))
69 #else
70 __attribute__ ((format(__printf__, 2, 3)))
71 #endif
72 #endif
73 ;
74 
75 #endif /* ifndef ARGV_H */
const char * argv_str(const struct argv *a, struct gc_arena *gc, const unsigned int flags)
Definition: argv.c:193
struct argv argv_new(void)
Definition: argv.c:52
void argv_parse_cmd(struct argv *a, const char *s)
Definition: argv.c:337
list flags
size_t capacity
Definition: argv.h:36
char ** argv
Definition: argv.h:38
void argv_msg(const int msglev, const struct argv *a)
Definition: argv.c:206
void argv_printf(struct argv *a, const char *format,...)
Definition: argv.c:318
void argv_msg_prefix(const int msglev, const struct argv *a, const char *prefix)
Definition: argv.c:214
size_t argc
Definition: argv.h:37
void argv_reset(struct argv *a)
Definition: argv.c:60
void argv_printf_cat(struct argv *a, const char *format,...)
Definition: argv.c:328
Garbage collection arena used to keep track of dynamically allocated memory.
Definition: buffer.h:116
Definition: argv.h:35
struct argv argv_insert_head(const struct argv *a, const char *head)
Definition: argv.c:126