本文整理汇总了C++中config_perror函数的典型用法代码示例。如果您正苦于以下问题:C++ config_perror函数的具体用法?C++ config_perror怎么用?C++ config_perror使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了config_perror函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: snmpd_parse_config_informsink
void
snmpd_parse_config_informsink(const char *word, char *cptr)
{
char tmpbuf[1024];
char *sp, *cp, *pp = NULL;
u_short sinkport;
if (!snmp_trapcommunity) snmp_trapcommunity = strdup("public");
sp = strtok(cptr, " \t\n");
cp = strtok(NULL, " \t\n");
if (cp) pp = strtok(NULL, " \t\n");
if (cp && pp) {
sinkport = atoi(pp);
if ((sinkport < 1) || (sinkport > 0xffff)) {
config_perror("trapsink port out of range");
sinkport = SNMP_TRAP_PORT;
}
} else {
sinkport = SNMP_TRAP_PORT;
}
if (create_v2_inform_session(sp, sinkport,
cp ? cp : snmp_trapcommunity) == 0) {
sprintf(tmpbuf,"cannot create informsink: %s", cptr);
config_perror(tmpbuf);
}
}
示例2: proxyOptProc
static void
proxyOptProc(int argc, char *const *argv, int opt)
{
switch (opt) {
case 'C':
while (*optarg) {
switch (*optarg++) {
case 'n':
optind++;
if (optind < argc) {
context_string = argv[optind - 1];
} else {
config_perror("No context name passed to -Cn");
}
break;
case 'c':
netsnmp_ds_set_boolean(NETSNMP_DS_LIBRARY_ID,
NETSNMP_DS_LIB_IGNORE_NO_COMMUNITY, 1);
break;
default:
config_perror("unknown argument passed to -C");
break;
}
}
break;
default:
break;
/*
* shouldn't get here
*/
}
}
示例3: disk_parse_config_all
static void disk_parse_config_all (const char *token, char *cptr)
{
#if HAVE_FSTAB_H || HAVE_GETMNTENT || HAVE_STATFS
int minpercent = DISKMINPERCENT;
if (numdisks == maxdisks)
{
if (maxdisks == 0)
{
maxdisks = 50;
disks = (struct diskpart *) malloc (maxdisks * sizeof (struct diskpart));
if (!disks)
{
config_perror ("malloc failed for new disk allocation.");
netsnmp_config_error ("\tignoring: %s", cptr);
return;
}
memset (disks, 0, maxdisks * sizeof (struct diskpart));
}
else
{
maxdisks *= 2;
disks = (struct diskpart *) realloc (disks, maxdisks * sizeof (struct diskpart));
if (!disks)
{
config_perror ("malloc failed for new disk allocation.");
netsnmp_config_error ("\tignoring: %s", cptr);
return;
}
memset (disks + maxdisks / 2, 0, maxdisks / 2 * sizeof (struct diskpart));
}
}
/*
* read the minimum disk usage percent
*/
if (cptr != NULL)
{
if (strchr (cptr, '%') != NULL)
{
minpercent = atoi (cptr);
}
}
/*
* if we have already seen the "includeAllDisks" directive
* then search for the disk in the "disks" array and modify
* the values. if we havent seen the "includeAllDisks"
* directive then include this disk
*/
if (allDisksIncluded)
{
config_perror ("includeAllDisks already specified.");
netsnmp_config_error ("\tignoring: includeAllDisks %s", cptr);
}
else
{
allDisksIncluded = 1;
find_and_add_allDisks (minpercent);
}
#endif /* HAVE_FSTAB_H || HAVE_GETMNTENT || HAVE_STATFS */
}
示例4: proxyOptProc
static void
proxyOptProc(int argc, char *const *argv, int opt)
{
switch (opt) {
case 'C':
while (*optarg) {
switch (*optarg++) {
case 'n':
optind++;
if (optind < argc) {
context_string = argv[optind - 1];
} else {
config_perror("No context name passed to -Cn");
}
break;
default:
config_perror("unknown argument passed to -C");
break;
}
}
break;
default:
break;
/*
* shouldn't get here
*/
}
}
示例5: snmpd_set_agent_group
void
snmpd_set_agent_group(const char *token, char *cptr)
{
#if defined(HAVE_GETGRNAM) && defined(HAVE_GRP_H)
struct group *info;
#endif
if (cptr[0] == '#') {
char *ecp;
int gid = strtoul(cptr + 1, &ecp, 10);
if (*ecp != 0) {
config_perror("Bad number");
} else {
netsnmp_ds_set_int(NETSNMP_DS_APPLICATION_ID,
NETSNMP_DS_AGENT_GROUPID, gid);
}
}
#if defined(HAVE_GETGRNAM) && defined(HAVE_GRP_H)
else if ((info = getgrnam(cptr)) != NULL) {
netsnmp_ds_set_int(NETSNMP_DS_APPLICATION_ID,
NETSNMP_DS_AGENT_GROUPID, info->gr_gid);
} else {
config_perror("Group not found in group database");
}
endpwent();
#endif
}
示例6: vacm_parse_authtokens
int
vacm_parse_authtokens(const char *token, char **confline)
{
char authspec[SNMP_MAXBUF_MEDIUM];
char *strtok_state;
char *type;
int viewtype, viewtypes = 0;
*confline = copy_nword(*confline, authspec, sizeof(authspec));
DEBUGMSGTL(("vacm_parse_authtokens","parsing %s",authspec));
if (!*confline) {
config_perror("Illegal configuration line: missing fields");
return -1;
}
type = strtok_r(authspec, ",|:", &strtok_state);
while(type && *type != '\0') {
viewtype = se_find_value_in_slist(VACM_VIEW_ENUM_NAME, type);
if (viewtype < 0 || viewtype >= VACM_MAX_VIEWS) {
config_perror("Illegal view name");
} else {
viewtypes |= (1 << viewtype);
}
type = strtok_r(NULL, ",|:", &strtok_state);
}
DEBUGMSG(("vacm_parse_authtokens"," .. result = 0x%x\n",viewtypes));
return viewtypes;
}
示例7: parse_snmpNotifyTable
/*
* parse_snmpNotifyTable():
* parses .conf file entries needed to configure the mib.
*/
void
parse_snmpNotifyTable(const char *token, char *line)
{
size_t tmpint;
struct snmpNotifyTable_data *StorageTmp =
SNMP_MALLOC_STRUCT(snmpNotifyTable_data);
DEBUGMSGTL(("snmpNotifyTable", "parsing config... "));
if (StorageTmp == NULL) {
config_perror("malloc failure");
return;
}
line =
read_config_read_data(ASN_OCTET_STR, line,
&StorageTmp->snmpNotifyName,
&StorageTmp->snmpNotifyNameLen);
if (StorageTmp->snmpNotifyName == NULL) {
config_perror("invalid specification for snmpNotifyName");
return;
}
line =
read_config_read_data(ASN_OCTET_STR, line,
&StorageTmp->snmpNotifyTag,
&StorageTmp->snmpNotifyTagLen);
if (StorageTmp->snmpNotifyTag == NULL) {
config_perror("invalid specification for snmpNotifyTag");
return;
}
line =
read_config_read_data(ASN_INTEGER, line,
&StorageTmp->snmpNotifyType, &tmpint);
line =
read_config_read_data(ASN_INTEGER, line,
&StorageTmp->snmpNotifyStorageType, &tmpint);
if (!StorageTmp->snmpNotifyStorageType)
StorageTmp->snmpNotifyStorageType = ST_READONLY;
line =
read_config_read_data(ASN_INTEGER, line,
&StorageTmp->snmpNotifyRowStatus, &tmpint);
if (!StorageTmp->snmpNotifyRowStatus)
StorageTmp->snmpNotifyRowStatus = RS_ACTIVE;
if (snmpNotifyTable_add(StorageTmp) != SNMPERR_SUCCESS){
SNMP_FREE(StorageTmp->snmpNotifyName);
SNMP_FREE(StorageTmp->snmpNotifyTag);
SNMP_FREE(StorageTmp);
}
DEBUGMSGTL(("snmpNotifyTable", "done.\n"));
}
示例8: parse_config_agentuser
void
parse_config_agentuser(const char *token, char *cptr)
{
if (cptr[0] == '#') {
char *ecp;
int uid;
uid = strtoul(cptr + 1, &ecp, 10);
if (*ecp != 0) {
config_perror("Bad number");
} else {
netsnmp_ds_set_int(NETSNMP_DS_APPLICATION_ID,
NETSNMP_DS_AGENT_USERID, uid);
}
#if defined(HAVE_GETPWNAM) && defined(HAVE_PWD_H)
} else {
struct passwd *info;
info = getpwnam(cptr);
if (info)
netsnmp_ds_set_int(NETSNMP_DS_APPLICATION_ID,
NETSNMP_DS_AGENT_USERID, info->pw_uid);
else
config_perror("User not found in passwd database");
endpwent();
#endif
}
}
示例9: parse_config_agentgroup
void
parse_config_agentgroup(const char *token, char *cptr)
{
if (cptr[0] == '#') {
char *ecp;
int gid = strtoul(cptr + 1, &ecp, 10);
if (*ecp != 0) {
config_perror("Bad number");
} else {
netsnmp_ds_set_int(NETSNMP_DS_APPLICATION_ID,
NETSNMP_DS_AGENT_GROUPID, gid);
}
#if defined(HAVE_GETGRNAM) && defined(HAVE_GRP_H)
} else {
struct group *info;
info = getgrnam(cptr);
if (info)
netsnmp_ds_set_int(NETSNMP_DS_APPLICATION_ID,
NETSNMP_DS_AGENT_GROUPID, info->gr_gid);
else
config_perror("Group not found in group database");
endgrent();
#endif
}
}
示例10: parse_snmpNotifyFilterTable
/*
* parse_snmpNotifyFilterTable():
* parses .conf file entries needed to configure the mib.
*/
void
parse_snmpNotifyFilterTable(const char *token, char *line)
{
size_t tmpint;
struct snmpNotifyFilterTable_data *StorageTmp =
SNMP_MALLOC_STRUCT(snmpNotifyFilterTable_data);
DEBUGMSGTL(("snmpNotifyFilterTable", "parsing config... "));
if (StorageTmp == NULL) {
config_perror("malloc failure");
return;
}
line =
read_config_read_data(ASN_OCTET_STR, line,
&StorageTmp->snmpNotifyFilterProfileName,
&StorageTmp->snmpNotifyFilterProfileNameLen);
if (StorageTmp->snmpNotifyFilterProfileName == NULL) {
config_perror
("invalid specification for snmpNotifyFilterProfileName");
return;
}
line =
read_config_read_data(ASN_OBJECT_ID, line,
&StorageTmp->snmpNotifyFilterSubtree,
&StorageTmp->snmpNotifyFilterSubtreeLen);
if (StorageTmp->snmpNotifyFilterSubtree == NULL) {
config_perror("invalid specification for snmpNotifyFilterSubtree");
return;
}
line =
read_config_read_data(ASN_OCTET_STR, line,
&StorageTmp->snmpNotifyFilterMask,
&StorageTmp->snmpNotifyFilterMaskLen);
line =
read_config_read_data(ASN_INTEGER, line,
&StorageTmp->snmpNotifyFilterType, &tmpint);
line =
read_config_read_data(ASN_INTEGER, line,
&StorageTmp->snmpNotifyFilterStorageType,
&tmpint);
line =
read_config_read_data(ASN_INTEGER, line,
&StorageTmp->snmpNotifyFilterRowStatus,
&tmpint);
snmpNotifyFilterTable_add(StorageTmp);
DEBUGMSGTL(("snmpNotifyFilterTable", "done.\n"));
}
示例11: vacm_parse_setaccess
void
vacm_parse_setaccess(const char *token, char *param)
{
char *name, *context, *viewname, *viewval;
int imodel, ilevel, iprefix;
int viewnum;
char *st;
struct vacm_accessEntry *ap;
if (_vacm_parse_access_common(token, param, &st, &name,
&context, &imodel, &ilevel, &iprefix)
== PARSE_FAIL) {
return;
}
viewname = strtok_r(NULL, " \t\n", &st);
if (!viewname) {
config_perror("missing viewname parameter");
return;
}
viewval = strtok_r(NULL, " \t\n", &st);
if (!viewval) {
config_perror("missing viewval parameter");
return;
}
if (strlen(viewval) + 1 > sizeof(ap->views[VACM_VIEW_NOTIFY])) {
config_perror("View value too long");
return;
}
viewnum = se_find_value_in_slist(VACM_VIEW_ENUM_NAME, viewname);
if (viewnum < 0 || viewnum >= VACM_MAX_VIEWS) {
config_perror("Illegal view name");
return;
}
ap = vacm_getAccessEntry(name, context, imodel, ilevel);
if (!ap) {
ap = vacm_createAccessEntry(name, context, imodel, ilevel);
DEBUGMSGTL(("vacm:conf:setaccess",
"no existing access found; creating a new one\n"));
} else {
DEBUGMSGTL(("vacm:conf:setaccess",
"existing access found, using it\n"));
}
if (!ap) {
config_perror("failed to create access entry");
return;
}
strcpy(ap->views[viewnum], viewval);
ap->contextMatch = iprefix;
ap->storageType = SNMP_STORAGE_PERMANENT;
ap->status = SNMP_ROW_ACTIVE;
free(ap->reserved);
ap->reserved = NULL;
}
示例12: parse_lookupResultsTable
void
parse_lookupResultsTable(const char *token, char *line)
{
size_t tmpint;
struct lookupResultsTable_data *StorageTmp =
SNMP_MALLOC_STRUCT(lookupResultsTable_data);
DEBUGMSGTL(("lookupResultsTable", "parsing config... "));
if (StorageTmp == NULL) {
config_perror("malloc failure");
return;
}
line =
read_config_read_data(ASN_OCTET_STR, line,
&StorageTmp->lookupCtlOwnerIndex,
&StorageTmp->lookupCtlOwnerIndexLen);
if (StorageTmp->lookupCtlOwnerIndex == NULL) {
config_perror("invalid specification for lookupCtlOwnerIndex");
return;
}
line =
read_config_read_data(ASN_OCTET_STR, line,
&StorageTmp->lookupCtlOperationName,
&StorageTmp->lookupCtlOperationNameLen);
if (StorageTmp->lookupCtlOperationName == NULL) {
config_perror("invalid specification for lookupCtlOperationName");
return;
}
line =
read_config_read_data(ASN_UNSIGNED, line,
&StorageTmp->lookupResultsIndex, &tmpint);
line =
read_config_read_data(ASN_INTEGER, line,
&StorageTmp->lookupResultsAddressType,
&tmpint);
line =
read_config_read_data(ASN_OCTET_STR, line,
&StorageTmp->lookupResultsAddress,
&StorageTmp->lookupResultsAddressLen);
if (StorageTmp->lookupResultsAddress == NULL) {
config_perror("invalid specification for lookupResultsAddress");
return;
}
lookupResultsTable_inadd(StorageTmp);
/* lookupResultsTable_cleaner(lookupResultsTableStorage); */
DEBUGMSGTL(("lookupResultsTable", "done.\n"));
}
示例13: parse_snmpNotifyFilterProfileTable
/*
* parse_snmpNotifyFilterProfileTable():
* parses .conf file entries needed to configure the mib.
*/
void
parse_snmpNotifyFilterProfileTable(const char *token, char *line)
{
size_t tmpint;
struct snmpNotifyFilterProfileTable_data *StorageTmp =
SNMP_MALLOC_STRUCT(snmpNotifyFilterProfileTable_data);
DEBUGMSGTL(("snmpNotifyFilterProfileTable", "parsing config... "));
if (StorageTmp == NULL) {
config_perror("malloc failure");
return;
}
line =
read_config_read_data(ASN_OCTET_STR, line,
&StorageTmp->snmpTargetParamsName,
&StorageTmp->snmpTargetParamsNameLen);
if (StorageTmp->snmpTargetParamsName == NULL) {
config_perror("invalid specification for snmpTargetParamsName");
return;
}
line =
read_config_read_data(ASN_OCTET_STR, line,
&StorageTmp->snmpNotifyFilterProfileName,
&StorageTmp->snmpNotifyFilterProfileNameLen);
if (StorageTmp->snmpNotifyFilterProfileName == NULL) {
config_perror("invalid specification for snmpNotifyFilterProfileName");
return;
}
line =
read_config_read_data(ASN_INTEGER, line,
&StorageTmp->snmpNotifyFilterProfileStorType,
&tmpint);
line =
read_config_read_data(ASN_INTEGER, line,
&StorageTmp->
snmpNotifyFilterProfileRowStatus, &tmpint);
if (snmpNotifyFilterProfileTable_add(StorageTmp) != SNMPERR_SUCCESS){
SNMP_FREE(StorageTmp->snmpTargetParamsName);
SNMP_FREE(StorageTmp->snmpNotifyFilterProfileName);
SNMP_FREE(StorageTmp);
}
DEBUGMSGTL(("snmpNotifyFilterProfileTable", "done.\n"));
}
示例14: snmpv3_secLevel_conf
/*******************************************************************-o-******
* snmpv3_secLevel_conf
*
* Parameters:
* *word
* *cptr
*
* Line syntax:
* defSecurityLevel "noAuthNoPriv" | "authNoPriv" | "authPriv"
*/
void
snmpv3_secLevel_conf(const char *word, char *cptr)
{
char buf[1024];
if (strcasecmp(cptr, "noAuthNoPriv") == 0 || strcmp(cptr, "1") == 0 ||
strcasecmp(cptr, "nanp") == 0) {
netsnmp_ds_set_int(NETSNMP_DS_LIBRARY_ID,
NETSNMP_DS_LIB_SECLEVEL, SNMP_SEC_LEVEL_NOAUTH);
} else if (strcasecmp(cptr, "authNoPriv") == 0 || strcmp(cptr, "2") == 0 ||
strcasecmp(cptr, "anp") == 0) {
netsnmp_ds_set_int(NETSNMP_DS_LIBRARY_ID,
NETSNMP_DS_LIB_SECLEVEL, SNMP_SEC_LEVEL_AUTHNOPRIV);
} else if (strcasecmp(cptr, "authPriv") == 0 || strcmp(cptr, "3") == 0 ||
strcasecmp(cptr, "ap") == 0) {
netsnmp_ds_set_int(NETSNMP_DS_LIBRARY_ID,
NETSNMP_DS_LIB_SECLEVEL, SNMP_SEC_LEVEL_AUTHPRIV);
} else {
snprintf(buf, sizeof(buf), "Unknown security level: %s", cptr);
buf[ sizeof(buf)-1 ] = 0;
config_perror(buf);
}
DEBUGMSGTL(("snmpv3", "default secLevel set to: %s = %d\n", cptr,
netsnmp_ds_get_int(NETSNMP_DS_LIBRARY_ID,
NETSNMP_DS_LIB_SECLEVEL)));
}
示例15: system_parse_config_sysObjectID
void system_parse_config_sysObjectID(const char *token, char *cptr)
{
char tmpbuf[1024];
sysObjectIDLength = MAX_OID_LEN;
if (!read_objid(cptr, sysObjectID, &sysObjectIDLength)) {
snprintf(tmpbuf,
sizeof(tmpbuf),
"sysobjectid token not a parsable OID:\n\t%s",
cptr);
config_perror(tmpbuf);
// Modified by Gavin Lin, 2008/10/30
//memcpy(sysObjectID, version_sysoid, version_sysoid_len * sizeof(oid));
//sysObjectIDLength = version_sysoid_len;
#ifdef CONFIG_MODEL_LRTXXX
/* purpose : 0012697 author : Gavin.Lin date : 2010-06-22 */
/* description : Customer requirements */
kd_doCommand("VERSION MODEL", CMD_PRINT, ASH_DO_NOTHING, tmpbuf);
if (!strcmp("LRT214", tmpbuf))
{
memcpy(sysObjectID, nk_sysobjectid_214, nk_sysobjectid_len * sizeof(oid));
}
if (!strcmp("LRT224", tmpbuf))
{
memcpy(sysObjectID, nk_sysobjectid_224, nk_sysobjectid_len * sizeof(oid));
}
#else
memcpy(sysObjectID, nk_sysobjectid, nk_sysobjectid_len * sizeof(oid));
#endif
sysObjectIDLength = nk_sysobjectid_len;
}
}