annotate plugins/error.c @ 4833:a6960b4b0c9b

[gaim-migrate @ 5158] A fix for the bug described in patch 702766, filed by darkrain: "gaim still segfaults if you click on the docklet just after starting gaim in the account editor." https://sourceforge.net/tracker/index.php?func=detail&aid=702766&group_id=235&atid=300235 committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Wed, 19 Mar 2003 22:31:05 +0000
parents cd938f18f3f8
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
391
be408b41c172 [gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1 #define GAIM_PLUGINS
be408b41c172 [gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2 #include "gaim.h"
be408b41c172 [gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3
be408b41c172 [gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
4 #include <stdlib.h>
be408b41c172 [gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
5 #include <time.h>
be408b41c172 [gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
6
1047
ece2d1543b20 [gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 398
diff changeset
7 char *gaim_plugin_error(int);
ece2d1543b20 [gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 398
diff changeset
8
ece2d1543b20 [gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 398
diff changeset
9 char *gaim_plugin_init(GModule *handle) {
391
be408b41c172 [gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
10 int error;
be408b41c172 [gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
11
be408b41c172 [gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
12 /* so here, we load any callbacks, do the normal stuff */
be408b41c172 [gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
13
be408b41c172 [gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
14 srand(time(NULL));
be408b41c172 [gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
15 error = rand() % 3;
398
59d97cd251ff [gaim-migrate @ 408]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 396
diff changeset
16 error -= 2;
391
be408b41c172 [gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
17 /* there's a 1 in 3 chance there *won't* be an error :) */
1047
ece2d1543b20 [gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 398
diff changeset
18 return gaim_plugin_error(error);
391
be408b41c172 [gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
19 }
be408b41c172 [gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
20
be408b41c172 [gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
21 void gaim_plugin_remove() {
be408b41c172 [gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
22 /* this only gets called if we get loaded successfully, and then
be408b41c172 [gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
23 * unloaded. */
be408b41c172 [gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
24 }
be408b41c172 [gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
25
be408b41c172 [gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
26 char *gaim_plugin_error(int error) {
be408b41c172 [gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
27 /* by the time we've gotten here, all our callbacks are removed.
be408b41c172 [gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
28 * we just have to deal with what the error was (as defined by us)
be408b41c172 [gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
29 * and do any other clean-up stuff we need to do. */
be408b41c172 [gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
30 switch (error) {
398
59d97cd251ff [gaim-migrate @ 408]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 396
diff changeset
31 case -1:
1047
ece2d1543b20 [gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 398
diff changeset
32 return "MY BAD";
398
59d97cd251ff [gaim-migrate @ 408]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 396
diff changeset
33 case -2:
391
be408b41c172 [gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
34 return "Internal plugin error: exiting.";
1047
ece2d1543b20 [gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 398
diff changeset
35 default:
ece2d1543b20 [gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 398
diff changeset
36 return NULL;
391
be408b41c172 [gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
37 }
be408b41c172 [gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
38 }
be408b41c172 [gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
39
3551
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 1047
diff changeset
40 struct gaim_plugin_description desc;
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 1047
diff changeset
41 struct gaim_plugin_description *gaim_plugin_desc() {
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 1047
diff changeset
42 desc.api_version = PLUGIN_API_VERSION;
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 1047
diff changeset
43 desc.name = g_strdup("Error Tester");
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 1047
diff changeset
44 desc.version = g_strdup(VERSION);
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 1047
diff changeset
45 desc.description = g_strdup("A plugin that causes error messages.");
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 1047
diff changeset
46 desc.authors = g_strdup("Eric Warmehoven &lt;eric@warmenhoven.org>");
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 1047
diff changeset
47 desc.url = g_strdup(WEBSITE);
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 1047
diff changeset
48 return &desc;
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 1047
diff changeset
49 }
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 1047
diff changeset
50
391
be408b41c172 [gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
51 char *name() {
396
b1d5c6ab7b0d [gaim-migrate @ 406]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 393
diff changeset
52 return "Error Tester " VERSION ;
391
be408b41c172 [gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
53 }
be408b41c172 [gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
54
be408b41c172 [gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
55 char *description() {
be408b41c172 [gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
56 return "A nice little program that causes error messages";
be408b41c172 [gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
57 }