]> granicus.if.org Git - zziplib/commitdiff
write.h extract
authorGuido Draheim <guidod@gmx.de>
Mon, 18 Sep 2006 02:07:15 +0000 (02:07 +0000)
committerGuido Draheim <guidod@gmx.de>
Mon, 18 Sep 2006 02:07:15 +0000 (02:07 +0000)
 (.)

zzip/Makefile.am
zzip/Makefile.in
zzip/fetch.c
zzip/file.c
zzip/fseeko.c
zzip/fseeko.h
zzip/mmapped.c
zzip/mmapped.h
zzip/write.c
zzip/write.h [new file with mode: 0644]
zzip/zzip.h

index 95fb8f17f78a3bf003623d1fec166114cfe4fc10..3ec2c7b6fe56b14a2c0674329bcabf71a275427c 100644 (file)
@@ -31,6 +31,7 @@ libzzip_la_headers = \
        plugin.h \
        lib.h \
        zzip.h \
+        write.h \
        fetch.h \
        format.h \
         info.h \
index 9475e5abd7b237e82580af38c123f50461d7e51b..a2d244e170532a50bae92c803ff3ac8adf24b6f5 100644 (file)
@@ -273,6 +273,7 @@ libzzip_la_headers = \
        plugin.h \
        lib.h \
        zzip.h \
+        write.h \
        fetch.h \
        format.h \
         info.h \
index 23be82376df24dbd40e32a9dcd0d98f2f8ea1964..8b7a7a89e3ff1c71e7145544f1df2b3436fe5087 100644 (file)
@@ -1,3 +1,19 @@
+/*
+ * These routines are helpers - note that this file gets linked into all the
+ * zip-access variants that refer to <zzip/format.h>. On the x86 platform the
+ * actual definitions will be empty - fetching is done on native machine-level
+ *
+ * Author: 
+ *      Guido Draheim <guidod@gmx.de>
+ *
+ * Copyright (c) 2004,2005,2006 Guido Draheim
+ *          All rights reserved,
+ *          use under the restrictions of the 
+ *          Lesser GNU General Public License
+ *          or alternatively the restrictions 
+ *          of the Mozilla Public License 1.1
+ */
+
 #include <zzip/fetch.h>
 
 #if defined ZZIP_WORDS_BIGENDIAN && \
index 4944cd7c74aada153e094c6f3c0138508054a81a..d8c1dc8edef841217b3944f3e2e0691265aef0ed 100644 (file)
@@ -471,7 +471,7 @@ zzip_fread(void *ptr, zzip_size_t size, zzip_size_t nmemb, ZZIP_FILE *file)
 
 /* ------------------------------------------------------------------- */
 
