LOCAL_USER_DECL;
-static void apply_options(struct ast_vm_user *vmu, char *options)
+static void populate_defaults(struct ast_vm_user *vmu)
{
- /* Destructively Parse options and apply */
- char *stringp = ast_strdupa(options);
- char *s;
- char *var, *value;
+ vmu->attach = -1;
if (reviewvm)
vmu->review = 1;
if (calloper)
strncpy(vmu->callback, callcontext, sizeof(vmu->callback) -1);
if (dialcontext)
strncpy(vmu->dialout, dialcontext, sizeof(vmu->dialout) -1);
+}
+
+static void apply_options(struct ast_vm_user *vmu, char *options)
+{
+ /* Destructively Parse options and apply */
+ char *stringp = ast_strdupa(options);
+ char *s;
+ char *var, *value;
+
while((s = strsep(&stringp, "|"))) {
value = s;
if ((var = strsep(&value, "=")) && value) {
/* fprintf(stderr,"postgres find_user:\n"); */
if (retval) {
- *retval->mailbox='\0';
- *retval->context='\0';
- strcpy(retval->password, "NULL");
- *retval->fullname='\0';
- *retval->email='\0';
- *retval->pager='\0';
- *retval->serveremail='\0';
- retval->attach=-1;
+ memset(retval, 0, sizeof(struct ast_vm_user));
retval->alloced=1;
- retval->next=NULL;
if (mailbox) {
strcpy(retval->mailbox, mailbox);
}
{
strcpy(retval->context, "default");
}
+ populate_defaults(retval);
sprintf(query, "SELECT password,fullname,email,pager,options FROM voicemail WHERE context='%s' AND mailbox='%s'", retval->context, mailbox);
/* fprintf(stderr,"postgres find_user: query = %s\n",query); */
memset(vmu, 0, sizeof(struct ast_vm_user));
strncpy(vmu->context, context, sizeof(vmu->context) - 1);
strncpy(vmu->mailbox, mbox, sizeof(vmu->mailbox) - 1);
- vmu->attach = -1;
+ populate_defaults(vmu);
stringp = tmp;
if ((s = strsep(&stringp, ",")))
strncpy(vmu->password, s, sizeof(vmu->password) - 1);