Annotation of freem/src/cmd_tstart.c, revision 1.4
1.1 snw 1: /*
1.4 ! snw 2: * $Id: cmd_tstart.c,v 1.3 2025/03/09 19:14:24 snw Exp $
1.1 snw 3: * Implementation of the TSTART command
4: *
5: *
1.2 snw 6: * Author: Serena Willis <snw@coherent-logic.com>
1.1 snw 7: * Copyright (C) 1998 MUG Deutschland
1.3 snw 8: * Copyright (C) 2023, 2025 Coherent Logic Development LLC
1.1 snw 9: *
10: *
11: * This file is part of FreeM.
12: *
13: * FreeM is free software: you can redistribute it and/or modify
14: * it under the terms of the GNU Affero Public License as published by
15: * the Free Software Foundation, either version 3 of the License, or
16: * (at your option) any later version.
17: *
18: * FreeM is distributed in the hope that it will be useful,
19: * but WITHOUT ANY WARRANTY; without even the implied warranty of
20: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21: * GNU Affero Public License for more details.
22: *
23: * You should have received a copy of the GNU Affero Public License
24: * along with FreeM. If not, see <https://www.gnu.org/licenses/>.
25: *
1.4 ! snw 26: * $Log: cmd_tstart.c,v $
! 27: * Revision 1.3 2025/03/09 19:14:24 snw
! 28: * First phase of REUSE compliance and header reformat
! 29: *
1.3 snw 30: *
31: * SPDX-FileCopyrightText: (C) 2025 Coherent Logic Development LLC
32: * SPDX-License-Identifier: AGPL-3.0-or-later
1.1 snw 33: **/
34:
35: #include <string.h>
36: #include <stdlib.h>
37: #include <ctype.h>
38: #include "mpsdef.h"
39: #include "mcommand.h"
40: #include "consttbl.h"
41: #include "transact.h"
42:
43: MRESULT cmd_tstart(MACTION *ra)
44: {
45: register char ch;
46: short serial = FALSE;
47: short restartable = FALSE;
48: char tran_ident[50];
49: char tre_offset[50];
50: short parct = 0;
51:
52: if ((rtn_dialect () != D_M95) &&
53: (rtn_dialect () != D_MDS) &&
54: (rtn_dialect () != D_M5) &&
55: (rtn_dialect () != D_FREEM)) {
56: return NOSTAND;
57: }
58:
59: uuid_v4 (tran_ident);
60:
61: if (((ch = *codptr) == SP) || ch == EOL) {
62:
63: serial = FALSE;
64: restartable = FALSE;
65:
66: goto exec_tstart;
67:
68: }
69:
70: restartable = TRUE;
71: getraddress (tre_offset, nstx);
72:
73: if (ch == ':') {
74: restartable = FALSE;
75: goto tstart_param;
76: }
77: else if (ch == '(') {
78: ch = *codptr++;
79:
80: if (ch == ')') goto tstart_param;
81: }
82: else if (ch == '*') {
83: printf ("all varnames\r\n");
84: }
85: else if ((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z')) {
86: printf ("one varname\r\n");
87: }
88:
89:
90: tstart_param:
91:
92: codptr++;
93: ch = *codptr;
94:
95: switch (ch) {
96:
97: case ':':
98: goto tstart_param;
99:
100: case 's':
101: case 'S':
102:
103: expr (NAME);
104: if (merr ()) return merr ();
105:
106: stcnv_m2c (varnam);
107: {
108: int stct;
109: for (stct = 0; stct < strlen (varnam); stct++) {
110: varnam[stct] = toupper (varnam[stct]);
111: }
112: }
113:
114: if ((strcmp (varnam, "S") == 0) ||
115: (strcmp (varnam, "SERIAL") == 0)) {
116: serial = TRUE;
117: }
118: else {
119: return SYNTERR;
120: }
121:
122: goto tstart_param;
123:
124: case 't':
125: case 'T':
126:
127: expr (NAME);
128: if (merr ()) return merr ();
129:
130: stcnv_m2c (varnam);
131: {
132: int stct;
133: for (stct = 0; stct < strlen (varnam); stct++) {
134: varnam[stct] = toupper (varnam[stct]);
135: }
136: }
137:
138: if ((strcmp (varnam, "T") == 0) ||
139: (strcmp (varnam, "TRANSACTIONID") == 0)) {
140:
141: codptr++;
142:
143: if ((ch = *codptr) != '=') {
144: return ASSIGNER;
145: }
146:
147: codptr++;
148:
149: expr (STRING);
150: if (merr () == BRAER) merr_clear ();
151: if (merr () > OK) {
152: return merr ();
153: }
154:
155: stcnv_m2c (argptr);
156: strcpy (tran_ident, argptr);
157:
158: codptr--;
159:
160: goto tstart_param;
161:
162: }
163: break;
164:
165: case '(':
166:
167: parct++;
168:
169: if (parct > 1) {
170: return SYNTERR;
171: }
172:
173: goto tstart_param;
174:
175: break;
176:
177: case ')':
178:
179: parct--;
180:
181: if (parct < 0) {
182: return SYNTERR;
183: }
184:
185: goto exec_tstart;
186:
187: case SP:
188: case EOL:
189:
190: if (parct > 0) {
191: return BRAER;
192: }
193:
194: goto exec_tstart;
195:
196: default:
197:
198: return SYNTERR;
199:
200: }
201:
202:
203: exec_tstart:
204: tp_tstart (tran_ident, serial, restartable, NULL);
205:
206: while ((ch = *(codptr++)) != SP && ch != EOL) ; /* skip to the end of the command */
207: *ra = RA_NEXTCMND;
208: return OK;
209: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>