-/**                                                            
+/**                                                          also: fopen(2)  
  * This function will => fopen(3) a real/zipped file.
  * 
  * It has some magic functionality builtin - it will first try to open
@@ -492,22 +492,22 @@ zzip_fread(void *ptr, zzip_size_t size, zzip_size_t nmemb, ZZIP_FILE *file)
  * zzip modes called ZZIP_CASEINSENSITIVE and ZZIP_IGNOREPATH.
  * Currently, this => zzip_fopen call will convert the following
  * characters in the mode-string into their corrsponding mode-bits: 
- *  <ul><li><code> "r" : O_RDONLY : </code> read-only
- * </li><li><code> "b" : O_BINARY : </code> binary (win32 specific)
- * </li><li><code> "f" : O_NOCTTY : </code> no char device (unix)
- * </li><li><code> "i" : ZZIP_CASELESS : </code> inside zip file
- * </li><li><code> "*" : ZZIP_NOPATHS : </code> inside zip file only
- * </ul> all other modes will be ignored for zip-contained entries
+ * <code> "r" : O_RDONLY : </code> read-only
+ * <code> "b" : O_BINARY : </code> binary (win32 specific)
+ * <code> "f" : O_NOCTTY : </code> no char device (unix)
+ * <code> "i" : ZZIP_CASELESS : </code> inside zip file
+ * <code> "*" : ZZIP_NOPATHS : </code> inside zip file only
+ * all other modes will be ignored for zip-contained entries
  * but they are transferred for compatibility and portability,
  * including these extra sugar bits:
- *  <ul><li><code> "x" : O_EXCL :</code> fail if file did exist
- * </li><li><code> "s" : O_SYNC :</code> synchronized access
- * </li><li><code> "n" : O_NONBLOCK :</code> nonblocking access
- * </li><li><code> "z#" : compression level :</code> for zlib
- * </li><li><code> "g#" : group access :</code> unix access bits
- * </li><li><code> "u#" : owner access :</code> unix access bits
- * </li><li><code> "o#" : world access :</code> unix access bits
- * </ul>... the access bits are in traditional unix bit format
+ * <code> "x" : O_EXCL :</code> fail if file did exist
+ * <code> "s" : O_SYNC :</code> synchronized access
+ * <code> "n" : O_NONBLOCK :</code> nonblocking access
+ * <code> "z#" : compression level :</code> for zlib
+ * <code> "g#" : group access :</code> unix access bits
+ * <code> "u#" : owner access :</code> unix access bits
+ * <code> "o#" : world access :</code> unix access bits
+ * ... the access bits are in traditional unix bit format
  * with 7 = read/write/execute, 6 = read/write, 4 = read-only.
  *
  * The default access mode is 0664, and the compression level
@@ -619,10 +619,10 @@ zzip_freopen(zzip_char_t* filename, zzip_char_t* mode, ZZIP_FILE* stream)
  * There was a possibility to transfer zziplib-specific openmodes
  * through o_flags but you should please not use them anymore and
  * look into => zzip_open_ext_io to submit them down. This function
- * is shallow in that it just extracts the zzipflags and calls <ul><li><code>
- * zzip_open_ext_io(filename, o_flags, zzipflags|0664, 0, 0) </code></li></ul>
- * you must stop using this extra functionality (not well known
- * anyway) since zzip_open might be later usable to open files
+ * is shallow in that it just extracts the zzipflags and calls <ul><li><p>
+ * <code>zzip_open_ext_io(filename, o_flags, zzipflags|0664, 0, 0) </code>
+ * </p></li></ul> you must stop using this extra functionality (not well 
+ * known anyway) since zzip_open might be later usable to open files
  * for writing in which case the _EXTRAFLAGS will get in conflict.
  *
  * compare with  => open(2) and => zzip_fopen
@@ -880,7 +880,7 @@ zzip_rewind(ZZIP_FILE *fp)
     return err;
 }
 
-/**                                                                  
+/**  
  * This function will perform a => lseek(2) operation on a real/zipped file
  *
  * It will try to seek to the offset specified by offset, relative to whence, 
index 290e6940cecbf1b4f0491e0dfd8d97e746809ba1..de1296532546b1c76d9d226b497565a7e904ce05 100644 (file)
 #define _LARGEFILE_SOURCE 1
 #define _ZZIP_ENTRY_STRUCT 1
 
-#include <zzip/types.h>
+#include <zzip/fseeko.h>
+
+#include <zzip/fetch.h>
+#include <zzip/__mmap.h>
+#include <zzip/__fnmatch.h>
 
 #include <assert.h>
 #include <stdlib.h>
 #include <strings.h>
 #endif
 
-#include <zlib.h>
-#include <zzip/format.h>
-#include <zzip/fseeko.h>
-#include <zzip/fetch.h>
-#include <zzip/__mmap.h>
-#include <zzip/__fnmatch.h>
-
 #if __STDC_VERSION__+0 > 199900L
 #define ___
 #define ____
index 6b84ff1739c130af05c7c74186069906969d831f..9abade7452c7df850bb68124817729e377957563 100644 (file)
 #include <zzip/types.h>
 #include <stdio.h>
 
+#ifdef _ZZIP_ENTRY_STRUCT
+#include <zlib.h>
+#include <zzip/format.h>
+#endif
+
 #ifdef __cplusplus
 extern "C" {
 #endif
index 3cad54daf58d4ee8dfc3d1ecb2f85c0fdf07604d..dfde71b0f82ca5db92b9beb6a69e3f25fba98bff 100644 (file)
@@ -17,7 +17,7 @@
  * Author: 
  *      Guido Draheim <guidod@gmx.de>
  *
- * Copyright (c) 2003,2004 Guido Draheim
+ * Copyright (c) 2003,2004,2006 Guido Draheim
  *          All rights reserved,
  *          use under the restrictions of the 
  *          Lesser GNU General Public License
  *          of the Mozilla Public License 1.1
  */
 
+#define _ZZIP_DISK_FILE_STRUCT 1
+
 #ifdef __linux__
-#define _GNU_SOURCE _glibc_developers_are_idiots_to_call_this_gnu_specific_
+#define _GNU_SOURCE _glibc_developers_are_idiots_to_call_strndup_gnu_specific_
 #endif
 
-#define _ZZIP_DISK_FILE_STRUCT 1
-
-#include <zzip/types.h>
+#include <zzip/mmapped.h>
+#include <zzip/format.h>
+#include <zzip/fetch.h>
+#include <zzip/__mmap.h>
+#include <zzip/__fnmatch.h>
 
 #include <stdlib.h>
 #include <sys/stat.h>
 #include <strings.h>
 #endif
 
