📄 u_ijou.c
字号:
/************************************************************************//* SISCO SOFTWARE MODULE HEADER *****************************************//************************************************************************//* (c) Copyright Systems Integration Specialists Company, Inc., *//* 1986 - 2002, All Rights Reserved. *//* *//* MODULE NAME : u_ijou.c *//* PRODUCT(S) : MMSEASE *//* *//* MODULE DESCRIPTION : *//* This module contains user defined code to service journal *//* management indications. These functions are invoked from *//* the 'mms_ind_serve' function, and should perform the request *//* action. *//* *//* GLOBAL FUNCTIONS DEFINED IN THIS MODULE : *//* *//* MODIFICATION LOG : *//* Date Who Rev Comments *//* -------- --- ------ ------------------------------------------- *//* 08/02/02 EJV 12 UNIX compilers don't like '//' for comment. *//* 07/30/02 NAV 11 Use Btime6StringToVals when reading .cfg *//* 07/11/02 NAV 10 more bugs in sendJreadResp & sendJinitResp *//* 06/26/02 NAV 09 sendJreadResp: change init of startEntryNum *//* 02/01/02 EJV 08 Support DOM_SPEC journals. *//* 12/20/01 EJV 08 Changed to use ASN1R *//* 02/25/99 RKR 07 send 0 current entries in status if not known*//* worked on sendJreadResp. *//* 07/30/98 EJV 06 UNIX compilers don't like '//' for comment. *//* 07/23/98 EJV 05 Add typcasting (eliminate warningon __alpha)*//* 07/23/98 NAV 04 use strftime instead of strdate *//* 07/17/98 EJV 03 Add typcasting (eliminate warning __alpha) *//* 07/01/98 NAV 02 Overhaul journal handling *//* 08/15/97 MDE 01 BTOD handling changes *//* 04/15/97 DSF 7.00 MMSEASE 7.0 release. See MODL70.DOC for *//* history. *//************************************************************************/#include "glbtypes.h"#include "sysincs.h"#include "mms_usr.h"#include "mms_vvmd.h"#include "mms_pcon.h"#include "mms_pjou.h"#include "mms_vjou.h"#include "mem_chk.h"#include "userdefs.h"#include "mmsop_en.h"#include "gvaldefs.h"#include "scrndefs.h"#include "fkeydefs.h"#include "cfg_util.h"#include "suicacse.h"#include "time_str.h"static ST_BOOLEAN done; /* used for input loop control */static ST_INT tot_len; /* used for total string len */static ST_INT len; /* used for return lengths */static ST_INT num; /* integer used for input */static ST_LONG lnum; /* long integer used for input */static ST_RET readJrnlFile (ST_CHAR *jrnlFile);static ST_VOID freeLocalJrnl (ST_VOID);static ST_VOID freeJournalEntry (JOURNAL_ENTRY *pstJE);static ST_VOID sendJreadResp (MMSREQ_IND *req_info);static ST_VOID sendJinitResp (MMSREQ_IND *req_info);static ST_VOID sendJwriteResp (MMSREQ_IND *req_info);static ST_INT compareMmsBtod (MMS_BTOD *btod1, MMS_BTOD *btod2);static ST_BOOLEAN findVarTag (ST_CHAR *varTag, ST_INT numVars, ST_CHAR **ppTagList);static ST_INT getFirstTS (MMS_BTOD *btod, ST_INT level);static ST_INT getLastTS (MMS_BTOD *btod);static ST_VOID writeLocalJrnl (JOURNAL *pstJrnl);static ST_VOID writeLocalJE (FILE *fp, JOURNAL_ENTRY *pstJE);static ST_VOID addToLocalJrnl (JOURNAL_ENTRY *pstJE);static ST_VOID assInfoToAppRef (ASS_INFO *assInfo, APP_REF *appRef);#if 0static ST_RET Btime6ValsToString (char *dest, ST_INT32 numDays, ST_INT32 numMSec);static ST_RET Btime4ValsToString (char *dest, ST_INT32 numMSec);#endif/************************************************************************//* For debug version, use a static pointer to avoid duplication of *//* __FILE__ strings. *//************************************************************************/#ifdef DEBUG_SISCOstatic ST_CHAR *thisFileName = __FILE__;#endif/************************************************************************/#define MAX_ENTRIES_PER_RESP 5#define JRNL_MAX_ENTRIES 50static JOURNAL_ENTRY *pstLocalJrnl[JRNL_MAX_ENTRIES];static int localJrnlLevel=0;static int lastEntryId=0;/************************************************************************//* JOURNAL MANAGEMENT *//************************************************************************//************************************************************************//* READ JOURNAL *//************************************************************************/#if MMS_JREAD_EN & RESP_ENST_VOID u_jread_ind (MMSREQ_IND *req_info) {JREAD_RESP_INFO *rsp_info;JREAD_REQ_INFO *ptr;JOURNAL_ENTRY *je_ptr;VAR_INFO *vi_ptr;ST_UCHAR *inp_str;ST_CHAR **var_ptr;ST_BOOLEAN data_entered, vi_done;ST_INT line, ch, j;OBJECT_NAME obj;NAMED_TYPE *tptr;ST_CHAR source[1024];ST_INT chan;ST_RET ret;ST_UCHAR *asn1Start, asn1Buf[1024];ST_INT asn1Len, asn1BufSize=1024;ASN1_ENC_CTXT localCtx;ASN1_ENC_CTXT *aCtx = &localCtx; chan = req_info->chan; if (mms_debug_sel & MMS_LOG_USR_IND) { indic_info_print (req_info,"Read Journal "); ptr = (JREAD_REQ_INFO *) req_info->req_info_ptr; printf ("\n\n Press return to continue"); ch = get_a_char (); CLEARSCR; printf ("\n Journal Name : "); print_objname (&(ptr->jou_name)); printf ("\n Range Start Spec : "); if (ptr->range_start_pres) { switch (ptr->start_tag) { case 0 : printf ("Starting Time"); print_evt_tod (&ptr->start_time); break; case 1 : printf ("\n Starting Entry : "); list_bytes (ptr->start_entry,ptr->start_entry_len); printf ("\n"); break; default : printf ("Invalid"); break; } } else printf ("Not Present"); printf ("\n Range Stop Spec : "); if (ptr->range_stop_pres) { switch (ptr->stop_tag) { case 0 : printf ("Ending Time"); print_evt_tod (&ptr->end_time); break; case 1 : printf ("\n Number of Entries : %ld\n", ptr->num_of_entries); break; default : printf ("Invalid"); break; } } else printf ("Not Present"); printf ("\n Start After Entry : "); if (ptr->sa_entry_pres) { printf ("\n Time Spec : "); print_evt_tod (&ptr->time_spec); printf (" Entry Spec : "); list_bytes (ptr->entry_spec,ptr->entry_spec_len); } else printf ("Not Present"); if (ptr->list_of_var_pres) { printf ("\n Number of Variables : %d", ptr->num_of_var); var_ptr = (ST_CHAR **) (ptr + 1); line = 16; for (j=0; j < ptr->num_of_var ; j++) { printf ("\n Variable %2d) %s", j+1, *var_ptr); line++; var_ptr++; if (((j+1) < ptr->num_of_var) && (line > 21)) { printf ("\n Press return for more variables, q to quit"); ch = get_a_char (); if (ch == 'q' || ch == 'Q') j = ptr->num_of_var; else { /* clear display lines */ for (line = 16; line < 25; line++) printf ("\n"); line = 16; } } } } else printf ("\n List of Variables : Not Present"); printf ("\n Press return to continue"); ch = get_a_char (); } /* use first 8K for response */ rsp_info = (JREAD_RESP_INFO *) dest_buffer; je_ptr = (JOURNAL_ENTRY *) (rsp_info + 1); inp_str = (ST_UCHAR *)dest_buffer + 8192; /* use last 2K for strings */ /* interactive response */ if (mms_debug_sel & MMS_LOG_USR_IND) { tot_len = 0; je_ptr = (JOURNAL_ENTRY *) (rsp_info + 1); inp_str = (ST_UCHAR *)dest_buffer + 8192; /* use last 2K for strings */ rsp_info->num_of_jou_entry = 0; printf ("\n"); done = SD_FALSE; while (!done) { printf ("\n\nJournal Entry %d) ", rsp_info->num_of_jou_entry+1); printf ("\n Enter Entry Identifier (R) : "); if (len = input_hex ((ST_UCHAR *)tbuf, 100)) { if ((tot_len += len) < 2048) { data_entered = SD_TRUE; memcpy (inp_str, tbuf, len); je_ptr->entry_id = inp_str; je_ptr->entry_id_len = len; inp_str += len; } else { data_entered = SD_FALSE; wait_msg ("\n Total Data too long, entry was lost "); } } else data_entered = SD_FALSE; if (data_entered) { printf ("\n Enter Originating ArName (R) : \n"); if (strget (tbuf)) { if (ms_arname_to_asn1 (tbuf, inp_str, 2048, &je_ptr->orig_ae, &len) == SD_SUCCESS) { data_entered = SD_TRUE; memcpy (inp_str, je_ptr->orig_ae, len); je_ptr->orig_ae = inp_str; je_ptr->orig_ae_len = len; inp_str += (len + 1); } else { data_entered = SD_FALSE; wait_msg ("\nUnknown ARName"); } } else data_entered = SD_FALSE; } if (data_entered) { /* get entry content from operator */ printf (" Entry Content : Sending occurence time "); je_ptr->ent_content.occur_time.form = MMS_BTOD6; je_ptr->ent_content.occur_time.ms = 12345; je_ptr->ent_content.occur_time.day = 4930; printf ("\n Enter Additional Detail (O) : "); if (len = input_hex ((ST_UCHAR *)tbuf, 100)) { if ((tot_len += len) < 2048) { memcpy (inp_str, tbuf, len); je_ptr->ent_content.addl_detail_pres = SD_TRUE; je_ptr->ent_content.addl_detail = inp_str; je_ptr->ent_content.addl_detail_len = len; inp_str += (len + 1); } else { je_ptr->ent_content.addl_detail_pres = SD_FALSE; wait_msg ("\n Total Data too long, entry was lost "); } } else je_ptr->ent_content.addl_detail_pres = SD_FALSE; } if (data_entered) { printf (" Enter Entry Form (2-3) (default = 2, data) : "); je_ptr->ent_content.entry_form_tag = 2; if (intget (&num) && num == 3) je_ptr->ent_content.entry_form_tag = num; } if (data_entered) { if (je_ptr->ent_content.entry_form_tag == 2) /* DATA FORM */ { je_ptr->ent_content.ef.data.event_pres = SD_FALSE; if (ask (" Send Event ? ",0)) { printf (" Enter Event Condition Name :\n"); if (get_objname (&je_ptr->ent_content.ef.data.evcon_name)) { je_ptr->ent_content.ef.data.event_pres = SD_TRUE; printf (" Enter Current State (0-2) (default = 0, disabled) : "); je_ptr->ent_content.ef.data.cur_state = 0; if (intget (&num) && (num >= 0) && (num <= 2)) je_ptr->ent_content.ef.data.cur_state = num; } } printf (" Enter Variable List -\n"); je_ptr->ent_content.ef.data.list_of_var_pres = SD_FALSE; je_ptr->ent_content.ef.data.num_of_var = 0; vi_ptr = (VAR_INFO *) (je_ptr + 1); vi_done = SD_FALSE; while (!vi_done) { printf (" Enter Variable Tag (O) : "); if (strget (tbuf)) { len = strlen (tbuf) + 1; if ((tot_len += len) < 2048) { strcpy ((ST_CHAR *)inp_str, tbuf); je_ptr->ent_content.ef.data.list_of_var_pres = SD_TRUE; vi_ptr->var_tag = (ST_CHAR *)inp_str; inp_str += len; data_entered = SD_FALSE; printf ("\n Select Named Type: "); if (get_objname (&obj)) { if (tptr = ms_find_named_type_obj (&obj,chan)) { /* valid type, get data */ if (get_write_data (&obj,source,chan) == SD_SUCCESS) { asn1r_strt_asn1_bld (aCtx, asn1Buf, asn1BufSize); ret = ms_locl_to_asn1 (aCtx, tptr, source); if (ret) printf ("\n Local to ASN1 Encoding failure."); else { asn1Start = aCtx->asn1r_field_ptr+1; asn1Len = (asn1Buf + asn1BufSize) - asn1Start; tot_len += asn1Len; if (tot_len < 2048) { memcpy (inp_str, asn1Start, asn1Len); vi_ptr->value_spec.data = inp_str; vi_ptr->value_spec.len = asn1Len; je_ptr->ent_content.ef.data.num_of_var++; inp_str += asn1Len; vi_ptr++; data_entered = SD_TRUE; } else { wait_msg ("\n Total Data too long, entry was lost "); vi_done = SD_TRUE; } } } } else { vi_done = SD_TRUE; data_entered = SD_FALSE; wait_msg ("\n Total Data too long, entry was lost "); } } else vi_done = SD_TRUE; } else { vi_done = SD_TRUE; wait_msg ("\n Total Data too long, entry was lost "); } } else vi_done = SD_TRUE; } /* END OF VARIABLE LIST */ vi_ptr = (VAR_INFO *) (je_ptr + 1); vi_ptr += je_ptr->ent_content.ef.data.num_of_var; je_ptr = (JOURNAL_ENTRY *) vi_ptr; } else /* ANNOTATION FORM */ { if (data_entered) { printf (" Enter Annotation (R) : "); if (strget (tbuf)) { len = strlen (tbuf) + 1; if ((tot_len += len) < 2048) { strcpy ((ST_CHAR *)inp_str, tbuf); je_ptr->ent_content.ef.annotation = (ST_CHAR *)inp_str; inp_str += len; } else wait_msg ("\n Total Data too long, entry was lost "); } } je_ptr += 1; /* point to next entry */ } } if (data_entered) rsp_info->num_of_jou_entry++; else done = SD_TRUE; } rsp_info->more_follows = (ST_BOOLEAN) ask (" Enter More Follows (y/n) : (default = SD_FALSE) ",0); mp_jread_resp (req_info, rsp_info); /* send the response */ } else sendJreadResp (req_info); indic_info_wait (); /* allow user to see indic info */ }#endif/************************************************************************//* sendJreadResp: use the local journal for the response *//************************************************************************/#define EMPTY_JOURNAL -1static ST_VOID sendJreadResp (MMSREQ_IND *req_info) {JOURNAL *pstJrnl;JREAD_RESP_INFO *pstRespInfo;JREAD_REQ_INFO *pstReqInfo;JOURNAL_ENTRY *pstJE, *pstLJE;ST_INT chan, numVars;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -