/**********************************************************************
 * luc_chain.c -- mark flags for transaction
 *
 * $Author: brlewis $
 * $Source: /afs/athena.mit.edu/astaff/project/lucydev/src/lib/RCS/luc_chain.c,v $
 * $Header: /afs/athena.mit.edu/astaff/project/lucydev/src/lib/RCS/luc_chain.c,v 1.1 91/09/24 14:33:26 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_chain_c[] = "$Header: /afs/athena.mit.edu/astaff/project/lucydev/src/lib/RCS/luc_chain.c,v 1.1 91/09/24 14:33:26 brlewis Exp Locker: brlewis $";
#endif /* lint */

#include "lucy/lucy.h"

/**********************************************************************
 * luc_chain(LMEETING *mp, int n1, int n2, int *np)
 *	caller sets mp (usually luv_curmtgp) to specify meeting
 *	caller sets n1, n2 to specify transaction numbers
 *
 * - appends copy of n2 to chain of n1
 * - deletes n2
 * - points np at new trn number
 * - returns error code
 * It is recommended that luc_reset_mtg() be called shortly after
 * luc_chain() in order to correct cached trn info.
 **********************************************************************/

long
luc_chain(mp, n1, n2, np)
     LMEETING *mp;
     int n1, n2, *np;
{
  long code;
  ltrn *info;
  char *fname;

  /* get subject line, etc */
  if (code = luc_trn_info(mp, n2, &info)) return(code);

  /* get text of trn */
  if (code = luc_trn_file(mp, n2, &fname)) return(code);

  /* add it to the chain */
  code = luc_add_trn(mp, fname, info->subject, info->signature, n1, np);
  luc_free_file(&fname);
  if (code) return(code);

  /* delete the old one */
  return(luc_delete(mp, n2));
}
