Ejemplo n.º 1
0
static void close_modules (void)
{
    int count = index_count (plugins);
    for (int i = 0; i < count; i ++)
        close_plugin (index_get (plugins, i));

    index_delete (plugins, 0, count);

    count = index_count (modules);
    for (int i = 0; i < count; i ++)
        g_module_close (index_get (modules, i));

    index_delete (modules, 0, count);
}
Ejemplo n.º 2
0
static void free_args(struct args *args) {
    unsigned int i;

    if (args->topic_file) {
        for (i = 0; i < args->topic_files; i++) {
            if (args->topic_file[i]) {
                free(args->topic_file[i]);
                args->topic_file[i] = NULL;
            }
        }
        free(args->topic_file);
    }

    if (args->stoplist) {
        free(args->stoplist);
    }

    if (args->idx) {
        index_delete(args->idx);
        args->idx = NULL;
    }

    if (args->run_id) {
        free(args->run_id);
        args->run_id = NULL;
    }

    if (args->qrels) {
        treceval_qrels_delete(&args->qrels);
    }

    free(args);
    return;
}
Ejemplo n.º 3
0
static int
pkg_fire(dialogMenuItem *self)
{
    int ret;
    ListPtrsPtr lists = (ListPtrsPtr)self->aux;
    PkgNodePtr sp, kp = self->data, plist = lists->plist;

    if (!plist)
	ret = DITEM_FAILURE;
    else if (kp->type == PACKAGE) {
	IndexEntryPtr ie = kp->data;

	sp = index_search(plist, kp->name, NULL);
	/* Not already selected? */
	if (!sp) {
	    if (!ie->installed) {
		PkgNodePtr np = (PkgNodePtr)safe_malloc(sizeof(PkgNode));

		*np = *kp;
		np->next = plist->kids;
		plist->kids = np;
		index_recorddeps(TRUE, lists->root, ie);
		msgInfo("Added %s to selection list", kp->name);
	    }
	    else if (ie->depc == 0) {
		if (!msgNoYes("Do you really want to delete %s from the system?", kp->name)) {
		    if (vsystem("pkg_delete %s %s", isDebug() ? "-v" : "", kp->name)) {
			msgConfirm("Warning:  pkg_delete of %s failed.\n  Check debug output for details.", kp->name);
		    }
		    else {
			ie->installed = 0;
			index_recorddeps(FALSE, lists->root, ie);
		    }
		}
	    }
	    else
		msgConfirm("Warning: Package %s is needed by\n  %d other installed package%s.",
			   kp->name, ie->depc, (ie->depc != 1) ? "s" : "");
	}
	else {
	    index_recorddeps(FALSE, lists->root, ie);
	    msgInfo("Removed %s from selection list", kp->name);
	    index_delete(sp);
	}
	ret = DITEM_SUCCESS;
	/* Mark menu for redraw if we had dependencies */
	if (strlen(ie->deps) > 0)
	    ret |= DITEM_REDRAW;
    }
    else {	/* Not a package, must be a directory */
	int p, s;
		    
	p = s = 0;
	index_menu(lists->root, kp, plist, &p, &s);
	ret = DITEM_SUCCESS | DITEM_CONTINUE;
    }
    return ret;
}
Ejemplo n.º 4
0
static void destroy_database (void)
{
    if (items)
        index_delete (items, 0, index_count (items));

    if (database)
    {
        g_hash_table_destroy (database);
        database = NULL;
    }
}
Ejemplo n.º 5
0
static void equalizerwin_delete_preset (Index * list, gchar * name, gchar * filename)
{
    int p = equalizerwin_find_preset (list, name);
    if (p < 0)
        return;

    EqualizerPreset * preset = index_get (list, p);
    equalizer_preset_free(preset);
    index_delete (list, p, 1);

    aud_equalizer_write_preset_file(list, filename);
}
Ejemplo n.º 6
0
void disable_plugin_locked (int i)
{
    g_return_if_fail (i >= 0 && i < index_count (loadeds));
    LoadedPlugin * loaded = index_get (loadeds, i);

    if (loaded->settings_win)
        gtk_widget_destroy (loaded->settings_win);

    shutdown_plugin_locked (loaded);

    g_free (loaded->values);
    g_slice_free (LoadedPlugin, loaded);
    index_delete (loadeds, i, 1);
}
Ejemplo n.º 7
0
static int fulltextUpdate(sqlite3_vtab *pVtab, int nArg, sqlite3_value **ppArg,
                   sqlite_int64 *pRowid){
  fulltext_vtab *v = (fulltext_vtab *) pVtab;

  if( nArg<2 ){
    return index_delete(v, sqlite3_value_int64(ppArg[0]));
  }

  if( sqlite3_value_type(ppArg[0]) != SQLITE_NULL ){
    return SQLITE_ERROR;   /* an update; not yet supported */
  }

  assert( nArg==3 );    /* ppArg[1] = rowid, ppArg[2] = content */
  return index_insert(v, ppArg[1],
                      (const char *)sqlite3_value_text(ppArg[2]), pRowid);
}
Ejemplo n.º 8
0
static void do_search (void)
{
    index_delete (items, 0, index_count (items));

    if (! database)
        return;

    SearchState state;

    for (int f = 0; f < FIELDS; f ++)
        state.items[f] = index_new ();

    /* effectively limits number of search terms to 32 */
    state.mask = (1 << index_count (search_terms)) - 1;

    g_hash_table_foreach (database, search_cb, & state);

    int total = 0;

    for (int f = 0; f < FIELDS; f ++)
    {
        int count = index_count (state.items[f]);
        if (count > MAX_RESULTS - total)
            count = MAX_RESULTS - total;

        if (count)
        {
            index_sort (state.items[f], item_compare);
            index_copy_insert (state.items[f], 0, items, -1, count);
            total += count;
        }

        index_free (state.items[f]);
    }

    g_array_set_size (selection, total);
    memset (selection->data, 0, selection->len);
    if (selection->len > 0)
        selection->data[0] = 1;
}
Ejemplo n.º 9
0
static void transfer (Index * source)
{
    Index * dest;
    GtkWidget * source_list, * dest_list;
    if (source == chosen)
    {
        dest = avail;
        source_list = chosen_list;
        dest_list = avail_list;
    }
    else
    {
        dest = chosen;
        source_list = avail_list;
        dest_list = chosen_list;
    }

    gint source_rows = index_count (source);
    gint dest_rows = index_count (dest);

    for (gint row = 0; row < source_rows; )
    {
        Column * c = index_get (source, row);
        if (! c->selected)
        {
            row ++;
            continue;
        }

        index_delete (source, row, 1);
        audgui_list_delete_rows (source_list, row, 1);
        source_rows --;
        index_append (dest, c);
        audgui_list_insert_rows (dest_list, dest_rows, 1);
        dest_rows ++;
    }
}
Ejemplo n.º 10
0
/* A simple wrap.
 * Just to make the interfaces of the index module more consistent.
 */
static inline void delete_an_entry(fingerprint *fp, int64_t *id){
	index_delete(fp, *id);
}