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.

85 lines
2.5KB

  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. jack_uuid_t session_id; /* requested session_id */
  35. }
  36. jack_varargs_t;
  37. static const char* jack_default_server_name (void)
  38. {
  39. const char *server_name;
  40. if ((server_name = getenv("JACK_DEFAULT_SERVER")) == NULL)
  41. server_name = "default";
  42. return server_name;
  43. }
  44. static inline void jack_varargs_init (jack_varargs_t *va)
  45. {
  46. memset (va, 0, sizeof(jack_varargs_t));
  47. va->server_name = (char*)jack_default_server_name();
  48. }
  49. static inline void jack_varargs_parse (jack_options_t options, va_list ap, jack_varargs_t *va)
  50. {
  51. // initialize default settings
  52. jack_varargs_init (va);
  53. if ((options & JackServerName)) {
  54. char *sn = va_arg(ap, char *);
  55. if (sn)
  56. va->server_name = sn;
  57. }
  58. if ((options & JackLoadName))
  59. va->load_name = va_arg(ap, char *);
  60. if ((options & JackLoadInit))
  61. va->load_init = va_arg(ap, char *);
  62. if ((options & JackSessionID)) {
  63. char *sid = va_arg(ap, char *);
  64. if (sid) {
  65. const long long id = atoll( sid );
  66. if (id > 0)
  67. va->session_id = id;
  68. }
  69. }
  70. }
  71. #ifdef __cplusplus
  72. }
  73. #endif
  74. #endif /* __jack_varargs_h__ */