📄 u_ijou.c
字号:
static ST_CHAR currVarTypeName[MAX_IDENT_LEN+1];static ST_VOID cfgBeginJrnl (ST_VOID);static ST_VOID cfgBeginEntry (ST_VOID);static ST_VOID cfgEntryId (ST_VOID);static ST_VOID cfgOrigAR (ST_VOID);static ST_VOID cfgOccurTime (ST_VOID);static ST_VOID cfgAnnotation (ST_VOID);static ST_VOID cfgEventName (ST_VOID);static ST_VOID cfgEventScope (ST_VOID);static ST_VOID cfgEventDomain (ST_VOID);static ST_VOID cfgEventState (ST_VOID);static ST_VOID cfgNumVars (ST_VOID);static ST_VOID cfgBeginVars (ST_VOID);static ST_VOID cfgEndEntry (ST_VOID);static ST_VOID cfgVarTag (ST_VOID);static ST_VOID cfgVarType (ST_VOID);static ST_VOID cfgVarData (ST_VOID);static ST_VOID cfgEndVars (ST_VOID);static ST_VOID cfgEndJrnl (ST_VOID);struct cfg_kw_el kwTblCfgBegin[] = { {"%BeginJournal", cfgBeginJrnl, NULL}, { NULL, NULL, NULL} };struct cfg_kw_el kwTblBegEntry[] = { {"%BeginEntry", cfgBeginEntry, NULL}, {"%EndJournal", cfgEndJrnl, NULL}, { NULL, NULL, NULL} };struct cfg_kw_el kwTblEntry[] = { {"EntryID", cfgEntryId, NULL}, {"OrigAR", cfgOrigAR, NULL}, {"OccurTime", cfgOccurTime, NULL}, {"Annotation", cfgAnnotation, NULL}, {"EventName", cfgEventName, NULL}, {"EventScope", cfgEventScope, NULL}, {"EventDomain", cfgEventDomain, NULL}, {"EventState", cfgEventState, NULL}, {"NumVars", cfgNumVars, NULL}, {"%BeginVars", cfgBeginVars, NULL}, {"%EndEntry", cfgEndEntry, NULL}, { NULL, NULL, NULL } };struct cfg_kw_el kwTblVars[] = { {"VarTag", cfgVarTag, NULL}, {"VarType", cfgVarType, NULL}, {"VarData", cfgVarData, NULL}, {"%EndVars", cfgEndVars, NULL}, { NULL, NULL, NULL } };/************************************************************************//* readJrnlFile: use cfg_util to read a journal file *//************************************************************************/static ST_RET readJrnlFile (ST_CHAR *jrnlFile) {ST_RET rtnCode; /* check for a filename */ if (!jrnlFile) return (SD_FAILURE); /* initialize cfg logging */ cfg_log_mask = CFG_LOG_ERR; /* clean up any remains of previous journals */ if (localJrnlLevel > 0) freeLocalJrnl (); entryCtrl = chk_malloc (sizeof (ENTRY_CTRL)); memset (entryCtrl, 0, sizeof (ENTRY_CTRL)); /* process the file */ rtnCode = cfg_process_file (jrnlFile, kwTblCfgBegin); chk_free (entryCtrl); return (rtnCode); }/************************************************************************//* cfgBeginJrnl: handle keyword %BeginJournal *//************************************************************************/static ST_VOID cfgBeginJrnl (ST_VOID) { if (cfg_tbl_push (kwTblBegEntry) != SD_SUCCESS) cfg_set_config_err (); }/************************************************************************//* cfgBeginEntry: handle keyword %BeginEntry *//************************************************************************/static ST_VOID cfgBeginEntry (ST_VOID) { entryCtrl->bInProgress = SD_FALSE; entryCtrl->bDiscardEntry = SD_FALSE; memset (&entryCtrl->currEntry, 0, sizeof (JOURNAL_ENTRY)); entryCtrl->numVars = 0; entryCtrl->aPtr = NULL; if (entryCtrl->numEntries >= JRNL_MAX_ENTRIES) { SLOGALWAYS0 ("Too Many Entries in Journal"); cfg_set_config_err (); } else if (cfg_tbl_push (kwTblEntry) != SD_SUCCESS) cfg_set_config_err (); }/************************************************************************//* cfgEntryID: handle keyword EntryID *//* entryID is an octet string but for cfgInput will assume *//* a visible string *//************************************************************************/static ST_VOID cfgEntryId (ST_VOID) {ST_CHAR *name = NULL, *temp;int len, id; if ((name = cfg_get_string_ptr ()) != NULL) { len = strlen (name); entryCtrl->currEntry.entry_id_len = len; temp = chk_malloc (len); memcpy (temp, name, len); entryCtrl->currEntry.entry_id = (ST_UCHAR *) temp; entryCtrl->bInProgress = SD_TRUE; entryCtrl->numEntries++; id = atoi (name); lastEntryId = max (lastEntryId, id); } else cfg_set_config_err (); }/************************************************************************//* cfgOrigAR: handle keyword OrigAR *//************************************************************************/static ST_VOID cfgOrigAR (ST_VOID) {ST_CHAR *name = NULL, buf[1024];ST_UCHAR *temp, *tmp;ST_INT len; if ((name = cfg_get_string_ptr ()) != NULL) { if (ms_arname_to_asn1 (name, (ST_UCHAR *) buf, 1024, &temp, &len) == SD_SUCCESS) { entryCtrl->currEntry.orig_ae_len = len; tmp = chk_malloc (len); memcpy (tmp, temp, len); entryCtrl->currEntry.orig_ae = tmp; } else { tmp = chk_malloc (2); tmp[0] = 0x30; tmp[1] = 0x00; entryCtrl->currEntry.orig_ae_len = 2; entryCtrl->currEntry.orig_ae = tmp; } } else cfg_set_config_err (); }/************************************************************************//* cfgOccurTime: handle keyword OccurTime *//* Read the date as a string with the following format: *//* MM-DD-YY HH:MM:SS.msec. Then convert to MMS_BTOD *//************************************************************************/static ST_VOID cfgOccurTime (ST_VOID) {ST_CHAR *strDate = NULL; if ((strDate = cfg_get_string_ptr ()) != NULL) { if (Btime6StringToVals (strDate, &entryCtrl->currEntry.ent_content.occur_time.day, &entryCtrl->currEntry.ent_content.occur_time.ms) == SD_SUCCESS) { entryCtrl->currEntry.ent_content.occur_time.form = MMS_BTOD6; } else { SLOGALWAYS1 ("Unable to parse journal occurence time %s", strDate); printf ("\nParse Failure for %s", strDate); entryCtrl->bDiscardEntry = SD_TRUE; } } else cfg_set_config_err (); }/************************************************************************//* cfgAnnotation: handle keyword Annotation *//************************************************************************/static ST_VOID cfgAnnotation (ST_VOID) {ST_CHAR *name = NULL, *temp;int len; if ((name = cfg_get_string_ptr ()) != NULL) { entryCtrl->currEntry.ent_content.entry_form_tag = 3; len = strlen (name) + 1; temp = chk_malloc (len); strcpy (temp, name); entryCtrl->currEntry.ent_content.ef.annotation = temp; } else cfg_set_config_err (); }/************************************************************************//* cfgEventName: handle keyword EventName *//************************************************************************/static ST_VOID cfgEventName (ST_VOID) {ST_CHAR *name = NULL;OBJECT_NAME *pstObjName; if ((name = cfg_get_string_ptr ()) != NULL) { entryCtrl->currEntry.ent_content.entry_form_tag = 2; entryCtrl->currEntry.ent_content.ef.data.event_pres = SD_TRUE; pstObjName = &entryCtrl->currEntry.ent_content.ef.data.evcon_name; strncpy (pstObjName->obj_name.vmd_spec, name, MAX_IDENT_LEN); } else cfg_set_config_err (); }/************************************************************************//* cfgEventScope: handle keyword EventScope *//************************************************************************/static ST_VOID cfgEventScope (ST_VOID) {ST_CHAR *name = NULL;OBJECT_NAME *pstObjName; if ((name = cfg_get_string_ptr ()) != NULL) { entryCtrl->currEntry.ent_content.entry_form_tag = 2; pstObjName = &entryCtrl->currEntry.ent_content.ef.data.evcon_name; if (stricmp (name, "vmd") == 0) pstObjName->object_tag = VMD_SPEC; else if (stricmp (name, "dom") == 0) pstObjName->object_tag = DOM_SPEC; else if (stricmp (name, "aa") == 0) pstObjName->object_tag = AA_SPEC; else { SLOGALWAYS0 ("Invalid Scope for journal event"); printf ("\nInvalid Scope for Journal Event"); cfg_set_config_err (); } } else cfg_set_config_err (); }/************************************************************************//* cfgEventDomain: handle keyword EventDomain *//************************************************************************/static ST_VOID cfgEventDomain (ST_VOID) {ST_CHAR *name = NULL;OBJECT_NAME *pstObjName; if ((name = cfg_get_string_ptr ()) != NULL) { entryCtrl->currEntry.ent_content.entry_form_tag = 2; pstObjName = &entryCtrl->currEntry.ent_content.ef.data.evcon_name; strncpy (pstObjName->domain_id, name, MAX_IDENT_LEN); } else cfg_set_config_err (); }/************************************************************************//* cfgEventState: handle keyword EventState *//************************************************************************/static ST_VOID cfgEventState (ST_VOID) {ST_CHAR *name = NULL; if ((name = cfg_get_string_ptr ()) != NULL) { if (stricmp (name, "DISABLED") == 0) entryCtrl->currEntry.ent_content.ef.data.cur_state = 0; else if (stricmp (name, "IDLE") == 0) entryCtrl->currEntry.ent_content.ef.data.cur_state = 1; else if (stricmp (name, "ACTIVE") == 0) entryCtrl->currEntry.ent_content.ef.data.cur_state = 2; else { SLOGALWAYS0 ("Invalid Event State in Journal"); printf ("\nInvalid State for Journal Event."); cfg_set_config_err (); } } else cfg_set_config_err (); }/************************************************************************//* cfgNumVars: handle keyword NumVars *//************************************************************************/static ST_VOID cfgNumVars (ST_VOID) {ST_INT16 sVal; if (cfg_get_short (&sVal) == SD_SUCCESS) { entryCtrl->currEntry.ent_content.entry_form_tag = 2; entryCtrl->numVars = sVal; entryCtrl->currEntry.ent_content.ef.data.list_of_var_pres = SD_TRUE; entryCtrl->currEntry.ent_content.ef.data.num_of_var = sVal; } else cfg_set_config_err (); }/************************************************************************//* cfgBeginVars: handle keyword %BeginVars *//* allocate space to stash numVars var tags and load *//* var keyWord table *//************************************************************************/static ST_VOID cfgBeginVars (ST_VOID) { if (entryCtrl->numVars > 0) { entryCtrl->aPtr = chk_calloc (entryCtrl->numVars, sizeof (VAR_INFO)); currVarInfo = entryCtrl->aPtr; if (cfg_tbl_push (kwTblVars) != SD_SUCCESS) cfg_set_config_err (); } else { SLOGALWAYS0 ("Unable to continue - NumVars not configured!"); printf ("\nNumVars not configured."); cfg_set_config_err (); } } /************************************************************************//* cfgVarTag: handle keyword VarTag *//************************************************************************/static ST_VOID cfgVarTag (ST_VOID) {ST_CHAR *name = NULL, *temp;int len; if ((name = cfg_get_string_ptr ()) != NULL) { len = strlen (name) + 1; temp = chk_malloc (len); strcpy (temp, name); currVarInfo->var_tag = temp; } else cfg_set_config_err (); }/************************************************************************//* cfgVarType: handle keyword VarType *//************************************************************************/static ST_VOID cfgVarType (ST_VOID) {ST_CHAR *name = NULL; if ((name = cfg_get_string_ptr ()) != NULL) strncpy (currVarTypeName, name, MAX_IDENT_LEN); else cfg_set_config_err (); }/************************************************************************//* cfgVarData: handle keyword VarData *//* only deal with Integer16, Double and Vstring64 *//************************************************************************/static ST_VOID cfgVarData (ST_VOID) {ST_CHAR *name = NULL, dataSrc[65];NAMED_TYPE *pstType;ST_UCHAR *asn1Start, asn1Buf[1024], *tmp;ST_INT asn1Len, asn1BufSize=1024;ST_RET ret;ASN1_ENC_CTXT localCtx;ASN1_ENC_CTXT *aCtx = &localCtx; if (strcmp (currVarTypeName, "Integer16") == 0) { if (cfg_get_short ((ST_INT16 *)dataSrc) != SD_SUCCESS) { cfg_set_config_err (); return; } } else if (strcmp (currVarTypeName, "Double") == 0) { if (cfg_get_double ((ST_DOUBLE *)dataSrc) != SD_SUCCESS) { cfg_set_config_err (); return; } } else if (strcmp (currVarTypeName, "Vstring64") == 0) { if ((name = cfg_get_string_ptr ()) == NULL) { cfg_set_config_err (); return; } else strcpy (dataSrc, name); } else { SLOGALWAYS0 ("Invalid Var Tag Type"); printf ("\nInvalid Var Tag Type %s", currVarTypeName); cfg_set_config_err (); return; } /* encode the data */ pstType = ms_find_named_type (&m_vmd_select->vmd_wide, currVarTypeName); if (pstType) { asn1r_strt_asn1_bld (aCtx, asn1Buf, asn1BufSize);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -