jack2 codebase
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

76 lines
2.1KB

  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.
  13. *
  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.
  17. *
  18. */
  19. #ifndef __jack_varargs_h__
  20. #define __jack_varargs_h__
  21. #include <stdlib.h>
  22. #include <stdarg.h>
  23. #include <string.h>
  24. #include "types.h"
  25. #ifdef __cplusplus
  26. extern "C"
  27. {
  28. #endif
  29. /* variable argument structure */
  30. typedef struct {
  31. char *server_name; /* server name */
  32. char *load_name; /* load module name */
  33. char *load_init; /* initialization string */
  34. }
  35. jack_varargs_t;
  36. static const char* jack_default_server_name (void)
  37. {
  38. const char *server_name;
  39. if ((server_name = getenv("JACK_DEFAULT_SERVER")) == NULL)
  40. server_name = "default";
  41. return server_name;
  42. }
  43. static inline void jack_varargs_init (jack_varargs_t *va)
  44. {
  45. memset (va, 0, sizeof(jack_varargs_t));
  46. va->server_name = (char*)jack_default_server_name();
  47. }
  48. static inline void jack_varargs_parse (jack_options_t options, va_list ap, jack_varargs_t *va)
  49. {
  50. // initialize default settings
  51. jack_varargs_init (va);
  52. if ((options & JackServerName)) {
  53. char *sn = va_arg(ap, char *);
  54. if (sn)
  55. va->server_name = sn;
  56. }
  57. if ((options & JackLoadName))
  58. va->load_name = va_arg(ap, char *);
  59. if ((options & JackLoadInit))
  60. va->load_init = va_arg(ap, char *);
  61. }
  62. #ifdef __cplusplus
  63. }
  64. #endif
  65. #endif /* __jack_varargs_h__ */