Tarfact.cpp
资源名称:hp_snmp3.zip [点击查看]
上传用户:czjinwang
上传日期:2007-01-12
资源大小:2484k
文件大小:2k
源码类别:
SNMP编程
开发平台:
Visual C++
- /*============================================================================
- Copyright (c) 1996
- Hewlett-Packard Company
- ATTENTION: USE OF THIS SOFTWARE IS SUBJECT TO THE FOLLOWING TERMS.
- Permission to use, copy, modify, distribute and/or sell this software
- and/or its documentation is hereby granted without fee. User agrees
- to display the above copyright notice and this license notice in all
- copies of the software and any documentation of the software. User
- agrees to assume all liability for the use of the software; Hewlett-Packard
- makes no representations about the suitability of this software for any
- purpose. It is provided "AS-IS without warranty of any kind,either express
- or implied. User hereby grants a royalty-free license to any and all
- derivatives based upon this software code base.
- =============================================================================*/
- #include "tarfact.h"
- #include "browser.h"
- //---------------------------------------------------------------
- // SNMP++ Target Factory
- // target factory returns an abstract target for a given
- // key
- // Note! A NMS platform will have its own target factory
- // which integrates with its own config database
- SnmpTarget * target_factory( char *key)
- {
- CString filename;
- filename = theApp.GetProfileString( BROWSER_VALUE,DB_NAME,DEF_DB_NAME);
- // create a target class
- Db target_db;
- TargetDb_Rec db_rec;
- target_db.set_attributtes( filename, sizeof( TargetDb_Rec));
- // read the record
- strcpy( db_rec.key, key);
- if ( target_db.read( &db_rec) == DB_OK)
- {
- CTarget *snmptarget;
- snmptarget = new CTarget( (GenAddress) key);
- snmptarget->set_readcommunity( db_rec.read_community);
- snmptarget->set_writecommunity( db_rec.write_community);
- snmptarget->set_timeout( db_rec.timeout);
- snmptarget->set_retry( db_rec.retries);
- snmptarget->set_version( (db_rec.snmp_type == SNMPV1)? version1: version2c );
- return ( snmptarget);
- }
- else
- return NULL;
- };