# include "data.h"
# define NCOLORS 9
static char colors[9][10] = {"black", "white", "red", "orange", "yellow", "green", "blue", "indigo", "violet"};

int style (int argc, char **argv) {
  
  int i, N, Ngraph;
  Graphdata graphmode;

  Ngraph = -1;
  if (N = get_argument (argc, argv, "-n")) {
    remove_argument (N, &argc, argv);
    Ngraph = atof (argv[N]);
    remove_argument (N, &argc, argv);
  }
  if (!GetGraph (&graphmode, NULL, &Ngraph)) return (FALSE);

  if (argc == 1) {
    fprintf (stderr, "current style (%d): -x %d -c %s -pt %d -lt %d -lw %f -sz %f\n", Ngraph,
	     graphmode.style, colors[graphmode.color], graphmode.ptype, 
	     graphmode.ltype, graphmode.lweight,
	     graphmode.size);
    return (TRUE);
  }

  if (N = get_argument (argc, argv, "-lt")) {
    remove_argument (N, &argc, argv);
    graphmode.ltype = atof(argv[N]);
    remove_argument (N, &argc, argv);
  }

  if (N = get_argument (argc, argv, "-lw")) {
    remove_argument (N, &argc, argv);
    graphmode.lweight = atof(argv[N]);
    remove_argument (N, &argc, argv);
  }

  if (N = get_argument (argc, argv, "-pt")) {
    remove_argument (N, &argc, argv);
    graphmode.ptype = atof(argv[N]);
    remove_argument (N, &argc, argv);
  }

  if (N = get_argument (argc, argv, "+eb")) {
    remove_argument (N, &argc, argv);
    graphmode.ebar = TRUE;
  }

  if (N = get_argument (argc, argv, "-eb")) {
    remove_argument (N, &argc, argv);
    graphmode.ebar = FALSE;
  }

  if (N = get_argument (argc, argv, "-sz")) {
    remove_argument (N, &argc, argv);
    graphmode.size = atof(argv[N]);
    remove_argument (N, &argc, argv);
  }

  if (N = get_argument (argc, argv, "-c")) {
    remove_argument (N, &argc, argv);
    graphmode.color = GetColor (argv[N]);
    if (graphmode.color == -1) return (FALSE);
    remove_argument (N, &argc, argv);
  }

  if (N = get_argument (argc, argv, "-x")) {
    remove_argument (N, &argc, argv);
    graphmode.style = atof(argv[N]);
    remove_argument (N, &argc, argv);
  }

  SetGraph (graphmode);

  if (argc > 1) {
    fprintf (stderr, "USAGE: style [-n Ngraph] [-x plot style] [-c color] [-pt point type] [-lt line type] [-lw line width] [-sz size]\n");
    return (FALSE);
  }

  return (TRUE);

}

