示例#1
0
int WindowEntry::SetThreshold(const char *threshold)
{
  int r = 0;

  dtrace("\"%s\"", threshold);

  SetScalar(0, threshold);

  if (D != NULL) {
    r = gd_alter_entry(D->D, E.field, &E, 0);

    if (!r) {
      switch(E.u.window.windop) {
        case GD_WINDOP_EQ:
        case GD_WINDOP_NE:
          r = gd_get_constant(D->D, threshold, GD_INT64,
              &E.u.window.threshold.i);
          break;
        case GD_WINDOP_SET:
        case GD_WINDOP_CLR:
          r = gd_get_constant(D->D, threshold, GD_UINT64,
              &E.u.window.threshold.u);
          break;
        default:
          r = gd_get_constant(D->D, threshold, GD_FLOAT64,
              &E.u.window.threshold.r);
          break;
      }
    }
  }
  
  dreturn("%i", r);
  return r;
}
示例#2
0
/**
 * @brief Searches for well known locked files
 * and applies their dispositions to the map.
 * @details Resets f->disp structure of locked files.
 */
static void redraw_well_known_locked_files(udefrag_job_parameters *jp)
{
    winx_file_info *f;
    ULONGLONG time;
    ULONGLONG n = 0;

    winx_dbg_print_header(0,0,I"searching for well known locked files...");
    time = winx_xtime();
    
    for(f = jp->filelist; f; f = f->next){
        if(f->disp.blockmap){ /* otherwise nothing to redraw */
            if(is_well_known_locked_file(f,jp)){
                if(!is_file_locked(f,jp)){
                    /* possibility of this case should be reduced */
                    dtrace("file wasn't locked: %ws",f->path);
                } else {
                    itrace("locked file DETECTED:  %ws",f->path);
                    n ++;
                }
            }
        }
        if(f->next == jp->filelist) break;
    }

    itrace("%I64u locked files found",n);
    winx_dbg_print_header(0,0,I"well known locked files search completed in %I64u ms",
        winx_xtime() - time);
}
示例#3
0
off64_t _GD_AsciiSeek(struct _gd_raw_file* file, off64_t count,
    gd_type_t data_type __gd_unused, unsigned int mode)
{
  char line[64];

  dtrace("%p, %lli, <unused>, 0x%X", file, (long long)count, mode);

  if (count < file->pos) {
    rewind((FILE *)file->edata);
    file->pos = 0;
  }

  for (; count > file->pos; ++file->pos)
    if (fgets(line, 64, (FILE *)file->edata) == NULL)
      break;

  if (mode & GD_FILE_WRITE && count > file->pos) {
    strcpy(line, "0\n");
    for (; count > file->pos; ++file->pos)
      fputs(line, (FILE *)file->edata);
  }

  dreturn("%lli", (long long)file->pos);
  return file->pos;
}
示例#4
0
static int _GD_CollectFragments(DIRFILE* D, int** f, int fragment, int nf)
{
  int i;
  int *new_f;

  dtrace("%p, %p, %i, %i", D, f, fragment, nf);

  new_f = (int *)_GD_Realloc(D, *f, sizeof(int) * ++nf);
  if (new_f == NULL) {
    dreturn("%i", -1);
    return -1;
  }
  new_f[nf - 1] = fragment;

  for (i = 0; i < D->n_fragment; ++i)
    if (D->fragment[i].parent == fragment) {
      nf = _GD_CollectFragments(D, &new_f, i, nf);
      if (nf == -1)
        break;
    }

  *f = new_f;

  dreturn("%i", nf);
  return nf;
}
示例#5
0
/* legacy interface to getdata() */
int GetData(const char *filename, const char *field_code,
    int first_frame, int first_samp, int num_frames, int num_samp,
    char return_type, void *data_out, int *error_code)
{
  DIRFILE* D;
  int nread;

  dtrace("\"%s\", \"%s\", %i, %i, %i, %i, '%c', %p, %p", filename, field_code,
      first_frame, first_samp, num_frames, num_samp, return_type, data_out,
      error_code);

  D = _GD_GetDirfile(filename, GD_RDONLY, error_code);

  if (!D) {
    dreturn("%i", 0);
    return 0;
  }

  nread = (int)gd_getdata64(D, field_code, (off64_t)first_frame,
      (off64_t)first_samp, (size_t)num_frames, (size_t)num_samp,
      _GD_LegacyType(return_type), data_out);
  *error_code = _GD_CopyGlobalError(D);

  dreturn("%i", nread);
  return nread;
}
示例#6
0
unsigned int _GD_NEntries(DIRFILE *D, struct _gd_private_entry *p, int type,
    unsigned int flags)
{
  int i;
  unsigned int u, n = 0;
  const int special = (type & GD_SPECIAL_ENTRY_BIT) ? type : 0;
  const gd_entype_t ctype = (type & GD_SPECIAL_ENTRY_BIT) ? GD_NO_ENTRY :
    (gd_entype_t)type;
  const int hidden = (flags & GD_ENTRIES_HIDDEN);
  const int noalias = (flags & GD_ENTRIES_NOALIAS);
  dtrace("%p, %p, 0x%X, 0x%X", D, p, type, flags);

  /* check for invalid type */
  if (ctype && _GD_InvalidEntype(ctype)) {
    _GD_SetError(D, GD_E_BAD_ENTRY, GD_E_ENTRY_TYPE, NULL, type, NULL);
    dreturn("%u", 0);
    return 0;
  }

  if (p) {
    for (i = 0; i < p->n_meta; ++i)
      if (_GD_ListEntry(p->p.meta_entry[i], 1, hidden, noalias, special,
            ctype))
        n++;
  } else {
    for (u = 0; u < D->n_entries; ++u)
      if (_GD_ListEntry(D->entry[u], 0, hidden, noalias, special, ctype))
        n++;
  }

  dreturn("%u", n);
  return n;
}
示例#7
0
/* Create new affixes given the current affixes and the new parts indicated
 * on a /INCLUDE line */
