|
|
| version 1.1, 2025/01/19 02:04:04 | version 1.11, 2025/04/11 14:21:03 |
|---|---|
| Line 1 | Line 1 |
| /* | /* |
| * * | * $Id$ |
| * * * | |
| * * * | |
| * *************** | |
| * * * * * | |
| * * MUMPS * | |
| * * * * * | |
| * *************** | |
| * * * | |
| * * * | |
| * * | |
| * | |
| * global_bltin.h | |
| * built-in global handler header | * built-in global handler header |
| * | * |
| * | * |
| * Author: Serena Willis <jpw@coherent-logic.com> | * Author: Serena Willis <snw@coherent-logic.com> |
| * Copyright (C) 1998 MUG Deutschland | * Copyright (C) 1998 MUG Deutschland |
| * Copyright (C) 2020 Coherent Logic Development LLC | * Copyright (C) 2020, 2025 Coherent Logic Development LLC |
| * | * |
| * | * |
| * This file is part of FreeM. | * This file is part of FreeM. |
| Line 35 | Line 23 |
| * You should have received a copy of the GNU Affero Public License | * You should have received a copy of the GNU Affero Public License |
| * along with FreeM. If not, see <https://www.gnu.org/licenses/>. | * along with FreeM. If not, see <https://www.gnu.org/licenses/>. |
| * | * |
| * $Log$ | |
| * Revision 1.11 2025/04/11 14:21:03 snw | |
| * Make all but one of the read/write calls in global_bltin use gbl_read_block or gbl_write_block | |
| * | |
| * Revision 1.10 2025/04/11 00:52:40 snw | |
| * Replace all lseek/read calls in global handler to use gbl_read_block function | |
| * | |
| * Revision 1.9 2025/04/09 14:34:30 snw | |
| * Further work on global_bltin.c refactor | |
| * | |
| * Revision 1.8 2025/04/09 00:43:07 snw | |
| * Exit with fatal error if a header mismatch found | |
| * | |
| * Revision 1.7 2025/04/08 21:41:13 snw | |
| * Make insert, update, and splitp global handler functions take a ptr to a global_handle instead of a file descriptor | |
| * | |
| * Revision 1.6 2025/04/08 20:00:56 snw | |
| * Global handler now uses a header file and maintains the last journaling transaction ID | |
| * | |
| * Revision 1.5 2025/04/08 16:46:11 snw | |
| * Add global file header and offsets | |
| * | |
| * Revision 1.4 2025/04/08 14:39:21 snw | |
| * Initial work on global handler refactor | |
| * | |
| * Revision 1.3 2025/03/09 19:14:25 snw | |
| * First phase of REUSE compliance and header reformat | |
| * | |
| * | |
| * SPDX-FileCopyrightText: (C) 2025 Coherent Logic Development LLC | |
| * SPDX-License-Identifier: AGPL-3.0-or-later | |
| **/ | **/ |
| #if !defined(__FREEM_GLOBAL_BLTIN_H) | |
| # define __FREEM_GLOBAL_BLTIN_H | |
| #include "version.h" | |
| #define GBL_FORMAT_VERSION 2 | |
| #define GBL_MAGIC "FRMGL" | |
| #define GBL_HDR_OK 0 | |
| #define GBL_HDR_NOTOPEN 1 | |
| #define GBL_HDR_BADMAGIC 2 | |
| #define GBL_HDR_BADVERSION 3 | |
| #define GBL_HDR_BADBLOCKSIZE 4 | |
| typedef struct global_header { | |
| char magic[5]; /* FRMGL */ | |
| int format_version; | |
| char host_triplet[40]; | |
| char host_id[256]; | |
| unsigned long block_size; | |
| unsigned long last_transaction_id; | |
| long created; | |
| long last_backup; | |
| } global_header; | |
| typedef struct global_handle { | |
| int fd; /* file descriptor */ | |
| global_header header; | |
| long age; | |
| short opened; | |
| short locked; | |
| unsigned long last_block; | |
| unsigned long use_count; /* how many times has it been accessed? */ | |
| unsigned long read_ops; | |
| unsigned long write_ops; | |
| unsigned long splits; | |
| unsigned long cache_misses; | |
| unsigned long cache_hits; | |
| short fast_path; | |
| char global_name[256]; | |
| char global_path[4096]; | |
| struct global_handle *next; | |
| } global_handle; | |
| extern global_handle *global_handles_head; | |
| extern unsigned long gbl_cache_misses; | |
| extern unsigned long gbl_cache_hits; | |
| extern inline long gbl_path(char *key, char *buf); | |
| extern void gbl_cache_hit(global_handle *g); | |
| extern void gbl_cache_miss(global_handle *g); | |
| extern int gbl_lock(global_handle *g, int type); | |
| extern int gbl_unlock(global_handle *g); | |
| extern void gbl_close(global_handle *g); | |
| extern void gbl_close_all(void); | |
| extern int gbl_write_initial_header(global_handle *g); | |
| extern int gbl_write_header(global_handle *g, global_header *hdr); | |
| extern int gbl_read_header(global_handle *g, global_header *h); | |
| extern int gbl_update_tid(global_handle *g); | |
| extern int gbl_create(global_handle *g); | |
| extern short gbl_open(global_handle *g, short action); | |
| extern int gbl_read_block(global_handle *g, unsigned long blocknum, char *block); | |
| extern int gbl_write_block(global_handle *g, unsigned long blocknum, char *block); | |
| extern global_handle *gbl_handle(char *key); | |
| #endif |