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
This commit is contained in:
parent
efb2e34d29
commit
9c4950dff3
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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")) {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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"))
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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! */
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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);
|
||||
|
|
7
utils.c
7
utils.c
|
@ -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;
|
||||
|
|
Reference in New Issue