Logo Search packages:      
Sourcecode: dballe version File versions

F77_INTEGER_FUNCTION() idba_scusa ( INTEGER(handle)   ) 

Remove QC informations for a variable of the current record.

The QC informations to be removed are set with:

   idba_setc(handle, "*varlist", "*B33021,*B33003");

The variable referred by the QC informations can be specified in three ways:

  • by variable code, using idba_setc(handle, "*var", "Bxxyyy")
  • by variable id, using idba_seti(handle, "*data_id", id)
  • unspecified, will use the last variable returned by idba_dammelo
Parameters:
handle Handle to a DBALLE session
Returns:
The error indicator for the function

Definition at line 2108 of file simple.c.

References dba_error_consistency, DBA_RUN_OR_GOTO, DBA_RUN_OR_RETURN, and DBA_STRING_TO_VAR.

{
      GENPTR_INTEGER(handle)
      dba_err err = DBA_OK;
      dba_arr_varcode arr = NULL;
      const char* val;
      int id_context;
      dba_varcode id_var;

      if (! (STATE.perms & PERM_ATTR_WRITE))
            return dba_error_consistency(
                  "idba_scusa must be called with the database open in attribute write mode");
      
      DBA_RUN_OR_RETURN(get_referred_data_id(handle, &id_context, &id_var));

      if ((val = dba_record_key_peek_value(STATE.qcinput, DBA_KEY_VAR)) != NULL)
      {
            if (arr == NULL)
                  DBA_RUN_OR_RETURN(dba_arr_varcode_create(&arr));
            if (*val != '*')
            {
                  err = dba_error_consistency("QC values to delete must start with '*'");
                  goto cleanup;
            }
            DBA_RUN_OR_GOTO(cleanup, dba_arr_varcode_append(arr, DBA_STRING_TO_VAR(val + 2)));
      }

      if ((val = dba_record_key_peek_value(STATE.qcinput, DBA_KEY_VARLIST)) != NULL)
      {
            // Delete only the QC values in *data_id
            size_t pos;
            size_t len;
            if (arr == NULL)
                  DBA_RUN_OR_RETURN(dba_arr_varcode_create(&arr));
            for (pos = 0; (len = strcspn(val + pos, ",")) > 0; pos += len + 1)
            {
                  /*
                  fprintf(stderr, "str: \"%s\", str+pos: \"%s\", str+pos+len: \"%s\"\n",
                              val, val+pos, val+pos+len);
                  */
                  if (*(val+pos) != '*')
                  {
                        err = dba_error_consistency("QC values to delete must start with '*'");
                        goto cleanup;
                  }
                  DBA_RUN_OR_GOTO(cleanup, dba_arr_varcode_append(arr, DBA_STRING_TO_VAR(val + pos + 1)));
            }
      }

      // If arr is still 0, then dba_qc_delete deletes all QC values
      DBA_RUN_OR_GOTO(cleanup,
                  dba_db_qc_remove(
                        SESSION, id_context, id_var,
                        arr == NULL ? NULL : dba_arr_varcode_data(arr),
                        arr == NULL ? 0 : dba_arr_varcode_size(arr)));

      clear_attr_rec(STATE.qcinput);

cleanup:
      if (arr != NULL)
            dba_arr_varcode_delete(arr);
      return err == DBA_OK ? dba_error_ok() : err;
}


Generated by  Doxygen 1.6.0   Back to index