This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project gfxprim.git.
The branch, master has been updated
discards e0a04e8ae2d7a772cab0eb49858bb6d3045c025d (commit)
via 25054131fde91ee366211edb541a0628ffa4b2e3 (commit)
via 96f9ca184489a22e585571f01592fa2dcb93c588 (commit)
This update added new revisions after undoing existing revisions. That is
to say, the old revision is not a strict subset of the new revision. This
situation occurs when you --force push a change and generate a repository
containing something like this:
* -- * -- B -- O -- O -- O (e0a04e8ae2d7a772cab0eb49858bb6d3045c025d)
N -- N -- N (25054131fde91ee366211edb541a0628ffa4b2e3)
When this happens we assume that you've already had alert emails for all
of the O revisions, and so we here report only the revisions in the N
branch from the common base, B.
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://repo.or.cz/w/gfxprim.git/commit/25054131fde91ee366211edb541a0628ffa4…
commit 25054131fde91ee366211edb541a0628ffa4b2e3
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Tue Jun 17 18:39:38 2014 +0200
tests: loaders: Add GP_IOFlush() test.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/tests/loaders/IO.c b/tests/loaders/IO.c
index 723c17d0..c193098d 100644
--- a/tests/loaders/IO.c
+++ b/tests/loaders/IO.c
@@ -257,6 +257,50 @@ static int test_IOFill(void)
static size_t counter;
+static ssize_t flush_write(GP_IO GP_UNUSED(*io), void *buf, size_t size)
+{
+ size_t to_write = GP_MIN(7u, size);
+
+ if (((uint8_t*)buf)[0] != counter)
+ return -1;
+
+ counter += to_write;
+
+ return to_write;
+}
+
+static int test_IOFlush(void)
+{
+ GP_IO io = {.Write = flush_write};
+ unsigned int i;
+ int fail = 0;
+ uint8_t buf[255];
+
+ for (i = 0; i < 255; i++)
+ buf[i] = i;
+
+ for (i = 1; i < 255; i++) {
+ counter = 0;
+ if (GP_IOFlush(&io, buf, i)) {
+ if (!fail)
+ tst_msg("GP_IOFlush failed");
+ fail++;
+ }
+
+ if (counter != i) {
+ if (!fail)
+ tst_msg("Bytes written %zu expected %u",
+ counter, i);
+ fail++;
+ }
+ }
+
+ if (fail)
+ return TST_FAILED;
+
+ return TST_SUCCESS;
+}
+
static ssize_t wbuf_write(GP_IO GP_UNUSED(*io), void *buf, size_t size)
{
unsigned int i;
@@ -318,7 +362,6 @@ static int test_IOWBuffer(void)
return TST_SUCCESS;
}
-
const struct tst_suite tst_suite = {
.suite_name = "IO",
.tests = {
@@ -333,8 +376,12 @@ const struct tst_suite tst_suite = {
{.name = "IOFill",
.tst_fn = test_IOFill},
+ {.name = "IOFlush",
+ .tst_fn = test_IOFlush},
+
{.name = "IOWBuffer",
- .tst_fn = test_IOWBuffer},
+ .tst_fn = test_IOWBuffer,
+ .flags = TST_CHECK_MALLOC},
{.name = NULL},
}
http://repo.or.cz/w/gfxprim.git/commit/96f9ca184489a22e585571f01592fa2dcb93…
commit 96f9ca184489a22e585571f01592fa2dcb93c588
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Tue Jun 17 00:02:09 2014 +0200
doc: loaders: Update I/O documentation.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/doc/loaders_io.txt b/doc/loaders_io.txt
index 2e010bbc..d3d00a7e 100644
--- a/doc/loaders_io.txt
+++ b/doc/loaders_io.txt
@@ -73,7 +73,21 @@ This is a wrapper to 'io->Read()'.
Reads at most 'size' bytes from an 'IO' stream and stores them into the
buffer. Returns number of bytes read.
-On failure the return value is negative and errno is set.
+On failure negative value is returned and errno is set.
+
+
+[source,c]
+-------------------------------------------------------------------------------
+#include <loaders/GP_IO.h>
+/* or */
+#include <GP.h>
+
+int GP_IOFill(GP_IO *io, void *buf, size_t size);
+-------------------------------------------------------------------------------
+
+Similar to 'GP_IORead()' but either reads the whole buffer or fails.
+
+Returns zero on success and non-zero on failure.
[source,c]
@@ -90,7 +104,34 @@ This is a wrapper to 'io->Write()'.
Writes at most 'size' bytes from an 'IO' stream and stores them into the
buffer. Returns number of bytes read.
-On failure the return value is negative and errno is set.
+On failure negative value is returned and errno is set.
+
+
+[source,c]
+-------------------------------------------------------------------------------
+#include <loaders/GP_IO.h>
+/* or */
+#include <GP.h>
+
+int GP_IOFlush(GP_IO *io, void *buf, size_t size);
+-------------------------------------------------------------------------------
+
+Similar to 'GP_IOWrite()' but either writes the whole buffer or fails.
+
+Returns zero on success and non-zero on failure.
+
+[source,c]
+-------------------------------------------------------------------------------
+#include <loaders/GP_IO.h>
+/* or */
+#include <GP.h>
+
+int GP_IOPrintF(GP_IO *io, const char *fmt, ...);
+-------------------------------------------------------------------------------
+
+Printf-like function for an I/O stream.
+
+Returns zero on success and non-zero on failure.
[source,c]
-------------------------------------------------------------------------------
@@ -106,7 +147,7 @@ This is a wrapper to 'io->Close()'.
Finalizes reading/writing, closes file descriptors (in case of file IO), frees
memory buffers.
-Returns zero on success, non-zero on IO failure and errno is set.
+Returns zero on success, non-zero on I/O failure and errno is set.
[source,c]
@@ -115,13 +156,30 @@ Returns zero on success, non-zero on IO failure and errno is set.
/* or */
#include <GP.h>
+enum GP_IOWhence {
+ GP_IO_SEEK_SET = 0,
+ GP_IO_SEEK_CUR = 1,
+ GP_IO_SEEK_END = 2,
+};
+
off_t GP_IOSeek(GP_IO *io, off_t off, enum GP_IOWhence whence);
-------------------------------------------------------------------------------
This is a wrapper to 'io->Seek()'.
-//TODO
+Returns '(off_t)-1' on failure and errno is set.
+
+Generally not all read I/O streams are seekable back (zlib/rle decompression
+streams, etc.) but all streams should be able to seek to the start of the
+stream, to the end and forward.
+
+.Most common errno values
+|==============================================================================
+| 'EINVAL' | Invalid 'whence' or 'off' points outside the stream.
+| 'ENOSYS' | Operation not supported, combination of 'whence' and 'off' points
+ inside the stream (is valid) but action cannot be done.
+|==============================================================================
[source,c]
-------------------------------------------------------------------------------
@@ -132,7 +190,7 @@ This is a wrapper to 'io->Seek()'.
off_t GP_IOTell(GP_IO *io);
-------------------------------------------------------------------------------
-Wrapper to 'GP_IOSeek()', returns current position in IO stream.
+Wrapper to 'GP_IOSeek()', returns current position in I/O stream.
[source,c]
@@ -144,7 +202,7 @@ Wrapper to 'GP_IOSeek()', returns current position in IO stream.
off_t GP_IORewind(GP_IO *io)
-------------------------------------------------------------------------------
-Wrapper to 'GP_IOSeek()', rewinds to the start of the IO stream.
+Wrapper to 'GP_IOSeek()', rewinds to the start of the I/O stream.
Returns zero on success, non-zero on failure and errno is set.
@@ -158,16 +216,17 @@ Returns zero on success, non-zero on failure and errno is set.
GP_IO *GP_IOMem(void *buf, size_t size, void (*free)(void *));
-------------------------------------------------------------------------------
-Creates an read-only IO from a memory buffer.
+Creates an read-only I/O from a memory buffer.
-Returns initialized IO or in case of failure NULL and errno is set.
+Returns initialized I/O or in case of failure NULL and errno is set.
The 'buf' is pointer to the start of the buffer, the 'size' is size in bytes.
The 'free()' callback if not NULL is called with the start of the buffer as
an argument on 'IOClose()'.
-TIP: See link:example_memory_io.html[memory IO example].
+TIP: See link:example_memory_io.html[memory I/O example].
+
[source,c]
-------------------------------------------------------------------------------
@@ -186,5 +245,24 @@ GP_IO *GP_IOFile(const char *path, enum GP_IOFileMode mode);
Creates an IO stream from a file.
-Returns a pointer to initialized IO stream, or in case of failure NULL and
+Returns a pointer to initialized I/O stream, or in case of failure NULL and
errno is set.
+
+
+[source,c]
+-------------------------------------------------------------------------------
+#include <loaders/GP_IO.h>
+/* or */
+#include <GP.h>
+
+GP_IO *GP_IOWBuffer(GP_IO *io, size_t bsize);
+-------------------------------------------------------------------------------
+
+Creates write buffered I/O on the top of an existing I/O.
+
+Generally you should create a buffered I/O if you are about to write data a
+few bytes at the time.
+
+If 'bsize' is zero default size is choosen.
+
+TIP: See link:example_loader_registration.html[example buffered I/O usage].
-----------------------------------------------------------------------
Summary of changes:
tests/loaders/IO.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 49 insertions(+), 2 deletions(-)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project gfxprim.git.
The branch, master has been updated
via e0a04e8ae2d7a772cab0eb49858bb6d3045c025d (commit)
via 271d541c7c6b1cf431dec46bf577770ad5a32d30 (commit)
via 948e9d7dc2253e7086c2f94792b9a3989a372a80 (commit)
from 76277f09b9ea5b7884309cfe4625ed82811cdfb9 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://repo.or.cz/w/gfxprim.git/commit/e0a04e8ae2d7a772cab0eb49858bb6d3045c…
commit e0a04e8ae2d7a772cab0eb49858bb6d3045c025d
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Tue Jun 17 00:02:09 2014 +0200
doc: loaders; Update I/O documentation.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/doc/loaders_io.txt b/doc/loaders_io.txt
index 2e010bbc..d3d00a7e 100644
--- a/doc/loaders_io.txt
+++ b/doc/loaders_io.txt
@@ -73,7 +73,21 @@ This is a wrapper to 'io->Read()'.
Reads at most 'size' bytes from an 'IO' stream and stores them into the
buffer. Returns number of bytes read.
-On failure the return value is negative and errno is set.
+On failure negative value is returned and errno is set.
+
+
+[source,c]
+-------------------------------------------------------------------------------
+#include <loaders/GP_IO.h>
+/* or */
+#include <GP.h>
+
+int GP_IOFill(GP_IO *io, void *buf, size_t size);
+-------------------------------------------------------------------------------
+
+Similar to 'GP_IORead()' but either reads the whole buffer or fails.
+
+Returns zero on success and non-zero on failure.
[source,c]
@@ -90,7 +104,34 @@ This is a wrapper to 'io->Write()'.
Writes at most 'size' bytes from an 'IO' stream and stores them into the
buffer. Returns number of bytes read.
-On failure the return value is negative and errno is set.
+On failure negative value is returned and errno is set.
+
+
+[source,c]
+-------------------------------------------------------------------------------
+#include <loaders/GP_IO.h>
+/* or */
+#include <GP.h>
+
+int GP_IOFlush(GP_IO *io, void *buf, size_t size);
+-------------------------------------------------------------------------------
+
+Similar to 'GP_IOWrite()' but either writes the whole buffer or fails.
+
+Returns zero on success and non-zero on failure.
+
+[source,c]
+-------------------------------------------------------------------------------
+#include <loaders/GP_IO.h>
+/* or */
+#include <GP.h>
+
+int GP_IOPrintF(GP_IO *io, const char *fmt, ...);
+-------------------------------------------------------------------------------
+
+Printf-like function for an I/O stream.
+
+Returns zero on success and non-zero on failure.
[source,c]
-------------------------------------------------------------------------------
@@ -106,7 +147,7 @@ This is a wrapper to 'io->Close()'.
Finalizes reading/writing, closes file descriptors (in case of file IO), frees
memory buffers.
-Returns zero on success, non-zero on IO failure and errno is set.
+Returns zero on success, non-zero on I/O failure and errno is set.
[source,c]
@@ -115,13 +156,30 @@ Returns zero on success, non-zero on IO failure and errno is set.
/* or */
#include <GP.h>
+enum GP_IOWhence {
+ GP_IO_SEEK_SET = 0,
+ GP_IO_SEEK_CUR = 1,
+ GP_IO_SEEK_END = 2,
+};
+
off_t GP_IOSeek(GP_IO *io, off_t off, enum GP_IOWhence whence);
-------------------------------------------------------------------------------
This is a wrapper to 'io->Seek()'.
-//TODO
+Returns '(off_t)-1' on failure and errno is set.
+
+Generally not all read I/O streams are seekable back (zlib/rle decompression
+streams, etc.) but all streams should be able to seek to the start of the
+stream, to the end and forward.
+
+.Most common errno values
+|==============================================================================
+| 'EINVAL' | Invalid 'whence' or 'off' points outside the stream.
+| 'ENOSYS' | Operation not supported, combination of 'whence' and 'off' points
+ inside the stream (is valid) but action cannot be done.
+|==============================================================================
[source,c]
-------------------------------------------------------------------------------
@@ -132,7 +190,7 @@ This is a wrapper to 'io->Seek()'.
off_t GP_IOTell(GP_IO *io);
-------------------------------------------------------------------------------
-Wrapper to 'GP_IOSeek()', returns current position in IO stream.
+Wrapper to 'GP_IOSeek()', returns current position in I/O stream.
[source,c]
@@ -144,7 +202,7 @@ Wrapper to 'GP_IOSeek()', returns current position in IO stream.
off_t GP_IORewind(GP_IO *io)
-------------------------------------------------------------------------------
-Wrapper to 'GP_IOSeek()', rewinds to the start of the IO stream.
+Wrapper to 'GP_IOSeek()', rewinds to the start of the I/O stream.
Returns zero on success, non-zero on failure and errno is set.
@@ -158,16 +216,17 @@ Returns zero on success, non-zero on failure and errno is set.
GP_IO *GP_IOMem(void *buf, size_t size, void (*free)(void *));
-------------------------------------------------------------------------------
-Creates an read-only IO from a memory buffer.
+Creates an read-only I/O from a memory buffer.
-Returns initialized IO or in case of failure NULL and errno is set.
+Returns initialized I/O or in case of failure NULL and errno is set.
The 'buf' is pointer to the start of the buffer, the 'size' is size in bytes.
The 'free()' callback if not NULL is called with the start of the buffer as
an argument on 'IOClose()'.
-TIP: See link:example_memory_io.html[memory IO example].
+TIP: See link:example_memory_io.html[memory I/O example].
+
[source,c]
-------------------------------------------------------------------------------
@@ -186,5 +245,24 @@ GP_IO *GP_IOFile(const char *path, enum GP_IOFileMode mode);
Creates an IO stream from a file.
-Returns a pointer to initialized IO stream, or in case of failure NULL and
+Returns a pointer to initialized I/O stream, or in case of failure NULL and
errno is set.
+
+
+[source,c]
+-------------------------------------------------------------------------------
+#include <loaders/GP_IO.h>
+/* or */
+#include <GP.h>
+
+GP_IO *GP_IOWBuffer(GP_IO *io, size_t bsize);
+-------------------------------------------------------------------------------
+
+Creates write buffered I/O on the top of an existing I/O.
+
+Generally you should create a buffered I/O if you are about to write data a
+few bytes at the time.
+
+If 'bsize' is zero default size is choosen.
+
+TIP: See link:example_loader_registration.html[example buffered I/O usage].
http://repo.or.cz/w/gfxprim.git/commit/271d541c7c6b1cf431dec46bf577770ad5a3…
commit 271d541c7c6b1cf431dec46bf577770ad5a32d30
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Tue Jun 17 00:01:07 2014 +0200
loaders: IO: Two fixes.
* Fix IOWBuffer close().
* Set errno on invalid whence.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/libs/loaders/GP_IO.c b/libs/loaders/GP_IO.c
index 329fdd43..c8dd9038 100644
--- a/libs/loaders/GP_IO.c
+++ b/libs/loaders/GP_IO.c
@@ -64,6 +64,7 @@ static off_t file_seek(GP_IO *self, off_t off, enum GP_IOWhence whence)
break;
default:
GP_WARN("Invalid whence");
+ errno = EINVAL;
return (off_t)-1;
}
@@ -389,7 +390,7 @@ static int wbuf_close(GP_IO *io)
GP_DEBUG(1, "Closing BufferIO (from %p)", buf_io->io);
if (buf_io->bpos) {
- if (GP_IOFlush(buf_io->io, buf_io->buf, buf_io->bsize))
+ if (GP_IOFlush(buf_io->io, buf_io->buf, buf_io->bpos))
ret = 1;
}
http://repo.or.cz/w/gfxprim.git/commit/948e9d7dc2253e7086c2f94792b9a3989a37…
commit 948e9d7dc2253e7086c2f94792b9a3989a372a80
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Tue Jun 17 00:00:14 2014 +0200
tests: loaders: Add IOWBuffer test.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/tests/loaders/IO.c b/tests/loaders/IO.c
index 32cfa2a1..723c17d0 100644
--- a/tests/loaders/IO.c
+++ b/tests/loaders/IO.c
@@ -255,6 +255,70 @@ static int test_IOFill(void)
return TST_SUCCESS;
}
+static size_t counter;
+
+static ssize_t wbuf_write(GP_IO GP_UNUSED(*io), void *buf, size_t size)
+{
+ unsigned int i;
+
+ for (i = 0; i < size; i++) {
+ if (((uint8_t*)buf)[i] != 'a') {
+ tst_msg("Wrong data in buffer");
+ return -1;
+ }
+ }
+
+ counter += size;
+ return size;
+}
+
+static int wbuf_close(GP_IO GP_UNUSED(*io))
+{
+ return 0;
+}
+
+static int test_IOWBuffer(void)
+{
+ GP_IO *bio;
+ size_t cnt = 0;
+ unsigned int i;
+ GP_IO io = {
+ .Write = wbuf_write,
+ .Close = wbuf_close,
+ };
+
+ counter = 0;
+
+ bio = GP_IOWBuffer(&io, 100);
+
+ if (!bio)
+ return TST_FAILED;
+
+ for (i = 0; i < 100; i++) {
+ size_t to_write = i % 10 + 1;
+ if (GP_IOFlush(bio, "aaaaaaaaaaa", to_write)) {
+ tst_msg("Failed to write data: %s", tst_strerr(errno));
+ GP_IOClose(bio);
+ return TST_FAILED;
+ }
+ cnt += to_write;
+ }
+
+ if (GP_IOClose(bio)) {
+ tst_msg("Failed to close I/O: %s", tst_strerr(errno));
+ return TST_FAILED;
+ }
+
+ if (counter != cnt) {
+ tst_msg("Wrong number of bytes written have %zu expected %zu",
+ counter, cnt);
+ return TST_FAILED;
+ }
+
+ return TST_SUCCESS;
+}
+
+
const struct tst_suite tst_suite = {
.suite_name = "IO",
.tests = {
@@ -269,6 +333,9 @@ const struct tst_suite tst_suite = {
{.name = "IOFill",
.tst_fn = test_IOFill},
+ {.name = "IOWBuffer",
+ .tst_fn = test_IOWBuffer},
+
{.name = NULL},
}
};
-----------------------------------------------------------------------
Summary of changes:
doc/loaders_io.txt | 98 ++++++++++++++++++++++++++++++++++++++++++++-----
libs/loaders/GP_IO.c | 3 +-
tests/loaders/IO.c | 67 ++++++++++++++++++++++++++++++++++
3 files changed, 157 insertions(+), 11 deletions(-)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project gfxprim.git.
The branch, master has been updated
via 7044b9ef7967a50a1f0b437ad5a0554325484296 (commit)
via 004c0cb918280c3a03cd9f1b3b1e5d27476defcb (commit)
via 11ff1196e509567cea23f3bf71653f75c23ac1e8 (commit)
from e0193a071feaf04b54c65348bf11db0d8db6c4ac (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://repo.or.cz/w/gfxprim.git/commit/7044b9ef7967a50a1f0b437ad5a055432548…
commit 7044b9ef7967a50a1f0b437ad5a0554325484296
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sat Jun 14 01:13:06 2014 +0200
loaders: ZIP: Seek to the end of the Zlib IO.
We need to Seek to the end of the Zlib I/O because:
* Files that are not images are not read at all
* There may be bytes that are not consumed by the loader
(known to happen)
and we have to get to the next ZIP header.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/libs/loaders/GP_ZIP.c b/libs/loaders/GP_ZIP.c
index 440aabbf..55d1cdaa 100644
--- a/libs/loaders/GP_ZIP.c
+++ b/libs/loaders/GP_ZIP.c
@@ -324,6 +324,7 @@ static GP_Context *zip_next_file(struct zip_priv *priv,
GP_IOClose(io);
goto out;
*/
+
io = GP_IOZlib(priv->io, header.comp_size);
if (!io)
goto out;
@@ -333,6 +334,15 @@ static GP_Context *zip_next_file(struct zip_priv *priv,
if (errno == ECANCELED)
err = errno;
+ /*
+ * We need to finish the Zlib IO for any of:
+ *
+ * - File is not image -> need to get to the end of the record
+ * - All image data were not consumed by loader (may happen)
+ */
+ if (GP_IOSeek(io, 0, GP_IO_SEEK_END) == (off_t)-1)
+ GP_DEBUG(1, "Failed to seek Zlib IO");
+
GP_IOClose(io);
if (header.flags & FLAG_DATA_DESC_HEADER) {
http://repo.or.cz/w/gfxprim.git/commit/004c0cb918280c3a03cd9f1b3b1e5d27476d…
commit 004c0cb918280c3a03cd9f1b3b1e5d27476defcb
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sat Jun 14 01:12:30 2014 +0200
loaders; IOZlib: Add Seek to end with offset=0
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/libs/loaders/GP_IOZlib.c b/libs/loaders/GP_IOZlib.c
index f62c831e..21675d60 100644
--- a/libs/loaders/GP_IOZlib.c
+++ b/libs/loaders/GP_IOZlib.c
@@ -146,6 +146,20 @@ static int zlib_reset(struct priv *priv)
return 0;
}
+static off_t zlib_seek_end(GP_IO *io)
+{
+ struct priv *priv = GP_IO_PRIV(io);
+ char buf[BUFS];
+ int ret;
+
+ while ((ret = zlib_read(io, buf, sizeof(buf))) > 0);
+
+ if (ret < 0)
+ return (off_t)-1;
+
+ return priv->bytes_read;
+}
+
static off_t zlib_seek(GP_IO *io, off_t offset, enum GP_IOWhence whence)
{
struct priv *priv = GP_IO_PRIV(io);
@@ -175,6 +189,10 @@ static off_t zlib_seek(GP_IO *io, off_t offset, enum GP_IOWhence whence)
return 0;
}
+
+ if (whence == GP_IO_SEEK_END && offset == 0)
+ return zlib_seek_end(io);
+
out:
errno = ENOSYS;
return (off_t)-1;
http://repo.or.cz/w/gfxprim.git/commit/11ff1196e509567cea23f3bf71653f75c23a…
commit 11ff1196e509567cea23f3bf71653f75c23ac1e8
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sat Jun 14 00:07:18 2014 +0200
doc: Updates for python core and loaders.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/doc/core_python.txt b/doc/core_python.txt
index 6e488244..487b903c 100644
--- a/doc/core_python.txt
+++ b/doc/core_python.txt
@@ -3,12 +3,12 @@ Python Core module
The python binding maps mostly to the C API with the 'GP_' prefix stripped.
-Structures like 'GP_Context' are not created by the 'GP_ContextAlloc()'
+However structures as 'GP_Context' are not created by the 'GP_ContextAlloc()'
function but have proper constructor and destructor to keep the Python
reference counting happy.
-There there are more complicated problems like 'GP_ProgressCallback' which
-needs a proxy function to call the python callback from the C code.
+Then there are a bit more tricky solutions, such as 'GP_ProgressCallback'
+which needs a proxy function to call the python callback from the C code.
Context
~~~~~~~
@@ -29,7 +29,13 @@ Creates a context of a particular size and pixel type.
First two parameters are 'width' and 'height' third is pixel type which is an
enumeration
-May raise 'OSError' with 'ENOMEM' errno if allocation has failed.
+|===============================================================================
+| May raise 'OSError' with errno set to 'ENOMEM' if allocation has failed.
+
+| May raise 'OSError' with errno set to 'EINVAL' for invalid pixel type and/or
+ zero width or height.
+
+|===============================================================================
[source,python]
-------------------------------------------------------------------------------
@@ -88,18 +94,18 @@ import gfxprim.core as core
Copy a rectangle from self to target.
-The blits can do simple conversions same as the 'Convert' functions however
-such blits are slower.
+The blits can do naive conversions (same as 'Convert') however such blits are
+a bit slower.
Blit is clipped.
-TIP: See link:example_py_showimage.html[example] Blit usage.
+TIP: See link:example_py_showimage.html[example Blit usage].
[[Colors_and_Pixels]]
Colors and Pixels
~~~~~~~~~~~~~~~~~
-Pixel in gfxprim is a number large enough to store a pixel value. Pixel is
+Pixel in GFXprim is a number large enough to store a pixel value. Pixel is
passed as a parameter to all drawing functions.
Color is a more abstract representation for example RGB triplet.
@@ -139,9 +145,12 @@ The PixelTypes array stores all supported pixel types
Progress Callback
~~~~~~~~~~~~~~~~~
-Progress callback is a last parameter of link:loaders_python.html[loaders] and
-link:filters_python.html[filters]. It can be either a python function or a
-touple with a function at the first position.
+Progress callback is the last parameter of link:loaders_python.html[loaders]
+and link:filters_python.html[filters]. It can be either a python function or a
+touple with a function at first position. In the latter case the second touple
+element is passed to the callback function as a second parameter. First
+parameter of the callback is a floating point number with the current progress
+in percents.
Progress callback must return an integer number. Returning non-zero will abort
the operation and the function, called with the callback as a parameter, will
@@ -164,8 +173,5 @@ import gfxprim.core as core
Sets and gets the GFXprim debug level. See link:debug.html[debug messages]
description for more details.
-
-
-
These are basic 'Context' methods from core module. Importing other modules
will add some other (for example gfx module adds all drawing functions).
diff --git a/doc/loaders_python.txt b/doc/loaders_python.txt
index a73d1f0e..5f230841 100644
--- a/doc/loaders_python.txt
+++ b/doc/loaders_python.txt
@@ -31,7 +31,7 @@ Loads an image from a file.
First one is general purpose loader function that automatically detects the
file format. The format is detected from file extension first and if this
-fails files signature is used.
+fails link:signatures.html[file signature] is used.
|===============================================================================
| May raise 'OSError' with errno set to 'EPERM', 'EISDIR', 'ENOENT' or any other
-----------------------------------------------------------------------
Summary of changes:
doc/core_python.txt | 34 ++++++++++++++++++++--------------
doc/loaders_python.txt | 2 +-
libs/loaders/GP_IOZlib.c | 18 ++++++++++++++++++
libs/loaders/GP_ZIP.c | 10 ++++++++++
4 files changed, 49 insertions(+), 15 deletions(-)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project gfxprim.git.
The branch, master has been updated
via 14a68f948a63033de7c8d8dcf12978edb29b5fa2 (commit)
from 069262b67e2bd246c98f76a4f9ddbbf9bf3c992f (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://repo.or.cz/w/gfxprim.git/commit/14a68f948a63033de7c8d8dcf12978edb29b…
commit 14a68f948a63033de7c8d8dcf12978edb29b5fa2
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri Jun 13 11:40:39 2014 +0200
build: Fix Debian build, core should link with -lrt
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/build/Makefile b/build/Makefile
index 3053edfa..5f88872b 100644
--- a/build/Makefile
+++ b/build/Makefile
@@ -37,10 +37,10 @@ endif
$(DYNAMIC_LIB): $(LIB_OBJECTS)
ifdef VERBOSE
- $(CC) -fPIC -dPIC --shared -Wl,-soname -Wl,$(SONAME) $^ -lm $(LDLIBS_core) -o $@
+ $(CC) -fPIC -dPIC --shared -Wl,-soname -Wl,$(SONAME) $^ -lm -lrt $(LDLIBS_core) -o $@
else
@echo "LD $@"
- @$(CC) -fPIC -dPIC --shared -Wl,-soname -Wl,$(SONAME) $^ -lm $(LDLIBS_core) -o $@
+ @$(CC) -fPIC -dPIC --shared -Wl,-soname -Wl,$(SONAME) $^ -lm -lrt $(LDLIBS_core) -o $@
endif
$(SYMLINKS): $(DYNAMIC_LIB)
-----------------------------------------------------------------------
Summary of changes:
build/Makefile | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")