forked from old/legacy-imlib2
added Gary V. Vaughan's patches for libtool loader stuff and now its all
automaked... :) SVN revision: 33
This commit is contained in:
parent
7fab5526f4
commit
a825029849
|
@ -0,0 +1,33 @@
|
|||
## Process this file with automake to produce Makefile.in
|
||||
|
||||
AUTOMAKE_OPTIONS = 1.4 foreign
|
||||
|
||||
# A list of all the files in the current directory which can be regenerated
|
||||
MAINTAINERCLEANFILES = INSTALL Makefile.in aclocal.m4 config.guess \
|
||||
config.h.in config.sub configure install-sh loaderpath.h \
|
||||
ltconfig ltmain.sh missing mkinstalldirs stamp-h.in
|
||||
|
||||
SUBDIRS = libltdl
|
||||
|
||||
# CFLAGS = -O -g -mpentium -mcpu=pentium -march=pentium
|
||||
LDFLAGS = -L/usr/X11R6/lib
|
||||
INCLUDES = -I/usr/X11R6/include -I$(top_srcdir)/libltdl
|
||||
|
||||
pkgdir = $(HOME)/.loaders/image
|
||||
pkg_LTLIBRARIES = png.la
|
||||
png_la_SOURCES = loader_png.c
|
||||
png_la_LDFLAGS = -no-undefined -module -avoid-version
|
||||
png_la_LIBADD = -lpng -lz -lX11 -lXext
|
||||
|
||||
bin_PROGRAMS = imlib2
|
||||
imlib2_SOURCES = rend.c ximage.c scale.c main.c rgba.c image.c \
|
||||
color.c grab.c blend.c file.c
|
||||
imlib2_LDADD = @DLLDFLAGS@ $(top_builddir)/libltdl/libltdlc.la -lX11 -lXext
|
||||
|
||||
SYS_LOADERS_PATH = @pkglibdir@
|
||||
|
||||
image.o: loaderpath.h
|
||||
loaderpath.h: Makefile
|
||||
@echo "#define SYS_LOADERS_PATH \"${SYS_LOADERS_PATH}\"" > $@
|
||||
@echo "#define USER_LOADERS_PATH \".loaders\"" >> $@
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
#! /bin/sh
|
||||
|
||||
set -x
|
||||
autoheader
|
||||
libtoolize --ltdl --force --copy
|
||||
aclocal
|
||||
automake --foreign --add-missing --copy
|
||||
autoconf
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
dnl Process this file with autoconf to create configure.
|
||||
|
||||
AC_INIT(rgba.h)
|
||||
AM_CONFIG_HEADER(config.h)
|
||||
AM_INIT_AUTOMAKE(imlib, 2.0)
|
||||
|
||||
pkglibdir='${libdir}'/loaders
|
||||
AC_SUBST(pkglibdir)
|
||||
|
||||
AC_LIBLTDL_CONVENIENCE
|
||||
AC_CONFIG_SUBDIRS(libltdl)
|
||||
|
||||
AC_PROG_CC
|
||||
AM_PROG_CC_STDC
|
||||
AC_C_CONST
|
||||
|
||||
AM_ENABLE_SHARED
|
||||
AM_DISABLE_STATIC
|
||||
AC_LIBTOOL_DLOPEN
|
||||
AC_LIBTOOL_WIN32_DLL
|
||||
AM_PROG_LIBTOOL
|
||||
|
||||
if test X"$enable_shared" = Xyes; then
|
||||
DLLDFLAGS=-export-dynamic
|
||||
AC_SUBST(DLLDFLAGS)
|
||||
fi
|
||||
|
||||
AC_PROG_INSTALL
|
||||
AC_PROG_MAKE_SET
|
||||
|
||||
AC_MSG_CHECKING(whether fopen accepts "b" mode)
|
||||
AC_CACHE_VAL([ag_cv_func_fopen_binary],
|
||||
[AC_TRY_RUN([#include <stdio.h>
|
||||
int main (int argc, char *argv[])
|
||||
{
|
||||
FILE *fp = fopen("/bin/sh", "rb");
|
||||
return (fclose(fp) >= 0);
|
||||
}],[ag_cv_func_fopen_binary=yes],
|
||||
[ag_cv_func_fopen_binary=yes],[ag_cv_func_fopen_binary=yes])
|
||||
rm -f core *.exe.core])
|
||||
AC_MSG_RESULT([$ag_cv_func_fopen_binary])
|
||||
if test x$ag_cv_func_fopen_binary = xyes; then
|
||||
AC_DEFINE(USE_FOPEN_BINARY, 1,
|
||||
[Define this if we can use the "b" mode for fopen safely.])
|
||||
fi
|
||||
|
||||
LTLIBOBJS=`echo "$LIBOBJS" | sed 's,.o ,.lo ,g;s,.o$,.lo,'`
|
||||
AC_SUBST(LTLIBOBJS)
|
||||
|
||||
AC_OUTPUT(Makefile,
|
||||
[test -z "$CONFIG_HEADERS" || echo timestamp > stamp-h])
|
48
image.c
48
image.c
|
@ -5,6 +5,7 @@
|
|||
#include <X11/Xlib.h>
|
||||
#include "image.h"
|
||||
#include "file.h"
|
||||
#include "loaderpath.h"
|
||||
|
||||
static ImlibImage *images = NULL;
|
||||
static ImlibImagePixmap *pixmaps = NULL;
|
||||
|
@ -340,27 +341,56 @@ __imlib_CleanupImagePixmapCache()
|
|||
}
|
||||
}
|
||||
|
||||
#define LOADERS_UNINITIALISED -4444
|
||||
|
||||
static void
|
||||
LTDL_Init(void)
|
||||
{
|
||||
static int errors = LOADERS_UNINITIALISED;
|
||||
|
||||
|
||||
/* Do this only once! */
|
||||
if (errors = LOADERS_UNINITIALISED)
|
||||
{
|
||||
errors = lt_dlinit();
|
||||
|
||||
/* Initialise libltdl's memory management. */
|
||||
lt_dlmalloc = malloc;
|
||||
lt_dlfree = free;
|
||||
}
|
||||
|
||||
/* Failing ltdl initialisation makes continuing somewhat futile... */
|
||||
if (errors != 0)
|
||||
{
|
||||
const char *dlerror = lt_dlerror();
|
||||
fprintf(stderr, "ERROR: failed to initialise ltdl: %s\n", dlerror);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
ImlibLoader *
|
||||
__imlib_ProduceLoader(char *file)
|
||||
{
|
||||
ImlibLoader *l;
|
||||
void (*l_formats)(ImlibLoader *l) ;
|
||||
|
||||
LTDL_Init();
|
||||
|
||||
l = malloc(sizeof(ImlibLoader));
|
||||
l->num_formats = 0;
|
||||
l->formats = NULL;
|
||||
l->handle = dlopen(file, RTLD_NOW);
|
||||
l->handle = lt_dlopenext(file);
|
||||
if (!l->handle)
|
||||
{
|
||||
free(l);
|
||||
return NULL;
|
||||
}
|
||||
l->load = dlsym(l->handle, "load");
|
||||
l->save = dlsym(l->handle, "save");
|
||||
l_formats = dlsym(l->handle, "formats");
|
||||
l->load = lt_dlsym(l->handle, "load");
|
||||
l->save = lt_dlsym(l->handle, "save");
|
||||
l_formats = lt_dlsym(l->handle, "formats");
|
||||
if ((!(l->load)) || (!(l->save)) || (!(l_formats)))
|
||||
{
|
||||
dlclose(l->handle);
|
||||
lt_dlclose(l->handle);
|
||||
free(l);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -378,7 +408,7 @@ __imlib_ListLoaders(int *num_ret)
|
|||
|
||||
*num_ret = 0;
|
||||
home = __imlib_FileHomeDir(getuid());
|
||||
sprintf(s, "%s/.loaders/image/", home);
|
||||
sprintf(s, "%s/" USER_LOADERS_PATH "/image", home);
|
||||
l = __imlib_FileDir(s, &num);
|
||||
if (num > 0)
|
||||
{
|
||||
|
@ -386,13 +416,13 @@ __imlib_ListLoaders(int *num_ret)
|
|||
list = malloc(sizeof(char *) * *num_ret);
|
||||
for (i = 0; i < num; i++)
|
||||
{
|
||||
sprintf(s, "%s/.loaders/image/%s", home, l[i]);
|
||||
sprintf(s, "%s/" USER_LOADERS_PATH "/image/%s", home, l[i]);
|
||||
list[i] = strdup(s);
|
||||
}
|
||||
pi = i;
|
||||
__imlib_FileFreeDirList(l, num);
|
||||
}
|
||||
sprintf(s, "/usr/lib/loaders/image/");
|
||||
sprintf(s, SYS_LOADERS_PATH "/image");
|
||||
l = __imlib_FileDir(s, &num);
|
||||
if (num > 0)
|
||||
{
|
||||
|
@ -400,7 +430,7 @@ __imlib_ListLoaders(int *num_ret)
|
|||
list = realloc(list, sizeof(char *) * *num_ret);
|
||||
for (i = 0; i < num; i++)
|
||||
{
|
||||
sprintf(s, "/usr/lib/loaders/image/%s", l[i]);
|
||||
sprintf(s, SYS_LOADERS_PATH "/image/%s", l[i]);
|
||||
list[pi + i] = strdup(s);
|
||||
}
|
||||
__imlib_FileFreeDirList(l, num);
|
||||
|
|
4
image.h
4
image.h
|
@ -1,6 +1,8 @@
|
|||
#ifndef __IMAGE
|
||||
# define __IMAGE 1
|
||||
|
||||
#include "ltdl.h" /* for lt_dlhandle definition */
|
||||
|
||||
typedef enum _iflags ImlibImageFlags;
|
||||
typedef struct _imlibimage ImlibImage;
|
||||
typedef struct _imlibimagepixmap ImlibImagePixmap;
|
||||
|
@ -58,7 +60,7 @@ struct _imlibloader
|
|||
char *file;
|
||||
int num_formats;
|
||||
char **formats;
|
||||
void *handle;
|
||||
lt_dlhandle handle;
|
||||
char (*load)(ImlibImage *im,
|
||||
void (*progress)(ImlibImage *im, char percent,
|
||||
int update_x, int update_y,
|
||||
|
|
15
loader_png.c
15
loader_png.c
|
@ -1,3 +1,14 @@
|
|||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
/* Some architectures require non-text files be opened in binary mode. */
|
||||
#ifdef USE_FOPEN_BINARY
|
||||
# define FOPEN_BINARY_FLAG "b"
|
||||
#else
|
||||
# define FOPEN_BINARY_FLAG
|
||||
#endif
|
||||
|
||||
#include "common.h"
|
||||
#include <string.h>
|
||||
#include <X11/Xlib.h>
|
||||
|
@ -6,7 +17,7 @@
|
|||
#include "image.h"
|
||||
#include <png.h>
|
||||
|
||||
/* this is a quick sample png loader module... nioce and small isnt it? */
|
||||
/* this is a quick sample png loader module... nice and small isnt it? */
|
||||
|
||||
/* PNG stuff */
|
||||
#define PNG_BYTES_TO_CHECK 4
|
||||
|
@ -81,7 +92,7 @@ RGBA_Load(char *file, int *w, int *h)
|
|||
FILE *f;
|
||||
DATA32 *data;
|
||||
|
||||
f = fopen(file, "r");
|
||||
f = fopen(file, "r" FOPEN_BINARY_FLAG);
|
||||
data = (DATA32 *)_load_PNG(w, h, f);
|
||||
fclose(f);
|
||||
return data;
|
||||
|
|
Loading…
Reference in New Issue