IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Aug 19, 2008, 12:29:10 PM (18 years ago)
Author:
eugene
Message:

adding host tracking and restart

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/opihi/pantasks/controller_host.c

    r8548 r19125  
    33int controller_host (int argc, char **argv) {
    44
    5   int status;
     5  int N, status, max_threads;
    66  char command[1024];
    77  IOBuffer buffer;
    88
    9   if (argc != 3) {
    10     gprint (GP_ERR, "USAGE: controller host (command) (hostname)\n");
    11     return (FALSE);
     9  max_threads = 0;
     10  if ((N = get_argument (argc, argv, "-threads"))) {
     11    remove_argument (N, &argc, argv);
     12    max_threads = atoi(argv[N]);
     13    remove_argument (N, &argc, argv);
    1214  }
     15
     16  if (argc != 3) goto usage;
    1317
    1418  /* start controller connection (if needed) */
     
    1822  }
    1923
    20   sprintf (command, "host %s %s", argv[1], argv[2]);
     24  // the user may issue any of these commands:
     25  // ADD, ON, RETRY, CHECK, OFF, DELETE
     26  // we need to catch ADD and DELETE and modify our host table accordingly
     27  if (!strcasecmp (argv[1], "ADD")) {
     28    AddHost (argv[2], max_threads);
     29  } else {
     30    if (max_threads) goto usage;
     31  }
     32
     33  if (!strcasecmp (argv[1], "DELETE")) {
     34    DeleteHost (argv[2]);
     35  }
     36
     37  if (max_threads) {
     38    sprintf (command, "host %s %s -threads %d", argv[1], argv[2], max_threads);
     39  } else {
     40    sprintf (command, "host %s %s", argv[1], argv[2]);
     41  }
    2142  InitIOBuffer (&buffer, 0x100);
    2243
     
    2950  FreeIOBuffer (&buffer);
    3051  return (TRUE);
     52 
     53usage:
     54  gprint (GP_LOG, "USAGE: controller host (command) (hostname)\n");
     55  gprint (GP_ERR, "  valid commands: add, on, retry, check, off, delete\n");
     56  gprint (GP_ERR, "  -threads Nthreads is optional for 'add'\n");
     57  return (FALSE);
    3158}
    3259
Note: See TracChangeset for help on using the changeset viewer.