[gaim-migrate @ 4676]
[pidgin-git.git] / plugins / error.c
blobb430b3c0f785d1b54c669c870719a4182db504f1
1 #define GAIM_PLUGINS
2 #include "gaim.h"
4 #include <stdlib.h>
5 #include <time.h>
7 char *gaim_plugin_error(int);
9 char *gaim_plugin_init(GModule *handle) {
10 int error;
12 /* so here, we load any callbacks, do the normal stuff */
14 srand(time(NULL));
15 error = rand() % 3;
16 error -= 2;
17 /* there's a 1 in 3 chance there *won't* be an error :) */
18 return gaim_plugin_error(error);
21 void gaim_plugin_remove() {
22 /* this only gets called if we get loaded successfully, and then
23 * unloaded. */
26 char *gaim_plugin_error(int error) {
27 /* by the time we've gotten here, all our callbacks are removed.
28 * we just have to deal with what the error was (as defined by us)
29 * and do any other clean-up stuff we need to do. */
30 switch (error) {
31 case -1:
32 return "MY BAD";
33 case -2:
34 return "Internal plugin error: exiting.";
35 default:
36 return NULL;
40 struct gaim_plugin_description desc;
41 struct gaim_plugin_description *gaim_plugin_desc() {
42 desc.api_version = PLUGIN_API_VERSION;
43 desc.name = g_strdup("Error Tester");
44 desc.version = g_strdup(VERSION);
45 desc.description = g_strdup("A plugin that causes error messages.");
46 desc.authors = g_strdup("Eric Warmehoven &lt;eric@warmenhoven.org>");
47 desc.url = g_strdup(WEBSITE);
48 return &desc;
51 char *name() {
52 return "Error Tester " VERSION ;
55 char *description() {
56 return "A nice little program that causes error messages";