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

#include <stdio.h>
#include <sys/types.h>
#include <ss/ss.h>
#include "lucy/lucy.h"
#include "config.h"

void
do_stat(argc, argv)
     int argc;
     char *argv[];
{
  long code;
  int i;
  ltrn *t;

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

  /* Get info on transaction */
  code = luc_trn_info(luv_curmtgp, i, &t);
  if (code) {
    com_err(argv[0], code, luv_context);
    return;
  }

  /* Print info */
  printf("Subject: %s\n", t->subject);
  printf(" Author: %s\n", t->author);
  if (t->signature && *(t->signature) != '\0')
    printf("\t (a.k.a. %s)\n", t->signature);
  printf("   Date: %s", ctime((time_t *) &(t->date_entered)));
  printf(" Length: %d %s, %d %s\n", t->num_lines,
	 (t->num_lines == 1) ? "line" : "lines",
	 t->num_chars,
	 (t->num_chars == 1) ? "character" : "characters");
  if (t->flags)
    printf(" Status: %s\n", luc_flgstr(t->flags));
  return;
}