static int _GD_SetFieldAffixes(DIRFILE *D, int me, const char *prefix_in,
    const char *suffix_in, int standards, int pedantic, const char *format_file,
    int line, char **prefix, char **suffix)
{
  dtrace("%p, %i, \"%s\", \"%s\", %i, %i, \"%s\", %i, %p, %p", D, me, prefix_in,
      suffix_in, standards, pedantic, format_file, line, prefix, suffix);

  /* suffix first, for some reason */
  if (suffix_in && suffix_in[0] != '\0') {
    if (_GD_ValidateField(suffix_in, standards, pedantic, 1, NULL))
    {
      _GD_SetError(D, GD_E_FORMAT, GD_E_FORMAT_BAD_NAME, format_file, line,
          suffix_in);
      dreturn("%i", 1);
      return 1;
    }

    if (D->fragment[me].suffix == NULL)
      *suffix = _GD_Strdup(D, suffix_in);
    else {
      *suffix = (char*)_GD_Malloc(D, strlen(D->fragment[me].suffix) +
          strlen(suffix_in) + 1);
      if (*suffix)
        strcat(strcpy(*suffix, suffix_in), D->fragment[me].suffix);
    }
  } else if (D->fragment[me].suffix)
    *suffix = _GD_Strdup(D, D->fragment[me].suffix);

  if (D->error) {
    dreturn("%i", 1);
    return 1;
  }

  /* now the prefix */
  if (prefix_in && prefix_in[0] != '\0') {
    if (_GD_ValidateField(prefix_in, standards, pedantic, 1, NULL))
    {
      _GD_SetError(D, GD_E_FORMAT, GD_E_FORMAT_BAD_NAME, format_file, line,
          prefix_in);
      dreturn("%i", 1);
      return 1;
    }

    if (D->fragment[me].prefix == NULL)
      *prefix = _GD_Strdup(D, prefix_in);
    else {
      *prefix = (char*)_GD_Malloc(D, strlen(D->fragment[me].prefix) +
          strlen(prefix_in) + 1);
      if (*prefix)
        strcat(strcpy(*prefix, D->fragment[me].prefix), prefix_in);
    }
  } else if (D->fragment[me].prefix)
    *prefix = _GD_Strdup(D, D->fragment[me].prefix);

  dreturn("%i", D->error);
  return D->error;
}
示例#8
0
void QueryThread::ProgressCallback(udefrag_progress_info *pi, void *p)
{
    //Copied from Job.cpp function of same-name
    if (pi->completion_status > 0){
        dtrace("The Completion Status Was 0. Begin Populating The Query Tab Here.");
        //cannot access member variable m_qp from in here.
        //would rather call a new member function.
        g_mainFrame->m_queryThread->DisplayQueryResults();
    }
}
示例#9
0
int gd_close(DIRFILE *D)
{
  int ret;

  dtrace("%p", D);

  ret = _GD_ShutdownDirfile(D, 1, 0);

  dreturn("%i", ret);
  return ret;
}
示例#10
0
int gd_discard(DIRFILE* D)
{
  int ret;

  dtrace("%p", D);

  ret = _GD_ShutdownDirfile(D, 0, 0);

  dreturn("%i", ret);
  return ret;
}
示例#11
0
int gd_include(DIRFILE* D, const char* file, int fragment_index,
    unsigned long flags)
{
  int new_fragment;

  dtrace("%p, \"%s\", %i, 0x%lX", D, file, fragment_index, flags);

  new_fragment = gd_include_affix(D, file, fragment_index, NULL, NULL, flags);

  dreturn("%i", new_fragment);
  return new_fragment;
}
示例#12
0
off64_t _GD_Bzip2Seek(struct _gd_raw_file* file, off64_t count,
    gd_type_t data_type, unsigned int mode __gd_unused)
{
  struct gd_bzdata *ptr = (struct gd_bzdata *)file->edata;

  dtrace("%p, %lli, 0x%X, <unused>", file, (long long)count, data_type);

  count *= GD_SIZE(data_type);

  if (ptr->base > count) {
    /* a backwards seek -- reopen the file */
    ptr->bzerror = 0;
    BZ2_bzReadClose(&ptr->bzerror, ptr->bzfile);
    ptr->bzfile = BZ2_bzReadOpen(&ptr->bzerror, ptr->stream, 0, 0, NULL, 0);

    if (ptr->bzfile == NULL || ptr->bzerror != BZ_OK) {
      fclose(ptr->stream);
      dreturn("%i", -1);
      return -1;
    }
    ptr->pos = ptr->end = 0;
    ptr->base = ptr->stream_end = 0;
  }

  /* seek forward the slow way */
  while (ptr->base + ptr->end < count) {
    int n;

    ptr->bzerror = 0;
    n = BZ2_bzRead(&ptr->bzerror, ptr->bzfile, ptr->data,
        GD_BZIP_BUFFER_SIZE);

    if (ptr->bzerror == BZ_OK || ptr->bzerror == BZ_STREAM_END) {
      ptr->base += ptr->end;
      ptr->end = n;
    } else {
      dreturn("%i", -1);
      return -1;
    }

    /* eof */
    if (ptr->bzerror != BZ_OK) {
      ptr->stream_end = 1;
      break;
    }
  }

  ptr->pos = (ptr->bzerror == BZ_STREAM_END && count >= ptr->base + ptr->end) ?
    ptr->end : count - ptr->base;

  dreturn("%lli", (long long)((ptr->base + ptr->pos) / GD_SIZE(data_type)));
  return (ptr->base + ptr->pos) / GD_SIZE(data_type);
}
示例#13
0
static const char* _GD_TypeName(DIRFILE* D, gd_type_t data_type)
{
  const char* ptr;

  dtrace("%p, 0x%X", D, data_type);

  switch(data_type) {
    case GD_UINT8:
      ptr = "UINT8";
      break;
    case GD_INT8:
      ptr = "INT8";
      break;
    case GD_UINT16:
      ptr = "UINT16";
      break;
    case GD_INT16:
      ptr = "INT16";
      break;
    case GD_UINT32:
      ptr = "UINT32";
      break;
    case GD_INT32:
      ptr = "INT32";
      break;
    case GD_UINT64:
      ptr = "UINT64";
      break;
    case GD_INT64:
      ptr = "INT64";
      break;
    case GD_FLOAT32:
      ptr = "FLOAT32";
      break;
    case GD_FLOAT64:
      ptr = "FLOAT64";
      break;
    case GD_COMPLEX64:
      ptr = "COMPLEX64";
      break;
    case GD_COMPLEX128:
      ptr = "COMPLEX128";
      break;
    default:
      _GD_InternalError(D);
      ptr = "";
      break;
  }

  dreturn("\"%s\"", ptr);
  return ptr;
}
示例#14
0
static void _GD_ScanFormat(char* fmt, gd_type_t data_type)
{
  dtrace("%p, 0x%X", fmt, data_type);

  switch(data_type) {
    case GD_UINT8:
#ifndef NO_8BIT_INT_PREFIX
      strcpy(fmt, "%" SCNu8);
      break;
#endif
    case GD_UINT16:
      strcpy(fmt, "%" SCNu16);
      break;
    case GD_INT8:
#ifndef NO_8BIT_INT_PREFIX
      strcpy(fmt, "%" SCNi8);
      break;
#endif
    case GD_INT16:
      strcpy(fmt, "%" SCNi16);
      break;
    case GD_UINT32:
      strcpy(fmt, "%" SCNu32);
      break;
    case GD_INT32:
      strcpy(fmt, "%" SCNi32);
      break;
    case GD_UINT64:
      strcpy(fmt, "%" SCNu64);
      break;
    case GD_INT64:
      strcpy(fmt, "%" SCNi64);
      break;
    case GD_FLOAT32:
      strcpy(fmt, "%f");
      break;
    case GD_FLOAT64:
      strcpy(fmt, "%lf");
      break;
    case GD_COMPLEX64:
      strcpy(fmt, "%f;%f");
      break;
    case GD_COMPLEX128:
      strcpy(fmt, "%lf;%lf");
      break;
    default:
      fmt[0] = 0;
      break;
  }

  dreturn("[\"%s\"]", fmt);
}
示例#15
0
off64_t gd_nframes64(DIRFILE* D)
{
  off64_t nf;

  dtrace("%p", D);

  _GD_ClearError(D);

  if (D->flags & GD_INVALID) {/* don't crash */
    _GD_SetError(D, GD_E_BAD_DIRFILE, 0, NULL, 0, NULL);
    dreturn("%i", 0);
    return 0;
  }

  if (D->reference_field == NULL) {
    dreturn("%i", 0);
    return 0;
  }

  if (!_GD_Supports(D, D->reference_field, GD_EF_NAME | GD_EF_SIZE)) {
    dreturn("%i", 0);
    return 0;
  }

  if ((*_gd_ef[D->reference_field->e->u.raw.file[0].subenc].name)(D,
        (const char*)D->fragment[D->reference_field->fragment_index].enc_data,
        D->reference_field->e->u.raw.file,
        D->reference_field->e->u.raw.filebase, 0, 0))
  {
    dreturn("%i", 0);
    return 0;
  }

  nf = (*_gd_ef[D->reference_field->e->u.raw.file[0].subenc].size)(
      D->fragment[D->reference_field->fragment_index].dirfd,
      D->reference_field->e->u.raw.file,
      D->reference_field->EN(raw,data_type), _GD_FileSwapBytes(D,
        D->reference_field->fragment_index));

  if (nf < 0) {
    _GD_SetError(D, GD_E_RAW_IO, 0, D->reference_field->e->u.raw.file[0].name,
        errno, NULL);
    dreturn("%lli", 0LL);
    return 0;
  }

  nf /= D->reference_field->EN(raw,spf);
  nf += D->fragment[D->reference_field->fragment_index].frame_offset;

  dreturn("%lli", (unsigned long long)nf);
  return nf;
}
示例#16
0
文件: spf.c 项目: syntheticpp/dirfile
/* _GD_GetSPF: Get samples per frame for field
*/
unsigned int _GD_GetSPF(DIRFILE *D, gd_entry_t *E)
{
  unsigned int spf = 0;

  dtrace("%p, %p", D, E);

  if (++D->recurse_level >= GD_MAX_RECURSE_LEVEL) {
    _GD_SetError(D, GD_E_RECURSE_LEVEL, GD_E_RECURSE_CODE, NULL, 0, E->field);
    dreturn("%u", 0);
    D->recurse_level--;
    return 0;
  }

  switch(E->field_type) {
    case GD_RAW_ENTRY:
      if (!E->e->calculated)
        _GD_CalculateEntry(D, E, 1);
      if (!D->error)
        spf = E->EN(raw,spf);
      break;
    case GD_LINCOM_ENTRY:
    case GD_MULTIPLY_ENTRY:
    case GD_DIVIDE_ENTRY:
    case GD_RECIP_ENTRY:
    case GD_BIT_ENTRY:
    case GD_PHASE_ENTRY:
    case GD_LINTERP_ENTRY:
    case GD_POLYNOM_ENTRY:
    case GD_SBIT_ENTRY:
    case GD_WINDOW_ENTRY:
    case GD_MPLEX_ENTRY:
      if (_GD_BadInput(D, E, 0, 1))
        break;

      spf = _GD_GetSPF(D, E->e->entry[0]);
      break;
    case GD_INDEX_ENTRY:
      spf = 1;
      break;
    case GD_CONST_ENTRY:
    case GD_CARRAY_ENTRY:
    case GD_STRING_ENTRY:
    case GD_ALIAS_ENTRY:
    case GD_NO_ENTRY:
      _GD_InternalError(D);
  }

  D->recurse_level--;
  dreturn("%u", spf);
  return spf;
}
示例#17
0
int WindowEntry::SetWindOp(WindOpType windop)
{
  int ret = 0;

  dtrace("0x%X", (unsigned)windop);

  E.u.window.windop = (gd_windop_t)windop;

  if (D != NULL)
    ret = gd_alter_entry(D->D, E.field, &E, 0);
  
  dreturn("%i", ret);
  return ret;
}
示例#18
0
static void CopyLinterpEntry(struct LinterpEntryType* L, gd_entry_t* E)
{
  dtrace("%p, %p", L, E);

  if (E == NULL) {
    dreturnvoid();
    return;
  }

  L->field = E->field;
  L->raw_field = E->in_fields[0];
  L->linterp_file = E->EN(linterp,table);

  dreturnvoid();
}
示例#19
0
int WindowEntry::SetThreshold(gd_triplet_t threshold)
{
  int ret = 0;

  dtrace("{%g,%llX,%lli}", threshold.r, (unsigned long long)threshold.u,
      (long long)threshold.i);

  E.u.window.threshold = threshold;

  if (D != NULL)
    ret = gd_alter_entry(D->D, E.field, &E, 0);
  
  dreturn("%i", ret);
  return ret;
}
示例#20
0
static void CopyMultDivEntry(struct MultiplyEntryType* M, gd_entry_t* E)
{
  dtrace("%p, %p", M, E);

  if (E == NULL) {
    dreturnvoid();
    return;
  }

  M->field = E->field;
  M->in_fields[0] = E->in_fields[0];
  M->in_fields[1] = E->in_fields[1];

  dreturnvoid();
}
示例#21
0
static int _GD_ContainsFragment(int* f, int nf, int fragment)
{
  int i;

  dtrace("%p, %i, %i", f, nf, fragment);

  for (i = 0; i < nf; ++i)
    if (f[i] == fragment) {
      dreturn("%i", 1);
      return 1;
    }

  dreturn("%i", 0);
  return 0;
}
示例#22
0
/* _GD_CopyGlobalError: Copy the last error message to the global error buffer.
*/
static int _GD_CopyGlobalError(DIRFILE* D)
{
  dtrace("%p", D);

  _GD_GlobalErrors.suberror = D->suberror;
  _GD_GlobalErrors.error_line = D->error_line;
  free(_GD_GlobalErrors.error_file);
  _GD_GlobalErrors.error_file = (D->error_file) ? strdup(D->error_file) : NULL;
  free(_GD_GlobalErrors.error_string);
  _GD_GlobalErrors.error_string = (D->error_string) ? strdup(D->error_string) :
    NULL;

  dreturn("%i", D->error);
  return _GD_GlobalErrors.error = D->error;
}
示例#23
0
static void CopyPhaseEntry(struct PhaseEntryType* P, gd_entry_t* E)
{
  dtrace("%p, %p", P, E);

  if (E == NULL) {
    dreturnvoid();
    return;
  }

  P->field = E->field;
  P->raw_field = E->in_fields[0];
  P->shift = E->EN(phase,shift);

  dreturnvoid();
}
示例#24
0
static void CopyBitEntry(struct BitEntryType* B, gd_entry_t* E)
{
  dtrace("%p, %p", B, E);

  if (E == NULL) {
    dreturnvoid();
    return;
  }

  B->field = E->field;
  B->raw_field = E->in_fields[0];
  B->bitnum = E->EN(bit,bitnum);
  B->numbits = E->EN(bit,numbits);

  dreturnvoid();
}
示例#25
0
static void CopyWindowEntry(struct MPlexEntryType* M, gd_entry_t* E)
{
  dtrace("%p, %p", M, E);

  if (E == NULL) {
    dreturnvoid();
    return;
  }

  M->field = E->field;
  M->data_field = E->in_fields[0];
  M->cnt_field = E->in_fields[1];
  M->i = (int)E->EN(window,windop);
  M->max_i = (int)E->EN(window,threshold.i);

  dreturnvoid();
}
示例#26
0
static void CopyReciprocalEntry(struct LincomEntryType* L, gd_entry_t* E)
{
  dtrace("%p, %p", L, E);

  if (E == NULL) {
    dreturnvoid();
    return;
  }

  L->field = E->field;
  L->n_fields = 1;
  L->in_fields[0] = E->in_fields[0];
  L->m[0] = E->EN(recip,dividend);
  L->b[0] = 0;

  dreturnvoid();
}
示例#27
0
static void CopyMplexEntry(struct MPlexEntryType* M, gd_entry_t* E)
{
  dtrace("%p, %p", M, E);

  if (E == NULL) {
    dreturnvoid();
    return;
  }

  M->field = E->field;
  M->data_field = E->in_fields[0];
  M->cnt_field = E->in_fields[1];
  M->i = (int)E->EN(mplex,count_val);
  M->max_i = (int)E->EN(mplex,count_max);

  dreturnvoid();
}
示例#28
0
int _GD_Bzip2Open(int dirfd, struct _gd_raw_file* file, int swap __gd_unused,
    unsigned int mode __gd_unused)
{
  dtrace("%i, %p, <unused>, <unused>", dirfd, file);

  file->edata = _GD_Bzip2DoOpen(dirfd, file);

  if (file->edata == NULL) {
    dreturn("%i", 1);
    return 1;
  }

  file->mode = GD_FILE_READ;
  file->idata = 0;
  dreturn("%i", 0);
  return 0;
}
示例#29
0
/* We operate under the myth that POLYNOMs are actually LINCOMs.  We report them
 * to have one input field, and discard non-linear terms */
