Esempio n. 1
0
void InputThread::ctrl_open_input(const FXString & uri) {
  GM_DEBUG_PRINT("[input] ctrl_open_input %s\n",uri.text());

  if (uri.empty()) {
    goto failed;
    }

  /// Open Input
  input=open_input(uri);
  if (input==NULL) {
    engine->post(new ErrorMessage(FXString::value("Unable to open %s",uri.text())));
    goto failed;
    }

  reader = open_reader();
  if (reader==NULL) {
    engine->post(new ErrorMessage(FXString::value("No input plugin available for %s",uri.text())));
    goto failed;
    }

  if (!reader->init(input)) {
    engine->post(new ErrorMessage(FXString::value("Failed to initialize plugin")));
    goto failed;
    }

  streamid++;
  set_state(StateProcessing,true);
  return;
failed:
  ctrl_close_input();
  set_state(StateIdle,true);
  }
Esempio n. 2
0
void InputThread::ctrl_open_inputs(const FXStringList & urls){
  for (FXint i=0;i<urls.no();i++){
    GM_DEBUG_PRINT("[input] ctrl_open_inputs[%d] %s\n",i,urls[i].text());
    if (urls[i].empty()) continue;

    /// Open Input
    input=open_input(urls[i]);
    if (input==NULL) {
      if (aborted()) break;
      continue;
      }

    /// Open Reader
    reader = open_reader();
    if (reader==NULL) continue;

    if (!reader->init(input))
      continue;

    streamid++;
    set_state(StateProcessing,true);
    return;
    }
  ctrl_close_input();
  set_state(StateIdle,true);
  }
Esempio n. 3
0
File: main.c Progetto: taysom/tau
struct db open_db(const char *dir)
{
    struct db db;

    db.w = open_logger(path(dir, "log"));
    db.r = open_reader(path(dir, "log"));
    db.mt = open_mtree(path(dir, "mtree"));
    db.bag = new_bag(BAG_SIZE);
    return db;
}
Esempio n. 4
0
/* Print errors to stderr if occured.
 * Returns true if error occured and false in normally case. */
bool get_file_hash(u256_t hash, const char * filepath)
{
    reader_state rs;
    u256_t message;

    if (open_reader(&rs, filepath))
    {
        print_error(stderr, rs.err_msg);
        return rs.err;
    }

    hasher_state hs;
    init_hasher(&hs);

    do
    {
        int cnt = read_u256(&rs, message);

        if (cnt < 1)
        {
            if (!rs.err && rs.eof)
            {
                break;
            }

            // Ignore possible close errors.
            close_reader(&rs);

            print_error(stderr, rs.err_msg);
            return rs.err;
        }

        make_hasher_step(&hs, message, cnt);
    }
    while (!rs.eof);

    // As defined in GOST R 34.11-94.
    if (rs.filesize == 0)
    {
        make_hasher_step(&hs, message, 0u);
    }

    if (close_reader(&rs))
    {
        print_error(stderr, rs.err_msg);
        return rs.err;
    }

    get_hash(hash, &hs);
    return rs.err;
}