Dmitry Baikov jackmp-time patch: add jack_get_time, jack_time_to_frames, jack_frames_...
[jack2.git] / common / varargs.h
blob238cb3c1f80f2324a05f6b9412176a37da4e2b0e
1 /*
2 * Copyright (C) 2004 Jack O'Quin
3 *
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.
8 *
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.
18 * $Id: varargs.h,v 1.3 2005/11/23 11:24:00 letz Exp $
21 #ifndef __jack_varargs_h__
22 #define __jack_varargs_h__
24 #include <stdlib.h>
25 #include <stdarg.h>
27 #ifdef __cplusplus
28 extern "C"
30 #endif
32 /* variable argument structure */
33 typedef struct {
34 char *server_name; /* server name */
35 char *load_name; /* load module name */
36 char *load_init; /* initialization string */
38 jack_varargs_t;
40 static char* jack_default_server_name (void) {
41 char *server_name;
42 if ((server_name = getenv("JACK_DEFAULT_SERVER")) == NULL)
43 server_name = "default";
44 return server_name;
47 static inline void jack_varargs_init (jack_varargs_t *va) {
48 memset (va, 0, sizeof(jack_varargs_t));
49 va->server_name = jack_default_server_name();
52 static inline void jack_varargs_parse (jack_options_t options, va_list ap, jack_varargs_t *va) {
53 // initialize default settings
54 jack_varargs_init (va);
56 if ((options & JackServerName)) {
57 char *sn = va_arg(ap, char *);
58 if (sn)
59 va->server_name = sn;
61 if ((options & JackLoadName))
62 va->load_name = va_arg(ap, char *);
63 if ((options & JackLoadInit))
64 va->load_init = va_arg(ap, char *);
67 #ifdef __cplusplus
69 #endif
71 #endif /* __jack_varargs_h__ */