-/* $OpenBSD: smtpd.h,v 1.607 2018/12/26 20:13:43 eric Exp $ */
+/* $OpenBSD: smtpd.h,v 1.608 2018/12/27 08:08:06 eric Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@poolp.org>
const char *name;
const unsigned int services;
int (*config)(struct table *);
- void *(*open)(struct table *);
+ int (*open)(struct table *);
int (*update)(struct table *);
void (*close)(void *);
int (*lookup)(void *, enum table_service, const char *, char **);
-/* $OpenBSD: table.c,v 1.38 2018/12/26 20:13:43 eric Exp $ */
+/* $OpenBSD: table.c,v 1.39 2018/12/27 08:08:06 eric Exp $ */
/*
* Copyright (c) 2013 Eric Faurot <eric@openbsd.org>
int
table_open(struct table *t)
{
- t->t_handle = NULL;
if (t->t_backend->open == NULL)
return (1);
- t->t_handle = t->t_backend->open(t);
- if (t->t_handle == NULL)
- return (0);
- return (1);
+ return (t->t_backend->open(t));
}
void
-/* $OpenBSD: table_db.c,v 1.14 2018/12/26 20:13:43 eric Exp $ */
+/* $OpenBSD: table_db.c,v 1.15 2018/12/27 08:08:06 eric Exp $ */
/*
* Copyright (c) 2011 Gilles Chehade <gilles@poolp.org>
/* db(3) backend */
static int table_db_config(struct table *);
static int table_db_update(struct table *);
-static void *table_db_open(struct table *);
+static int table_db_open(struct table *);
+static void *table_db_open2(struct table *);
static int table_db_lookup(void *, enum table_service, const char *, char **);
static int table_db_fetch(void *, enum table_service, char **);
static void table_db_close(void *);
{
struct dbhandle *handle;
- handle = table_db_open(table);
+ handle = table_db_open2(table);
if (handle == NULL)
return 0;
{
struct dbhandle *handle;
- handle = table_db_open(table);
+ handle = table_db_open2(table);
if (handle == NULL)
return 0;
return 1;
}
-static void *
+static int
table_db_open(struct table *table)
+{
+ table->t_handle = table_db_open2(table);
+ if (table->t_handle == NULL)
+ return 0;
+ return 1;
+}
+
+static void *
+table_db_open2(struct table *table)
{
struct dbhandle *handle;
struct stat sb;
-/* $OpenBSD: table_getpwnam.c,v 1.8 2018/12/26 20:13:43 eric Exp $ */
+/* $OpenBSD: table_getpwnam.c,v 1.9 2018/12/27 08:08:06 eric Exp $ */
/*
* Copyright (c) 2012 Gilles Chehade <gilles@poolp.org>
/* getpwnam(3) backend */
static int table_getpwnam_config(struct table *);
static int table_getpwnam_update(struct table *);
-static void *table_getpwnam_open(struct table *);
+static int table_getpwnam_open(struct table *);
static int table_getpwnam_lookup(void *, enum table_service, const char *,
char **);
static void table_getpwnam_close(void *);
return 1;
}
-static void *
+static int
table_getpwnam_open(struct table *table)
{
- return table;
+ return 1;
}
static void
-/* $OpenBSD: table_proc.c,v 1.11 2018/12/26 20:13:43 eric Exp $ */
+/* $OpenBSD: table_proc.c,v 1.12 2018/12/27 08:08:06 eric Exp $ */
/*
* Copyright (c) 2013 Eric Faurot <eric@openbsd.org>
* API
*/
-static void *
+static int
table_proc_open(struct table *table)
{
struct table_proc_priv *priv;
table_proc_call(priv);
table_proc_end();
- return (priv);
+ table->t_handle = priv;
+
+ return (1);
}
static int
-/* $OpenBSD: table_static.c,v 1.24 2018/12/26 20:13:43 eric Exp $ */
+/* $OpenBSD: table_static.c,v 1.25 2018/12/27 08:08:06 eric Exp $ */
/*
* Copyright (c) 2013 Eric Faurot <eric@openbsd.org>
/* static backend */
static int table_static_config(struct table *);
static int table_static_update(struct table *);
-static void *table_static_open(struct table *);
+static int table_static_open(struct table *);
static int table_static_lookup(void *, enum table_service, const char *,
char **);
static int table_static_fetch(void *, enum table_service, char **);
return 0;
}
-static void *
+static int
table_static_open(struct table *table)
{
- return table;
+ table->t_handle = table;
+ return 1;
}
static void