Codename Pineapple

Home page | Mailing list | Docs

Last updated: Sat Feb 3 05:01:46 2007

Asterisk developer's documentation :: Codename Pineapple


res_realtime.c File Reference


Detailed Description

RealTime CLI.

Author:
Anthony Minessale <anthmct@yahoo.com>

Mark Spencer <markster@digium.com>

Definition in file res_realtime.c.

#include "asterisk.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include "asterisk/file.h"
#include "asterisk/logger.h"
#include "asterisk/channel.h"
#include "asterisk/options.h"
#include "asterisk/pbx.h"
#include "asterisk/config.h"
#include "asterisk/module.h"
#include "asterisk/lock.h"
#include "asterisk/cli.h"

Include dependency graph for res_realtime.c:

Go to the source code of this file.

Functions

 AST_MODULE_INFO_STANDARD (ASTERISK_GPL_KEY,"Realtime Data Lookup/Rewrite")
static int cli_realtime_load (int fd, int argc, char **argv)
static int cli_realtime_update (int fd, int argc, char **argv)
static int load_module (void)
static int unload_module (void)

Variables

static struct ast_cli_entry cli_realtime []
static const char cli_realtime_load_usage []
static const char cli_realtime_update_usage []


Function Documentation

AST_MODULE_INFO_STANDARD ASTERISK_GPL_KEY  ,
"Realtime Data Lookup/Rewrite" 
 

static int cli_realtime_load int  fd,
int  argc,
char **  argv
[static]
 

Definition at line 50 of file res_realtime.c.

References ast_cli(), ast_load_realtime_all(), RESULT_FAILURE, RESULT_SUCCESS, and var.

00051 {
00052    char *header_format = "%30s  %-30s\n";
00053    struct ast_variable *var=NULL;
00054 
00055    if(argc<5) {
00056       ast_cli(fd, "You must supply a family name, a column to match on, and a value to match to.\n");
00057       return RESULT_FAILURE;
00058    }
00059 
00060    var = ast_load_realtime_all(argv[2], argv[3], argv[4], NULL);
00061 
00062    if(var) {
00063       ast_cli(fd, header_format, "Column Name", "Column Value");
00064       ast_cli(fd, header_format, "--------------------", "--------------------");
00065       while(var) {
00066          ast_cli(fd, header_format, var->name, var->value);
00067          var = var->next;
00068       }
00069    } else {
00070       ast_cli(fd, "No rows found matching search criteria.\n");
00071    }
00072    return RESULT_SUCCESS;
00073 }

static int cli_realtime_update int  fd,
int  argc,
char **  argv
[static]
 

Definition at line 75 of file res_realtime.c.

References ast_cli(), ast_update_realtime(), ESS, RESULT_FAILURE, and RESULT_SUCCESS.

00075                                                               {
00076    int res = 0;
00077 
00078    if(argc<7) {
00079       ast_cli(fd, "You must supply a family name, a column to update on, a new value, column to match, and value to to match.\n");
00080       ast_cli(fd, "Ex: realtime update sipfriends name bobsphone port 4343\n will execute SQL as UPDATE sipfriends SET port = 4343 WHERE name = bobsphone\n");
00081       return RESULT_FAILURE;
00082    }
00083 
00084    res = ast_update_realtime(argv[2], argv[3], argv[4], argv[5], argv[6], NULL);
00085 
00086    if(res < 0) {
00087       ast_cli(fd, "Failed to update. Check the debug log for possible SQL related entries.\n");
00088       return RESULT_SUCCESS;
00089    }
00090 
00091        ast_cli(fd, "Updated %d RealTime record%s.\n", res, ESS(res));
00092 
00093    return RESULT_SUCCESS;
00094 }

static int load_module void   )  [static]
 

Definition at line 121 of file res_realtime.c.

References ast_cli_register_multiple(), and cli_realtime.

00122 {
00123    ast_cli_register_multiple(cli_realtime, sizeof(cli_realtime) / sizeof(struct ast_cli_entry));
00124    return 0;
00125 }

static int unload_module void   )  [static]
 

Definition at line 114 of file res_realtime.c.

References ast_cli_unregister_multiple(), ast_module_user_hangup_all, and cli_realtime.

00115 {
00116    ast_cli_unregister_multiple(cli_realtime, sizeof(cli_realtime) / sizeof(struct ast_cli_entry));
00117    ast_module_user_hangup_all();
00118    return 0;
00119 }


Variable Documentation

struct ast_cli_entry cli_realtime[] [static]
 

Definition at line 104 of file res_realtime.c.

const char cli_realtime_load_usage[] [static]
 

Initial value:

"Usage: realtime load <family> <colmatch> <value>\n"
"       Prints out a list of variables using the RealTime driver.\n"

Definition at line 96 of file res_realtime.c.

const char cli_realtime_update_usage[] [static]
 

Initial value:

"Usage: realtime update <family> <colmatch> <value>\n"
"       Update a single variable using the RealTime driver.\n"

Definition at line 100 of file res_realtime.c.


Asterisk is a trademark for Digium, inc.. | Edvina.net | Asterisk.org | This documentation was generated with Doxygen