Exemple #1
0
void if_shutdown(void)
{
    /* Shut down curses cleanly */
    if (curses_initialized)
        swin_endwin();

    if (status_win) {
        swin_delwin(status_win);
        status_win = NULL;
    }

    if (gdb_scroller) {
        scr_free(gdb_scroller);
        gdb_scroller = NULL;
    }

    if (src_viewer) {
        source_free(src_viewer);
        src_viewer = NULL;
    }

    if (vseparator_win) {
        swin_delwin(vseparator_win);
        vseparator_win = NULL;
    }

    if (G_line_number) {
        ibuf_free(G_line_number);
        G_line_number = 0;
    }
}
Exemple #2
0
void source_unregister(struct btd_service *service)
{
	struct btd_device *dev = btd_service_get_device(service);

	DBG("%s", device_get_path(dev));

	source_free(service);
}
Exemple #3
0
static void path_unregister(void *data)
{
	struct audio_device *dev = data;

	debug("Unregistered interface %s on path %s",
		AUDIO_SOURCE_INTERFACE, dev->path);

	source_free(dev);
}
Exemple #4
0
void if_shutdown(void)
{
    /* Shut down curses cleanly */
    if (curses_initialized)
        endwin();

    if (status_win != NULL)
        delwin(status_win);

    if (tty_status_win != NULL)
        delwin(tty_status_win);

    if (gdb_win != NULL)
        scr_free(gdb_win);

    if (tty_win != NULL)
        scr_free(tty_win);

    if (src_win != NULL)
        source_free(src_win);
}
struct source *source_new_htcnf(const tn_hash *htcnf) 
{
    char spec[PATH_MAX];
    struct source *src;
    const char *vs, *type, *srcnam;
    int  n = 0;
    int  v;
    
    vs = poldek_conf_get(htcnf, "name", NULL);
    if (vs == NULL)
        vs = "anon";
    srcnam = vs;
    
    n += n_snprintf(&spec[n], sizeof(spec) - n, "%s", vs);

    if ((vs = poldek_conf_get(htcnf, "type", NULL)))
        n += n_snprintf(&spec[n], sizeof(spec) - n, ",type=%s", vs);
    type = vs;
    
    if ((v = poldek_conf_get_int(htcnf, "pri", 0)))
        n += n_snprintf(&spec[n], sizeof(spec) - n, ",pri=%d", v);
    
    if ((v = poldek_conf_get_bool(htcnf, "noauto", 0)))
        n += n_snprintf(&spec[n], sizeof(spec) - n, ",noauto");
    
    else if ((v = poldek_conf_get_bool(htcnf, "auto", 1)) == 0)
        n += n_snprintf(&spec[n], sizeof(spec) - n, ",noauto");

    if ((v = poldek_conf_get_bool(htcnf, "noautoup", 0)))
        n += n_snprintf(&spec[n], sizeof(spec) - n, ",noautoup");
    
    else if ((v = poldek_conf_get_bool(htcnf, "autoup", 1)) == 0)
        n += n_snprintf(&spec[n], sizeof(spec) - n, ",noautoup");

    if ((v = poldek_conf_get_bool(htcnf, "signed", 0)))
        n += n_snprintf(&spec[n], sizeof(spec) - n, ",sign");
    
    else if ((v = poldek_conf_get_bool(htcnf, "sign", 0)))
        n += n_snprintf(&spec[n], sizeof(spec) - n, ",sign");

    if ((vs = poldek_conf_get(htcnf, "lang", NULL)))
        n += n_snprintf(&spec[n], sizeof(spec) - n, ",lang=%s", vs);

    vs = poldek_conf_get(htcnf, "path", NULL);
    if (vs == NULL)
        vs = poldek_conf_get(htcnf, "url", NULL);
    
    if (vs == NULL && type && n_str_ne(type, source_TYPE_GROUP)) {
        logn(LOGERR, "source: %s: missing required 'path'", srcnam);
        return NULL;
    }
    
