struct ast_include *include_alloc(const char *value, const char *registrar) { struct ast_include *new_include; char *c; int valuebufsz = strlen(value) + 1; char *p; /* allocate new include structure ... */ new_include = ast_calloc(1, sizeof(*new_include) + (valuebufsz * 2)); if (!new_include) { return NULL; } /* Fill in this structure. Use 'p' for assignments, as the fields * in the structure are 'const char *' */ p = new_include->stuff; new_include->name = p; strcpy(p, value); p += valuebufsz; new_include->rname = p; strcpy(p, value); /* Strip off timing info, and process if it is there */ if ((c = strchr(p, ',')) ) { *c++ = '\0'; new_include->hastime = ast_build_timing(&(new_include->timing), c); } new_include->registrar = registrar; return new_include; }
static int iftime(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len) { struct ast_timing timing; char *expr; char *iftrue; char *iffalse; data = ast_strip_quoted(data, "\"", "\""); expr = strsep(&data, "?"); iftrue = strsep(&data, ":"); iffalse = data; if (ast_strlen_zero(expr) || !(iftrue || iffalse)) { ast_log(LOG_WARNING, "Syntax IFTIME(<timespec>?[<true>][:<false>])\n"); return -1; } if (!ast_build_timing(&timing, expr)) { ast_log(LOG_WARNING, "Invalid Time Spec.\n"); return -1; } if (iftrue) iftrue = ast_strip_quoted(iftrue, "\"", "\""); if (iffalse) iffalse = ast_strip_quoted(iffalse, "\"", "\""); ast_copy_string(buf, ast_check_timing(&timing) ? S_OR(iftrue, "") : S_OR(iffalse, ""), len); return 0; }