-- File [Ivy]<Nelson>Lupine>LupineMarshalTestBinder.mesa.
-- Last edited by BZM on 12-May-82 19:35:26.


DIRECTORY
  LupineMarshalTestRpcControl USING [
  	ImportInterface, UnimportInterface,
	ExportInterface, UnexportInterface ],
  RPC USING [ExportFailed, ImportFailed, InterfaceName, MakeKey],
  Runtime USING [IsBound];


LupineMarshalTestBinder: PROGRAM
  IMPORTS
	clientControl: LupineMarshalTestRpcControl,
	serverControl: LupineMarshalTestRpcControl,
	RPC: RPC, Runtime  =
  BEGIN


-- Remote Binding Routines for LupineMarshalTest.

  BindingFailed: SIGNAL [{import, export}] = CODE;
  
  MarshalTestInterface: RPC.InterfaceName = [instance: "Nelson.PA"];

  ImportTestProgram: PROC = 
    BEGIN
    IF ~Runtime.IsBound[RPC.ImportFailed] THEN RETURN;
    IF Runtime.IsBound[clientControl.ImportInterface]
      THEN clientControl.ImportInterface [
		interfaceName: MarshalTestInterface
	     ! RPC.ImportFailed => {SIGNAL BindingFailed[import]; RETRY} ];
    END;

  ExportTestProgram: PROC = 
    BEGIN
    IF ~Runtime.IsBound[RPC.ExportFailed] THEN RETURN;
    IF Runtime.IsBound[serverControl.ExportInterface]
      THEN serverControl.ExportInterface [
		interfaceName: MarshalTestInterface,
		user: "RPCRuntime.PA",
		password: RPC.MakeKey["zzy"]
	     ! RPC.ExportFailed => {SIGNAL BindingFailed[export]; RETRY} ];
    END;

  UnimportTestProgram: PROC = 
    BEGIN
    IF ~Runtime.IsBound[RPC.ImportFailed] THEN RETURN;
    IF Runtime.IsBound[clientControl.UnimportInterface]
      THEN clientControl.UnimportInterface;
    END;

  UnexportTestProgram: PROC = 
    BEGIN
    IF ~Runtime.IsBound[RPC.ExportFailed] THEN RETURN;
    IF Runtime.IsBound[serverControl.UnexportInterface]
      THEN serverControl.UnexportInterface;
    END;



-- Module Initialization.

  -- This one module is used for both importing and exporting, and can be
  -- used in clients, servers, or both combined.

  ExportTestProgram[];  -- Try to export.
  ImportTestProgram[];  -- Try to import.
  

END.  -- LupineMarshalTestBinder.