1: /*
2: * $Id: transact.h,v 1.3 2025/03/09 19:50:47 snw Exp $
3: * Function prototypes, structs, and macros for FreeM
4: * transaction support
5: *
6: *
7: * Author: Serena Willis <snw@coherent-logic.com>
8: * Copyright (C) 1998 MUG Deutschland
9: * Copyright (C) 2020, 2025 Coherent Logic Development LLC
10: *
11: *
12: * This file is part of FreeM.
13: *
14: * FreeM is free software: you can redistribute it and/or modify
15: * it under the terms of the GNU Affero Public License as published by
16: * the Free Software Foundation, either version 3 of the License, or
17: * (at your option) any later version.
18: *
19: * FreeM is distributed in the hope that it will be useful,
20: * but WITHOUT ANY WARRANTY; without even the implied warranty of
21: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22: * GNU Affero Public License for more details.
23: *
24: * You should have received a copy of the GNU Affero Public License
25: * along with FreeM. If not, see <https://www.gnu.org/licenses/>.
26: *
27: * $Log: transact.h,v $
28: * Revision 1.3 2025/03/09 19:50:47 snw
29: * Second phase of REUSE compliance and header reformat
30: *
31: *
32: * SPDX-FileCopyrightText: (C) 2025 Coherent Logic Development LLC
33: * SPDX-License-Identifier: AGPL-3.0-or-later
34: **/
35:
36: #define TP_MAX_NEST 256
37: #define TP_MAX_OPS 256
38:
39: typedef struct tp_gblop {
40:
41: /* does this operation represent a LOCK? */
42: short is_lock;
43:
44: /* flags presented to global(); action and
45: data do not apply if is_lock == TRUE */
46: short action;
47: char key[256];
48: char data[256];
49:
50: } tp_gblop;
51:
52: typedef struct tp_transaction {
53:
54: /* transaction ID */
55: char tp_id[256];
56:
57: /* transaction flags */
58: short serial;
59: short restartable;
60:
61: /* array of symbols to be restored on TRESTART */
62: char sym_save[256][256];
63:
64: int opcount;
65:
66: tp_gblop ops[TP_MAX_OPS];
67:
68: } tp_transaction;
69:
70: extern int tp_committing;
71: extern int tp_level;
72: extern tp_transaction transactions[TP_MAX_NEST];
73: extern void tp_init(void);
74: extern short tp_get_sem(void);
75: extern void tp_release_sem(void);
76: extern int tp_tstart(char *tp_id, short serial, short restartable, char **sym_save);
77: extern int tp_add_op(short islock, short action, char *key, char *data);
78: extern int tp_tcommit(void);
79: extern int tp_cleanup(int levels);
80: extern int tp_trollback(int levels);
81: extern int tp_trestart(void);
82: extern void tp_tdump(void);
83: extern void tp_get_op_name(char *buf, const short action);
84:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>