Annotation of freem/src/mcommand.c, revision 1.1
1.1 ! snw 1: /*
! 2: * *
! 3: * * *
! 4: * * *
! 5: * ***************
! 6: * * * * *
! 7: * * MUMPS *
! 8: * * * * *
! 9: * ***************
! 10: * * *
! 11: * * *
! 12: * *
! 13: *
! 14: * mcommand.c
! 15: * M command utility functions
! 16: *
! 17: *
! 18: * Author: Serena Willis <jpw@coherent-logic.com>
! 19: * Copyright (C) 1998 MUG Deutschland
! 20: * Copyright (C) 2023 Coherent Logic Development LLC
! 21: *
! 22: *
! 23: * This file is part of FreeM.
! 24: *
! 25: * FreeM is free software: you can redistribute it and/or modify
! 26: * it under the terms of the GNU Affero Public License as published by
! 27: * the Free Software Foundation, either version 3 of the License, or
! 28: * (at your option) any later version.
! 29: *
! 30: * FreeM is distributed in the hope that it will be useful,
! 31: * but WITHOUT ANY WARRANTY; without even the implied warranty of
! 32: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
! 33: * GNU Affero Public License for more details.
! 34: *
! 35: * You should have received a copy of the GNU Affero Public License
! 36: * along with FreeM. If not, see <https://www.gnu.org/licenses/>.
! 37: *
! 38: **/
! 39:
! 40: #include <string.h>
! 41: #include <stdlib.h>
! 42: #include "mpsdef.h"
! 43: #include "mcommand.h"
! 44:
! 45: MRESULT mcmd_tokenize(MACTION *ra, char *tmp3, char *deferrable_codptr, char *deferrable_code, int *j)
! 46: {
! 47: tmp3[0] = SP;
! 48: tmp3[1] = mcmnd;
! 49: tmp3[++(*j)] = SP;
! 50: tmp3[++(*j)] = EOL;
! 51:
! 52: if (mcmnd != 'z') {
! 53:
! 54: if (find (" ab ablock assert assign asta astart asto astop aunb aunblock \
! 55: break co const close do else esta estart esto estop etr etrigger for goto hang halt \
! 56: if job kill ks ksubscripts kv kvalue lock ma map merge new open quit read rl rload \
! 57: rs rsave set tc tcommit th then thr throw tro trollback ts tstart use \
! 58: un unmap usi using view wa watch write wi with xecute ", tmp3) == FALSE) {
! 59: return CMMND;
! 60: }
! 61:
! 62: switch (mcmnd)
! 63: {
! 64:
! 65: case 'a':
! 66:
! 67: if (tmp3[2] == 'b') {
! 68: mcmnd = ABLOCK;
! 69: }
! 70: else if (tmp3[2] == 'u') {
! 71: mcmnd = AUNBLOCK;
! 72: }
! 73: else if (tmp3[2] == 's') {
! 74:
! 75: if (tmp3[4] == 'a') {
! 76: mcmnd = ASTART;
! 77: }
! 78: else if (tmp3[4] == 'o') {
! 79: mcmnd = ASTOP;
! 80: }
! 81: else if (tmp3[4] == 'e') {
! 82: mcmnd = ASSERT_TKN;
! 83: }
! 84:
! 85: }
! 86:
! 87: break;
! 88:
! 89: case 'c':
! 90:
! 91: if (tmp3[2] == 'l') {
! 92: mcmnd = CLOSE;
! 93: }
! 94: else {
! 95: mcmnd = CONST;
! 96: }
! 97:
! 98: case 'e':
! 99: if (tmp3[2] == 't') mcmnd = ETRIGGER;
! 100: else if (tmp3[4] == 'a') mcmnd = ESTART;
! 101: else if (tmp3[4] == 'o') mcmnd = ESTOP;
! 102: break;
! 103:
! 104: case 'h':
! 105: mcmnd = tmp3[4] == 't' ? HALT : HANG;
! 106: break;
! 107:
! 108: case 'k':
! 109: if (tmp3[2] == 'v') mcmnd = KVALUE;
! 110: else if (tmp3[2] == 's') mcmnd = KSUBSC;
! 111: break;
! 112:
! 113: case 'm':
! 114:
! 115: if (tmp3[2] == 'e') {
! 116:
! 117: /* save off pre-parse codptr and code for commands implemented in M routines */
! 118: deferrable_codptr = codptr;
! 119: stcpy (deferrable_code, "MERGE\201");
! 120: stcat (deferrable_code, deferrable_codptr);
! 121:
! 122: break;
! 123:
! 124: }
! 125: else if (tmp3[2] == 'a') {
! 126: mcmnd = MAP;
! 127: break;
! 128: }
! 129:
! 130: case 'r':
! 131: if (tmp3[2] == 'l') mcmnd = RLOAD;
! 132: else if (tmp3[2] == 's') mcmnd = RSAVE;
! 133: break;
! 134:
! 135: case 't':
! 136: if (tmp3[2] == 'c') mcmnd = TCOMMIT;
! 137: else if (tmp3[2] == 'h') {
! 138: if (tmp3[3] == 'e') {
! 139: mcmnd = THEN;
! 140: }
! 141: else if (tmp3[3] == 'r') {
! 142: mcmnd = THROW;
! 143: }
! 144: }
! 145: else if (tmp3[3] == 'o') mcmnd = TROLLBACK;
! 146: else if (tmp3[2] == 's') mcmnd = TSTART;
! 147: break;
! 148:
! 149: case 'w':
! 150:
! 151: switch (tmp3[2]) {
! 152:
! 153:
! 154: case 'a':
! 155: mcmnd = WATCH;
! 156: break;
! 157:
! 158: case 'i':
! 159: mcmnd = OO_WITH;
! 160: break;
! 161:
! 162: case 'r':
! 163: mcmnd = WRITE;
! 164: break;
! 165:
! 166:
! 167: }
! 168:
! 169: break;
! 170:
! 171: case 'u':
! 172:
! 173: if (tmp3[2] == 'n') {
! 174: mcmnd = UNMAP;
! 175: break;
! 176: }
! 177:
! 178: switch (tmp3[3]) {
! 179:
! 180: case 'e':
! 181: mcmnd = USE;
! 182: break;
! 183:
! 184: case 'i':
! 185: mcmnd = OO_USING;
! 186: break;
! 187:
! 188: }
! 189:
! 190:
! 191: } /* end of switch(mcmnd) */
! 192:
! 193: }
! 194: else {
! 195:
! 196: mcmnd = tmp3[2] - 32; /* z_command select */
! 197:
! 198: if (find (zcommds, tmp3) == FALSE) mcmnd = PRIVATE;
! 199: }
! 200:
! 201: *ra = RA_CONTINUE;
! 202: return OK;
! 203: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>