/**********************************************************************
 * luc_add_trn.c -- add a transaction to a chain
 *
 * $Author: brlewis $
 * $Source: /afs/athena.mit.edu/astaff/project/lucydev/src/lib/RCS/luc_add_trn.c,v $
 * $Header: /afs/athena.mit.edu/astaff/project/lucydev/src/lib/RCS/luc_add_trn.c,v 1.1 91/08/01 14:28:11 brlewis Exp Locker: brlewis $
 *
 * Copyright 1991 by the Massachusetts Institute of Technology.
 *
 * For copying and distribution information, please see the file
 * <mit-copyright.h>.
 **********************************************************************/
#include <mit-copyright.h>

#ifndef lint
static char rcsid_luc_add_trn_c[] = "$Header: /afs/athena.mit.edu/astaff/project/lucydev/src/lib/RCS/luc_add_trn.c,v 1.1 91/08/01 14:28:11 brlewis Exp Locker: brlewis $";
#endif /* lint */

#include <stdio.h>
#include <strings.h>
#include <sys/errno.h>
#include <sys/file.h>
#include "lucy/lucy.h"
#include "lucy/memory.h"

/**********************************************************************
 * luc_add_trn(mp, filename, subject, signature, inreplyto, np)
 *	caller sets mp (usually luv_curmtgp) to specify meeting
 *	caller sets filename to file containing text of trn
 *	caller sets subject
 *	caller sets signature, usually luc_fullname(mp->nb.user_id)
 *		or NULL if no signature
 *	caller sets inreplyto if this is to be added to a chain
 *
 * - essentially an abstraction for dsc_add_trn2
 * - points np at new trn number
 * - returns error code
 **********************************************************************/

long
luc_add_trn(mp, filename, subject, signature, inreplyto, np)
     LMEETING *mp;
     char *filename, *subject, *signature;
     int inreplyto, *np;
{
  long code;
  tfile tf;
  FILE *fp;

  fp = fopen(filename, "r");
  if (!fp) {
    strcpy(luv_context, filename);
    return((long) errno);
  }
  tf = unix_tfile(fp->_file);
  dsc_add_trn2(&(mp->nb), tf, subject, signature, inreplyto, np, &code);
  (void) fclose(fp);		/* ret val doesn't matter on read-only */
  return(code);

}
