aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org>2019-07-10 19:24:03 +0300
committerSergey Poznyakoff <gray@gnu.org>2019-07-10 19:24:03 +0300
commit83582b43ae232809fe7a718b3439218d625afb66 (patch)
tree3e6eb370c7e7dc4d691bc5776d4d05061ced32c5
parentdb70332594c75b60baf7e257c68129b43f33e4c1 (diff)
downloadslb-83582b43ae232809fe7a718b3439218d625afb66.tar.gz
slb-83582b43ae232809fe7a718b3439218d625afb66.tar.bz2
Switch to grecs b06fb7d3
-rwxr-xr-xbootstrap3
m---------grecs0
-rw-r--r--src/Makefile.am4
-rw-r--r--src/config.c10
-rw-r--r--src/expr.y6
-rw-r--r--src/exprtab.c6
-rw-r--r--src/logger.c4
-rw-r--r--src/oidtab.c4
-rw-r--r--src/output.c8
-rw-r--r--src/slb.c6
-rw-r--r--src/snmploop.c37
-rw-r--r--src/symimp.c8
12 files changed, 45 insertions, 51 deletions
diff --git a/bootstrap b/bootstrap
index ae677ac..494dfa0 100755
--- a/bootstrap
+++ b/bootstrap
@@ -1,5 +1,4 @@
#! /bin/sh
set -e
-git submodule init
-git submodule update
+git submodule update --init --recursive
autoreconf -f -i -s
diff --git a/grecs b/grecs
-Subproject 1d38d5397e97063f07e7ff84649debfdd5032ee
+Subproject b06fb7d30415eec1d2efb39286ab96070c724fd
diff --git a/src/Makefile.am b/src/Makefile.am
index 0c38f64..84e71ad 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,8 +1,8 @@
# This file is part of SLB
-# Copyright (C) 2011 Sergey Poznyakoff
+# Copyright (C) 2011, 2019 Sergey Poznyakoff
#
# SLB is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
#
@@ -43,17 +43,17 @@ SUFFIXES=.opt .c .h
NET_SNMP_INCLUDES =
NET_SNMP_LIBS = `$(NET_SNMP_CONFIG) --libs`
NET_SNMP_EXLIBS = `$(NET_SNMP_CONFIG) --external-libs`
AM_LDFLAGS = $(NET_SNMP_LIBS) $(NET_SNMP_EXLIBS)
LDADD=@LIBOBJS@ ../grecs/src/libgrecs.a -lm
-INCLUDES = -I$(top_srcdir)/grecs/src/ $(NET_SNMP_INCLUDES)
incdir=$(pkgdatadir)/$(VERSION)/include
AM_CPPFLAGS= \
+ @GRECS_INCLUDES@ $(NET_SNMP_INCLUDES) \
-DSYSCONFDIR=\"$(sysconfdir)\"\
-DDEFAULT_VERSION_INCLUDE_DIR=\"$(incdir)\"\
-DDEFAULT_INCLUDE_DIR=\"$(pkgdatadir)/include\"\
-DDEFAULT_PREPROCESSOR="$(DEFAULT_PREPROCESSOR)"
AM_YFLAGS=-tv
diff --git a/src/config.c b/src/config.c
index 877bd85..e62a13d 100644
--- a/src/config.c
+++ b/src/config.c
@@ -1,8 +1,8 @@
/* This file is part of SLB
- Copyright (C) 2011, 2012 Sergey Poznyakoff
+ Copyright (C) 2011, 2012, 2019 Sergey Poznyakoff
SLB is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
@@ -1030,13 +1030,13 @@ static struct grecs_keyword syslog_kw[] = {
static struct grecs_keyword slb_kw[] = {
{ "standalone", NULL, N_("Enable standalone mode"),
grecs_type_bool, GRECS_DFLT, &standalone_mode },
{ "foreground", NULL, N_("Start in foreground even in daemon mode"),
grecs_type_bool, GRECS_DFLT, &foreground },
{ "pidfile", N_("file"), N_("Set pid file name"),
- grecs_type_string, GRECS_DFLT, &pidfile },
+ grecs_type_string, GRECS_DFLT|GRECS_CONST, &pidfile },
#if 0
/* These are reserved for future use. The '' quotes are used to
pacify make check-docs in /dir */
{ ''user'', N_("name"), N_("Run with UID and GID of this user"),
grecs_type_string, GRECS_DFLT, NULL, 0, cb_user },
{ ''group'', NULL, N_("Retain these supplementary groups"),
@@ -1074,16 +1074,16 @@ static struct grecs_keyword slb_kw[] = {
grecs_type_size, GRECS_DFLT, &output_tail_count },
{ "head", NULL,
N_("Output at most <arg> records from the sorted list"),
grecs_type_size, GRECS_DFLT, &output_head_count },
{ "output-file", NULL,
N_("Name of the output file or command"),
- grecs_type_string, GRECS_DFLT, &output_file },
+ grecs_type_string, GRECS_DFLT|GRECS_CONST, &output_file },
{ "output-format", NULL,
N_("format string for output records"),
- grecs_type_string, GRECS_DFLT, &output_format },
+ grecs_type_string, GRECS_DFLT|GRECS_CONST, &output_format },
{ "begin-output-message", NULL,
N_("string emitted before formatting output records"),
grecs_type_string, GRECS_DFLT, &begin_output_message },
{ "end-output-message", NULL,
N_("string emitted after formatting output records"),
grecs_type_string, GRECS_DFLT, &end_output_message },
@@ -1115,13 +1115,13 @@ void
config_init()
{
grecs_include_path_setup(DEFAULT_VERSION_INCLUDE_DIR,
DEFAULT_INCLUDE_DIR, NULL);
grecs_preprocessor = DEFAULT_PREPROCESSOR;
grecs_log_to_stderr = 1;
- grecs_adjust_string_locations = 1;
+ grecs_parser_options = GRECS_OPTION_ADJUST_STRING_LOCATIONS;
grecs_print_diag_fun = grecs_print_diag;
}
struct config_finish_hook_entry
{
diff --git a/src/expr.y b/src/expr.y
index d9f23d8..710132c 100644
--- a/src/expr.y
+++ b/src/expr.y
@@ -1,8 +1,8 @@
/* This file is part of SLB
- Copyright (C) 2011 Sergey Poznyakoff
+ Copyright (C) 2011, 2019 Sergey Poznyakoff
SLB is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
@@ -13,13 +13,13 @@
You should have received a copy of the GNU General Public License
along with SLB. If not, see <http://www.gnu.org/licenses/>. */
%{
#include "slb.h"
-#include "grecs-locus.h"
+#include "grecs/locus.h"
#include <math.h>
double round(double x);
double trunc(double x);
@@ -1148,13 +1148,13 @@ eval_expression(struct slb_expression *expr, struct slb_node_state **pstate,
{
struct eval_result res;
if (debug_level[SLB_DEBCAT_EVAL] >= 2) {
debug_printf("evaluating expression \"%s\"", expr->ex_text);
debug_printf("input arguments:");
- grecs_symtab_enumerate(expr->ex_vartab, _print_arg, NULL);
+ grecs_symtab_foreach(expr->ex_vartab, _print_arg, NULL);
}
if (evalnode(expr->ex_tree, pstate, &res)) {
debug(SLB_DEBCAT_EVAL, 1,
("failure evaluating expression \"%s\"",
expr->ex_text));
diff --git a/src/exprtab.c b/src/exprtab.c
index 1d6422e..98a914b 100644
--- a/src/exprtab.c
+++ b/src/exprtab.c
@@ -1,8 +1,8 @@
/* This file is part of SLB
- Copyright (C) 2011 Sergey Poznyakoff
+ Copyright (C) 2011, 2019 Sergey Poznyakoff
SLB is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
@@ -315,11 +315,11 @@ fixup_expression(struct slb_expression *expr, struct grecs_symtab *vit)
if (expr->ex_fixed)
return 0;
nodefixup(expr->ex_tree, vit, expr);
clos.rc = grecs_error_count;
clos.loc = &expr->ex_locus;
- grecs_symtab_enumerate(expr->ex_vartab, report_undefined_refs, &clos);
+ grecs_symtab_foreach(expr->ex_vartab, report_undefined_refs, &clos);
undo_output_refs();
- grecs_symtab_enumerate(vit, mark_used_instances, &expr->ex_locus);
+ grecs_symtab_foreach(vit, mark_used_instances, &expr->ex_locus);
return clos.rc;
}
diff --git a/src/logger.c b/src/logger.c
index cc2daea..a54e0b8 100644
--- a/src/logger.c
+++ b/src/logger.c
@@ -1,8 +1,8 @@
/* This file is part of SLB
- Copyright (C) 2011 Sergey Poznyakoff
+ Copyright (C) 2011, 2019 Sergey Poznyakoff
SLB is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
@@ -12,13 +12,13 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with SLB. If not, see <http://www.gnu.org/licenses/>. */
#include "slb.h"
-#include "grecs-locus.h"
+#include "grecs/locus.h"
int log_to_stderr = -1; /* -1 means autodetect */
int syslog_facility = LOG_DAEMON;
const char *syslog_tag = NULL;
int syslog_include_prio; /* syslog messages include priority */
diff --git a/src/oidtab.c b/src/oidtab.c
index 09a0cde..a11d2b5 100644
--- a/src/oidtab.c
+++ b/src/oidtab.c
@@ -1,8 +1,8 @@
/* This file is part of SLB
- Copyright (C) 2011 Sergey Poznyakoff
+ Copyright (C) 2011, 2019 Sergey Poznyakoff
SLB is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
@@ -100,13 +100,13 @@ create_oidtab(struct grecs_symtab *vit)
oidref_hash, oidref_cmp, oidref_copy,
NULL,
oidref_free);
if (!oidtab)
grecs_alloc_die();
- grecs_symtab_enumerate(vit, _create_ref, oidtab);
+ grecs_symtab_foreach(vit, _create_ref, oidtab);
return oidtab;
}
struct slb_varinstance *
oidtab_lookup(struct grecs_symtab *oidtab, oid *name, size_t name_length)
{
diff --git a/src/output.c b/src/output.c
index 755e1a3..3fa99d5 100644
--- a/src/output.c
+++ b/src/output.c
@@ -1,8 +1,8 @@
/* This file is part of SLB
- Copyright (C) 2011 Sergey Poznyakoff
+ Copyright (C) 2011, 2019 Sergey Poznyakoff
SLB is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
@@ -212,13 +212,13 @@ ref_drv(struct slb_server *srv, void *data,
expression_lookup(s + 1, slen - 1);
if (!expr) {
logmsg(LOG_CRIT, "output format refers to undefined "
"expression %.*s", (int)(slen - 1), s + 1);
exit(EX_CONFIG);
}
- grecs_symtab_enumerate(expr->ex_vartab, _ref_var, NULL);
+ grecs_symtab_foreach(expr->ex_vartab, _ref_var, NULL);
if (expr->ex_min_eval > output_suppress_count)
output_suppress_count = expr->ex_min_eval;
symtab_register_expression(&srv->exprtab, expr);
} else
varref_lookup(outreftab, s, slen, &install);
return 0;
@@ -254,13 +254,13 @@ _unref(void *sym, void *data)
return 0;
}
void
undo_output_refs()
{
- grecs_symtab_enumerate(outreftab, _unref, NULL);
+ grecs_symtab_foreach(outreftab, _unref, NULL);
}
static int
_report_unbound_refs(void *sym, void *data)
{
struct slb_varref *ref = sym;
@@ -273,13 +273,13 @@ _report_unbound_refs(void *sym, void *data)
return 0;
}
void
report_unbound_output_refs(struct slb_server *srv)
{
- grecs_symtab_enumerate(outreftab, _report_unbound_refs, srv);
+ grecs_symtab_foreach(outreftab, _report_unbound_refs, srv);
}
static int
output_drv(struct slb_server *srv, void *data,
int code, const char *fbuf, const char *s, size_t slen)
diff --git a/src/slb.c b/src/slb.c
index 4722390..32787c7 100644
--- a/src/slb.c
+++ b/src/slb.c
@@ -1,8 +1,8 @@
/* This file is part of SLB
- Copyright (C) 2011 Sergey Poznyakoff
+ Copyright (C) 2011, 2019 Sergey Poznyakoff
SLB is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
@@ -384,14 +384,14 @@ test_eval(int argc, char **argv)
do {
if (eval_expression(expr, &state, &result))
continue;
printf(eval_output_format, result);
} while (slb_loop_serial++, slb_loop_ts += wakeup_interval,
next_loop = 0,
- (rc = grecs_symtab_enumerate(syminst, _next_val,
- &next_loop)) == 0 && next_loop);
+ (rc = grecs_symtab_foreach(syminst, _next_val,
+ &next_loop)) == 0 && next_loop);
return rc;
}
int
main(int argc, char **argv)
diff --git a/src/snmploop.c b/src/snmploop.c
index 7c5f215..b2f3827 100644
--- a/src/snmploop.c
+++ b/src/snmploop.c
@@ -1,8 +1,8 @@
/* This file is part of SLB
- Copyright (C) 2011, 2012 Sergey Poznyakoff
+ Copyright (C) 2011, 2012, 2019 Sergey Poznyakoff
SLB is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
@@ -88,17 +88,15 @@ table_clear(void *sym, void *data)
/* Re-initialize server state */
static int
slb_server_init(struct slb_server *srv, int clrflag)
{
slb_node_state_init(srv->state);
srv->expr->ex_eval_count = 0;
- grecs_symtab_enumerate(srv->assertions,
- assrt_clear_prev,
- NULL);
+ grecs_symtab_foreach(srv->assertions, assrt_clear_prev, NULL);
if (clrflag) {
- grecs_symtab_enumerate(srv->tables, table_clear, NULL);
+ grecs_symtab_foreach(srv->tables, table_clear, NULL);
srv->flags &= ~clrflag;
}
}
#define E_VARINST_OK 0
#define E_VARINST_UNSUPPORTED 1
@@ -321,13 +319,14 @@ process_result(struct slb_server *srv, struct snmp_pdu *pdu)
static int
slb_table_grow(struct slb_table *tab, struct variable_list *vp)
{
char *buf;
struct slb_idxnum *ent;
int install = 1;
- int ovf, out_len;
+ int ovf;
+ size_t out_len;
buf = slb_format_oid_value(vp->name, vp->name_length, vp, NULL);
if (!buf) {
logmsg(LOG_ERR,
"cannot format variable: %s",
snmp_api_errstring(snmp_errno));
@@ -381,13 +380,13 @@ oid_to_table(struct slb_server *srv, oid *oid, size_t oidlen)
struct table_match_closure clos;
clos.tables = srv->tables;
clos.oid = oid;
clos.oidlen = oidlen;
clos.result = NULL;
- grecs_symtab_enumerate(srv->tables, table_match_var, &clos);
+ grecs_symtab_foreach(srv->tables, table_match_var, &clos);
return clos.result;
}
static int
resolve_tabref(struct slb_varinstance *vinst, struct slb_server *srv)
{
@@ -522,19 +521,19 @@ process_next(struct slb_server *srv, struct snmp_pdu *pdu)
if (varcnt && snmp_send(srv->sess, pdu2))
active_count++;
else {
snmp_free_pdu(pdu2);
debug(SLB_DEBCAT_SNMP, 2,
("%s: resolving indexed variables", srvid(srv)));
- grecs_symtab_enumerate(srv->varinst,
- resolve_varinst_index,
- srv);
+ grecs_symtab_foreach(srv->varinst,
+ resolve_varinst_index,
+ srv);
#if 0
- grecs_symtab_enumerate(srv->assertions,
- resolve_assertion_index,
- srv);
+ grecs_symtab_foreach(srv->assertions,
+ resolve_assertion_index,
+ srv);
#endif
}
}
static void
_process_pdu(int operation, struct slb_server *srv,
@@ -709,26 +708,22 @@ send_requests()
if ((srv->flags & SLB_SRV_TAB_REFERENCED) &&
!(srv->flags & SLB_SRV_TAB_RESOLVED)) {
srv->sess->callback = asynch_response_next;
refcnt++;
req = snmp_pdu_create(SNMP_MSG_GETNEXT);
- grecs_symtab_enumerate(srv->tables, add_table_var,
- req);
+ grecs_symtab_foreach(srv->tables, add_table_var, req);
srv->flags |= SLB_SRV_TAB_RESOLVED;
} else {
srv->sess->callback = asynch_response;
varinst_unset(srv->varinst);
req = snmp_pdu_create(SNMP_MSG_GET);
- grecs_symtab_enumerate(srv->varinst,
- add_snmp_var,
- req);
- grecs_symtab_enumerate(srv->assertions,
- add_snmp_assertion,
- req);
+ grecs_symtab_foreach(srv->varinst, add_snmp_var, req);
+ grecs_symtab_foreach(srv->assertions,
+ add_snmp_assertion, req);
}
if (snmp_send(srv->sess, req)) {
active_count++;
srv->pdu = req;
} else {
diff --git a/src/symimp.c b/src/symimp.c
index d8d693c..a53e2bc 100644
--- a/src/symimp.c
+++ b/src/symimp.c
@@ -1,8 +1,8 @@
/* This file is part of SLB
- Copyright (C) 2011, 2012 Sergey Poznyakoff
+ Copyright (C) 2011, 2012, 2019 Sergey Poznyakoff
SLB is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
@@ -88,13 +88,13 @@ _varinst_unset(void *sym, void *data)
return 0;
}
void
varinst_unset(struct grecs_symtab *vit)
{
- grecs_symtab_enumerate(vit, _varinst_unset, NULL);
+ grecs_symtab_foreach(vit, _varinst_unset, NULL);
}
static int
_varinst_clear(void *sym, void *data)
{
struct slb_varinstance *vp = sym;
@@ -106,13 +106,13 @@ _varinst_clear(void *sym, void *data)
return 0;
}
void
varinst_clear(struct grecs_symtab *vit)
{
- grecs_symtab_enumerate(vit, _varinst_clear, NULL);
+ grecs_symtab_foreach(vit, _varinst_clear, NULL);
}
static int
_varinst_allset(void *sym, void *data)
{
struct slb_varinstance *vp = sym;
@@ -125,13 +125,13 @@ _varinst_allset(void *sym, void *data)
}
int
varinst_allset(struct grecs_symtab *vit)
{
int rc = 1;
- grecs_symtab_enumerate(vit, _varinst_allset, &rc);
+ grecs_symtab_foreach(vit, _varinst_allset, &rc);
return rc;
}
struct slb_varref *
varref_lookup(struct grecs_symtab *vit, const char *name, size_t len,

Return to:

Send suggestions and report system problems to the System administrator.