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.

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