📄 mmsapp.c
字号:
/************************************************************************//* SISCO SOFTWARE MODULE HEADER *****************************************//************************************************************************//* (c) Copyright Systems Integration Specialists Company, Inc., *//* 1986 - 2002, All Rights Reserved. *//* *//* MODULE NAME : mmsapp.c *//* PRODUCT(S) : MMSEASE *//* *//* MODULE DESCRIPTION : *//* This module contains the 'main' function, powerup code, SUIC *//* function, invoke sample functions, screen and function key *//* setup, etc. *//* *//* GLOBAL FUNCTIONS DEFINED IN THIS MODULE : *//* *//* MODIFICATION LOG : *//* Date Who Rev Comments *//* -------- --- ------ ------------------------------------------- *//* 08/21/02 EJV 37 Added call to dyn_mem_ptr_status. *//* 07/19/02 EJV 36 Changed version to 7.10 (Tru64 & Windows rel)*//* 02/01/02 EJV 35 Changed copyright year . *//* 11/29/01 EJV 34 Del code for old LATT, XENIX, ultrix, RMX86. *//* 11/28/01 EJV 33 Changed version to 7.09 (Windows rel). *//* 10/19/01 EJV 32 mms_comm_service: deleted 'while' that caused*//* full pipes deadlock, now SUIC handles READY.*//* Replaced few defs with 'SYSTEM_SEL & SYS_5' *//* Reworked UNIX includes. *//* 09/21/01 EJV 31 Changed version to 7.08 (Sun Solaris 8 rel) *//* 09/24/01 EJV 30 Changed SISCO phone to (586) 254-0020. *//* 08/07/01 EJV 29 Changed version to 7.073 (Tru64 UNIX release)*//* 05/16/01 EJV 28 term_init, term_rest protos now in fkeydefs.h*//* SYS_5: use new funcs term_init, term_rest. *//* 03/21/01 EJV 27 Changed version to 7.07 (Tru64 UNIX release) *//* 12/06/00 EJV 26 Added support for unnamed variables *//* 10/12/00 EJV 25 Changed version to 7.06 (implemented glbsem *//* on DIGITAL UNIX). Revised sigfun, sigbus. *//* 09/06/00 RKR 24 Changed version to 7.05. *//* 05/03/00 EJV 23 Added initialization of m_mem_debug=SD_TRUE *//* 04/19/00 EJV 22 Changed version to 7.04. *//* EXtended copyright year to 2000. *//* 01/11/00 RKR 21 Added call for BLOCK_VARIABLE_SUPPORT *//* 02/08/99 JRB 20 If LEAN_T, use 1 sec timeout so timers work. *//* If UCA_SMP, call smp_init. *//* 01/05/99 EJV 19 Changed version to V7.03 *//* 10/12/98 EJV 18 UNIX systems - mms_comm_service check if *//* stack's pipe has place for READY msg. *//* 08/28/98 EJV 17 Renamed noecho to set_echo_off. *//* 07/21/98 EJV 16 Added do_auto_disc. *//* 06/26/98 EJV 15 Make sure __alpha for DECUNIX is defined *//* 06/17/98 EJV 14 Added init of s_max_pipe_size for __alpha. *//* 03/24/98 EJV 13 version update and use SISCO's def (SD_TRUE) *//* 03/06/98 EJV 12 version update *//* 01/26/98 EJV 11 Changed param in proto of wait_any_event. *//* 01/02/98 EJV 10 added #if defined(sun) to event handling func*//* 12/30/97 EJV 09 Changed signal handler to have int param. *//* 11/20/97 RKR 08 version update *//* 10/24/97 JRB 07 Add UCA_SMP code. *//* 10/20/97 DSF 06 No more M_USE_BSEARCH *//* 10/20/97 RKR 05 fixed a typo *//* 07/29/97 DSF 04 No more ms_load_tpy_dib () *//* 06/20/97 MDE 03 Removed SPECIAL_DATA ifdefs *//* 06/03/97 RKR 02 Changed USE_VA_BSEARCH to M_USE_BSEARCH *//* 05/22/97 RKR 01 Changed mms_comm_service and default timeout *//* 04/15/97 DSF 7.00 MMSEASE 7.0 release. See MODL70.DOC for *//* history. *//************************************************************************/#include "glbtypes.h"#include "sysincs.h"#if defined (VXWORKS)#include <selectLib.h>#endif /* VXWORKS */#if defined (__OS2__)#define INCL_DOS#define INCL_DOSERRORS#include <os2.h>SEMRECORD sems[2];HMUX muxAnyEvent;extern HEV s_read_event_sem;extern HMTX o_kbd_event_sem;#endif #if defined (_WIN32)#include <windows.h>extern HANDLE kbdEvent;#endif#ifdef VXWORKS#include <ioLib.h>#endif#if (SYSTEM_SEL & (MSOFT | OS2))#include <conio.h>#endif/*#define USE_MRA*/#if (SYSTEM_SEL & (MSOFT | OS2))#ifndef __OS2__#include <dos.h>#endif#include <process.h>#endif#if (SYSTEM_SEL & (SYS_5))#include <signal.h>void sigfun (int sig);void sigbus (int sig);#endif#include "mem_chk.h"#include "mms_usr.h" /* to access MMS fucntions, variables */#include "mms_pcon.h"#include "mms_vcon.h"#include "mms_pvar.h"#include "mms_vvar.h"#include "mms_ms.h"#include "mms_llp.h"#include "mmsop_en.h"#include "asn1defs.h" /* to access ASN.1 variables */#include "mem_chk.h"#include "gvaldefs.h"#include "scrndefs.h"#include "userdefs.h"#include "fkeydefs.h" /* Function key handling */#include "stime.h"#ifdef USE_MLOG#include "mloguser.h"#endif#include "suicacse.h"#if (SYSTEM_SEL & (OPEN_VMS))#include <time.h>#endif#if defined (_AIX)#include <sys/select.h>#include <errno.h>#endif#if (defined (__alpha) && !defined(__VMS))#include <sys/time.h>#include <sys/select.h>#include <errno.h>#endif#if defined (__hpux)#include <errno.h>#endif#if defined(UCA_SMP)#include "smp_usr.h"ST_VOID do_uca_timesync (ST_VOID);#endif /* UCA_SMP */#ifdef VXWORKS int vxfd;#endif#if (SYSTEM_SEL & (OPEN_VMS)) /* Functional Prototypes for functions found in mvkey.c */ void wait_any_event_vms (ST_INT32);#endifST_VOID wait_any_event (ST_LONG);ST_VOID init_event_handling (ST_VOID);#if (SYSTEM_SEL & (MSOFT))static ST_CHAR c = 'F'; /* MSDOS machines only use fun keys */static ST_CHAR str [] = "F10";#elsestatic ST_CHAR c = ' ';static ST_CHAR str [] = " 0 ";#endif#ifdef PSOS_SYSTEMextern char LastKeyHit;extern short AKeyWasHit;extern short NetReadDataPresent;extern short EchoFlag;extern unsigned long TasksInSystemID[];#endif/************************************************************************//* For debug version, use a static pointer to avoid duplication of *//* __FILE__ strings. *//************************************************************************/#ifdef DEBUG_SISCOstatic ST_CHAR *thisFileName = __FILE__;#endif/************************************************************************/static ST_INT quiet;static ST_BOOLEAN doit;/************************************************************************//* event_service *//************************************************************************/ST_INT event_count = 0; /* outstanding events */ST_BOOLEAN use_events;ST_LONG total_events = 0;ST_LONG comm_serve_count = 0;/* If we are using MMS events, this function will be called when MMS *//* requires servicing */ST_VOID event_service (ST_INT count) { total_events += count; event_count += count; }/************************************************************************//* mms_comm_service *//************************************************************************/#if (SYSTEM_SEL & SYS_5)ST_VOID mms_comm_service (ST_VOID) {ST_RET ret;static struct timeval time_to_wait = {0, 50000}; /* {0 sec,50 msec} */ comm_serve_count = 0; while (doit) { if (ret = ms_comm_serve ()) /* do all MMSEASE service */ comm_serve_count++; else break; } if (!doit) return; if (comm_serve_count == 0)#ifdef LEAN_T wait_any_event (1000); /* LEAN_T needs 1 sec timeout so timers work*/#else wait_any_event (10000); /* wait for action or timeout in 10 sec*/#endif }#else /* Non-UNIX systems */ST_VOID mms_comm_service (ST_VOID) {ST_RET ret; comm_serve_count = 0; while (ret = ms_comm_serve ()) /* do all MMSEASE service */ { comm_serve_count++; } if (comm_serve_count == 0)#ifdef LEAN_T wait_any_event (1000); /* LEAN_T needs 1 sec timeout so timers work*/#else wait_any_event (10000); /* wait for action */#endif }#endif /* Non-UNIX systems *//************************************************************************//************************************************************************//************************************************************************//************************************************************************//************************************************************************//* menu_service *//************************************************************************/ST_VOID menu_service (ST_VOID) {#ifdef PSOS_SYSTEM while (1) { /* wait for an event */ wait_any_event (100); if (AKeyWasHit == 1) { if (check_key () == 1) break; } if (NetReadDataPresent != 0) { mms_comm_service (); } }#else while (check_key () != 1 && doit) /* Execute function keys until F10 hit */ { mms_comm_service (); /* do case rx/tx interface service */ update_var_blocks(TIME_CTXT); }#endif } /************************************************************************//************************************************************************//************************************************************************//* main *//* This is the main function for the MMS sample application. *//* This is where the various initialization of the MAP modules takes *//* place, as well as any system specific setup. *//************************************************************************/#ifdef VXWORKSST_INT mmsdemo (ST_VOID)#elseST_INT main (int argc, char **argv)#endif {ST_RET ret;#ifdef REQUIRE_S_LOGFILE *fp;#endif#if defined (__OS2__)APIRET apiret;#endif#if DIRECTORY_SUPPORTstatic MDS_USERID x500_userid;static MDS_USERID ldap_userid;#endif /* set the flag allowing to track memory problems (previously set in lib code) */ m_mem_debug = SD_TRUE;#if (SYSTEM_SEL & SYS_5) setbuf (stdout,NULL); /* no buffering, please */#endif#ifdef VXWORKS /* Redirect stdin, stdout, and stderr to COM2: */ if ((vxfd=open ("/tyCo/1", O_RDWR,0)) == -1) { fprintf (stderr, "open /tyCo/1 %s\n", strerror (errno)); exit (EXIT_FAILURE); } ioTaskStdSet (0,0,vxfd); ioTaskStdSet (0,1,vxfd); ioTaskStdSet (0,2,vxfd);#endif /* VXWORKS */#ifndef VXWORKS/* Allow automatic startup */ if (argc == 2 && !strcmp (argv[1], "-q")) quiet = SD_TRUE; else#endif /* VXWORKS */ quiet = SD_FALSE;/* First do any system specific initialization, for screen, etc. */#if (SYSTEM_SEL & (SYS_5)) term_init (); (*signal) (SIGINT, sigfun); (*signal) (SIGBUS, sigbus); (*signal) (SIGSEGV, sigbus);#endif#if (SYSTEM_SEL & (QNX_C86))int option_save; option_save = term_init ();#endif#if (SYSTEM_SEL & (OPEN_VMS | SYS_BSD | OS2 | SYSVXWORKS | SYS_QNX4 | NEW_SYSTEM)) term_init ();#endif#if defined (_WIN32) term_init ();#endif#if (SYSTEM_SEL & (SYS_BSD)) set_echo_off ();#endif CLEARSCR;/* Initialize the logging system *//* First see if the user wants to use the log configuration file */#ifdef REQUIRE_S_LOG if (quiet || ask ("\n Set Logging per configuration file (Y) ? ",SD_TRUE)) {/* see if the new slog configuration file is around before resorting to *//* oring bit masks. */ if (fp = fopen (MMS_LOG_CFG_FILE, "r")) { fclose (fp); m_set_log_config (MMS_LOG_CFG_FILE); } else m_set_log_cfg (MMSLOG_CFG_FILE); } else#endif mms_debug_sel |= (MMS_LOG_USR_CONF | MMS_LOG_USR_IND);/* Check to see if the user wants to change the logging */ if (!quiet && ask (" Modify DEBUG print levels (N) ? ",0)) { menu_set_fun = set_null_menu; /* used to reset the menu */ do_debugset ();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -