IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Nov 22, 2006, 3:41:55 PM (20 years ago)
Author:
jhoblitt
Message:

add -det_mode support to the appropriate tool modes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippTools/src/dettool.c

    r10124 r10150  
    8080static psS32 incrementIteration(pxConfig *config, const char *det_id);
    8181static bool setDetRunState(pxConfig *config, const char *det_id, const char *state);
     82static bool isValidMode(pxConfig *config, const char *mode);
    8283
    8384# define MODECASE(caseName, func) \
     
    232233
    233234    // optional
     235    psString det_mode = psMetadataLookupStr(&status, config->args, "-det_mode");
     236    if (!status) {
     237        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -det_mode");
     238        return false;
     239    }
     240    // check det_mode
     241    if (det_mode && !isValidMode(config, det_mode)) {
     242        psError(PS_ERR_UNKNOWN, false, "invalud det_mode");
     243        return false;
     244    }
     245
    234246    psString exp_type = psMetadataLookupStr(&status, config->args, "-exp_type");
    235247    if (!status) {
     
    392404            0,
    393405            det_type,
     406            det_mode,
    394407            "run",
    395408            exp_type,
     
    601614
    602615    // optional
     616    psString det_mode = psMetadataLookupStr(&status, config->args, "-det_mode");
     617    if (!status) {
     618        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -det_mode");
     619        return false;
     620    }
     621    // check det_mode
     622    if (det_mode && !isValidMode(config, det_mode)) {
     623        psError(PS_ERR_UNKNOWN, false, "invalud det_mode");
     624        return false;
     625    }
     626
    603627    psString exp_type = psMetadataLookupStr(&status, config->args, "-set_exp_type");
    604628    if (!status) {
     
    709733            0,
    710734            det_type,
     735            det_mode,
    711736            "run",
    712737            exp_type,
     
    856881
    857882    // walk through the optional values and update the detRun as required
     883    psString det_type = psMetadataLookupStr(&status, config->args, "-set_det_type");
     884    if (!status) {
     885        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -set_det_type");
     886        return false;
     887    }
     888    if (det_type) {
     889        psFree(detRun->det_type);
     890        detRun->det_type = psStringCopy(det_type);
     891    }
     892
     893    psString det_mode = psMetadataLookupStr(&status, config->args, "-set_det_mode");
     894    if (!status) {
     895        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -set_det_mode");
     896        return false;
     897    }
     898    // check det_mode
     899    if (det_mode && !isValidMode(config, det_mode)) {
     900        psError(PS_ERR_UNKNOWN, false, "invalud det_mode");
     901        return false;
     902    }
     903    if (det_mode) {
     904        psFree(detRun->det_mode);
     905        detRun->det_mode = psStringCopy(det_mode);
     906    }
     907
    858908    psString exp_type = psMetadataLookupStr(&status, config->args, "-set_exp_type");
    859909    if (!status) {
     
    49735023
    49745024    // everything else is optional
     5025    psString det_mode = psMetadataLookupStr(&status, config->args, "-det_mode");
     5026    if (!status) {
     5027        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -det_mode");
     5028        return false;
     5029    }
     5030    // check det_mode
     5031    if (det_mode && !isValidMode(config, det_mode)) {
     5032        psError(PS_ERR_UNKNOWN, false, "invalud det_mode");
     5033        return false;
     5034    }
     5035
    49755036    psString exp_type = psMetadataLookupStr(&status, config->args, "-exp_type");
    49765037    if (!status) {
     
    50875148            0,  // the iteration is fixed at 0
    50885149            det_type,
     5150            det_mode,
    50895151            "reg",
    50905152            exp_type,
     
    52895351    return true;
    52905352}
     5353
     5354static bool isValidMode(pxConfig *config, const char *mode)
     5355{
     5356    PS_ASSERT_PTR_NON_NULL(config, false);
     5357    PS_ASSERT_PTR_NON_NULL(mode, false);
     5358
     5359    // check that state is a valid string value
     5360    if (!(
     5361            (strncmp(mode, "create", 7) == 0)
     5362            || (strncmp(mode, "verify", 7) == 0)
     5363        )
     5364    ) {
     5365        psError(PS_ERR_UNKNOWN, false,
     5366                "invalid detRun mode: %s", mode);
     5367        return false;
     5368    }
     5369
     5370    return true;
     5371}
Note: See TracChangeset for help on using the changeset viewer.