📄 maintidi.c
字号:
pLib->OutgoingCallsConnectedActive = 0; return (-1); } pLib->req_busy = 1; return (0); } return (0);}static int process_idi_event (diva_strace_context_t* pLib, diva_man_var_header_t* pVar) { const char* path = (char*)&pVar->path_length+1; char name[64]; int i; if (!strncmp("State\\B Event", path, pVar->path_length)) { dword ch_id; if (!diva_trace_read_variable (pVar, &ch_id)) { if (!pLib->line_init_event && !pLib->pending_line_status) { for (i = 1; i <= pLib->Channels; i++) { diva_line_event(pLib, i); } return (0); } else if (ch_id && ch_id <= pLib->Channels) { return (diva_line_event(pLib, (int)ch_id)); } return (0); } return (-1); } if (!strncmp("State\\FAX Event", path, pVar->path_length)) { dword ch_id; if (!diva_trace_read_variable (pVar, &ch_id)) { if (!pLib->pending_fax_status && !pLib->fax_init_event) { for (i = 1; i <= pLib->Channels; i++) { diva_fax_event(pLib, i); } return (0); } else if (ch_id && ch_id <= pLib->Channels) { return (diva_fax_event(pLib, (int)ch_id)); } return (0); } return (-1); } if (!strncmp("State\\Modem Event", path, pVar->path_length)) { dword ch_id; if (!diva_trace_read_variable (pVar, &ch_id)) { if (!pLib->pending_modem_status && !pLib->modem_init_event) { for (i = 1; i <= pLib->Channels; i++) { diva_modem_event(pLib, i); } return (0); } else if (ch_id && ch_id <= pLib->Channels) { return (diva_modem_event(pLib, (int)ch_id)); } return (0); } return (-1); } /* First look for Line Event */ for (i = 1; i <= pLib->Channels; i++) { sprintf (name, "State\\B%d\\Line", i); if (find_var (pVar, name)) { return (diva_line_event(pLib, i)); } } /* Look for Moden Progress Event */ for (i = 1; i <= pLib->Channels; i++) { sprintf (name, "State\\B%d\\Modem\\Event", i); if (find_var (pVar, name)) { return (diva_modem_event (pLib, i)); } } /* Look for Fax Event */ for (i = 1; i <= pLib->Channels; i++) { sprintf (name, "State\\B%d\\FAX\\Event", i); if (find_var (pVar, name)) { return (diva_fax_event (pLib, i)); } } /* Notification about loss of events */ if (!strncmp("Events Down", path, pVar->path_length)) { if (pLib->trace_events_down == 1) { pLib->trace_events_down = 2; } else { diva_trace_error (pLib, 1, "Events Down", 0); } return (0); } if (!strncmp("State\\Layer1", path, pVar->path_length)) { diva_strace_read_asz (pVar, &pLib->lines[0].pInterface->Layer1[0]); if (pLib->l1_trace == 1) { pLib->l1_trace = 2; } else { diva_trace_notify_user (pLib, 0, DIVA_SUPER_TRACE_INTERFACE_CHANGE); } return (0); } if (!strncmp("State\\Layer2 No1", path, pVar->path_length)) { char* tmp = &pLib->lines[0].pInterface->Layer2[0]; dword l2_state; diva_strace_read_uint (pVar, &l2_state); switch (l2_state) { case 0: strcpy (tmp, "Idle"); break; case 1: strcpy (tmp, "Layer2 UP"); break; case 2: strcpy (tmp, "Layer2 Disconnecting"); break; case 3: strcpy (tmp, "Layer2 Connecting"); break; case 4: strcpy (tmp, "SPID Initializing"); break; case 5: strcpy (tmp, "SPID Initialised"); break; case 6: strcpy (tmp, "Layer2 Connecting"); break; case 7: strcpy (tmp, "Auto SPID Stopped"); break; case 8: strcpy (tmp, "Auto SPID Idle"); break; case 9: strcpy (tmp, "Auto SPID Requested"); break; case 10: strcpy (tmp, "Auto SPID Delivery"); break; case 11: strcpy (tmp, "Auto SPID Complete"); break; default: sprintf (tmp, "U:%d", (int)l2_state); } if (pLib->l2_trace == 1) { pLib->l2_trace = 2; } else { diva_trace_notify_user (pLib, 0, DIVA_SUPER_TRACE_INTERFACE_CHANGE); } return (0); } if (!strncmp("Statistics\\Incoming Calls\\Calls", path, pVar->path_length) || !strncmp("Statistics\\Incoming Calls\\Connected", path, pVar->path_length)) { return (SuperTraceGetIncomingCallStatistics (pLib)); } if (!strncmp("Statistics\\Outgoing Calls\\Calls", path, pVar->path_length) || !strncmp("Statistics\\Outgoing Calls\\Connected", path, pVar->path_length)) { return (SuperTraceGetOutgoingCallStatistics (pLib)); } return (-1);}static int diva_line_event (diva_strace_context_t* pLib, int Channel) { pLib->pending_line_status |= (1L << (Channel-1)); return (0);}static int diva_modem_event (diva_strace_context_t* pLib, int Channel) { pLib->pending_modem_status |= (1L << (Channel-1)); return (0);}static int diva_fax_event (diva_strace_context_t* pLib, int Channel) { pLib->pending_fax_status |= (1L << (Channel-1)); return (0);}/* Process INFO indications that arrive from the card Uses path of first I.E. to detect the source of the infication */static int process_idi_info (diva_strace_context_t* pLib, diva_man_var_header_t* pVar) { const char* path = (char*)&pVar->path_length+1; char name[64]; int i, len; /* First look for Modem Status Info */ for (i = pLib->Channels; i > 0; i--) { len = sprintf (name, "State\\B%d\\Modem", i); if (!strncmp(name, path, len)) { return (diva_modem_info (pLib, i, pVar)); } } /* Look for Fax Status Info */ for (i = pLib->Channels; i > 0; i--) { len = sprintf (name, "State\\B%d\\FAX", i); if (!strncmp(name, path, len)) { return (diva_fax_info (pLib, i, pVar)); } } /* Look for Line Status Info */ for (i = pLib->Channels; i > 0; i--) { len = sprintf (name, "State\\B%d", i); if (!strncmp(name, path, len)) { return (diva_line_info (pLib, i, pVar)); } } if (!diva_ifc_statistics (pLib, pVar)) { return (0); } return (-1);}/* MODEM INSTANCE STATE UPDATE Update Modem Status Information and issue notification to user, that will inform about change in the state of modem instance, that is associuated with this channel */static int diva_modem_info (diva_strace_context_t* pLib, int Channel, diva_man_var_header_t* pVar) { diva_man_var_header_t* cur; int i, nr = Channel - 1; for (i = pLib->modem_parse_entry_first[nr]; i <= pLib->modem_parse_entry_last[nr]; i++) { if ((cur = find_var (pVar, pLib->parse_table[i].path))) { if (diva_trace_read_variable (cur, pLib->parse_table[i].variable)) { diva_trace_error (pLib, -3 , __FILE__, __LINE__); return (-1); } } else { diva_trace_error (pLib, -2 , __FILE__, __LINE__); return (-1); } } /* We do not use first event to notify user - this is the event that is generated as result of EVENT ON operation and is used only to initialize internal variables of application */ if (pLib->modem_init_event & (1L << nr)) { diva_trace_notify_user (pLib, nr, DIVA_SUPER_TRACE_NOTIFY_MODEM_CHANGE); } else { pLib->modem_init_event |= (1L << nr); } return (0);}static int diva_fax_info (diva_strace_context_t* pLib, int Channel, diva_man_var_header_t* pVar) { diva_man_var_header_t* cur; int i, nr = Channel - 1; for (i = pLib->fax_parse_entry_first[nr]; i <= pLib->fax_parse_entry_last[nr]; i++) { if ((cur = find_var (pVar, pLib->parse_table[i].path))) { if (diva_trace_read_variable (cur, pLib->parse_table[i].variable)) { diva_trace_error (pLib, -3 , __FILE__, __LINE__); return (-1); } } else { diva_trace_error (pLib, -2 , __FILE__, __LINE__); return (-1); } } /* We do not use first event to notify user - this is the event that is generated as result of EVENT ON operation and is used only to initialize internal variables of application */ if (pLib->fax_init_event & (1L << nr)) { diva_trace_notify_user (pLib, nr, DIVA_SUPER_TRACE_NOTIFY_FAX_CHANGE); } else { pLib->fax_init_event |= (1L << nr); } return (0);}/* LINE STATE UPDATE Update Line Status Information and issue notification to user, that will inform about change in the line state. */static int diva_line_info (diva_strace_context_t* pLib, int Channel, diva_man_var_header_t* pVar) { diva_man_var_header_t* cur; int i, nr = Channel - 1; for (i = pLib->line_parse_entry_first[nr]; i <= pLib->line_parse_entry_last[nr]; i++) { if ((cur = find_var (pVar, pLib->parse_table[i].path))) { if (diva_trace_read_variable (cur, pLib->parse_table[i].variable)) { diva_trace_error (pLib, -3 , __FILE__, __LINE__); return (-1); } } else { diva_trace_error (pLib, -2 , __FILE__, __LINE__); return (-1); } } /* We do not use first event to notify user - this is the event that is generated as result of EVENT ON operation and is used only to initialize internal variables of application Exception is is if the line is "online". In this case we have to notify user about this confition. */ if (pLib->line_init_event & (1L << nr)) { diva_trace_notify_user (pLib, nr, DIVA_SUPER_TRACE_NOTIFY_LINE_CHANGE); } else { pLib->line_init_event |= (1L << nr); if (strcmp (&pLib->lines[nr].Line[0], "Idle")) { diva_trace_notify_user (pLib, nr, DIVA_SUPER_TRACE_NOTIFY_LINE_CHANGE); } } return (0);}/* Move position to next vatianle in the chain */static diva_man_var_header_t* get_next_var (diva_man_var_header_t* pVar) { byte* msg = (byte*)pVar; byte* start; int msg_length; if (*msg != ESC) return NULL; start = msg + 2; msg_length = *(msg+1); msg = (start+msg_length); if (*msg != ESC) return NULL; return ((diva_man_var_header_t*)msg);}/* Move position to variable with given name */static diva_man_var_header_t* find_var (diva_man_var_header_t* pVar, const char* name) { const char* path; do { path = (char*)&pVar->path_length+1; if (!strncmp (name, path, pVar->path_length)) { break; } } while ((pVar = get_next_var (pVar))); return (pVar);}static void diva_create_line_parse_table (diva_strace_context_t* pLib, int Channel) { diva_trace_line_state_t* pLine = &pLib->lines[Channel]; int nr = Channel+1; if ((pLib->cur_parse_entry + LINE_PARSE_ENTRIES) >= pLib->parse_entries) { diva_trace_error (pLib, -1, __FILE__, __LINE__); return; } pLine->ChannelNumber = nr; pLib->line_parse_entry_first[Channel] = pLib->cur_parse_entry; sprintf (pLib->parse_table[pLib->cur_parse_entry].path, "State\\B%d\\Framing", nr); pLib->parse_table[pLib->cur_parse_entry++].variable = &pLine->Framing[0];
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -