📄 sctmem.c
字号:
/*-------------------------------------------------------+-----*//* | GMD *//* SYSTEM STAMOD - Version 2.0 +-----*//* *//*-------------------------------------------------------------*//* *//* PACKAGE SCTMEM VERSION 2.0 *//* DATE November 1991 *//* BY Levona Eckstein*//* *//* FILENAME *//* sctmem.c *//* *//* DESCRIPTION *//* SCT - Memory - Module *//* *//* EXPORT DESCRIPTION *//* cr_sctlist() create SCT-list out of install- *//* File *//* get_idelem() get SCT-Element *//* search-string = SCT-identifier *//* get_orgelem() get original SCT-Element out *//* of install-file *//* pr_element print sct-element if TRACE *//* *//* Aenderungen Viebeg Beginn *//* sca_get_SCT_config_fname() Get name of SCT configuration *//* file. *//* sca_write_SCT_config() Encrypt and write SCT *//* configuration data. *//* Aenderungen Viebeg End *//* *//* *//* INTERNAL DESCRIPTION *//* del_sctlist delete sct-list *//* init_elem initialize sct element *//* pr_sctlist print sct-list if TRACE *//* *//* IMPORT DESCRIPTION *//* sct_errno error variable from sctint.c *//* *//* Aenderungen Viebeg Beginn *//* *//* STATIC *//* sca_delete_old_SCT_config() Delete old SCT configuration *//* file. *//* sca_get_process_key() Get process key for encryption /*//* decryption of SCT config. *//* sca_int2ascii() Transform integer to asciistring*//* sca_read_SCT_config() Read and decrypt configuration *//* data for the specified SCT. *//* SCT_config_changed() Check whether SCT config data *//* have been changed. *//* aux_add_error() Add error to error stack. *//* aux_cpy_String() Copy string. *//* *//* Aenderungen Viebeg End *//*-------------------------------------------------------------*//*-------------------------------------------------------------*//* include-Files *//*-------------------------------------------------------------*/#include <stdio.h>#include <string.h>#ifdef PROCDAT#define FILEMASK 0600 /* file creation mask (for SCT configuration files) */#include <sys/types.h>#include <sys/stat.h>#include "secsc.h"#include <fcntl.h>#include <errno.h>#else#include "sca.h"#endif /* PROCDAT */#include "sctport.h"#include "install.h"#include "sctmem.h"#include "sctrc.h"#include "sctloc.h"#ifdef MAC#include "Mac.h"#include "baud.h"#endif /* MAC */char *get_unixname();/*-------------------------------------------------------------*//* extern declarations *//*-------------------------------------------------------------*/#ifdef PROCDATextern unsigned int tp1_err; /* error-variable from transmission module */extern int COMinit();#endifextern unsigned int sct_errno; /* error variable */extern char *sct_errmsg;extern SCTerror sct_error[TABLEN];#ifdef TRACEextern FILE *sct_trfp; /* Filepointer of trace file */#endif/*-------------------------------------------------------------*//* forward declarations *//*-------------------------------------------------------------*/static void del_sctlist();static void init_elem();static void pr_sctlist();void pr_element();/*-------------------------------------------------------------*//* type definitions *//*-------------------------------------------------------------*/#ifdef BSD/*#define B19200 14*/#include <sys/ttydev.h>#endif#ifdef SYSTEMV/*#define B19200 14*/#include <sys/ttydev.h>#endif#ifdef __HP__#ifdef SYSV#include <termio.h>#else#include <sgtty.h>#endif#endif/*-------------------------------------------------------------*//* globale variable definitions *//*-------------------------------------------------------------*/struct s_portparam *p_lhead;/*-------------------------------------------------------------*//* lokale Variable definitions *//*-------------------------------------------------------------*/static struct s_portparam *p_llast;static struct s_portparam *p_elem;#ifdef PROCDATstatic int sca_delete_old_SCT_config(); static char *sca_get_process_key();static int sca_read_SCT_config();static int sca_int2ascii();char *sca_get_SCT_config_fname();static Boolean SCT_config_changed();#endif /* PROCDAT *//*--------------------------------------------------------*//* | GMD *//* +-----*//* PROC cr_sctlist VERSION 2.0 *//* DATE November 1991 *//* BY L.Eckstein,GMD *//* *//* DESCRIPTION *//* Create SCT-List *//* In the environment must exists the shell-variable *//* "STAMOD". *//* This shell-variable contains the name of the *//* installation - File *//* *//* *//* IN DESCRIPTION *//* *//* *//* OUT *//* *//* *//* *//* *//* RETURN DESCRIPTION *//* 0 o.k. *//* -1 error *//* ENOSHELL *//* EOPERR *//* EEMPTY *//* EMEMAVAIL *//* ECLERR *//*--------------------------------------------------------*/intcr_sctlist(){ /*----------------------------------------------------------*/ /* Definitions */ /*----------------------------------------------------------*/ char *fileptr; FILE *fd; struct s_record genrecord; int lindex = 0; int i; /*----------------------------------------------------------*/ /* Statements */ /*----------------------------------------------------------*/ /*------------------------------------*/ /* Open file for read */ /*------------------------------------*/ /* read shell - variable */#ifdef MAC if ((fileptr = MacGetEnv("STAMOD")) == NULL) {#else if ((fileptr = getenv("STAMOD")) == NULL) {#endif /* !MAC */ sct_errno = ENOSHELL; sct_errmsg = sct_error[sct_errno].msg; return (S_ERR); }; /* open File for read */ if ((fd = fopen(fileptr, "r")) == NULL) { sct_errno = EOPERR; sct_errmsg = sct_error[sct_errno].msg; return (S_ERR); }; /*------------------------------------*/ /* create SCT-List */ /*------------------------------------*/ if (fread(&genrecord, sizeof(struct s_record), 1, fd) == 0) { sct_errno = EEMPTY; sct_errmsg = sct_error[sct_errno].msg; return (S_ERR); }; do { if (lindex == 0) { /* create first element */#ifdef MALLOC p_lhead = (struct s_portparam *) malloc(sizeof(struct s_portparam));#endif p_llast = p_lhead; } else { /* next element */#ifdef MALLOC p_llast->p_next = (struct s_portparam *) malloc(sizeof(struct s_portparam));#endif p_llast = p_llast->p_next; }; if (p_llast != PORTNULL) { memcpy(p_llast->port_name, genrecord.port_name, LPORTNAME); p_llast->port_name[LPORTNAME] = '\0'; for (i = 0; i < LPORTNAME; i++) { if (p_llast->port_name[i] == 0x20) { p_llast->port_name[i] = '\0'; break; }; }; /*------------------------------------------------------*/ /* Initialize element */ /*------------------------------------------------------*/ init_elem(p_llast, &genrecord, TRUE); p_llast->p_next = PORTNULL; /*------------------------------------------------------*/ /* create next element */ /*------------------------------------------------------*/ lindex++; } else { sct_errno = EMEMAVAIL; sct_errmsg = sct_error[sct_errno].msg; /* delete sct-list */ fclose(fd); del_sctlist(); return (S_ERR); }; } while (fread(&genrecord, sizeof(struct s_record), 1, fd) != 0); /*------------------------------------*/ /* close Installation File */ /*------------------------------------*/ if (fclose(fd) != 0) { sct_errno = ECLERR; sct_errmsg = sct_error[sct_errno].msg; return (S_ERR); };#ifdef TRACE /* print list */ fprintf(sct_trfp, "FUNCTION cr_sctlist: \n"); pr_sctlist(sct_trfp);#endif return (0);}/*-------------------------------------------------------------*//* E N D O F P R O C E D U R E cr_sctlist *//*-------------------------------------------------------------*//*--------------------------------------------------------*//* | GMD *//* +-----*//* PROC get_idelem VERSION 2.0 *//* DATE November 1991 *//* BY L.Eckstein,GMD *//* *//* DESCRIPTION *//* Get sct-element with search-string = sct_id *//* Aenderungen Viebeg Beginn *//* If the configuration for the SCT (sct_id=1|2) has not been *//* done: *//* *//* => 1. Get key for the decryption of the SCT config data *//* 2a. There is a key: *//* Read SCA SCT configuration data: *//* The data for the specified SCT are read, decrypted *//* and set into "p_elem". *//* If no configuration file for the specified SCT *//* exists, the value of p_elem is left unchanged. *//* If the port to the specified SCT has already been *//* opened by a previous process, the port is opened *//* again. *//* 2b. There is no key: *//* The value of p_elem is left unchanged. *//* *//* Aenderungen Viebeg End *//* *//* *//* IN DESCRIPTION *//* fd filedescriptor *//* *//* OUT *//* *//* *//* RETURN DESCRIPTION *//* Pointer Pointer of sct-element *//* POINTNULL error *//* ESIDUNK *//* Aenderungen Viebeg Beginn *//* *//* CALLED FUNCTIONS DESCRIPTION *//* sca_get_process_key() Get process key for encryption /*//* decryption of SCT config. *//* sca_read_SCT_config() Read and decrypt configuration *//* file for the specified SCT. *//* aux_add_error() Add error to error stack. *//* *//* Aenderungen Viebeg End *//*--------------------------------------------------------*/struct s_portparam *get_idelem(sct_id) int sct_id;{ /*----------------------------------------------------------*/ /* Definitions */ /*----------------------------------------------------------*/ int i;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -