/**********************************************************************
 * luc_post.c -- post transaction
 *
 * $Author: brlewis $
 * $Source: /afs/athena.mit.edu/astaff/project/lucydev/src/lib/RCS/luc_post.c,v $
 * $Header: /afs/athena.mit.edu/astaff/project/lucydev/src/lib/RCS/luc_post.c,v 1.3 91/10/15 16:45: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_post_c[] = "$Header: /afs/athena.mit.edu/astaff/project/lucydev/src/lib/RCS/luc_post.c,v 1.3 91/10/15 16:45:26 brlewis Exp Locker: brlewis $";
#endif /* lint */

#include <stdio.h>
#include <strings.h>
#include <lucy/lucy.h>

/**********************************************************************
 * luc_post(mp, n, subject, inreplyto)
 *	caller sets mp (usually luv_curmtgp) to specify meeting
 *	caller sets n to specify transaction number
 *	caller sets subject as appropriate
 *	caller sets inreplyto to 0 or previous trn number in browser
 *
 * - returns error code
 **********************************************************************/

long
luc_post(mp, n, subject, inreplyto)
     LMEETING *mp;
     int n;
     char *subject;
     int inreplyto;
{
  long code;
  char buf[BUFSIZ];
  int n3;

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

  /* Add transaction requesting posting */
  sprintf(buf, "post %d ", n);
  if (inreplyto) sprintf(buf, "post %d [%04d] %s", n, inreplyto, subject);
  else sprintf(buf, "post %d %s", n, subject);
  if (code = luc_add_trn(mp, "/dev/null", buf,
			 luc_fullname(mp->nb.user_id), n, &n3)) {
    sprintf(luv_context, "%d", n);
    return(code);
  }
  if (code = luc_mark(mp, n3, LUCY_WANT_POST)) {
    sprintf(luv_context, "%d", n);
    return(code);
  }

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