2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these libraries and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
23 // $XConsortium: XpmLib.cc /main/3 1996/06/11 16:30:30 cde-hal $
24 /* Copyright (c) 1994,1995 FUJITSU LIMITED */
25 /* All Rights Reserved */
30 #define C_WindowSystem
38 static XpmLib g_xpmlib;
40 #define XPMLIB_PREFIX "libXpm.so"
41 #define XPMLIB_DEFAULT_PATH "libXpm.so.4.1"
43 static char* default_path = XPMLIB_DEFAULT_PATH;
45 XpmLib* XpmLib::f_xpm_lib;
47 XpmLib::XpmLib(const char* arg_path, int open_mode) : f_handle(0)
56 if (! path || *path == '\0')
59 if (! (f_handle = dlopen(path, open_mode)))
60 f_handle = dlopen(XPMLIB_PREFIX, open_mode);
69 void* XpmLib::symbol(const char* name)
71 if (! f_handle || ! name || *name == '\0')
74 return dlsym(f_handle, name);
77 int XpmLib::CreatePixmapFromData(Display *display, Drawable d, char **data,
78 Pixmap *pixmap_return, Pixmap *shapemask_return,
79 XpmAttributes *attributes)
83 int (*func)(Display*, Drawable, char**, Pixmap*, Pixmap*, XpmAttributes*);
85 func = (int (*)(Display*, Drawable, char**, Pixmap*, Pixmap*, XpmAttributes*)) symbol("XpmCreatePixmapFromData");
88 status = (*func)(display, d, data, pixmap_return,
89 shapemask_return, attributes);
96 int XpmLib::CreatePixmapFromBuffer(Display *display, Drawable d, char *buffer,
97 Pixmap *pixmap_return, Pixmap *shapemask_return,
98 XpmAttributes *attributes)
102 int (*func)(Display*, Drawable, char*, Pixmap*, Pixmap*, XpmAttributes*);
104 func = (int (*)(Display*, Drawable, char*, Pixmap*, Pixmap*, XpmAttributes*)) symbol("XpmCreatePixmapFromBuffer");
107 status = (*func)(display, d, buffer, pixmap_return,
108 shapemask_return, attributes);
115 int XpmLib::ReadFileToPixmap(Display *display, Drawable d, char *filename,
116 Pixmap *pixmap_return, Pixmap *shapemask_return,
117 XpmAttributes *attributes)
121 int (*func)(Display*, Drawable, char*, Pixmap*, Pixmap*, XpmAttributes*);
123 func = (int (*)(Display*, Drawable, char*, Pixmap*, Pixmap*, XpmAttributes*)) symbol("XpmReadFileToPixmap");
126 status = (*func)(display, d, filename, pixmap_return,
127 shapemask_return, attributes);