-- TabPostOfficeGetPutImpl.mesa
-- Please do not edit this file.
-- It was generated using CedarRPCGen.

DIRECTORY
  Rope,
  SunRPC,
  TabPostOffice,
  TabPostOfficeGetPut;

TabPostOfficeGetPutImpl: CEDAR PROGRAM
  IMPORTS SunRPC  EXPORTS TabPostOffice, TabPostOfficeGetPut =
BEGIN
Handle: TYPE = SunRPC.Handle;

ROPE: TYPE = Rope.ROPE;

GetErrorInfo: PUBLIC PROC[h: Handle] RETURNS [res: TabPostOffice.ErrorInfo] = {
    res.errno ← SunRPC.GetInt32[h];
    res.msg ← SunRPC.GetRope[h];
  };

PutErrorInfo: PUBLIC PROC[h: Handle, in: TabPostOffice.ErrorInfo] = {
    SunRPC.PutInt32[h, in.errno];
    SunRPC.PutRope[h, in.msg];
  };

GetProperty: PUBLIC PROC[h: Handle] RETURNS [res: TabPostOffice.Property] = {
    res ← SunRPC.GetRope[h];
  };

PutProperty: PUBLIC PROC[h: Handle, in: TabPostOffice.Property] = {
    SunRPC.PutRope[h, in];
  };

GetRelation: PUBLIC PROC[h: Handle] RETURNS [res: TabPostOffice.Relation] = {
    res ← SunRPC.GetRope[h];
  };

PutRelation: PUBLIC PROC[h: Handle, in: TabPostOffice.Relation] = {
    SunRPC.PutRope[h, in];
  };

GetValue: PUBLIC PROC[h: Handle] RETURNS [res: TabPostOffice.Value] = {
    res ← SunRPC.GetRope[h];
  };

PutValue: PUBLIC PROC[h: Handle, in: TabPostOffice.Value] = {
    SunRPC.PutRope[h, in];
  };

GetPropertyArray: PUBLIC PROC[h: Handle] RETURNS [res: TabPostOffice.PropertyArray] = {
    {
    len: INT ← SunRPC.GetInt32[h];
    res ← NEW[TabPostOffice.SeqType0Object[len]];
    FOR i: INT IN [0..len) DO
      res[i] ← GetProperty[h];
      ENDLOOP;
    };
  };

PutPropertyArray: PUBLIC PROC[h: Handle, in: TabPostOffice.PropertyArray] = {
    SunRPC.PutInt32[h, in.size];
    FOR i: INT IN [0..in.size) DO
      PutProperty[h, in[i]];
      ENDLOOP;
  };

GetPropInfo: PUBLIC PROC[h: Handle] RETURNS [res: TabPostOffice.PropInfo] = {
    res.p ← GetProperty[h];
    res.r ← GetRelation[h];
    res.v ← GetValue[h];
  };

PutPropInfo: PUBLIC PROC[h: Handle, in: TabPostOffice.PropInfo] = {
    PutProperty[h, in.p];
    PutRelation[h, in.r];
    PutValue[h, in.v];
  };

GetPropInfoArray: PUBLIC PROC[h: Handle] RETURNS [res: TabPostOffice.PropInfoArray] = {
    {
    len: INT ← SunRPC.GetInt32[h];
    res ← NEW[TabPostOffice.SeqType1Object[len]];
    FOR i: INT IN [0..len) DO
      res[i] ← GetPropInfo[h];
      ENDLOOP;
    };
  };

PutPropInfoArray: PUBLIC PROC[h: Handle, in: TabPostOffice.PropInfoArray] = {
    SunRPC.PutInt32[h, in.size];
    FOR i: INT IN [0..in.size) DO
      PutPropInfo[h, in[i]];
      ENDLOOP;
  };

GetMsgID: PUBLIC PROC[h: Handle] RETURNS [res: TabPostOffice.MsgID] = {
    res ← SunRPC.GetInt32[h];
  };

PutMsgID: PUBLIC PROC[h: Handle, in: TabPostOffice.MsgID] = {
    SunRPC.PutInt32[h, in];
  };

GetPriority: PUBLIC PROC[h: Handle] RETURNS [res: TabPostOffice.Priority] = {
    res ← SunRPC.GetInt32[h];
  };

PutPriority: PUBLIC PROC[h: Handle, in: TabPostOffice.Priority] = {
    SunRPC.PutInt32[h, in];
  };

GetFilter: PUBLIC PROC[h: Handle] RETURNS [res: TabPostOffice.Filter] = {
    res ← SunRPC.GetRope[h];
  };

PutFilter: PUBLIC PROC[h: Handle, in: TabPostOffice.Filter] = {
    SunRPC.PutRope[h, in];
  };

GetFilterSet: PUBLIC PROC[h: Handle] RETURNS [res: TabPostOffice.FilterSet] = {
    {
    len: INT ← SunRPC.GetInt32[h];
    res ← NEW[TabPostOffice.SeqType2Object[len]];
    FOR i: INT IN [0..len) DO
      res[i] ← GetFilter[h];
      ENDLOOP;
    };
  };

PutFilterSet: PUBLIC PROC[h: Handle, in: TabPostOffice.FilterSet] = {
    SunRPC.PutInt32[h, in.size];
    FOR i: INT IN [0..in.size) DO
      PutFilter[h, in[i]];
      ENDLOOP;
  };

GetFolder: PUBLIC PROC[h: Handle] RETURNS [res: TabPostOffice.Folder] = {
    res ← SunRPC.GetRope[h];
  };

PutFolder: PUBLIC PROC[h: Handle, in: TabPostOffice.Folder] = {
    SunRPC.PutRope[h, in];
  };

GetFolders: PUBLIC PROC[h: Handle] RETURNS [res: TabPostOffice.Folders] = {
    {
    len: INT ← SunRPC.GetInt32[h];
    res ← NEW[TabPostOffice.SeqType3Object[len]];
    FOR i: INT IN [0..len) DO
      res[i] ← GetFolder[h];
      ENDLOOP;
    };
  };

PutFolders: PUBLIC PROC[h: Handle, in: TabPostOffice.Folders] = {
    SunRPC.PutInt32[h, in.size];
    FOR i: INT IN [0..in.size) DO
      PutFolder[h, in[i]];
      ENDLOOP;
  };

GetTime: PUBLIC PROC[h: Handle] RETURNS [res: TabPostOffice.Time] = {
    res ← SunRPC.GetInt32[h];
  };

PutTime: PUBLIC PROC[h: Handle, in: TabPostOffice.Time] = {
    SunRPC.PutInt32[h, in];
  };

StatusNames: PUBLIC ARRAY TabPostOffice.Status OF ROPE ← [
	"New",
	"Unread",
	"Read"
	];

GetStatus: PUBLIC PROC[h: Handle] RETURNS [res: TabPostOffice.Status] = {
    res ← VAL[SunRPC.GetInt32[h]];
  };

PutStatus: PUBLIC PROC[h: Handle, in: TabPostOffice.Status] = {
    SunRPC.PutInt32[h, ORD[in]];
  };

WhencesNames: PUBLIC ARRAY TabPostOffice.Whences OF ROPE ← [
	"BOM",
	"BOB"
	];

GetWhences: PUBLIC PROC[h: Handle] RETURNS [res: TabPostOffice.Whences] = {
    res ← VAL[SunRPC.GetInt32[h]];
  };

PutWhences: PUBLIC PROC[h: Handle, in: TabPostOffice.Whences] = {
    SunRPC.PutInt32[h, ORD[in]];
  };

GetSessionInfo: PUBLIC PROC[h: Handle] RETURNS [res: TabPostOffice.SessionInfo] = {
    res.numselects ← SunRPC.GetInt32[h];
    res.plist ← GetPropInfoArray[h];
    res.numorders ← SunRPC.GetInt32[h];
    res.olist ← GetPropertyArray[h];
  };

PutSessionInfo: PUBLIC PROC[h: Handle, in: TabPostOffice.SessionInfo] = {
    SunRPC.PutInt32[h, in.numselects];
    PutPropInfoArray[h, in.plist];
    SunRPC.PutInt32[h, in.numorders];
    PutPropertyArray[h, in.olist];
  };

GetSessionResult: PUBLIC PROC[h: Handle] RETURNS [res: TabPostOffice.SessionResult] = {
    res.total ← SunRPC.GetInt32[h];
    res.new ← SunRPC.GetInt32[h];
    res.unread ← SunRPC.GetInt32[h];
    res.loPri ← GetPriority[h];
    res.hiPri ← GetPriority[h];
    res.lastModifyTime ← GetTime[h];
    res.lastAccessTime ← GetTime[h];
    res.e ← GetErrorInfo[h];
  };

PutSessionResult: PUBLIC PROC[h: Handle, in: TabPostOffice.SessionResult] = {
    SunRPC.PutInt32[h, in.total];
    SunRPC.PutInt32[h, in.new];
    SunRPC.PutInt32[h, in.unread];
    PutPriority[h, in.loPri];
    PutPriority[h, in.hiPri];
    PutTime[h, in.lastModifyTime];
    PutTime[h, in.lastAccessTime];
    PutErrorInfo[h, in.e];
  };

GetMsgIDRange: PUBLIC PROC[h: Handle] RETURNS [res: TabPostOffice.MsgIDRange] = {
    res.beginId ← GetMsgID[h];
    res.endId ← GetMsgID[h];
  };

PutMsgIDRange: PUBLIC PROC[h: Handle, in: TabPostOffice.MsgIDRange] = {
    PutMsgID[h, in.beginId];
    PutMsgID[h, in.endId];
  };

