version 1.2, 2025/03/09 15:20:18
|
version 1.6, 2025/04/17 14:34:27
|
Line 1
|
Line 1
|
/* |
/* |
* * |
* $Id$ |
* * * |
|
* * * |
|
* *************** |
|
* * * * * |
|
* * MUMPS * |
|
* * * * * |
|
* *************** |
|
* * * |
|
* * * |
|
* * |
|
* |
|
* fma_journals.c |
|
* Journal utilities for fmadm |
* Journal utilities for fmadm |
* |
* |
* |
* |
* Author: Serena Willis <snw@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.6 2025/04/17 14:34:27 snw |
|
* Further logging improvements |
|
* |
|
* Revision 1.5 2025/04/13 04:22:43 snw |
|
* Fix snprintf calls |
|
* |
|
* Revision 1.4 2025/04/09 19:52:02 snw |
|
* Eliminate as many warnings as possible while building with -Wall |
|
* |
|
* 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 |
**/ |
**/ |
|
|
#include <stdlib.h> |
#include <stdlib.h> |
Line 51
|
Line 55
|
|
|
#include "fmadm.h" |
#include "fmadm.h" |
#include "jnldefs.h" |
#include "jnldefs.h" |
|
#include "log.h" |
|
|
void cvt_key (char *buf, char *key); |
void cvt_key (char *buf, char *key); |
extern short ierr; |
extern short ierr; |
Line 73 int fma_journals_examine (int optc, char
|
Line 78 int fma_journals_examine (int optc, char
|
jnl_ent_t ent; |
jnl_ent_t ent; |
|
|
if ((fd = open (fma_journal_path, O_RDONLY)) == -1) { |
if ((fd = open (fma_journal_path, O_RDONLY)) == -1) { |
fprintf (stderr, "fmadm: error %d opening journal file %s (%s)\n", errno, fma_journal_path, strerror (errno)); |
logprintf (FM_LOG_FATAL, "fmadm: error opening journal file %s (error code %ld [%s])",fma_journal_path, errno, strerror (errno)); |
|
|
exit (2); |
|
} |
} |
|
|
if (read (fd, &hdr, sizeof (jnl_hdr_t)) == -1) { |
if (read (fd, &hdr, sizeof (jnl_hdr_t)) == -1) { |
fprintf (stderr, "fmadm: error %d reading header from journal file %s (%s)\n", errno, fma_journal_path, strerror (errno)); |
logprintf (FM_LOG_FATAL, "fmadm: error reading header from journal file %s (error code %ld [%s])", errno, fma_journal_path, strerror (errno)); |
|
|
exit (3); |
|
} |
} |
|
|
printf ("\nFreeM Journal Dump\n"); |
printf ("\nFreeM Journal Dump\n"); |
Line 140 int fma_journals_examine (int optc, char
|
Line 141 int fma_journals_examine (int optc, char
|
|
|
if (ent.action == JNLA_SET) { |
if (ent.action == JNLA_SET) { |
|
|
snprintf (dbuf, 2049, "%s=%s", kbuf, ent.data); |
snprintf (dbuf, sizeof (dbuf) - 1, "%s=%s", kbuf, ent.data); |
|
|
for (k = 0; k < strlen (dbuf); k++) { |
for (k = 0; k < strlen (dbuf); k++) { |
if (dbuf[k] == '\201') dbuf[k] = '\0'; |
if (dbuf[k] == '\201') dbuf[k] = '\0'; |
Line 163 int fma_journals_restore (int optc, char
|
Line 164 int fma_journals_restore (int optc, char
|
{ |
{ |
|
|
register int i; |
register int i; |
register int k; |
|
int fd; |
int fd; |
unsigned long siz; |
unsigned long siz; |
unsigned long ct; |
unsigned long ct; |
|
|
char kbuf[1024]; |
|
char *tbuf; |
|
|
|
char dbuf[2049]; |
|
|
|
jnl_hdr_t hdr; |
jnl_hdr_t hdr; |
jnl_ent_t ent; |
jnl_ent_t ent; |
|
|
if ((fd = open (fma_journal_path, O_RDONLY)) == -1) { |
if ((fd = open (fma_journal_path, O_RDONLY)) == -1) { |
fprintf (stderr, "error: error %d opening journal file %s\n", errno, fma_journal_path); |
logprintf (FM_LOG_FATAL, "fmadm: error opening journal file %s (error code %ld [%s])",fma_journal_path, errno, strerror (errno)); |
|
|
exit (2); |
|
} |
} |
|
|
if (read (fd, &hdr, sizeof (jnl_hdr_t)) == -1) { |
if (read (fd, &hdr, sizeof (jnl_hdr_t)) == -1) { |
fprintf (stderr, "error: error %d reading header from journal file %s\n", errno, fma_journal_path); |
logprintf (FM_LOG_FATAL, "fmadm: error reading header from journal file %s (error code %ld [%s])", errno, fma_journal_path, strerror (errno)); |
|
|
exit (3); |
|
} |
} |
|
|
printf ("\nFreeM Journal Playback\n"); |
printf ("\nFreeM Journal Playback\n"); |