/**********************************************************************
 * do_lpr.c  -- SS command for printing a report
 * tty lucy client using SS library
 *
 * $Author: brlewis $
 * $Source: /afs/athena.mit.edu/astaff/project/lucydev/src/tty/do_lpr.c,v $
 * $Header: /afs/athena.mit.edu/astaff/project/lucydev/src/tty/do_lpr.c,v 1.1 91/09/24 14:44:45 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_do_lpr_c[] = "$Header: /afs/athena.mit.edu/astaff/project/lucydev/src/tty/do_lpr.c,v 1.1 91/09/24 14:44:45 brlewis Exp Locker: brlewis $";
#endif /* lint */

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

void
do_lpr(argc, argv)
     int argc;
     char *argv[];
{
  char filename[256], call[256];
  int i;

  /* Make sure the report file is there */
  sprintf(filename, "%s/report.dvi", luv_topdir);
  if (access(filename, F_OK)) {
    printf("First use the report command to generate a report.\n");
    return;
  }

  /* Prepare system call with lpr arguments */
  sprintf(call, "dvi2ps -r %s | lpr", filename);
  for(i=1; i<argc; i++) strcat(strcat(call, " "), argv[i]);

  /* dvi2ps and lpr will print their own error diagnostics */
  system(call);
  return;
}
