Update pri_event2str() to current defined events.

git-svn-id: https://origsvn.digium.com/svn/libpri/branches/1.4@1107 2fbb986a-6c06-0410-b554-c9c1f0a7f128
This commit is contained in:
Richard Mudgett 2009-09-22 02:23:48 +00:00
parent 599128a65a
commit 4d19486781

71
pri.c
View File

@ -355,45 +355,42 @@ void pri_set_nsf(struct pri *pri, int nsf)
char *pri_event2str(int id) char *pri_event2str(int id)
{ {
switch(id) { unsigned idx;
case PRI_EVENT_DCHAN_UP: struct {
return "D-Channel Up"; int id;
case PRI_EVENT_DCHAN_DOWN: char *name;
return "D-channel Down"; } events[] = {
case PRI_EVENT_RESTART: /* *INDENT-OFF* */
return "Restart channel"; { PRI_EVENT_DCHAN_UP, "D-Channel Up" },
case PRI_EVENT_RING: { PRI_EVENT_DCHAN_DOWN, "D-channel Down" },
return "Ring"; { PRI_EVENT_RESTART, "Restart channel" },
case PRI_EVENT_HANGUP: { PRI_EVENT_CONFIG_ERR, "Configuration Error" },
return "Hangup"; { PRI_EVENT_RING, "Ring" },
case PRI_EVENT_RINGING: { PRI_EVENT_HANGUP, "Hangup" },
return "Ringing"; { PRI_EVENT_RINGING, "Ringing" },
case PRI_EVENT_ANSWER: { PRI_EVENT_ANSWER, "Answer" },
return "Answer"; { PRI_EVENT_HANGUP_ACK, "Hangup ACK" },
case PRI_EVENT_HANGUP_ACK: { PRI_EVENT_RESTART_ACK, "Restart ACK" },
return "Hangup ACK"; { PRI_EVENT_FACILITY, "Facility" },
case PRI_EVENT_RESTART_ACK: { PRI_EVENT_INFO_RECEIVED, "Info Received" },
return "Restart ACK"; { PRI_EVENT_PROCEEDING, "Proceeding" },
case PRI_EVENT_FACILITY: { PRI_EVENT_SETUP_ACK, "Setup ACK" },
return "Facility"; { PRI_EVENT_HANGUP_REQ, "Hangup Req" },
case PRI_EVENT_INFO_RECEIVED: { PRI_EVENT_NOTIFY, "Notify" },
return "Info Received"; { PRI_EVENT_PROGRESS, "Progress" },
case PRI_EVENT_PROCEEDING: { PRI_EVENT_KEYPAD_DIGIT, "Keypad Digit" },
return "Proceeding"; { PRI_EVENT_SERVICE, "Service" },
case PRI_EVENT_SETUP_ACK: { PRI_EVENT_SERVICE_ACK, "Service ACK" },
return "Setup ACK"; /* *INDENT-ON* */
case PRI_EVENT_HANGUP_REQ: };
return "Hangup Req";
case PRI_EVENT_NOTIFY: for (idx = 0; idx < ARRAY_LEN(events); ++idx) {
return "Notify"; if (events[idx].id == id) {
case PRI_EVENT_PROGRESS: return events[idx].name;
return "Progress";
case PRI_EVENT_CONFIG_ERR:
return "Configuration Error";
default:
return "Unknown Event";
} }
} }
return "Unknown Event";
}
pri_event *pri_check_event(struct pri *pri) pri_event *pri_check_event(struct pri *pri)
{ {