IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 39297


Ignore:
Timestamp:
Dec 28, 2015, 8:17:22 AM (11 years ago)
Author:
eugene
Message:

add verbosity and handle interrupts on uniq

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/opihi/cmd.data/uniq.c

    r38986 r39297  
    88  int Nnew, i, N;
    99  Vector *ivec, *ovec;
     10
     11  int VERBOSE = FALSE;
     12  if ((N = get_argument (argc, argv, "-v"))) {
     13    remove_argument (N, &argc, argv);
     14    VERBOSE = TRUE;
     15  }
    1016
    1117  Vector *cvec = NULL;
     
    4854    opihi_flt *vsrc = indata;
    4955
    50     for (i = 0; i < ivec->Nelements; Nnew++) {
     56    int onePercent = ivec->Nelements / 100;
     57
     58    void *Signal = signal (SIGINT, handle_interrupt);
     59    interrupt = FALSE;
     60    for (i = 0; (i < ivec->Nelements) && !interrupt; Nnew++) {
    5161      vtgt[Nnew] = *vsrc;
    5262      int Ndup = 0;
     
    5666        vsrc ++;
    5767        Ndup ++;
     68        if (VERBOSE && (i % onePercent == 0)) gprint (GP_ERR, ".");
    5869      }
    5970      if (cvec) {
     
    6172      }
    6273    }
     74    signal (SIGINT, Signal);
     75    if (VERBOSE) gprint (GP_ERR, "\n");
    6376    free (indata);
    6477  } else {
     
    7588    opihi_int *vsrc = indata;
    7689
    77     for (i = 0; i < ivec->Nelements; Nnew++) {
     90    int onePercent = ivec->Nelements / 100;
     91
     92    void *Signal = signal (SIGINT, handle_interrupt);
     93    interrupt = FALSE;
     94    for (i = 0; (i < ivec->Nelements) && !interrupt; Nnew++) {
    7895      vtgt[Nnew] = *vsrc;
    7996      int Ndup = 0;
     
    83100        vsrc ++;
    84101        Ndup ++;
     102        if (VERBOSE && (i % onePercent == 0)) gprint (GP_ERR, ".");
    85103      }
    86104      if (cvec) {
     
    88106      }
    89107    }
     108    signal (SIGINT, Signal);
     109    if (VERBOSE) gprint (GP_ERR, "\n");
    90110    free (indata);
    91111  }
Note: See TracChangeset for help on using the changeset viewer.