varargs.h

00001 /*
00002 *  Copyright (C) 2004 Jack O'Quin
00003 *  
00004 *  This program is free software; you can redistribute it and/or modify
00005 *  it under the terms of the GNU Lesser General Public License as published by
00006 *  the Free Software Foundation; either version 2.1 of the License, or
00007 *  (at your option) any later version.
00008 *  
00009 *  This program is distributed in the hope that it will be useful,
00010 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 *  GNU Lesser General Public License for more details.
00013 *  
00014 *  You should have received a copy of the GNU Lesser General Public License
00015 *  along with this program; if not, write to the Free Software 
00016 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00017 *
00018 *  $Id: varargs.h,v 1.3 2005/11/23 11:24:00 letz Exp $
00019 */
00020 
00021 #ifndef __jack_varargs_h__
00022 #define __jack_varargs_h__
00023 
00024 #include <stdlib.h>
00025 #include <stdarg.h>
00026 
00027 #ifdef __cplusplus
00028 extern "C"
00029 {
00030 #endif
00031 
00032     /* variable argument structure */
00033     typedef struct {
00034         char *server_name;              /* server name */
00035         char *load_name;                /* load module name */
00036         char *load_init;                /* initialization string */
00037     }
00038     jack_varargs_t;
00039 
00040     static char* jack_default_server_name (void) {
00041         char *server_name;
00042         if ((server_name = getenv("JACK_DEFAULT_SERVER")) == NULL)
00043             server_name = "default";
00044         return server_name;
00045     }
00046 
00047     static inline void jack_varargs_init (jack_varargs_t *va) {
00048         memset (va, 0, sizeof(jack_varargs_t));
00049         va->server_name = jack_default_server_name();
00050     }
00051 
00052     static inline void jack_varargs_parse (jack_options_t options, va_list ap, jack_varargs_t *va) {
00053         // initialize default settings
00054         jack_varargs_init (va);
00055 
00056         if ((options & JackServerName)) {
00057             char *sn = va_arg(ap, char *);
00058             if (sn)
00059                 va->server_name = sn;
00060         }
00061         if ((options & JackLoadName))
00062             va->load_name = va_arg(ap, char *);
00063         if ((options & JackLoadInit))
00064             va->load_init = va_arg(ap, char *);
00065     }
00066 
00067 #ifdef __cplusplus
00068 }
00069 #endif
00070 
00071 #endif /* __jack_varargs_h__ */

Generated on Wed Jan 10 11:42:47 2007 for Jackdmp by  doxygen 1.4.5