diff options
author | kpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b> | 2006-02-23 17:13:57 +0000 |
---|---|---|
committer | kpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b> | 2006-02-23 17:13:57 +0000 |
commit | 9c4950dff36fc6083132969ac592045c5cda464e (patch) | |
tree | a6044b368ffd4c159c9584c7fcf17347cb8cee67 | |
parent | efb2e34d2948dbc76d3be4a3a8805f7baba44bcc (diff) |
add 'consumed' argument to ast_get_time_t, so callers can know how many characters were used in the parser
update pbx_dundi to use ast_get_time_t
eliminate some compiler warnings
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@10871 f38db490-d61c-443f-a65b-d21fe96a405b
-rw-r--r-- | apps/app_sayunixtime.c | 4 | ||||
-rw-r--r-- | apps/app_voicemail.c | 2 | ||||
-rw-r--r-- | channels/chan_iax2.c | 2 | ||||
-rw-r--r-- | channels/chan_misdn.c | 4 | ||||
-rw-r--r-- | channels/chan_sip.c | 2 | ||||
-rw-r--r-- | channels/chan_vpb.c | 2 | ||||
-rw-r--r-- | funcs/func_strings.c | 2 | ||||
-rw-r--r-- | include/asterisk/strings.h | 3 | ||||
-rw-r--r-- | pbx/pbx_dundi.c | 11 | ||||
-rw-r--r-- | res/res_agi.c | 2 | ||||
-rw-r--r-- | utils.c | 7 |
11 files changed, 22 insertions, 19 deletions
diff --git a/apps/app_sayunixtime.c b/apps/app_sayunixtime.c index d3efc0101..09ba838f9 100644 --- a/apps/app_sayunixtime.c +++ b/apps/app_sayunixtime.c @@ -1,7 +1,7 @@ /* * Asterisk -- An open source telephony toolkit. * - * Copyright (c) 2003 Tilghman Lesher. All rights reserved. + * Copyright (c) 2003, 2006 Tilghman Lesher. All rights reserved. * Copyright (c) 2006 Digium, Inc. * * Tilghman Lesher <app_sayunixtime__200309@the-tilghman.com> @@ -93,7 +93,7 @@ static int sayunixtime_exec(struct ast_channel *chan, void *data) AST_STANDARD_APP_ARGS(args, parse); - ast_get_time_t(args.timeval, &unixtime, time(NULL)); + ast_get_time_t(args.timeval, &unixtime, time(NULL), NULL); if (chan->_state != AST_STATE_UP) res = ast_answer(chan); diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c index 7b9a37dfd..dc2db6e0b 100644 --- a/apps/app_voicemail.c +++ b/apps/app_voicemail.c @@ -3607,7 +3607,7 @@ static int play_message_datetime(struct ast_channel *chan, struct ast_vm_user *v struct vm_zone *the_zone = NULL; time_t t; - if (ast_get_time_t(origtime, &t, 0)) { + if (ast_get_time_t(origtime, &t, 0, NULL)) { ast_log(LOG_WARNING, "Couldn't find origtime in %s\n", filename); return 0; } diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c index df647b63d..f6a197783 100644 --- a/channels/chan_iax2.c +++ b/channels/chan_iax2.c @@ -2617,7 +2617,7 @@ static struct iax2_peer *realtime_peer(const char *peername, struct sockaddr_in break; } } else if (!strcasecmp(tmp->name, "regseconds")) { - ast_get_time_t(tmp->value, ®seconds, 0); + ast_get_time_t(tmp->value, ®seconds, 0, NULL); } else if (!strcasecmp(tmp->name, "ipaddr")) { inet_aton(tmp->value, &(peer->addr.sin_addr)); } else if (!strcasecmp(tmp->name, "port")) { diff --git a/channels/chan_misdn.c b/channels/chan_misdn.c index e56f4d2d8..b2f80d6bb 100644 --- a/channels/chan_misdn.c +++ b/channels/chan_misdn.c @@ -1,7 +1,7 @@ /* * Asterisk -- An open source telephony toolkit. * - * Copyright (C) 2004, Christian Richter + * Copyright (C) 2004 - 2006, Christian Richter * * Christian Richter <crich@beronet.com> * @@ -2933,7 +2933,7 @@ static void send_cause2ast(struct ast_channel *ast, struct misdn_bchannel*bc) { void import_ies(struct ast_channel *chan, struct misdn_bchannel *bc) { - char *tmp; + const char *tmp; tmp=pbx_builtin_getvar_helper(chan,"PRI_MODE"); if (tmp) bc->mode=atoi(tmp); diff --git a/channels/chan_sip.c b/channels/chan_sip.c index bf11e5790..848422fd3 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -12149,7 +12149,7 @@ static struct sip_peer *build_peer(const char *name, struct ast_variable *v, int continue; if (realtime && !strcasecmp(v->name, "regseconds")) { - ast_get_time_t(v->value, ®seconds, 0); + ast_get_time_t(v->value, ®seconds, 0, NULL); } else if (realtime && !strcasecmp(v->name, "ipaddr") && !ast_strlen_zero(v->value) ) { inet_aton(v->value, &(peer->addr.sin_addr)); } else if (realtime && !strcasecmp(v->name, "name")) diff --git a/channels/chan_vpb.c b/channels/chan_vpb.c index c6c1dfacf..a43a1f498 100644 --- a/channels/chan_vpb.c +++ b/channels/chan_vpb.c @@ -149,7 +149,9 @@ static VPB_TONE Ringbacktone = {440, 480, 0, -20, -20, -100, 2000, 4000}; #endif /* grunt tone defn's */ +#if 0 static VPB_DETECT toned_grunt = { 3, VPB_GRUNT, 1, 2000, 3000, 0, 0, -40, 0, 0, 0, 40, { { VPB_DELAY, 1000, 0, 0 }, { VPB_RISING, 0, 40, 0 }, { 0, 100, 0, 0 } } }; +#endif static VPB_DETECT toned_ungrunt = { 2, VPB_GRUNT, 1, 2000, 1, 0, 0, -40, 0, 0, 30, 40, { { 0, 0, 0, 0 } } }; /* Use loop polarity detection for CID */ diff --git a/funcs/func_strings.c b/funcs/func_strings.c index e24fc1ea4..26712f8d5 100644 --- a/funcs/func_strings.c +++ b/funcs/func_strings.c @@ -245,7 +245,7 @@ static int acf_strftime(struct ast_channel *chan, char *cmd, char *parse, AST_STANDARD_APP_ARGS(args, parse); - ast_get_time_t(args.epoch, &epochi, time(NULL)); + ast_get_time_t(args.epoch, &epochi, time(NULL), NULL); ast_localtime(&epochi, &tm, args.timezone); if (!args.format) diff --git a/include/asterisk/strings.h b/include/asterisk/strings.h index a48520ad6..c9015544a 100644 --- a/include/asterisk/strings.h +++ b/include/asterisk/strings.h @@ -228,9 +228,10 @@ void ast_join(char *s, size_t len, char * const w[]); \param src String to parse \param dst Destination \param _default Value to use if the string does not contain a valid time + \param consumed The number of characters 'consumed' in the string by the parse (see 'man sscanf' for details) \return zero on success, non-zero on failure */ -int ast_get_time_t(const char *src, time_t *dst, time_t _default); +int ast_get_time_t(const char *src, time_t *dst, time_t _default, int *consumed); /* The realloca lets us ast_restrdupa(), but you can't mix any other ast_strdup calls! */ diff --git a/pbx/pbx_dundi.c b/pbx/pbx_dundi.c index 9d842c69b..0a79b5cd9 100644 --- a/pbx/pbx_dundi.c +++ b/pbx/pbx_dundi.c @@ -1132,16 +1132,15 @@ static int cache_lookup_internal(time_t now, struct dundi_request *req, char *ke int expiration; char fs[256]; time_t timeout; - unsigned int x; + /* Build request string */ if (!ast_db_get("dundi/cache", key, data, sizeof(data))) { ptr = data; - if (sscanf(ptr, "%d|%n", (int *)&x, &length) == 1) { - timeout = x; + if (!ast_get_time_t(ptr, &timeout, 0, &length)) { expiration = timeout - now; if (expiration > 0) { ast_log(LOG_DEBUG, "Found cache expiring in %d seconds!\n", (int)(timeout - now)); - ptr += length; + ptr += length + 1; while((sscanf(ptr, "%d/%d/%d/%n", &(flags.flags), &weight, &tech, &length) == 3)) { ptr += length; term = strchr(ptr, '|'); @@ -2030,11 +2029,9 @@ static void load_password(void) char *last=NULL; char tmp[256]; time_t expired; - unsigned int x; ast_db_get(secretpath, "secretexpiry", tmp, sizeof(tmp)); - if (sscanf(tmp, "%d", (int *)&x) == 1) { - expired = x; + if (!ast_get_time_t(tmp, &expired, 0, NULL)) { ast_db_get(secretpath, "secret", tmp, sizeof(tmp)); current = strchr(tmp, ';'); if (!current) diff --git a/res/res_agi.c b/res/res_agi.c index 5a2e5cc1f..874eb49b8 100644 --- a/res/res_agi.c +++ b/res/res_agi.c @@ -770,7 +770,7 @@ static int handle_saydatetime(struct ast_channel *chan, AGI *agi, int argc, char if (argc > 5 && !ast_strlen_zero(argv[5])) zone = argv[5]; - if (ast_get_time_t(argv[2], &unixtime, 0)) + if (ast_get_time_t(argv[2], &unixtime, 0, NULL)) return RESULT_SHOWUSAGE; res = ast_say_date_with_format(chan, unixtime, argv[3], chan->language, format, zone); @@ -1051,9 +1051,10 @@ void __ast_string_field_index_build(struct ast_string_field_mgr *mgr, /* * get values from config variables. */ -int ast_get_time_t(const char *src, time_t *dst, time_t _default) +int ast_get_time_t(const char *src, time_t *dst, time_t _default, int *consumed) { long t; + int scanned; if (dst == NULL) return -1; @@ -1064,8 +1065,10 @@ int ast_get_time_t(const char *src, time_t *dst, time_t _default) return -1; /* only integer at the moment, but one day we could accept more formats */ - if (sscanf(src, "%ld", &t) == 1) { + if (sscanf(src, "%ld%n", &t, &scanned) == 1) { *dst = t; + if (consumed) + *consumed = scanned; return 0; } else return -1; |