Exemple #1
0
static bool default_generators(
    w_query *query,
    w_root_t *root,
    struct w_query_ctx *ctx,
    void *gendata)
{
  bool generated = false;

  unused_parameter(gendata);

  // Time based query
  if (ctx->since.is_timestamp || !ctx->since.clock.is_fresh_instance) {
    if (!time_generator(query, root, ctx)) {
      return false;
    }
    generated = true;
  }

  // Suffix
  if (query->suffixes) {
    if (!suffix_generator(query, root, ctx)) {
      return false;
    }
    generated = true;
  }

  if (query->npaths) {
    if (!path_generator(query, root, ctx)) {
      return false;
    }
    generated = true;
  }

  // And finally, if there were no other generators, we walk all known
  // files
  if (!generated) {
    if (!all_files_generator(query, root, ctx)) {
      return false;
    }
  }

  return true;
}
Exemple #2
0
static bool default_generators(
    w_query *query,
    w_root_t *root,
    struct w_query_ctx *ctx,
    void *gendata,
    int64_t *num_walked)
{
  bool generated = false;
  int64_t n = 0;
  int64_t total = 0;
  bool result = true;

  unused_parameter(gendata);

  // Time based query
  if (ctx->since.is_timestamp || !ctx->since.clock.is_fresh_instance) {
    n = 0;
    result = time_generator(query, root, ctx, &n);
    total += n;
    if (!result) {
      goto done;
    }
    generated = true;
  }

  // Suffix
  if (query->suffixes) {
    n = 0;
    result = suffix_generator(query, root, ctx, &n);
    total += n;
    if (!result) {
      goto done;
    }
    generated = true;
  }

  if (query->npaths) {
    n = 0;
    result = path_generator(query, root, ctx, &n);
    total += n;
    if (!result) {
      goto done;
    }
    generated = true;
  }

  // And finally, if there were no other generators, we walk all known
  // files
  if (!generated) {
    n = 0;
    result = all_files_generator(query, root, ctx, &n);
    total += n;
    if (!result) {
      goto done;
    }
  }

done:
  *num_walked = total;
  return result;
}