IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Mar 2, 2010, 6:29:45 PM (16 years ago)
Author:
watersc1
Message:

Code and regtool rewrites to enable the lossy compression of old data that aren't scientifically useful.

File:
1 edited

Legend:

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

    r21402 r27149  
    5858    return true;
    5959}
     60
     61bool pxrawExpSetState(pxConfig *config, psS64 exp_id, const char *state)
     62{
     63    if (!exp_id) {
     64        psError(PS_ERR_UNKNOWN, true, "0 is not a valid exp_id");
     65        return false;
     66    }
     67    PS_ASSERT_PTR_NON_NULL(state, false);
     68
     69    // check that state is a valid string value
     70    if (!(
     71            (strncmp(state, "full", 5) == 0)
     72            || (strncmp(state, "new", 4) == 0)
     73            || (strncmp(state, "goto_compressed", 14) == 0)
     74            || (strncmp(state, "compressed", 11) == 0)
     75            || (strncmp(state, "goto_lossy", 11) == 0)
     76            || (strncmp(state, "lossy", 6) == 0)
     77        )
     78    ) {
     79        psError(PS_ERR_UNKNOWN, false,
     80                "invalid rawExp state: %s", state);
     81        return false;
     82    }
     83
     84    char *query = "UPDATE rawExp SET state = '%s' WHERE exp_id = %"PRId64;
     85    if (!p_psDBRunQueryF(config->dbh, query, state, exp_id)) {
     86        psError(PS_ERR_UNKNOWN, false,
     87                "failed to change state for exp_id %"PRId64, exp_id);
     88        return false;
     89    }
     90
     91    return true;
     92}
     93bool pxrawImfileSetState(pxConfig *config, psS64 exp_id, const char *class_id, const char *state)
     94{
     95    if (!exp_id) {
     96        psError(PS_ERR_UNKNOWN, true, "0 is not a valid exp_id");
     97        return false;
     98    }
     99    PS_ASSERT_PTR_NON_NULL(state, false);
     100
     101    // check that state is a valid string value
     102    if (!(
     103            (strncmp(state, "full", 5) == 0)
     104            || (strncmp(state, "new", 4) == 0)
     105            || (strncmp(state, "goto_compressed", 14) == 0)
     106            || (strncmp(state, "compressed", 11) == 0)
     107            || (strncmp(state, "goto_lossy", 11) == 0)
     108            || (strncmp(state, "lossy", 6) == 0)
     109        )
     110    ) {
     111        psError(PS_ERR_UNKNOWN, false,
     112                "invalid rawImfile data_state: %s", state);
     113        return false;
     114    }
     115
     116    char *query = "UPDATE rawImfile SET data_state = '%s' WHERE class_id = %s AND exp_id = %"PRId64;
     117    if (!p_psDBRunQueryF(config->dbh, query, state, class_id, exp_id)) {
     118        psError(PS_ERR_UNKNOWN, false,
     119                "failed to change state for exp_id %"PRId64, exp_id);
     120        return false;
     121    }
     122
     123    return true;
     124}
Note: See TracChangeset for help on using the changeset viewer.