-#include <zlib.h>
-#include <zzip/mmapped.h>
-#include <zzip/format.h>
-#include <zzip/fetch.h>
-#include <zzip/__mmap.h>
-#include <zzip/__fnmatch.h>
 
 #if __STDC_VERSION__+0 > 199900L
 #define ___
index 951602abb859492f3ce8b7dd00a48f02016dac29..e7faa8ce74e0b821df85f0d13d41bd6e9653ad50 100644 (file)
 
 #include <zzip/types.h>
 
+#ifdef _ZZIP_DISK_FILE_STRUCT
+#include <zlib.h> /* z_stream */
+#endif
+
 #ifdef __cplusplus
 extern "C" {
 #endif
index 36637ddbcc9dc9a41957ede21cb5ad196c10893a..2f6ab0c59dfbabad451d837cd34f15a2b44eda7f 100644 (file)
@@ -5,6 +5,14 @@
  * where time-stamps are rather unimportant. Here we can create an 
  * archive with filenames and their data portions, possibly obfuscated.
  *
+ * DONT USE THIS
+ *
+ * The write support is supposed to be added directly into the main
+ * zziplib but it has not been implemented so far. It does however
+ * export the relevant call entries which will return EROFS (read-only
+ * filesystem) in case they are being called. That allows later programs
+ * to start up with earlier versions of zziplib that can only read ZIPs.
+ *
  * Author: 
  *      Guido Draheim <guidod@gmx.de>
  *
@@ -24,7 +32,7 @@
 #define _ZZIP_POSIX_WRITE
 #endif
 
-#include <zzip/lib.h>                                         /* exported...*/
+#include <zzip/write.h>                   /* #includes <zzip/lib.h> */
 #include <zzip/file.h>
 
 #include <string.h>
@@ -207,7 +215,7 @@ zzip_createdir(zzip_char_t* name, int o_mode)
         return zzip_dir_creat (name, o_mode);
 }
 
