From 57e473b61cf373f8d9befb03d359b999eca4262b Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Sat, 4 Sep 2004 00:27:36 +0000 Subject: add support for automatic termination of the daemon after the last client quit remove all gcc warnings add boolean types for tagstruct and modargs git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@178 fefdeb5f-60dc-0310-8127-8f9354f1896f --- polyp/modargs.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'polyp/modargs.c') diff --git a/polyp/modargs.c b/polyp/modargs.c index 87d99ad2..4874d808 100644 --- a/polyp/modargs.c +++ b/polyp/modargs.c @@ -207,6 +207,46 @@ int pa_modargs_get_value_u32(struct pa_modargs *ma, const char *key, uint32_t *v return 0; } +int pa_modargs_get_value_s32(struct pa_modargs *ma, const char *key, int32_t *value) { + const char *v; + char *e; + signed long l; + assert(ma && key && value); + + if (!(v = pa_modargs_get_value(ma, key, NULL))) + return 0; + + if (!*v) + return -1; + + l = strtol(v, &e, 0); + if (*e) + return -1; + + *value = (int32_t) l; + return 0; +} + +int pa_modargs_get_value_boolean(struct pa_modargs *ma, const char *key, int *value) { + const char *v; + assert(ma && key && value); + + if (!(v = pa_modargs_get_value(ma, key, NULL))) + return 0; + + if (!*v) + return -1; + + if (!strcmp(v, "1") || !strcasecmp(v, "yes") || !strcasecmp(v, "y") || !strcasecmp(v, "on")) + *value = 1; + else if (!strcmp(v, "0") || !strcasecmp(v, "no") || !strcasecmp(v, "n") || !strcasecmp(v, "off")) + *value = 0; + else + return -1; + + return 0; +} + int pa_modargs_get_sample_spec(struct pa_modargs *ma, struct pa_sample_spec *rss) { const char *format; uint32_t channels; -- cgit