# include "data.h"

int device (int argc, char **argv) {

  int N, Source, Nsource, IsImage;
  /* set / get current graphics device */

  Nsource = -1;
  if ((N = get_argument (argc, argv, "-n"))) {
    remove_argument (N, &argc, argv);
    Nsource = atof (argv[N]);
    remove_argument (N, &argc, argv);
  }
  if ((N = get_argument (argc, argv, "-g"))) {
    remove_argument (N, &argc, argv);
    SetImageDevice (FALSE);
  }  
  if ((N = get_argument (argc, argv, "-i"))) {
    remove_argument (N, &argc, argv);
    SetImageDevice (TRUE);
  }  

  IsImage = GetCurrentDevice ();
  if (IsImage) {
    if (!GetImage (&Source, &Nsource)) return (FALSE);
    gprint (GP_ERR, "kii %d\n", Nsource); 
  } else {
    if (!GetGraph (NULL, &Source, &Nsource)) return (FALSE);
    gprint (GP_ERR, "kapa %d\n", Nsource); 
  }

  return (TRUE);
}
