Errors
UnknownAddress: PUBLIC ERROR ~ CODE;
StubError: PUBLIC ERROR [whatsUp: ROPE] ~ CODE;
RemoteOperation: TYPE ~ PROC [crH: CrRPC.Handle];
Guarded:
PROC [server:
ROPE, op: RemoteOperation] ~ {
ENABLE {
UNWIND => { NULL };
Adobe2.Error => {
whatsUp: ROPE ~ IO.PutFR1["Adobe2.Error[code: (%g)]", IO.card[why.ORD] ];
ERROR StubError[whatsUp];
};
};
qualified: XNSCHName.Name; add: XNS.Address;
[qualified, add] ¬ XNSCH.LookupAddressFromRope[server];
IF ( add = XNS.unknownAddress ) THEN ERROR UnknownAddress;
{
name: ROPE ~ XNSCHName.RopeFromName[qualified];
address: REF XNS.Address ~ NEW[XNS.Address ¬ add];
crH: CrRPC.Handle ~ CrRPC.CreateClientHandle[crAtom, address];
realId: XNSAuth.Identity ~ UserCredentials.GetIdentity[];
conversation: XNSAuth.Conversation ~ XNSAuth.Initiate[realId, qualified];
credentials: XNSAuth.Credentials ~ XNSAuth.GetCredentials[conversation];
verifier: XNSAuth.Verifier;
XNSAuth.SetRecipientHostNumber[conversation, address.host];
verifier ← XNSAuth.GetNextVerifier[conversation];
op[crH];
CrRPC.DestroyClientHandle[crH];
};
};
Remote Operations (system)
GetDatabaseDescription:
PUBLIC PROC [server:
ROPE, system: Adobe2.Database]
RETURNS [description: Adobe2.Description] ~ {
GetDatabaseDescriptionOp: RemoteOperation ~ {
target: Adobe2.Target ~ [system];
description ¬ Adobe2.GetSystemDescription[crH, target];
};
Guarded[server, GetDatabaseDescriptionOp];
};
GetLocationOfARs:
PUBLIC PROC [server:
ROPE, system: Adobe2.Database]
RETURNS [referenceToARs: Adobe2.NSName] ~ {
GetLocationOfARsOp: RemoteOperation ~ {
target: Adobe2.Target ~ [system];
referenceToARs ¬ Adobe2.GetLocationOfARs[crH, target];
};
Guarded[server, GetLocationOfARsOp];
};
GetVersion:
PUBLIC PROC [server:
ROPE, system: Adobe2.Database]
RETURNS [version: Adobe2.ARVersion ¬ 0]~ {
GetVersionOp: RemoteOperation ~ {
target: Adobe2.Target ~ [system];
version ¬ Adobe2.GetVersion[crH, target];
};
Guarded[server, GetVersionOp];
};
LookupARs:
PUBLIC PROC [server:
ROPE, system: Adobe2.Database,
version: Adobe2.ARVersion, fieldName:
ROPE, value: Adobe2.FieldItemQueryValue,
set: Adobe2.SetOfARs]
RETURNS [s: Adobe2.SetOfARs] ~ {
LookupARsOp: RemoteOperation ~ {
target: Adobe2.Target ~ [system];
instance: Adobe2.StaticTarget ~ [target, version];
query: Adobe2.QueryItem ¬ [fieldName, value];
boundSet: Adobe2.SetOfARs ¬ set;
s ¬ Adobe2.LookupARs[crH, instance, query, boundSet];
};
Guarded[server, LookupARsOp];
};
ReadLastARNumber:
PUBLIC PROC [server:
ROPE, system: Adobe2.Database]
RETURNS [lastAR: Adobe2.ARNumber ¬ 0] ~ {
ReadLastARNumberOp: RemoteOperation ~ {
target: Adobe2.Target ~ [system];
lastAR ¬ Adobe2.ReadLastARNumber[crH, target];
};
Guarded[server, ReadLastARNumberOp];
};
GetAcceleratorInfo:
PUBLIC PROC [server:
ROPE, system: Adobe2.Database, version:
CARD32, arSet: Adobe2.SetOfARs, fieldList: Adobe2.FieldList, to: CrRPC.BulkDataSink] ~ {
GetAcceleratorInfoOp: RemoteOperation ~ {
instance: Adobe2.StaticTarget ~ [[system], version];
Adobe2.GetAcceleratorInfo[crH, instance, arSet, fieldList, to];
};
Guarded[server, GetAcceleratorInfoOp];
};
GetSystemDefaultUserFile:
PUBLIC PROC [server:
ROPE, system: Adobe2.Database, to: CrRPC.BulkDataSink] ~ {
GetSystemDefaultUserFileOp: RemoteOperation ~ {
target: Adobe2.Target ~ [system];
Adobe2.GetSystemDefaultUserFile[crH, target, to];
};
Guarded[server, GetSystemDefaultUserFileOp];
};
Remote Operations (more complex)
AboutToStore:
PUBLIC PROC [server:
ROPE, system: Adobe2.Database, version:
CARD32, arNumber:
CARD32] ~ {
AboutToStoreOp: RemoteOperation ~ {
instance: Adobe2.StaticTarget ~ [[system], version];
Adobe2.AboutToStore[crH, instance, arNumber];
};
Guarded[server, AboutToStoreOp];
SubmitFailed:
PUBLIC PROC [server:
ROPE, system: Adobe2.Database, version:
CARD32, arNumber:
CARD32] ~ {
SubmitFailedOp: RemoteOperation ~ {
target: Adobe2.Target ~ [system];
Adobe2.SubmitFailed[crH, target, version, arNumber];
};
Guarded[server, SubmitFailedOp];
UpdateAcceleratorField:
PUBLIC PROC [server:
ROPE, system: Adobe2.Database, version:
CARD32, arNumber:
CARD32, field: Adobe2.FieldItemValue, fieldName:
ROPE] ~ {
UpdateAcceleratorFieldOp: RemoteOperation ~ {
instance: Adobe2.StaticTarget ~ [[system], version];
Adobe2.UpdateAcceleratorField[crH, instance, arNumber, field, fieldName];
};
Guarded[server, UpdateAcceleratorFieldOp];
GetNextSubmitNumber:
PUBLIC PROC [server:
ROPE, system: Adobe2.Database]
RETURNS [submitNumber: Adobe2.SubmitNumber ¬ 0] ~ {
GetNextSubmitNumberOp: RemoteOperation ~ {
target: Adobe2.Target ~ [system];
submitNumber ¬ Adobe2.GetNextSubmitNumber[crH, target];
};
Guarded[server, GetNextSubmitNumberOp];
};
PutSubmitNumber:
PUBLIC PROC [server:
ROPE, system: Adobe2.Database,
submitNumber: Adobe2.SubmitNumber] ~ {
PutSubmitNumberOp: RemoteOperation ~ {
target: Adobe2.Target ~ [system];
Adobe2.PutSubmitNumber[crH, target, submitNumber];
};
Guarded[server, PutSubmitNumberOp];
};
Commander Operations (system)
FieldTypeName: ARRAY Adobe2.FieldType OF ROPE ¬
["ar(0)", "time(1)", "numeric(2)", "bounded(3)", "enumerated(4)", "string(5)"];
PrintFieldList:
PROC [out:
IO.
STREAM, fieldList: Adobe2.FieldList] ~ {
FOR i:
CARDINAL IN [0..fieldList.length)
DO
item: Adobe2.FieldItemObject ~ fieldList.flSeq[i];
type: Adobe2.FieldType ~ item.type;
rope: ROPE ~ AdobeP75V2Aux.ExposeFieldItem[item, 1];
out.PutF["(%g) [%g]\n", IO.card[i], IO.rope[rope] ];
ENDLOOP;
};
GetDatabaseDescriptionCommand: Commander.CommandProc ~ {
cmd.out.PutF1["server: %g\n", IO.rope[server] ];
cmd.out.PutF1[" system/database: %g\n", IO.rope[system] ];
{
ENABLE {
StubError=> { msg ¬ whatsUp; GOTO Failed };
UnknownAddress => { msg ¬ "UnknownAddress"; GOTO Failed };
};
description: Adobe2.Description ¬ GetDatabaseDescription[server, system];
cmd.out.PutRope[" Description:\n"];
cmd.out.PutF1[" name:\t%g\n", IO.rope[description.name] ];
cmd.out.PutF1[" host:\t%g\n", IO.rope[description.host] ];
cmd.out.PutF1[" directory:\t%g\n", IO.rope[description.directory] ];
cmd.out.PutF1[" version:\t%g\n", IO.card[description.version] ];
cmd.out.PutF1[" fieldList:\t(%g) [\n",
IO.card[description.fieldList.length] ];
PrintFieldList[cmd.out, description.fieldList];
cmd.out.PutRope["\t]\n"];
};
EXITS Failed => { result ¬ $Failure };
};
GetLocationOfARsCommand: Commander.CommandProc ~ {
cmd.out.PutF1["server: %g\n", IO.rope[server] ];
cmd.out.PutF1[" system/database: %g\n", IO.rope[system] ];
{
ENABLE {
StubError=> { msg ¬ whatsUp; GOTO Failed };
UnknownAddress => { msg ¬ "UnknownAddress"; GOTO Failed };
};
referenceToARs: Adobe2.NSName ¬ GetLocationOfARs[server, system];
cmd.out.PutF[" Location of ARs: %g:%g:%g\n", IO.rope[referenceToARs.local], IO.rope[referenceToARs.domain], IO.rope[referenceToARs.org]];
};
EXITS Failed => { result ¬ $Failure };
};
GetVersionCommand: Commander.CommandProc ~ {
cmd.out.PutF1["server: %g\n", IO.rope[server] ];
cmd.out.PutF1[" system/database: %g\n", IO.rope[system] ];
{
ENABLE {
StubError=> { msg ¬ whatsUp; GOTO Failed };
UnknownAddress => { msg ¬ "UnknownAddress"; GOTO Failed };
};
version: Adobe2.ARVersion ¬ GetVersion[server, system];
cmd.out.PutF1[" version: %g\n", IO.card[version] ];
};
EXITS Failed => { result ¬ $Failure };
};
ReadLastARNumberCommand: Commander.CommandProc ~ {
cmd.out.PutF1["server: %g\n", IO.rope[server] ];
cmd.out.PutF1[" system/database: %g\n", IO.rope[system] ];
{
ENABLE {
StubError=> { msg ¬ whatsUp; GOTO Failed };
UnknownAddress => { msg ¬ "UnknownAddress"; GOTO Failed };
};
lastAR: Adobe2.ARNumber ¬ ReadLastARNumber[server, system];
cmd.out.PutF1[" lastAR: %g\n", IO.card[lastAR] ];
};
EXITS Failed => { result ¬ $Failure };
};
Commander Operations (using state)
currentAR: Adobe2.SubmitNumber ¬ 11;
cmd.out.PutF[" target/database: %g(%g)\n", IO.rope[system], IO.card[version] ];
instance: Adobe2.StaticTarget ~ [target, version];
GetNextSubmitNumberCommand: Commander.CommandProc ~ {
cmd.out.PutF1["server: %g\n", IO.rope[server] ];
cmd.out.PutF1[" system/database: %g\n", IO.rope[system] ];
{
ENABLE {
StubError=> { msg ¬ whatsUp; GOTO Failed };
UnknownAddress => { msg ¬ "UnknownAddress"; GOTO Failed };
};
target: Adobe2.Target ~ [system];
submitNumber: Adobe2.SubmitNumber ¬ GetNextSubmitNumber[server, target];
cmd.out.PutF1[" NextSubmitNumber: %g\n", IO.card[submitNumber] ];
currentAR ¬ submitNumber;
};
EXITS Failed => { result ¬ $Failure };
};
PutSubmitNumberCommand: Commander.CommandProc ~ {
cmd.out.PutF1["server: %g\n", IO.rope[server] ];
cmd.out.PutF1[" system/database: %g\n", IO.rope[system] ];
{
ENABLE {
StubError=> { msg ¬ whatsUp; GOTO Failed };
UnknownAddress => { msg ¬ "UnknownAddress"; GOTO Failed };
};
submitNumber: Adobe2.SubmitNumber ¬ currentAR;
PutSubmitNumber[server, system, submitNumber];
cmd.out.PutF1[" PutSubmitNumber: %g\n", IO.card[submitNumber] ];
};
currentAR ¬ currentAR.PRED; -- why?
EXITS Failed => { result ¬ $Failure };
};
NumQueryCommand: Commander.CommandProc ~ {
cmd.out.PutF1["server: %g\n", IO.rope[server] ];
cmd.out.PutF1[" system/database: %g\n", IO.rope[system] ];
{
ENABLE {
StubError=> { msg ¬ whatsUp; GOTO Failed };
UnknownAddress => { msg ¬ "UnknownAddress"; GOTO Failed };
};
value: Adobe2.FieldItemQueryValue ¬ [greaterThanOrEqual,
NEW[Adobe2.FieldItemValueRec.numeric ¬ [numeric[35]]]];
arSet: Adobe2.SetOfARs ¬ NEW[Adobe2.SetOfARsObject[1]];
arSet[0] ¬ [1,5];
arSet ¬ LookupARs[server, system, version, "Age", value, arSet];
cmd.out.PutRope[" result: \n"];
FOR i:
CARD IN [0..arSet.len)
DO
cmd.out.PutF[" %g-%g\n", IO.card[arSet[i].startValue], IO.card[arSet[i].startValue + arSet[i].runLength - 1] ];
ENDLOOP;
};
EXITS Failed => { result ¬ $Failure };
};
ARQueryCommand: Commander.CommandProc ~ {
cmd.out.PutF1["server: %g\n", IO.rope[server] ];
cmd.out.PutF1[" system/database: %g\n", IO.rope[system] ];
{
ENABLE {
StubError=> { msg ¬ whatsUp; GOTO Failed };
UnknownAddress => { msg ¬ "UnknownAddress"; GOTO Failed };
};
value: Adobe2.FieldItemQueryValue ¬ [greaterThanOrEqual,
NEW[Adobe2.FieldItemValueRec.arId ¬ [arId[3]]]];
arSet: Adobe2.SetOfARs ¬ NEW[Adobe2.SetOfARsObject[1]];
arSet[0] ¬ [1,5];
arSet ¬ LookupARs[server, system, version, "Number", value, arSet];
cmd.out.PutRope[" result: \n"];
FOR i:
CARD IN [0..arSet.len)
DO
cmd.out.PutF[" %g-%g\n", IO.card[arSet[i].startValue], IO.card[arSet[i].startValue + arSet[i].runLength - 1] ];
ENDLOOP;
};
EXITS Failed => { result ¬ $Failure };
};
EnumQueryCommand: Commander.CommandProc ~ {
cmd.out.PutF1["server: %g\n", IO.rope[server] ];
cmd.out.PutF1[" system/database: %g\n", IO.rope[system] ];
{
ENABLE {
StubError=> { msg ¬ whatsUp; GOTO Failed };
UnknownAddress => { msg ¬ "UnknownAddress"; GOTO Failed };
};
value: Adobe2.FieldItemQueryValue ¬ [equal,
NEW[Adobe2.FieldItemValueRec.enumerated ¬ [enumerated[2]]]];
arSet: Adobe2.SetOfARs ¬ NEW[Adobe2.SetOfARsObject[1]];
arSet[0] ¬ [1,5];
arSet ¬ LookupARs[server, system, version, "System", value, arSet];
cmd.out.PutRope[" result: \n"];
FOR i:
CARD IN [0..arSet.len)
DO
cmd.out.PutF[" %g-%g\n", IO.card[arSet[i].startValue], IO.card[arSet[i].startValue + arSet[i].runLength - 1] ];
ENDLOOP;
};
EXITS Failed => { result ¬ $Failure };
};
FixQueryCommand: Commander.CommandProc ~ {
cmd.out.PutF1["server: %g\n", IO.rope[server] ];
cmd.out.PutF1[" system/database: %g\n", IO.rope[system] ];
{
ENABLE {
StubError=> { msg ¬ whatsUp; GOTO Failed };
UnknownAddress => { msg ¬ "UnknownAddress"; GOTO Failed };
};
value: Adobe2.FieldItemQueryValue ¬ [in,
NEW[Adobe2.FieldItemValueRec.fixedLengthString ¬ [fixedLengthString["pj", 60]]]];
arSet: Adobe2.SetOfARs ¬ NEW[Adobe2.SetOfARsObject[1]];
arSet[0] ¬ [1,5];
arSet ¬ LookupARs[server, system, version, "Assigned To", value, arSet];
cmd.out.PutRope[" result: \n"];
FOR i:
CARD IN [0..arSet.len)
DO
cmd.out.PutF[" %g-%g\n", IO.card[arSet[i].startValue], IO.card[arSet[i].startValue + arSet[i].runLength - 1] ];
ENDLOOP;
};
EXITS Failed => { result ¬ $Failure };
};
PutC:
PROCEDURE [c:
CHAR] ~ {
SELECT c
FROM
IN['A..'Z],
IN['a..'z],
IN['0..'9] => globalCmd.out.PutF1["%g ", IO.char[c]];
ENDCASE => globalCmd.out.PutF1["/%gD ", IO.card[ORD[c]]];
};
To: CrRPC.BulkDataSink ~ {
len, line, field: CARD ¬ 0;
b1, b2: CARD ¬ 0;
IF checkAbort[h]
THEN {
globalCmd.out.PutRope["Instant Abort.\n"];
RETURN[FALSE];
};
IF IO.EndOf[s]
THEN {
globalCmd.out.PutRope["Empty stream.\n"];
RETURN[FALSE];
};
line ¬ 1;
WHILE NOT IO.EndOf[s]
DO
IF field > 3
THEN {
field ¬ 0;
line ¬ line + 1;
IO.PutF1[globalCmd.out, "line: %g\n", IO.card[line]];
};
IO.PutF1[globalCmd.out, "\tfield: %g ", IO.card[field]];
b1 ¬ ORD[IO.GetByte[s]];
b2 ¬ ORD[IO.GetByte[s]];
IO.PutF[globalCmd.out, "\b1: %g b2: %g", IO.card[b1], IO.card[b2]];
len ¬ (b1 * (ORD[LAST[CHAR]] + 1)) + b2;
IO.PutF1[globalCmd.out, "(len = %g)\n", IO.card[len]];
FOR i:
CARD IN [0..len)
DO
PutC[IO.GetChar[s]];
ENDLOOP;
IO.PutRope[globalCmd.out, "\n"];
IF (len
MOD 2) = 1
THEN
[] ¬ IO.GetChar[s];
ENDLOOP;
RETURN[FALSE];
};
globalCmd: Commander.Handle ¬ NIL;
GetAccInfoCommand: Commander.CommandProc ~ {
cmd.out.PutF1["server: %g\n", IO.rope[server] ];
cmd.out.PutF1[" system/database: %g\n", IO.rope[system] ];
{
ENABLE {
StubError=> { msg ¬ whatsUp; GOTO Failed };
UnknownAddress => { msg ¬ "UnknownAddress"; GOTO Failed };
};
accInfo: Adobe2.AcceleratorInfo ← NIL;
arSet: Adobe2.SetOfARs ¬ NEW[Adobe2.SetOfARsObject[1]];
fieldList: Adobe2.FieldList ¬ NEW[Adobe2.FieldListArray[4]];
globalCmd ¬ cmd;
fieldList[0]¬ NEW[Adobe2.FieldItemObjectRec.arId];
fieldList[0].name ¬ "Number";
fieldList[1]¬ NEW[Adobe2.FieldItemObjectRec.arId];
fieldList[1].name ¬ "System";
fieldList[2]¬ NEW[Adobe2.FieldItemObjectRec.arId];
fieldList[2].name ¬ "Subsystem";
fieldList[3]¬ NEW[Adobe2.FieldItemObjectRec.arId];
fieldList[3].name ¬ "Subject";
arSet[0] ¬ [1,5];
GetAcceleratorInfo[server, system, version, arSet, fieldList, To];
FOR i: CARD IN [0..accInfo.len) DO
IO.PutF[cmd.out, "AR #%g\n", IO.card[i]];
FOR j: CARD IN [0..accInfo[i].len) DO
IO.PutF[cmd.out, "\tField #%g: %g\n", IO.card[j], IO.rope[accInfo[i][j]]];
ENDLOOP;
ENDLOOP;
};
EXITS Failed => { result ¬ $Failure };
};
GetDefaultUserFileCommand: Commander.CommandProc ~ {
cmd.out.PutF1["server: %g\n", IO.rope[server] ];
cmd.out.PutF1[" system/database: %g\n", IO.rope[system] ];
{
ENABLE {
StubError=> { msg ¬ whatsUp; GOTO Failed };
UnknownAddress => { msg ¬ "UnknownAddress"; GOTO Failed };
};
GDUSink: CrRPC.BulkDataSink = {
IF checkAbort[h]
THEN {
cmd.out.PutRope["Instant Abort.\n"];
RETURN[FALSE];
};
IF IO.EndOf[s]
THEN {
cmd.out.PutRope["Empty stream.\n"];
RETURN[FALSE];
};
WHILE NOT IO.EndOf[s]
DO
cmd.out.PutF1["%g ", IO.char[IO.GetChar[s]]];
ENDLOOP;
RETURN[FALSE];
GetSystemDefaultUserFile[server, system, GDUSink];
};
EXITS Failed => { result ¬ $Failure };
};
Init:
PROC ~ {
Commander.Register["XNSAdobe.GetDatabaseDescription", GetDatabaseDescriptionCommand];
Commander.Register["XNSAdobe.GetDefaultUserFile", GetDefaultUserFileCommand];
Commander.Register["XNSAdobe.GetLocationOfARs", GetLocationOfARsCommand];
Commander.Register["XNSAdobe.GetNextSubmitNumber", GetNextSubmitNumberCommand];
Commander.Register["XNSAdobe.GetVersion", GetVersionCommand];
Commander.Register["XNSAdobe.ListDatabases", ListDatabasesCommand];
Commander.Register["XNSAdobe.PutSubmitNumber", PutSubmitNumberCommand];
Commander.Register["XNSAdobe.ReadLastARNumber", ReadLastARNumberCommand];
Commander.Register["XNSAdobe.NumQuery", NumQueryCommand];
Commander.Register["XNSAdobe.ARQuery", ARQueryCommand];
Commander.Register["XNSAdobe.EnumQuery", EnumQueryCommand];
Commander.Register["XNSAdobe.FixQuery", FixQueryCommand];
Commander.Register["XNSAdobe.GetAccInfo", GetAccInfoCommand];
};
}.