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

rep_auto.c

00001 /* Do not edit: automatically built by gen_rec.awk. */
00002 
00003 #include "db_config.h"
00004 
00005 #ifndef NO_SYSTEM_INCLUDES
00006 #include <stdlib.h>
00007 #include <string.h>
00008 #endif
00009 
00010 #include "db_int.h"
00011 #include "dbinc/db_page.h"
00012 #include "dbinc/db_shash.h"
00013 #include "dbinc/db_am.h"
00014 #include "dbinc/log.h"
00015 #include "dbinc/mp.h"
00016 #include "dbinc/txn.h"
00017 
00018 /*
00019  * PUBLIC: int __rep_update_buf __P((u_int8_t *, size_t, size_t *,
00020  * PUBLIC:     DB_LSN *, u_int32_t));
00021  */
00022 int
00023 __rep_update_buf(buf, max, lenp,
00024     first_lsn, num_files)
00025         u_int8_t *buf;
00026         size_t max, *lenp;
00027         DB_LSN * first_lsn;
00028         u_int32_t num_files;
00029 {
00030         u_int32_t uinttmp;
00031         u_int8_t *endbuf;
00032         u_int8_t *bp;
00033         int ret;
00034 
00035         ret = 0;
00036 
00037         bp = buf;
00038         endbuf = bp + max;
00039 
00040         if (bp + sizeof(*first_lsn) > endbuf)
00041                 return (ENOMEM);
00042         if (first_lsn != NULL)
00043                 memcpy(bp, first_lsn, sizeof(*first_lsn));
00044         else
00045                 memset(bp, 0, sizeof(*first_lsn));
00046         bp += sizeof(*first_lsn);
00047 
00048         uinttmp = (u_int32_t)num_files;
00049         if (bp + sizeof(uinttmp) > endbuf)
00050                 return (ENOMEM);
00051         memcpy(bp, &uinttmp, sizeof(uinttmp));
00052         bp += sizeof(uinttmp);
00053 
00054         *lenp = (u_int32_t)(bp - buf);
00055 
00056         return (ret);
00057 }
00058 
00059 /*
00060  * PUBLIC: int __rep_update_read __P((DB_ENV *, void *, void **,
00061  * PUBLIC:     __rep_update_args **));
00062  */
00063 int
00064 __rep_update_read(dbenv, recbuf, nextp, argpp)
00065         DB_ENV *dbenv;
00066         void *recbuf;
00067         void **nextp;
00068         __rep_update_args **argpp;
00069 {
00070         __rep_update_args *argp;
00071         u_int32_t uinttmp;
00072         u_int8_t *bp;
00073         int ret;
00074 
00075         if ((ret = __os_malloc(dbenv,
00076             sizeof(__rep_update_args), &argp)) != 0)
00077                 return (ret);
00078         bp = recbuf;
00079         memcpy(&argp->first_lsn, bp,  sizeof(argp->first_lsn));
00080         bp += sizeof(argp->first_lsn);
00081 
00082         memcpy(&uinttmp, bp, sizeof(uinttmp));
00083         argp->num_files = (u_int32_t)uinttmp;
00084         bp += sizeof(uinttmp);
00085 
00086         *nextp = bp;
00087         *argpp = argp;
00088         return (0);
00089 }
00090 
00091 /*
00092  * PUBLIC: int __rep_fileinfo_buf __P((u_int8_t *, size_t, size_t *,
00093  * PUBLIC:     u_int32_t, db_pgno_t, db_pgno_t, u_int32_t, int32_t, u_int32_t,
00094  * PUBLIC:     u_int32_t, const DBT *, const DBT *));
00095  */
00096 int
00097 __rep_fileinfo_buf(buf, max, lenp,
00098     pgsize, pgno, max_pgno, filenum, id, type,
00099     flags, uid, info)
00100         u_int8_t *buf;
00101         size_t max, *lenp;
00102         u_int32_t pgsize;
00103         db_pgno_t pgno;
00104         db_pgno_t max_pgno;
00105         u_int32_t filenum;
00106         int32_t id;
00107         u_int32_t type;
00108         u_int32_t flags;
00109         const DBT *uid;
00110         const DBT *info;
00111 {
00112         u_int32_t zero;
00113         u_int32_t uinttmp;
00114         u_int8_t *endbuf;
00115         u_int8_t *bp;
00116         int ret;
00117 
00118         ret = 0;
00119 
00120         bp = buf;
00121         endbuf = bp + max;
00122 
00123         uinttmp = (u_int32_t)pgsize;
00124         if (bp + sizeof(uinttmp) > endbuf)
00125                 return (ENOMEM);
00126         memcpy(bp, &uinttmp, sizeof(uinttmp));
00127         bp += sizeof(uinttmp);
00128 
00129         uinttmp = (u_int32_t)pgno;
00130         if (bp + sizeof(uinttmp) > endbuf)
00131                 return (ENOMEM);
00132         memcpy(bp, &uinttmp, sizeof(uinttmp));
00133         bp += sizeof(uinttmp);
00134 
00135         uinttmp = (u_int32_t)max_pgno;
00136         if (bp + sizeof(uinttmp) > endbuf)
00137                 return (ENOMEM);
00138         memcpy(bp, &uinttmp, sizeof(uinttmp));
00139         bp += sizeof(uinttmp);
00140 
00141         uinttmp = (u_int32_t)filenum;
00142         if (bp + sizeof(uinttmp) > endbuf)
00143                 return (ENOMEM);
00144         memcpy(bp, &uinttmp, sizeof(uinttmp));
00145         bp += sizeof(uinttmp);
00146 
00147         uinttmp = (u_int32_t)id;
00148         if (bp + sizeof(uinttmp) > endbuf)
00149                 return (ENOMEM);
00150         memcpy(bp, &uinttmp, sizeof(uinttmp));
00151         bp += sizeof(uinttmp);
00152 
00153         uinttmp = (u_int32_t)type;
00154         if (bp + sizeof(uinttmp) > endbuf)
00155                 return (ENOMEM);
00156         memcpy(bp, &uinttmp, sizeof(uinttmp));
00157         bp += sizeof(uinttmp);
00158 
00159         uinttmp = (u_int32_t)flags;
00160         if (bp + sizeof(uinttmp) > endbuf)
00161                 return (ENOMEM);
00162         memcpy(bp, &uinttmp, sizeof(uinttmp));
00163         bp += sizeof(uinttmp);
00164 
00165         if (uid == NULL) {
00166                 zero = 0;
00167                 if (bp + sizeof(u_int32_t) > endbuf)
00168                         return (ENOMEM);
00169                 memcpy(bp, &zero, sizeof(u_int32_t));
00170                 bp += sizeof(u_int32_t);
00171         } else {
00172                 if (bp + sizeof(uid->size) > endbuf)
00173                         return (ENOMEM);
00174                 memcpy(bp, &uid->size, sizeof(uid->size));
00175                 bp += sizeof(uid->size);
00176                 if (bp + uid->size > endbuf)
00177                         return (ENOMEM);
00178                 memcpy(bp, uid->data, uid->size);
00179                 bp += uid->size;
00180         }
00181 
00182         if (info == NULL) {
00183                 zero = 0;
00184                 if (bp + sizeof(u_int32_t) > endbuf)
00185                         return (ENOMEM);
00186                 memcpy(bp, &zero, sizeof(u_int32_t));
00187                 bp += sizeof(u_int32_t);
00188         } else {
00189                 if (bp + sizeof(info->size) > endbuf)
00190                         return (ENOMEM);
00191                 memcpy(bp, &info->size, sizeof(info->size));
00192                 bp += sizeof(info->size);
00193                 if (bp + info->size > endbuf)
00194                         return (ENOMEM);
00195                 memcpy(bp, info->data, info->size);
00196                 bp += info->size;
00197         }
00198 
00199         *lenp = (u_int32_t)(bp - buf);
00200 
00201         return (ret);
00202 }
00203 
00204 /*
00205  * PUBLIC: int __rep_fileinfo_read __P((DB_ENV *, void *, void **,
00206  * PUBLIC:     __rep_fileinfo_args **));
00207  */
00208 int
00209 __rep_fileinfo_read(dbenv, recbuf, nextp, argpp)
00210         DB_ENV *dbenv;
00211         void *recbuf;
00212         void **nextp;
00213         __rep_fileinfo_args **argpp;
00214 {
00215         __rep_fileinfo_args *argp;
00216         u_int32_t uinttmp;
00217         u_int8_t *bp;
00218         int ret;
00219 
00220         if ((ret = __os_malloc(dbenv,
00221             sizeof(__rep_fileinfo_args), &argp)) != 0)
00222                 return (ret);
00223         bp = recbuf;
00224         memcpy(&uinttmp, bp, sizeof(uinttmp));
00225         argp->pgsize = (u_int32_t)uinttmp;
00226         bp += sizeof(uinttmp);
00227 
00228         memcpy(&uinttmp, bp, sizeof(uinttmp));
00229         argp->pgno = (db_pgno_t)uinttmp;
00230         bp += sizeof(uinttmp);
00231 
00232         memcpy(&uinttmp, bp, sizeof(uinttmp));
00233         argp->max_pgno = (db_pgno_t)uinttmp;
00234         bp += sizeof(uinttmp);
00235 
00236         memcpy(&uinttmp, bp, sizeof(uinttmp));
00237         argp->filenum = (u_int32_t)uinttmp;
00238         bp += sizeof(uinttmp);
00239 
00240         memcpy(&uinttmp, bp, sizeof(uinttmp));
00241         argp->id = (int32_t)uinttmp;
00242         bp += sizeof(uinttmp);
00243 
00244         memcpy(&uinttmp, bp, sizeof(uinttmp));
00245         argp->type = (u_int32_t)uinttmp;
00246         bp += sizeof(uinttmp);
00247 
00248         memcpy(&uinttmp, bp, sizeof(uinttmp));
00249         argp->flags = (u_int32_t)uinttmp;
00250         bp += sizeof(uinttmp);
00251 
00252         memset(&argp->uid, 0, sizeof(argp->uid));
00253         memcpy(&argp->uid.size, bp, sizeof(u_int32_t));
00254         bp += sizeof(u_int32_t);
00255         argp->uid.data = bp;
00256         bp += argp->uid.size;
00257 
00258         memset(&argp->info, 0, sizeof(argp->info));
00259         memcpy(&argp->info.size, bp, sizeof(u_int32_t));
00260         bp += sizeof(u_int32_t);
00261         argp->info.data = bp;
00262         bp += argp->info.size;
00263 
00264         *nextp = bp;
00265         *argpp = argp;
00266         return (0);
00267 }
00268 

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