Commit 90c47741 authored by John P. Willis's avatar John P. Willis
Browse files

Further work on mappings

parent e870016d
Pipeline #752 passed with stage
in 1 minute and 27 seconds
......@@ -138,6 +138,19 @@ trmstat ;
W "CTRLOPROC = "_^$DEVICE($P,"CTRLOPROC")_" NOTYPEAHEAD = "_^$DEVICE($P,"NOTYPEAHEAD")_" TERMID = "_^$DEVICE($P,"TERMID"),!,!
W "Device Status Word is "_^$DEVICE($P,"DSW"),!,!
Q
GLOBAL ;
global ;
N GBLNAM,G
W !,"Which global (including ^)? "
R GBLNAM W !!
I '$D(GBLNAM) W "Invalid global?",! G GLOBAL
S G=$E(GBLNAM,2,$L(GBLNAM))
W "GLOBAL: ",GBLNAM,!
W "NAMESPACE: ",^$GLOBAL(G,"NAMESPACE")
I $D(^$SYSTEM("MAPPINGS","GLOBAL",GBLNAM)) W " [mapped]",!
E W !
W "DATA FILE: ",^$GLOBAL(G,"FILE"),!
Q
rw ;
W !,"---=== PROFESSOR RICHARD WALTERS ===---",!!
W "UC Davis professor Richard Walters, the former director of the",!
......
......@@ -128,6 +128,9 @@ void ssvn_global(short action, char *key, char *data)
char gb_path[STRLEN];
char gb_cpath[STRLEN];
char ns_key[256];
char ns_data[256];
long blkcount;
freem_ref_t *r = (freem_ref_t *) malloc (sizeof (freem_ref_t));
......@@ -141,6 +144,32 @@ void ssvn_global(short action, char *key, char *data)
switch (action) {
case set_sym:
if (strcmp (mref_get_subscript (r, 1), "NAMESPACE") != 0) {
ierr = M29;
goto done;
}
snprintf (ns_key, 255, "^$SYSTEM\202MAPPINGS\202GLOBAL\202^%s\201", mref_get_subscript (r, 0));
global (set_sym, ns_key, data);
goto done;
case kill_sym:
if (strcmp (mref_get_subscript (r, 1), "NAMESPACE") != 0) {
ierr = M29;
goto done;
}
snprintf (ns_key, 255, "^$SYSTEM\202MAPPINGS\202GLOBAL\202^%s\201", mref_get_subscript (r, 0));
global (kill_sym, ns_key, data);
goto done;
case get_sym:
if (frm_global_exists (gb_ns, gb_path, r->subscripts[0]) != TRUE) {
......@@ -332,6 +361,7 @@ void ssvn_global(short action, char *key, char *data)
ierr = M38;
goto done;
default:
ierr = INVREF;
......
......@@ -338,6 +338,12 @@ void ssvn_system(short action, char *key, char *data)
global (action, key, data);
ierr = OK;
goto done;
case dat:
global (action, key, data);
ierr = OK;
goto done;
default:
......
......@@ -145,6 +145,8 @@ extern int read_history ();
#define KSUBSC 11
#define LOCK 'l'
#define MERGE 'm'
#define MAP 26
#define UNMAP 27
#define NEWCMD 'n'
#define OPEN 'o'
#define QUIT 'q'
......@@ -598,9 +600,9 @@ next0:
if (find (" ab ablock assert assign asta astart asto astop aunb aunblock \
break co const close do else esta estart esto estop etr etrigger for goto hang halt \
if job kill ks ksubscripts kv kvalue lock merge new open quit read rl rload\
if job kill ks ksubscripts kv kvalue lock ma map merge new open quit read rl rload\
rs rsave set tc tcommit th then thr throw tre trestart tro trollback ts tstart use\
usi using view wa watch write wi with xecute ", tmp3) == FALSE) {
un unmap usi using view wa watch write wi with xecute ", tmp3) == FALSE) {
ierr = CMMND;
goto err;
}
......@@ -657,12 +659,21 @@ next0:
break;
case 'm':
/* save off pre-parse codptr and code for commands implemented in M routines */
deferrable_codptr = codptr;
stcpy (deferrable_code, "MERGE\201");
stcat (deferrable_code, deferrable_codptr);
if (tmp3[2] == 'e') {
/* save off pre-parse codptr and code for commands implemented in M routines */
deferrable_codptr = codptr;
stcpy (deferrable_code, "MERGE\201");
stcat (deferrable_code, deferrable_codptr);
break;
break;
}
else if (tmp3[2] == 'a') {
mcmnd = MAP;
break;
}
case 'r':
if (tmp3[2] == 'l') mcmnd = RLOAD;
......@@ -708,6 +719,11 @@ next0:
case 'u':
if (tmp3[2] == 'n') {
mcmnd = UNMAP;
break;
}
switch (tmp3[3]) {
case 'e':
......@@ -719,6 +735,7 @@ next0:
break;
}
} /* end of switch(mcmnd) */
......@@ -815,6 +832,96 @@ again:
switch (mcmnd) {
case MAP:
{
char mapping_type;
char mapping_obj[256];
char mapping_ns[256];
char tmp_key[256];
expr (NAME);
if (stcmp (varnam, "GLOBAL\201") == 0 || stcmp (varnam, "global\201") == 0) {
mapping_type = 'g';
}
else if (stcmp (varnam, "ROUTINE\201") == 0 || stcmp (varnam, "routine\201") == 0) {
mapping_type = 'r';
ierr = ARGLIST;
goto err;
}
else {
ierr = ARGLIST;
goto err;
}
codptr += 2;
expr (NAME);
stcpy (mapping_obj, varnam);
stcnv_m2c (mapping_obj);
codptr++;
if (*codptr != '=') {
ierr = ASSIGNER;
goto err;
}
codptr++;
expr (STRING);
stcpy (mapping_ns, argptr);
snprintf (tmp_key, 255, "^$SYSTEM\202MAPPINGS\202GLOBAL\202%s\201", mapping_obj);
global (set_sym, tmp_key, mapping_ns);
break;
}
case UNMAP:
{
char mapping_type;
char mapping_obj[256];
char tmp_data[256];
char tmp_key[256];
expr (NAME);
if (stcmp (varnam, "GLOBAL\201") == 0 || stcmp (varnam, "global\201") == 0) {
mapping_type = 'g';
}
else if (stcmp (varnam, "ROUTINE\201") == 0 || stcmp (varnam, "routine\201") == 0) {
mapping_type = 'r';
ierr = ARGLIST;
goto err;
}
else {
ierr = ARGLIST;
goto err;
}
codptr += 2;
expr (NAME);
stcpy (mapping_obj, varnam);
stcnv_m2c (mapping_obj);
snprintf (tmp_key, 255, "^$SYSTEM\202MAPPINGS\202GLOBAL\202%s\201", mapping_obj);
global (kill_sym, tmp_key, tmp_data);
codptr++;
break;
}
case THEN:
{
then_ctr++;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment