Asterisk - The Open Source Telephony Project GIT-master-7805f28
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Macros Modules Pages
Functions | Variables
app_getcpeid.c File Reference

Get ADSI CPE ID. More...

#include "asterisk.h"
#include "asterisk/lock.h"
#include "asterisk/file.h"
#include "asterisk/channel.h"
#include "asterisk/pbx.h"
#include "asterisk/module.h"
#include "asterisk/adsi.h"
Include dependency graph for app_getcpeid.c:

Go to the source code of this file.

Functions

static void __reg_module (void)
 
static void __unreg_module (void)
 
struct ast_moduleAST_MODULE_SELF_SYM (void)
 
static int cpeid_exec (struct ast_channel *chan, const char *idata)
 
static int cpeid_setstatus (struct ast_channel *chan, char *stuff[], int voice)
 
static int load_module (void)
 
static int unload_module (void)
 

Variables

static struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT , .description = "Get ADSI CPE ID" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = AST_BUILDOPT_SUM, .support_level = AST_MODULE_SUPPORT_DEPRECATED, .load = load_module, .unload = unload_module, .requires = "res_adsi", }
 
static char * app = "GetCPEID"
 
static const struct ast_module_infoast_module_info = &__mod_info
 

Detailed Description

Get ADSI CPE ID.

Author
Mark Spencer marks.nosp@m.ter@.nosp@m.digiu.nosp@m.m.co.nosp@m.m

Definition in file app_getcpeid.c.

Function Documentation

◆ __reg_module()

static void __reg_module ( void  )
static

Definition at line 148 of file app_getcpeid.c.

◆ __unreg_module()

static void __unreg_module ( void  )
static

Definition at line 148 of file app_getcpeid.c.

◆ AST_MODULE_SELF_SYM()

struct ast_module * AST_MODULE_SELF_SYM ( void  )

Definition at line 148 of file app_getcpeid.c.

◆ cpeid_exec()

static int cpeid_exec ( struct ast_channel chan,
const char *  idata 
)
static

Definition at line 70 of file app_getcpeid.c.

71{
72 int res=0;
73 unsigned char cpeid[4];
74 int gotgeometry = 0;
75 int gotcpeid = 0;
76 int width, height, buttons;
77 char *data[4];
78 unsigned int x;
79
80 for (x = 0; x < 4; x++)
81 data[x] = ast_alloca(80);
82
83 strcpy(data[0], "** CPE Info **");
84 strcpy(data[1], "Identifying CPE...");
85 strcpy(data[2], "Please wait...");
86 res = ast_adsi_load_session(chan, NULL, 0, 1);
87 if (res > 0) {
88 cpeid_setstatus(chan, data, 0);
89 res = ast_adsi_get_cpeid(chan, cpeid, 0);
90 if (res > 0) {
91 gotcpeid = 1;
92 ast_verb(3, "Got CPEID of '%02hhx:%02hhx:%02hhx:%02hhx' on '%s'\n",
93 cpeid[0], cpeid[1], cpeid[2], cpeid[3], ast_channel_name(chan));
94 }
95 if (res > -1) {
96 strcpy(data[1], "Measuring CPE...");
97 strcpy(data[2], "Please wait...");
98 cpeid_setstatus(chan, data, 0);
99 res = ast_adsi_get_cpeinfo(chan, &width, &height, &buttons, 0);
100 if (res > -1) {
101 ast_verb(3, "CPE has %d lines, %d columns, and %d buttons on '%s'\n", height, width, buttons, ast_channel_name(chan));
102 gotgeometry = 1;
103 }
104 }
105 if (res > -1) {
106 if (gotcpeid)
107 snprintf(data[1], 80, "CPEID: %02hhx:%02hhx:%02hhx:%02hhx",
108 cpeid[0], cpeid[1], cpeid[2], cpeid[3]);
109 else
110 strcpy(data[1], "CPEID Unknown");
111 if (gotgeometry)
112 snprintf(data[2], 80, "Geom: %dx%d, %d buttons", width, height, buttons);
113 else
114 strcpy(data[2], "Geometry unknown");
115 strcpy(data[3], "Press # to exit");
116 cpeid_setstatus(chan, data, 1);
117 for(;;) {
118 res = ast_waitfordigit(chan, 1000);
119 if (res < 0)
120 break;
121 if (res == '#') {
122 res = 0;
123 break;
124 }
125 }
127 }
128 }
129
130 return res;
131}
int ast_adsi_unload_session(struct ast_channel *chan)
Definition: adsi.c:87
int ast_adsi_get_cpeid(struct ast_channel *chan, unsigned char *cpeid, int voice)
Definition: adsi.c:164
int ast_adsi_load_session(struct ast_channel *chan, unsigned char *app, int ver, int data)
Check if scripts for a given app are already loaded. Version may be -1, if any version is okay,...
Definition: adsi.c:76
int ast_adsi_get_cpeinfo(struct ast_channel *chan, int *width, int *height, int *buttons, int voice)
Definition: adsi.c:175
static int cpeid_setstatus(struct ast_channel *chan, char *stuff[], int voice)
Definition: app_getcpeid.c:59
#define ast_alloca(size)
call __builtin_alloca to ensure we get gcc builtin semantics
Definition: astmm.h:288
int ast_waitfordigit(struct ast_channel *c, int ms)
Waits for a digit.
Definition: channel.c:3143
const char * ast_channel_name(const struct ast_channel *chan)
#define ast_verb(level,...)
#define NULL
Definition: resample.c:96

