1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  *	db_log_entry.cc
24  *
25  *	Copyright (c) 1988-1992 Sun Microsystems Inc
26  *	All Rights Reserved.
27  */
28 
29 #include <stdio.h>
30 
31 #include "db_headers.h"
32 #include "db_log_entry.h"
33 #include "db_table.h"
34 
35 extern void print_entry(entryp, entry_object *);
36 
37 /*
38  * Constructor:  Create a log entry using the given parameters.  Note that
39  * pointers to db_query and entry_object are simply assigned, not copied.
40  */
db_log_entry(db_action a,vers * v,db_query * q,entry_object * obj)41 db_log_entry::db_log_entry(db_action a, vers * v, db_query *q,
42 			    entry_object *obj)
43 {
44 	action = a;
45 	aversion.assign(v);
46 	query = q;
47 	object = obj;
48 	next = NULL;
49 	bversion.assign(v);
50 }
51 
~db_log_entry()52 db_log_entry::~db_log_entry()
53 {
54 /* we might not have allocated these ourselves, so we cannot delete them */
55 //	if (query) delete query;
56 //	if (object) free_entry(object);
57 }
58 
59 /* prints a line from the journal */
60 void
print()61 db_log_entry::print()
62 {
63 	switch (action) {
64 	case DB_ADD:
65 	    printf("add: ");
66 	    break;
67 	case DB_REMOVE:
68 	    printf("remove: ");
69 	    break;
70 	default:
71 	    printf("action(%d): ", action);
72 	    break;
73 	}
74 
75 	aversion.print(stdout);
76 	putchar(' ');
77 	if (query != NULL)
78 		query->print();
79 	else
80 		printf("no query!\n");
81 
82 	if (object != NULL) {
83 		print_entry(0, object);
84 	} else {
85 		printf("no object\n");
86 	}
87 	bversion.print(stdout);
88 	putchar('\n');
89 }
90