Main Page | Class Hierarchy | Data Structures | Directories | File List | Data Fields | Related Pages

gen_client_ret.c

00001 /*-
00002  * See the file LICENSE for redistribution information.
00003  *
00004  * Copyright (c) 2000-2005
00005  *      Sleepycat Software.  All rights reserved.
00006  *
00007  * $Id: gen_client_ret.c,v 12.2 2005/07/21 18:21:30 bostic Exp $
00008  */
00009 
00010 #include "db_config.h"
00011 
00012 #ifndef NO_SYSTEM_INCLUDES
00013 #include <sys/types.h>
00014 
00015 #include <rpc/rpc.h>
00016 
00017 #include <string.h>
00018 #endif
00019 
00020 #include "db_server.h"
00021 
00022 #include "db_int.h"
00023 #include "dbinc/db_page.h"
00024 #include "dbinc/db_am.h"
00025 #include "dbinc/txn.h"
00026 #include "dbinc_auto/rpc_client_ext.h"
00027 
00028 #define FREE_IF_CHANGED(dbtp, orig)     do {                            \
00029         if ((dbtp)->data != NULL && (dbtp)->data != orig) {             \
00030                 __os_free(dbenv, (dbtp)->data);                         \
00031                 (dbtp)->data = NULL;                                    \
00032         }                                                               \
00033 } while (0)
00034 
00035 /*
00036  * PUBLIC: int __dbcl_env_create_ret
00037  * PUBLIC:     __P((DB_ENV *, long, __env_create_reply *));
00038  */
00039 int
00040 __dbcl_env_create_ret(dbenv, timeout, replyp)
00041         DB_ENV * dbenv;
00042         long timeout;
00043         __env_create_reply *replyp;
00044 {
00045 
00046         COMPQUIET(timeout, 0);
00047 
00048         if (replyp->status != 0)
00049                 return (replyp->status);
00050         dbenv->cl_id = replyp->envcl_id;
00051         return (replyp->status);
00052 }
00053 
00054 /*
00055  * PUBLIC: int __dbcl_env_open_ret __P((DB_ENV *,
00056  * PUBLIC:     const char *, u_int32_t, int, __env_open_reply *));
00057  */
00058 int
00059 __dbcl_env_open_ret(dbenv, home, flags, mode, replyp)
00060         DB_ENV *dbenv;
00061         const char *home;
00062         u_int32_t flags;
00063         int mode;
00064         __env_open_reply *replyp;
00065 {
00066         DB_TXNMGR *tmgrp;
00067         int ret;
00068 
00069         COMPQUIET(home, NULL);
00070         COMPQUIET(mode, 0);
00071 
00072         /*
00073          * If error, return it.
00074          */
00075         if (replyp->status != 0)
00076                 return (replyp->status);
00077 
00078         dbenv->cl_id = replyp->envcl_id;
00079         /*
00080          * If the user requested transactions, then we have some
00081          * local client-side setup to do also.
00082          */
00083         if (LF_ISSET(DB_INIT_TXN)) {
00084                 if ((ret = __os_calloc(dbenv,
00085                     1, sizeof(DB_TXNMGR), &tmgrp)) != 0)
00086                         return (ret);
00087                 TAILQ_INIT(&tmgrp->txn_chain);
00088                 tmgrp->dbenv = dbenv;
00089                 dbenv->tx_handle = tmgrp;
00090         }
00091 
00092         return (replyp->status);
00093 }
00094 
00095 /*
00096  * PUBLIC: int __dbcl_env_remove_ret
00097  * PUBLIC:     __P((DB_ENV *, const char *, u_int32_t, __env_remove_reply *));
00098  */
00099 int
00100 __dbcl_env_remove_ret(dbenv, home, flags, replyp)
00101         DB_ENV *dbenv;
00102         const char *home;
00103         u_int32_t flags;
00104         __env_remove_reply *replyp;
00105 {
00106         int ret;
00107 
00108         COMPQUIET(home, NULL);
00109         COMPQUIET(flags, 0);
00110 
00111         ret = __dbcl_refresh(dbenv);
00112         __os_free(NULL, dbenv);
00113         if (replyp->status == 0 && ret != 0)
00114                 return (ret);
00115         else
00116                 return (replyp->status);
00117 }
00118 
00119 /*
00120  * PUBLIC: int __dbcl_txn_abort_ret __P((DB_TXN *, __txn_abort_reply *));
00121  */
00122 int
00123 __dbcl_txn_abort_ret(txnp, replyp)
00124         DB_TXN *txnp;
00125         __txn_abort_reply *replyp;
00126 {
00127         __dbcl_txn_end(txnp);
00128         return (replyp->status);
00129 }
00130 
00131 /*
00132  * PUBLIC: int __dbcl_env_txn_begin_ret __P((DB_ENV *,
00133  * PUBLIC:     DB_TXN *, DB_TXN **, u_int32_t, __env_txn_begin_reply *));
00134  */
00135 int
00136 __dbcl_env_txn_begin_ret(envp, parent, txnpp, flags, replyp)
00137         DB_ENV *envp;
00138         DB_TXN *parent, **txnpp;
00139         u_int32_t flags;
00140         __env_txn_begin_reply *replyp;
00141 {
00142         DB_TXN *txn;
00143         int ret;
00144 
00145         COMPQUIET(flags, 0);
00146 
00147         if (replyp->status != 0)
00148                 return (replyp->status);
00149 
00150         if ((ret = __os_calloc(envp, 1, sizeof(DB_TXN), &txn)) != 0)
00151                 return (ret);
00152         /*
00153          * !!!
00154          * Cast the txnidcl_id to 32-bits.  We don't want to change the
00155          * size of the txn structure.  But if we're running on 64-bit
00156          * machines, we could overflow.  Ignore for now.
00157          */
00158         __dbcl_txn_setup(envp, txn, parent, (u_int32_t)replyp->txnidcl_id);
00159         *txnpp = txn;
00160         return (replyp->status);
00161 }
00162 
00163 /*
00164  * PUBLIC: int __dbcl_txn_commit_ret
00165  * PUBLIC:     __P((DB_TXN *, u_int32_t, __txn_commit_reply *));
00166  */
00167 int
00168 __dbcl_txn_commit_ret(txnp, flags, replyp)
00169         DB_TXN *txnp;
00170         u_int32_t flags;
00171         __txn_commit_reply *replyp;
00172 {
00173         COMPQUIET(flags, 0);
00174 
00175         __dbcl_txn_end(txnp);
00176         return (replyp->status);
00177 }
00178 
00179 /*
00180  * PUBLIC: int __dbcl_txn_discard_ret __P((DB_TXN *, u_int32_t,
00181  * PUBLIC:      __txn_discard_reply *));
00182  */
00183 int
00184 __dbcl_txn_discard_ret(txnp, flags, replyp)
00185         DB_TXN * txnp;
00186         u_int32_t flags;
00187         __txn_discard_reply *replyp;
00188 {
00189         COMPQUIET(flags, 0);
00190 
00191         __dbcl_txn_end(txnp);
00192         return (replyp->status);
00193 }
00194 
00195 /*
00196  * PUBLIC: int __dbcl_env_txn_recover_ret __P((DB_ENV *, DB_PREPLIST *, long,
00197  * PUBLIC:      long *, u_int32_t, __env_txn_recover_reply *));
00198  */
00199 int
00200 __dbcl_env_txn_recover_ret(dbenv, preplist, count, retp, flags, replyp)
00201         DB_ENV * dbenv;
00202         DB_PREPLIST * preplist;
00203         long count;
00204         long * retp;
00205         u_int32_t flags;
00206         __env_txn_recover_reply *replyp;
00207 {
00208         DB_PREPLIST *prep;
00209         DB_TXN *txnarray, *txn;
00210         u_int32_t i, *txnid;
00211         int ret;
00212         u_int8_t *gid;
00213 
00214         COMPQUIET(flags, 0);
00215         COMPQUIET(count, 0);
00216 
00217         if (replyp->status != 0)
00218                 return (replyp->status);
00219 
00220         *retp = (long) replyp->retcount;
00221 
00222         if (replyp->retcount == 0)
00223                 return (replyp->status);
00224 
00225         if ((ret = __os_calloc(dbenv, replyp->retcount, sizeof(DB_TXN),
00226             &txnarray)) != 0)
00227                 return (ret);
00228         /*
00229          * We have a bunch of arrays that need to iterate in
00230          * lockstep with each other.
00231          */
00232         i = 0;
00233         txn = txnarray;
00234         txnid = (u_int32_t *)replyp->txn.txn_val;
00235         gid = (u_int8_t *)replyp->gid.gid_val;
00236         prep = preplist;
00237         while (i++ < replyp->retcount) {
00238                 __dbcl_txn_setup(dbenv, txn, NULL, *txnid);
00239                 prep->txn = txn;
00240                 memcpy(prep->gid, gid, DB_XIDDATASIZE);
00241                 /*
00242                  * Now increment all our array pointers.
00243                  */
00244                 txn++;
00245                 gid += DB_XIDDATASIZE;
00246                 txnid++;
00247                 prep++;
00248         }
00249 
00250         return (0);
00251 }
00252 
00253 /*
00254  * PUBLIC: int __dbcl_db_close_ret __P((DB *, u_int32_t, __db_close_reply *));
00255  */
00256 int
00257 __dbcl_db_close_ret(dbp, flags, replyp)
00258         DB *dbp;
00259         u_int32_t flags;
00260         __db_close_reply *replyp;
00261 {
00262         int ret;
00263 
00264         COMPQUIET(flags, 0);
00265 
00266         ret = __dbcl_dbclose_common(dbp);
00267 
00268         if (replyp->status != 0)
00269                 return (replyp->status);
00270         else
00271                 return (ret);
00272 }
00273 
00274 /*
00275  * PUBLIC: int __dbcl_db_create_ret
00276  * PUBLIC:     __P((DB *, DB_ENV *, u_int32_t, __db_create_reply *));
00277  */
00278 int
00279 __dbcl_db_create_ret(dbp, dbenv, flags, replyp)
00280         DB * dbp;
00281         DB_ENV * dbenv;
00282         u_int32_t flags;
00283         __db_create_reply *replyp;
00284 {
00285         COMPQUIET(dbenv, NULL);
00286         COMPQUIET(flags, 0);
00287 
00288         if (replyp->status != 0)
00289                 return (replyp->status);
00290         dbp->cl_id = replyp->dbcl_id;
00291         return (replyp->status);
00292 }
00293 
00294 /*
00295  * PUBLIC: int __dbcl_db_get_ret
00296  * PUBLIC:     __P((DB *, DB_TXN *, DBT *, DBT *, u_int32_t, __db_get_reply *));
00297  */
00298 int
00299 __dbcl_db_get_ret(dbp, txnp, key, data, flags, replyp)
00300         DB *dbp;
00301         DB_TXN *txnp;
00302         DBT *key, *data;
00303         u_int32_t flags;
00304         __db_get_reply *replyp;
00305 {
00306         DB_ENV *dbenv;
00307         int ret;
00308         void *oldkey;
00309 
00310         COMPQUIET(txnp, NULL);
00311         COMPQUIET(flags, 0);
00312 
00313         ret = 0;
00314         if (replyp->status != 0)
00315                 return (replyp->status);
00316 
00317         dbenv = dbp->dbenv;
00318 
00319         oldkey = key->data;
00320         ret = __dbcl_retcopy(dbenv, key, replyp->keydata.keydata_val,
00321             replyp->keydata.keydata_len, &dbp->my_rkey.data,
00322             &dbp->my_rkey.ulen);
00323         if (ret)
00324                 return (ret);
00325         ret = __dbcl_retcopy(dbenv, data, replyp->datadata.datadata_val,
00326             replyp->datadata.datadata_len, &dbp->my_rdata.data,
00327             &dbp->my_rdata.ulen);
00328         /*
00329          * If an error on copying 'data' and we allocated for 'key'
00330          * free it before returning the error.
00331          */
00332         if (ret)
00333                 FREE_IF_CHANGED(key, oldkey);
00334         return (ret);
00335 }
00336 
00337 /*
00338  * PUBLIC: int __dbcl_db_key_range_ret __P((DB *, DB_TXN *,
00339  * PUBLIC:     DBT *, DB_KEY_RANGE *, u_int32_t, __db_key_range_reply *));
00340  */
00341 int
00342 __dbcl_db_key_range_ret(dbp, txnp, key, range, flags, replyp)
00343         DB *dbp;
00344         DB_TXN *txnp;
00345         DBT *key;
00346         DB_KEY_RANGE *range;
00347         u_int32_t flags;
00348         __db_key_range_reply *replyp;
00349 {
00350         COMPQUIET(dbp, NULL);
00351         COMPQUIET(txnp, NULL);
00352         COMPQUIET(key, NULL);
00353         COMPQUIET(flags, 0);
00354 
00355         if (replyp->status != 0)
00356                 return (replyp->status);
00357         range->less = replyp->less;
00358         range->equal = replyp->equal;
00359         range->greater = replyp->greater;
00360         return (replyp->status);
00361 }
00362 
00363 /*
00364  * PUBLIC: int __dbcl_db_open_ret __P((DB *, DB_TXN *, const char *,
00365  * PUBLIC:     const char *, DBTYPE, u_int32_t, int, __db_open_reply *));
00366  */
00367 int
00368 __dbcl_db_open_ret(dbp, txn, name, subdb, type, flags, mode, replyp)
00369         DB *dbp;
00370         DB_TXN *txn;
00371         const char *name, *subdb;
00372         DBTYPE type;
00373         u_int32_t flags;
00374         int mode;
00375         __db_open_reply *replyp;
00376 {
00377         COMPQUIET(txn, NULL);
00378         COMPQUIET(name, NULL);
00379         COMPQUIET(subdb, NULL);
00380         COMPQUIET(type, DB_UNKNOWN);
00381         COMPQUIET(flags, 0);
00382         COMPQUIET(mode, 0);
00383 
00384         if (replyp->status == 0) {
00385                 dbp->cl_id = replyp->dbcl_id;
00386                 dbp->type = (DBTYPE)replyp->type;
00387                 /*
00388                  * We get back the database's byteorder on the server.
00389                  * Determine if our byteorder is the same or not by
00390                  * calling __db_set_lorder.
00391                  *
00392                  * XXX
00393                  * This MUST come before we set the flags because
00394                  * __db_set_lorder checks that it is called before
00395                  * the open flag is set.
00396                  */
00397                 (void)__db_set_lorder(dbp, replyp->lorder);
00398 
00399                 /*
00400                  * Explicitly set DB_AM_OPEN_CALLED since open is now
00401                  * successfully completed.
00402                  */
00403                 F_SET(dbp, DB_AM_OPEN_CALLED);
00404         }
00405         return (replyp->status);
00406 }
00407 
00408 /*
00409  * PUBLIC: int __dbcl_db_pget_ret __P((DB *, DB_TXN *, DBT *, DBT *, DBT *,
00410  * PUBLIC:      u_int32_t, __db_pget_reply *));
00411  */
00412 int
00413 __dbcl_db_pget_ret(dbp, txnp, skey, pkey, data, flags, replyp)
00414         DB * dbp;
00415         DB_TXN * txnp;
00416         DBT * skey;
00417         DBT * pkey;
00418         DBT * data;
00419         u_int32_t flags;
00420         __db_pget_reply *replyp;
00421 {
00422         DB_ENV *dbenv;
00423         int ret;
00424         void *oldskey, *oldpkey;
00425 
00426         COMPQUIET(txnp, NULL);
00427         COMPQUIET(flags, 0);
00428 
00429         ret = 0;
00430         if (replyp->status != 0)
00431                 return (replyp->status);
00432 
00433         dbenv = dbp->dbenv;
00434 
00435         oldskey = skey->data;
00436         ret = __dbcl_retcopy(dbenv, skey, replyp->skeydata.skeydata_val,
00437             replyp->skeydata.skeydata_len, &dbp->my_rskey.data,
00438             &dbp->my_rskey.ulen);
00439         if (ret)
00440                 return (ret);
00441 
00442         oldpkey = pkey->data;
00443         if ((ret = __dbcl_retcopy(dbenv, pkey, replyp->pkeydata.pkeydata_val,
00444             replyp->pkeydata.pkeydata_len, &dbp->my_rkey.data,
00445             &dbp->my_rkey.ulen)) != 0)
00446                 goto err;
00447         ret = __dbcl_retcopy(dbenv, data, replyp->datadata.datadata_val,
00448             replyp->datadata.datadata_len, &dbp->my_rdata.data,
00449             &dbp->my_rdata.ulen);
00450 
00451         if (ret) {
00452 err:            FREE_IF_CHANGED(skey, oldskey);
00453                 FREE_IF_CHANGED(pkey, oldpkey);
00454         }
00455         return (ret);
00456 }
00457 
00458 /*
00459  * PUBLIC: int __dbcl_db_put_ret
00460  * PUBLIC:     __P((DB *, DB_TXN *, DBT *, DBT *, u_int32_t, __db_put_reply *));
00461  */
00462 int
00463 __dbcl_db_put_ret(dbp, txnp, key, data, flags, replyp)
00464         DB *dbp;
00465         DB_TXN *txnp;
00466         DBT *key, *data;
00467         u_int32_t flags;
00468         __db_put_reply *replyp;
00469 {
00470         int ret;
00471 
00472         COMPQUIET(dbp, NULL);
00473         COMPQUIET(txnp, NULL);
00474         COMPQUIET(data, NULL);
00475 
00476         ret = replyp->status;
00477         if (replyp->status == 0 && (flags == DB_APPEND))
00478                 *(db_recno_t *)key->data =
00479                     *(db_recno_t *)replyp->keydata.keydata_val;
00480         return (ret);
00481 }
00482 
00483 /*
00484  * PUBLIC: int __dbcl_db_remove_ret __P((DB *,
00485  * PUBLIC:     const char *, const char *, u_int32_t, __db_remove_reply *));
00486  */
00487 int
00488 __dbcl_db_remove_ret(dbp, name, subdb, flags, replyp)
00489         DB *dbp;
00490         const char *name, *subdb;
00491         u_int32_t flags;
00492         __db_remove_reply *replyp;
00493 {
00494         int ret;
00495 
00496         COMPQUIET(name, 0);
00497         COMPQUIET(subdb, 0);
00498         COMPQUIET(flags, 0);
00499 
00500         ret = __dbcl_dbclose_common(dbp);
00501 
00502         if (replyp->status != 0)
00503                 return (replyp->status);
00504         else
00505                 return (ret);
00506 }
00507 
00508 /*
00509  * PUBLIC: int __dbcl_db_rename_ret __P((DB *, const char *,
00510  * PUBLIC:     const char *, const char *, u_int32_t, __db_rename_reply *));
00511  */
00512 int
00513 __dbcl_db_rename_ret(dbp, name, subdb, newname, flags, replyp)
00514         DB *dbp;
00515         const char *name, *subdb, *newname;
00516         u_int32_t flags;
00517         __db_rename_reply *replyp;
00518 {
00519         int ret;
00520 
00521         COMPQUIET(name, 0);
00522         COMPQUIET(subdb, 0);
00523         COMPQUIET(newname, 0);
00524         COMPQUIET(flags, 0);
00525 
00526         ret = __dbcl_dbclose_common(dbp);
00527 
00528         if (replyp->status != 0)
00529                 return (replyp->status);
00530         else
00531                 return (ret);
00532 }
00533 
00534 /*
00535  * PUBLIC: int __dbcl_db_stat_ret
00536  * PUBLIC:     __P((DB *, DB_TXN *, void *, u_int32_t, __db_stat_reply *));
00537  */
00538 int
00539 __dbcl_db_stat_ret(dbp, txnp, sp, flags, replyp)
00540         DB *dbp;
00541         DB_TXN *txnp;
00542         void *sp;
00543         u_int32_t flags;
00544         __db_stat_reply *replyp;
00545 {
00546         size_t len;
00547         u_int32_t i, *q, *p, *retsp;
00548         int ret;
00549 
00550         COMPQUIET(flags, 0);
00551         COMPQUIET(txnp, NULL);
00552 
00553         if (replyp->status != 0 || sp == NULL)
00554                 return (replyp->status);
00555 
00556         len = replyp->stats.stats_len * sizeof(u_int32_t);
00557         if ((ret = __os_umalloc(dbp->dbenv, len, &retsp)) != 0)
00558                 return (ret);
00559         for (i = 0, q = retsp, p = (u_int32_t *)replyp->stats.stats_val;
00560             i < replyp->stats.stats_len; i++, q++, p++)
00561                 *q = *p;
00562         *(u_int32_t **)sp = retsp;
00563         return (0);
00564 }
00565 
00566 /*
00567  * PUBLIC: int __dbcl_db_truncate_ret __P((DB *, DB_TXN *, u_int32_t  *,
00568  * PUBLIC:      u_int32_t, __db_truncate_reply *));
00569  */
00570 int
00571 __dbcl_db_truncate_ret(dbp, txnp, countp, flags, replyp)
00572         DB *dbp;
00573         DB_TXN *txnp;
00574         u_int32_t *countp, flags;
00575         __db_truncate_reply *replyp;
00576 {
00577         COMPQUIET(dbp, NULL);
00578         COMPQUIET(txnp, NULL);
00579         COMPQUIET(flags, 0);
00580 
00581         if (replyp->status != 0)
00582                 return (replyp->status);
00583         *countp = replyp->count;
00584 
00585         return (replyp->status);
00586 }
00587 
00588 /*
00589  * PUBLIC: int __dbcl_db_cursor_ret
00590  * PUBLIC:     __P((DB *, DB_TXN *, DBC **, u_int32_t, __db_cursor_reply *));
00591  */
00592 int
00593 __dbcl_db_cursor_ret(dbp, txnp, dbcp, flags, replyp)
00594         DB *dbp;
00595         DB_TXN *txnp;
00596         DBC **dbcp;
00597         u_int32_t flags;
00598         __db_cursor_reply *replyp;
00599 {
00600         COMPQUIET(txnp, NULL);
00601         COMPQUIET(flags, 0);
00602 
00603         if (replyp->status != 0)
00604                 return (replyp->status);
00605 
00606         return (__dbcl_c_setup(replyp->dbcidcl_id, dbp, dbcp));
00607 }
00608 
00609 /*
00610  * PUBLIC: int __dbcl_db_join_ret
00611  * PUBLIC:     __P((DB *, DBC **, DBC **, u_int32_t, __db_join_reply *));
00612  */
00613 int
00614 __dbcl_db_join_ret(dbp, curs, dbcp, flags, replyp)
00615         DB *dbp;
00616         DBC **curs, **dbcp;
00617         u_int32_t flags;
00618         __db_join_reply *replyp;
00619 {
00620         COMPQUIET(curs, NULL);
00621         COMPQUIET(flags, 0);
00622 
00623         if (replyp->status != 0)
00624                 return (replyp->status);
00625 
00626         /*
00627          * We set this up as a normal cursor.  We do not need
00628          * to treat a join cursor any differently than a normal
00629          * cursor, even though DB itself must.  We only need the
00630          * client-side cursor/db relationship to know what cursors
00631          * are open in the db, and to store their ID.  Nothing else.
00632          */
00633         return (__dbcl_c_setup(replyp->dbcidcl_id, dbp, dbcp));
00634 }
00635 
00636 /*
00637  * PUBLIC: int __dbcl_dbc_c_close_ret __P((DBC *, __dbc_c_close_reply *));
00638  */
00639 int
00640 __dbcl_dbc_c_close_ret(dbc, replyp)
00641         DBC *dbc;
00642         __dbc_c_close_reply *replyp;
00643 {
00644         __dbcl_c_refresh(dbc);
00645         return (replyp->status);
00646 }
00647 
00648 /*
00649  * PUBLIC: int __dbcl_dbc_c_count_ret
00650  * PUBLIC:     __P((DBC *, db_recno_t *, u_int32_t, __dbc_c_count_reply *));
00651  */
00652 int
00653 __dbcl_dbc_c_count_ret(dbc, countp, flags, replyp)
00654         DBC *dbc;
00655         db_recno_t *countp;
00656         u_int32_t flags;
00657         __dbc_c_count_reply *replyp;
00658 {
00659         COMPQUIET(dbc, NULL);
00660         COMPQUIET(flags, 0);
00661 
00662         if (replyp->status != 0)
00663                 return (replyp->status);
00664         *countp = replyp->dupcount;
00665 
00666         return (replyp->status);
00667 }
00668 
00669 /*
00670  * PUBLIC: int __dbcl_dbc_c_dup_ret
00671  * PUBLIC:     __P((DBC *, DBC **, u_int32_t, __dbc_c_dup_reply *));
00672  */
00673 int
00674 __dbcl_dbc_c_dup_ret(dbc, dbcp, flags, replyp)
00675         DBC *dbc, **dbcp;
00676         u_int32_t flags;
00677         __dbc_c_dup_reply *replyp;
00678 {
00679         COMPQUIET(flags, 0);
00680 
00681         if (replyp->status != 0)
00682                 return (replyp->status);
00683 
00684         return (__dbcl_c_setup(replyp->dbcidcl_id, dbc->dbp, dbcp));
00685 }
00686 
00687 /*
00688  * PUBLIC: int __dbcl_dbc_c_get_ret
00689  * PUBLIC:     __P((DBC *, DBT *, DBT *, u_int32_t, __dbc_c_get_reply *));
00690  */
00691 int
00692 __dbcl_dbc_c_get_ret(dbc, key, data, flags, replyp)
00693         DBC *dbc;
00694         DBT *key, *data;
00695         u_int32_t flags;
00696         __dbc_c_get_reply *replyp;
00697 {
00698         DB_ENV *dbenv;
00699         int ret;
00700         void *oldkey;
00701 
00702         COMPQUIET(flags, 0);
00703 
00704         ret = 0;
00705         if (replyp->status != 0)
00706                 return (replyp->status);
00707 
00708         dbenv = dbc->dbp->dbenv;
00709         oldkey = key->data;
00710         ret = __dbcl_retcopy(dbenv, key, replyp->keydata.keydata_val,
00711             replyp->keydata.keydata_len, &dbc->my_rkey.data,
00712             &dbc->my_rkey.ulen);
00713         if (ret)
00714                 return (ret);
00715         ret = __dbcl_retcopy(dbenv, data, replyp->datadata.datadata_val,
00716             replyp->datadata.datadata_len, &dbc->my_rdata.data,
00717             &dbc->my_rdata.ulen);
00718 
00719         /*
00720          * If an error on copying 'data' and we allocated for 'key'
00721          * free it before returning the error.
00722          */
00723         if (ret)
00724                 FREE_IF_CHANGED(key, oldkey);
00725         return (ret);
00726 }
00727 
00728 /*
00729  * PUBLIC: int __dbcl_dbc_c_pget_ret __P((DBC *, DBT *, DBT *, DBT *, u_int32_t,
00730  * PUBLIC:      __dbc_c_pget_reply *));
00731  */
00732 int
00733 __dbcl_dbc_c_pget_ret(dbc, skey, pkey, data, flags, replyp)
00734         DBC * dbc;
00735         DBT * skey;
00736         DBT * pkey;
00737         DBT * data;
00738         u_int32_t flags;
00739         __dbc_c_pget_reply *replyp;
00740 {
00741         DB_ENV *dbenv;
00742         int ret;
00743         void *oldskey, *oldpkey;
00744 
00745         COMPQUIET(flags, 0);
00746 
00747         ret = 0;
00748         if (replyp->status != 0)
00749                 return (replyp->status);
00750 
00751         dbenv = dbc->dbp->dbenv;
00752 
00753         oldskey = skey->data;
00754         ret = __dbcl_retcopy(dbenv, skey, replyp->skeydata.skeydata_val,
00755             replyp->skeydata.skeydata_len, &dbc->my_rskey.data,
00756             &dbc->my_rskey.ulen);
00757         if (ret)
00758                 return (ret);
00759 
00760         oldpkey = pkey->data;
00761         if ((ret = __dbcl_retcopy(dbenv, pkey, replyp->pkeydata.pkeydata_val,
00762             replyp->pkeydata.pkeydata_len, &dbc->my_rkey.data,
00763             &dbc->my_rkey.ulen)) != 0)
00764                 goto err;
00765         ret = __dbcl_retcopy(dbenv, data, replyp->datadata.datadata_val,
00766             replyp->datadata.datadata_len, &dbc->my_rdata.data,
00767             &dbc->my_rdata.ulen);
00768 
00769         /*
00770          * If an error on copying 'data' and we allocated for '*key'
00771          * free it before returning the error.
00772          */
00773         if (ret) {
00774 err:            FREE_IF_CHANGED(skey, oldskey);
00775                 FREE_IF_CHANGED(pkey, oldpkey);
00776         }
00777         return (ret);
00778 }
00779 
00780 /*
00781  * PUBLIC: int __dbcl_dbc_c_put_ret
00782  * PUBLIC:     __P((DBC *, DBT *, DBT *, u_int32_t, __dbc_c_put_reply *));
00783  */
00784 int
00785 __dbcl_dbc_c_put_ret(dbc, key, data, flags, replyp)
00786         DBC *dbc;
00787         DBT *key, *data;
00788         u_int32_t flags;
00789         __dbc_c_put_reply *replyp;
00790 {
00791         COMPQUIET(data, NULL);
00792 
00793         if (replyp->status != 0)
00794                 return (replyp->status);
00795 
00796         if (replyp->status == 0 && dbc->dbp->type == DB_RECNO &&
00797             (flags == DB_AFTER || flags == DB_BEFORE))
00798                 *(db_recno_t *)key->data =
00799                     *(db_recno_t *)replyp->keydata.keydata_val;
00800         return (replyp->status);
00801 }

Generated on Sun Dec 25 12:14:46 2005 for Berkeley DB 4.4.16 by  doxygen 1.4.2