Apply srcfactor.diff patch for ticket #162.
[jack2.git] / common / varargs.h
blobd1442fd30d9b34965ac756394ea6ae270c60fc2d
1 /*
2 * Copyright (C) 2004 Jack O'Quin
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; either version 2.1 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 #ifndef __jack_varargs_h__
21 #define __jack_varargs_h__
23 #include <stdlib.h>
24 #include <stdarg.h>
25 #include <string.h>
26 #include "types.h"
28 #ifdef __cplusplus
29 extern "C"
31 #endif
33 /* variable argument structure */
34 typedef struct {
35 char *server_name; /* server name */
36 char *load_name; /* load module name */
37 char *load_init; /* initialization string */
39 jack_varargs_t;
41 static const char* jack_default_server_name (void)
43 const char *server_name;
44 if ((server_name = getenv("JACK_DEFAULT_SERVER")) == NULL)
45 server_name = "default";
46 return server_name;
49 static inline void jack_varargs_init (jack_varargs_t *va)
51 memset (va, 0, sizeof(jack_varargs_t));
52 va->server_name = (char*)jack_default_server_name();
55 static inline void jack_varargs_parse (jack_options_t options, va_list ap, jack_varargs_t *va)
57 // initialize default settings
58 jack_varargs_init (va);
60 if ((options & JackServerName)) {
61 char *sn = va_arg(ap, char *);
62 if (sn)
63 va->server_name = sn;
65 if ((options & JackLoadName))
66 va->load_name = va_arg(ap, char *);
67 if ((options & JackLoadInit))
68 va->load_init = va_arg(ap, char *);
71 #ifdef __cplusplus
73 #endif
75 #endif /* __jack_varargs_h__ */