/**********************************************************************
 * luc_reply.c -- reply to a transaction
 *
 * $Author: brlewis $
 * $Source: /afs/athena.mit.edu/astaff/project/lucydev/src/lib/RCS/luc_reply.c,v $
 * $Header: /afs/athena.mit.edu/astaff/project/lucydev/src/lib/RCS/luc_reply.c,v 1.2 91/10/15 16:45:23 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_reply_c[] = "$Header: /afs/athena.mit.edu/astaff/project/lucydev/src/lib/RCS/luc_reply.c,v 1.2 91/10/15 16:45:23 brlewis Exp Locker: brlewis $";
#endif /* lint */

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

/**********************************************************************
 * luc_reply(lmeeting *mp, int n, char *rcpt)
 *	caller sets mp (usually luv_curmtgp) to specify meeting
 *	caller sets n to specify transaction number
 *	caller sets rcpt to email address
 *
 * - returns error code
 **********************************************************************/

long
luc_reply(mp, n, rcpt)
     LMEETING *mp;
     int n;
     char *rcpt;
{
  long code;
  char buf[BUFSIZ];
  int nannounce;		/* trn that announces reply */

  /* Mark the trn to be sent */
  if (code = luc_mark(mp, n, LUCY_WANT_REPLY)) {
    sprintf(luv_context, "%d", n);
    return(code);
  }

  /* Add transaction announcing replying */
  sprintf(buf, "repl %d %s", n, rcpt);
  if (code = luc_add_trn(mp, "/dev/null", buf,
			 luc_fullname(mp->nb.user_id), n, &nannounce)) {
    sprintf(luv_context, "[%04d]", n);
    return(code);
  }
  if (code = luc_mark(mp, nannounce, LUCY_WANT_REPLY)) {
    sprintf(luv_context, "[%04d]", nannounce);
    return(code);
  }

  /* let the lucyd server do the rest of the work */
  return(luc_parse(nannounce));
}
