Update.
[glibc.git] / db2 / log / log_auto.c
blobb17b1ffb2f4bb9514ae9c9a88b4ec61023d32507
1 /* Do not edit: automatically built by dist/db_gen.sh. */
2 #include "config.h"
4 #ifndef NO_SYSTEM_INCLUDES
5 #include <ctype.h>
6 #include <errno.h>
7 #include <stddef.h>
8 #include <stdlib.h>
9 #include <string.h>
10 #endif
12 #include "db_int.h"
13 #include "shqueue.h"
14 #include "db_page.h"
15 #include "db_dispatch.h"
16 #include "log.h"
17 #include "db_am.h"
19 * PUBLIC: int __log_register_log
20 * PUBLIC: __P((DB_LOG *, DB_TXN *, DB_LSN *, u_int32_t,
21 * PUBLIC: u_int32_t, const DBT *, const DBT *, u_int32_t,
22 * PUBLIC: DBTYPE));
24 int __log_register_log(logp, txnid, ret_lsnp, flags,
25 opcode, name, uid, id, ftype)
26 DB_LOG *logp;
27 DB_TXN *txnid;
28 DB_LSN *ret_lsnp;
29 u_int32_t flags;
30 u_int32_t opcode;
31 const DBT *name;
32 const DBT *uid;
33 u_int32_t id;
34 DBTYPE ftype;
36 DBT logrec;
37 DB_LSN *lsnp, null_lsn;
38 u_int32_t zero;
39 u_int32_t rectype, txn_num;
40 int ret;
41 u_int8_t *bp;
43 rectype = DB_log_register;
44 txn_num = txnid == NULL ? 0 : txnid->txnid;
45 if (txnid == NULL) {
46 null_lsn.file = 0;
47 null_lsn.offset = 0;
48 lsnp = &null_lsn;
49 } else
50 lsnp = &txnid->last_lsn;
51 logrec.size = sizeof(rectype) + sizeof(txn_num) + sizeof(DB_LSN)
52 + sizeof(opcode)
53 + sizeof(u_int32_t) + (name == NULL ? 0 : name->size)
54 + sizeof(u_int32_t) + (uid == NULL ? 0 : uid->size)
55 + sizeof(id)
56 + sizeof(ftype);
57 if ((logrec.data = (void *)__db_malloc(logrec.size)) == NULL)
58 return (ENOMEM);
60 bp = logrec.data;
61 memcpy(bp, &rectype, sizeof(rectype));
62 bp += sizeof(rectype);
63 memcpy(bp, &txn_num, sizeof(txn_num));
64 bp += sizeof(txn_num);
65 memcpy(bp, lsnp, sizeof(DB_LSN));
66 bp += sizeof(DB_LSN);
67 memcpy(bp, &opcode, sizeof(opcode));
68 bp += sizeof(opcode);
69 if (name == NULL) {
70 zero = 0;
71 memcpy(bp, &zero, sizeof(u_int32_t));
72 bp += sizeof(u_int32_t);
73 } else {
74 memcpy(bp, &name->size, sizeof(name->size));
75 bp += sizeof(name->size);
76 memcpy(bp, name->data, name->size);
77 bp += name->size;
79 if (uid == NULL) {
80 zero = 0;
81 memcpy(bp, &zero, sizeof(u_int32_t));
82 bp += sizeof(u_int32_t);
83 } else {
84 memcpy(bp, &uid->size, sizeof(uid->size));
85 bp += sizeof(uid->size);
86 memcpy(bp, uid->data, uid->size);
87 bp += uid->size;
89 memcpy(bp, &id, sizeof(id));
90 bp += sizeof(id);
91 memcpy(bp, &ftype, sizeof(ftype));
92 bp += sizeof(ftype);
93 #ifdef DIAGNOSTIC
94 if ((u_int32_t)(bp - (u_int8_t *)logrec.data) != logrec.size)
95 fprintf(stderr, "Error in log record length");
96 #endif
97 ret = __log_put(logp, ret_lsnp, (DBT *)&logrec, flags);
98 if (txnid != NULL)
99 txnid->last_lsn = *ret_lsnp;
100 __db_free(logrec.data);
101 return (ret);
105 * PUBLIC: int __log_register_print
106 * PUBLIC: __P((DB_LOG *, DBT *, DB_LSN *, int, void *));
109 __log_register_print(notused1, dbtp, lsnp, notused2, notused3)
110 DB_LOG *notused1;
111 DBT *dbtp;
112 DB_LSN *lsnp;
113 int notused2;
114 void *notused3;
116 __log_register_args *argp;
117 u_int32_t i;
118 u_int ch;
119 int ret;
121 i = 0;
122 ch = 0;
123 notused1 = NULL;
124 notused2 = 0;
125 notused3 = NULL;
127 if ((ret = __log_register_read(dbtp->data, &argp)) != 0)
128 return (ret);
129 printf("[%lu][%lu]log_register: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
130 (u_long)lsnp->file,
131 (u_long)lsnp->offset,
132 (u_long)argp->type,
133 (u_long)argp->txnid->txnid,
134 (u_long)argp->prev_lsn.file,
135 (u_long)argp->prev_lsn.offset);
136 printf("\topcode: %lu\n", (u_long)argp->opcode);
137 printf("\tname: ");
138 for (i = 0; i < argp->name.size; i++) {
139 ch = ((u_int8_t *)argp->name.data)[i];
140 if (isprint(ch) || ch == 0xa)
141 putchar(ch);
142 else
143 printf("%#x ", ch);
145 printf("\n");
146 printf("\tuid: ");
147 for (i = 0; i < argp->uid.size; i++) {
148 ch = ((u_int8_t *)argp->uid.data)[i];
149 if (isprint(ch) || ch == 0xa)
150 putchar(ch);
151 else
152 printf("%#x ", ch);
154 printf("\n");
155 printf("\tid: %lu\n", (u_long)argp->id);
156 printf("\tftype: 0x%lx\n", (u_long)argp->ftype);
157 printf("\n");
158 __db_free(argp);
159 return (0);
163 * PUBLIC: int __log_register_read __P((void *, __log_register_args **));
166 __log_register_read(recbuf, argpp)
167 void *recbuf;
168 __log_register_args **argpp;
170 __log_register_args *argp;
171 u_int8_t *bp;
173 argp = (__log_register_args *)__db_malloc(sizeof(__log_register_args) +
174 sizeof(DB_TXN));
175 if (argp == NULL)
176 return (ENOMEM);
177 argp->txnid = (DB_TXN *)&argp[1];
178 bp = recbuf;
179 memcpy(&argp->type, bp, sizeof(argp->type));
180 bp += sizeof(argp->type);
181 memcpy(&argp->txnid->txnid, bp, sizeof(argp->txnid->txnid));
182 bp += sizeof(argp->txnid->txnid);
183 memcpy(&argp->prev_lsn, bp, sizeof(DB_LSN));
184 bp += sizeof(DB_LSN);
185 memcpy(&argp->opcode, bp, sizeof(argp->opcode));
186 bp += sizeof(argp->opcode);
187 memcpy(&argp->name.size, bp, sizeof(u_int32_t));
188 bp += sizeof(u_int32_t);
189 argp->name.data = bp;
190 bp += argp->name.size;
191 memcpy(&argp->uid.size, bp, sizeof(u_int32_t));
192 bp += sizeof(u_int32_t);
193 argp->uid.data = bp;
194 bp += argp->uid.size;
195 memcpy(&argp->id, bp, sizeof(argp->id));
196 bp += sizeof(argp->id);
197 memcpy(&argp->ftype, bp, sizeof(argp->ftype));
198 bp += sizeof(argp->ftype);
199 *argpp = argp;
200 return (0);
204 * PUBLIC: int __log_init_print __P((DB_ENV *));
207 __log_init_print(dbenv)
208 DB_ENV *dbenv;
210 int ret;
212 if ((ret = __db_add_recovery(dbenv,
213 __log_register_print, DB_log_register)) != 0)
214 return (ret);
215 return (0);
219 * PUBLIC: int __log_init_recover __P((DB_ENV *));
222 __log_init_recover(dbenv)
223 DB_ENV *dbenv;
225 int ret;
227 if ((ret = __db_add_recovery(dbenv,
228 __log_register_recover, DB_log_register)) != 0)
229 return (ret);
230 return (0);