⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 read_con.c

📁 wm PNE 3.3 source code, running at more than vxworks6.x version.
💻 C
字号:
/* $Header: /usr/cvsroot/target/src/wrn/wm/demo/unxagent/sun/read_con.c,v 1.3 2003/01/15 14:05:00 josh Exp $ *//* * Copyright (C) 1999-2005 Wind River Systems, Inc. * All rights reserved.  Provided under license only. * Distribution or other use of this software is only * permitted pursuant to the terms of a license agreement * from Wind River Systems (and is otherwise prohibited). * Refer to that license agreement for terms of use. *//**************************************************************************** *  Copyright 1988-1997 Epilogue Technology Corporation. *  Copyright 1998 Integrated Systems, Inc. *  All rights reserved. ****************************************************************************//* * $Log: read_con.c,v $ * Revision 1.3  2003/01/15 14:05:00  josh * directory structure shifting * * Revision 1.2  2001/11/09 21:49:03  josh * unxagent demo path adjustment, first pass * * Revision 1.1.1.1  2001/11/05 17:49:17  tneale * Tornado shuffle * * Revision 7.10  2001/06/25 17:06:45  josh * Let's make snark/unxagent build on Solaris * * Revision 7.9  2001/01/19 22:25:02  paul * Update copyright. * * Revision 7.8  2000/03/17 00:15:27  meister * Update copyright message * * Revision 7.7  1998/06/07 03:04:43  sar * Moved the global variables for the non-volatile configuration stuff * and the community strings to the snark library. * Also changed the names of the configuration variables * * Revision 7.6  1998/06/03 22:06:09  sar * Updated code to use common string macros * In agent.c only init the ip stack methods if we are on sunos * * Revision 7.5  1998/02/25 15:22:01  sra * Finish moving types.h, bug.h, and bugdef.h to common/h/. * * Revision 7.4  1998/02/25 04:58:22  sra * Update copyrights. * * Revision 7.3  1997/03/20 06:54:12  sra * DFARS-safe copyright text.  Zap! * * Revision 7.2  1997/02/25 10:58:16  sra * Update copyright notice, dust under the bed. * * Revision 7.1  1997/01/08 23:01:49  sar * Updated copyright and modified include files to use envoy/h as * appropriate * * Revision 7.0  1996/03/15  22:07:57  sar * Updated revision to 7.0 and copyright to 96 * * Revision 6.2  1995/11/11  00:12:33  sar * added a new command option to decide whre the viewtree comes from - * the config.txt file or nvviews.c * * Revision 6.1  1995/11/01  01:03:00  sar * added pp style argument list * changed install of nv config file to be based on rfc1445_view_routines * * Revision 6.0  1995/05/31  21:49:46  sra * Release 6.0. * * Revision 5.2  1995/03/21  19:37:43  sar * Created set_conf_int to translate a string into an integer for the * command processor. * * Revision 5.1  1994/09/29  20:34:40  sar * Modified the allocation of the SNMP_Talk_NV strings we now have * a pointer for use in nvutils.c and a array for use in read_con.c * for each of the the three names. * * Revision 5.0  1994/05/16  16:20:43  sar * Updated revision to 5.0 and copyright to include 1994 * * Revision 4.0  1993/06/24  17:34:02  sar * Updated rev to 4.0 copyright to 93 * * Revision 3.1  1993/05/13  22:20:00  sar * Added defines, includes (<sysent.h>, <errno.h>, <libc.h>) and casts * (struct sockaddr *) as well as changed memfoo to MEMFOO and objidcmp * to llist_cmp to get rid of warnings. * * Revision 3.0  1992/04/03  19:53:44  dab * Release 3.0 * * Revision 2.101  92/02/04  10:47:28  dab * Updated for release 3.0 of SNMP. *  * Revision 2.100  92/02/03  16:46:14  dab * Generic unix SNMP agent. *  *  *    Rev 2.0   31 Mar 1990 15:34:14 * Initial revision. * *//* [clearcase]modification history-------------------01a,19apr05,job  update copyright notices*//* Get the standard types and the install defines */#if !defined(EPILOGUE_TYPES_H)#include <wrn/wm/common/types.h>#endif#include <wrn/wm/common/config.h>#include <wrn/wm/snmp/engine/asn1conf.h>#include <wrn/wm/snmp/engine/snmp.h>#include <wrn/wm/snmp/engine/buildpkt.h>#include <wrn/wm/snmp/engine/auxfuncs.h>#include <sys/types.h>#include <stdio.h>#include <ctype.h>#if !INSTALL_on_solaris#include <a.out.h>#endif#include <fcntl.h>#include <string.h>#include <sys/time.h>#include <errno.h>#include "snmpvars.h"#include "../agent.h"#include <wrn/wm/demo/nvutils.h>#include <wrn/wm/demo/snmpfunc.h>#include <wrn/wm/common/glue.h>extern int errno;extern int name_to_ulong        __((char *tname, u_long *tlong));typedef struct cmd {    char *name;    int (*rtn)();    char *arg1;    int arg2;    } CMD_T;/* Table of commands */extern int set_conf_string  __((char *string, CMD_T *cmd));extern int set_conf_traps   __((char *string, CMD_T *cmd));extern int set_nv_read_only __((char *string, CMD_T *cmd));extern int set_conf_int     __((char *string, CMD_T *cmd));CMD_T cmds[] = {    { "sysdescr", set_conf_string, snmp_sysDescr, MAX_SYSDESCR },    { "syscontact",  set_conf_string, snmp_sysContact, MAX_SYSCONTACT },    { "syslocation", set_conf_string, snmp_sysLocation, MAX_SYSLOCATION },    { "trap-community", set_conf_string, snmp_trap_community, SNMP_COMM_MAX },    { "read-community", set_conf_string, snmp_get_request_community,        SNMP_COMM_MAX },    { "write-community", set_conf_string, snmp_set_request_community,        SNMP_COMM_MAX },    { "trap", set_conf_traps, 0, 0 },    { "kernel-file", set_conf_string, kernel_file, MAX_KERN_FILE },    { "use-async", set_conf_int, (char *)(&snmp_use_async), 0 }, #if (INSTALL_ENVOY_SNMP_VERSION_3 || INSTALL_ENVOY_SNMP_DYNAMIC_VIEWS)    { "nv-views-from-config", set_conf_int, (char *)(&NV_Views_From_Config), 0 },     { "nv-config-file",      set_conf_string,  NV_Config_Static,      MAX_NVF},    { "nv-config-file-old",  set_conf_string,  NV_Old_Config_Static,  MAX_NVF},    { "nv-config-file-temp", set_conf_string,  NV_Temp_Config_Static, MAX_NVF},    { "nv-read-only",        set_nv_read_only, (char *)(&NV_Read_Only), 0},#endif    { 0, 0, 0, 0 }};/**********************************************************************//*                                                                    *//*  Read the configuration file                                       *//*                                                                    *//**********************************************************************/int  read_config(){    FILE *      hostf;    char        linebuff[256];    struct cmd *cmd;    if (trace_level > 2)        printf("Processing configuration file...\n");        /* See if we can find the system in the snmp.hosts file */    if ((hostf = fopen(config_file, "r")) == (FILE *)NULL) {        perror("Can not open agent configuration file");        return -1;        }        for(;;) {        char *ccp;        int cmd_len;        (void) fgets(linebuff, sizeof(linebuff), hostf);        if (feof(hostf) || ferror(hostf)) {            if (trace_level > 2) {                printf("Hit EOF of config file\n");                fflush(stdout);                }            break;            }        /* Weed out any comment text */        if ((ccp = strchr(linebuff, '#')) != (char *)NULL)            *ccp = '\0';                  /* Zap the newline, if any */        if ((ccp = strchr(linebuff, '\n')) != (char *)NULL)            *ccp = '\0';                  if ((linebuff[0] == '\0') || (linebuff[0] == '\n'))            continue;                  /* Parse off the command name */        cmd_len = strcspn(linebuff, " \t");        ccp = linebuff + cmd_len + strspn(linebuff + cmd_len, " \t");        /* Look up the command */        for (cmd = cmds; cmd->name; cmd++) {            if ((strlen(cmd->name) == cmd_len) &&                 (STRNICMP(linebuff, cmd->name, cmd_len) == 0)) {                (*cmd->rtn)(ccp, cmd);                goto next;            }        }        printf("Unknown config command `%s'\n", linebuff);    next:        ;  }    fclose(hostf);    return 0;}int  set_conf_string(       char *string,                  struct cmd  *cmd){    strncpy(cmd->arg1, string, cmd->arg2);    return(0);}/*ARGSUSED*/int  set_conf_traps(       char *string,                 struct cmd  *cmd){    int nnames;    int tlnum;    int thnum;    char thost[MAX_TRAPS_TO][MAX_HOST_NAME_SZ];                  /* The following scanf format is keyed to a value of        */    /* MAX_TRAPS_TO being 5.                                    */    /* It is also keyed to the value of MAX_HOST_NAME_SZ        */    nnames = sscanf(string, "%63s %63s %63s %63s %63s",                    thost[0], thost[1], thost[2], thost[3], thost[4]);    for (thnum = 0, tlnum = 0; thnum < nnames; thnum++) {        if (name_to_ulong(thost[thnum], &(traplist[tlnum])) != -1)          tlnum++;        else printf("Can not resolve trap receiver name \"%s\"\n", thost[thnum]);    }    trap_2_cnt = tlnum;    return(0);}int  set_nv_read_only(       char *string,                   struct cmd  *cmd){    *(int *)cmd->arg1 = atoi(string);    return(0);}int  set_conf_int(       char *string,               struct cmd  *cmd){    *(int *)cmd->arg1 = atoi(string);    return(0);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -