-- Copyright (C) 1984, 1985  by Xerox Corporation. All rights reserved. 
-- NameUpdateDefs.mesa:  defs for updates to the database

-- HGM, 14-Sep-85 22:30:59
-- Andrew Birrell  August 27, 1982 3:10 pm

DIRECTORY
  BodyDefs USING [Connect, Password, Remark, RName],
  ProtocolDefs USING [MakeKey, RSOperation],
  NameInfoDefs USING [Outcome];

NameUpdateDefs: DEFINITIONS IMPORTS ProtocolDefs =

  BEGIN

  -- Replicated from ProtocolDefs --

  MakeKey: PROC [text: LONG STRING] RETURNS [BodyDefs.Password] = INLINE {
    RETURN[ProtocolDefs.MakeKey[text]]};




  -- Private subroutines --

  Update: PRIVATE PROC [
    user: BodyDefs.RName, password: BodyDefs.Password,
    op: ProtocolDefs.RSOperation, target: BodyDefs.RName, value: LONG STRING ← NIL,
    newPwd: BodyDefs.Password ← [, , , ], reporter: PROC [LONG STRING] ← NIL]
    RETURNS [NameInfoDefs.Outcome];




  -- Creation and Deletion --

  CreateIndividual: PROC [
    user: BodyDefs.RName, password: BodyDefs.Password, individual: BodyDefs.RName,
    newPwd: BodyDefs.Password ← [0, 0, 0, 0]] RETURNS [NameInfoDefs.Outcome] =
    INLINE {
    RETURN[Update[user, password, CreateIndividual, individual, NIL, newPwd]]};

  DeleteIndividual: PROC [
    user: BodyDefs.RName, password: BodyDefs.Password, individual: BodyDefs.RName]
    RETURNS [NameInfoDefs.Outcome] = INLINE {
    RETURN[Update[user, password, DeleteIndividual, individual]]};

  CreateGroup: PROC [
    user: BodyDefs.RName, password: BodyDefs.Password, group: BodyDefs.RName]
    RETURNS [NameInfoDefs.Outcome] = INLINE {
    RETURN[Update[user, password, CreateGroup, group]]};

  DeleteGroup: PROC [
    user: BodyDefs.RName, password: BodyDefs.Password, group: BodyDefs.RName]
    RETURNS [NameInfoDefs.Outcome] = INLINE {
    RETURN[Update[user, password, DeleteGroup, group]]};




  -- Updates to single-valued components --

  SetPassword: PROC [
    user: BodyDefs.RName, password: BodyDefs.Password, individual: BodyDefs.RName,
    newPwd: BodyDefs.Password] RETURNS [NameInfoDefs.Outcome] = INLINE {
    RETURN[Update[user, password, ChangePassword, individual, NIL, newPwd]]};

  SetConnect: PROC [
    user: BodyDefs.RName, password: BodyDefs.Password, individual: BodyDefs.RName,
    connect: BodyDefs.Connect] RETURNS [NameInfoDefs.Outcome] = INLINE {
    RETURN[Update[user, password, ChangeConnect, individual, connect]]};

  SetRemark: PROC [
    user: BodyDefs.RName, password: BodyDefs.Password, group: BodyDefs.RName,
    remark: BodyDefs.Remark] RETURNS [NameInfoDefs.Outcome] = INLINE {
    RETURN[Update[user, password, ChangeRemark, group, remark]]};




  -- Adding to list-valued components --

  AddMailbox: PROC [
    user: BodyDefs.RName, password: BodyDefs.Password, individual: BodyDefs.RName,
    site: BodyDefs.RName] RETURNS [NameInfoDefs.Outcome] = INLINE {
    RETURN[Update[user, password, AddMailBox, individual, site]]};

  AddForward: PROC [
    user: BodyDefs.RName, password: BodyDefs.Password, individual: BodyDefs.RName,
    dest: BodyDefs.RName] RETURNS [NameInfoDefs.Outcome] = INLINE {
    RETURN[Update[user, password, AddForward, individual, dest]]};

  AddMember: PROC [
    user: BodyDefs.RName, password: BodyDefs.Password, group: BodyDefs.RName,
    member: BodyDefs.RName] RETURNS [NameInfoDefs.Outcome] = INLINE {
    RETURN[Update[user, password, AddMember, group, member]]};

  AddOwner: PROC [
    user: BodyDefs.RName, password: BodyDefs.Password, group: BodyDefs.RName,
    owner: BodyDefs.RName] RETURNS [NameInfoDefs.Outcome] = INLINE {
    RETURN[Update[user, password, AddOwner, group, owner]]};

  AddFriend: PROC [
    user: BodyDefs.RName, password: BodyDefs.Password, group: BodyDefs.RName,
    friend: BodyDefs.RName] RETURNS [NameInfoDefs.Outcome] = INLINE {
    RETURN[Update[user, password, AddFriend, group, friend]]};




  -- Removing from list-valued components --

  RemoveMailbox: PROC [
    user: BodyDefs.RName, password: BodyDefs.Password, individual: BodyDefs.RName,
    site: BodyDefs.RName] RETURNS [NameInfoDefs.Outcome] = INLINE {
    RETURN[Update[user, password, DeleteMailBox, individual, site]]};

  RemoveForward: PROC [
    user: BodyDefs.RName, password: BodyDefs.Password, individual: BodyDefs.RName,
    dest: BodyDefs.RName] RETURNS [NameInfoDefs.Outcome] = INLINE {
    RETURN[Update[user, password, DeleteForward, individual, dest]]};

  RemoveMember: PROC [
    user: BodyDefs.RName, password: BodyDefs.Password, group: BodyDefs.RName,
    member: BodyDefs.RName] RETURNS [NameInfoDefs.Outcome] = INLINE {
    RETURN[Update[user, password, DeleteMember, group, member]]};

  RemoveOwner: PROC [
    user: BodyDefs.RName, password: BodyDefs.Password, group: BodyDefs.RName,
    owner: BodyDefs.RName] RETURNS [NameInfoDefs.Outcome] = INLINE {
    RETURN[Update[user, password, DeleteOwner, group, owner]]};

  RemoveFriend: PROC [
    user: BodyDefs.RName, password: BodyDefs.Password, group: BodyDefs.RName,
    friend: BodyDefs.RName] RETURNS [NameInfoDefs.Outcome] = INLINE {
    RETURN[Update[user, password, DeleteFriend, group, friend]]};


  END.