GetMsgInfo: PUBLIC PROC[h: Handle] RETURNS [res: TabPostOffice.MsgInfo] = {
    res.msgId ← GetMsgID[h];
    res.from ← SunRPC.GetRope[h];
    res.to ← SunRPC.GetRope[h];
    res.cc ← SunRPC.GetRope[h];
    res.date ← SunRPC.GetRope[h];
    res.subject ← SunRPC.GetRope[h];
    res.priority ← GetPriority[h];
    res.filters ← GetFilterSet[h];
    res.status ← GetStatus[h];
    res.bodyLength ← SunRPC.GetInt32[h];
    res.bodyLines ← SunRPC.GetInt32[h];
  };

PutMsgInfo: PUBLIC PROC[h: Handle, in: TabPostOffice.MsgInfo] = {
    PutMsgID[h, in.msgId];
    SunRPC.PutRope[h, in.from];
    SunRPC.PutRope[h, in.to];
    SunRPC.PutRope[h, in.cc];
    SunRPC.PutRope[h, in.date];
    SunRPC.PutRope[h, in.subject];
    PutPriority[h, in.priority];
    PutFilterSet[h, in.filters];
    PutStatus[h, in.status];
    SunRPC.PutInt32[h, in.bodyLength];
    SunRPC.PutInt32[h, in.bodyLines];
  };

GetMsgInfos: PUBLIC PROC[h: Handle] RETURNS [res: TabPostOffice.MsgInfos] = {
    {
    len: INT ← SunRPC.GetInt32[h];
    res ← NEW[TabPostOffice.SeqType4Object[len]];
    FOR i: INT IN [0..len) DO
      res[i] ← GetMsgInfo[h];
      ENDLOOP;
    };
  };

PutMsgInfos: PUBLIC PROC[h: Handle, in: TabPostOffice.MsgInfos] = {
    SunRPC.PutInt32[h, in.size];
    FOR i: INT IN [0..in.size) DO
      PutMsgInfo[h, in[i]];
      ENDLOOP;
  };

GetMsgInfoResult: PUBLIC PROC[h: Handle] RETURNS [res: TabPostOffice.MsgInfoResult] = {
    res.info ← GetMsgInfos[h];
    res.e ← GetErrorInfo[h];
  };

PutMsgInfoResult: PUBLIC PROC[h: Handle, in: TabPostOffice.MsgInfoResult] = {
    PutMsgInfos[h, in.info];
    PutErrorInfo[h, in.e];
  };

GetMsgTextInfo: PUBLIC PROC[h: Handle] RETURNS [res: TabPostOffice.MsgTextInfo] = {
    res.msgId ← GetMsgID[h];
    res.beginByte ← SunRPC.GetInt32[h];
    res.numBytes ← SunRPC.GetInt32[h];
    res.whence ← GetWhences[h];
  };

PutMsgTextInfo: PUBLIC PROC[h: Handle, in: TabPostOffice.MsgTextInfo] = {
    PutMsgID[h, in.msgId];
    SunRPC.PutInt32[h, in.beginByte];
    SunRPC.PutInt32[h, in.numBytes];
    PutWhences[h, in.whence];
  };

GetMsgTextResult: PUBLIC PROC[h: Handle] RETURNS [res: TabPostOffice.MsgTextResult] = {
    res.body ← SunRPC.GetRope[h];
    res.e ← GetErrorInfo[h];
  };

PutMsgTextResult: PUBLIC PROC[h: Handle, in: TabPostOffice.MsgTextResult] = {
    SunRPC.PutRope[h, in.body];
    PutErrorInfo[h, in.e];
  };

GetNewMailResult: PUBLIC PROC[h: Handle] RETURNS [res: TabPostOffice.NewMailResult] = {
    res.newMail ← SunRPC.GetInt32[h] # 0;
    res.e ← GetErrorInfo[h];
  };

PutNewMailResult: PUBLIC PROC[h: Handle, in: TabPostOffice.NewMailResult] = {
    SunRPC.PutInt32[h, IF in.newMail THEN 1 ELSE 0];
    PutErrorInfo[h, in.e];
  };

GetFoldersResult: PUBLIC PROC[h: Handle] RETURNS [res: TabPostOffice.FoldersResult] = {
    res.folders ← GetFolders[h];
    res.numFolders ← SunRPC.GetInt32[h];
    res.e ← GetErrorInfo[h];
  };

PutFoldersResult: PUBLIC PROC[h: Handle, in: TabPostOffice.FoldersResult] = {
    PutFolders[h, in.folders];
    SunRPC.PutInt32[h, in.numFolders];
    PutErrorInfo[h, in.e];
  };

GetMark: PUBLIC PROC[h: Handle] RETURNS [res: TabPostOffice.Mark] = {
    res.msgId ← GetMsgID[h];
    res.markID ← SunRPC.GetRope[h];
    res.markMsg ← SunRPC.GetRope[h];
  };

PutMark: PUBLIC PROC[h: Handle, in: TabPostOffice.Mark] = {
    PutMsgID[h, in.msgId];
    SunRPC.PutRope[h, in.markID];
    SunRPC.PutRope[h, in.markMsg];
  };

END.