References ast_adsi_get_cpeid(), ast_adsi_get_cpeinfo(), ast_adsi_load_session(), ast_adsi_unload_session(), ast_alloca, ast_channel_name(), ast_verb, ast_waitfordigit(), cpeid_setstatus(), and NULL.

Referenced by load_module().

◆ cpeid_setstatus()

static int cpeid_setstatus ( struct ast_channel chan,
char *  stuff[],
int  voice 
)
static

Definition at line 59 of file app_getcpeid.c.

60{
62 char *tmp[5];
63 int x;
64 for (x=0;x<4;x++)
65 tmp[x] = stuff[x];
66 tmp[4] = NULL;
67 return ast_adsi_print(chan, tmp, justify, voice);
68}
#define ADSI_JUST_CENT
Definition: adsi.h:114
int ast_adsi_print(struct ast_channel *chan, char **lines, int *align, int voice)
Display some stuff on the screen.
Definition: adsi.c:65
#define ADSI_JUST_LEFT
Definition: adsi.h:112
static const struct adsi_event justify[]
Definition: app_adsiprog.c:115

References ADSI_JUST_CENT, ADSI_JUST_LEFT, ast_adsi_print(), justify, and NULL.

Referenced by cpeid_exec().

◆ load_module()

static int load_module ( void  )
static

Definition at line 138 of file app_getcpeid.c.

139{
141}
static char * app
Definition: app_getcpeid.c:57
static int cpeid_exec(struct ast_channel *chan, const char *idata)
Definition: app_getcpeid.c:70
#define ast_register_application_xml(app, execute)
Register an application using XML documentation.
Definition: module.h:640

References app, ast_register_application_xml, and cpeid_exec().

◆ unload_module()

static int unload_module ( void  )
static

Definition at line 133 of file app_getcpeid.c.

134{
136}
int ast_unregister_application(const char *app)
Unregister an application.
Definition: pbx_app.c:392

References app, and ast_unregister_application().

Variable Documentation

◆ __mod_info

struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT , .description = "Get ADSI CPE ID" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = AST_BUILDOPT_SUM, .support_level = AST_MODULE_SUPPORT_DEPRECATED, .load = load_module, .unload = unload_module, .requires = "res_adsi", }
static

Definition at line 148 of file app_getcpeid.c.

◆ app

char* app = "GetCPEID"
static

Definition at line 57 of file app_getcpeid.c.

Referenced by load_module(), and unload_module().

◆ ast_module_info

const struct ast_module_info* ast_module_info = &__mod_info
static

Definition at line 148 of file app_getcpeid.c.