static void CopyPolynomEntry(struct LincomEntryType* L, gd_entry_t* E)
{
  dtrace("%p, %p", L, E);

  if (E == NULL) {
    dreturnvoid();
    return;
  }

  L->field = E->field;
  L->n_fields = 1;
  L->in_fields[0] = E->in_fields[0];
  L->m[0] = E->EN(polynom,a)[1];
  L->b[0] = E->EN(polynom,a)[0];

  dreturnvoid();
}
示例#30
0
int gd_alter_frameoffset64(DIRFILE* D, off64_t offset, int fragment, int move)
{
  int i;

  dtrace("%p, %lli, %i, %i", D, (long long)offset, fragment, move);

  if (D->flags & GD_INVALID) {/* don't crash */
    _GD_SetError(D, GD_E_BAD_DIRFILE, 0, NULL, 0, NULL);
    dreturn("%i", -1);
    return -1;
  }

  if ((D->flags & GD_ACCMODE) != GD_RDWR) {
    _GD_SetError(D, GD_E_ACCMODE, 0, NULL, 0, NULL);
    dreturn("%i", -1);
    return -1;
  }

  if (fragment < GD_ALL_FRAGMENTS || fragment >= D->n_fragment) {
    _GD_SetError(D, GD_E_BAD_INDEX, 0, NULL, 0, NULL);
    dreturn("%i", -1);
    return -1;
  }

  if (offset < 0) {
    _GD_SetError(D, GD_E_RANGE, GD_E_OUT_OF_RANGE, NULL, 0, NULL);
    dreturn("%i", -1);
    return -1;
  }

  _GD_ClearError(D);

  if (fragment == GD_ALL_FRAGMENTS) {
    for (i = 0; i < D->n_fragment; ++i) {
      _GD_ShiftFragment(D, offset, i, move);

      if (D->error)
        break;
    }
  } else
    _GD_ShiftFragment(D, offset, fragment, move);

  dreturn("%i", (D->error) ? -1 : 0);
  return (D->error) ? -1 : 0;
}