-/** => zzip_file_creat                   => mkdir(2), creat(2), zzip_dir_creat
+/** => zzip_file_creat              also: mkdir(2), creat(2), zzip_dir_creat
  *
  * This function has an additional primary argument over the posix
  * mkdir(2) - if it is null then this function behaves just like
diff --git a/zzip/write.h b/zzip/write.h
new file mode 100644 (file)
index 0000000..6db6b09
--- /dev/null
@@ -0,0 +1,58 @@
+#ifndef _ZZIP_WRITE_H
+#define _ZZIP_WRITE_H
+
+#include <zzip/lib.h>
+
+/* ........................................................................
+ * write support is not yet implemented
+ * zzip/write.c
+ */
+#define ZZIP_NO_CREAT 1
+
+ZZIP_DIR*    zzip_dir_creat_ext_io(zzip_char_t* name, int o_mode, 
+                                   zzip_strings_t* ext, zzip_plugin_io_t io);
+ZZIP_DIR*    zzip_dir_creat(zzip_char_t* name, int o_mode);
+int          zzip_file_mkdir(ZZIP_DIR* dir, zzip_char_t* name, int o_mode);
+ZZIP_FILE*   zzip_file_creat(ZZIP_DIR* dir, zzip_char_t* name, int o_mode);
+zzip_ssize_t zzip_file_write(ZZIP_FILE* file, 
+                             const void* ptr, zzip_size_t len);
+
+ZZIP_DIR*    zzip_createdir(zzip_char_t* name, int o_mode);
+zzip_ssize_t zzip_write(ZZIP_FILE* file, const void* ptr, zzip_size_t len);
+zzip_size_t  zzip_fwrite(const void* ptr, zzip_size_t len, 
+                         zzip_size_t multiply, ZZIP_FILE* file);
+#ifndef zzip_savefile
+#define zzip_savefile 0
+#define zzip_savefile_is_null
+#endif
+
+#ifdef _ZZIP_NO_INLINE
+#define zzip_mkdir(_name_,_mode_) \
+        zzip_file_mkdir((zzip_savefile),(_name_),(_mode_))
+#define zzip_creat(_name_,_mode_) \
+        zzip_file_creat((zzip_savefile),(_name_),(_mode_))
+#define zzip_sync() \
+      { zzip_closedir((zzip_savefile)); (zzip_savefile) = 0; }
+#define zzip_start(_name_,_mode_,_ext_) \
+      { if ((zzip_savefile)) zzip_closedir((zzip_savefile)); 
+         zzip_savefile = zzip_dir_creat(_name_, _mode_,_ext_); }
+
+#else
+
+_zzip_inline static int         zzip_mkdir(zzip_char_t* name, int o_mode)
+{                   return zzip_file_mkdir(zzip_savefile, name, o_mode); }
+_zzip_inline static ZZIP_FILE*  zzip_creat(zzip_char_t* name, int o_mode)
+{                   return zzip_file_creat(zzip_savefile, name, o_mode); }
+
+#ifndef zzip_savefile_is_null
+_zzip_inline static void        zzip_sync(void)
+{                           zzip_closedir(zzip_savefile); zzip_savefile = 0; }
+_zzip_inline static void        zzip_mkfifo(zzip_char_t* name, int o_mode)
+{       if ((zzip_savefile)) zzip_closedir (zzip_savefile);
+             zzip_savefile = zzip_createdir(_name_,_mode_); }
+#else
+_zzip_inline static void        zzip_sync(void) {}
+_zzip_inline static void        zzip_mkfifo(zzip_char_t* name, int o_mode) {}
+#endif
+#endif /* _ZZIP_NO_INLINE */
+#endif /* _ZZIP_WRITE_H */
index eecc4737af1bce5438f0d2f5f9eeaed5938331ba..b3bb4a2228c749ab2dbf4686e36e368cd240dcab 100644 (file)
@@ -255,61 +255,6 @@ ZZIP_DIR *  zzip_dir_open_ext_io(zzip_char_t* filename,
 
 /* zzip_file_open_ext_io => zzip_dir_open_ext_io + zzip_file_open */
 
-#if defined _ZZIP_WRITE_SOURCE
-/* ........................................................................
- * write support is not yet implemented
- * zzip/write.c
- */
-#define ZZIP_NO_CREAT 1
-
-ZZIP_DIR*    zzip_dir_creat_ext_io(zzip_char_t* name, int o_mode, 
-                                   zzip_strings_t* ext, zzip_plugin_io_t io);
-ZZIP_DIR*    zzip_dir_creat(zzip_char_t* name, int o_mode);
-int          zzip_file_mkdir(ZZIP_DIR* dir, zzip_char_t* name, int o_mode);
-ZZIP_FILE*   zzip_file_creat(ZZIP_DIR* dir, zzip_char_t* name, int o_mode);
-zzip_ssize_t zzip_file_write(ZZIP_FILE* file, 
-                             const void* ptr, zzip_size_t len);
-
-ZZIP_DIR*    zzip_createdir(zzip_char_t* name, int o_mode);
-zzip_ssize_t zzip_write(ZZIP_FILE* file, const void* ptr, zzip_size_t len);
-zzip_size_t  zzip_fwrite(const void* ptr, zzip_size_t len, 
-                         zzip_size_t multiply, ZZIP_FILE* file);
-#ifndef zzip_savefile
-#define zzip_savefile 0
-#define zzip_savefile_is_null
-#endif
-
-#ifdef _ZZIP_NO_INLINE
-#define zzip_mkdir(_name_,_mode_) \
-        zzip_file_mkdir((zzip_savefile),(_name_),(_mode_))
-#define zzip_creat(_name_,_mode_) \
-        zzip_file_creat((zzip_savefile),(_name_),(_mode_))
-#define zzip_sync() \
-      { zzip_closedir((zzip_savefile)); (zzip_savefile) = 0; }
-#define zzip_start(_name_,_mode_,_ext_) \
-      { if ((zzip_savefile)) zzip_closedir((zzip_savefile)); 
-         zzip_savefile = zzip_dir_creat(_name_, _mode_,_ext_); }
-
-#else
-
-_zzip_inline static int         zzip_mkdir(zzip_char_t* name, int o_mode)
-{                   return zzip_file_mkdir(zzip_savefile, name, o_mode); }
-_zzip_inline static ZZIP_FILE*  zzip_creat(zzip_char_t* name, int o_mode)
-{                   return zzip_file_creat(zzip_savefile, name, o_mode); }
-
-#ifndef zzip_savefile_is_null
-_zzip_inline static void        zzip_sync(void)
-{                           zzip_closedir(zzip_savefile); zzip_savefile = 0; }
-_zzip_inline static void        zzip_mkfifo(zzip_char_t* name, int o_mode)
-{       if ((zzip_savefile)) zzip_closedir (zzip_savefile);
-             zzip_savefile = zzip_createdir(_name_,_mode_); }
-#else
-_zzip_inline static void        zzip_sync(void) {}
-_zzip_inline static void        zzip_mkfifo(zzip_char_t* name, int o_mode) {}
-#endif
-#endif /* _ZZIP_NO_INLINE */
-#endif /* _ZZIP_WRITE_SOURCE */
-
 #ifdef __cplusplus
 };
 #endif