Asterisk - The Open Source Telephony Project  GIT-master-9ed6387
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"

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.

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().

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_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
#define NULL
Definition: resample.c:96
int ast_adsi_get_cpeid(struct ast_channel *chan, unsigned char *cpeid, int voice)
Definition: adsi.c:164
#define ast_verb(level,...)
Definition: logger.h:455
#define ast_alloca(size)
call __builtin_alloca to ensure we get gcc builtin semantics
Definition: astmm.h:290
static int cpeid_setstatus(struct ast_channel *chan, char *stuff[], int voice)
Definition: app_getcpeid.c:56
int ast_waitfordigit(struct ast_channel *c, int ms)
Waits for a digit.
Definition: channel.c:3150
const char * ast_channel_name(const struct ast_channel *chan)
int ast_adsi_unload_session(struct ast_channel *chan)
Definition: adsi.c:87
int ast_adsi_get_cpeinfo(struct ast_channel *chan, int *width, int *height, int *buttons, int voice)
Definition: adsi.c:175

◆ cpeid_setstatus()

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

Definition at line 56 of file app_getcpeid.c.

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

Referenced by cpeid_exec().

57 {
58  int justify[5] = { ADSI_JUST_CENT, ADSI_JUST_LEFT, ADSI_JUST_LEFT, ADSI_JUST_LEFT };
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 }
static int tmp()
Definition: bt_open.c:389
#define ADSI_JUST_LEFT
Definition: adsi.h:112
#define NULL
Definition: resample.c:96
static const struct adsi_event justify[]
Definition: app_adsiprog.c:112
#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

◆ load_module()

static int load_module ( void  )
static

Definition at line 135 of file app_getcpeid.c.

References app, AST_MODFLAG_DEFAULT, AST_MODULE_INFO(), AST_MODULE_SUPPORT_DEPRECATED, ast_register_application_xml, ASTERISK_GPL_KEY, cpeid_exec(), and unload_module().

136 {
138 }
static int cpeid_exec(struct ast_channel *chan, const char *idata)
Definition: app_getcpeid.c:67
static char * app
Definition: app_getcpeid.c:54
#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.

References app, and ast_unregister_application().

Referenced by load_module().

131 {
133 }
int ast_unregister_application(const char *app)
Unregister an application.
Definition: pbx_app.c:392
static char * app
Definition: app_getcpeid.c:54

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 145 of file app_getcpeid.c.

◆ app

char* app = "GetCPEID"
static

Definition at line 54 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 145 of file app_getcpeid.c.