/*
* $Id: cmd_tstart.c,v 1.3 2025/03/09 19:14:24 snw Exp $
* Implementation of the TSTART command
*
*
* Author: Serena Willis <snw@coherent-logic.com>
* Copyright (C) 1998 MUG Deutschland
* Copyright (C) 2023, 2025 Coherent Logic Development LLC
*
*
* This file is part of FreeM.
*
* FreeM is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* FreeM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero Public License for more details.
*
* You should have received a copy of the GNU Affero Public License
* along with FreeM. If not, see <https://www.gnu.org/licenses/>.
*
* $Log: cmd_tstart.c,v $
* Revision 1.3 2025/03/09 19:14:24 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 <string.h>
#include <stdlib.h>
#include <ctype.h>
#include "mpsdef.h"
#include "mcommand.h"
#include "consttbl.h"
#include "transact.h"
MRESULT cmd_tstart(MACTION *ra)
{
register char ch;
short serial = FALSE;
short restartable = FALSE;
char tran_ident[50];
char tre_offset[50];
short parct = 0;
if ((rtn_dialect () != D_M95) &&
(rtn_dialect () != D_MDS) &&
(rtn_dialect () != D_M5) &&
(rtn_dialect () != D_FREEM)) {
return NOSTAND;
}
uuid_v4 (tran_ident);
if (((ch = *codptr) == SP) || ch == EOL) {
serial = FALSE;
restartable = FALSE;
goto exec_tstart;
}
restartable = TRUE;
getraddress (tre_offset, nstx);
//printf ("tre_offset = '%s'\r\n", tre_offset);
if (ch == ':') {
restartable = FALSE;
goto tstart_param;
}
else if (ch == '(') {
ch = *codptr++;
if (ch == ')') goto tstart_param;
}
else if (ch == '*') {
printf ("all varnames\r\n");
}
else if ((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z')) {
printf ("one varname\r\n");
}
tstart_param:
codptr++;
ch = *codptr;
switch (ch) {
case ':':
goto tstart_param;
case 's':
case 'S':
expr (NAME);
if (merr ()) return merr ();
stcnv_m2c (varnam);
{
int stct;
for (stct = 0; stct < strlen (varnam); stct++) {
varnam[stct] = toupper (varnam[stct]);
}
}
if ((strcmp (varnam, "S") == 0) ||
(strcmp (varnam, "SERIAL") == 0)) {
serial = TRUE;
}
else {
return SYNTERR;
}
goto tstart_param;
case 't':
case 'T':
expr (NAME);
if (merr ()) return merr ();
stcnv_m2c (varnam);
{
int stct;
for (stct = 0; stct < strlen (varnam); stct++) {
varnam[stct] = toupper (varnam[stct]);
}
}
if ((strcmp (varnam, "T") == 0) ||
(strcmp (varnam, "TRANSACTIONID") == 0)) {
codptr++;
if ((ch = *codptr) != '=') {
return ASSIGNER;
}
codptr++;
expr (STRING);
if (merr () == BRAER) merr_clear ();
if (merr () > OK) {
return merr ();
}
stcnv_m2c (argptr);
strcpy (tran_ident, argptr);
codptr--;
goto tstart_param;
}
break;
case '(':
parct++;
if (parct > 1) {
return SYNTERR;
}
goto tstart_param;
break;
case ')':
parct--;
if (parct < 0) {
return SYNTERR;
}
goto exec_tstart;
case SP:
case EOL:
if (parct > 0) {
return BRAER;
}
goto exec_tstart;
default:
return SYNTERR;
}
exec_tstart:
tp_tstart (tran_ident, serial, restartable, NULL);
while ((ch = *(codptr++)) != SP && ch != EOL) ; /* skip to the end of the command */
*ra = RA_NEXTCMND;
return OK;
}
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>