Removed titlebar drop shadow code and add plugin to draw text on titlebars.
[wmaker-crm.git] / src / plugin.c
blob04d2615028e73c0bd1c9dbef4412b857bbd2dd1d
1 /* plugin.c- plugin
3 * Window Maker window manager
5 * Copyright (c) hmmm... Should I put everybody's name here?
6 * Where's my lawyer?? -- ]d :D
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
21 * USA.
23 * * * * * * * * *
24 * Do you think I should move this code into another file? -- ]d
27 #include "plugin.h"
29 #ifdef TEXTURE_PLUGIN
30 # ifdef HAVE_DLFCN_H
31 # include <dlfcn.h>
32 # endif
33 #endif
35 #include <proplist.h>
37 WFunction *
38 wPluginCreateFunction(int type, char *library_name,
39 char *init_proc_name, char *proc_name, char *free_data_proc_name,
40 proplist_t pl_arg, void *init_data) {
41 WFunction *function;
42 _DL_InitDataProc *initProc;
44 function = wmalloc(sizeof(WFunction));
45 bzero(function, sizeof(WFunction));
47 function->handle = dlopen(library_name, RTLD_LAZY);
48 if (!function->handle) {
49 wwarning(_("library \"%s\" cound not be opened."), library_name);
50 free(function);
51 return NULL;
54 function->proc.any = dlsym(function->handle, proc_name);
55 if (!function->proc.any) {
56 wwarning(_("function \"%s\" not found in library \"%s\""), proc_name, library_name);
57 dlclose(function->handle);
58 free(function);
59 return NULL;
62 if (free_data_proc_name) {
63 function->freeData = dlsym(function->handle, free_data_proc_name);
64 if (!function->freeData) {
65 wwarning(_("function \"%s\" not found in library \"%s\""), free_data_proc_name, library_name);
66 dlclose(function->handle);
67 free(function);
68 return NULL;
72 if (pl_arg) function->arg = PLDeepCopy(pl_arg);
73 function->data = init_data;
74 if (init_proc_name) {
75 initProc = dlsym(function->handle, init_proc_name);
76 if (initProc) {
77 initProc(function->arg, &function->data);
78 } else {
79 /* Where's my english teacher? -- ]d
80 wwarning(_("?"),?);
82 dlclose(function->handle);
83 free(function);
87 function->type = type;
88 return function;
91 void
92 wPluginDestroyFunction(WFunction *function) {
93 if (!function) return;
94 if (function->data) {
95 if (function->freeData) {
96 function->freeData(&function->data);
97 } else {
98 free(function->data);
101 if (function->arg) PLRelease(function->arg);
102 free(function);
103 return;
106 /* hmmmm, need another function to pack a va_list
107 * but better move on something else for now :D */