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

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

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

long
luc_ask_file(subj, fname, repl, publ)
     char *subj, *fname, *repl, *publ;
{
  FILE *pipe;
  long code;

  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);
  if (code = luc_insert_file(pipe, fname)) return(code);
  fprintf(pipe, "\nSEND PERSONAL REPLY: %s\n", repl);
  fprintf(pipe, "PUBLISH QUESTION/ANSWER IN BROWSER: %s\n", publ);
  pclose(pipe);
  return(0L);
}
