コード例 #1
0
ファイル: cache.c プロジェクト: Illuminux/forked-daapd
/*
 * Adds the given (scaled) artwork image to the artwork cache
 *
 * @param persistentid persistent songalbumid or songartistid
 * @param max_w maximum image width
 * @param max_h maximum image height
 * @param format ART_FMT_PNG for png, ART_FMT_JPEG for jpeg or 0 if no artwork available
 * @param filename the full path to the artwork file (could be an jpg/png image or a media file with embedded artwork) or empty if no artwork available
 * @param evbuf event buffer containing the (scaled) image
 * @return 0 if successful, -1 if an error occurred
 */
int
cache_artwork_add(int64_t persistentid, int max_w, int max_h, int format, char *filename, struct evbuffer *evbuf)
{
  struct cache_command cmd;
  int ret;

  if (!g_initialized)
    return -1;

  command_init(&cmd);

  cmd.func = cache_artwork_add_impl;
  cmd.arg.peristentid = persistentid;
  cmd.arg.max_w = max_w;
  cmd.arg.max_h = max_h;
  cmd.arg.format = format;
  cmd.arg.path = strdup(filename);
  cmd.arg.evbuf = evbuf;

  ret = sync_command(&cmd);

  command_deinit(&cmd);

  return ret;
}
コード例 #2
0
ファイル: cache.c プロジェクト: Illuminux/forked-daapd
/*
 * Get the cached artwork image for the given persistentid and maximum width/height
 *
 * If there is a cached entry for the given id and width/height, the parameter cached is set to 1.
 * In this case format and data contain the cached values.
 *
 * @param persistentid persistent songalbumid or songartistid
 * @param max_w maximum image width
 * @param max_h maximum image height
 * @param cached set by this function to 0 if no cache entry exists, otherwise 1
 * @param format set by this function to the format of the cache entry
 * @param evbuf event buffer filled by this function with the scaled image
 * @return 0 if successful, -1 if an error occurred
 */
int
cache_artwork_get(int64_t persistentid, int max_w, int max_h, int *cached, int *format, struct evbuffer *evbuf)
{
  struct cache_command cmd;
  int ret;

  if (!g_initialized)
    return -1;

  command_init(&cmd);

  cmd.func = cache_artwork_get_impl;
  cmd.arg.peristentid = persistentid;
  cmd.arg.max_w = max_w;
  cmd.arg.max_h = max_h;
  cmd.arg.evbuf = evbuf;

  ret = sync_command(&cmd);

  *format = cmd.arg.format;
  *cached = cmd.arg.cached;

  command_deinit(&cmd);

  return ret;
}
コード例 #3
0
ファイル: parser_imp.cpp プロジェクト: Paradoxika/lean
/** \brief Parse a sequence of commands. This method also perform error management. */
bool parser_imp::parse_commands() {
    bool done = false;
    while (!done) {
        protected_call([&]() {
                check_interrupted();
                switch (curr()) {
                case scanner::token::CommandId:   if (!parse_command()) done = true; break;
                case scanner::token::ScriptBlock: parse_script(); break;
                case scanner::token::Period:      show_prompt(); next(); break;
                case scanner::token::Eof:         done = true; break;
                default:
                    throw parser_error("Command expected", pos());
                }
            },
            [&]() { sync_command(); });
    }
    return !m_found_errors;
}
コード例 #4
0
ファイル: cache.c プロジェクト: Illuminux/forked-daapd
/*
 * Removes all cache entries with cached timestamp older than the given reference timestamp
 *
 * @param ref reference timestamp
 * @return 0 if successful, -1 if an error occurred
 */
