/**********************************************************************
 * luc_ask.c -- send question to lucy
 *
 * $Author: brlewis $
 * $Source: /afs/athena.mit.edu/astaff/project/lucydev/src/lib/RCS/luc_ask.c,v $
 * $Header: /afs/athena.mit.edu/astaff/project/lucydev/src/lib/RCS/luc_ask.c,v 1.2 91/09/24 14:32:51 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_ask_c[] = "$Header: /afs/athena.mit.edu/astaff/project/lucydev/src/lib/RCS/luc_ask.c,v 1.2 91/09/24 14:32:51 brlewis Exp Locker: brlewis $";
#endif /* lint */

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

/**********************************************************************
 * luc_ask(char *subj, char *text, char *repl, char *publ)
 *	caller sets strings appropriately
 *
 * - mails message to lucy
 * - returns error code
 **********************************************************************/

long
luc_ask(subj, text, repl, publ)
     char *subj, *text, *repl, *publ;
{
  FILE *pipe;

  pipe = popen("/usr/lib/sendmail -t", "w");
  if (!pipe) return((long) errno);

  fprintf(pipe, "To: %s\n", luv_email);
  fprintf(pipe, "Subject: %s\n\n", subj);
  fprintf(pipe, "%s\n", text);
  fprintf(pipe, "SEND PERSONAL REPLY: %s\n", repl);
  fprintf(pipe, "PUBLISH QUESTION/ANSWER IN BROWSER: %s\n", publ);
  pclose(pipe);
  return(0L);
}
