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

#include <stdio.h>
#include <strings.h>
#include <ss/ss.h>
#include "lucy/lucy.h"
#include "lucy/memory.h"
#include "config.h"

void
do_show(argc, argv)
     int argc;
     char *argv[];
{
  long code;
  int i, n;
  char *s = NULL;
  char call[2048];		/* XXX make arbitrarily large */

  /* Check usage */
  if (argc < 2 || !atoi(argv[1])) {
    printf("You must specify a number.\n");
    return;
  }

  /* Prepare system call */
  strcpy(call, "MORE=d more");

  /* Go through arguments */
  for (i=1; i < argc; i++) {
    n = atoi(argv[i]);
    code = luc_trn_file(luv_curmtgp, n, &s);
    if (code) {
      luc_free_file(&s);
      com_err(argv[0], code, luv_context);
      return;
    }
    strcat(call, " ");
    strcat(call, s);
    luc_free_file(&s);
  }

  /* Let the "more" program do its stuff */
  system(call);
  return;
}
