/* Copyright Milan Technology, 1991 1992 */
/*  2.2 10/9/1994, Modified to support 4 port MIL-3200 */
/*  3.4 9/30/1997, Adds bidirectional printer info support */
/* @(#)fpstatus.c	3.4 9/30/97 */

#include "udp.h"
#include <stdio.h>

#ifndef SCO
#include <sys/file.h>
#endif

#include <sys/types.h>

#include "dp.h"

#ifdef ANSI
main(int argc,char **argv)
#else
main(argc,argv)
int argc;
char **argv;
#endif
{
  char status_string[MAXSTRNGLEN];
  char temp_string[MAXSTRNGLEN];
  int i, j = 0;
  int get_bidi = 0;
 
  if (argc != 2 && argc != 3) {
HELP:
    fprintf(stderr,"Usage: fpstatus <fastport name> [b]\n");
    fprintf(stderr,"Option:  b - get only bidirectional info from the printer(s)\n");

    exit(1);
  }
  if((argc == 3)&&(argv[2][0] != 'b')){
    fprintf(stderr, "Invalid option\n");
    goto HELP;
  }
  if((argc == 3)&&(argv[2][0] == 'b')){
	get_bidi = 1;
  }
  status_string[0] = 0;
  get_printer_status(argv[1],status_string,ALL,get_bidi);
if (get_bidi == 1) {
  for(i = 0; status_string[i] != '\0'; i++) {
	if (status_string[i] == ';') {
		temp_string[j] = '\0';
		printf("%s\n",temp_string);	
		j = 0;
	}
	else {
		temp_string[j]=status_string[i];
		j++;
	}
  }
  temp_string[j] = '\0';
  printf("%s\n", temp_string);
}
else
	fprintf(stderr,status_string);
}