int
cache_artwork_purge_cruft(time_t ref)
{
  struct cache_command cmd;
  int ret;

  if (!g_initialized)
    return -1;

  command_init(&cmd);

  cmd.func = cache_artwork_purge_cruft_impl;
  cmd.arg.mtime = ref;

  ret = sync_command(&cmd);

  command_deinit(&cmd);

  return ret;
}
コード例 #5
0
ファイル: cache.c プロジェクト: Illuminux/forked-daapd
/*
 * Removes all cache entries for the given path
 *
 * @param path the full path to the artwork file (could be an jpg/png image or a media file with embedded artwork)
 * @return 0 if successful, -1 if an error occurred
 */
int
cache_artwork_delete_by_path(char *path)
{
  struct cache_command cmd;
  int ret;

  if (!g_initialized)
    return -1;

  command_init(&cmd);

  cmd.func = cache_artwork_delete_by_path_impl;
  cmd.arg.path = strdup(path);

  ret = sync_command(&cmd);

  command_deinit(&cmd);

  return ret;
}
コード例 #6
0
ファイル: cache.c プロジェクト: Illuminux/forked-daapd
/*
 * Updates cached timestamps to current time for all cache entries for the given path, if the file was not modfied
 * after the cached timestamp.
 *
 * If the parameter "del" is greater than 0, all cache entries for the given path are deleted, if the file was
 * modified after the cached timestamp.
 *
 * @param path the full path to the artwork file (could be an jpg/png image or a media file with embedded artwork)
 * @param mtime modified timestamp of the artwork file
 * @param del if > 0 cached entries for the given path are deleted if the cached timestamp (db_timestamp) is older than mtime
 * @return 0 if successful, -1 if an error occurred
 */
int
cache_artwork_ping(char *path, time_t mtime)
{
  struct cache_command cmd;
  int ret;

  if (!g_initialized)
    return -1;

  command_init(&cmd);

  cmd.func = cache_artwork_ping_impl;
  cmd.arg.path = strdup(path);
  cmd.arg.mtime = mtime;

  ret = sync_command(&cmd);

  command_deinit(&cmd);

  return ret;
}
コード例 #7
0
ファイル: cache.c プロジェクト: Illuminux/forked-daapd
int
cache_daap_get(const char *query, struct evbuffer *evbuf)
{
  struct cache_command cmd;
  int ret;

  if (!g_initialized)
    return -1;

  command_init(&cmd);

  cmd.func = cache_daap_query_get;
  cmd.arg.query = strdup(query);
  cmd.arg.evbuf = evbuf;

  ret = sync_command(&cmd);

  command_deinit(&cmd);

  return ret;
}
コード例 #8
0
ファイル: parser_imp.cpp プロジェクト: codyroux/lean0.1
parser_imp::parser_imp(environment const & env, io_state const & st, std::istream & in, char const * strm_name,
                       script_state * S, bool use_exceptions, bool interactive):
    m_env(env),
    m_io_state(st),
    m_scanner(in, strm_name),
    m_strm_name(strm_name),
    m_elaborator(env),
    m_use_exceptions(use_exceptions),
    m_interactive(interactive),
    m_script_state(S),
    m_set_parser(m_script_state, this) {
    m_unary_nat = false;
    m_namespace_prefixes.push_back(name());
    m_check_identifiers = true;
    updt_options();
    m_found_errors = false;
    m_num_local_decls = 0;
    m_scanner.set_command_keywords(get_command_keywords());
    if (m_script_state) {
        m_script_state->apply([&](lua_State * L) {
                m_expr_macros   = &get_expr_macros(L);
                m_tactic_macros = &get_tactic_macros(L);
                m_cmd_macros    = &get_cmd_macros(L);
                for (auto const & p : *m_cmd_macros) {
                    m_scanner.add_command_keyword(p.first);
                }
            });
    } else {
        m_expr_macros   = nullptr;
        m_tactic_macros = nullptr;
        m_cmd_macros    = nullptr;
    }
    // Initialize m_curr with some value. We need that because scan()
    // may fail, and m_curr will remain uninitialized.
    // In thi case, Valgrind would report unit var errors.
    m_curr = scanner::token::Id;
    protected_call([&]() { scan(); },
                   [&]() { sync_command(); });
}