RCS_ID_C="$Id: resource.c,v 2.1 1994/02/17 12:09:16 ppessi Exp $";
/*
 * resource.c -- handle credential resource
 *
 * Author: ppessi <Pekka.Pessi@hut.fi>
 *
 * This file is part of the AmiTCP/IP usergroup.library.
 *
 * Copyright © 1993 AmiTCP/IP Group, <AmiTCP-Group@hut.fi>
 *                  Helsinki University of Technology, Finland.
 *
 * Created      : Tue Jan 18 10:53:56 1994 ppessi
 * Last modified: Thu Feb 17 07:31:07 1994 ppessi
 *
 */

#include "base.h"
#include <exec/memory.h>

#include "credential.h"
#include "credential_rev.h"

/*
 * Create credential resource
 *
 * Note - this is mindless single-user-version
 */
struct CredentialResource *CredentialInit(const char *name)
{
  struct CredentialResource *res;
  ULONG ressize = sizeof(*res) + sizeof(VSTRING);

  res = AllocVec(ressize, MEMF_CLEAR|MEMF_PUBLIC);

  CopyMem(CREDENTIALNAME, res->r_name, sizeof(CREDENTIALNAME));
  CopyMem(VSTRING, res->r_vstring, sizeof(VSTRING));

  res->r_Lib.lib_Node.ln_Type = NT_RESOURCE;
  res->r_Lib.lib_Node.ln_Name =  (STRPTR)res->r_name;
  res->r_Lib.lib_Flags = LIBF_SUMUSED | LIBF_CHANGED;
  /* res->r_Lib.lib_NegSize = 0; */
  res->r_Lib.lib_PosSize = ressize;
  res->r_Lib.lib_Version = VERSION;
  res->r_Lib.lib_Revision = REVISION;
  res->r_Lib.lib_IdString = (APTR)res->r_vstring;
  /* res->r_Lib.lib_Sum = 0; */
  res->r_Lib.lib_OpenCnt = 1;

  res->r_proc->p_ucred = res->r_ucred;
  res->r_proc->p_cred->p_ngroups = 1;

  AddResource(res);

  return res;
}

struct proc *procfind(pid_t pid)
{
  return CredentialBase->r_proc;
}

struct ucred *crcopy(struct ucred *cred)
{
  return cred;
}
