Esempio n. 1
0
File: mu-index.c Progetto: Dabg/mu
MuError
mu_index_run (MuIndex *index, const char *path,
	      gboolean reindex, MuIndexStats *stats,
	      MuIndexMsgCallback msg_cb, MuIndexDirCallback dir_cb,
	      void *user_data)
{
	MuIndexCallbackData cb_data;
	MuError rv;

	g_return_val_if_fail (index && index->_store, MU_ERROR);
	g_return_val_if_fail (msg_cb, MU_ERROR);

	if (!check_path (path))
		return MU_ERROR;

	if (!reindex && index->_needs_reindex) {
		g_warning ("database not up-to-date; needs full reindex");
		return MU_ERROR;
	}

	init_cb_data (&cb_data, index->_store, reindex,
		      index->_max_filesize, stats,
		      msg_cb, dir_cb, user_data);

	rv = mu_maildir_walk (path,
			      (MuMaildirWalkMsgCallback)on_run_maildir_msg,
			      (MuMaildirWalkDirCallback)on_run_maildir_dir,
			      reindex, /* re-index, ie. do a full update */
			      &cb_data);

	mu_store_flush (index->_store);

	return rv;
}
Esempio n. 2
0
MuError
mu_cmd_server (MuStore *store, MuConfig *opts/*unused*/, GError **err)
{
	ServerContext ctx;
	gboolean do_quit;

	g_return_val_if_fail (store, MU_ERROR_INTERNAL);

	ctx.store = store;
	ctx.query = mu_query_new (store, err);
	if (!ctx.query)
		return MU_G_ERROR_CODE (err);

	srand (time(NULL)*getpid());

	install_sig_handler ();

	g_print (";; welcome to " PACKAGE_STRING "\n");

	/*  the main REPL */
	do_quit = FALSE;
	while (!MU_TERMINATE && !do_quit) {

		GHashTable	*args;
		GError		*my_err;

		/* args will receive a the command as a list of
		 * strings. returning NULL indicates an error */
		my_err = NULL;
		args   = read_command_line (&my_err);
		if (!args) {
			if (feof(stdin))
				break;
			if (my_err)
				print_and_clear_g_error (&my_err);
			continue;
		}

		switch (handle_args (&ctx, args, &my_err)) {
		case MU_OK:
			break;
		case MU_STOP:
			do_quit = TRUE;
			break;
		default: /* some error occurred */
			print_and_clear_g_error (&my_err);
		}

		g_hash_table_destroy (args);
	}

	mu_store_flush   (ctx.store);
	mu_query_destroy (ctx.query);

	return MU_OK;
}
Esempio n. 3
0
File: mu-index.c Progetto: Dabg/mu
MuError
mu_index_cleanup (MuIndex *index, MuIndexStats *stats,
		  MuIndexCleanupDeleteCallback cb,
		  void *user_data, GError **err)
{
	MuError rv;
	CleanupData cudata;

	g_return_val_if_fail (index, MU_ERROR);

	cudata._store	  = index->_store;
	cudata._stats	  = stats;
	cudata._cb	  = cb;
	cudata._user_data = user_data;

	rv = mu_store_foreach (index->_store,
			       (MuStoreForeachFunc)foreach_doc_cb,
			       &cudata, err);

	mu_store_flush (index->_store);

	return rv;
}