From: <enl...@li...> - 2002-05-08 02:19:32
|
Enlightenment CVS committal Author : raster Project : e17 Module : libs/eet Dir : e17/libs/eet Log Message: Directory /cvsroot/enlightenment/e17/libs/eet added to the repository --> Using per-directory sticky tag `SPLIT' |
From: <enl...@li...> - 2002-05-08 02:19:48
|
Enlightenment CVS committal Author : raster Project : e17 Module : libs/eet Dir : e17/libs/eet/src Log Message: Directory /cvsroot/enlightenment/e17/libs/eet/src added to the repository --> Using per-directory sticky tag `SPLIT' |
From: <enl...@li...> - 2002-05-08 02:27:51
|
Enlightenment CVS committal Author : raster Project : e17 Module : libs/eet Dir : e17/libs/eet Added Files: Tag: SPLIT configure Log Message: eet goes in! now you ask.. what is eet! well.. 1. you link to the library from programs with: -leet 2. it's an alternative to edb. why? different properties. it's NOT random access write. you build an eet file with everything in it once. you rebuild it completely if things change. all elements in an eet file are optionally compressable, and can be VERY quickly random-access read from the eet archive. it's a lot like zip, minus all the file attributes etc (thus simpler to impliment and debug, etc.). 3. comes with an eet exectable that can pack up and unpack eet files 4. its a lib for anything else to use too. 5. easy to create the little buggers on the cmd-line: eet -c eet_file.eet base_dir [base_dir2 ...] 6. easy to unpack: eet -d eet_file.eet 7. pretty damn fast for reads. 8. tiny file sizes (comparable to zip - maybe about 10-20% smaller) if you use the compess flag (the eet exe does by default). 9. simple as all hell. even got comments out the wazoo 10. i'm trying a new tack of not using autoconf. the result? no autogen needed. no arguments over automake/autoconf/libtool versions. it just works (on linux - should work on bsd and veen solaris i'd guess. if it doesn't help out and add the appropriate changes to the configure script) it doesn't even use make. ok. here goes. |
From: <enl...@li...> - 2002-05-08 02:27:51
|
Enlightenment CVS committal Author : raster Project : e17 Module : libs/eet Dir : e17/libs/eet/src Added Files: Tag: SPLIT Eet.h eet-config.in eet_lib.c eet_main.c Log Message: eet goes in! now you ask.. what is eet! well.. 1. you link to the library from programs with: -leet 2. it's an alternative to edb. why? different properties. it's NOT random access write. you build an eet file with everything in it once. you rebuild it completely if things change. all elements in an eet file are optionally compressable, and can be VERY quickly random-access read from the eet archive. it's a lot like zip, minus all the file attributes etc (thus simpler to impliment and debug, etc.). 3. comes with an eet exectable that can pack up and unpack eet files 4. its a lib for anything else to use too. 5. easy to create the little buggers on the cmd-line: eet -c eet_file.eet base_dir [base_dir2 ...] 6. easy to unpack: eet -d eet_file.eet 7. pretty damn fast for reads. 8. tiny file sizes (comparable to zip - maybe about 10-20% smaller) if you use the compess flag (the eet exe does by default). 9. simple as all hell. even got comments out the wazoo 10. i'm trying a new tack of not using autoconf. the result? no autogen needed. no arguments over automake/autoconf/libtool versions. it just works (on linux - should work on bsd and veen solaris i'd guess. if it doesn't help out and add the appropriate changes to the configure script) it doesn't even use make. ok. here goes. |
From: <enl...@li...> - 2002-05-08 02:40:43
|
Enlightenment CVS committal Author : raster Project : e17 Module : libs/eet Dir : e17/libs/eet Modified Files: Tag: SPLIT configure Log Message: oops. built wrong exe =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/eet/Attic/configure,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -u -3 -r1.1.2.1 -r1.1.2.2 --- configure 8 May 2002 02:27:51 -0000 1.1.2.1 +++ configure 8 May 2002 02:40:42 -0000 1.1.2.2 @@ -73,12 +73,12 @@ rm .script.sed OUT="lib"$LIB".so" -EXE=$OUT"."$VERSION +OUTPUT=$OUT"."$VERSION BUILDFLAGS="-shared -fPIC -DPIC -Wl,-soname -Wl,libeet.so.0" LDFLAGS=$LDFLAGS" -L/usr/local/lib "$LINK CFLAGS=$CFLAGS" -I/usr/local/include "$INCLUDES echo "Building library..." -$CC $BUILDFLAGS $CFLAGS $SRC $LDFLAGS -o $EXE +$CC $BUILDFLAGS $CFLAGS $SRC $LDFLAGS -o $OUTPUT $PRECMD cp -a $EXE $PREFIX"/lib" $PRECMD ln -sf $OUT"."$VERSION $PREFIX"/lib/"$OUT"."$VERSION2 @@ -92,11 +92,12 @@ SRC="eet_main.c" +OUTPUT=$EXE BUILDFLAGS="" LDFLAGS=$LDFLAGS" -L/usr/local/lib "$LIBS CFLAGS=$CFLAGS" -I. "$INCLUDES echo "Building tool..." -$CC $BUILDFLAGS $CFLAGS $SRC $LDFLAGS -o $EXE +$CC $BUILDFLAGS $CFLAGS $SRC $LDFLAGS -o $OUTPUT $PRECMD cp -a $EXE $PREFIX"/bin" |
From: <enl...@li...> - 2002-05-08 02:44:27
|
Enlightenment CVS committal Author : raster Project : e17 Module : libs/eet Dir : e17/libs/eet Modified Files: Tag: SPLIT configure Log Message: a bit nicer... =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/eet/Attic/configure,v retrieving revision 1.1.2.2 retrieving revision 1.1.2.3 diff -u -3 -r1.1.2.2 -r1.1.2.3 --- configure 8 May 2002 02:40:42 -0000 1.1.2.2 +++ configure 8 May 2002 02:43:56 -0000 1.1.2.3 @@ -25,6 +25,9 @@ if [ $1 = "--dist" ]; then mkdir $PACKAGE"-"$VERSION cp -ar ./configure src $PACKAGE"-"$VERSION + cd $PACKAGE"-"$VERSION + rm -rf `find . -name CVS -type d -print` + cd .. tar zcvf $PACKAGE"-"$VERSION".tar.gz" $PACKAGE"-"$VERSION rm -rf $PACKAGE"-"$VERSION exit @@ -80,7 +83,7 @@ echo "Building library..." $CC $BUILDFLAGS $CFLAGS $SRC $LDFLAGS -o $OUTPUT -$PRECMD cp -a $EXE $PREFIX"/lib" +$PRECMD cp -a $OUTPUT $PREFIX"/lib" $PRECMD ln -sf $OUT"."$VERSION $PREFIX"/lib/"$OUT"."$VERSION2 $PRECMD ln -sf $OUT"."$VERSION $PREFIX"/lib/"$OUT"."$VERSION3 $PRECMD ln -sf $OUT"."$VERSION $PREFIX"/lib/"$OUT @@ -99,6 +102,6 @@ echo "Building tool..." $CC $BUILDFLAGS $CFLAGS $SRC $LDFLAGS -o $OUTPUT -$PRECMD cp -a $EXE $PREFIX"/bin" +$PRECMD cp -a $OUTPUT $PREFIX"/bin" cd .. |
From: <enl...@li...> - 2002-05-08 03:03:27
|
Enlightenment CVS committal Author : raster Project : e17 Module : libs/eet Dir : e17/libs/eet Modified Files: Tag: SPLIT configure Log Message: behaves a bit more like confiugre & make... =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/eet/Attic/configure,v retrieving revision 1.1.2.3 retrieving revision 1.1.2.4 diff -u -3 -r1.1.2.3 -r1.1.2.4 --- configure 8 May 2002 02:43:56 -0000 1.1.2.3 +++ configure 8 May 2002 03:03:26 -0000 1.1.2.4 @@ -15,14 +15,18 @@ ############################################################################### # figure stuff out +ln -sf ./configure ./make + TMPFILES="*~ *.bak .#* "#"*" -rm -f $TMPFILES -cd src - rm -f eet-config eet libeet.so.* $TMPFILES -cd .. + +INSTALL="" if [ -n "$1" ]; then if [ $1 = "--dist" ]; then + rm -f $TMPFILES + cd src + rm -f eet-config eet libeet.so* $TMPFILES + cd .. mkdir $PACKAGE"-"$VERSION cp -ar ./configure src $PACKAGE"-"$VERSION cd $PACKAGE"-"$VERSION @@ -32,21 +36,25 @@ rm -rf $PACKAGE"-"$VERSION exit fi + if [ $1 = "clean" ]; then + rm -f $TMPFILES + cd src + rm -f eet-config eet libeet.so* $TMPFILES + cd .. + exit + fi if [ $1 = "--prefix=" ]; then PREFIX=`echo $1 | sed 's/--prefix=//'` fi + if [ $1 = "install" ]; then + INSTALL="y" + fi fi if [ -z "$CC" ]; then CC=gcc fi -if [ "$USER" = "root" ]; then - PRECMD="" -else - PRECMD="sudo" -fi - LINK="-L"$PREFIX"/libs "$LINK INCLUDES="-I"$PREFIX"/includes "$INCLUDES LIBS=$LINK" -l"$LIB @@ -76,32 +84,46 @@ rm .script.sed OUT="lib"$LIB".so" -OUTPUT=$OUT"."$VERSION -BUILDFLAGS="-shared -fPIC -DPIC -Wl,-soname -Wl,libeet.so.0" -LDFLAGS=$LDFLAGS" -L/usr/local/lib "$LINK -CFLAGS=$CFLAGS" -I/usr/local/include "$INCLUDES -echo "Building library..." -$CC $BUILDFLAGS $CFLAGS $SRC $LDFLAGS -o $OUTPUT - -$PRECMD cp -a $OUTPUT $PREFIX"/lib" -$PRECMD ln -sf $OUT"."$VERSION $PREFIX"/lib/"$OUT"."$VERSION2 -$PRECMD ln -sf $OUT"."$VERSION $PREFIX"/lib/"$OUT"."$VERSION3 -$PRECMD ln -sf $OUT"."$VERSION $PREFIX"/lib/"$OUT -$PRECMD chmod a+r+x $PREFIX"/lib/"$OUT"."$VERSION -$PRECMD cp -a $INC $PREFIX"/include" -$PRECMD cp -a $CONFIG $PREFIX"/bin" - -# exe tool - -SRC="eet_main.c" - -OUTPUT=$EXE -BUILDFLAGS="" -LDFLAGS=$LDFLAGS" -L/usr/local/lib "$LIBS -CFLAGS=$CFLAGS" -I. "$INCLUDES -echo "Building tool..." -$CC $BUILDFLAGS $CFLAGS $SRC $LDFLAGS -o $OUTPUT -$PRECMD cp -a $OUTPUT $PREFIX"/bin" +if [ -z "$INSTALL" ]; then + # library + + echo "Building library..." + OUTPUT=$OUT"."$VERSION + BUILDFLAGS="-shared -fPIC -DPIC -Wl,-soname -Wl,libeet.so.0" + LDFLAGS=$LDFLAGS" -L/usr/local/lib "$LINK + CFLAGS=$CFLAGS" -I/usr/local/include "$INCLUDES + + $CC $BUILDFLAGS $CFLAGS $SRC $LDFLAGS -o $OUTPUT + + ln -sf $OUT"."$VERSION $OUT"."$VERSION2 + ln -sf $OUT"."$VERSION $OUT"."$VERSION3 + ln -sf $OUT"."$VERSION $OUT + + # exe tool + + SRC="eet_main.c" + + OUTPUT=$EXE + BUILDFLAGS="" + LDFLAGS=$LDFLAGS" -L. -L/usr/local/lib "$LIBS + CFLAGS=$CFLAGS" -I. "$INCLUDES + echo "Building tool..." + $CC $BUILDFLAGS $CFLAGS $SRC $LDFLAGS -o $OUTPUT +fi + +if [ -n "$INSTALL" ]; then + # install + + echo "Installing..." + cp -a $OUT"."$VERSION $PREFIX"/lib" + ln -sf $OUT"."$VERSION $PREFIX"/lib/"$OUT"."$VERSION2 + ln -sf $OUT"."$VERSION $PREFIX"/lib/"$OUT"."$VERSION3 + ln -sf $OUT"."$VERSION $PREFIX"/lib/"$OUT + chmod a+r+x $PREFIX"/lib/"$OUT"."$VERSION + cp -a $INC $PREFIX"/include" + cp -a $CONFIG $PREFIX"/bin" + cp -a $EXE $PREFIX"/bin" +fi cd .. |
From: <enl...@li...> - 2002-05-08 03:23:03
|
Enlightenment CVS committal Author : raster Project : e17 Module : libs/eet Dir : e17/libs/eet Modified Files: Tag: SPLIT configure Log Message: and ... event better... now behaves a lot like autoconf.. so peoel wont be too confuzzled. =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/eet/Attic/configure,v retrieving revision 1.1.2.4 retrieving revision 1.1.2.5 diff -u -3 -r1.1.2.4 -r1.1.2.5 --- configure 8 May 2002 03:03:26 -0000 1.1.2.4 +++ configure 8 May 2002 03:22:31 -0000 1.1.2.5 @@ -17,39 +17,50 @@ # figure stuff out ln -sf ./configure ./make -TMPFILES="*~ *.bak .#* "#"*" +touch .config +. ./.config + +TMPFILES=".* *~ *.bak .\#* \#*" INSTALL="" +BUILD="" +CONFIGURE="" -if [ -n "$1" ]; then - if [ $1 = "--dist" ]; then - rm -f $TMPFILES - cd src - rm -f eet-config eet libeet.so* $TMPFILES - cd .. - mkdir $PACKAGE"-"$VERSION - cp -ar ./configure src $PACKAGE"-"$VERSION - cd $PACKAGE"-"$VERSION - rm -rf `find . -name CVS -type d -print` - cd .. - tar zcvf $PACKAGE"-"$VERSION".tar.gz" $PACKAGE"-"$VERSION - rm -rf $PACKAGE"-"$VERSION - exit - fi - if [ $1 = "clean" ]; then - rm -f $TMPFILES - cd src - rm -f eet-config eet libeet.so* $TMPFILES - cd .. - exit - fi - if [ $1 = "--prefix=" ]; then - PREFIX=`echo $1 | sed 's/--prefix=//'` - fi - if [ $1 = "install" ]; then - INSTALL="y" - fi -fi +case $1 in + --prefix*) + PREFIX=`echo $1 | sed 's/--prefix=//'` + BUILD="" + ;; + --dist) + rm -f $TMPFILES + cd src + rm -f eet-config eet libeet.so* $TMPFILES + cd .. + mkdir $PACKAGE"-"$VERSION + cp -ar ./configure src $PACKAGE"-"$VERSION + cd $PACKAGE"-"$VERSION + rm -rf `find . -name CVS -type d -print` + cd .. + tar zcvf $PACKAGE"-"$VERSION".tar.gz" $PACKAGE"-"$VERSION + rm -rf $PACKAGE"-"$VERSION + exit; + ;; + clean) + rm -f $TMPFILES + cd src + rm -f eet-config eet libeet.so* $TMPFILES + cd .. + exit + ;; + install) + INSTALL="y" + ;; + *) + BUILD="y" + ;; +esac + +echo "PREFIX=\""$PREFIX"\"" > ./.config if [ -z "$CC" ]; then CC=gcc @@ -85,7 +96,9 @@ OUT="lib"$LIB".so" -if [ -z "$INSTALL" ]; then +echo Ok. + +if [ -n "$BUILD" ]; then # library echo "Building library..." |
From: <enl...@li...> - 2002-05-08 15:10:36
|
Enlightenment CVS committal Author : raster Project : e17 Module : libs/eet Dir : e17/libs/eet Modified Files: Tag: SPLIT configure Added Files: Tag: SPLIT eet.spec Log Message: we build in a build root and make rpm's! YAY! =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/eet/Attic/configure,v retrieving revision 1.1.2.5 retrieving revision 1.1.2.6 diff -u -3 -r1.1.2.5 -r1.1.2.6 --- configure 8 May 2002 03:22:31 -0000 1.1.2.5 +++ configure 8 May 2002 15:10:33 -0000 1.1.2.6 @@ -37,7 +37,7 @@ rm -f eet-config eet libeet.so* $TMPFILES cd .. mkdir $PACKAGE"-"$VERSION - cp -ar ./configure src $PACKAGE"-"$VERSION + cp -ar ./configure ./*.spec ./src $PACKAGE"-"$VERSION cd $PACKAGE"-"$VERSION rm -rf `find . -name CVS -type d -print` cd .. @@ -129,6 +129,9 @@ # install echo "Installing..." + install -d $PREFIX"/lib" + install -d $PREFIX"/include" + install -d $PREFIX"/bin" cp -a $OUT"."$VERSION $PREFIX"/lib" ln -sf $OUT"."$VERSION $PREFIX"/lib/"$OUT"."$VERSION2 ln -sf $OUT"."$VERSION $PREFIX"/lib/"$OUT"."$VERSION3 |
From: <enl...@li...> - 2002-05-09 00:32:17
|
Enlightenment CVS committal Author : raster Project : e17 Module : libs/eet Dir : e17/libs/eet/src Modified Files: Tag: SPLIT Eet.h eet_lib.c eet_main.c Log Message: oh lookie here! documentation! the whole api is now documented. i've added a list function and removed flush as an external api call. all structs are now opaque and internal. there's a COPYING, README and AUTHORS. =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/eet/src/Attic/Eet.h,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -u -3 -r1.1.2.1 -r1.1.2.2 --- Eet.h 8 May 2002 02:27:51 -0000 1.1.2.1 +++ Eet.h 9 May 2002 00:31:45 -0000 1.1.2.2 @@ -1,80 +1,132 @@ #ifndef _EET_H #define _EET_H -#include <time.h> +/***************************************************************************/ + +/* + * EET - E file chunk reading/writing library + * + * What is it? + * It is a tiny library designed to write an arbitary set of chunks of data + * to a file and optionally compress each chunk (very much like a zip file) + * and allow fast random-access reading of the file later on. It does not + * do zip as zip itself has more complexity than we need, and it was much + * simpler to impliment this once here. + * + */ + +/***************************************************************************/ #ifdef __cplusplus extern "C" { #endif - - #define EET_MAGIC_FILE 0x1ee7ff00 - #define EET_MAGIC_FILE_HEADER 0x1ee7ff01 - #define EET_MAGIC_FILE_NODE 0x1ee7ff02 - #define EET_MAGIC_FILE_DIRECTORY 0x1ee7ff03 - #define EET_MAGIC_FILE_DIRECTORY_HASH 0x1ee7ff04 + +/***************************************************************************/ + typedef enum _Eet_File_Mode Eet_File_Mode; typedef struct _Eet_File Eet_File; - typedef struct _Eet_File_Header Eet_File_Header; - typedef struct _Eet_File_Node Eet_File_Node; - typedef struct _Eet_File_Directory Eet_File_Directory; - typedef struct _Eet_File_Directory_Hash Eet_File_Directory_Hash; - + enum _Eet_File_Mode { EET_FILE_MODE_READ, EET_FILE_MODE_WRITE }; - - struct _Eet_File - { - int magic; - int references; - - char *path; - char *real_path; - - int fd; - Eet_File_Mode mode; - - int writes_pending : 1; - - Eet_File_Header *header; - }; - struct _Eet_File_Header - { - int magic; - Eet_File_Directory *directory; - }; - struct _Eet_File_Node - { - char *name; - int offset; - int compression; - int size; - int data_size; - void *data; - }; - struct _Eet_File_Directory - { - int size; - Eet_File_Directory_Hash *hash; - }; - struct _Eet_File_Directory_Hash - { - int size; - Eet_File_Node *node; - }; - - Eet_File *eet_open(char *file, Eet_File_Mode mode); - void eet_close(Eet_File *ef); - - void *eet_read(Eet_File *ef, char *name, int *size_ret); - int eet_write(Eet_File *ef, char *name, void *data, int size, int compress); - void eet_flush(Eet_File *ef); +/***************************************************************************/ + + /* eet_open - Open an eet file on disk, and returns a handle to it. + * @file: The file path to the eet file. eg: "/tmp/file.eet". + * @mode: The mode for opening. Either EET_FILE_MODE_READ or EET_FILE_MODE_WRITE, but not both. + * + * This function will open an exiting eet file for reading, and build + * the directory table in memory and return a handle to the file, if it + * exists and can be read, and no memory errors occur on the way, otherwise + * NULL will be returned. + * + * It will also open an eet file for writing. This will, if successful, + * delete the original file and replace it with a new empty file, till + * the eet file handle is closed or flushed. If it cannot be opened for + * writing or a memory error occurs, NULL is returned. + */ + Eet_File *eet_open (char *file, Eet_File_Mode mode); + /* eet_close - Close an eet file handle and flush and writes pending. + * @ef: A valid eet file handle. + * + * This function will flush any pending writes to disk if the eet file + * was opened for write, and free all data associated with the file handle + * and file, and close the file. + * + * If the eet file handle is not valid nothing will be done. + */ + void eet_close (Eet_File *ef); + /* eet_read - Read a specified entry from an eet file and return data + * @ef: A valid eet file handle. + * @name: Name of the entry. eg: "/base/file_i_want". + * @size_ret: Number of bytes read from entry and returned. + * + * This function finds an entry in the eet file that is stored under the + * name specified, and returns that data, decompressed, if successfule. + * NULL is retuurned if the lookup fails or if memory errors are + * encountered. It is the job of the calling program to call free() on + * the returned data. The number of bytes in the returned data chunk are + * placed in size_ret. + * + * If the eet file handle is not valid NULl is returned and size_ret is + * filled with 0. + */ + void *eet_read (Eet_File *ef, char *name, int *size_ret); + /* eet_write - Write a specified entry to an eet file handle + * @ef: A valid eet file handle opened for writing. + * @name: Name of the entry. eg: "/base/file_i_want". + * @data: Pointer to the data to be stored. + * @size: Length in bytes in the data to be stored. + * @compress: Compression flags (1 == compress, 0 = don't compress). + * + * This function will write the specified chunk of data to the eet file + * and return 1 on success. 0 will be returned on failure. + * + * The eet file handle must be a valid file handle for an eet file opened + * for writing. If it is not, 0 will be returned and no action will be + * performed. + * + * Name, and data must not be NULL, and size must be > 0. If these + * conditions are not met, 0 will be returned. + * + * The data will be copied (and optionally compressed) in ram, pending + * a flush to disk (it will stay in ram till the eet file handle is + * closed though). + */ + int eet_write (Eet_File *ef, char *name, void *data, int size, int compress); + /* eet_list - List all entries in eet file matching shell glob. + * @ef: A valid eet file handle. + * @glob: A shell glob to match against. + * @count_ret: number of entries foudn to match. + * + * This function will list all entries in the eet file matching the + * supplied shell glob and return an allocated list of their names, if + * there are any, and if no memory errors occur. + * + * The eet file handle must be valid and glob must not be NULL, or NULL + * will be returned and count_ret will be filled with 0. + * + * The calling program must call free() on the array returned, but NOT + * on the string pointers in the array. They are taken as read-only + * internals from the eet file handle. They are only valid as long as + * the file handle is not closed. When it is closed those pointers in the + * array are now not valid and should not be used. + * + * On success the array returned will have a list of string pointers + * that are the names of the entries that matched, and count_ret will have + * the number of entries in this array placed in it. + * + * Hint: an easy way to list all entries in an eet file is to use a glob + * value of "*". + */ + char **eet_list (Eet_File *ef, char *glob, int *count_ret); +/***************************************************************************/ #ifdef __cplusplus } #endif =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/eet/src/Attic/eet_lib.c,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -u -3 -r1.1.2.1 -r1.1.2.2 --- eet_lib.c 8 May 2002 02:27:51 -0000 1.1.2.1 +++ eet_lib.c 9 May 2002 00:31:45 -0000 1.1.2.2 @@ -9,6 +9,59 @@ #include <netinet/in.h> #include <zlib.h> #include <string.h> +#include <fnmatch.h> + +#define EET_MAGIC_FILE 0x1ee7ff00 +#define EET_MAGIC_FILE_HEADER 0x1ee7ff01 +#define EET_MAGIC_FILE_NODE 0x1ee7ff02 +#define EET_MAGIC_FILE_DIRECTORY 0x1ee7ff03 +#define EET_MAGIC_FILE_DIRECTORY_HASH 0x1ee7ff04 + +typedef struct _Eet_File_Header Eet_File_Header; +typedef struct _Eet_File_Node Eet_File_Node; +typedef struct _Eet_File_Directory Eet_File_Directory; +typedef struct _Eet_File_Directory_Hash Eet_File_Directory_Hash; + +struct _Eet_File +{ + int magic; + int references; + + char *path; + char *real_path; + + int fd; + Eet_File_Mode mode; + + int writes_pending : 1; + + Eet_File_Header *header; +}; +struct _Eet_File_Header +{ + int magic; + Eet_File_Directory *directory; +}; +struct _Eet_File_Node +{ + char *name; + int offset; + int compression; + int size; + int data_size; + void *data; +}; +struct _Eet_File_Directory +{ + int size; + Eet_File_Directory_Hash *hash; +}; +struct _Eet_File_Directory_Hash +{ + int size; + Eet_File_Node *node; +}; + #if 0 /* NB: all int's are stored in network byte order on disk */ @@ -29,8 +82,9 @@ #endif /* prototypes of internal calls */ -static int eet_string_match(char *s1, char *s2); -static int eet_hash_gen(char *key, int hash_size); +static int eet_string_match(char *s1, char *s2); +static int eet_hash_gen(char *key, int hash_size); +static void eet_flush(Eet_File *ef); /* internal string match. bails out at first mismatch - not comparing all */ /* bytes in strings */ @@ -82,6 +136,108 @@ return hash_num; } +/* flush out writes to an eet file */ +static void +eet_flush(Eet_File *ef) +{ + int i, j, count, size, num, offset; + int head[3]; + unsigned long int i1, i2; + + /* check to see its' an eet file pointer */ + if ((!ef) || (ef->magic != EET_MAGIC_FILE)) + return; + if (ef->mode != EET_FILE_MODE_WRITE) return; + if (!ef->writes_pending) return; + + /* calculate total size in bytes of directory block */ + size = 0; + count = 0; + num = (1 << (ef->header->directory->size - 1)); + for (i = 0; i < num; i++) + { + for (j = 0; j < ef->header->directory->hash[i].size; j++) + { + size += 20 + strlen(ef->header->directory->hash[i].node[j].name); + count++; + } + } + /* caluclate offsets per entry */ + offset = 0; + for (i = 0; i < num; i++) + { + for (j = 0; j < ef->header->directory->hash[i].size; j++) + { + ef->header->directory->hash[i].node[j].offset = 12 + size + offset; + offset += ef->header->directory->hash[i].node[j].size; + } + } + /* go thru and write the header */ + i1 = (unsigned long int)EET_MAGIC_FILE; + i2 = htonl(i1); + head[0] = (int)i2; + i1 = (unsigned long int)count; + i2 = htonl(i1); + head[1] = (int)i2; + i1 = (unsigned long int)size; + i2 = htonl(i1); + head[2] = (int)i2; + lseek(ef->fd, 0, SEEK_SET); + if (write(ef->fd, head, 12) != 12) return; + offset = 12; + for (i = 0; i < num; i++) + { + for (j = 0; j < ef->header->directory->hash[i].size; j++) + { + unsigned char *buf; + int buf_size; + int name_size; + + name_size = strlen(ef->header->directory->hash[i].node[j].name); + buf_size = 20 + name_size; + buf = malloc(buf_size); + if (!buf) return; + i1 = (unsigned long int)ef->header->directory->hash[i].node[j].offset; + i2 = htonl(i1); + *((int *)(buf + 0)) = (int)i2; + i1 = (unsigned long int)ef->header->directory->hash[i].node[j].compression; + i2 = htonl(i1); + *((int *)(buf + 4)) = (int)i2; + i1 = (unsigned long int)ef->header->directory->hash[i].node[j].size; + i2 = htonl(i1); + *((int *)(buf + 8)) = (int)i2; + i1 = (unsigned long int)ef->header->directory->hash[i].node[j].data_size; + i2 = htonl(i1); + *((int *)(buf + 12)) = (int)i2; + i1 = (unsigned long int)name_size; + i2 = htonl(i1); + *((int *)(buf + 16)) = (int)i2; + memcpy(buf + 20, ef->header->directory->hash[i].node[j].name, name_size); + if (write(ef->fd, buf, buf_size) != buf_size) + { + free(buf); + return; + } + offset += buf_size; + free(buf); + } + } + /* write data */ + for (i = 0; i < num; i++) + { + for (j = 0; j < ef->header->directory->hash[i].size; j++) + { + if (write(ef->fd, + ef->header->directory->hash[i].node[j].data, + ef->header->directory->hash[i].node[j].size) != + ef->header->directory->hash[i].node[j].size) + return; + } + } + /* no more writes pending */ + ef->writes_pending = 0; +} + Eet_File * eet_open(char *file, Eet_File_Mode mode) { @@ -409,19 +565,28 @@ data = malloc(size); if (data) { - /* seek to data location */ - if (lseek(ef->fd, ef->header->directory->hash[hash].node[i].offset, SEEK_SET) < 0) - { - free(data); - data = NULL; - break; - } - /* read it */ - if (read(ef->fd, data, size) != (ssize_t)size) + /* if we alreayd have the data in ram... copy that */ + if (ef->header->directory->hash[hash].node[i].data) + memcpy(data, + ef->header->directory->hash[hash].node[i].data, + ef->header->directory->hash[hash].node[i].size); + /* or get data from disk */ + else { - free(data); - data = NULL; - break; + /* seek to data location */ + if (lseek(ef->fd, ef->header->directory->hash[hash].node[i].offset, SEEK_SET) < 0) + { + free(data); + data = NULL; + break; + } + /* read it */ + if (read(ef->fd, data, size) != (ssize_t)size) + { + free(data); + data = NULL; + break; + } } } break; @@ -443,21 +608,30 @@ { uLongf dlen; - /* seek to data location */ - if (lseek(ef->fd, ef->header->directory->hash[hash].node[i].offset, SEEK_SET) < 0) + /* if we already have the data in ram... copy that */ + if (ef->header->directory->hash[hash].node[i].data) + memcpy(tmp_data, + ef->header->directory->hash[hash].node[i].data, + tmp_size); + /* or get data from disk */ + else { - free(tmp_data); - free(data); - data = NULL; - break; - } - /* read it */ - if (read(ef->fd, tmp_data, tmp_size) != (ssize_t)tmp_size) - { - free(tmp_data); - free(data); - data = NULL; - break; + /* seek to data location */ + if (lseek(ef->fd, ef->header->directory->hash[hash].node[i].offset, SEEK_SET) < 0) + { + free(tmp_data); + free(data); + data = NULL; + break; + } + /* read it */ + if (read(ef->fd, tmp_data, tmp_size) != (ssize_t)tmp_size) + { + free(tmp_data); + free(data); + data = NULL; + break; + } } /* decompress it */ dlen = size; @@ -492,8 +666,9 @@ /* check to see its' an eet file pointer */ if ((!ef) || (ef->magic != EET_MAGIC_FILE) - || (!name) || (!data) || (size == 0)) - return -1; + || (!name) || (!data) || (size <= 0) || + (ef->mode != EET_FILE_MODE_WRITE)) + return 0; if (!ef->header) { @@ -575,103 +750,52 @@ return size; } -void -eet_flush(Eet_File *ef) +char ** +eet_list(Eet_File *ef, char *glob, int *count_ret) { - int i, j, count, size, num, offset; - int head[3]; - unsigned long int i1, i2; - - /* check to see its' an eet file pointer */ - if ((!ef) || (ef->magic != EET_MAGIC_FILE)) - return; - if (ef->mode != EET_FILE_MODE_WRITE) return; - if (!ef->writes_pending) return; + char **list_ret = NULL; + int list_count = 0; + int list_count_alloc = 0; + int i, j, num; - /* calculate total size in bytes of directory block */ - size = 0; - count = 0; - num = (1 << (ef->header->directory->size - 1)); - for (i = 0; i < num; i++) - { - for (j = 0; j < ef->header->directory->hash[i].size; j++) - { - size += 20 + strlen(ef->header->directory->hash[i].node[j].name); - count++; - } - } - /* caluclate offsets per entry */ - offset = 0; - for (i = 0; i < num; i++) + /* check to see its' an eet file pointer */ + if ((!ef) || (ef->magic != EET_MAGIC_FILE) || (!glob)) { - for (j = 0; j < ef->header->directory->hash[i].size; j++) - { - ef->header->directory->hash[i].node[j].offset = 12 + size + offset; - offset += ef->header->directory->hash[i].node[j].size; - } + if (count_ret) *count_ret = 0; + return NULL; } - /* go thru and write the header */ - i1 = (unsigned long int)EET_MAGIC_FILE; - i2 = htonl(i1); - head[0] = (int)i2; - i1 = (unsigned long int)count; - i2 = htonl(i1); - head[1] = (int)i2; - i1 = (unsigned long int)size; - i2 = htonl(i1); - head[2] = (int)i2; - lseek(ef->fd, 0, SEEK_SET); - if (write(ef->fd, head, 12) != 12) return; - offset = 12; + /* loop through all entries */ + num = (1 << (ef->header->directory->size - 1)); for (i = 0; i < num; i++) { for (j = 0; j < ef->header->directory->hash[i].size; j++) { - unsigned char *buf; - int buf_size; - int name_size; - - name_size = strlen(ef->header->directory->hash[i].node[j].name); - buf_size = 20 + name_size; - buf = malloc(buf_size); - if (!buf) return; - i1 = (unsigned long int)ef->header->directory->hash[i].node[j].offset; - i2 = htonl(i1); - *((int *)(buf + 0)) = (int)i2; - i1 = (unsigned long int)ef->header->directory->hash[i].node[j].compression; - i2 = htonl(i1); - *((int *)(buf + 4)) = (int)i2; - i1 = (unsigned long int)ef->header->directory->hash[i].node[j].size; - i2 = htonl(i1); - *((int *)(buf + 8)) = (int)i2; - i1 = (unsigned long int)ef->header->directory->hash[i].node[j].data_size; - i2 = htonl(i1); - *((int *)(buf + 12)) = (int)i2; - i1 = (unsigned long int)name_size; - i2 = htonl(i1); - *((int *)(buf + 16)) = (int)i2; - memcpy(buf + 20, ef->header->directory->hash[i].node[j].name, name_size); - if (write(ef->fd, buf, buf_size) != buf_size) + /* if the entry matches the input glob */ + if (!fnmatch(ef->header->directory->hash[i].node[j].name, glob, 0)) { - free(buf); - return; + char **new_list; + + /* add it to our list */ + list_count++; + /* only realloc in 32 entry chunks */ + if (list_count > list_count_alloc) + { + list_count_alloc += 32; + new_list = realloc(list_ret, list_count_alloc * (sizeof(char *))); + if (!new_list) + { + free(list_ret); + if (count_ret) *count_ret = 0; + return NULL; + } + list_ret = new_list; + } + /* put pointer of name string in */ + list_ret[list_count - 1] = ef->header->directory->hash[i].node[j].name; } - offset += buf_size; - free(buf); } } - /* write data */ - for (i = 0; i < num; i++) - { - for (j = 0; j < ef->header->directory->hash[i].size; j++) - { - if (write(ef->fd, - ef->header->directory->hash[i].node[j].data, - ef->header->directory->hash[i].node[j].size) != - ef->header->directory->hash[i].node[j].size) - return; - } - } - /* no more writes pending */ - ef->writes_pending = 0; + /* return count and list */ + if (count_ret) *count_ret = list_count; + return list_ret; } =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/eet/src/Attic/eet_main.c,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -u -3 -r1.1.2.1 -r1.1.2.2 --- eet_main.c 8 May 2002 02:27:51 -0000 1.1.2.1 +++ eet_main.c 9 May 2002 00:31:45 -0000 1.1.2.2 @@ -87,7 +87,8 @@ void depack(char *pak_file) { - int i, j, num; + int i, num; + char **list; Eet_File *ef; ef = eet_open(pak_file, EET_FILE_MODE_READ); @@ -96,13 +97,12 @@ printf("cannot open for reading: %s\n", pak_file); return; } - num = (1 << (ef->header->directory->size - 1)); - for (i = 0; i < num; i++) + list = eet_list(ef, "*", &num); + if (list) { - for (j = 0; j < ef->header->directory->hash[i].size; j++) - { - depak_file(ef, ef->header->directory->hash[i].node[j].name); - } + for (i = 0; i < num; i++) + depak_file(ef, list[i]); + free(list); } eet_close(ef); } |
From: <enl...@li...> - 2002-05-09 00:32:17
|
Enlightenment CVS committal Author : raster Project : e17 Module : libs/eet Dir : e17/libs/eet Modified Files: Tag: SPLIT configure Added Files: Tag: SPLIT AUTHORS COPYING README Log Message: oh lookie here! documentation! the whole api is now documented. i've added a list function and removed flush as an external api call. all structs are now opaque and internal. there's a COPYING, README and AUTHORS. =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/eet/Attic/configure,v retrieving revision 1.1.2.6 retrieving revision 1.1.2.7 diff -u -3 -r1.1.2.6 -r1.1.2.7 --- configure 8 May 2002 15:10:33 -0000 1.1.2.6 +++ configure 9 May 2002 00:31:45 -0000 1.1.2.7 @@ -31,13 +31,13 @@ PREFIX=`echo $1 | sed 's/--prefix=//'` BUILD="" ;; - --dist) + dist) rm -f $TMPFILES cd src rm -f eet-config eet libeet.so* $TMPFILES cd .. mkdir $PACKAGE"-"$VERSION - cp -ar ./configure ./*.spec ./src $PACKAGE"-"$VERSION + cp -ar ./configure ./*.spec ./COPYING ./README ./AUTHORS ./src $PACKAGE"-"$VERSION cd $PACKAGE"-"$VERSION rm -rf `find . -name CVS -type d -print` cd .. @@ -80,7 +80,7 @@ echo '}' >> .script.sed VERSION=`echo $VERSION | sed -f .script.sed` -INCLUDES=`echo $VINCLUDES | sed -f .script.sed` +INCLUDES=`echo $INCLUDES | sed -f .script.sed` LIBS=`echo $LIBS | sed -f .script.sed` rm .script.sed |
From: <enl...@li...> - 2002-05-09 04:57:28
|
Enlightenment CVS committal Author : raster Project : e17 Module : libs/eet Dir : e17/libs/eet Modified Files: Tag: SPLIT configure Log Message: now has... a reference cache - actually using our ref counts. =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/eet/Attic/configure,v retrieving revision 1.1.2.7 retrieving revision 1.1.2.8 diff -u -3 -r1.1.2.7 -r1.1.2.8 --- configure 9 May 2002 00:31:45 -0000 1.1.2.7 +++ configure 9 May 2002 04:56:56 -0000 1.1.2.8 @@ -119,7 +119,7 @@ OUTPUT=$EXE BUILDFLAGS="" - LDFLAGS=$LDFLAGS" -L. -L/usr/local/lib "$LIBS + LDFLAGS=$LDFLAGS" -L./ -L/usr/local/lib -L./ "$LIBS CFLAGS=$CFLAGS" -I. "$INCLUDES echo "Building tool..." $CC $BUILDFLAGS $CFLAGS $SRC $LDFLAGS -o $OUTPUT |
From: <enl...@li...> - 2002-05-09 04:57:29
|
Enlightenment CVS committal Author : raster Project : e17 Module : libs/eet Dir : e17/libs/eet/src Modified Files: Tag: SPLIT eet_lib.c eet_main.c Log Message: now has... a reference cache - actually using our ref counts. =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/eet/src/Attic/eet_lib.c,v retrieving revision 1.1.2.2 retrieving revision 1.1.2.3 diff -u -3 -r1.1.2.2 -r1.1.2.3 --- eet_lib.c 9 May 2002 00:31:45 -0000 1.1.2.2 +++ eet_lib.c 9 May 2002 04:56:57 -0000 1.1.2.3 @@ -30,7 +30,7 @@ char *path; char *real_path; - int fd; + FILE *fp; Eet_File_Mode mode; int writes_pending : 1; @@ -62,7 +62,6 @@ Eet_File_Node *node; }; - #if 0 /* NB: all int's are stored in network byte order on disk */ /* file format: */ @@ -82,9 +81,75 @@ #endif /* prototypes of internal calls */ -static int eet_string_match(char *s1, char *s2); -static int eet_hash_gen(char *key, int hash_size); -static void eet_flush(Eet_File *ef); +static Eet_File *eet_cache_find(char *real_path, Eet_File **cache, int cache_num); +static void eet_cache_add(Eet_File *ef, Eet_File ***cache, int *cache_num); +static void eet_cache_del(Eet_File *ef, Eet_File ***cache, int *cache_num); +static int eet_string_match(char *s1, char *s2); +static int eet_hash_gen(char *key, int hash_size); +static void eet_flush(Eet_File *ef); + +/* cache. i don't expect this to ever be large, so arrays will do */ +static int eet_writers_num = 0; +static Eet_File **eet_writers = NULL; +static int eet_readers_num = 0; +static Eet_File **eet_readers = NULL; + +/* find an eet file in the currently in use cache */ +static Eet_File * +eet_cache_find(char *real_path, Eet_File **cache, int cache_num) +{ + int i; + + /* walk list */ + for (i = 0; i < cache_num; i++) + { + /* if matches real path - return it */ + if (eet_string_match(cache[i]->real_path, real_path)) return cache[i]; + } + /* not found */ + return NULL; +} + +/* add to end of cache */ +static void +eet_cache_add(Eet_File *ef, Eet_File ***cache, int *cache_num) +{ + Eet_File **new_cache; + int new_cache_num; + + new_cache_num = *cache_num; + new_cache = *cache; + new_cache_num++; + new_cache = realloc(new_cache, new_cache_num * sizeof(Eet_File *)); + if (!new_cache) return; + new_cache[new_cache_num - 1] = ef; + *cache = new_cache; + *cache_num = new_cache_num; +} + +/* delete from cache */ +static void +eet_cache_del(Eet_File *ef, Eet_File ***cache, int *cache_num) +{ + Eet_File **new_cache; + int new_cache_num; + int i, j; + + new_cache_num = *cache_num; + new_cache = *cache; + if (new_cache_num <= 0) return; + for (i = 0; i < new_cache_num; i++) + { + if (new_cache[i] == ef) break; + } + if (i >= new_cache_num) return; + new_cache_num--; + for (j = i; j < new_cache_num; j++) new_cache[j] = new_cache[j + 1]; + new_cache = realloc(new_cache, new_cache_num * sizeof(Eet_File *)); + *cache_num = new_cache_num; + if ((new_cache_num > 0) && (!new_cache)) return; + *cache = new_cache; +} /* internal string match. bails out at first mismatch - not comparing all */ /* bytes in strings */ @@ -182,8 +247,8 @@ i1 = (unsigned long int)size; i2 = htonl(i1); head[2] = (int)i2; - lseek(ef->fd, 0, SEEK_SET); - if (write(ef->fd, head, 12) != 12) return; + fseek(ef->fp, 0, SEEK_SET); + if (fwrite(head, 12, 1, ef->fp) != 1) return; offset = 12; for (i = 0; i < num; i++) { @@ -213,7 +278,7 @@ i2 = htonl(i1); *((int *)(buf + 16)) = (int)i2; memcpy(buf + 20, ef->header->directory->hash[i].node[j].name, name_size); - if (write(ef->fd, buf, buf_size) != buf_size) + if (fwrite(buf, buf_size, 1, ef->fp) != 1) { free(buf); return; @@ -227,10 +292,9 @@ { for (j = 0; j < ef->header->directory->hash[i].size; j++) { - if (write(ef->fd, - ef->header->directory->hash[i].node[j].data, - ef->header->directory->hash[i].node[j].size) != - ef->header->directory->hash[i].node[j].size) + if (fwrite(ef->header->directory->hash[i].node[j].data, + ef->header->directory->hash[i].node[j].size, + 1, ef->fp) != 1) return; } } @@ -249,6 +313,20 @@ { if (mode == EET_FILE_MODE_READ) return NULL; } + + /* find the current file handle in cache*/ + ef = NULL; + if (mode == EET_FILE_MODE_READ) + ef = eet_cache_find(buf, eet_readers, eet_readers_num); + else if (mode == EET_FILE_MODE_WRITE) + ef = eet_cache_find(buf, eet_writers, eet_writers_num); + /* we found one */ + if (ef) + { + /* reference it up and return it */ + ef->references++; + return ef; + } /* allocate struct for eet file and have it zero'd out */ ef = calloc(sizeof(Eet_File), 1); @@ -263,12 +341,12 @@ /* try open the file based on mode */ if (ef->mode == EET_FILE_MODE_READ) - ef->fd = open(ef->path, O_RDONLY); + ef->fp = fopen(ef->path, "r"); else if (ef->mode == EET_FILE_MODE_WRITE) { /* opening for write - delete old copy of file right away */ unlink(ef->real_path); - ef->fd = open(ef->path, O_RDWR | O_CREAT); + ef->fp = fopen(ef->path, "w"); } else { @@ -277,7 +355,7 @@ } /* if we can't open - bail out */ - if (ef->fd < 0) + if (!ef->fp) { eet_close(ef); return NULL; @@ -290,12 +368,12 @@ unsigned char *dyn_buf, *p; unsigned long int i1, i2; int num_entries, byte_entries, i; - ssize_t count; + size_t count; /* build header table if read mode */ /* geat header */ - count = read(ef->fd, buf, 12); - if (count != 12) + count = fread(buf, 12, 1, ef->fp); + if (count != 1) { eet_close(ef); return NULL; @@ -362,8 +440,8 @@ return NULL; } /* actually read the directory block - all of it, into ram */ - count = read(ef->fd, dyn_buf, byte_entries); - if (count != (ssize_t)byte_entries) + count = fread(dyn_buf, byte_entries, 1, ef->fp); + if (count != 1) { free(dyn_buf); eet_close(ef); @@ -472,6 +550,11 @@ /* done - free dynamic buffer */ free(dyn_buf); } + /* add to cache */ + if (ef->mode == EET_FILE_MODE_READ) + eet_cache_add(ef, &eet_readers, &eet_readers_num); + else if (ef->mode == EET_FILE_MODE_WRITE) + eet_cache_add(ef, &eet_writers, &eet_writers_num); return ef; } @@ -485,11 +568,16 @@ ef->references--; /* if its still referenced - dont go any further */ if (ef->references > 0) return; + /* remove from cache */ + if (ef->mode == EET_FILE_MODE_READ) + eet_cache_del(ef, &eet_readers, &eet_readers_num); + else if (ef->mode == EET_FILE_MODE_WRITE) + eet_cache_del(ef, &eet_writers, &eet_writers_num); /* flush any writes */ eet_flush(ef); /* free up members */ - if (ef->fd) close(ef->fd); + if (ef->fp) fclose(ef->fp); if (ef->path) free(ef->path); if (ef->real_path) free(ef->real_path); @@ -574,14 +662,14 @@ else { /* seek to data location */ - if (lseek(ef->fd, ef->header->directory->hash[hash].node[i].offset, SEEK_SET) < 0) + if (fseek(ef->fp, ef->header->directory->hash[hash].node[i].offset, SEEK_SET) < 0) { free(data); data = NULL; break; } /* read it */ - if (read(ef->fd, data, size) != (ssize_t)size) + if (fread(data, size, 1, ef->fp) != 1) { free(data); data = NULL; @@ -617,7 +705,7 @@ else { /* seek to data location */ - if (lseek(ef->fd, ef->header->directory->hash[hash].node[i].offset, SEEK_SET) < 0) + if (fseek(ef->fp, ef->header->directory->hash[hash].node[i].offset, SEEK_SET) < 0) { free(tmp_data); free(data); @@ -625,7 +713,7 @@ break; } /* read it */ - if (read(ef->fd, tmp_data, tmp_size) != (ssize_t)tmp_size) + if (fread(tmp_data, tmp_size, 1, ef->fp) != 1) { free(tmp_data); free(data); @@ -771,7 +859,7 @@ for (j = 0; j < ef->header->directory->hash[i].size; j++) { /* if the entry matches the input glob */ - if (!fnmatch(ef->header->directory->hash[i].node[j].name, glob, 0)) + if (!fnmatch(glob, ef->header->directory->hash[i].node[j].name, 0)) { char **new_list; =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/eet/src/Attic/eet_main.c,v retrieving revision 1.1.2.2 retrieving revision 1.1.2.3 diff -u -3 -r1.1.2.2 -r1.1.2.3 --- eet_main.c 9 May 2002 00:31:45 -0000 1.1.2.2 +++ eet_main.c 9 May 2002 04:56:57 -0000 1.1.2.3 @@ -8,6 +8,7 @@ #include <unistd.h> #include <dirent.h> #include <limits.h> +#include <fnmatch.h> int eet_mkdir(char *dir); void eet_mkdirs(char *s); @@ -15,9 +16,9 @@ void depak_file(Eet_File *ef, char *file); void depack(char *pak_file); -void pak_file(Eet_File *ef, char *file, int compress); -void pak_dir(Eet_File *ef, char *dir, int compress); -void pack(char *pak_file, char **files, int count, int compress); +void pak_file(Eet_File *ef, char *file, char **noz, int noz_num); +void pak_dir(Eet_File *ef, char *dir, char **noz, int noz_num); +void pack(char *pak_file, char **files, int count, char **noz, int noz_num); static mode_t default_mode = S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH; @@ -108,7 +109,7 @@ } void -pak_file(Eet_File *ef, char *file, int compress) +pak_file(Eet_File *ef, char *file, char **noz, int noz_num) { struct stat st; @@ -124,6 +125,17 @@ f = fopen(file, "r"); if (f) { + int compress = 1; + int i; + + for (i = 0; i < noz_num; i++) + { + if (!fnmatch(noz[i], file, 0)) + { + compress = 1; + break; + } + } fread(buf, 1, st.st_size, f); if (!eet_write(ef, file, buf, st.st_size, compress)) printf("error importing: %s\n", file); @@ -137,14 +149,14 @@ } void -pak_dir(Eet_File *ef, char *dir, int compress) +pak_dir(Eet_File *ef, char *dir, char **noz, int noz_num) { DIR *dirp; struct dirent *dp; dirp = opendir(dir); if (!dirp) - pak_file(ef, dir, compress); + pak_file(ef, dir, noz, noz_num); else { while ((dp = readdir(dirp))) @@ -157,14 +169,14 @@ else { snprintf(buf, sizeof(buf), "%s/%s", dir, dp->d_name); - pak_dir(ef, buf, compress); + pak_dir(ef, buf, noz, noz_num); } } } } void -pack(char *pak_file, char **files, int count, int compress) +pack(char *pak_file, char **files, int count, char **noz, int noz_num) { Eet_File *ef; int i; @@ -175,7 +187,7 @@ printf("cannot open for writing: %s\n", pak_file); return; } - for (i = 0; i < count; i++) pak_dir(ef, files[i], compress); + for (i = 0; i < count; i++) pak_dir(ef, files[i], noz, noz_num); printf("done.\n"); eet_close(ef); } @@ -194,14 +206,39 @@ } else if (argc > 3) { + char **noz = NULL; + int noz_num = 0; + if (!strcmp(argv[1], "-c")) { - pack(argv[2], &(argv[3]), argc - 3, 1); + int i; + + for (i = 3; i < argc; i++) + { + if (!strcmp(argv[i], "-nz")) + { + if (i < (argc - 1)) + { + i++; + noz_num++; + noz = realloc(noz, noz_num * sizeof(char *)); + noz[noz_num - 1] = argv[i]; + } + } + else + break; + } + pack(argv[2], &(argv[i]), argc - i, noz, noz_num); return 0; } } - printf("usage: %s -d pack_file\n" - " %s -c out_pack_file file1 [file2...]\n", + printf("usage:\n" + " %s -d in_file\n" + " %s -c out_file [-nz glob [-nz glob ...]] dir_file1 [dir_file2 ...]\n" + "where:\n" + " -d in_file unpack eet file\n" + " -c out_file pack up eet file\n" + " -nz match don't compress files matching match glob\n", argv[0], argv[0]); return -1; } |
From: <enl...@li...> - 2002-05-09 05:43:21
|
Enlightenment CVS committal Author : raster Project : e17 Module : libs/eet Dir : e17/libs/eet/src Modified Files: Tag: SPLIT eet_lib.c Log Message: oops... fix fix... =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/eet/src/Attic/eet_lib.c,v retrieving revision 1.1.2.3 retrieving revision 1.1.2.4 diff -u -3 -r1.1.2.3 -r1.1.2.4 --- eet_lib.c 9 May 2002 04:56:57 -0000 1.1.2.3 +++ eet_lib.c 9 May 2002 05:43:21 -0000 1.1.2.4 @@ -161,7 +161,7 @@ /* go thru - first mismatch - exit with 0 */ do { - if (s1 != s2) return 0; + if (*s1 != *s2) return 0; s1++; s2++; } |
From: <enl...@li...> - 2002-05-09 05:43:51
|
Enlightenment CVS committal Author : raster Project : e17 Module : libs/eet Dir : e17/libs/eet Modified Files: Tag: SPLIT configure Log Message: oops... fix fix... =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/eet/Attic/configure,v retrieving revision 1.1.2.8 retrieving revision 1.1.2.9 diff -u -3 -r1.1.2.8 -r1.1.2.9 --- configure 9 May 2002 04:56:56 -0000 1.1.2.8 +++ configure 9 May 2002 05:43:20 -0000 1.1.2.9 @@ -132,6 +132,7 @@ install -d $PREFIX"/lib" install -d $PREFIX"/include" install -d $PREFIX"/bin" + rm -f $PREFIX"/lib"$OUT"."$VERSION cp -a $OUT"."$VERSION $PREFIX"/lib" ln -sf $OUT"."$VERSION $PREFIX"/lib/"$OUT"."$VERSION2 ln -sf $OUT"."$VERSION $PREFIX"/lib/"$OUT"."$VERSION3 @@ -139,6 +140,7 @@ chmod a+r+x $PREFIX"/lib/"$OUT"."$VERSION cp -a $INC $PREFIX"/include" cp -a $CONFIG $PREFIX"/bin" + rm -f $PREFIX"/bin/"$EXE cp -a $EXE $PREFIX"/bin" fi |
From: <enl...@li...> - 2002-05-09 05:44:30
|
Enlightenment CVS committal Author : raster Project : e17 Module : libs/eet Dir : e17/libs/eet Modified Files: Tag: SPLIT configure Log Message: and clean that. =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/eet/Attic/configure,v retrieving revision 1.1.2.9 retrieving revision 1.1.2.10 diff -u -3 -r1.1.2.9 -r1.1.2.10 --- configure 9 May 2002 05:43:20 -0000 1.1.2.9 +++ configure 9 May 2002 05:44:29 -0000 1.1.2.10 @@ -133,6 +133,9 @@ install -d $PREFIX"/include" install -d $PREFIX"/bin" rm -f $PREFIX"/lib"$OUT"."$VERSION + rm -f $PREFIX"/lib"$OUT"."$VERSION2 + rm -f $PREFIX"/lib"$OUT"."$VERSION3 + rm -f $PREFIX"/lib"$OUT" cp -a $OUT"."$VERSION $PREFIX"/lib" ln -sf $OUT"."$VERSION $PREFIX"/lib/"$OUT"."$VERSION2 ln -sf $OUT"."$VERSION $PREFIX"/lib/"$OUT"."$VERSION3 |
From: <enl...@li...> - 2002-05-09 05:45:23
|
Enlightenment CVS committal Author : raster Project : e17 Module : libs/eet Dir : e17/libs/eet Modified Files: Tag: SPLIT configure Log Message: oops =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/eet/Attic/configure,v retrieving revision 1.1.2.10 retrieving revision 1.1.2.11 diff -u -3 -r1.1.2.10 -r1.1.2.11 --- configure 9 May 2002 05:44:29 -0000 1.1.2.10 +++ configure 9 May 2002 05:45:22 -0000 1.1.2.11 @@ -135,7 +135,7 @@ rm -f $PREFIX"/lib"$OUT"."$VERSION rm -f $PREFIX"/lib"$OUT"."$VERSION2 rm -f $PREFIX"/lib"$OUT"."$VERSION3 - rm -f $PREFIX"/lib"$OUT" + rm -f $PREFIX"/lib"$OUT cp -a $OUT"."$VERSION $PREFIX"/lib" ln -sf $OUT"."$VERSION $PREFIX"/lib/"$OUT"."$VERSION2 ln -sf $OUT"."$VERSION $PREFIX"/lib/"$OUT"."$VERSION3 |
From: <enl...@li...> - 2002-05-09 23:56:33
|
Enlightenment CVS committal Author : raster Project : e17 Module : libs/eet Dir : e17/libs/eet/src Modified Files: Tag: SPLIT eet_main.c Log Message: add a -l option, and more help. =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/eet/src/Attic/eet_main.c,v retrieving revision 1.1.2.3 retrieving revision 1.1.2.4 diff -u -3 -r1.1.2.3 -r1.1.2.4 --- eet_main.c 9 May 2002 04:56:57 -0000 1.1.2.3 +++ eet_main.c 9 May 2002 23:56:31 -0000 1.1.2.4 @@ -16,6 +16,8 @@ void depak_file(Eet_File *ef, char *file); void depack(char *pak_file); +void list(char *pak_file); + void pak_file(Eet_File *ef, char *file, char **noz, int noz_num); void pak_dir(Eet_File *ef, char *dir, char **noz, int noz_num); void pack(char *pak_file, char **files, int count, char **noz, int noz_num); @@ -109,6 +111,29 @@ } void +list(char *pak_file) +{ + int i, num; + char **list; + Eet_File *ef; + + ef = eet_open(pak_file, EET_FILE_MODE_READ); + if (!ef) + { + printf("cannot open for reading: %s\n", pak_file); + return; + } + list = eet_list(ef, "*", &num); + if (list) + { + for (i = 0; i < num; i++) + printf("%s\n",list[i]); + free(list); + } + eet_close(ef); +} + +void pak_file(Eet_File *ef, char *file, char **noz, int noz_num) { struct stat st; @@ -203,6 +228,11 @@ depack(argv[2]); return 0; } + else if (!strcmp(argv[1], "-l")) + { + list(argv[2]); + return 0; + } } else if (argc > 3) { @@ -233,12 +263,21 @@ } } printf("usage:\n" + " %s -l in_file\n" " %s -d in_file\n" " %s -c out_file [-nz glob [-nz glob ...]] dir_file1 [dir_file2 ...]\n" + "\n" "where:\n" + " -l in_file list contents of eet file\n" " -d in_file unpack eet file\n" " -c out_file pack up eet file\n" - " -nz match don't compress files matching match glob\n", - argv[0], argv[0]); + " -nz match don't compress files matching match glob\n" + "\n" + "example:\n" + " %s -c out.eet -nz \"*.jpg\" things/\n" + " %s -l out.eet\n" + " %s -d out.eet\n", + argv[0], argv[0], argv[0], + argv[0], argv[0], argv[0]); return -1; } |
From: <enl...@li...> - 2002-05-10 00:09:16
|
Enlightenment CVS committal Author : raster Project : e17 Module : libs/eet Dir : e17/libs/eet/src Modified Files: Tag: SPLIT eet_main.c Log Message: oops - didnt honor no compress glob. fixed and print startus of if it's being compressed or not. =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/eet/src/Attic/eet_main.c,v retrieving revision 1.1.2.4 retrieving revision 1.1.2.5 diff -u -3 -r1.1.2.4 -r1.1.2.5 --- eet_main.c 9 May 2002 23:56:31 -0000 1.1.2.4 +++ eet_main.c 10 May 2002 00:09:16 -0000 1.1.2.5 @@ -157,7 +157,7 @@ { if (!fnmatch(noz[i], file, 0)) { - compress = 1; + compress = 0; break; } } @@ -165,7 +165,12 @@ if (!eet_write(ef, file, buf, st.st_size, compress)) printf("error importing: %s\n", file); else - printf("imported: %s\n", file); + { + if (compress) + printf("compress: %s\n", file); + else + printf("imported: %s\n", file); + } fclose(f); } free(buf); |
From: <enl...@li...> - 2002-05-13 00:24:06
|
Enlightenment CVS committal Author : raster Project : e17 Module : libs/eet Dir : e17/libs/eet Modified Files: Tag: SPLIT configure Log Message: oops... =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/eet/Attic/configure,v retrieving revision 1.1.2.11 retrieving revision 1.1.2.12 diff -u -3 -r1.1.2.11 -r1.1.2.12 --- configure 9 May 2002 05:45:22 -0000 1.1.2.11 +++ configure 13 May 2002 00:24:06 -0000 1.1.2.12 @@ -66,7 +66,7 @@ CC=gcc fi -LINK="-L"$PREFIX"/libs "$LINK +LINK="-L"$PREFIX"/lib "$LINK INCLUDES="-I"$PREFIX"/includes "$INCLUDES LIBS=$LINK" -l"$LIB VERSION2=`echo $VERSION | awk -F"." '{printf("%s.%s", $1, $2);}'` |
From: <enl...@li...> - 2002-05-13 01:38:46
|
Enlightenment CVS committal Author : raster Project : e17 Module : libs/eet Dir : e17/libs/eet Modified Files: Tag: SPLIT configure Log Message: oopsie =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/eet/Attic/configure,v retrieving revision 1.1.2.12 retrieving revision 1.1.2.13 diff -u -3 -r1.1.2.12 -r1.1.2.13 --- configure 13 May 2002 00:24:06 -0000 1.1.2.12 +++ configure 13 May 2002 01:38:44 -0000 1.1.2.13 @@ -67,7 +67,7 @@ fi LINK="-L"$PREFIX"/lib "$LINK -INCLUDES="-I"$PREFIX"/includes "$INCLUDES +INCLUDES="-I"$PREFIX"/include "$INCLUDES LIBS=$LINK" -l"$LIB VERSION2=`echo $VERSION | awk -F"." '{printf("%s.%s", $1, $2);}'` VERSION3=`echo $VERSION | awk -F"." '{printf("%s", $1);}'` |
From: <enl...@li...> - 2002-05-19 22:40:31
|
Enlightenment CVS committal Author : raster Project : e17 Module : libs/eet Dir : e17/libs/eet Modified Files: Tag: SPLIT configure Log Message: wheee. cp fix =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/eet/Attic/configure,v retrieving revision 1.1.2.13 retrieving revision 1.1.2.14 diff -u -3 -r1.1.2.13 -r1.1.2.14 --- configure 13 May 2002 01:38:44 -0000 1.1.2.13 +++ configure 19 May 2002 22:40:29 -0000 1.1.2.14 @@ -37,7 +37,7 @@ rm -f eet-config eet libeet.so* $TMPFILES cd .. mkdir $PACKAGE"-"$VERSION - cp -ar ./configure ./*.spec ./COPYING ./README ./AUTHORS ./src $PACKAGE"-"$VERSION + cp -pR ./configure ./*.spec ./COPYING ./README ./AUTHORS ./src $PACKAGE"-"$VERSION cd $PACKAGE"-"$VERSION rm -rf `find . -name CVS -type d -print` cd .. @@ -136,15 +136,15 @@ rm -f $PREFIX"/lib"$OUT"."$VERSION2 rm -f $PREFIX"/lib"$OUT"."$VERSION3 rm -f $PREFIX"/lib"$OUT - cp -a $OUT"."$VERSION $PREFIX"/lib" + cp -pR $OUT"."$VERSION $PREFIX"/lib" ln -sf $OUT"."$VERSION $PREFIX"/lib/"$OUT"."$VERSION2 ln -sf $OUT"."$VERSION $PREFIX"/lib/"$OUT"."$VERSION3 ln -sf $OUT"."$VERSION $PREFIX"/lib/"$OUT chmod a+r+x $PREFIX"/lib/"$OUT"."$VERSION - cp -a $INC $PREFIX"/include" - cp -a $CONFIG $PREFIX"/bin" + cp -pR $INC $PREFIX"/include" + cp -pR $CONFIG $PREFIX"/bin" rm -f $PREFIX"/bin/"$EXE - cp -a $EXE $PREFIX"/bin" + cp -pR $EXE $PREFIX"/bin" fi cd .. |
From: <enl...@li...> - 2002-08-04 09:06:26
|
Enlightenment CVS committal Author : raster Project : e17 Module : libs/eet Dir : e17/libs/eet/src Modified Files: Tag: SPLIT Eet.h Added Files: Tag: SPLIT eet_data.c Log Message: eet_data. the start of data munging/encapsulation code for eet. for now it can save and loadimage data into an eet entry (images can be uncompressed, compressed losslessly (to any level 1 to 9), compressed with lossiness at any quality (1 - 100) and lossy compression ALSO SUPPORTS alpha channels for images (the alpha channel is jpeg compressed as an extra grayscale plane). evas2 can load these all right now. i also plan on adding data struct -> eet and eet -> struct code that linerises lumps of data and de-linearises them so apps can quickly populate data structs and save them too. =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/eet/src/Attic/Eet.h,v retrieving revision 1.1.2.2 retrieving revision 1.1.2.3 diff -u -3 -r1.1.2.2 -r1.1.2.3 --- Eet.h 9 May 2002 00:31:45 -0000 1.1.2.2 +++ Eet.h 4 Aug 2002 09:06:24 -0000 1.1.2.3 @@ -23,16 +23,16 @@ /***************************************************************************/ - - typedef enum _Eet_File_Mode Eet_File_Mode; - - typedef struct _Eet_File Eet_File; enum _Eet_File_Mode { EET_FILE_MODE_READ, EET_FILE_MODE_WRITE }; + + typedef enum _Eet_File_Mode Eet_File_Mode; + + typedef struct _Eet_File Eet_File; /***************************************************************************/ @@ -125,7 +125,17 @@ * value of "*". */ char **eet_list (Eet_File *ef, char *glob, int *count_ret); - + + /* TBD + * + */ + void *eet_data_image_read(Eet_File *ef, char *name, + int *w, int *h, int *alpha, + int *compress, int *quality, int *lossy); + int eet_data_image_write(Eet_File *ef, char *name, + void *data, int w, int h, int alpha, + int compression, int quality, int lossy); + /***************************************************************************/ #ifdef __cplusplus } |
From: <enl...@li...> - 2002-08-04 09:06:56
|
Enlightenment CVS committal Author : raster Project : e17 Module : libs/eet Dir : e17/libs/eet Modified Files: Tag: SPLIT configure Log Message: eet_data. the start of data munging/encapsulation code for eet. for now it can save and loadimage data into an eet entry (images can be uncompressed, compressed losslessly (to any level 1 to 9), compressed with lossiness at any quality (1 - 100) and lossy compression ALSO SUPPORTS alpha channels for images (the alpha channel is jpeg compressed as an extra grayscale plane). evas2 can load these all right now. i also plan on adding data struct -> eet and eet -> struct code that linerises lumps of data and de-linearises them so apps can quickly populate data structs and save them too. =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/eet/Attic/configure,v retrieving revision 1.1.2.14 retrieving revision 1.1.2.15 diff -u -3 -r1.1.2.14 -r1.1.2.15 --- configure 19 May 2002 22:40:29 -0000 1.1.2.14 +++ configure 4 Aug 2002 09:06:23 -0000 1.1.2.15 @@ -9,8 +9,8 @@ CONFIG="eet-config" INC="Eet.h" -SRC="eet_lib.c" -LINK="-lz" +SRC="eet_lib.c eet_data.c" +LINK="-lz -ljpeg" INCLUDES="" ############################################################################### |
From: <enl...@li...> - 2002-09-14 09:22:39
|
Enlightenment CVS committal Author : raster Project : e17 Module : libs/eet Dir : e17/libs/eet Modified Files: Tag: SPLIT README configure Log Message: eet... jpeg in eet handling (load/save) jpeg +alpha in eet handling (load/save) lossless compression (with alpha) handling (load/save) uncompressed lossless (with alpha) handling (load.save) data struct encoding (load/save) =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/eet/Attic/README,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -u -3 -r1.1.2.1 -r1.1.2.2 --- README 9 May 2002 00:31:45 -0000 1.1.2.1 +++ README 14 Sep 2002 09:22:06 -0000 1.1.2.2 @@ -12,6 +12,7 @@ What does it require: Zlib. + libjpeg. How to build: =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/eet/Attic/configure,v retrieving revision 1.1.2.15 retrieving revision 1.1.2.16 diff -u -3 -r1.1.2.15 -r1.1.2.16 --- configure 4 Aug 2002 09:06:23 -0000 1.1.2.15 +++ configure 14 Sep 2002 09:22:06 -0000 1.1.2.16 @@ -115,7 +115,7 @@ # exe tool - SRC="eet_main.c" + SRC="eet_main.c "$SRC OUTPUT=$EXE BUILDFLAGS="" |