1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
|
/*-
* See the file LICENSE for redistribution information.
*
* Copyright (c) 1999-2009 Oracle. All rights reserved.
*
* $Id$
*/
#include "db_config.h"
#include "db_int.h"
#ifdef HAVE_SYSTEM_INCLUDE_FILES
#include <tcl.h>
#endif
#include "dbinc/log.h"
#include "dbinc/tcl_db.h"
#ifdef CONFIG_TEST
static int tcl_LogcGet __P((Tcl_Interp *, int, Tcl_Obj * CONST*, DB_LOGC *));
/*
* tcl_LogArchive --
*
* PUBLIC: int tcl_LogArchive __P((Tcl_Interp *, int,
* PUBLIC: Tcl_Obj * CONST*, DB_ENV *));
*/
int
tcl_LogArchive(interp, objc, objv, dbenv)
Tcl_Interp *interp; /* Interpreter */
int objc; /* How many arguments? */
Tcl_Obj *CONST objv[]; /* The argument objects */
DB_ENV *dbenv; /* Environment pointer */
{
static const char *archopts[] = {
"-arch_abs", "-arch_data", "-arch_log", "-arch_remove",
NULL
};
enum archopts {
ARCH_ABS, ARCH_DATA, ARCH_LOG, ARCH_REMOVE
};
Tcl_Obj *fileobj, *res;
u_int32_t flag;
int i, optindex, result, ret;
char **file, **list;
result = TCL_OK;
flag = 0;
/*
* Get the flag index from the object based on the options
* defined above.
*/
i = 2;
while (i < objc) {
if (Tcl_GetIndexFromObj(interp, objv[i],
archopts, "option", TCL_EXACT, &optindex) != TCL_OK)
return (IS_HELP(objv[i]));
i++;
switch ((enum archopts)optindex) {
case ARCH_ABS:
flag |= DB_ARCH_ABS;
break;
case ARCH_DATA:
flag |= DB_ARCH_DATA;
break;
case ARCH_LOG:
flag |= DB_ARCH_LOG;
break;
case ARCH_REMOVE:
flag |= DB_ARCH_REMOVE;
break;
}
}
_debug_check();
list = NULL;
ret = dbenv->log_archive(dbenv, &list, flag);
result = _ReturnSetup(interp, ret, DB_RETOK_STD(ret), "log archive");
if (result == TCL_OK) {
res = Tcl_NewListObj(0, NULL);
for (file = list; file != NULL && *file != NULL; file++) {
fileobj = NewStringObj(*file, strlen(*file));
result = Tcl_ListObjAppendElement(interp, res, fileobj);
if (result != TCL_OK)
break;
}
Tcl_SetObjResult(interp, res);
}
if (list != NULL)
__os_ufree(dbenv->env, list);
return (result);
}
/*
* tcl_LogCompare --
*
* PUBLIC: int tcl_LogCompare __P((Tcl_Interp *, int,
* PUBLIC: Tcl_Obj * CONST*));
*/
int
tcl_LogCompare(interp, objc, objv)
Tcl_Interp *interp; /* Interpreter */
int objc; /* How many arguments? */
Tcl_Obj *CONST objv[]; /* The argument objects */
{
DB_LSN lsn0, lsn1;
Tcl_Obj *res;
int result, ret;
result = TCL_OK;
/*
* No flags, must be 4 args.
*/
if (objc != 4) {
Tcl_WrongNumArgs(interp, 2, objv, "lsn1 lsn2");
return (TCL_ERROR);
}
result = _GetLsn(interp, objv[2], &lsn0);
if (result == TCL_ERROR)
return (result);
result = _GetLsn(interp, objv[3], &lsn1);
if (result == TCL_ERROR)
return (result);
_debug_check();
ret = log_compare(&lsn0, &lsn1);
res = Tcl_NewIntObj(ret);
Tcl_SetObjResult(interp, res);
return (result);
}
/*
* tcl_LogFile --
*
* PUBLIC: int tcl_LogFile __P((Tcl_Interp *, int,
* PUBLIC: Tcl_Obj * CONST*, DB_ENV *));
*/
int
tcl_LogFile(interp, objc, objv, dbenv)
Tcl_Interp *interp; /* Interpreter */
int objc; /* How many arguments? */
Tcl_Obj *CONST objv[]; /* The argument objects */
DB_ENV *dbenv; /* Environment pointer */
{
DB_LSN lsn;
Tcl_Obj *res;
size_t len;
int result, ret;
char *name;
result = TCL_OK;
/*
* No flags, must be 3 args.
*/
if (objc != 3) {
Tcl_WrongNumArgs(interp, 2, objv, "lsn");
return (TCL_ERROR);
}
result = _GetLsn(interp, objv[2], &lsn);
if (result == TCL_ERROR)
return (result);
len = MSG_SIZE;
ret = ENOMEM;
name = NULL;
while (ret == ENOMEM) {
if (name != NULL)
__os_free(dbenv->env, name);
ret = __os_malloc(dbenv->env, len, &name);
if (ret != 0) {
Tcl_SetResult(interp, db_strerror(ret), TCL_STATIC);
break;
}
_debug_check();
ret = dbenv->log_file(dbenv, &lsn, name, len);
len *= 2;
}
result = _ReturnSetup(interp, ret, DB_RETOK_STD(ret), "log_file");
if (ret == 0) {
res = NewStringObj(name, strlen(name));
Tcl_SetObjResult(interp, res);
}
if (name != NULL)
__os_free(dbenv->env, name);
return (result);
}
/*
* tcl_LogFlush --
*
* PUBLIC: int tcl_LogFlush __P((Tcl_Interp *, int,
* PUBLIC: Tcl_Obj * CONST*, DB_ENV *));
*/
int
tcl_LogFlush(interp, objc, objv, dbenv)
Tcl_Interp *interp; /* Interpreter */
int objc; /* How many arguments? */
Tcl_Obj *CONST objv[]; /* The argument objects */
DB_ENV *dbenv; /* Environment pointer */
{
DB_LSN lsn, *lsnp;
int result, ret;
result = TCL_OK;
/*
* No flags, must be 2 or 3 args.
*/
if (objc > 3) {
Tcl_WrongNumArgs(interp, 2, objv, "?lsn?");
return (TCL_ERROR);
}
if (objc == 3) {
lsnp = &lsn;
result = _GetLsn(interp, objv[2], &lsn);
if (result == TCL_ERROR)
return (result);
} else
lsnp = NULL;
_debug_check();
ret = dbenv->log_flush(dbenv, lsnp);
result = _ReturnSetup(interp, ret, DB_RETOK_STD(ret), "log_flush");
return (result);
}
/*
* tcl_LogGet --
*
* PUBLIC: int tcl_LogGet __P((Tcl_Interp *, int,
* PUBLIC: Tcl_Obj * CONST*, DB_ENV *));
*/
int
tcl_LogGet(interp, objc, objv, dbenv)
Tcl_Interp *interp; /* Interpreter */
int objc; /* How many arguments? */
Tcl_Obj *CONST objv[]; /* The argument objects */
DB_ENV *dbenv; /* Environment pointer */
{
COMPQUIET(objv, NULL);
COMPQUIET(objc, 0);
COMPQUIET(dbenv, NULL);
Tcl_SetResult(interp, "FAIL: log_get deprecated\n", TCL_STATIC);
return (TCL_ERROR);
}
/*
* tcl_LogPut --
*
* PUBLIC: int tcl_LogPut __P((Tcl_Interp *, int,
* PUBLIC: Tcl_Obj * CONST*, DB_ENV *));
*/
int
tcl_LogPut(interp, objc, objv, dbenv)
Tcl_Interp *interp; /* Interpreter */
int objc; /* How many arguments? */
Tcl_Obj *CONST objv[]; /* The argument objects */
DB_ENV *dbenv; /* Environment pointer */
{
static const char *logputopts[] = {
"-flush",
NULL
};
enum logputopts {
LOGPUT_FLUSH
};
DB_LSN lsn;
DBT data;
Tcl_Obj *intobj, *res;
void *dtmp;
u_int32_t flag;
int freedata, optindex, result, ret;
result = TCL_OK;
flag = 0;
freedata = 0;
if (objc < 3) {
Tcl_WrongNumArgs(interp, 2, objv, "?-args? record");
return (TCL_ERROR);
}
/*
* Data/record must be the last arg.
*/
memset(&data, 0, sizeof(data));
ret = _CopyObjBytes(interp, objv[objc-1], &dtmp,
&data.size, &freedata);
if (ret != 0) {
result = _ReturnSetup(interp, ret,
DB_RETOK_STD(ret), "log put");
return (result);
}
data.data = dtmp;
/*
* Get the command name index from the object based on the options
* defined above.
*/
if (objc == 4) {
if (Tcl_GetIndexFromObj(interp, objv[2],
logputopts, "option", TCL_EXACT, &optindex) != TCL_OK) {
return (IS_HELP(objv[2]));
}
switch ((enum logputopts)optindex) {
case LOGPUT_FLUSH:
flag = DB_FLUSH;
break;
}
}
if (result == TCL_ERROR)
return (result);
_debug_check();
ret = dbenv->log_put(dbenv, &lsn, &data, flag);
result = _ReturnSetup(interp, ret, DB_RETOK_STD(ret), "log_put");
if (result == TCL_ERROR)
return (result);
res = Tcl_NewListObj(0, NULL);
intobj = Tcl_NewWideIntObj((Tcl_WideInt)lsn.file);
result = Tcl_ListObjAppendElement(interp, res, intobj);
intobj = Tcl_NewWideIntObj((Tcl_WideInt)lsn.offset);
result = Tcl_ListObjAppendElement(interp, res, intobj);
Tcl_SetObjResult(interp, res);
if (freedata)
__os_free(NULL, dtmp);
return (result);
}
/*
* tcl_LogStat --
*
* PUBLIC: int tcl_LogStat __P((Tcl_Interp *, int,
* PUBLIC: Tcl_Obj * CONST*, DB_ENV *));
*/
int
tcl_LogStat(interp, objc, objv, dbenv)
Tcl_Interp *interp; /* Interpreter */
int objc; /* How many arguments? */
Tcl_Obj *CONST objv[]; /* The argument objects */
DB_ENV *dbenv; /* Environment pointer */
{
DB_LOG_STAT *sp;
Tcl_Obj *res;
int result, ret;
result = TCL_OK;
/*
* No args for this. Error if there are some.
*/
if (objc != 2) {
Tcl_WrongNumArgs(interp, 2, objv, NULL);
return (TCL_ERROR);
}
_debug_check();
ret = dbenv->log_stat(dbenv, &sp, 0);
result = _ReturnSetup(interp, ret, DB_RETOK_STD(ret), "log stat");
if (result == TCL_ERROR)
return (result);
/*
* Have our stats, now construct the name value
* list pairs and free up the memory.
*/
res = Tcl_NewObj();
/*
* MAKE_STAT_LIST assumes 'res' and 'error' label.
*/
#ifdef HAVE_STATISTICS
MAKE_STAT_LIST("Magic", sp->st_magic);
MAKE_STAT_LIST("Log file Version", sp->st_version);
MAKE_STAT_LIST("Region size", sp->st_regsize);
MAKE_STAT_LIST("Log file mode", sp->st_mode);
MAKE_STAT_LIST("Log record cache size", sp->st_lg_bsize);
MAKE_STAT_LIST("Current log file size", sp->st_lg_size);
MAKE_WSTAT_LIST("Log file records written", sp->st_record);
MAKE_STAT_LIST("Mbytes written", sp->st_w_mbytes);
MAKE_STAT_LIST("Bytes written (over Mb)", sp->st_w_bytes);
MAKE_STAT_LIST("Mbytes written since checkpoint", sp->st_wc_mbytes);
MAKE_STAT_LIST("Bytes written (over Mb) since checkpoint",
sp->st_wc_bytes);
MAKE_WSTAT_LIST("Times log written", sp->st_wcount);
MAKE_STAT_LIST("Times log written because cache filled up",
sp->st_wcount_fill);
MAKE_WSTAT_LIST("Times log read from disk", sp->st_rcount);
MAKE_WSTAT_LIST("Times log flushed to disk", sp->st_scount);
MAKE_STAT_LIST("Current log file number", sp->st_cur_file);
MAKE_STAT_LIST("Current log file offset", sp->st_cur_offset);
MAKE_STAT_LIST("On-disk log file number", sp->st_disk_file);
MAKE_STAT_LIST("On-disk log file offset", sp->st_disk_offset);
MAKE_STAT_LIST("Max commits in a log flush", sp->st_maxcommitperflush);
MAKE_STAT_LIST("Min commits in a log flush", sp->st_mincommitperflush);
MAKE_WSTAT_LIST("Number of region lock waits", sp->st_region_wait);
MAKE_WSTAT_LIST("Number of region lock nowaits", sp->st_region_nowait);
#endif
Tcl_SetObjResult(interp, res);
error:
__os_ufree(dbenv->env, sp);
return (result);
}
/*
* logc_Cmd --
* Implements the log cursor command.
*
* PUBLIC: int logc_Cmd __P((ClientData, Tcl_Interp *, int, Tcl_Obj * CONST*));
*/
int
logc_Cmd(clientData, interp, objc, objv)
ClientData clientData; /* Cursor handle */
Tcl_Interp *interp; /* Interpreter */
int objc; /* How many arguments? */
Tcl_Obj *CONST objv[]; /* The argument objects */
{
static const char *logccmds[] = {
"close",
"get",
"version",
NULL
};
enum logccmds {
LOGCCLOSE,
LOGCGET,
LOGCVERSION
};
DB_LOGC *logc;
DBTCL_INFO *logcip;
Tcl_Obj *res;
u_int32_t version;
int cmdindex, result, ret;
Tcl_ResetResult(interp);
logc = (DB_LOGC *)clientData;
logcip = _PtrToInfo((void *)logc);
result = TCL_OK;
if (objc <= 1) {
Tcl_WrongNumArgs(interp, 1, objv, "command cmdargs");
return (TCL_ERROR);
}
if (logc == NULL) {
Tcl_SetResult(interp, "NULL logc pointer", TCL_STATIC);
return (TCL_ERROR);
}
if (logcip == NULL) {
Tcl_SetResult(interp, "NULL logc info pointer", TCL_STATIC);
return (TCL_ERROR);
}
/*
* Get the command name index from the object based on the berkdbcmds
* defined above.
*/
if (Tcl_GetIndexFromObj(interp, objv[1], logccmds, "command",
TCL_EXACT, &cmdindex) != TCL_OK)
return (IS_HELP(objv[1]));
switch ((enum logccmds)cmdindex) {
case LOGCCLOSE:
/*
* No args for this. Error if there are some.
*/
if (objc > 2) {
Tcl_WrongNumArgs(interp, 2, objv, NULL);
return (TCL_ERROR);
}
_debug_check();
ret = logc->close(logc, 0);
result = _ReturnSetup(interp, ret, DB_RETOK_STD(ret),
"logc close");
if (result == TCL_OK) {
(void)Tcl_DeleteCommand(interp, logcip->i_name);
_DeleteInfo(logcip);
}
break;
case LOGCGET:
result = tcl_LogcGet(interp, objc, objv, logc);
break;
case LOGCVERSION:
/*
* No args for this. Error if there are some.
*/
if (objc > 2) {
Tcl_WrongNumArgs(interp, 2, objv, NULL);
return (TCL_ERROR);
}
_debug_check();
ret = logc->version(logc, &version, 0);
if ((result = _ReturnSetup(interp, ret, DB_RETOK_STD(ret),
"logc version")) == TCL_OK) {
res = Tcl_NewIntObj((int)version);
Tcl_SetObjResult(interp, res);
}
break;
}
return (result);
}
static int
tcl_LogcGet(interp, objc, objv, logc)
Tcl_Interp *interp;
int objc;
Tcl_Obj * CONST *objv;
DB_LOGC *logc;
{
static const char *logcgetopts[] = {
"-current",
"-first",
"-last",
"-next",
"-prev",
"-set",
NULL
};
enum logcgetopts {
LOGCGET_CURRENT,
LOGCGET_FIRST,
LOGCGET_LAST,
LOGCGET_NEXT,
LOGCGET_PREV,
LOGCGET_SET
};
DB_LSN lsn;
DBT data;
Tcl_Obj *dataobj, *lsnlist, *myobjv[2], *res;
u_int32_t flag;
int i, myobjc, optindex, result, ret;
result = TCL_OK;
res = NULL;
flag = 0;
if (objc < 3) {
Tcl_WrongNumArgs(interp, 2, objv, "?-args? lsn");
return (TCL_ERROR);
}
/*
* Get the command name index from the object based on the options
* defined above.
*/
i = 2;
while (i < objc) {
if (Tcl_GetIndexFromObj(interp, objv[i],
logcgetopts, "option", TCL_EXACT, &optindex) != TCL_OK)
return (IS_HELP(objv[i]));
i++;
switch ((enum logcgetopts)optindex) {
case LOGCGET_CURRENT:
FLAG_CHECK(flag);
flag |= DB_CURRENT;
break;
case LOGCGET_FIRST:
FLAG_CHECK(flag);
flag |= DB_FIRST;
break;
case LOGCGET_LAST:
FLAG_CHECK(flag);
flag |= DB_LAST;
break;
case LOGCGET_NEXT:
FLAG_CHECK(flag);
flag |= DB_NEXT;
break;
case LOGCGET_PREV:
FLAG_CHECK(flag);
flag |= DB_PREV;
break;
case LOGCGET_SET:
FLAG_CHECK(flag);
flag |= DB_SET;
if (i == objc) {
Tcl_WrongNumArgs(interp, 2, objv, "?-set lsn?");
result = TCL_ERROR;
break;
}
result = _GetLsn(interp, objv[i++], &lsn);
break;
}
}
if (result == TCL_ERROR)
return (result);
memset(&data, 0, sizeof(data));
_debug_check();
ret = logc->get(logc, &lsn, &data, flag);
res = Tcl_NewListObj(0, NULL);
if (res == NULL)
goto memerr;
if (ret == 0) {
/*
* Success. Set up return list as {LSN data} where LSN
* is a sublist {file offset}.
*/
myobjc = 2;
myobjv[0] = Tcl_NewWideIntObj((Tcl_WideInt)lsn.file);
myobjv[1] = Tcl_NewWideIntObj((Tcl_WideInt)lsn.offset);
lsnlist = Tcl_NewListObj(myobjc, myobjv);
if (lsnlist == NULL)
goto memerr;
result = Tcl_ListObjAppendElement(interp, res, lsnlist);
dataobj = NewStringObj(data.data, data.size);
if (dataobj == NULL) {
goto memerr;
}
result = Tcl_ListObjAppendElement(interp, res, dataobj);
} else
result = _ReturnSetup(interp, ret, DB_RETOK_LGGET(ret),
"DB_LOGC->get");
Tcl_SetObjResult(interp, res);
if (0) {
memerr: if (res != NULL) {
Tcl_DecrRefCount(res);
}
Tcl_SetResult(interp, "allocation failed", TCL_STATIC);
}
return (result);
}
static const char *confwhich[] = {
"autoremove",
"direct",
"dsync",
"inmemory",
"zero",
NULL
};
enum logwhich {
LOGCONF_AUTO,
LOGCONF_DIRECT,
LOGCONF_DSYNC,
LOGCONF_INMEMORY,
LOGCONF_ZERO
};
/*
* tcl_LogConfig --
* Call DB_ENV->rep_set_config().
*
* PUBLIC: int tcl_LogConfig
* PUBLIC: __P((Tcl_Interp *, DB_ENV *, Tcl_Obj *));
*/
int
tcl_LogConfig(interp, dbenv, list)
Tcl_Interp *interp; /* Interpreter */
DB_ENV *dbenv; /* Environment pointer */
Tcl_Obj *list; /* {which on|off} */
{
static const char *confonoff[] = {
"off",
"on",
NULL
};
enum confonoff {
LOGCONF_OFF,
LOGCONF_ON
};
Tcl_Obj **myobjv, *onoff, *which;
int myobjc, on, optindex, result, ret;
u_int32_t wh;
result = Tcl_ListObjGetElements(interp, list, &myobjc, &myobjv);
if (myobjc != 2)
Tcl_WrongNumArgs(interp, 2, myobjv, "?{which onoff}?");
which = myobjv[0];
onoff = myobjv[1];
if (result != TCL_OK)
return (result);
if (Tcl_GetIndexFromObj(interp, which, confwhich, "option",
TCL_EXACT, &optindex) != TCL_OK)
return (IS_HELP(which));
switch ((enum logwhich)optindex) {
case LOGCONF_AUTO:
wh = DB_LOG_AUTO_REMOVE;
break;
case LOGCONF_DIRECT:
wh = DB_LOG_DIRECT;
break;
case LOGCONF_DSYNC:
wh = DB_LOG_DSYNC;
break;
case LOGCONF_INMEMORY:
wh = DB_LOG_IN_MEMORY;
break;
case LOGCONF_ZERO:
wh = DB_LOG_ZERO;
break;
default:
return (TCL_ERROR);
}
if (Tcl_GetIndexFromObj(interp, onoff, confonoff, "option",
TCL_EXACT, &optindex) != TCL_OK)
return (IS_HELP(onoff));
switch ((enum confonoff)optindex) {
case LOGCONF_OFF:
on = 0;
break;
case LOGCONF_ON:
on = 1;
break;
default:
return (TCL_ERROR);
}
ret = dbenv->log_set_config(dbenv, wh, on);
return (_ReturnSetup(interp, ret, DB_RETOK_STD(ret),
"env rep_config"));
}
/*
* tcl_LogGetConfig --
* Call DB_ENV->rep_get_config().
*
* PUBLIC: int tcl_LogGetConfig
* PUBLIC: __P((Tcl_Interp *, DB_ENV *, Tcl_Obj *));
*/
int
tcl_LogGetConfig(interp, dbenv, which)
Tcl_Interp *interp; /* Interpreter */
DB_ENV *dbenv; /* Environment pointer */
Tcl_Obj *which; /* which flag */
{
Tcl_Obj *res;
int on, optindex, result, ret;
u_int32_t wh;
if (Tcl_GetIndexFromObj(interp, which, confwhich, "option",
TCL_EXACT, &optindex) != TCL_OK)
return (IS_HELP(which));
res = NULL;
switch ((enum logwhich)optindex) {
case LOGCONF_AUTO:
wh = DB_LOG_AUTO_REMOVE;
break;
case LOGCONF_DIRECT:
wh = DB_LOG_DIRECT;
break;
case LOGCONF_DSYNC:
wh = DB_LOG_DSYNC;
break;
case LOGCONF_INMEMORY:
wh = DB_LOG_IN_MEMORY;
break;
case LOGCONF_ZERO:
wh = DB_LOG_ZERO;
break;
default:
return (TCL_ERROR);
}
ret = dbenv->log_get_config(dbenv, wh, &on);
if ((result = _ReturnSetup(interp, ret, DB_RETOK_STD(ret),
"env log_config")) == TCL_OK) {
res = Tcl_NewIntObj(on);
Tcl_SetObjResult(interp, res);
}
return (result);
}
#endif
|