Asterisk - The Open Source Telephony Project  GIT-master-a24979a
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 145 of file app_getcpeid.c.

◆ __unreg_module()

static void __unreg_module ( void  )
static

Definition at line 145 of file app_getcpeid.c.

◆ AST_MODULE_SELF_SYM()

struct ast_module* AST_MODULE_SELF_SYM ( void  )

Definition at line 145 of file app_getcpeid.c.

◆ cpeid_exec()

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

Definition at line 67 of file app_getcpeid.c.

68 {
69  int res=0;
70  unsigned char cpeid[4];
71  int gotgeometry = 0;
72  int gotcpeid = 0;
73  int width, height, buttons;
74  char *data[4];
75  unsigned int x;
76 
77  for (x = 0; x < 4; x++)
78  data[x] = ast_alloca(80);
79 
80  strcpy(data[0], "** CPE Info **");
81  strcpy(data[1], "Identifying CPE...");
82  strcpy(data[2], "Please wait...");
83  res = ast_adsi_load_session(chan, NULL, 0, 1);
84  if (res > 0) {
85  cpeid_setstatus(chan, data, 0);
86  res = ast_adsi_get_cpeid(chan, cpeid, 0);
87  if (res > 0) {
88  gotcpeid = 1;
89  ast_verb(3, "Got CPEID of '%02hhx:%02hhx:%02hhx:%02hhx' on '%s'\n",
90  cpeid[0], cpeid[1], cpeid[2], cpeid[3], ast_channel_name(chan));
91  }
92  if (res > -1) {
93  strcpy(data[1], "Measuring CPE...");
94  strcpy(data[2], "Please wait...");
95  cpeid_setstatus(chan, data, 0);
96  res = ast_adsi_get_cpeinfo(chan, &width, &height, &buttons, 0);
97  if (res > -1) {
98  ast_verb(3, "CPE has %d lines, %d columns, and %d buttons on '%s'\n", height, width, buttons, ast_channel_name(chan));
99  gotgeometry = 1;
100  }
101  }
102  if (res > -1) {
103  if (gotcpeid)
104  snprintf(data[1], 80, "CPEID: %02hhx:%02hhx:%02hhx:%02hhx",
105  cpeid[0], cpeid[1], cpeid[2], cpeid[3]);
106  else
107  strcpy(data[1], "CPEID Unknown");
108  if (gotgeometry)
109  snprintf(data[2], 80, "Geom: %dx%d, %d buttons", width, height, buttons);
110  else
111  strcpy(data[2], "Geometry unknown");
112  strcpy(data[3], "Press # to exit");
113  cpeid_setstatus(chan, data, 1);
114  for(;;) {
115  res = ast_waitfordigit(chan, 1000);
116  if (res < 0)
117  break;
118  if (res == '#') {
119  res = 0;
120  break;
121  }
122  }
124  }
125  }
126 
127  return res;
128 }
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:56
#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:3176
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.

◆ cpeid_setstatus()

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

Definition at line 56 of file app_getcpeid.c.

57 {
59  char *tmp[5];
60  int x;
61  for (x=0;x<4;x++)
62  tmp[x] = stuff[x];
63  tmp[4] = NULL;
64  return ast_adsi_print(chan, tmp, justify, voice);
65 }
#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:112
static int tmp()
Definition: bt_open.c:389

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

Referenced by cpeid_exec().

◆ load_module()

static int load_module ( void  )
static

Definition at line 135 of file app_getcpeid.c.

136 {
138 }
static char * app
Definition: app_getcpeid.c:54
static int cpeid_exec(struct ast_channel *chan, const char *idata)
Definition: app_getcpeid.c:67
#define ast_register_application_xml(app, execute)
Register an application using XML documentation.
Definition: module.h:626

◆ unload_module()

static int unload_module ( void  )
static

Definition at line 130 of file app_getcpeid.c.

131 {
133 }
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 135 of file app_getcpeid.c.

◆ app

char* app = "GetCPEID"
static

Definition at line 54 of file app_getcpeid.c.

Referenced by unload_module().

◆ ast_module_info

const struct ast_module_info* ast_module_info = &__mod_info
static

Definition at line 145 of file app_getcpeid.c.