Edb is dead.

This commit is contained in:
Kim Woelders 2013-03-24 21:16:48 +01:00
parent 0149dcf7ce
commit 0540ddc0ef
5 changed files with 1 additions and 454 deletions

View File

@ -13,10 +13,6 @@ is distributed under the BSD license, whereas the XCF loader is using
elements of the Gimp's (www.gimp.org) codebase, which is distributed
under the GPL. The XCF loader therefore is GPL'd as well.
2 other loaders are here too:
EDB and EET
------------------------------------------------------------------------------
COMPILING AND INSTALLING:

View File

@ -84,17 +84,6 @@ packagesrcdir=`cd $srcdir && pwd`
AC_DEFINE_UNQUOTED(PACKAGE_SOURCE_DIR, "${packagesrcdir}", [Source code directory])
edb=auto
AC_ARG_ENABLE(edb,
[ --disable-edb disable building the edb loader],
[
if test x$enableval = xno; then
edb=no
else
edb=yes
fi
])
eet=auto
AC_ARG_ENABLE(eet,
[ --disable-eet disable building the eet loader],
@ -125,19 +114,6 @@ AC_ARG_WITH(imlib2-config, [ --with-imlib2-config=IMLIB2_CONFIG use imlib2-c
my_includes=`$IMLIB2_CONFIG --cflags`
found_edb=no
if test "x$edb" != "xno" ; then
PKG_CHECK_MODULES(EDB, edb, found_edb=yes, found_edb=no)
fi
if test "x$edb$found_edb" = "xyesno" ; then
AC_MSG_ERROR(Edb support was requested but not found)
elif test "x$found_edb" = "xno" ; then
edb=no
EDB_CFLAGS=""
EDB_LIBS=""
fi
found_eet=no
if test "x$eet" != "xno" ; then
PKG_CHECK_MODULES(EET, eet, found_eet=yes, found_eet=no)
@ -151,12 +127,9 @@ elif test "x$found_eet" = "xno" ; then
fi
AC_SUBST(my_includes)
AC_SUBST(EDB_CFLAGS)
AC_SUBST(EDB_LIBS)
AC_SUBST(EET_CFLAGS)
AC_SUBST(EET_LIBS)
AM_CONDITIONAL(BUILD_EDB_LOADER, test x$edb != xno)
AM_CONDITIONAL(BUILD_EET_LOADER, test x$eet != xno)
AM_CONDITIONAL(BUILD_XCF_LOADER, test x$xcf != xno)
@ -172,12 +145,6 @@ imlib2_loaders.spec
echo -e "\nBuild summary:"
echo "------------------------"
echo -n " EDB: "
if test x$edb = xno ; then
echo "Disabled "
else
echo "Enabled "
fi
echo -n " EET: "
if test x$eet = xno ; then
echo "Disabled "

View File

@ -9,7 +9,7 @@ Source: %{name}-%{version}.tar.gz
Packager: %{?_packager:%{_packager}}%{!?_packager:Michael Jennings <mej@eterm.org>}
Vendor: %{?_vendorinfo:%{_vendorinfo}}%{!?_vendorinfo:The Enlightenment Project (http://www.enlightenment.org/)}
Distribution: %{?_distribution:%{_distribution}}%{!?_distribution:%{_vendor}}
#BuildSuggests: xorg-x11-devel freetype-devel freetype2-devel xproto edb-devel
#BuildSuggests: xorg-x11-devel freetype-devel freetype2-devel xproto
BuildRequires: /usr/bin/freetype-config /usr/include/X11/X.h libjpeg-devel
BuildRequires: eet-devel imlib2-devel
BuildRoot: %{_tmppath}/%{name}-%{version}-root

View File

@ -8,9 +8,6 @@ AM_CPPFLAGS = -I. \
pkgdir = $(libdir)/imlib2/loaders
if BUILD_EDB_LOADER
EDB_L = db.la
endif
if BUILD_EET_LOADER
EET_L = eet.la
endif
@ -19,17 +16,11 @@ XCF_L = xcf.la
endif
pkg_LTLIBRARIES = \
$(EDB_L) \
$(EET_L) \
$(XCF_L) \
ico.la \
ani.la
db_la_SOURCES = loader_db.c common.h image.h
db_la_CPPFLAGS = @EDB_CFLAGS@ $(AM_CPPFLAGS)
db_la_LDFLAGS = -module -avoid-version
db_la_LIBADD = @EDB_LIBS@
eet_la_SOURCES = loader_eet.c common.h image.h
eet_la_CPPFLAGS = @EET_CFLAGS@ $(AM_CPPFLAGS)
eet_la_LDFLAGS = -module -avoid-version

View File

@ -1,407 +0,0 @@
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include "common.h"
#include <string.h>
#include <X11/Xlib.h>
#include <X11/extensions/XShm.h>
#include <X11/Xutil.h>
#include "image.h"
char load (ImlibImage *im, ImlibProgressFunction progress,
char progress_granularity, char immediate_load);
char save (ImlibImage *im, ImlibProgressFunction progress,
char progress_granularity);
void formats (ImlibLoader *l);
#define SWAP32(x) (x) = \
((((x) & 0x000000ff ) << 24) |\
(((x) & 0x0000ff00 ) << 8) |\
(((x) & 0x00ff0000 ) >> 8) |\
(((x) & 0xff000000 ) >> 24))
#include <Edb.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/stat.h>
#include <zlib.h>
static int
permissions(char *file)
{
struct stat st;
if (stat(file, &st) < 0)
return 0;
return st.st_mode;
}
static int
exists(char *file)
{
struct stat st;
if (stat(file, &st) < 0)
return 0;
return 1;
}
static int
can_read(char *file)
{
#ifndef __EMX__
if (!(permissions(file) & (S_IRUSR | S_IRGRP | S_IROTH)))
#else
if (!(permissions(file)))
#endif
return 0;
return (1 + access(file, R_OK));
}
static int
can_write(char *file)
{
#ifndef __EMX__
if (!(permissions(file) & (S_IWUSR | S_IWGRP | S_IWOTH)))
#else
if (!(permissions(file)))
#endif
return 0;
return (1 + access(file, W_OK));
}
char
load (ImlibImage *im, ImlibProgressFunction progress,
char progress_granularity, char immediate_load)
{
int w, h, alpha, compression, size;
E_DB_File *db;
char file[4096], key[4096];
DATA32 *ret;
DATA32 *body;
if (im->data)
return 0;
if ((!im->file) || (!im->real_file) || (!im->key))
return 0;
strcpy(file, im->real_file);
strcpy(key, im->key);
if (!can_read(file)) return 0;
db = e_db_open_read(file);
if (!db)
return 0;
ret = e_db_data_get(db, key, &size);
if (!ret)
{
e_db_close(db);
return 0;
}
/* header */
{
DATA32 header[8];
if (size < 32)
{
free(ret);
e_db_close(db);
return 0;
}
memcpy(header, ret, 32);
#ifdef WORDS_BIGENDIAN
{
int i;
for (i = 0; i < 8; i++)
SWAP32(header[i]);
}
#endif
if (header[0] != 0xac1dfeed)
{
free(ret);
e_db_close(db);
return 0;
}
w = header[1];
h = header[2];
alpha = header[3];
compression = header[4];
if ((w > 8192) || (h > 8192))
{
free(ret);
e_db_close(db);
return 0;
}
if ((compression == 0) && (size < ((w * h * 4) + 32)))
{
free(ret);
e_db_close(db);
return 0;
}
im->w = w;
im->h = h;
if (!im->format)
{
if (alpha)
SET_FLAG(im->flags, F_HAS_ALPHA);
else
UNSET_FLAG(im->flags, F_HAS_ALPHA);
im->format = strdup("db");
}
}
if (((!im->data) && (im->loader)) || (immediate_load) || (progress))
{
DATA32 *ptr;
int y, pl = 0;
char pper = 0;
body = &(ret[8]);
/* must set the im->data member before callign progress function */
if (!compression)
{
if (progress)
{
char per;
int l;
ptr = im->data = malloc(w * h * sizeof(DATA32));
if (!im->data)
{
free(ret);
e_db_close(db);
return 0;
}
for (y = 0; y < h; y++)
{
#ifdef WORDS_BIGENDIAN
{
int x;
memcpy(ptr, &(body[y * w]), im->w * sizeof(DATA32));
for (x = 0; x < im->w; x++)
SWAP32(ptr[x]);
}
#else
memcpy(ptr, &(body[y * w]), im->w * sizeof(DATA32));
#endif
ptr += im->w;
per = (char)((100 * y) / im->h);
if (((per - pper) >= progress_granularity) ||
(y == (im->h - 1)))
{
l = y - pl;
if(!progress(im, per, 0, (y - l), im->w, l))
{
free(ret);
e_db_close(db);
return 2;
}
pper = per;
pl = y;
}
}
}
else
{
ptr = im->data = malloc(w * h * sizeof(DATA32));
if (!im->data)
{
free(ret);
e_db_close(db);
return 0;
}
#ifdef WORDS_BIGENDIAN
{
int x;
memcpy(ptr, body, im->w * im->h * sizeof(DATA32));
for (x = 0; x < (im->w * im->h); x++)
SWAP32(ptr[x]);
}
#else
memcpy(ptr, body, im->w * im->h * sizeof(DATA32));
#endif
}
}
else
{
uLongf dlen;
dlen = w * h * sizeof(DATA32);
im->data = malloc(w * h * sizeof(DATA32));
if (!im->data)
{
free(ret);
e_db_close(db);
return 0;
}
uncompress((Bytef *)im->data, &dlen, (Bytef *)body, (uLongf)(size - 32));
#ifdef WORDS_BIGENDIAN
{
int x;
for (x = 0; x < (im->w * im->h); x++)
SWAP32(im->data[x]);
}
#endif
if (progress)
progress(im, 100, 0, 0, im->w, im->h);
}
}
free(ret);
e_db_close(db);
return 1;
}
char
save (ImlibImage *im, ImlibProgressFunction progress,
char progress_granularity)
{
int alpha = 0;
char file[4096], key[4096], *tmp;
DATA32 *header;
DATA32 *buf;
E_DB_File *db;
int compression = 0, size = 0;
DATA32 *ret;
/* no image data? abort */
if (!im->data)
return 0;
if (im->flags & F_HAS_ALPHA)
alpha = 1;
if ((!im->file) || (!im->real_file))
return 0;
strcpy(file, im->real_file);
tmp = strrchr(file, ':');
if(!tmp)
return 0;
*tmp++ = '\0';
if(!*tmp)
return 0;
strcpy(key, tmp);
if (exists(file))
{
if (!can_write(file)) return 0;
if (!can_read(file)) return 0;
}
db = e_db_open(file);
if (!db)
return 0;
/* account for space for compression */
buf = (DATA32 *) malloc((((im->w * im->h * 101) / 100) + 3 + 8) * sizeof(DATA32));
header = buf;
header[0] = 0xac1dfeed;
header[1] = im->w;
header[2] = im->h;
header[3] = alpha;
{
ImlibImageTag *tag;
tag = __imlib_GetTag(im, "compression");
if (!tag)
header[4] = 0;
else
{
compression = tag->val;
if (compression < 0)
compression = 0;
else if (compression > 9)
compression = 9;
header[4] = compression;
}
}
if (compression > 0)
{
DATA32 *compressed;
int retr;
uLongf buflen;
compressed = &(buf[8]);
buflen = ((im->w * im->h * sizeof(DATA32) * 101) / 100) + 12;
#ifdef WORDS_BIGENDIAN
{
int i;
DATA32 *buf2;
for (i = 0; i < 8; i++)
SWAP32(header[i]);
buf2 = malloc((((im->w * im->h * 101) / 100) + 3) * sizeof(DATA32));
if (buf2)
{
int y;
memcpy(buf2, im->data, im->w * im->h * sizeof(DATA32));
for (y = 0; y < (im->w * im->h) + 8; y++)
SWAP32(buf2[y]);
retr = compress2((Bytef *)compressed, &buflen,
(Bytef *)buf2,
(uLong)(im->w * im->h * sizeof(DATA32)),
compression);
free(buf2);
}
else
retr = Z_MEM_ERROR;
}
#else
retr = compress2((Bytef *)compressed, &buflen,
(Bytef *)im->data,
(uLong)(im->w * im->h * sizeof(DATA32)),
compression);
#endif
if (retr != Z_OK)
compressed = 0;
else
{
if (buflen >= (im->w * im->h * sizeof(DATA32)))
compressed = 0;
else
size = (8 * sizeof(DATA32)) + buflen;
}
}
else
{
memcpy(&(buf[8]), im->data, im->w * im->h * sizeof(DATA32));
header[4] = compression;
#ifdef WORDS_BIGENDIAN
{
int y;
for (y = 0; y < (im->w * im->h) + 8; y++)
SWAP32(buf[y]);
}
#endif
size = ((im->w * im->h) + 8) * sizeof(DATA32);
}
ret = buf;
e_db_data_set(db, key, ret, size);
free(buf);
if (progress)
progress(im, 100, 0, 0, im->w, im->h);
/* finish off */
e_db_close(db);
return 1;
progress_granularity = 0;
}
void
formats (ImlibLoader *l)
{
char *list_formats[] =
{ "db" };
{
int i;
l->num_formats = (sizeof(list_formats) / sizeof (char *));
l->formats = malloc(sizeof(char *) * l->num_formats);
for (i = 0; i < l->num_formats; i++)
l->formats[i] = strdup(list_formats[i]);
}
}