po: updated German translation
[ncmpc.git] / src / plugin.h
blobe6331544aa0087a7fb962dec4e260eecd0659021
1 /* ncmpc (Ncurses MPD Client)
2 * (c) 2004-2009 The Music Player Daemon Project
3 * Project homepage: http://musicpd.org
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 #ifndef PLUGIN_H
21 #define PLUGIN_H
23 #include <glib.h>
24 #include <stdbool.h>
26 /**
27 * A list of registered plugins.
29 struct plugin_list {
30 GPtrArray *plugins;
33 /**
34 * When a plugin cycle is finished, this function is called. In any
35 * case, plugin_stop() has to be called to free all memory.
37 * @param result the plugin's output (stdout) on success; summary of all error
38 * messages on failure as determined by success
39 * @param success result of the plugin cycle; true if result is meaningful
40 * output, false if result contains error messages
41 * @param data the caller defined pointer passed to plugin_run()
43 typedef void (*plugin_callback_t)(const GString *result, const bool success,
44 void *data);
46 /**
47 * This object represents a cycle through all available plugins, until
48 * a plugin returns a positive result.
50 struct plugin_cycle;
52 /**
53 * Initialize an empty plugin_list structure.
55 static inline void
56 plugin_list_init(struct plugin_list *list)
58 list->plugins = g_ptr_array_new();
61 /**
62 * Load all plugins (executables) in a directory.
64 bool
65 plugin_list_load_directory(struct plugin_list *list, const char *path);
67 /**
68 * Frees all memory held by the plugin_list object (but not the
69 * pointer itself).
71 void plugin_list_deinit(struct plugin_list *list);
73 /**
74 * Run plugins in this list, until one returns success (or until the
75 * plugin list is exhausted).
77 * @param list the plugin list
78 * @param args NULL terminated command line arguments passed to the
79 * plugin programs
80 * @param callback the callback function which will be called when a
81 * result is available
82 * @param callback_data caller defined pointer which is passed to the
83 * callback function
85 struct plugin_cycle *
86 plugin_run(struct plugin_list *list, const char *const*args,
87 plugin_callback_t callback, void *callback_data);
89 /**
90 * Stops the plugin cycle and frees resources. This can be called to
91 * abort the current cycle, or after the plugin_callback_t has been
92 * invoked.
94 void
95 plugin_stop(struct plugin_cycle *invocation);
97 #endif