--- manager.c.orig 2004-06-06 20:01:41.000000000 -0700 +++ manager.c 2004-06-06 20:08:59.000000000 -0700 @@ -39,6 +39,7 @@ #include #include #include +#include struct fast_originate_helper { @@ -549,6 +550,66 @@ return 0; } +static int action_dbput(struct mansession *s, struct message *m) +{ + char *family = astman_get_header(m, "Family"); + char *key = astman_get_header(m, "Key"); + char *value = astman_get_header(m, "Value"); + int res; + + if (!strlen(family)) { + astman_send_error(s, m, "No Family specified"); + return 0; + } + if (!strlen(key)) { + astman_send_error(s, m, "No Key specified"); + return 0; + } + + if (!strlen(value)) { + astman_send_error(s, m, "No Value specified"); + return 0; + } + + res = ast_db_put(family, key, value); + + if(!res) + astman_send_ack(s, m, "AstDB Updated"); + else + astman_send_error(s, m, "AstDB update"); + return 0; +} + +static int action_dbget(struct mansession *s, struct message *m) +{ + char *family = astman_get_header(m, "Family"); + char *key = astman_get_header(m, "Key"); + char varval[128]; + int res; + + if (!strlen(family)) { + astman_send_error(s, m, "No Family specified"); + return 0; + } + if (!strlen(key)) { + astman_send_error(s, m, "No Key specified"); + return 0; + } + + + + res = ast_db_get(family, key, varval, sizeof(varval) - 1); + + if(!res){ + ast_cli(s->fd, "Response: Success\r\n" + "%s: %s: %s",family, key, varval); + } + else + astman_send_error(s, m, "AstDB get"); + + return 0; +} + static int action_status(struct mansession *s, struct message *m) { @@ -1234,6 +1295,8 @@ ast_manager_register( "Status", EVENT_FLAG_CALL, action_status, "Status" ); ast_manager_register( "Setvar", EVENT_FLAG_CALL, action_setvar, "Set Channel Variable" ); ast_manager_register( "Getvar", EVENT_FLAG_CALL, action_getvar, "Gets a Channel Variable" ); + ast_manager_register( "DBput", EVENT_FLAG_CALL, action_dbput, "Puts a value into the Asterisk Database" ); + ast_manager_register( "DBget", EVENT_FLAG_CALL, action_dbget, "Gets a value from the Asterisk Database" ); ast_manager_register( "Redirect", EVENT_FLAG_CALL, action_redirect, "Redirect" ); ast_manager_register2("Originate", EVENT_FLAG_CALL, action_originate, "Originate Call", mandescr_originate); ast_manager_register( "MailboxStatus", EVENT_FLAG_CALL, action_mailboxstatus, "Check Mailbox" );