1 /* Do not edit: automatically built by dist/db_gen.sh. */
4 #ifndef NO_SYSTEM_INCLUDES
15 #include "db_dispatch.h"
18 #include "common_ext.h"
21 * PUBLIC: int __log_register_log
22 * PUBLIC: __P((DB_LOG *, DB_TXN *, DB_LSN *, u_int32_t,
23 * PUBLIC: DBT *, DBT *, u_int32_t, DBTYPE));
25 int __log_register_log(logp, txnid, ret_lsnp, flags,
37 DB_LSN *lsnp, null_lsn;
39 u_int32_t rectype, txn_num;
43 rectype = DB_log_register;
44 txn_num = txnid == NULL ? 0 : txnid->txnid;
50 lsnp = &txnid->last_lsn;
51 logrec.size = sizeof(rectype) + sizeof(txn_num) + sizeof(DB_LSN)
52 + sizeof(u_int32_t) + (name == NULL ? 0 : name->size)
53 + sizeof(u_int32_t) + (uid == NULL ? 0 : uid->size)
56 if ((logrec.data = (void *)__db_malloc(logrec.size)) == NULL)
60 memcpy(bp, &rectype, sizeof(rectype));
61 bp += sizeof(rectype);
62 memcpy(bp, &txn_num, sizeof(txn_num));
63 bp += sizeof(txn_num);
64 memcpy(bp, lsnp, sizeof(DB_LSN));
68 memcpy(bp, &zero, sizeof(u_int32_t));
69 bp += sizeof(u_int32_t);
71 memcpy(bp, &name->size, sizeof(name->size));
72 bp += sizeof(name->size);
73 memcpy(bp, name->data, name->size);
78 memcpy(bp, &zero, sizeof(u_int32_t));
79 bp += sizeof(u_int32_t);
81 memcpy(bp, &uid->size, sizeof(uid->size));
82 bp += sizeof(uid->size);
83 memcpy(bp, uid->data, uid->size);
86 memcpy(bp, &id, sizeof(id));
88 memcpy(bp, &ftype, sizeof(ftype));
91 if ((u_int32_t)(bp - (u_int8_t *)logrec.data) != logrec.size)
92 fprintf(stderr, "Error in log record length");
94 ret = __log_put(logp, ret_lsnp, (DBT *)&logrec, flags);
96 txnid->last_lsn = *ret_lsnp;
97 __db_free(logrec.data);
102 * PUBLIC: int __log_register_print
103 * PUBLIC: __P((DB_LOG *, DBT *, DB_LSN *, int, void *));
107 __log_register_print(notused1, dbtp, lsnp, notused3, notused4)
114 __log_register_args *argp;
124 if ((ret = __log_register_read(dbtp->data, &argp)) != 0)
126 printf("[%lu][%lu]log_register: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
128 (u_long)lsnp->offset,
130 (u_long)argp->txnid->txnid,
131 (u_long)argp->prev_lsn.file,
132 (u_long)argp->prev_lsn.offset);
134 for (i = 0; i < argp->name.size; i++) {
135 c = ((char *)argp->name.data)[i];
136 if (isprint(c) || c == 0xa)
143 for (i = 0; i < argp->uid.size; i++) {
144 c = ((char *)argp->uid.data)[i];
145 if (isprint(c) || c == 0xa)
151 printf("\tid: %lu\n", (u_long)argp->id);
152 printf("\tftype: 0x%lx\n", (u_long)argp->ftype);
159 * PUBLIC: int __log_register_read __P((void *, __log_register_args **));
162 __log_register_read(recbuf, argpp)
164 __log_register_args **argpp;
166 __log_register_args *argp;
169 argp = (__log_register_args *)__db_malloc(sizeof(__log_register_args) +
173 argp->txnid = (DB_TXN *)&argp[1];
175 memcpy(&argp->type, bp, sizeof(argp->type));
176 bp += sizeof(argp->type);
177 memcpy(&argp->txnid->txnid, bp, sizeof(argp->txnid->txnid));
178 bp += sizeof(argp->txnid->txnid);
179 memcpy(&argp->prev_lsn, bp, sizeof(DB_LSN));
180 bp += sizeof(DB_LSN);
181 memcpy(&argp->name.size, bp, sizeof(u_int32_t));
182 bp += sizeof(u_int32_t);
183 argp->name.data = bp;
184 bp += argp->name.size;
185 memcpy(&argp->uid.size, bp, sizeof(u_int32_t));
186 bp += sizeof(u_int32_t);
188 bp += argp->uid.size;
189 memcpy(&argp->id, bp, sizeof(argp->id));
190 bp += sizeof(argp->id);
191 memcpy(&argp->ftype, bp, sizeof(argp->ftype));
192 bp += sizeof(argp->ftype);
198 * PUBLIC: int __log_unregister_log
199 * PUBLIC: __P((DB_LOG *, DB_TXN *, DB_LSN *, u_int32_t,
200 * PUBLIC: u_int32_t));
202 int __log_unregister_log(logp, txnid, ret_lsnp, flags,
211 DB_LSN *lsnp, null_lsn;
212 u_int32_t rectype, txn_num;
216 rectype = DB_log_unregister;
217 txn_num = txnid == NULL ? 0 : txnid->txnid;
223 lsnp = &txnid->last_lsn;
224 logrec.size = sizeof(rectype) + sizeof(txn_num) + sizeof(DB_LSN)
226 if ((logrec.data = (void *)__db_malloc(logrec.size)) == NULL)
230 memcpy(bp, &rectype, sizeof(rectype));
231 bp += sizeof(rectype);
232 memcpy(bp, &txn_num, sizeof(txn_num));
233 bp += sizeof(txn_num);
234 memcpy(bp, lsnp, sizeof(DB_LSN));
235 bp += sizeof(DB_LSN);
236 memcpy(bp, &id, sizeof(id));
239 if ((u_int32_t)(bp - (u_int8_t *)logrec.data) != logrec.size)
240 fprintf(stderr, "Error in log record length");
242 ret = __log_put(logp, ret_lsnp, (DBT *)&logrec, flags);
244 txnid->last_lsn = *ret_lsnp;
245 __db_free(logrec.data);
250 * PUBLIC: int __log_unregister_print
251 * PUBLIC: __P((DB_LOG *, DBT *, DB_LSN *, int, void *));
255 __log_unregister_print(notused1, dbtp, lsnp, notused3, notused4)
262 __log_unregister_args *argp;
272 if ((ret = __log_unregister_read(dbtp->data, &argp)) != 0)
274 printf("[%lu][%lu]log_unregister: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
276 (u_long)lsnp->offset,
278 (u_long)argp->txnid->txnid,
279 (u_long)argp->prev_lsn.file,
280 (u_long)argp->prev_lsn.offset);
281 printf("\tid: %lu\n", (u_long)argp->id);
288 * PUBLIC: int __log_unregister_read __P((void *, __log_unregister_args **));
291 __log_unregister_read(recbuf, argpp)
293 __log_unregister_args **argpp;
295 __log_unregister_args *argp;
298 argp = (__log_unregister_args *)__db_malloc(sizeof(__log_unregister_args) +
302 argp->txnid = (DB_TXN *)&argp[1];
304 memcpy(&argp->type, bp, sizeof(argp->type));
305 bp += sizeof(argp->type);
306 memcpy(&argp->txnid->txnid, bp, sizeof(argp->txnid->txnid));
307 bp += sizeof(argp->txnid->txnid);
308 memcpy(&argp->prev_lsn, bp, sizeof(DB_LSN));
309 bp += sizeof(DB_LSN);
310 memcpy(&argp->id, bp, sizeof(argp->id));
311 bp += sizeof(argp->id);
317 * PUBLIC: int __log_init_print __P((DB_ENV *));
320 __log_init_print(dbenv)
325 if ((ret = __db_add_recovery(dbenv,
326 __log_register_print, DB_log_register)) != 0)
328 if ((ret = __db_add_recovery(dbenv,
329 __log_unregister_print, DB_log_unregister)) != 0)
335 * PUBLIC: int __log_init_recover __P((DB_ENV *));
338 __log_init_recover(dbenv)
343 if ((ret = __db_add_recovery(dbenv,
344 __log_register_recover, DB_log_register)) != 0)
346 if ((ret = __db_add_recovery(dbenv,
347 __log_unregister_recover, DB_log_unregister)) != 0)