/**********************************************************************
 * lucy_print.c -- print-question routine for lucy
 *
 * $Source$
 * $Author: brlewis $
 * $Header$
 *
 * Copyright 1990 by the Massachusetts Institute of Technology.
 * For copying and distribution information, see the file
 * "mit-copyright.h".
 **********************************************************************/
#include "mit-copyright.h"

#ifndef lint
static char rcsid_lucy_print_c[] = "$Header$";
#endif /* lint */

#include <stdio.h>
#include "lucy/lucy.h"
tfile unix_tfile();		/* XXX should be in discuss .h file */

void
lucy_print(argc, argv)
     int argc;
     char *argv[];
{
  long code;
  tfile tfstdout;
  FILE *fp, *pipe;
  lucy_qident i;
  int j;
  name_blk *nb;
  lucyqlist l;
  char filename[32], call[64];

  /* XXX figure out why lpr doesn't work */
  pipe = popen("cat >/tmp/p", "w");

  for(j=1; j < argc; j++) {
    i = atoi(argv[j]);		/* XXX error check */
    code = lucy_chain_to_file(i, pipe, 0);
    fputc('\014', pipe);
    if (code) {
      com_err(argv[0], code, "");
      pclose(pipe);
      return;
    }
  }
  system("lpr /tmp/p");
  return;
}
