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,
24 * Do you think I should move this code into another file? -- ]d
32 #ifdef DRAWSTRING_PLUGIN
49 wPluginPackInitData(int members
, ...)
54 p
= wmalloc(sizeof(void *) * (members
+ 1));
55 memset(p
, 0, sizeof(void *) * (members
+ 1));
56 va_start(vp
, members
);
57 for(i
=0;i
<members
;i
++) {
58 p
[i
] = va_arg(vp
, void *);
59 printf(" %d > %d\n",i
,(int)p
[i
]);
61 printf(" s> %s\n",(char*)p
[2]);
67 wPluginCreateFunction(int type
, char *library_name
,
68 char *init_proc_name
, char *proc_name
, char *free_data_proc_name
,
69 proplist_t pl_arg
, void *init_data
)
72 _DL_InitDataProc
*initProc
;
74 function
= wmalloc(sizeof(WFunction
));
75 memset(function
, 0, sizeof(WFunction
));
77 function
->handle
= dlopen(library_name
, RTLD_LAZY
);
78 if (!function
->handle
) {
79 wwarning(_("library \"%s\" cound not be opened."), library_name
);
84 function
->proc
.any
= dlsym(function
->handle
, proc_name
);
85 if (!function
->proc
.any
) {
86 wwarning(_("function \"%s\" not found in library \"%s\""), proc_name
, library_name
);
87 dlclose(function
->handle
);
92 if (free_data_proc_name
) {
93 function
->freeData
= dlsym(function
->handle
, free_data_proc_name
);
94 if (!function
->freeData
) {
95 wwarning(_("function \"%s\" not found in library \"%s\""), free_data_proc_name
, library_name
);
97 dlclose(function->handle);
104 if (pl_arg
) function
->arg
= PLDeepCopy(pl_arg
);
105 function
->data
= init_data
;
106 if (init_proc_name
) {
107 initProc
= dlsym(function
->handle
, init_proc_name
);
109 initProc(function
->arg
, function
->data
);
111 /* Where's my english teacher? -- ]d
112 wwarning(_("ignore?"),?);
117 function
->type
= type
;
122 wPluginDestroyFunction(WFunction
*function
)
127 if (function
->data
) {
128 if (function
->freeData
) {
129 function
->freeData(&function
->data
);
131 free(function
->data
);
134 if (function
->arg
) PLRelease(function
->arg
);