// Entry point
int main(int argc, char** argv)
{
  int result;
  GTH_api api;
  int verbose = 0;
  GTH_const_attribute attrs[MAX_ATTRIBUTES];
  int n_attrs = 0;

  while (argc > 1 && argv[1][0] == '-') {
    switch (argv[1][1]) {
    case 'v': verbose = 1; break;

    default: usage();
    }
    argc--;
    argv++;
  }

  if (argc < 3) {
    usage();
  }

  win32_specific_startup();

  result = gth_connect(&api, argv[1], verbose);
  if (result != 0) {
    die("Unable to connect to the GTH. Giving up.");
  }
  api.event_handler = &gth_silent_event_handler;

  // First attribute is in argv[3], first value in argv[4]
  if (argc >= MAX_ATTRIBUTES) {
    die("Too many name/value pairs. Abort.");
  }

  for (n_attrs = 0; n_attrs < (argc - 3) / 2; n_attrs++) {
    attrs[n_attrs].key   = argv[n_attrs * 2 + 3];
    attrs[n_attrs].value = argv[n_attrs * 2 + 4];
  }
  result = gth_enable(&api, argv[2], attrs, n_attrs);
  if (result != 0) {
    fprintf(stderr, "failed to enable %s\n", argv[2]);
    exit(1);
  }

  gth_bye(&api);

  return 0;
}
// Optical E1/T1: just enable; no special options required.
static void
enable_optical_l1(GTH_api *api,
		  const char* span,
		  const int monitoring)
{
  int result;

  if (monitoring)
    fprintf(stderr, "Warning: ignoring -m switch on optical hardware.\n");

  result = gth_enable(api, span, 0, 0);

  if (result != 0)
    die("Setting up L1 failed. (-v switch gives more information)");
}