diff options
author | jbj <devnull@localhost> | 2001-03-21 18:33:35 +0000 |
---|---|---|
committer | jbj <devnull@localhost> | 2001-03-21 18:33:35 +0000 |
commit | 731946f4b90eb1173452dd30f1296dd825155d82 (patch) | |
tree | 67535f54ecb7e5463c06e62044e4efd84ae0291d /db/rpc_client | |
parent | 7ed904da030dc4640ff9bce8458ba07cc09d830d (diff) | |
download | librpm-tizen-731946f4b90eb1173452dd30f1296dd825155d82.tar.gz librpm-tizen-731946f4b90eb1173452dd30f1296dd825155d82.tar.bz2 librpm-tizen-731946f4b90eb1173452dd30f1296dd825155d82.zip |
Initial revision
CVS patchset: 4644
CVS date: 2001/03/21 18:33:35
Diffstat (limited to 'db/rpc_client')
-rw-r--r-- | db/rpc_client/client.c | 371 | ||||
-rw-r--r-- | db/rpc_client/db_server_clnt.c | 692 | ||||
-rw-r--r-- | db/rpc_client/gen_client.c | 2494 | ||||
-rw-r--r-- | db/rpc_client/gen_client_ret.c | 542 |
4 files changed, 4099 insertions, 0 deletions
diff --git a/db/rpc_client/client.c b/db/rpc_client/client.c new file mode 100644 index 000000000..70744f54b --- /dev/null +++ b/db/rpc_client/client.c @@ -0,0 +1,371 @@ +/*- + * See the file LICENSE for redistribution information. + * + * Copyright (c) 1996, 1997, 1998, 1999, 2000 + * Sleepycat Software. All rights reserved. + */ + +#include "db_config.h" + +#ifndef lint +static const char revid[] = "$Id: client.c,v 1.21 2000/11/30 00:58:44 ubell Exp $"; +#endif /* not lint */ + +#ifdef HAVE_RPC +#ifndef NO_SYSTEM_INCLUDES +#include <sys/types.h> + +#include <rpc/rpc.h> + +#include <ctype.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> +#endif +#include "db_server.h" + +#include "db_int.h" +#include "txn.h" +#include "gen_client_ext.h" +#include "rpc_client_ext.h" + +/* + * __dbclenv_server -- + * Initialize an environment's server. + * + * PUBLIC: int __dbcl_envserver __P((DB_ENV *, char *, long, long, u_int32_t)); + */ +int +__dbcl_envserver(dbenv, host, tsec, ssec, flags) + DB_ENV *dbenv; + char *host; + long tsec, ssec; + u_int32_t flags; +{ + CLIENT *cl; + __env_create_msg req; + __env_create_reply *replyp; + struct timeval tp; + int ret; + + COMPQUIET(flags, 0); + +#ifdef HAVE_VXWORKS + if ((ret = rpcTaskInit()) != 0) { + __db_err(dbenv, "Could not initialize VxWorks RPC"); + return (ERROR); + } +#endif + if ((cl = + clnt_create(host, DB_SERVERPROG, DB_SERVERVERS, "tcp")) == NULL) { + __db_err(dbenv, clnt_spcreateerror(host)); + return (DB_NOSERVER); + } + dbenv->cl_handle = cl; + + if (tsec != 0) { + tp.tv_sec = tsec; + tp.tv_usec = 0; + (void)clnt_control(cl, CLSET_TIMEOUT, (char *)&tp); + } + + req.timeout = ssec; + /* + * CALL THE SERVER + */ + if ((replyp = __db_env_create_1(&req, cl)) == NULL) { + __db_err(dbenv, clnt_sperror(cl, "Berkeley DB")); + return (DB_NOSERVER); + } + + /* + * Process reply and free up our space from request + * SUCCESS: Store ID from server. + */ + if ((ret = replyp->status) != 0) + return (ret); + + dbenv->cl_id = replyp->envcl_id; + return (0); +} + +/* + * __dbcl_refresh -- + * Clean up an environment. + * + * PUBLIC: int __dbcl_refresh __P((DB_ENV *)); + */ +int +__dbcl_refresh(dbenv) + DB_ENV *dbenv; +{ + CLIENT *cl; + int ret; + + cl = (CLIENT *)dbenv->cl_handle; + + ret = 0; + if (dbenv->tx_handle != NULL) { + /* + * We only need to free up our stuff, the caller + * of this function will call the server who will + * do all the real work. + */ + ret = __dbcl_txn_close(dbenv); + dbenv->tx_handle = NULL; + } + if (cl != NULL) + clnt_destroy(cl); + dbenv->cl_handle = NULL; + return (ret); +} + +/* + * __dbcl_txn_close -- + * Clean up an environment's transactions. + * + * PUBLIC: int __dbcl_txn_close __P((DB_ENV *)); + */ +int +__dbcl_txn_close(dbenv) + DB_ENV *dbenv; +{ + DB_TXN *txnp; + DB_TXNMGR *tmgrp; + int ret; + + ret = 0; + tmgrp = dbenv->tx_handle; + + /* + * This function can only be called once per process (i.e., not + * once per thread), so no synchronization is required. + * Also this function is called *after* the server has been called, + * so the server has already closed/aborted any transactions that + * were open on its side. We only need to do local cleanup. + */ + while ((txnp = TAILQ_FIRST(&tmgrp->txn_chain)) != NULL) + __dbcl_txn_end(txnp); + + __os_free(tmgrp, sizeof(*tmgrp)); + return (ret); + +} + +/* + * __dbcl_txn_end -- + * Clean up an transaction. + * RECURSIVE FUNCTION: Clean up nested transactions. + * + * PUBLIC: void __dbcl_txn_end __P((DB_TXN *)); + */ +void +__dbcl_txn_end(txnp) + DB_TXN *txnp; +{ + DB_ENV *dbenv; + DB_TXN *kids; + DB_TXNMGR *mgr; + + mgr = txnp->mgrp; + dbenv = mgr->dbenv; + + /* + * First take care of any kids we have + */ + for (kids = TAILQ_FIRST(&txnp->kids); + kids != NULL; + kids = TAILQ_FIRST(&txnp->kids)) + __dbcl_txn_end(kids); + + /* + * We are ending this transaction no matter what the parent + * may eventually do, if we have a parent. All those details + * are taken care of by the server. We only need to make sure + * that we properly release resources. + */ + if (txnp->parent != NULL) + TAILQ_REMOVE(&txnp->parent->kids, txnp, klinks); + TAILQ_REMOVE(&mgr->txn_chain, txnp, links); + __os_free(txnp, sizeof(*txnp)); + + return; +} + +/* + * __dbcl_c_destroy -- + * Destroy a cursor. + * + * PUBLIC: int __dbcl_c_destroy __P((DBC *)); + */ +int +__dbcl_c_destroy(dbc) + DBC *dbc; +{ + DB *dbp; + + dbp = dbc->dbp; + + TAILQ_REMOVE(&dbp->free_queue, dbc, links); + __os_free(dbc, sizeof(*dbc)); + + return (0); +} + +/* + * __dbcl_c_refresh -- + * Refresh a cursor. Move it from the active queue to the free queue. + * + * PUBLIC: void __dbcl_c_refresh __P((DBC *)); + */ +void +__dbcl_c_refresh(dbcp) + DBC *dbcp; +{ + DB *dbp; + + dbp = dbcp->dbp; + dbcp->flags = 0; + dbcp->cl_id = 0; + + /* + * If dbp->cursor fails locally, we use a local dbc so that + * we can close it. In that case, dbp will be NULL. + */ + if (dbp != NULL) { + TAILQ_REMOVE(&dbp->active_queue, dbcp, links); + TAILQ_INSERT_TAIL(&dbp->free_queue, dbcp, links); + } + return; +} + +/* + * __dbcl_c_setup -- + * Allocate a cursor. + * + * PUBLIC: int __dbcl_c_setup __P((long, DB *, DBC **)); + */ +int +__dbcl_c_setup(cl_id, dbp, dbcpp) + long cl_id; + DB *dbp; + DBC **dbcpp; +{ + DBC *dbc, tmpdbc; + int ret, t_ret; + + if ((dbc = TAILQ_FIRST(&dbp->free_queue)) != NULL) + TAILQ_REMOVE(&dbp->free_queue, dbc, links); + else { + if ((ret = + __os_calloc(dbp->dbenv, 1, sizeof(DBC), &dbc)) != 0) { + /* + * If we die here, set up a tmp dbc to call the + * server to shut down that cursor. + */ + tmpdbc.dbp = NULL; + tmpdbc.cl_id = cl_id; + t_ret = __dbcl_dbc_close(&tmpdbc); + return (ret); + } + dbc->c_close = __dbcl_dbc_close; + dbc->c_count = __dbcl_dbc_count; + dbc->c_del = __dbcl_dbc_del; + dbc->c_dup = __dbcl_dbc_dup; + dbc->c_get = __dbcl_dbc_get; + dbc->c_put = __dbcl_dbc_put; + dbc->c_am_destroy = __dbcl_c_destroy; + } + dbc->cl_id = cl_id; + dbc->dbp = dbp; + TAILQ_INSERT_TAIL(&dbp->active_queue, dbc, links); + *dbcpp = dbc; + return (0); +} + +/* + * __dbcl_retcopy -- + * Copy the returned data into the user's DBT, handling special flags + * as they apply to a client. Modeled after __db_retcopy(). + * + * PUBLIC: int __dbcl_retcopy __P((DB_ENV *, DBT *, void *, u_int32_t)); + */ +int +__dbcl_retcopy(dbenv, dbt, data, len) + DB_ENV *dbenv; + DBT *dbt; + void *data; + u_int32_t len; +{ + int ret; + + /* + * No need to handle DB_DBT_PARTIAL here, server already did. + */ + dbt->size = len; + + /* + * Allocate memory to be owned by the application: DB_DBT_MALLOC + * and DB_DBT_REALLOC. Always allocate even if we're copying 0 bytes. + * Or use memory specified by application: DB_DBT_USERMEM. + */ + if (F_ISSET(dbt, DB_DBT_MALLOC)) { + if ((ret = __os_malloc(dbenv, len, NULL, &dbt->data)) != 0) + return (ret); + } else if (F_ISSET(dbt, DB_DBT_REALLOC)) { + if ((ret = __os_realloc(dbenv, len, NULL, &dbt->data)) != 0) + return (ret); + } else if (F_ISSET(dbt, DB_DBT_USERMEM)) { + if (len != 0 && (dbt->data == NULL || dbt->ulen < len)) + return (ENOMEM); + } else { + /* + * If no user flags, then set the DBT to point to the + * returned data pointer and return. + */ + dbt->data = data; + return (0); + } + + if (len != 0) + memcpy(dbt->data, data, len); + return (0); +} + +/* + * __dbcl_dbclose_common -- + * Common code for closing/cleaning a dbp. + * + * PUBLIC: int __dbcl_dbclose_common __P((DB *)); + */ +int +__dbcl_dbclose_common(dbp) + DB *dbp; +{ + int ret, t_ret; + DBC *dbc; + + /* + * Go through the active cursors and call the cursor recycle routine, + * which resolves pending operations and moves the cursors onto the + * free list. Then, walk the free list and call the cursor destroy + * routine. + * + * NOTE: We do not need to use the join_queue for join cursors. + * See comment in __dbcl_dbjoin_ret. + */ + ret = 0; + while ((dbc = TAILQ_FIRST(&dbp->active_queue)) != NULL) + __dbcl_c_refresh(dbc); + while ((dbc = TAILQ_FIRST(&dbp->free_queue)) != NULL) + if ((t_ret = __dbcl_c_destroy(dbc)) != 0 && ret == 0) + ret = t_ret; + + TAILQ_INIT(&dbp->free_queue); + TAILQ_INIT(&dbp->active_queue); + + memset(dbp, CLEAR_BYTE, sizeof(*dbp)); + __os_free(dbp, sizeof(*dbp)); + return (ret); +} +#endif /* HAVE_RPC */ diff --git a/db/rpc_client/db_server_clnt.c b/db/rpc_client/db_server_clnt.c new file mode 100644 index 000000000..680a26144 --- /dev/null +++ b/db/rpc_client/db_server_clnt.c @@ -0,0 +1,692 @@ +#include "db_config.h" +#ifdef HAVE_RPC +/* + * Please do not edit this file. + * It was generated using rpcgen. + */ + +#include "db_server.h" + +/* Default timeout can be changed using clnt_control() */ +static struct timeval TIMEOUT = { 25, 0 }; + +__env_cachesize_reply * +__db_env_cachesize_1(argp, clnt) + __env_cachesize_msg *argp; + CLIENT *clnt; +{ + static __env_cachesize_reply clnt_res; + + memset((char *)&clnt_res, 0, sizeof (clnt_res)); + if (clnt_call(clnt, __DB_env_cachesize, + (xdrproc_t) xdr___env_cachesize_msg, (caddr_t) argp, + (xdrproc_t) xdr___env_cachesize_reply, (caddr_t) &clnt_res, + TIMEOUT) != RPC_SUCCESS) { + return (NULL); + } + return (&clnt_res); +} + +__env_close_reply * +__db_env_close_1(argp, clnt) + __env_close_msg *argp; + CLIENT *clnt; +{ + static __env_close_reply clnt_res; + + memset((char *)&clnt_res, 0, sizeof (clnt_res)); + if (clnt_call(clnt, __DB_env_close, + (xdrproc_t) xdr___env_close_msg, (caddr_t) argp, + (xdrproc_t) xdr___env_close_reply, (caddr_t) &clnt_res, + TIMEOUT) != RPC_SUCCESS) { + return (NULL); + } + return (&clnt_res); +} + +__env_create_reply * +__db_env_create_1(argp, clnt) + __env_create_msg *argp; + CLIENT *clnt; +{ + static __env_create_reply clnt_res; + + memset((char *)&clnt_res, 0, sizeof (clnt_res)); + if (clnt_call(clnt, __DB_env_create, + (xdrproc_t) xdr___env_create_msg, (caddr_t) argp, + (xdrproc_t) xdr___env_create_reply, (caddr_t) &clnt_res, + TIMEOUT) != RPC_SUCCESS) { + return (NULL); + } + return (&clnt_res); +} + +__env_flags_reply * +__db_env_flags_1(argp, clnt) + __env_flags_msg *argp; + CLIENT *clnt; +{ + static __env_flags_reply clnt_res; + + memset((char *)&clnt_res, 0, sizeof (clnt_res)); + if (clnt_call(clnt, __DB_env_flags, + (xdrproc_t) xdr___env_flags_msg, (caddr_t) argp, + (xdrproc_t) xdr___env_flags_reply, (caddr_t) &clnt_res, + TIMEOUT) != RPC_SUCCESS) { + return (NULL); + } + return (&clnt_res); +} + +__env_open_reply * +__db_env_open_1(argp, clnt) + __env_open_msg *argp; + CLIENT *clnt; +{ + static __env_open_reply clnt_res; + + memset((char *)&clnt_res, 0, sizeof (clnt_res)); + if (clnt_call(clnt, __DB_env_open, + (xdrproc_t) xdr___env_open_msg, (caddr_t) argp, + (xdrproc_t) xdr___env_open_reply, (caddr_t) &clnt_res, + TIMEOUT) != RPC_SUCCESS) { + return (NULL); + } + return (&clnt_res); +} + +__env_remove_reply * +__db_env_remove_1(argp, clnt) + __env_remove_msg *argp; + CLIENT *clnt; +{ + static __env_remove_reply clnt_res; + + memset((char *)&clnt_res, 0, sizeof (clnt_res)); + if (clnt_call(clnt, __DB_env_remove, + (xdrproc_t) xdr___env_remove_msg, (caddr_t) argp, + (xdrproc_t) xdr___env_remove_reply, (caddr_t) &clnt_res, + TIMEOUT) != RPC_SUCCESS) { + return (NULL); + } + return (&clnt_res); +} + +__txn_abort_reply * +__db_txn_abort_1(argp, clnt) + __txn_abort_msg *argp; + CLIENT *clnt; +{ + static __txn_abort_reply clnt_res; + + memset((char *)&clnt_res, 0, sizeof (clnt_res)); + if (clnt_call(clnt, __DB_txn_abort, + (xdrproc_t) xdr___txn_abort_msg, (caddr_t) argp, + (xdrproc_t) xdr___txn_abort_reply, (caddr_t) &clnt_res, + TIMEOUT) != RPC_SUCCESS) { + return (NULL); + } + return (&clnt_res); +} + +__txn_begin_reply * +__db_txn_begin_1(argp, clnt) + __txn_begin_msg *argp; + CLIENT *clnt; +{ + static __txn_begin_reply clnt_res; + + memset((char *)&clnt_res, 0, sizeof (clnt_res)); + if (clnt_call(clnt, __DB_txn_begin, + (xdrproc_t) xdr___txn_begin_msg, (caddr_t) argp, + (xdrproc_t) xdr___txn_begin_reply, (caddr_t) &clnt_res, + TIMEOUT) != RPC_SUCCESS) { + return (NULL); + } + return (&clnt_res); +} + +__txn_commit_reply * +__db_txn_commit_1(argp, clnt) + __txn_commit_msg *argp; + CLIENT *clnt; +{ + static __txn_commit_reply clnt_res; + + memset((char *)&clnt_res, 0, sizeof (clnt_res)); + if (clnt_call(clnt, __DB_txn_commit, + (xdrproc_t) xdr___txn_commit_msg, (caddr_t) argp, + (xdrproc_t) xdr___txn_commit_reply, (caddr_t) &clnt_res, + TIMEOUT) != RPC_SUCCESS) { + return (NULL); + } + return (&clnt_res); +} + +__db_bt_maxkey_reply * +__db_db_bt_maxkey_1(argp, clnt) + __db_bt_maxkey_msg *argp; + CLIENT *clnt; +{ + static __db_bt_maxkey_reply clnt_res; + + memset((char *)&clnt_res, 0, sizeof (clnt_res)); + if (clnt_call(clnt, __DB_db_bt_maxkey, + (xdrproc_t) xdr___db_bt_maxkey_msg, (caddr_t) argp, + (xdrproc_t) xdr___db_bt_maxkey_reply, (caddr_t) &clnt_res, + TIMEOUT) != RPC_SUCCESS) { + return (NULL); + } + return (&clnt_res); +} + +__db_bt_minkey_reply * +__db_db_bt_minkey_1(argp, clnt) + __db_bt_minkey_msg *argp; + CLIENT *clnt; +{ + static __db_bt_minkey_reply clnt_res; + + memset((char *)&clnt_res, 0, sizeof (clnt_res)); + if (clnt_call(clnt, __DB_db_bt_minkey, + (xdrproc_t) xdr___db_bt_minkey_msg, (caddr_t) argp, + (xdrproc_t) xdr___db_bt_minkey_reply, (caddr_t) &clnt_res, + TIMEOUT) != RPC_SUCCESS) { + return (NULL); + } + return (&clnt_res); +} + +__db_close_reply * +__db_db_close_1(argp, clnt) + __db_close_msg *argp; + CLIENT *clnt; +{ + static __db_close_reply clnt_res; + + memset((char *)&clnt_res, 0, sizeof (clnt_res)); + if (clnt_call(clnt, __DB_db_close, + (xdrproc_t) xdr___db_close_msg, (caddr_t) argp, + (xdrproc_t) xdr___db_close_reply, (caddr_t) &clnt_res, + TIMEOUT) != RPC_SUCCESS) { + return (NULL); + } + return (&clnt_res); +} + +__db_create_reply * +__db_db_create_1(argp, clnt) + __db_create_msg *argp; + CLIENT *clnt; +{ + static __db_create_reply clnt_res; + + memset((char *)&clnt_res, 0, sizeof (clnt_res)); + if (clnt_call(clnt, __DB_db_create, + (xdrproc_t) xdr___db_create_msg, (caddr_t) argp, + (xdrproc_t) xdr___db_create_reply, (caddr_t) &clnt_res, + TIMEOUT) != RPC_SUCCESS) { + return (NULL); + } + return (&clnt_res); +} + +__db_del_reply * +__db_db_del_1(argp, clnt) + __db_del_msg *argp; + CLIENT *clnt; +{ + static __db_del_reply clnt_res; + + memset((char *)&clnt_res, 0, sizeof (clnt_res)); + if (clnt_call(clnt, __DB_db_del, + (xdrproc_t) xdr___db_del_msg, (caddr_t) argp, + (xdrproc_t) xdr___db_del_reply, (caddr_t) &clnt_res, + TIMEOUT) != RPC_SUCCESS) { + return (NULL); + } + return (&clnt_res); +} + +__db_extentsize_reply * +__db_db_extentsize_1(argp, clnt) + __db_extentsize_msg *argp; + CLIENT *clnt; +{ + static __db_extentsize_reply clnt_res; + + memset((char *)&clnt_res, 0, sizeof (clnt_res)); + if (clnt_call(clnt, __DB_db_extentsize, + (xdrproc_t) xdr___db_extentsize_msg, (caddr_t) argp, + (xdrproc_t) xdr___db_extentsize_reply, (caddr_t) &clnt_res, + TIMEOUT) != RPC_SUCCESS) { + return (NULL); + } + return (&clnt_res); +} + +__db_flags_reply * +__db_db_flags_1(argp, clnt) + __db_flags_msg *argp; + CLIENT *clnt; +{ + static __db_flags_reply clnt_res; + + memset((char *)&clnt_res, 0, sizeof (clnt_res)); + if (clnt_call(clnt, __DB_db_flags, + (xdrproc_t) xdr___db_flags_msg, (caddr_t) argp, + (xdrproc_t) xdr___db_flags_reply, (caddr_t) &clnt_res, + TIMEOUT) != RPC_SUCCESS) { + return (NULL); + } + return (&clnt_res); +} + +__db_get_reply * +__db_db_get_1(argp, clnt) + __db_get_msg *argp; + CLIENT *clnt; +{ + static __db_get_reply clnt_res; + + memset((char *)&clnt_res, 0, sizeof (clnt_res)); + if (clnt_call(clnt, __DB_db_get, + (xdrproc_t) xdr___db_get_msg, (caddr_t) argp, + (xdrproc_t) xdr___db_get_reply, (caddr_t) &clnt_res, + TIMEOUT) != RPC_SUCCESS) { + return (NULL); + } + return (&clnt_res); +} + +__db_h_ffactor_reply * +__db_db_h_ffactor_1(argp, clnt) + __db_h_ffactor_msg *argp; + CLIENT *clnt; +{ + static __db_h_ffactor_reply clnt_res; + + memset((char *)&clnt_res, 0, sizeof (clnt_res)); + if (clnt_call(clnt, __DB_db_h_ffactor, + (xdrproc_t) xdr___db_h_ffactor_msg, (caddr_t) argp, + (xdrproc_t) xdr___db_h_ffactor_reply, (caddr_t) &clnt_res, + TIMEOUT) != RPC_SUCCESS) { + return (NULL); + } + return (&clnt_res); +} + +__db_h_nelem_reply * +__db_db_h_nelem_1(argp, clnt) + __db_h_nelem_msg *argp; + CLIENT *clnt; +{ + static __db_h_nelem_reply clnt_res; + + memset((char *)&clnt_res, 0, sizeof (clnt_res)); + if (clnt_call(clnt, __DB_db_h_nelem, + (xdrproc_t) xdr___db_h_nelem_msg, (caddr_t) argp, + (xdrproc_t) xdr___db_h_nelem_reply, (caddr_t) &clnt_res, + TIMEOUT) != RPC_SUCCESS) { + return (NULL); + } + return (&clnt_res); +} + +__db_key_range_reply * +__db_db_key_range_1(argp, clnt) + __db_key_range_msg *argp; + CLIENT *clnt; +{ + static __db_key_range_reply clnt_res; + + memset((char *)&clnt_res, 0, sizeof (clnt_res)); + if (clnt_call(clnt, __DB_db_key_range, + (xdrproc_t) xdr___db_key_range_msg, (caddr_t) argp, + (xdrproc_t) xdr___db_key_range_reply, (caddr_t) &clnt_res, + TIMEOUT) != RPC_SUCCESS) { + return (NULL); + } + return (&clnt_res); +} + +__db_lorder_reply * +__db_db_lorder_1(argp, clnt) + __db_lorder_msg *argp; + CLIENT *clnt; +{ + static __db_lorder_reply clnt_res; + + memset((char *)&clnt_res, 0, sizeof (clnt_res)); + if (clnt_call(clnt, __DB_db_lorder, + (xdrproc_t) xdr___db_lorder_msg, (caddr_t) argp, + (xdrproc_t) xdr___db_lorder_reply, (caddr_t) &clnt_res, + TIMEOUT) != RPC_SUCCESS) { + return (NULL); + } + return (&clnt_res); +} + +__db_open_reply * +__db_db_open_1(argp, clnt) + __db_open_msg *argp; + CLIENT *clnt; +{ + static __db_open_reply clnt_res; + + memset((char *)&clnt_res, 0, sizeof (clnt_res)); + if (clnt_call(clnt, __DB_db_open, + (xdrproc_t) xdr___db_open_msg, (caddr_t) argp, + (xdrproc_t) xdr___db_open_reply, (caddr_t) &clnt_res, + TIMEOUT) != RPC_SUCCESS) { + return (NULL); + } + return (&clnt_res); +} + +__db_pagesize_reply * +__db_db_pagesize_1(argp, clnt) + __db_pagesize_msg *argp; + CLIENT *clnt; +{ + static __db_pagesize_reply clnt_res; + + memset((char *)&clnt_res, 0, sizeof (clnt_res)); + if (clnt_call(clnt, __DB_db_pagesize, + (xdrproc_t) xdr___db_pagesize_msg, (caddr_t) argp, + (xdrproc_t) xdr___db_pagesize_reply, (caddr_t) &clnt_res, + TIMEOUT) != RPC_SUCCESS) { + return (NULL); + } + return (&clnt_res); +} + +__db_put_reply * +__db_db_put_1(argp, clnt) + __db_put_msg *argp; + CLIENT *clnt; +{ + static __db_put_reply clnt_res; + + memset((char *)&clnt_res, 0, sizeof (clnt_res)); + if (clnt_call(clnt, __DB_db_put, + (xdrproc_t) xdr___db_put_msg, (caddr_t) argp, + (xdrproc_t) xdr___db_put_reply, (caddr_t) &clnt_res, + TIMEOUT) != RPC_SUCCESS) { + return (NULL); + } + return (&clnt_res); +} + +__db_re_delim_reply * +__db_db_re_delim_1(argp, clnt) + __db_re_delim_msg *argp; + CLIENT *clnt; +{ + static __db_re_delim_reply clnt_res; + + memset((char *)&clnt_res, 0, sizeof (clnt_res)); + if (clnt_call(clnt, __DB_db_re_delim, + (xdrproc_t) xdr___db_re_delim_msg, (caddr_t) argp, + (xdrproc_t) xdr___db_re_delim_reply, (caddr_t) &clnt_res, + TIMEOUT) != RPC_SUCCESS) { + return (NULL); + } + return (&clnt_res); +} + +__db_re_len_reply * +__db_db_re_len_1(argp, clnt) + __db_re_len_msg *argp; + CLIENT *clnt; +{ + static __db_re_len_reply clnt_res; + + memset((char *)&clnt_res, 0, sizeof (clnt_res)); + if (clnt_call(clnt, __DB_db_re_len, + (xdrproc_t) xdr___db_re_len_msg, (caddr_t) argp, + (xdrproc_t) xdr___db_re_len_reply, (caddr_t) &clnt_res, + TIMEOUT) != RPC_SUCCESS) { + return (NULL); + } + return (&clnt_res); +} + +__db_re_pad_reply * +__db_db_re_pad_1(argp, clnt) + __db_re_pad_msg *argp; + CLIENT *clnt; +{ + static __db_re_pad_reply clnt_res; + + memset((char *)&clnt_res, 0, sizeof (clnt_res)); + if (clnt_call(clnt, __DB_db_re_pad, + (xdrproc_t) xdr___db_re_pad_msg, (caddr_t) argp, + (xdrproc_t) xdr___db_re_pad_reply, (caddr_t) &clnt_res, + TIMEOUT) != RPC_SUCCESS) { + return (NULL); + } + return (&clnt_res); +} + +__db_remove_reply * +__db_db_remove_1(argp, clnt) + __db_remove_msg *argp; + CLIENT *clnt; +{ + static __db_remove_reply clnt_res; + + memset((char *)&clnt_res, 0, sizeof (clnt_res)); + if (clnt_call(clnt, __DB_db_remove, + (xdrproc_t) xdr___db_remove_msg, (caddr_t) argp, + (xdrproc_t) xdr___db_remove_reply, (caddr_t) &clnt_res, + TIMEOUT) != RPC_SUCCESS) { + return (NULL); + } + return (&clnt_res); +} + +__db_rename_reply * +__db_db_rename_1(argp, clnt) + __db_rename_msg *argp; + CLIENT *clnt; +{ + static __db_rename_reply clnt_res; + + memset((char *)&clnt_res, 0, sizeof (clnt_res)); + if (clnt_call(clnt, __DB_db_rename, + (xdrproc_t) xdr___db_rename_msg, (caddr_t) argp, + (xdrproc_t) xdr___db_rename_reply, (caddr_t) &clnt_res, + TIMEOUT) != RPC_SUCCESS) { + return (NULL); + } + return (&clnt_res); +} + +__db_stat_reply * +__db_db_stat_1(argp, clnt) + __db_stat_msg *argp; + CLIENT *clnt; +{ + static __db_stat_reply clnt_res; + + memset((char *)&clnt_res, 0, sizeof (clnt_res)); + if (clnt_call(clnt, __DB_db_stat, + (xdrproc_t) xdr___db_stat_msg, (caddr_t) argp, + (xdrproc_t) xdr___db_stat_reply, (caddr_t) &clnt_res, + TIMEOUT) != RPC_SUCCESS) { + return (NULL); + } + return (&clnt_res); +} + +__db_swapped_reply * +__db_db_swapped_1(argp, clnt) + __db_swapped_msg *argp; + CLIENT *clnt; +{ + static __db_swapped_reply clnt_res; + + memset((char *)&clnt_res, 0, sizeof (clnt_res)); + if (clnt_call(clnt, __DB_db_swapped, + (xdrproc_t) xdr___db_swapped_msg, (caddr_t) argp, + (xdrproc_t) xdr___db_swapped_reply, (caddr_t) &clnt_res, + TIMEOUT) != RPC_SUCCESS) { + return (NULL); + } + return (&clnt_res); +} + +__db_sync_reply * +__db_db_sync_1(argp, clnt) + __db_sync_msg *argp; + CLIENT *clnt; +{ + static __db_sync_reply clnt_res; + + memset((char *)&clnt_res, 0, sizeof (clnt_res)); + if (clnt_call(clnt, __DB_db_sync, + (xdrproc_t) xdr___db_sync_msg, (caddr_t) argp, + (xdrproc_t) xdr___db_sync_reply, (caddr_t) &clnt_res, + TIMEOUT) != RPC_SUCCESS) { + return (NULL); + } + return (&clnt_res); +} + +__db_cursor_reply * +__db_db_cursor_1(argp, clnt) + __db_cursor_msg *argp; + CLIENT *clnt; +{ + static __db_cursor_reply clnt_res; + + memset((char *)&clnt_res, 0, sizeof (clnt_res)); + if (clnt_call(clnt, __DB_db_cursor, + (xdrproc_t) xdr___db_cursor_msg, (caddr_t) argp, + (xdrproc_t) xdr___db_cursor_reply, (caddr_t) &clnt_res, + TIMEOUT) != RPC_SUCCESS) { + return (NULL); + } + return (&clnt_res); +} + +__db_join_reply * +__db_db_join_1(argp, clnt) + __db_join_msg *argp; + CLIENT *clnt; +{ + static __db_join_reply clnt_res; + + memset((char *)&clnt_res, 0, sizeof (clnt_res)); + if (clnt_call(clnt, __DB_db_join, + (xdrproc_t) xdr___db_join_msg, (caddr_t) argp, + (xdrproc_t) xdr___db_join_reply, (caddr_t) &clnt_res, + TIMEOUT) != RPC_SUCCESS) { + return (NULL); + } + return (&clnt_res); +} + +__dbc_close_reply * +__db_dbc_close_1(argp, clnt) + __dbc_close_msg *argp; + CLIENT *clnt; +{ + static __dbc_close_reply clnt_res; + + memset((char *)&clnt_res, 0, sizeof (clnt_res)); + if (clnt_call(clnt, __DB_dbc_close, + (xdrproc_t) xdr___dbc_close_msg, (caddr_t) argp, + (xdrproc_t) xdr___dbc_close_reply, (caddr_t) &clnt_res, + TIMEOUT) != RPC_SUCCESS) { + return (NULL); + } + return (&clnt_res); +} + +__dbc_count_reply * +__db_dbc_count_1(argp, clnt) + __dbc_count_msg *argp; + CLIENT *clnt; +{ + static __dbc_count_reply clnt_res; + + memset((char *)&clnt_res, 0, sizeof (clnt_res)); + if (clnt_call(clnt, __DB_dbc_count, + (xdrproc_t) xdr___dbc_count_msg, (caddr_t) argp, + (xdrproc_t) xdr___dbc_count_reply, (caddr_t) &clnt_res, + TIMEOUT) != RPC_SUCCESS) { + return (NULL); + } + return (&clnt_res); +} + +__dbc_del_reply * +__db_dbc_del_1(argp, clnt) + __dbc_del_msg *argp; + CLIENT *clnt; +{ + static __dbc_del_reply clnt_res; + + memset((char *)&clnt_res, 0, sizeof (clnt_res)); + if (clnt_call(clnt, __DB_dbc_del, + (xdrproc_t) xdr___dbc_del_msg, (caddr_t) argp, + (xdrproc_t) xdr___dbc_del_reply, (caddr_t) &clnt_res, + TIMEOUT) != RPC_SUCCESS) { + return (NULL); + } + return (&clnt_res); +} + +__dbc_dup_reply * +__db_dbc_dup_1(argp, clnt) + __dbc_dup_msg *argp; + CLIENT *clnt; +{ + static __dbc_dup_reply clnt_res; + + memset((char *)&clnt_res, 0, sizeof (clnt_res)); + if (clnt_call(clnt, __DB_dbc_dup, + (xdrproc_t) xdr___dbc_dup_msg, (caddr_t) argp, + (xdrproc_t) xdr___dbc_dup_reply, (caddr_t) &clnt_res, + TIMEOUT) != RPC_SUCCESS) { + return (NULL); + } + return (&clnt_res); +} + +__dbc_get_reply * +__db_dbc_get_1(argp, clnt) + __dbc_get_msg *argp; + CLIENT *clnt; +{ + static __dbc_get_reply clnt_res; + + memset((char *)&clnt_res, 0, sizeof (clnt_res)); + if (clnt_call(clnt, __DB_dbc_get, + (xdrproc_t) xdr___dbc_get_msg, (caddr_t) argp, + (xdrproc_t) xdr___dbc_get_reply, (caddr_t) &clnt_res, + TIMEOUT) != RPC_SUCCESS) { + return (NULL); + } + return (&clnt_res); +} + +__dbc_put_reply * +__db_dbc_put_1(argp, clnt) + __dbc_put_msg *argp; + CLIENT *clnt; +{ + static __dbc_put_reply clnt_res; + + memset((char *)&clnt_res, 0, sizeof (clnt_res)); + if (clnt_call(clnt, __DB_dbc_put, + (xdrproc_t) xdr___dbc_put_msg, (caddr_t) argp, + (xdrproc_t) xdr___dbc_put_reply, (caddr_t) &clnt_res, + TIMEOUT) != RPC_SUCCESS) { + return (NULL); + } + return (&clnt_res); +} +#endif /* HAVE_RPC */ diff --git a/db/rpc_client/gen_client.c b/db/rpc_client/gen_client.c new file mode 100644 index 000000000..7cc598e7d --- /dev/null +++ b/db/rpc_client/gen_client.c @@ -0,0 +1,2494 @@ +/* Do not edit: automatically built by gen_rpc.awk. */ +#include "db_config.h" + +#ifdef HAVE_RPC +#ifndef NO_SYSTEM_INCLUDES +#include <sys/types.h> +#include <rpc/rpc.h> +#include <rpc/xdr.h> + +#include <errno.h> +#include <string.h> +#endif +#include "db_server.h" + +#include "db_int.h" +#include "db_page.h" +#include "db_ext.h" +#include "mp.h" +#include "rpc_client_ext.h" +#include "txn.h" + +#include "gen_client_ext.h" + +int +__dbcl_env_cachesize(dbenv, gbytes, bytes, ncache) + DB_ENV * dbenv; + u_int32_t gbytes; + u_int32_t bytes; + int ncache; +{ + CLIENT *cl; + __env_cachesize_msg req; + static __env_cachesize_reply *replyp = NULL; + int ret; + + ret = 0; + if (dbenv == NULL || dbenv->cl_handle == NULL) { + __db_err(dbenv, "No server environment."); + return (DB_NOSERVER); + } + + if (replyp != NULL) { + xdr_free((xdrproc_t)xdr___env_cachesize_reply, (void *)replyp); + replyp = NULL; + } + cl = (CLIENT *)dbenv->cl_handle; + + if (dbenv == NULL) + req.dbenvcl_id = 0; + else + req.dbenvcl_id = dbenv->cl_id; + req.gbytes = gbytes; + req.bytes = bytes; + req.ncache = ncache; + + replyp = __db_env_cachesize_1(&req, cl); + if (replyp == NULL) { + __db_err(dbenv, clnt_sperror(cl, "Berkeley DB")); + ret = DB_NOSERVER; + goto out; + } + ret = replyp->status; +out: + return (ret); +} + +int +__dbcl_env_close(dbenv, flags) + DB_ENV * dbenv; + u_int32_t flags; +{ + CLIENT *cl; + __env_close_msg req; + static __env_close_reply *replyp = NULL; + int ret; + + ret = 0; + if (dbenv == NULL || dbenv->cl_handle == NULL) { + __db_err(dbenv, "No server environment."); + return (DB_NOSERVER); + } + + if (replyp != NULL) { + xdr_free((xdrproc_t)xdr___env_close_reply, (void *)replyp); + replyp = NULL; + } + cl = (CLIENT *)dbenv->cl_handle; + + if (dbenv == NULL) + req.dbenvcl_id = 0; + else + req.dbenvcl_id = dbenv->cl_id; + req.flags = flags; + + replyp = __db_env_close_1(&req, cl); + if (replyp == NULL) { + __db_err(dbenv, clnt_sperror(cl, "Berkeley DB")); + ret = DB_NOSERVER; + goto out; + } + return (__dbcl_env_close_ret(dbenv, flags, replyp)); +out: + return (ret); +} + +int +__dbcl_rpc_illegal(dbenv, name) + DB_ENV *dbenv; + char *name; +{ + __db_err(dbenv, + "%s method meaningless in RPC environment", name); + return (__db_eopnotsup(dbenv)); +} + +int +__dbcl_set_data_dir(dbenv, dir) + DB_ENV * dbenv; + const char * dir; +{ + COMPQUIET(dir, NULL); + return (__dbcl_rpc_illegal(dbenv, "set_data_dir")); +} + +int +__dbcl_env_set_feedback(dbenv, func0) + DB_ENV * dbenv; + void (*func0) __P((DB_ENV *, int, int)); +{ + COMPQUIET(func0, 0); + return (__dbcl_rpc_illegal(dbenv, "env_set_feedback")); +} + +int +__dbcl_env_flags(dbenv, flags, onoff) + DB_ENV * dbenv; + u_int32_t flags; + int onoff; +{ + CLIENT *cl; + __env_flags_msg req; + static __env_flags_reply *replyp = NULL; + int ret; + + ret = 0; + if (dbenv == NULL || dbenv->cl_handle == NULL) { + __db_err(dbenv, "No server environment."); + return (DB_NOSERVER); + } + + if (replyp != NULL) { + xdr_free((xdrproc_t)xdr___env_flags_reply, (void *)replyp); + replyp = NULL; + } + cl = (CLIENT *)dbenv->cl_handle; + + if (dbenv == NULL) + req.dbenvcl_id = 0; + else + req.dbenvcl_id = dbenv->cl_id; + req.flags = flags; + req.onoff = onoff; + + replyp = __db_env_flags_1(&req, cl); + if (replyp == NULL) { + __db_err(dbenv, clnt_sperror(cl, "Berkeley DB")); + ret = DB_NOSERVER; + goto out; + } + ret = replyp->status; +out: + return (ret); +} + +int +__dbcl_set_lg_bsize(dbenv, bsize) + DB_ENV * dbenv; + u_int32_t bsize; +{ + COMPQUIET(bsize, 0); + return (__dbcl_rpc_illegal(dbenv, "set_lg_bsize")); +} + +int +__dbcl_set_lg_dir(dbenv, dir) + DB_ENV * dbenv; + const char * dir; +{ + COMPQUIET(dir, NULL); + return (__dbcl_rpc_illegal(dbenv, "set_lg_dir")); +} + +int +__dbcl_set_lg_max(dbenv, max) + DB_ENV * dbenv; + u_int32_t max; +{ + COMPQUIET(max, 0); + return (__dbcl_rpc_illegal(dbenv, "set_lg_max")); +} + +int +__dbcl_set_lk_conflict(dbenv, conflicts, modes) + DB_ENV * dbenv; + u_int8_t * conflicts; + int modes; +{ + COMPQUIET(conflicts, 0); + COMPQUIET(modes, 0); + return (__dbcl_rpc_illegal(dbenv, "set_lk_conflict")); +} + +int +__dbcl_set_lk_detect(dbenv, detect) + DB_ENV * dbenv; + u_int32_t detect; +{ + COMPQUIET(detect, 0); + return (__dbcl_rpc_illegal(dbenv, "set_lk_detect")); +} + +int +__dbcl_set_lk_max(dbenv, max) + DB_ENV * dbenv; + u_int32_t max; +{ + COMPQUIET(max, 0); + return (__dbcl_rpc_illegal(dbenv, "set_lk_max")); +} + +int +__dbcl_set_lk_max_locks(dbenv, max) + DB_ENV * dbenv; + u_int32_t max; +{ + COMPQUIET(max, 0); + return (__dbcl_rpc_illegal(dbenv, "set_lk_max_locks")); +} + +int +__dbcl_set_lk_max_lockers(dbenv, max) + DB_ENV * dbenv; + u_int32_t max; +{ + COMPQUIET(max, 0); + return (__dbcl_rpc_illegal(dbenv, "set_lk_max_lockers")); +} + +int +__dbcl_set_lk_max_objects(dbenv, max) + DB_ENV * dbenv; + u_int32_t max; +{ + COMPQUIET(max, 0); + return (__dbcl_rpc_illegal(dbenv, "set_lk_max_objects")); +} + +int +__dbcl_set_mp_mmapsize(dbenv, mmapsize) + DB_ENV * dbenv; + size_t mmapsize; +{ + COMPQUIET(mmapsize, 0); + return (__dbcl_rpc_illegal(dbenv, "set_mp_mmapsize")); +} + +int +__dbcl_set_mutex_locks(dbenv, do_lock) + DB_ENV * dbenv; + int do_lock; +{ + COMPQUIET(do_lock, 0); + return (__dbcl_rpc_illegal(dbenv, "set_mutex_locks")); +} + +int +__dbcl_env_open(dbenv, home, flags, mode) + DB_ENV * dbenv; + const char * home; + u_int32_t flags; + int mode; +{ + CLIENT *cl; + __env_open_msg req; + static __env_open_reply *replyp = NULL; + int ret; + + ret = 0; + if (dbenv == NULL || dbenv->cl_handle == NULL) { + __db_err(dbenv, "No server environment."); + return (DB_NOSERVER); + } + + if (replyp != NULL) { + xdr_free((xdrproc_t)xdr___env_open_reply, (void *)replyp); + replyp = NULL; + } + cl = (CLIENT *)dbenv->cl_handle; + + if (dbenv == NULL) + req.dbenvcl_id = 0; + else + req.dbenvcl_id = dbenv->cl_id; + if (home == NULL) + req.home = ""; + else + req.home = (char *)home; + req.flags = flags; + req.mode = mode; + + replyp = __db_env_open_1(&req, cl); + if (replyp == NULL) { + __db_err(dbenv, clnt_sperror(cl, "Berkeley DB")); + ret = DB_NOSERVER; + goto out; + } + return (__dbcl_env_open_ret(dbenv, home, flags, mode, replyp)); +out: + return (ret); +} + +int +__dbcl_env_paniccall(dbenv, func0) + DB_ENV * dbenv; + void (*func0) __P((DB_ENV *, int)); +{ + COMPQUIET(func0, 0); + return (__dbcl_rpc_illegal(dbenv, "env_paniccall")); +} + +int +__dbcl_set_recovery_init(dbenv, func0) + DB_ENV * dbenv; + int (*func0) __P((DB_ENV *)); +{ + COMPQUIET(func0, 0); + return (__dbcl_rpc_illegal(dbenv, "set_recovery_init")); +} + +int +__dbcl_env_remove(dbenv, home, flags) + DB_ENV * dbenv; + const char * home; + u_int32_t flags; +{ + CLIENT *cl; + __env_remove_msg req; + static __env_remove_reply *replyp = NULL; + int ret; + + ret = 0; + if (dbenv == NULL || dbenv->cl_handle == NULL) { + __db_err(dbenv, "No server environment."); + return (DB_NOSERVER); + } + + if (replyp != NULL) { + xdr_free((xdrproc_t)xdr___env_remove_reply, (void *)replyp); + replyp = NULL; + } + cl = (CLIENT *)dbenv->cl_handle; + + if (dbenv == NULL) + req.dbenvcl_id = 0; + else + req.dbenvcl_id = dbenv->cl_id; + if (home == NULL) + req.home = ""; + else + req.home = (char *)home; + req.flags = flags; + + replyp = __db_env_remove_1(&req, cl); + if (replyp == NULL) { + __db_err(dbenv, clnt_sperror(cl, "Berkeley DB")); + ret = DB_NOSERVER; + goto out; + } + return (__dbcl_env_remove_ret(dbenv, home, flags, replyp)); +out: + return (ret); +} + +int +__dbcl_set_shm_key(dbenv, shm_key) + DB_ENV * dbenv; + long shm_key; +{ + COMPQUIET(shm_key, 0); + return (__dbcl_rpc_illegal(dbenv, "set_shm_key")); +} + +int +__dbcl_set_tmp_dir(dbenv, dir) + DB_ENV * dbenv; + const char * dir; +{ + COMPQUIET(dir, NULL); + return (__dbcl_rpc_illegal(dbenv, "set_tmp_dir")); +} + +int +__dbcl_set_tx_recover(dbenv, func0) + DB_ENV * dbenv; + int (*func0) __P((DB_ENV *, DBT *, DB_LSN *, db_recops)); +{ + COMPQUIET(func0, 0); + return (__dbcl_rpc_illegal(dbenv, "set_tx_recover")); +} + +int +__dbcl_set_tx_max(dbenv, max) + DB_ENV * dbenv; + u_int32_t max; +{ + COMPQUIET(max, 0); + return (__dbcl_rpc_illegal(dbenv, "set_tx_max")); +} + +int +__dbcl_set_tx_timestamp(dbenv, max) + DB_ENV * dbenv; + time_t * max; +{ + COMPQUIET(max, 0); + return (__dbcl_rpc_illegal(dbenv, "set_tx_timestamp")); +} + +int +__dbcl_set_verbose(dbenv, which, onoff) + DB_ENV * dbenv; + u_int32_t which; + int onoff; +{ + COMPQUIET(which, 0); + COMPQUIET(onoff, 0); + return (__dbcl_rpc_illegal(dbenv, "set_verbose")); +} + +int +__dbcl_txn_abort(txnp) + DB_TXN * txnp; +{ + CLIENT *cl; + __txn_abort_msg req; + static __txn_abort_reply *replyp = NULL; + int ret; + DB_ENV *dbenv; + + ret = 0; + dbenv = NULL; + dbenv = txnp->mgrp->dbenv; + if (dbenv == NULL || dbenv->cl_handle == NULL) { + __db_err(dbenv, "No server environment."); + return (DB_NOSERVER); + } + + if (replyp != NULL) { + xdr_free((xdrproc_t)xdr___txn_abort_reply, (void *)replyp); + replyp = NULL; + } + cl = (CLIENT *)dbenv->cl_handle; + + if (txnp == NULL) + req.txnpcl_id = 0; + else + req.txnpcl_id = txnp->txnid; + + replyp = __db_txn_abort_1(&req, cl); + if (replyp == NULL) { + __db_err(dbenv, clnt_sperror(cl, "Berkeley DB")); + ret = DB_NOSERVER; + goto out; + } + return (__dbcl_txn_abort_ret(txnp, replyp)); +out: + return (ret); +} + +int +__dbcl_txn_begin(envp, parent, txnpp, flags) + DB_ENV * envp; + DB_TXN * parent; + DB_TXN ** txnpp; + u_int32_t flags; +{ + CLIENT *cl; + __txn_begin_msg req; + static __txn_begin_reply *replyp = NULL; + int ret; + + ret = 0; + if (envp == NULL || envp->cl_handle == NULL) { + __db_err(envp, "No server environment."); + return (DB_NOSERVER); + } + + if (replyp != NULL) { + xdr_free((xdrproc_t)xdr___txn_begin_reply, (void *)replyp); + replyp = NULL; + } + cl = (CLIENT *)envp->cl_handle; + + if (envp == NULL) + req.envpcl_id = 0; + else + req.envpcl_id = envp->cl_id; + if (parent == NULL) + req.parentcl_id = 0; + else + req.parentcl_id = parent->txnid; + req.flags = flags; + + replyp = __db_txn_begin_1(&req, cl); + if (replyp == NULL) { + __db_err(envp, clnt_sperror(cl, "Berkeley DB")); + ret = DB_NOSERVER; + goto out; + } + return (__dbcl_txn_begin_ret(envp, parent, txnpp, flags, replyp)); +out: + return (ret); +} + +int +__dbcl_txn_checkpoint(dbenv, kbyte, min) + DB_ENV * dbenv; + u_int32_t kbyte; + u_int32_t min; +{ + COMPQUIET(kbyte, 0); + COMPQUIET(min, 0); + return (__dbcl_rpc_illegal(dbenv, "txn_checkpoint")); +} + +int +__dbcl_txn_commit(txnp, flags) + DB_TXN * txnp; + u_int32_t flags; +{ + CLIENT *cl; + __txn_commit_msg req; + static __txn_commit_reply *replyp = NULL; + int ret; + DB_ENV *dbenv; + + ret = 0; + dbenv = NULL; + dbenv = txnp->mgrp->dbenv; + if (dbenv == NULL || dbenv->cl_handle == NULL) { + __db_err(dbenv, "No server environment."); + return (DB_NOSERVER); + } + + if (replyp != NULL) { + xdr_free((xdrproc_t)xdr___txn_commit_reply, (void *)replyp); + replyp = NULL; + } + cl = (CLIENT *)dbenv->cl_handle; + + if (txnp == NULL) + req.txnpcl_id = 0; + else + req.txnpcl_id = txnp->txnid; + req.flags = flags; + + replyp = __db_txn_commit_1(&req, cl); + if (replyp == NULL) { + __db_err(dbenv, clnt_sperror(cl, "Berkeley DB")); + ret = DB_NOSERVER; + goto out; + } + return (__dbcl_txn_commit_ret(txnp, flags, replyp)); +out: + return (ret); +} + +int +__dbcl_txn_prepare(txnp) + DB_TXN * txnp; +{ + DB_ENV *dbenv; + + dbenv = txnp->mgrp->dbenv; + return (__dbcl_rpc_illegal(dbenv, "txn_prepare")); +} + +int +__dbcl_txn_stat(dbenv, statp, func0) + DB_ENV * dbenv; + DB_TXN_STAT ** statp; + void *(*func0) __P((size_t)); +{ + COMPQUIET(statp, 0); + COMPQUIET(func0, 0); + return (__dbcl_rpc_illegal(dbenv, "txn_stat")); +} + +int +__dbcl_db_bt_compare(dbp, func0) + DB * dbp; + int (*func0) __P((DB *, const DBT *, const DBT *)); +{ + DB_ENV *dbenv; + + dbenv = dbp->dbenv; + COMPQUIET(func0, 0); + return (__dbcl_rpc_illegal(dbenv, "db_bt_compare")); +} + +int +__dbcl_db_bt_maxkey(dbp, maxkey) + DB * dbp; + u_int32_t maxkey; +{ + CLIENT *cl; + __db_bt_maxkey_msg req; + static __db_bt_maxkey_reply *replyp = NULL; + int ret; + DB_ENV *dbenv; + + ret = 0; + dbenv = NULL; + dbenv = dbp->dbenv; + if (dbenv == NULL || dbenv->cl_handle == NULL) { + __db_err(dbenv, "No server environment."); + return (DB_NOSERVER); + } + + if (replyp != NULL) { + xdr_free((xdrproc_t)xdr___db_bt_maxkey_reply, (void *)replyp); + replyp = NULL; + } + cl = (CLIENT *)dbenv->cl_handle; + + if (dbp == NULL) + req.dbpcl_id = 0; + else + req.dbpcl_id = dbp->cl_id; + req.maxkey = maxkey; + + replyp = __db_db_bt_maxkey_1(&req, cl); + if (replyp == NULL) { + __db_err(dbenv, clnt_sperror(cl, "Berkeley DB")); + ret = DB_NOSERVER; + goto out; + } + ret = replyp->status; +out: + return (ret); +} + +int +__dbcl_db_bt_minkey(dbp, minkey) + DB * dbp; + u_int32_t minkey; +{ + CLIENT *cl; + __db_bt_minkey_msg req; + static __db_bt_minkey_reply *replyp = NULL; + int ret; + DB_ENV *dbenv; + + ret = 0; + dbenv = NULL; + dbenv = dbp->dbenv; + if (dbenv == NULL || dbenv->cl_handle == NULL) { + __db_err(dbenv, "No server environment."); + return (DB_NOSERVER); + } + + if (replyp != NULL) { + xdr_free((xdrproc_t)xdr___db_bt_minkey_reply, (void *)replyp); + replyp = NULL; + } + cl = (CLIENT *)dbenv->cl_handle; + + if (dbp == NULL) + req.dbpcl_id = 0; + else + req.dbpcl_id = dbp->cl_id; + req.minkey = minkey; + + replyp = __db_db_bt_minkey_1(&req, cl); + if (replyp == NULL) { + __db_err(dbenv, clnt_sperror(cl, "Berkeley DB")); + ret = DB_NOSERVER; + goto out; + } + ret = replyp->status; +out: + return (ret); +} + +int +__dbcl_db_bt_prefix(dbp, func0) + DB * dbp; + size_t (*func0) __P((DB *, const DBT *, const DBT *)); +{ + DB_ENV *dbenv; + + dbenv = dbp->dbenv; + COMPQUIET(func0, 0); + return (__dbcl_rpc_illegal(dbenv, "db_bt_prefix")); +} + +int +__dbcl_db_set_append_recno(dbp, func0) + DB * dbp; + int (*func0) __P((DB *, DBT *, db_recno_t)); +{ + DB_ENV *dbenv; + + dbenv = dbp->dbenv; + COMPQUIET(func0, 0); + return (__dbcl_rpc_illegal(dbenv, "db_set_append_recno")); +} + +int +__dbcl_db_cachesize(dbp, gbytes, bytes, ncache) + DB * dbp; + u_int32_t gbytes; + u_int32_t bytes; + int ncache; +{ + DB_ENV *dbenv; + + dbenv = dbp->dbenv; + COMPQUIET(gbytes, 0); + COMPQUIET(bytes, 0); + COMPQUIET(ncache, 0); + return (__dbcl_rpc_illegal(dbenv, "db_cachesize")); +} + +int +__dbcl_db_close(dbp, flags) + DB * dbp; + u_int32_t flags; +{ + CLIENT *cl; + __db_close_msg req; + static __db_close_reply *replyp = NULL; + int ret; + DB_ENV *dbenv; + + ret = 0; + dbenv = NULL; + dbenv = dbp->dbenv; + if (dbenv == NULL || dbenv->cl_handle == NULL) { + __db_err(dbenv, "No server environment."); + return (DB_NOSERVER); + } + + if (replyp != NULL) { + xdr_free((xdrproc_t)xdr___db_close_reply, (void *)replyp); + replyp = NULL; + } + cl = (CLIENT *)dbenv->cl_handle; + + if (dbp == NULL) + req.dbpcl_id = 0; + else + req.dbpcl_id = dbp->cl_id; + req.flags = flags; + + replyp = __db_db_close_1(&req, cl); + if (replyp == NULL) { + __db_err(dbenv, clnt_sperror(cl, "Berkeley DB")); + ret = DB_NOSERVER; + goto out; + } + return (__dbcl_db_close_ret(dbp, flags, replyp)); +out: + return (ret); +} + +int +__dbcl_db_del(dbp, txnp, key, flags) + DB * dbp; + DB_TXN * txnp; + DBT * key; + u_int32_t flags; +{ + CLIENT *cl; + __db_del_msg req; + static __db_del_reply *replyp = NULL; + int ret; + DB_ENV *dbenv; + + ret = 0; + dbenv = NULL; + dbenv = dbp->dbenv; + if (dbenv == NULL || dbenv->cl_handle == NULL) { + __db_err(dbenv, "No server environment."); + return (DB_NOSERVER); + } + + if (replyp != NULL) { + xdr_free((xdrproc_t)xdr___db_del_reply, (void *)replyp); + replyp = NULL; + } + cl = (CLIENT *)dbenv->cl_handle; + + if (dbp == NULL) + req.dbpcl_id = 0; + else + req.dbpcl_id = dbp->cl_id; + if (txnp == NULL) + req.txnpcl_id = 0; + else + req.txnpcl_id = txnp->txnid; + req.keydlen = key->dlen; + req.keydoff = key->doff; + req.keyflags = key->flags; + req.keydata.keydata_val = key->data; + req.keydata.keydata_len = key->size; + req.flags = flags; + + replyp = __db_db_del_1(&req, cl); + if (replyp == NULL) { + __db_err(dbenv, clnt_sperror(cl, "Berkeley DB")); + ret = DB_NOSERVER; + goto out; + } + ret = replyp->status; +out: + return (ret); +} + +int +__dbcl_db_extentsize(dbp, extentsize) + DB * dbp; + u_int32_t extentsize; +{ + CLIENT *cl; + __db_extentsize_msg req; + static __db_extentsize_reply *replyp = NULL; + int ret; + DB_ENV *dbenv; + + ret = 0; + dbenv = NULL; + dbenv = dbp->dbenv; + if (dbenv == NULL || dbenv->cl_handle == NULL) { + __db_err(dbenv, "No server environment."); + return (DB_NOSERVER); + } + + if (replyp != NULL) { + xdr_free((xdrproc_t)xdr___db_extentsize_reply, (void *)replyp); + replyp = NULL; + } + cl = (CLIENT *)dbenv->cl_handle; + + if (dbp == NULL) + req.dbpcl_id = 0; + else + req.dbpcl_id = dbp->cl_id; + req.extentsize = extentsize; + + replyp = __db_db_extentsize_1(&req, cl); + if (replyp == NULL) { + __db_err(dbenv, clnt_sperror(cl, "Berkeley DB")); + ret = DB_NOSERVER; + goto out; + } + ret = replyp->status; +out: + return (ret); +} + +int +__dbcl_db_fd(dbp, fdp) + DB * dbp; + int * fdp; +{ + DB_ENV *dbenv; + + dbenv = dbp->dbenv; + COMPQUIET(fdp, 0); + return (__dbcl_rpc_illegal(dbenv, "db_fd")); +} + +int +__dbcl_db_feedback(dbp, func0) + DB * dbp; + void (*func0) __P((DB *, int, int)); +{ + DB_ENV *dbenv; + + dbenv = dbp->dbenv; + COMPQUIET(func0, 0); + return (__dbcl_rpc_illegal(dbenv, "db_feedback")); +} + +int +__dbcl_db_flags(dbp, flags) + DB * dbp; + u_int32_t flags; +{ + CLIENT *cl; + __db_flags_msg req; + static __db_flags_reply *replyp = NULL; + int ret; + DB_ENV *dbenv; + + ret = 0; + dbenv = NULL; + dbenv = dbp->dbenv; + if (dbenv == NULL || dbenv->cl_handle == NULL) { + __db_err(dbenv, "No server environment."); + return (DB_NOSERVER); + } + + if (replyp != NULL) { + xdr_free((xdrproc_t)xdr___db_flags_reply, (void *)replyp); + replyp = NULL; + } + cl = (CLIENT *)dbenv->cl_handle; + + if (dbp == NULL) + req.dbpcl_id = 0; + else + req.dbpcl_id = dbp->cl_id; + req.flags = flags; + + replyp = __db_db_flags_1(&req, cl); + if (replyp == NULL) { + __db_err(dbenv, clnt_sperror(cl, "Berkeley DB")); + ret = DB_NOSERVER; + goto out; + } + ret = replyp->status; +out: + return (ret); +} + +int +__dbcl_db_get(dbp, txnp, key, data, flags) + DB * dbp; + DB_TXN * txnp; + DBT * key; + DBT * data; + u_int32_t flags; +{ + CLIENT *cl; + __db_get_msg req; + static __db_get_reply *replyp = NULL; + int ret; + DB_ENV *dbenv; + + ret = 0; + dbenv = NULL; + dbenv = dbp->dbenv; + if (dbenv == NULL || dbenv->cl_handle == NULL) { + __db_err(dbenv, "No server environment."); + return (DB_NOSERVER); + } + + if (replyp != NULL) { + xdr_free((xdrproc_t)xdr___db_get_reply, (void *)replyp); + replyp = NULL; + } + cl = (CLIENT *)dbenv->cl_handle; + + if (dbp == NULL) + req.dbpcl_id = 0; + else + req.dbpcl_id = dbp->cl_id; + if (txnp == NULL) + req.txnpcl_id = 0; + else + req.txnpcl_id = txnp->txnid; + req.keydlen = key->dlen; + req.keydoff = key->doff; + req.keyflags = key->flags; + req.keydata.keydata_val = key->data; + req.keydata.keydata_len = key->size; + req.datadlen = data->dlen; + req.datadoff = data->doff; + req.dataflags = data->flags; + req.datadata.datadata_val = data->data; + req.datadata.datadata_len = data->size; + req.flags = flags; + + replyp = __db_db_get_1(&req, cl); + if (replyp == NULL) { + __db_err(dbenv, clnt_sperror(cl, "Berkeley DB")); + ret = DB_NOSERVER; + goto out; + } + return (__dbcl_db_get_ret(dbp, txnp, key, data, flags, replyp)); +out: + return (ret); +} + +int +__dbcl_db_h_ffactor(dbp, ffactor) + DB * dbp; + u_int32_t ffactor; +{ + CLIENT *cl; + __db_h_ffactor_msg req; + static __db_h_ffactor_reply *replyp = NULL; + int ret; + DB_ENV *dbenv; + + ret = 0; + dbenv = NULL; + dbenv = dbp->dbenv; + if (dbenv == NULL || dbenv->cl_handle == NULL) { + __db_err(dbenv, "No server environment."); + return (DB_NOSERVER); + } + + if (replyp != NULL) { + xdr_free((xdrproc_t)xdr___db_h_ffactor_reply, (void *)replyp); + replyp = NULL; + } + cl = (CLIENT *)dbenv->cl_handle; + + if (dbp == NULL) + req.dbpcl_id = 0; + else + req.dbpcl_id = dbp->cl_id; + req.ffactor = ffactor; + + replyp = __db_db_h_ffactor_1(&req, cl); + if (replyp == NULL) { + __db_err(dbenv, clnt_sperror(cl, "Berkeley DB")); + ret = DB_NOSERVER; + goto out; + } + ret = replyp->status; +out: + return (ret); +} + +int +__dbcl_db_h_hash(dbp, func0) + DB * dbp; + u_int32_t (*func0) __P((DB *, const void *, u_int32_t)); +{ + DB_ENV *dbenv; + + dbenv = dbp->dbenv; + COMPQUIET(func0, 0); + return (__dbcl_rpc_illegal(dbenv, "db_h_hash")); +} + +int +__dbcl_db_h_nelem(dbp, nelem) + DB * dbp; + u_int32_t nelem; +{ + CLIENT *cl; + __db_h_nelem_msg req; + static __db_h_nelem_reply *replyp = NULL; + int ret; + DB_ENV *dbenv; + + ret = 0; + dbenv = NULL; + dbenv = dbp->dbenv; + if (dbenv == NULL || dbenv->cl_handle == NULL) { + __db_err(dbenv, "No server environment."); + return (DB_NOSERVER); + } + + if (replyp != NULL) { + xdr_free((xdrproc_t)xdr___db_h_nelem_reply, (void *)replyp); + replyp = NULL; + } + cl = (CLIENT *)dbenv->cl_handle; + + if (dbp == NULL) + req.dbpcl_id = 0; + else + req.dbpcl_id = dbp->cl_id; + req.nelem = nelem; + + replyp = __db_db_h_nelem_1(&req, cl); + if (replyp == NULL) { + __db_err(dbenv, clnt_sperror(cl, "Berkeley DB")); + ret = DB_NOSERVER; + goto out; + } + ret = replyp->status; +out: + return (ret); +} + +int +__dbcl_db_key_range(dbp, txnp, key, range, flags) + DB * dbp; + DB_TXN * txnp; + DBT * key; + DB_KEY_RANGE * range; + u_int32_t flags; +{ + CLIENT *cl; + __db_key_range_msg req; + static __db_key_range_reply *replyp = NULL; + int ret; + DB_ENV *dbenv; + + ret = 0; + dbenv = NULL; + dbenv = dbp->dbenv; + if (dbenv == NULL || dbenv->cl_handle == NULL) { + __db_err(dbenv, "No server environment."); + return (DB_NOSERVER); + } + + if (replyp != NULL) { + xdr_free((xdrproc_t)xdr___db_key_range_reply, (void *)replyp); + replyp = NULL; + } + cl = (CLIENT *)dbenv->cl_handle; + + if (dbp == NULL) + req.dbpcl_id = 0; + else + req.dbpcl_id = dbp->cl_id; + if (txnp == NULL) + req.txnpcl_id = 0; + else + req.txnpcl_id = txnp->txnid; + req.keydlen = key->dlen; + req.keydoff = key->doff; + req.keyflags = key->flags; + req.keydata.keydata_val = key->data; + req.keydata.keydata_len = key->size; + req.flags = flags; + + replyp = __db_db_key_range_1(&req, cl); + if (replyp == NULL) { + __db_err(dbenv, clnt_sperror(cl, "Berkeley DB")); + ret = DB_NOSERVER; + goto out; + } + return (__dbcl_db_key_range_ret(dbp, txnp, key, range, flags, replyp)); +out: + return (ret); +} + +int +__dbcl_db_lorder(dbp, lorder) + DB * dbp; + int lorder; +{ + CLIENT *cl; + __db_lorder_msg req; + static __db_lorder_reply *replyp = NULL; + int ret; + DB_ENV *dbenv; + + ret = 0; + dbenv = NULL; + dbenv = dbp->dbenv; + if (dbenv == NULL || dbenv->cl_handle == NULL) { + __db_err(dbenv, "No server environment."); + return (DB_NOSERVER); + } + + if (replyp != NULL) { + xdr_free((xdrproc_t)xdr___db_lorder_reply, (void *)replyp); + replyp = NULL; + } + cl = (CLIENT *)dbenv->cl_handle; + + if (dbp == NULL) + req.dbpcl_id = 0; + else + req.dbpcl_id = dbp->cl_id; + req.lorder = lorder; + + replyp = __db_db_lorder_1(&req, cl); + if (replyp == NULL) { + __db_err(dbenv, clnt_sperror(cl, "Berkeley DB")); + ret = DB_NOSERVER; + goto out; + } + ret = replyp->status; +out: + return (ret); +} + +int +__dbcl_db_malloc(dbp, func0) + DB * dbp; + void *(*func0) __P((size_t)); +{ + DB_ENV *dbenv; + + dbenv = dbp->dbenv; + COMPQUIET(func0, 0); + return (__dbcl_rpc_illegal(dbenv, "db_malloc")); +} + +int +__dbcl_db_open(dbp, name, subdb, type, flags, mode) + DB * dbp; + const char * name; + const char * subdb; + DBTYPE type; + u_int32_t flags; + int mode; +{ + CLIENT *cl; + __db_open_msg req; + static __db_open_reply *replyp = NULL; + int ret; + DB_ENV *dbenv; + + ret = 0; + dbenv = NULL; + dbenv = dbp->dbenv; + if (dbenv == NULL || dbenv->cl_handle == NULL) { + __db_err(dbenv, "No server environment."); + return (DB_NOSERVER); + } + + if (replyp != NULL) { + xdr_free((xdrproc_t)xdr___db_open_reply, (void *)replyp); + replyp = NULL; + } + cl = (CLIENT *)dbenv->cl_handle; + + if (dbp == NULL) + req.dbpcl_id = 0; + else + req.dbpcl_id = dbp->cl_id; + if (name == NULL) + req.name = ""; + else + req.name = (char *)name; + if (subdb == NULL) + req.subdb = ""; + else + req.subdb = (char *)subdb; + req.type = type; + req.flags = flags; + req.mode = mode; + + replyp = __db_db_open_1(&req, cl); + if (replyp == NULL) { + __db_err(dbenv, clnt_sperror(cl, "Berkeley DB")); + ret = DB_NOSERVER; + goto out; + } + return (__dbcl_db_open_ret(dbp, name, subdb, type, flags, mode, replyp)); +out: + return (ret); +} + +int +__dbcl_db_pagesize(dbp, pagesize) + DB * dbp; + u_int32_t pagesize; +{ + CLIENT *cl; + __db_pagesize_msg req; + static __db_pagesize_reply *replyp = NULL; + int ret; + DB_ENV *dbenv; + + ret = 0; + dbenv = NULL; + dbenv = dbp->dbenv; + if (dbenv == NULL || dbenv->cl_handle == NULL) { + __db_err(dbenv, "No server environment."); + return (DB_NOSERVER); + } + + if (replyp != NULL) { + xdr_free((xdrproc_t)xdr___db_pagesize_reply, (void *)replyp); + replyp = NULL; + } + cl = (CLIENT *)dbenv->cl_handle; + + if (dbp == NULL) + req.dbpcl_id = 0; + else + req.dbpcl_id = dbp->cl_id; + req.pagesize = pagesize; + + replyp = __db_db_pagesize_1(&req, cl); + if (replyp == NULL) { + __db_err(dbenv, clnt_sperror(cl, "Berkeley DB")); + ret = DB_NOSERVER; + goto out; + } + ret = replyp->status; +out: + return (ret); +} + +int +__dbcl_db_panic(dbp, func0) + DB * dbp; + void (*func0) __P((DB_ENV *, int)); +{ + DB_ENV *dbenv; + + dbenv = dbp->dbenv; + COMPQUIET(func0, 0); + return (__dbcl_rpc_illegal(dbenv, "db_panic")); +} + +int +__dbcl_db_put(dbp, txnp, key, data, flags) + DB * dbp; + DB_TXN * txnp; + DBT * key; + DBT * data; + u_int32_t flags; +{ + CLIENT *cl; + __db_put_msg req; + static __db_put_reply *replyp = NULL; + int ret; + DB_ENV *dbenv; + + ret = 0; + dbenv = NULL; + dbenv = dbp->dbenv; + if (dbenv == NULL || dbenv->cl_handle == NULL) { + __db_err(dbenv, "No server environment."); + return (DB_NOSERVER); + } + + if (replyp != NULL) { + xdr_free((xdrproc_t)xdr___db_put_reply, (void *)replyp); + replyp = NULL; + } + cl = (CLIENT *)dbenv->cl_handle; + + if (dbp == NULL) + req.dbpcl_id = 0; + else + req.dbpcl_id = dbp->cl_id; + if (txnp == NULL) + req.txnpcl_id = 0; + else + req.txnpcl_id = txnp->txnid; + req.keydlen = key->dlen; + req.keydoff = key->doff; + req.keyflags = key->flags; + req.keydata.keydata_val = key->data; + req.keydata.keydata_len = key->size; + req.datadlen = data->dlen; + req.datadoff = data->doff; + req.dataflags = data->flags; + req.datadata.datadata_val = data->data; + req.datadata.datadata_len = data->size; + req.flags = flags; + + replyp = __db_db_put_1(&req, cl); + if (replyp == NULL) { + __db_err(dbenv, clnt_sperror(cl, "Berkeley DB")); + ret = DB_NOSERVER; + goto out; + } + return (__dbcl_db_put_ret(dbp, txnp, key, data, flags, replyp)); +out: + return (ret); +} + +int +__dbcl_db_realloc(dbp, func0) + DB * dbp; + void *(*func0) __P((void *, size_t)); +{ + DB_ENV *dbenv; + + dbenv = dbp->dbenv; + COMPQUIET(func0, 0); + return (__dbcl_rpc_illegal(dbenv, "db_realloc")); +} + +int +__dbcl_db_re_delim(dbp, delim) + DB * dbp; + int delim; +{ + CLIENT *cl; + __db_re_delim_msg req; + static __db_re_delim_reply *replyp = NULL; + int ret; + DB_ENV *dbenv; + + ret = 0; + dbenv = NULL; + dbenv = dbp->dbenv; + if (dbenv == NULL || dbenv->cl_handle == NULL) { + __db_err(dbenv, "No server environment."); + return (DB_NOSERVER); + } + + if (replyp != NULL) { + xdr_free((xdrproc_t)xdr___db_re_delim_reply, (void *)replyp); + replyp = NULL; + } + cl = (CLIENT *)dbenv->cl_handle; + + if (dbp == NULL) + req.dbpcl_id = 0; + else + req.dbpcl_id = dbp->cl_id; + req.delim = delim; + + replyp = __db_db_re_delim_1(&req, cl); + if (replyp == NULL) { + __db_err(dbenv, clnt_sperror(cl, "Berkeley DB")); + ret = DB_NOSERVER; + goto out; + } + ret = replyp->status; +out: + return (ret); +} + +int +__dbcl_db_re_len(dbp, len) + DB * dbp; + u_int32_t len; +{ + CLIENT *cl; + __db_re_len_msg req; + static __db_re_len_reply *replyp = NULL; + int ret; + DB_ENV *dbenv; + + ret = 0; + dbenv = NULL; + dbenv = dbp->dbenv; + if (dbenv == NULL || dbenv->cl_handle == NULL) { + __db_err(dbenv, "No server environment."); + return (DB_NOSERVER); + } + + if (replyp != NULL) { + xdr_free((xdrproc_t)xdr___db_re_len_reply, (void *)replyp); + replyp = NULL; + } + cl = (CLIENT *)dbenv->cl_handle; + + if (dbp == NULL) + req.dbpcl_id = 0; + else + req.dbpcl_id = dbp->cl_id; + req.len = len; + + replyp = __db_db_re_len_1(&req, cl); + if (replyp == NULL) { + __db_err(dbenv, clnt_sperror(cl, "Berkeley DB")); + ret = DB_NOSERVER; + goto out; + } + ret = replyp->status; +out: + return (ret); +} + +int +__dbcl_db_re_pad(dbp, pad) + DB * dbp; + int pad; +{ + CLIENT *cl; + __db_re_pad_msg req; + static __db_re_pad_reply *replyp = NULL; + int ret; + DB_ENV *dbenv; + + ret = 0; + dbenv = NULL; + dbenv = dbp->dbenv; + if (dbenv == NULL || dbenv->cl_handle == NULL) { + __db_err(dbenv, "No server environment."); + return (DB_NOSERVER); + } + + if (replyp != NULL) { + xdr_free((xdrproc_t)xdr___db_re_pad_reply, (void *)replyp); + replyp = NULL; + } + cl = (CLIENT *)dbenv->cl_handle; + + if (dbp == NULL) + req.dbpcl_id = 0; + else + req.dbpcl_id = dbp->cl_id; + req.pad = pad; + + replyp = __db_db_re_pad_1(&req, cl); + if (replyp == NULL) { + __db_err(dbenv, clnt_sperror(cl, "Berkeley DB")); + ret = DB_NOSERVER; + goto out; + } + ret = replyp->status; +out: + return (ret); +} + +int +__dbcl_db_re_source(dbp, re_source) + DB * dbp; + const char * re_source; +{ + DB_ENV *dbenv; + + dbenv = dbp->dbenv; + COMPQUIET(re_source, NULL); + return (__dbcl_rpc_illegal(dbenv, "db_re_source")); +} + +int +__dbcl_db_remove(dbp, name, subdb, flags) + DB * dbp; + const char * name; + const char * subdb; + u_int32_t flags; +{ + CLIENT *cl; + __db_remove_msg req; + static __db_remove_reply *replyp = NULL; + int ret; + DB_ENV *dbenv; + + ret = 0; + dbenv = NULL; + dbenv = dbp->dbenv; + if (dbenv == NULL || dbenv->cl_handle == NULL) { + __db_err(dbenv, "No server environment."); + return (DB_NOSERVER); + } + + if (replyp != NULL) { + xdr_free((xdrproc_t)xdr___db_remove_reply, (void *)replyp); + replyp = NULL; + } + cl = (CLIENT *)dbenv->cl_handle; + + if (dbp == NULL) + req.dbpcl_id = 0; + else + req.dbpcl_id = dbp->cl_id; + if (name == NULL) + req.name = ""; + else + req.name = (char *)name; + if (subdb == NULL) + req.subdb = ""; + else + req.subdb = (char *)subdb; + req.flags = flags; + + replyp = __db_db_remove_1(&req, cl); + if (replyp == NULL) { + __db_err(dbenv, clnt_sperror(cl, "Berkeley DB")); + ret = DB_NOSERVER; + goto out; + } + return (__dbcl_db_remove_ret(dbp, name, subdb, flags, replyp)); +out: + return (ret); +} + +int +__dbcl_db_rename(dbp, name, subdb, newname, flags) + DB * dbp; + const char * name; + const char * subdb; + const char * newname; + u_int32_t flags; +{ + CLIENT *cl; + __db_rename_msg req; + static __db_rename_reply *replyp = NULL; + int ret; + DB_ENV *dbenv; + + ret = 0; + dbenv = NULL; + dbenv = dbp->dbenv; + if (dbenv == NULL || dbenv->cl_handle == NULL) { + __db_err(dbenv, "No server environment."); + return (DB_NOSERVER); + } + + if (replyp != NULL) { + xdr_free((xdrproc_t)xdr___db_rename_reply, (void *)replyp); + replyp = NULL; + } + cl = (CLIENT *)dbenv->cl_handle; + + if (dbp == NULL) + req.dbpcl_id = 0; + else + req.dbpcl_id = dbp->cl_id; + if (name == NULL) + req.name = ""; + else + req.name = (char *)name; + if (subdb == NULL) + req.subdb = ""; + else + req.subdb = (char *)subdb; + if (newname == NULL) + req.newname = ""; + else + req.newname = (char *)newname; + req.flags = flags; + + replyp = __db_db_rename_1(&req, cl); + if (replyp == NULL) { + __db_err(dbenv, clnt_sperror(cl, "Berkeley DB")); + ret = DB_NOSERVER; + goto out; + } + return (__dbcl_db_rename_ret(dbp, name, subdb, newname, flags, replyp)); +out: + return (ret); +} + +int +__dbcl_db_stat(dbp, sp, func0, flags) + DB * dbp; + void * sp; + void *(*func0) __P((size_t)); + u_int32_t flags; +{ + CLIENT *cl; + __db_stat_msg req; + static __db_stat_reply *replyp = NULL; + int ret; + DB_ENV *dbenv; + + ret = 0; + dbenv = NULL; + dbenv = dbp->dbenv; + if (dbenv == NULL || dbenv->cl_handle == NULL) { + __db_err(dbenv, "No server environment."); + return (DB_NOSERVER); + } + + if (replyp != NULL) { + xdr_free((xdrproc_t)xdr___db_stat_reply, (void *)replyp); + replyp = NULL; + } + cl = (CLIENT *)dbenv->cl_handle; + + if (func0 != NULL) { + __db_err(sp, "User functions not supported in RPC."); + return (EINVAL); + } + if (dbp == NULL) + req.dbpcl_id = 0; + else + req.dbpcl_id = dbp->cl_id; + req.flags = flags; + + replyp = __db_db_stat_1(&req, cl); + if (replyp == NULL) { + __db_err(dbenv, clnt_sperror(cl, "Berkeley DB")); + ret = DB_NOSERVER; + goto out; + } + return (__dbcl_db_stat_ret(dbp, sp, func0, flags, replyp)); +out: + return (ret); +} + +int +__dbcl_db_swapped(dbp) + DB * dbp; +{ + CLIENT *cl; + __db_swapped_msg req; + static __db_swapped_reply *replyp = NULL; + int ret; + DB_ENV *dbenv; + + ret = 0; + dbenv = NULL; + dbenv = dbp->dbenv; + if (dbenv == NULL || dbenv->cl_handle == NULL) { + __db_err(dbenv, "No server environment."); + return (DB_NOSERVER); + } + + if (replyp != NULL) { + xdr_free((xdrproc_t)xdr___db_swapped_reply, (void *)replyp); + replyp = NULL; + } + cl = (CLIENT *)dbenv->cl_handle; + + if (dbp == NULL) + req.dbpcl_id = 0; + else + req.dbpcl_id = dbp->cl_id; + + replyp = __db_db_swapped_1(&req, cl); + if (replyp == NULL) { + __db_err(dbenv, clnt_sperror(cl, "Berkeley DB")); + ret = DB_NOSERVER; + goto out; + } + ret = replyp->status; +out: + return (ret); +} + +int +__dbcl_db_sync(dbp, flags) + DB * dbp; + u_int32_t flags; +{ + CLIENT *cl; + __db_sync_msg req; + static __db_sync_reply *replyp = NULL; + int ret; + DB_ENV *dbenv; + + ret = 0; + dbenv = NULL; + dbenv = dbp->dbenv; + if (dbenv == NULL || dbenv->cl_handle == NULL) { + __db_err(dbenv, "No server environment."); + return (DB_NOSERVER); + } + + if (replyp != NULL) { + xdr_free((xdrproc_t)xdr___db_sync_reply, (void *)replyp); + replyp = NULL; + } + cl = (CLIENT *)dbenv->cl_handle; + + if (dbp == NULL) + req.dbpcl_id = 0; + else + req.dbpcl_id = dbp->cl_id; + req.flags = flags; + + replyp = __db_db_sync_1(&req, cl); + if (replyp == NULL) { + __db_err(dbenv, clnt_sperror(cl, "Berkeley DB")); + ret = DB_NOSERVER; + goto out; + } + ret = replyp->status; +out: + return (ret); +} + +int +__dbcl_db_upgrade(dbp, fname, flags) + DB * dbp; + const char * fname; + u_int32_t flags; +{ + DB_ENV *dbenv; + + dbenv = dbp->dbenv; + COMPQUIET(fname, NULL); + COMPQUIET(flags, 0); + return (__dbcl_rpc_illegal(dbenv, "db_upgrade")); +} + +int +__dbcl_db_cursor(dbp, txnp, dbcpp, flags) + DB * dbp; + DB_TXN * txnp; + DBC ** dbcpp; + u_int32_t flags; +{ + CLIENT *cl; + __db_cursor_msg req; + static __db_cursor_reply *replyp = NULL; + int ret; + DB_ENV *dbenv; + + ret = 0; + dbenv = NULL; + dbenv = dbp->dbenv; + if (dbenv == NULL || dbenv->cl_handle == NULL) { + __db_err(dbenv, "No server environment."); + return (DB_NOSERVER); + } + + if (replyp != NULL) { + xdr_free((xdrproc_t)xdr___db_cursor_reply, (void *)replyp); + replyp = NULL; + } + cl = (CLIENT *)dbenv->cl_handle; + + if (dbp == NULL) + req.dbpcl_id = 0; + else + req.dbpcl_id = dbp->cl_id; + if (txnp == NULL) + req.txnpcl_id = 0; + else + req.txnpcl_id = txnp->txnid; + req.flags = flags; + + replyp = __db_db_cursor_1(&req, cl); + if (replyp == NULL) { + __db_err(dbenv, clnt_sperror(cl, "Berkeley DB")); + ret = DB_NOSERVER; + goto out; + } + return (__dbcl_db_cursor_ret(dbp, txnp, dbcpp, flags, replyp)); +out: + return (ret); +} + +static int __dbcl_db_join_curslist __P((__db_join_curslist **, DBC **)); +static void __dbcl_db_join_cursfree __P((__db_join_curslist **)); +int +__dbcl_db_join(dbp, curs, dbcp, flags) + DB * dbp; + DBC ** curs; + DBC ** dbcp; + u_int32_t flags; +{ + CLIENT *cl; + __db_join_msg req; + static __db_join_reply *replyp = NULL; + int ret; + DB_ENV *dbenv; + + ret = 0; + dbenv = NULL; + dbenv = dbp->dbenv; + if (dbenv == NULL || dbenv->cl_handle == NULL) { + __db_err(dbenv, "No server environment."); + return (DB_NOSERVER); + } + + if (replyp != NULL) { + xdr_free((xdrproc_t)xdr___db_join_reply, (void *)replyp); + replyp = NULL; + } + cl = (CLIENT *)dbenv->cl_handle; + + if (dbp == NULL) + req.dbpcl_id = 0; + else + req.dbpcl_id = dbp->cl_id; + if ((ret = __dbcl_db_join_curslist(&req.curslist, curs)) != 0) + goto out; + req.flags = flags; + + replyp = __db_db_join_1(&req, cl); + if (replyp == NULL) { + __db_err(dbenv, clnt_sperror(cl, "Berkeley DB")); + ret = DB_NOSERVER; + goto out; + } + __dbcl_db_join_cursfree(&req.curslist); + return (__dbcl_db_join_ret(dbp, curs, dbcp, flags, replyp)); +out: + __dbcl_db_join_cursfree(&req.curslist); + return (ret); +} + +int +__dbcl_db_join_curslist(locp, pp) + __db_join_curslist **locp; + DBC ** pp; +{ + DBC ** p; + u_int32_t *q; + int ret; + __db_join_curslist *nl, **nlp; + + *locp = NULL; + if (pp == NULL) + return (0); + nlp = locp; + for (p = pp; *p != 0; p++) { + if ((ret = __os_malloc(NULL, sizeof(*nl), NULL, nlp)) != 0) + goto out; + nl = *nlp; + nl->next = NULL; + nl->ent.ent_val = NULL; + nl->ent.ent_len = 0; + if ((ret = __os_malloc(NULL, sizeof(u_int32_t), NULL, &nl->ent.ent_val)) != 0) + goto out; + q = (u_int32_t *)nl->ent.ent_val; + *q = (*p)->cl_id; + nl->ent.ent_len = sizeof(u_int32_t); + nlp = &nl->next; + } + return (0); +out: + __dbcl_db_join_cursfree(locp); + return (ret); +} + +void +__dbcl_db_join_cursfree(locp) + __db_join_curslist **locp; +{ + __db_join_curslist *nl, *nl1; + + if (locp == NULL) + return; + for (nl = *locp; nl != NULL; nl = nl1) { + nl1 = nl->next; + if (nl->ent.ent_val) + __os_free(nl->ent.ent_val, nl->ent.ent_len); + __os_free(nl, sizeof(*nl)); + } +} + +int +__dbcl_dbc_close(dbc) + DBC * dbc; +{ + CLIENT *cl; + __dbc_close_msg req; + static __dbc_close_reply *replyp = NULL; + int ret; + DB_ENV *dbenv; + + ret = 0; + dbenv = NULL; + dbenv = dbc->dbp->dbenv; + if (dbenv == NULL || dbenv->cl_handle == NULL) { + __db_err(dbenv, "No server environment."); + return (DB_NOSERVER); + } + + if (replyp != NULL) { + xdr_free((xdrproc_t)xdr___dbc_close_reply, (void *)replyp); + replyp = NULL; + } + cl = (CLIENT *)dbenv->cl_handle; + + if (dbc == NULL) + req.dbccl_id = 0; + else + req.dbccl_id = dbc->cl_id; + + replyp = __db_dbc_close_1(&req, cl); + if (replyp == NULL) { + __db_err(dbenv, clnt_sperror(cl, "Berkeley DB")); + ret = DB_NOSERVER; + goto out; + } + return (__dbcl_dbc_close_ret(dbc, replyp)); +out: + return (ret); +} + +int +__dbcl_dbc_count(dbc, countp, flags) + DBC * dbc; + db_recno_t * countp; + u_int32_t flags; +{ + CLIENT *cl; + __dbc_count_msg req; + static __dbc_count_reply *replyp = NULL; + int ret; + DB_ENV *dbenv; + + ret = 0; + dbenv = NULL; + dbenv = dbc->dbp->dbenv; + if (dbenv == NULL || dbenv->cl_handle == NULL) { + __db_err(dbenv, "No server environment."); + return (DB_NOSERVER); + } + + if (replyp != NULL) { + xdr_free((xdrproc_t)xdr___dbc_count_reply, (void *)replyp); + replyp = NULL; + } + cl = (CLIENT *)dbenv->cl_handle; + + if (dbc == NULL) + req.dbccl_id = 0; + else + req.dbccl_id = dbc->cl_id; + req.flags = flags; + + replyp = __db_dbc_count_1(&req, cl); + if (replyp == NULL) { + __db_err(dbenv, clnt_sperror(cl, "Berkeley DB")); + ret = DB_NOSERVER; + goto out; + } + return (__dbcl_dbc_count_ret(dbc, countp, flags, replyp)); +out: + return (ret); +} + +int +__dbcl_dbc_del(dbc, flags) + DBC * dbc; + u_int32_t flags; +{ + CLIENT *cl; + __dbc_del_msg req; + static __dbc_del_reply *replyp = NULL; + int ret; + DB_ENV *dbenv; + + ret = 0; + dbenv = NULL; + dbenv = dbc->dbp->dbenv; + if (dbenv == NULL || dbenv->cl_handle == NULL) { + __db_err(dbenv, "No server environment."); + return (DB_NOSERVER); + } + + if (replyp != NULL) { + xdr_free((xdrproc_t)xdr___dbc_del_reply, (void *)replyp); + replyp = NULL; + } + cl = (CLIENT *)dbenv->cl_handle; + + if (dbc == NULL) + req.dbccl_id = 0; + else + req.dbccl_id = dbc->cl_id; + req.flags = flags; + + replyp = __db_dbc_del_1(&req, cl); + if (replyp == NULL) { + __db_err(dbenv, clnt_sperror(cl, "Berkeley DB")); + ret = DB_NOSERVER; + goto out; + } + ret = replyp->status; +out: + return (ret); +} + +int +__dbcl_dbc_dup(dbc, dbcp, flags) + DBC * dbc; + DBC ** dbcp; + u_int32_t flags; +{ + CLIENT *cl; + __dbc_dup_msg req; + static __dbc_dup_reply *replyp = NULL; + int ret; + DB_ENV *dbenv; + + ret = 0; + dbenv = NULL; + dbenv = dbc->dbp->dbenv; + if (dbenv == NULL || dbenv->cl_handle == NULL) { + __db_err(dbenv, "No server environment."); + return (DB_NOSERVER); + } + + if (replyp != NULL) { + xdr_free((xdrproc_t)xdr___dbc_dup_reply, (void *)replyp); + replyp = NULL; + } + cl = (CLIENT *)dbenv->cl_handle; + + if (dbc == NULL) + req.dbccl_id = 0; + else + req.dbccl_id = dbc->cl_id; + req.flags = flags; + + replyp = __db_dbc_dup_1(&req, cl); + if (replyp == NULL) { + __db_err(dbenv, clnt_sperror(cl, "Berkeley DB")); + ret = DB_NOSERVER; + goto out; + } + return (__dbcl_dbc_dup_ret(dbc, dbcp, flags, replyp)); +out: + return (ret); +} + +int +__dbcl_dbc_get(dbc, key, data, flags) + DBC * dbc; + DBT * key; + DBT * data; + u_int32_t flags; +{ + CLIENT *cl; + __dbc_get_msg req; + static __dbc_get_reply *replyp = NULL; + int ret; + DB_ENV *dbenv; + + ret = 0; + dbenv = NULL; + dbenv = dbc->dbp->dbenv; + if (dbenv == NULL || dbenv->cl_handle == NULL) { + __db_err(dbenv, "No server environment."); + return (DB_NOSERVER); + } + + if (replyp != NULL) { + xdr_free((xdrproc_t)xdr___dbc_get_reply, (void *)replyp); + replyp = NULL; + } + cl = (CLIENT *)dbenv->cl_handle; + + if (dbc == NULL) + req.dbccl_id = 0; + else + req.dbccl_id = dbc->cl_id; + req.keydlen = key->dlen; + req.keydoff = key->doff; + req.keyflags = key->flags; + req.keydata.keydata_val = key->data; + req.keydata.keydata_len = key->size; + req.datadlen = data->dlen; + req.datadoff = data->doff; + req.dataflags = data->flags; + req.datadata.datadata_val = data->data; + req.datadata.datadata_len = data->size; + req.flags = flags; + + replyp = __db_dbc_get_1(&req, cl); + if (replyp == NULL) { + __db_err(dbenv, clnt_sperror(cl, "Berkeley DB")); + ret = DB_NOSERVER; + goto out; + } + return (__dbcl_dbc_get_ret(dbc, key, data, flags, replyp)); +out: + return (ret); +} + +int +__dbcl_dbc_put(dbc, key, data, flags) + DBC * dbc; + DBT * key; + DBT * data; + u_int32_t flags; +{ + CLIENT *cl; + __dbc_put_msg req; + static __dbc_put_reply *replyp = NULL; + int ret; + DB_ENV *dbenv; + + ret = 0; + dbenv = NULL; + dbenv = dbc->dbp->dbenv; + if (dbenv == NULL || dbenv->cl_handle == NULL) { + __db_err(dbenv, "No server environment."); + return (DB_NOSERVER); + } + + if (replyp != NULL) { + xdr_free((xdrproc_t)xdr___dbc_put_reply, (void *)replyp); + replyp = NULL; + } + cl = (CLIENT *)dbenv->cl_handle; + + if (dbc == NULL) + req.dbccl_id = 0; + else + req.dbccl_id = dbc->cl_id; + req.keydlen = key->dlen; + req.keydoff = key->doff; + req.keyflags = key->flags; + req.keydata.keydata_val = key->data; + req.keydata.keydata_len = key->size; + req.datadlen = data->dlen; + req.datadoff = data->doff; + req.dataflags = data->flags; + req.datadata.datadata_val = data->data; + req.datadata.datadata_len = data->size; + req.flags = flags; + + replyp = __db_dbc_put_1(&req, cl); + if (replyp == NULL) { + __db_err(dbenv, clnt_sperror(cl, "Berkeley DB")); + ret = DB_NOSERVER; + goto out; + } + return (__dbcl_dbc_put_ret(dbc, key, data, flags, replyp)); +out: + return (ret); +} + +int +__dbcl_lock_detect(dbenv, flags, atype, aborted) + DB_ENV * dbenv; + u_int32_t flags; + u_int32_t atype; + int * aborted; +{ + COMPQUIET(flags, 0); + COMPQUIET(atype, 0); + COMPQUIET(aborted, 0); + return (__dbcl_rpc_illegal(dbenv, "lock_detect")); +} + +int +__dbcl_lock_get(dbenv, locker, flags, obj, mode, lock) + DB_ENV * dbenv; + u_int32_t locker; + u_int32_t flags; + const DBT * obj; + db_lockmode_t mode; + DB_LOCK * lock; +{ + COMPQUIET(locker, 0); + COMPQUIET(flags, 0); + COMPQUIET(obj, NULL); + COMPQUIET(mode, 0); + COMPQUIET(lock, 0); + return (__dbcl_rpc_illegal(dbenv, "lock_get")); +} + +int +__dbcl_lock_id(dbenv, idp) + DB_ENV * dbenv; + u_int32_t * idp; +{ + COMPQUIET(idp, 0); + return (__dbcl_rpc_illegal(dbenv, "lock_id")); +} + +int +__dbcl_lock_put(dbenv, lock) + DB_ENV * dbenv; + DB_LOCK * lock; +{ + COMPQUIET(lock, 0); + return (__dbcl_rpc_illegal(dbenv, "lock_put")); +} + +int +__dbcl_lock_stat(dbenv, statp, func0) + DB_ENV * dbenv; + DB_LOCK_STAT ** statp; + void *(*func0) __P((size_t)); +{ + COMPQUIET(statp, 0); + COMPQUIET(func0, 0); + return (__dbcl_rpc_illegal(dbenv, "lock_stat")); +} + +int +__dbcl_lock_vec(dbenv, locker, flags, list, nlist, elistp) + DB_ENV * dbenv; + u_int32_t locker; + u_int32_t flags; + DB_LOCKREQ * list; + int nlist; + DB_LOCKREQ ** elistp; +{ + COMPQUIET(locker, 0); + COMPQUIET(flags, 0); + COMPQUIET(list, 0); + COMPQUIET(nlist, 0); + COMPQUIET(elistp, 0); + return (__dbcl_rpc_illegal(dbenv, "lock_vec")); +} + +int +__dbcl_log_archive(dbenv, listp, flags, func0) + DB_ENV * dbenv; + char *** listp; + u_int32_t flags; + void *(*func0) __P((size_t)); +{ + COMPQUIET(listp, 0); + COMPQUIET(flags, 0); + COMPQUIET(func0, 0); + return (__dbcl_rpc_illegal(dbenv, "log_archive")); +} + +int +__dbcl_log_file(dbenv, lsn, namep, len) + DB_ENV * dbenv; + const DB_LSN * lsn; + char * namep; + size_t len; +{ + COMPQUIET(lsn, NULL); + COMPQUIET(namep, NULL); + COMPQUIET(len, 0); + return (__dbcl_rpc_illegal(dbenv, "log_file")); +} + +int +__dbcl_log_flush(dbenv, lsn) + DB_ENV * dbenv; + const DB_LSN * lsn; +{ + COMPQUIET(lsn, NULL); + return (__dbcl_rpc_illegal(dbenv, "log_flush")); +} + +int +__dbcl_log_get(dbenv, lsn, data, flags) + DB_ENV * dbenv; + DB_LSN * lsn; + DBT * data; + u_int32_t flags; +{ + COMPQUIET(lsn, 0); + COMPQUIET(data, NULL); + COMPQUIET(flags, 0); + return (__dbcl_rpc_illegal(dbenv, "log_get")); +} + +int +__dbcl_log_put(dbenv, lsn, data, flags) + DB_ENV * dbenv; + DB_LSN * lsn; + const DBT * data; + u_int32_t flags; +{ + COMPQUIET(lsn, 0); + COMPQUIET(data, NULL); + COMPQUIET(flags, 0); + return (__dbcl_rpc_illegal(dbenv, "log_put")); +} + +int +__dbcl_log_register(dbenv, dbp, namep) + DB_ENV * dbenv; + DB * dbp; + const char * namep; +{ + COMPQUIET(dbp, 0); + COMPQUIET(namep, NULL); + return (__dbcl_rpc_illegal(dbenv, "log_register")); +} + +int +__dbcl_log_stat(dbenv, statp, func0) + DB_ENV * dbenv; + DB_LOG_STAT ** statp; + void *(*func0) __P((size_t)); +{ + COMPQUIET(statp, 0); + COMPQUIET(func0, 0); + return (__dbcl_rpc_illegal(dbenv, "log_stat")); +} + +int +__dbcl_log_unregister(dbenv, dbp) + DB_ENV * dbenv; + DB * dbp; +{ + COMPQUIET(dbp, 0); + return (__dbcl_rpc_illegal(dbenv, "log_unregister")); +} + +int +__dbcl_memp_fclose(mpf) + DB_MPOOLFILE * mpf; +{ + DB_ENV *dbenv; + + dbenv = mpf->dbmp->dbenv; + return (__dbcl_rpc_illegal(dbenv, "memp_fclose")); +} + +int +__dbcl_memp_fget(mpf, pgno, flags, pagep) + DB_MPOOLFILE * mpf; + db_pgno_t * pgno; + u_int32_t flags; + void ** pagep; +{ + DB_ENV *dbenv; + + dbenv = mpf->dbmp->dbenv; + COMPQUIET(pgno, 0); + COMPQUIET(flags, 0); + COMPQUIET(pagep, 0); + return (__dbcl_rpc_illegal(dbenv, "memp_fget")); +} + +int +__dbcl_memp_fopen(dbenv, file, flags, mode, pagesize, finfop, mpf) + DB_ENV * dbenv; + const char * file; + u_int32_t flags; + int mode; + size_t pagesize; + DB_MPOOL_FINFO * finfop; + DB_MPOOLFILE ** mpf; +{ + COMPQUIET(file, NULL); + COMPQUIET(flags, 0); + COMPQUIET(mode, 0); + COMPQUIET(pagesize, 0); + COMPQUIET(finfop, 0); + COMPQUIET(mpf, 0); + return (__dbcl_rpc_illegal(dbenv, "memp_fopen")); +} + +int +__dbcl_memp_fput(mpf, pgaddr, flags) + DB_MPOOLFILE * mpf; + void * pgaddr; + u_int32_t flags; +{ + DB_ENV *dbenv; + + dbenv = mpf->dbmp->dbenv; + COMPQUIET(pgaddr, 0); + COMPQUIET(flags, 0); + return (__dbcl_rpc_illegal(dbenv, "memp_fput")); +} + +int +__dbcl_memp_fset(mpf, pgaddr, flags) + DB_MPOOLFILE * mpf; + void * pgaddr; + u_int32_t flags; +{ + DB_ENV *dbenv; + + dbenv = mpf->dbmp->dbenv; + COMPQUIET(pgaddr, 0); + COMPQUIET(flags, 0); + return (__dbcl_rpc_illegal(dbenv, "memp_fset")); +} + +int +__dbcl_memp_fsync(mpf) + DB_MPOOLFILE * mpf; +{ + DB_ENV *dbenv; + + dbenv = mpf->dbmp->dbenv; + return (__dbcl_rpc_illegal(dbenv, "memp_fsync")); +} + +int +__dbcl_memp_register(dbenv, ftype, func0, func1) + DB_ENV * dbenv; + int ftype; + int (*func0) __P((DB_ENV *, db_pgno_t, void *, DBT *)); + int (*func1) __P((DB_ENV *, db_pgno_t, void *, DBT *)); +{ + COMPQUIET(ftype, 0); + COMPQUIET(func0, 0); + COMPQUIET(func1, 0); + return (__dbcl_rpc_illegal(dbenv, "memp_register")); +} + +int +__dbcl_memp_stat(dbenv, gstatp, fstatp, func0) + DB_ENV * dbenv; + DB_MPOOL_STAT ** gstatp; + DB_MPOOL_FSTAT *** fstatp; + void *(*func0) __P((size_t)); +{ + COMPQUIET(gstatp, 0); + COMPQUIET(fstatp, 0); + COMPQUIET(func0, 0); + return (__dbcl_rpc_illegal(dbenv, "memp_stat")); +} + +int +__dbcl_memp_sync(dbenv, lsn) + DB_ENV * dbenv; + DB_LSN * lsn; +{ + COMPQUIET(lsn, 0); + return (__dbcl_rpc_illegal(dbenv, "memp_sync")); +} + +int +__dbcl_memp_trickle(dbenv, pct, nwrotep) + DB_ENV * dbenv; + int pct; + int * nwrotep; +{ + COMPQUIET(pct, 0); + COMPQUIET(nwrotep, 0); + return (__dbcl_rpc_illegal(dbenv, "memp_trickle")); +} + +#endif /* HAVE_RPC */ diff --git a/db/rpc_client/gen_client_ret.c b/db/rpc_client/gen_client_ret.c new file mode 100644 index 000000000..17e3f195f --- /dev/null +++ b/db/rpc_client/gen_client_ret.c @@ -0,0 +1,542 @@ +/*- + * See the file LICENSE for redistribution information. + * + * Copyright (c) 2000 + * Sleepycat Software. All rights reserved. + */ + +#include "db_config.h" + +#ifndef lint +static const char revid[] = "$Id: gen_client_ret.c,v 1.29 2000/12/31 19:26:23 bostic Exp $"; +#endif /* not lint */ + +#ifdef HAVE_RPC +#ifndef NO_SYSTEM_INCLUDES +#include <sys/types.h> + +#include <rpc/rpc.h> + +#include <string.h> +#endif +#include "db_server.h" + +#include "db_int.h" +#include "db_page.h" +#include "txn.h" +#include "db_ext.h" +#include "rpc_client_ext.h" + +static void __db_db_stat_statsfree __P((u_int32_t *)); +static int __db_db_stat_statslist __P((__db_stat_statsreplist *, u_int32_t **)); + +int +__dbcl_env_close_ret(dbenv, flags, replyp) + DB_ENV *dbenv; + u_int32_t flags; + __env_close_reply *replyp; +{ + int ret; + + COMPQUIET(flags, 0); + + ret = __dbcl_refresh(dbenv); + __os_free(dbenv, sizeof(*dbenv)); + if (replyp->status == 0 && ret != 0) + return (ret); + else + return (replyp->status); +} + +int +__dbcl_env_open_ret(dbenv, home, flags, mode, replyp) + DB_ENV *dbenv; + const char *home; + u_int32_t flags; + int mode; + __env_open_reply *replyp; +{ + DB_TXNMGR *tmgrp; + int ret; + + COMPQUIET(home, NULL); + COMPQUIET(mode, 0); + + /* + * If error, return it. + */ + if (replyp->status != 0) + return (replyp->status); + + /* + * If the user requested transactions, then we have some + * local client-side setup to do also. + */ + if (LF_ISSET(DB_INIT_TXN)) { + if ((ret = __os_calloc(dbenv, + 1, sizeof(DB_TXNMGR), &tmgrp)) != 0) + return (ret); + TAILQ_INIT(&tmgrp->txn_chain); + tmgrp->dbenv = dbenv; + dbenv->tx_handle = tmgrp; + } + + return (replyp->status); +} + +int +__dbcl_env_remove_ret(dbenv, home, flags, replyp) + DB_ENV *dbenv; + const char *home; + u_int32_t flags; + __env_remove_reply *replyp; +{ + int ret; + + COMPQUIET(home, NULL); + COMPQUIET(flags, 0); + + ret = __dbcl_refresh(dbenv); + __os_free(dbenv, sizeof(*dbenv)); + if (replyp->status == 0 && ret != 0) + return (ret); + else + return (replyp->status); +} + +int +__dbcl_txn_abort_ret(txnp, replyp) + DB_TXN *txnp; + __txn_abort_reply *replyp; +{ + __dbcl_txn_end(txnp); + return (replyp->status); +} + +int +__dbcl_txn_begin_ret(envp, parent, txnpp, flags, replyp) + DB_ENV *envp; + DB_TXN *parent, **txnpp; + u_int32_t flags; + __txn_begin_reply *replyp; +{ + DB_TXN *txn; + int ret; + + COMPQUIET(flags, 0); + + if (replyp->status != 0) + return (replyp->status); + + if ((ret = __os_calloc(envp, 1, sizeof(DB_TXN), &txn)) != 0) + return (ret); + txn->txnid = replyp->txnidcl_id; + txn->mgrp = envp->tx_handle; + txn->parent = parent; + TAILQ_INIT(&txn->kids); + txn->flags = TXN_MALLOC; + if (parent != NULL) + TAILQ_INSERT_HEAD(&parent->kids, txn, klinks); + + /* + * XXX + * In DB library the txn_chain is protected by the mgrp->mutexp. + * However, that mutex is implemented in the environments shared + * memory region. The client library does not support all of the + * region - that just get forwarded to the server. Therefore, + * the chain is unprotected here, but properly protected on the + * server. + */ + TAILQ_INSERT_TAIL(&txn->mgrp->txn_chain, txn, links); + + *txnpp = txn; + return (replyp->status); +} + +int +__dbcl_txn_commit_ret(txnp, flags, replyp) + DB_TXN *txnp; + u_int32_t flags; + __txn_commit_reply *replyp; +{ + COMPQUIET(flags, 0); + + __dbcl_txn_end(txnp); + return (replyp->status); +} + +int +__dbcl_db_close_ret(dbp, flags, replyp) + DB *dbp; + u_int32_t flags; + __db_close_reply *replyp; +{ + int ret; + + COMPQUIET(flags, 0); + + ret = __dbcl_dbclose_common(dbp); + + if (replyp->status != 0) + return (replyp->status); + else + return (ret); +} + +int +__dbcl_db_get_ret(dbp, txnp, key, data, flags, replyp) + DB *dbp; + DB_TXN *txnp; + DBT *key, *data; + u_int32_t flags; + __db_get_reply *replyp; +{ + DB_ENV *dbenv; + int ret; + void *oldkey; + + COMPQUIET(txnp, NULL); + COMPQUIET(flags, 0); + + ret = 0; + if (replyp->status != 0) + return (replyp->status); + + dbenv = dbp->dbenv; + + oldkey = key->data; + ret = __dbcl_retcopy(dbenv, key, replyp->keydata.keydata_val, + replyp->keydata.keydata_len); + if (ret) + return (ret); + ret = __dbcl_retcopy(dbenv, data, replyp->datadata.datadata_val, + replyp->datadata.datadata_len); + /* + * If an error on copying 'data' and we allocated for 'key' + * free it before returning the error. + */ + if (ret && oldkey != NULL) + __os_free(key->data, key->size); + return (ret); +} + +int +__dbcl_db_key_range_ret(dbp, txnp, key, range, flags, replyp) + DB *dbp; + DB_TXN *txnp; + DBT *key; + DB_KEY_RANGE *range; + u_int32_t flags; + __db_key_range_reply *replyp; +{ + COMPQUIET(dbp, NULL); + COMPQUIET(txnp, NULL); + COMPQUIET(key, NULL); + COMPQUIET(flags, 0); + + if (replyp->status != 0) + return (replyp->status); + range->less = replyp->less; + range->equal = replyp->equal; + range->greater = replyp->greater; + return (replyp->status); +} + +int +__dbcl_db_open_ret(dbp, name, subdb, type, flags, mode, replyp) + DB *dbp; + const char *name, *subdb; + DBTYPE type; + u_int32_t flags; + int mode; + __db_open_reply *replyp; +{ + COMPQUIET(name, NULL); + COMPQUIET(subdb, NULL); + COMPQUIET(type, 0); + COMPQUIET(flags, 0); + COMPQUIET(mode, 0); + + dbp->type = replyp->type; + + /* + * XXX + * This is only for Tcl which peeks at the dbp flags. + * When dbp->get_flags exists, this should go away. + */ + dbp->flags = replyp->dbflags; + return (replyp->status); +} + +int +__dbcl_db_put_ret(dbp, txnp, key, data, flags, replyp) + DB *dbp; + DB_TXN *txnp; + DBT *key, *data; + u_int32_t flags; + __db_put_reply *replyp; +{ + int ret; + + COMPQUIET(dbp, NULL); + COMPQUIET(txnp, NULL); + COMPQUIET(data, NULL); + + ret = replyp->status; + if (replyp->status == 0 && (flags == DB_APPEND)) + *(db_recno_t *)key->data = + *(db_recno_t *)replyp->keydata.keydata_val; + return (ret); +} + +int +__dbcl_db_remove_ret(dbp, name, subdb, flags, replyp) + DB *dbp; + const char *name, *subdb; + u_int32_t flags; + __db_remove_reply *replyp; +{ + int ret; + + COMPQUIET(name, 0); + COMPQUIET(subdb, 0); + COMPQUIET(flags, 0); + + ret = __dbcl_dbclose_common(dbp); + + if (replyp->status != 0) + return (replyp->status); + else + return (ret); +} + +int +__dbcl_db_rename_ret(dbp, name, subdb, newname, flags, replyp) + DB *dbp; + const char *name, *subdb, *newname; + u_int32_t flags; + __db_remove_reply *replyp; +{ + int ret; + + COMPQUIET(name, 0); + COMPQUIET(subdb, 0); + COMPQUIET(newname, 0); + COMPQUIET(flags, 0); + + ret = __dbcl_dbclose_common(dbp); + + if (replyp->status != 0) + return (replyp->status); + else + return (ret); +} + +int +__dbcl_db_stat_ret(dbp, sp, func, flags, replyp) + DB *dbp; + void *sp; + void *(*func) __P((size_t)); + u_int32_t flags; + __db_stat_reply *replyp; +{ + int ret; + u_int32_t *__db_statslist; + + COMPQUIET(dbp, NULL); + COMPQUIET(func, NULL); + COMPQUIET(flags, 0); + + if (replyp->status != 0) + return (replyp->status); + + if ((ret = + __db_db_stat_statslist(replyp->statslist, &__db_statslist)) != 0) + return (ret); + + if (sp == NULL) + __db_db_stat_statsfree(__db_statslist); + else + *(u_int32_t **)sp = __db_statslist; + return (replyp->status); +} + +static int +__db_db_stat_statslist(locp, ppp) + __db_stat_statsreplist *locp; + u_int32_t **ppp; +{ + u_int32_t *pp; + int cnt, ret, size; + __db_stat_statsreplist *nl; + + for (cnt = 0, nl = locp; nl != NULL; cnt++, nl = nl->next) + ; + + if (cnt == 0) { + *ppp = NULL; + return (0); + } + size = sizeof(*pp) * cnt; + if ((ret = __os_malloc(NULL, size, NULL, ppp)) != 0) + return (ret); + memset(*ppp, 0, size); + for (pp = *ppp, nl = locp; nl != NULL; nl = nl->next, pp++) { + *pp = *(u_int32_t *)nl->ent.ent_val; + } + return (0); +} + +static void +__db_db_stat_statsfree(pp) + u_int32_t *pp; +{ + size_t size; + u_int32_t *p; + + if (pp == NULL) + return; + size = sizeof(*p); + for (p = pp; *p != 0; p++) + size += sizeof(*p); + + __os_free(pp, size); +} + +int +__dbcl_db_cursor_ret(dbp, txnp, dbcpp, flags, replyp) + DB *dbp; + DB_TXN *txnp; + DBC **dbcpp; + u_int32_t flags; + __db_cursor_reply *replyp; +{ + COMPQUIET(txnp, NULL); + COMPQUIET(flags, 0); + + if (replyp->status != 0) + return (replyp->status); + + return (__dbcl_c_setup(replyp->dbcidcl_id, dbp, dbcpp)); +} + +int +__dbcl_db_join_ret(dbp, curs, dbcpp, flags, replyp) + DB *dbp; + DBC **curs, **dbcpp; + u_int32_t flags; + __db_join_reply *replyp; +{ + COMPQUIET(curs, NULL); + COMPQUIET(flags, 0); + + if (replyp->status != 0) + return (replyp->status); + + /* + * We set this up as a normal cursor. We do not need + * to treat a join cursor any differently than a normal + * cursor, even though DB itself must. We only need the + * client-side cursor/db relationship to know what cursors + * are open in the db, and to store their ID. Nothing else. + */ + return (__dbcl_c_setup(replyp->dbcidcl_id, dbp, dbcpp)); +} + +int +__dbcl_dbc_close_ret(dbcp, replyp) + DBC *dbcp; + __dbc_close_reply *replyp; +{ + DB *dbp; + + dbp = dbcp->dbp; + __dbcl_c_refresh(dbcp); + return (replyp->status); +} + +int +__dbcl_dbc_count_ret(dbc, countp, flags, replyp) + DBC *dbc; + db_recno_t *countp; + u_int32_t flags; + __dbc_count_reply *replyp; +{ + COMPQUIET(dbc, NULL); + COMPQUIET(flags, 0); + + if (replyp->status != 0) + return (replyp->status); + *countp = replyp->dupcount; + + return (replyp->status); +} + +int +__dbcl_dbc_dup_ret(dbcp, dbcpp, flags, replyp) + DBC *dbcp, **dbcpp; + u_int32_t flags; + __dbc_dup_reply *replyp; +{ + COMPQUIET(flags, 0); + + if (replyp->status != 0) + return (replyp->status); + + return (__dbcl_c_setup(replyp->dbcidcl_id, dbcp->dbp, dbcpp)); +} + +int +__dbcl_dbc_get_ret(dbcp, key, data, flags, replyp) + DBC *dbcp; + DBT *key, *data; + u_int32_t flags; + __dbc_get_reply *replyp; +{ + DB_ENV *dbenv; + int ret; + void *oldkey; + + COMPQUIET(flags, 0); + + ret = 0; + if (replyp->status != 0) + return (replyp->status); + + dbenv = dbcp->dbp->dbenv; + oldkey = key->data; + ret = __dbcl_retcopy(dbenv, key, replyp->keydata.keydata_val, + replyp->keydata.keydata_len); + if (ret) + return (ret); + ret = __dbcl_retcopy(dbenv, data, replyp->datadata.datadata_val, + replyp->datadata.datadata_len); + + /* + * If an error on copying 'data' and we allocated for 'key' + * free it before returning the error. + */ + if (ret && oldkey != NULL) + __os_free(key->data, key->size); + return (ret); +} + +int +__dbcl_dbc_put_ret(dbcp, key, data, flags, replyp) + DBC *dbcp; + DBT *key, *data; + u_int32_t flags; + __dbc_put_reply *replyp; +{ + COMPQUIET(data, NULL); + + if (replyp->status != 0) + return (replyp->status); + + if (replyp->status == 0 && dbcp->dbp->type == DB_RECNO && + (flags == DB_AFTER || flags == DB_BEFORE)) + *(db_recno_t *)key->data = + *(db_recno_t *)replyp->keydata.keydata_val; + return (replyp->status); +} +#endif /* HAVE_RPC */ |