Wed Jan 8 2020 09:49:53

Asterisk developer's documentation


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)
 
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 = "ac1f6a56484a8820659555499174e588" , .load = load_module, .unload = unload_module, .nonoptreq = "res_adsi", }
 
static char * app = "GetCPEID"
 
static 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

static void __reg_module ( void  )
static

Definition at line 147 of file app_getcpeid.c.

static void __unreg_module ( void  )
static

Definition at line 147 of file app_getcpeid.c.

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

Definition at line 68 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_verb, ast_waitfordigit(), cpeid_setstatus(), and ast_channel::name.

Referenced by load_module().

69 {
70  int res=0;
71  unsigned char cpeid[4];
72  int gotgeometry = 0;
73  int gotcpeid = 0;
74  int width, height, buttons;
75  char *data[4];
76  unsigned int x;
77 
78  for (x = 0; x < 4; x++)
79  data[x] = ast_alloca(80);
80 
81  strcpy(data[0], "** CPE Info **");
82  strcpy(data[1], "Identifying CPE...");
83  strcpy(data[2], "Please wait...");
84  res = ast_adsi_load_session(chan, NULL, 0, 1);
85  if (res > 0) {
86  cpeid_setstatus(chan, data, 0);
87  res = ast_adsi_get_cpeid(chan, cpeid, 0);
88  if (res > 0) {
89  gotcpeid = 1;
90  ast_verb(3, "Got CPEID of '%02x:%02x:%02x:%02x' on '%s'\n",
91  (unsigned)cpeid[0], (unsigned)cpeid[1], (unsigned)cpeid[2],
92  (unsigned)cpeid[3], chan->name);
93  }
94  if (res > -1) {
95  strcpy(data[1], "Measuring CPE...");
96  strcpy(data[2], "Please wait...");
97  cpeid_setstatus(chan, data, 0);
98  res = ast_adsi_get_cpeinfo(chan, &width, &height, &buttons, 0);
99  if (res > -1) {
100  ast_verb(3, "CPE has %d lines, %d columns, and %d buttons on '%s'\n", height, width, buttons, chan->name);
101  gotgeometry = 1;
102  }
103  }
104  if (res > -1) {
105  if (gotcpeid)
106  snprintf(data[1], 80, "CPEID: %02x:%02x:%02x:%02x",
107  (unsigned)cpeid[0], (unsigned)cpeid[1],
108  (unsigned)cpeid[2], (unsigned)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 }
#define ast_alloca(size)
call __builtin_alloca to ensure we get gcc builtin semantics
Definition: utils.h:653
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_cpeid(struct ast_channel *chan, unsigned char *cpeid, int voice)
Definition: adsi.c:164
#define ast_verb(level,...)
Definition: logger.h:243
static int cpeid_setstatus(struct ast_channel *chan, char *stuff[], int voice)
Definition: app_getcpeid.c:57
const ast_string_field name
Definition: channel.h:787
int ast_waitfordigit(struct ast_channel *c, int ms)
Waits for a digit.
Definition: channel.c:3552
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
static int cpeid_setstatus ( struct ast_channel chan,
char *  stuff[],
int  voice 
)
static

Definition at line 57 of file app_getcpeid.c.

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

Referenced by cpeid_exec().

58 {
59  int justify[5] = { ADSI_JUST_CENT, ADSI_JUST_LEFT, ADSI_JUST_LEFT, ADSI_JUST_LEFT };
60  char *tmp[5];
61  int x;
62  for (x=0;x<4;x++)
63  tmp[x] = stuff[x];
64  tmp[4] = NULL;
65  return ast_adsi_print(chan, tmp, justify, voice);
66 }
#define ADSI_JUST_LEFT
Definition: adsi.h:112
static struct adsi_event justify[]
Definition: app_adsiprog.c:105
#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
static int load_module ( void  )
static

Definition at line 138 of file app_getcpeid.c.

References ast_register_application_xml, and cpeid_exec().

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

Definition at line 133 of file app_getcpeid.c.

References ast_unregister_application().

134 {
136 }
int ast_unregister_application(const char *app)
Unregister an application.
Definition: pbx.c:7705
static char * app
Definition: app_getcpeid.c:55

Variable Documentation

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 = "ac1f6a56484a8820659555499174e588" , .load = load_module, .unload = unload_module, .nonoptreq = "res_adsi", }
static

Definition at line 147 of file app_getcpeid.c.

char* app = "GetCPEID"
static

Definition at line 55 of file app_getcpeid.c.

Definition at line 147 of file app_getcpeid.c.