Browse Source

support delete-delay passed as a string

fixes #118
pull/136/head
Richard Fuchs 11 years ago
parent
commit
d9d8f97db0
2 changed files with 25 additions and 1 deletions
  1. +9
    -1
      daemon/call_interfaces.c
  2. +16
    -0
      daemon/str.h

+ 9
- 1
daemon/call_interfaces.c View File

@ -765,8 +765,16 @@ const char *call_delete_ng(bencode_item_t *input, struct callmaster *m, bencode_
} }
} }
delete_delay = bencode_dictionary_get_integer(input, "delete-delay", -1); delete_delay = bencode_dictionary_get_integer(input, "delete-delay", -1);
if (delete_delay == -1)
if (delete_delay == -1) {
delete_delay = bencode_dictionary_get_integer(input, "delete delay", -1); delete_delay = bencode_dictionary_get_integer(input, "delete delay", -1);
if (delete_delay == -1) {
/* legacy support */
str s;
bencode_dictionary_get_str(input, "delete-delay", &s);
if (s.s)
delete_delay = str_to_i(&s, -1);
}
}
if (call_delete_branch(m, &callid, &viabranch, &fromtag, &totag, output, delete_delay)) { if (call_delete_branch(m, &callid, &viabranch, &fromtag, &totag, output, delete_delay)) {
if (fatal) if (fatal)


+ 16
- 0
daemon/str.h View File

@ -61,6 +61,8 @@ INLINE int str_memcmp(const str *s, void *m);
INLINE int str_str(const str *s, const char *sub); INLINE int str_str(const str *s, const char *sub);
/* swaps the contents of two str objects */ /* swaps the contents of two str objects */
INLINE void str_swap(str *a, str *b); INLINE void str_swap(str *a, str *b);
/* parses a string into an int, returns default if conversion fails */
INLINE int str_to_i(str *s, int def);
/* asprintf() analogs */ /* asprintf() analogs */
#define str_sprintf(fmt, a...) __str_sprintf(STR_MALLOC_PADDING fmt, a) #define str_sprintf(fmt, a...) __str_sprintf(STR_MALLOC_PADDING fmt, a)
@ -240,4 +242,18 @@ INLINE void str_swap(str *a, str *b) {
*b = t; *b = t;
} }
INLINE int str_to_i(str *s, int def) {
char c, *ep;
long ret;
if (s->len <= 0)
return def;
c = s->s[s->len];
s->s[s->len] = '\0';
ret = strtol(s->s, &ep, 10);
s->s[s->len] = c;
if (ep == s->s)
return def;
return ret;
}
#endif #endif

Loading…
Cancel
Save