[asterisk-commits] trunk r10871 - in /trunk: ./ apps/ channels/
funcs/ include/asterisk/ pbx/ res/
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Thu Feb 23 10:13:59 MST 2006
Author: kpfleming
Date: Thu Feb 23 11:13:57 2006
New Revision: 10871
URL: http://svn.digium.com/view/asterisk?rev=10871&view=rev
Log:
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
Modified:
trunk/apps/app_sayunixtime.c
trunk/apps/app_voicemail.c
trunk/channels/chan_iax2.c
trunk/channels/chan_misdn.c
trunk/channels/chan_sip.c
trunk/channels/chan_vpb.c
trunk/funcs/func_strings.c
trunk/include/asterisk/strings.h
trunk/pbx/pbx_dundi.c
trunk/res/res_agi.c
trunk/utils.c
Modified: trunk/apps/app_sayunixtime.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_sayunixtime.c?rev=10871&r1=10870&r2=10871&view=diff
==============================================================================
--- trunk/apps/app_sayunixtime.c (original)
+++ trunk/apps/app_sayunixtime.c Thu Feb 23 11:13:57 2006
@@ -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 at the-tilghman.com>
@@ -93,7 +93,7 @@
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);
Modified: trunk/apps/app_voicemail.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_voicemail.c?rev=10871&r1=10870&r2=10871&view=diff
==============================================================================
--- trunk/apps/app_voicemail.c (original)
+++ trunk/apps/app_voicemail.c Thu Feb 23 11:13:57 2006
@@ -3607,7 +3607,7 @@
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;
}
Modified: trunk/channels/chan_iax2.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_iax2.c?rev=10871&r1=10870&r2=10871&view=diff
==============================================================================
--- trunk/channels/chan_iax2.c (original)
+++ trunk/channels/chan_iax2.c Thu Feb 23 11:13:57 2006
@@ -2617,7 +2617,7 @@
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")) {
Modified: trunk/channels/chan_misdn.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_misdn.c?rev=10871&r1=10870&r2=10871&view=diff
==============================================================================
--- trunk/channels/chan_misdn.c (original)
+++ trunk/channels/chan_misdn.c Thu Feb 23 11:13:57 2006
@@ -1,7 +1,7 @@
/*
* Asterisk -- An open source telephony toolkit.
*
- * Copyright (C) 2004, Christian Richter
+ * Copyright (C) 2004 - 2006, Christian Richter
*
* Christian Richter <crich at beronet.com>
*
@@ -2933,7 +2933,7 @@
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);
Modified: trunk/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_sip.c?rev=10871&r1=10870&r2=10871&view=diff
==============================================================================
--- trunk/channels/chan_sip.c (original)
+++ trunk/channels/chan_sip.c Thu Feb 23 11:13:57 2006
@@ -12149,7 +12149,7 @@
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"))
Modified: trunk/channels/chan_vpb.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_vpb.c?rev=10871&r1=10870&r2=10871&view=diff
==============================================================================
--- trunk/channels/chan_vpb.c (original)
+++ trunk/channels/chan_vpb.c Thu Feb 23 11:13:57 2006
@@ -149,7 +149,9 @@
#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 */
Modified: trunk/funcs/func_strings.c
URL: http://svn.digium.com/view/asterisk/trunk/funcs/func_strings.c?rev=10871&r1=10870&r2=10871&view=diff
==============================================================================
--- trunk/funcs/func_strings.c (original)
+++ trunk/funcs/func_strings.c Thu Feb 23 11:13:57 2006
@@ -245,7 +245,7 @@
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)
Modified: trunk/include/asterisk/strings.h
URL: http://svn.digium.com/view/asterisk/trunk/include/asterisk/strings.h?rev=10871&r1=10870&r2=10871&view=diff
==============================================================================
--- trunk/include/asterisk/strings.h (original)
+++ trunk/include/asterisk/strings.h Thu Feb 23 11:13:57 2006
@@ -228,9 +228,10 @@
\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! */
Modified: trunk/pbx/pbx_dundi.c
URL: http://svn.digium.com/view/asterisk/trunk/pbx/pbx_dundi.c?rev=10871&r1=10870&r2=10871&view=diff
==============================================================================
--- trunk/pbx/pbx_dundi.c (original)
+++ trunk/pbx/pbx_dundi.c Thu Feb 23 11:13:57 2006
@@ -1132,16 +1132,15 @@
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 @@
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)
Modified: trunk/res/res_agi.c
URL: http://svn.digium.com/view/asterisk/trunk/res/res_agi.c?rev=10871&r1=10870&r2=10871&view=diff
==============================================================================
--- trunk/res/res_agi.c (original)
+++ trunk/res/res_agi.c Thu Feb 23 11:13:57 2006
@@ -770,7 +770,7 @@
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);
Modified: trunk/utils.c
URL: http://svn.digium.com/view/asterisk/trunk/utils.c?rev=10871&r1=10870&r2=10871&view=diff
==============================================================================
--- trunk/utils.c (original)
+++ trunk/utils.c Thu Feb 23 11:13:57 2006
@@ -1051,9 +1051,10 @@
/*
* 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 @@
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;
More information about the asterisk-commits
mailing list