    if (type && n_str_eq(type, source_TYPE_GROUP)) {
        char tmp[PATH_MAX], *p;
        int i, n = 0;
        
        tn_array *arr = poldek_conf_get_multi(htcnf, "sources");
        n_array_sort(arr); 
        for (i=0; i<n_array_size(arr); i++) 
            n += n_snprintf(&tmp[n], sizeof(tmp) - n, "%s%s", n_array_nth(arr, i),
                            i < n_array_size(arr) - 1 ? ", " : "");
        n_array_free(arr);
        n_strdupap((char*)tmp, &p);
        vs = p;
    }

    //printf("spec %d = %s\n", n_hash_size(htcnf), spec);
    //n_assert(vs);
    
    n_snprintf(&spec[n], sizeof(spec) - n, " %s", vs);
    
    vs = poldek_conf_get(htcnf, "prefix", NULL);
    
    src = source_new_pathspec(NULL, spec, vs);
    
    vs = poldek_conf_get(htcnf, "original type", NULL);
    if (vs && src->type && n_str_eq(src->type, vs)) {
        logn(LOGERR, "%s: original type and type must be differ",
             source_idstr(src));
        
        source_free(src);
        return NULL;
    }
    if (vs)
        src->original_type = n_strdup(vs);
    
    get_conf_opt_list(htcnf, "exclude path", src->exclude_path);
    get_conf_opt_list(htcnf, "ignore", src->ign_patterns);
    return src;
}
int source_make_idx(struct source *src, const char *stype, 
                    const char *dtype, const char *idxpath,
                    unsigned flags, tn_hash *kw)
{
    struct source *ssrc;
    int typcaps;
    int rc = 0;

    DBGF("%s(src=%s) => %s\n", stype, src->type ? src->type : "null", dtype);
    if (stype == NULL)
        stype = determine_stype(src, idxpath);
    
    if (src->type == NULL)
        source_set_default_type(src);
    n_assert(src->type);
    
    if (dtype == NULL) {
           /* if not from config */
        if ((src->flags & PKGSOURCE_NAMED) == 0) {
            if (n_str_eq(src->type, "dir"))
                dtype = poldek_conf_PKGDIR_DEFAULT_TYPE;
            /* stype not default one, so guess destination type is default */
            else if (n_str_ne(stype, poldek_conf_PKGDIR_DEFAULT_TYPE))
                dtype = poldek_conf_PKGDIR_DEFAULT_TYPE;
        }
        
        if (dtype == NULL)
            dtype = src->type;
    }
    
    ssrc = source_dup(src);
    /* swap types */
    source_set(&ssrc->type, stype);
    ssrc->flags &= ~(PKGSOURCE_NAMED);
    
    rc = 1;
    if ((typcaps = pkgdir_type_info(dtype)) < 0)
        rc = 0;
    
    else if ((typcaps & PKGDIR_CAP_SAVEABLE) == 0) {
        logn(LOGERR, _("%s: repository could not be created (missing "
                       "feature)"), dtype);
        rc = 0;

    } else if (idxpath == NULL) {
        if (source_is_remote(src)) { 
            logn(LOGERR, _("%s: unable to write remote index"),
                 source_idstr(src));
            rc = 0;
            
        } else if (source_is_type(ssrc, dtype)) { /* same type */
            struct stat st;

            if (stat(ssrc->path, &st) == 0) {
                logn(LOGERR, _("%s: refusing to overwrite index"),
                     source_idstr(ssrc));
                rc = 0;
            }
            /* if not exists, let do_source_make_idx() to shout */
        }
    }

    if (rc) {
        DBGF("do %s(%s) => %s\n", stype, src->type ? src->type : "null", dtype);
        rc = do_source_make_idx(ssrc, dtype, idxpath, flags, kw);
    }
    
    source_free(ssrc);
    return rc;
}
Exemple #7
0
void source_unregister(struct audio_device *dev)
{
	DBG("%s", device_get_path(dev->btd_dev));

	source_free(dev);
}