You've already forked pgbackrest
mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2025-07-17 01:12:23 +02:00
Implement filters that do not modify the buffer.
Update cryptoHash to use the new interface.
This commit is contained in:
@ -48,7 +48,7 @@
|
||||
</release-item>
|
||||
|
||||
<release-item>
|
||||
<p>Abstract IO layer out of the storage layer. This allows the routines to be used for IO objects that do not have a storage representation. Implement buffer read and write IO objects.</p>
|
||||
<p>Abstract IO layer out of the storage layer. This allows the routines to be used for IO objects that do not have a storage representation. Implement buffer read and write IO objects. Implement filters that do not modify the buffer and update <code>cryptoHash</code> to use the new interface.</p>
|
||||
</release-item>
|
||||
|
||||
<release-item>
|
||||
|
@ -49,6 +49,9 @@ my @stryCFile =
|
||||
'common/error.c',
|
||||
'common/ini.c',
|
||||
'common/io/bufferRead.c',
|
||||
'common/io/bufferWrite.c',
|
||||
'common/io/filter/filter.c',
|
||||
'common/io/filter/group.c',
|
||||
'common/io/handle.c',
|
||||
'common/io/io.c',
|
||||
'common/io/read.c',
|
||||
|
47
src/Makefile
47
src/Makefile
@ -66,6 +66,9 @@ SRCS = \
|
||||
common/exit.c \
|
||||
common/fork.c \
|
||||
common/io/bufferRead.c \
|
||||
common/io/bufferWrite.c \
|
||||
common/io/filter/filter.c \
|
||||
common/io/filter/group.c \
|
||||
common/io/handle.c \
|
||||
common/io/io.c \
|
||||
common/io/read.c \
|
||||
@ -127,13 +130,13 @@ install: pgbackrest
|
||||
####################################################################################################################################
|
||||
# Compile rules
|
||||
####################################################################################################################################
|
||||
command/archive/common.o: command/archive/common.c command/archive/common.h common/assert.h common/debug.h common/error.auto.h common/error.h common/io/read.h common/io/write.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/keyValue.h common/type/string.h common/type/stringList.h common/type/variant.h common/type/variantList.h common/wait.h postgres/version.h storage/driver/posix/driverRead.h storage/driver/posix/driverWrite.h storage/fileRead.h storage/fileWrite.h storage/helper.h storage/info.h storage/storage.h version.h
|
||||
command/archive/common.o: command/archive/common.c command/archive/common.h common/assert.h common/debug.h common/error.auto.h common/error.h common/io/filter/filter.h common/io/filter/group.h common/io/read.h common/io/write.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/keyValue.h common/type/string.h common/type/stringList.h common/type/variant.h common/type/variantList.h common/wait.h postgres/version.h storage/driver/posix/driverRead.h storage/driver/posix/driverWrite.h storage/fileRead.h storage/fileWrite.h storage/helper.h storage/info.h storage/storage.h version.h
|
||||
$(CC) $(CFLAGS) -c command/archive/common.c -o command/archive/common.o
|
||||
|
||||
command/archive/get/get.o: command/archive/get/get.c command/archive/common.h command/command.h common/assert.h common/debug.h common/error.auto.h common/error.h common/fork.h common/io/read.h common/io/write.h common/lock.h common/log.h common/logLevel.h common/memContext.h common/regExp.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/keyValue.h common/type/string.h common/type/stringList.h common/type/variant.h common/type/variantList.h common/wait.h config/config.auto.h config/config.h config/define.auto.h config/define.h config/load.h perl/exec.h postgres/info.h storage/driver/posix/driverRead.h storage/driver/posix/driverWrite.h storage/fileRead.h storage/fileWrite.h storage/helper.h storage/info.h storage/storage.h version.h
|
||||
command/archive/get/get.o: command/archive/get/get.c command/archive/common.h command/command.h common/assert.h common/debug.h common/error.auto.h common/error.h common/fork.h common/io/filter/filter.h common/io/filter/group.h common/io/read.h common/io/write.h common/lock.h common/log.h common/logLevel.h common/memContext.h common/regExp.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/keyValue.h common/type/string.h common/type/stringList.h common/type/variant.h common/type/variantList.h common/wait.h config/config.auto.h config/config.h config/define.auto.h config/define.h config/load.h perl/exec.h postgres/info.h storage/driver/posix/driverRead.h storage/driver/posix/driverWrite.h storage/fileRead.h storage/fileWrite.h storage/helper.h storage/info.h storage/storage.h version.h
|
||||
$(CC) $(CFLAGS) -c command/archive/get/get.c -o command/archive/get/get.o
|
||||
|
||||
command/archive/push/push.o: command/archive/push/push.c command/archive/common.h command/command.h common/debug.h common/error.auto.h common/error.h common/fork.h common/io/read.h common/io/write.h common/lock.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/keyValue.h common/type/string.h common/type/stringList.h common/type/variant.h common/type/variantList.h common/wait.h config/config.auto.h config/config.h config/define.auto.h config/define.h config/load.h perl/exec.h storage/driver/posix/driverRead.h storage/driver/posix/driverWrite.h storage/fileRead.h storage/fileWrite.h storage/helper.h storage/info.h storage/storage.h version.h
|
||||
command/archive/push/push.o: command/archive/push/push.c command/archive/common.h command/command.h common/debug.h common/error.auto.h common/error.h common/fork.h common/io/filter/filter.h common/io/filter/group.h common/io/read.h common/io/write.h common/lock.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/keyValue.h common/type/string.h common/type/stringList.h common/type/variant.h common/type/variantList.h common/wait.h config/config.auto.h config/config.h config/define.auto.h config/define.h config/load.h perl/exec.h storage/driver/posix/driverRead.h storage/driver/posix/driverWrite.h storage/fileRead.h storage/fileWrite.h storage/helper.h storage/info.h storage/storage.h version.h
|
||||
$(CC) $(CFLAGS) -c command/archive/push/push.c -o command/archive/push/push.o
|
||||
|
||||
command/command.o: command/command.c common/assert.h common/debug.h common/error.auto.h common/error.h common/lock.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/time.h common/type/buffer.h common/type/convert.h common/type/keyValue.h common/type/string.h common/type/stringList.h common/type/variant.h common/type/variantList.h config/config.auto.h config/config.h config/define.auto.h config/define.h version.h
|
||||
@ -160,28 +163,34 @@ common/exit.o: common/exit.c command/command.h common/debug.h common/error.auto.
|
||||
common/fork.o: common/fork.c common/debug.h common/error.auto.h common/error.h common/log.h common/logLevel.h common/stackTrace.h common/type/convert.h
|
||||
$(CC) $(CFLAGS) -c common/fork.c -o common/fork.o
|
||||
|
||||
common/ini.o: common/ini.c common/debug.h common/error.auto.h common/error.h common/ini.h common/io/read.h common/io/write.h common/logLevel.h common/memContext.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/keyValue.h common/type/string.h common/type/stringList.h common/type/variant.h common/type/variantList.h storage/driver/posix/driverRead.h storage/driver/posix/driverWrite.h storage/fileRead.h storage/fileWrite.h storage/helper.h storage/info.h storage/storage.h version.h
|
||||
common/ini.o: common/ini.c common/debug.h common/error.auto.h common/error.h common/ini.h common/io/filter/filter.h common/io/filter/group.h common/io/read.h common/io/write.h common/logLevel.h common/memContext.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/keyValue.h common/type/string.h common/type/stringList.h common/type/variant.h common/type/variantList.h storage/driver/posix/driverRead.h storage/driver/posix/driverWrite.h storage/fileRead.h storage/fileWrite.h storage/helper.h storage/info.h storage/storage.h version.h
|
||||
$(CC) $(CFLAGS) -c common/ini.c -o common/ini.o
|
||||
|
||||
common/io/bufferRead.o: common/io/bufferRead.c common/assert.h common/debug.h common/error.auto.h common/error.h common/io/bufferRead.h common/io/read.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/string.h
|
||||
common/io/bufferRead.o: common/io/bufferRead.c common/assert.h common/debug.h common/error.auto.h common/error.h common/io/bufferRead.h common/io/filter/filter.h common/io/filter/group.h common/io/read.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/keyValue.h common/type/string.h common/type/variant.h common/type/variantList.h
|
||||
$(CC) $(CFLAGS) -c common/io/bufferRead.c -o common/io/bufferRead.o
|
||||
|
||||
common/io/bufferWrite.o: common/io/bufferWrite.c common/assert.h common/debug.h common/error.auto.h common/error.h common/io/bufferWrite.h common/io/write.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/string.h
|
||||
common/io/bufferWrite.o: common/io/bufferWrite.c common/assert.h common/debug.h common/error.auto.h common/error.h common/io/bufferWrite.h common/io/filter/filter.h common/io/filter/group.h common/io/write.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/keyValue.h common/type/string.h common/type/variant.h common/type/variantList.h
|
||||
$(CC) $(CFLAGS) -c common/io/bufferWrite.c -o common/io/bufferWrite.o
|
||||
|
||||
common/io/filter/filter.o: common/io/filter/filter.c common/assert.h common/debug.h common/error.auto.h common/error.h common/io/filter/filter.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/keyValue.h common/type/string.h common/type/variant.h common/type/variantList.h
|
||||
$(CC) $(CFLAGS) -c common/io/filter/filter.c -o common/io/filter/filter.o
|
||||
|
||||
common/io/filter/group.o: common/io/filter/group.c common/assert.h common/debug.h common/error.auto.h common/error.h common/io/filter/filter.h common/io/filter/group.h common/io/io.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/keyValue.h common/type/list.h common/type/string.h common/type/variant.h common/type/variantList.h
|
||||
$(CC) $(CFLAGS) -c common/io/filter/group.c -o common/io/filter/group.o
|
||||
|
||||
common/io/handle.o: common/io/handle.c common/debug.h common/error.auto.h common/error.h common/io/handle.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/string.h
|
||||
$(CC) $(CFLAGS) -c common/io/handle.c -o common/io/handle.o
|
||||
|
||||
common/io/io.o: common/io/io.c common/assert.h common/debug.h common/error.auto.h common/error.h common/io/io.h common/log.h common/logLevel.h common/stackTrace.h common/type/convert.h
|
||||
$(CC) $(CFLAGS) -c common/io/io.c -o common/io/io.o
|
||||
|
||||
common/io/read.o: common/io/read.c common/debug.h common/error.auto.h common/error.h common/io/read.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/string.h
|
||||
common/io/read.o: common/io/read.c common/debug.h common/error.auto.h common/error.h common/io/filter/filter.h common/io/filter/group.h common/io/io.h common/io/read.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/keyValue.h common/type/string.h common/type/variant.h common/type/variantList.h
|
||||
$(CC) $(CFLAGS) -c common/io/read.c -o common/io/read.o
|
||||
|
||||
common/io/write.o: common/io/write.c common/debug.h common/error.auto.h common/error.h common/io/write.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/string.h
|
||||
common/io/write.o: common/io/write.c common/debug.h common/error.auto.h common/error.h common/io/filter/filter.h common/io/filter/group.h common/io/write.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/keyValue.h common/type/string.h common/type/variant.h common/type/variantList.h
|
||||
$(CC) $(CFLAGS) -c common/io/write.c -o common/io/write.o
|
||||
|
||||
common/lock.o: common/lock.c common/assert.h common/debug.h common/error.auto.h common/error.h common/io/handle.h common/io/read.h common/io/write.h common/lock.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/keyValue.h common/type/string.h common/type/stringList.h common/type/variant.h common/type/variantList.h common/wait.h storage/driver/posix/driverRead.h storage/driver/posix/driverWrite.h storage/fileRead.h storage/fileWrite.h storage/helper.h storage/info.h storage/storage.h version.h
|
||||
common/lock.o: common/lock.c common/assert.h common/debug.h common/error.auto.h common/error.h common/io/filter/filter.h common/io/filter/group.h common/io/handle.h common/io/read.h common/io/write.h common/lock.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/keyValue.h common/type/string.h common/type/stringList.h common/type/variant.h common/type/variantList.h common/wait.h storage/driver/posix/driverRead.h storage/driver/posix/driverWrite.h storage/fileRead.h storage/fileWrite.h storage/helper.h storage/info.h storage/storage.h version.h
|
||||
$(CC) $(CFLAGS) -c common/lock.c -o common/lock.o
|
||||
|
||||
common/log.o: common/log.c common/assert.h common/debug.h common/error.auto.h common/error.h common/log.h common/logLevel.h common/stackTrace.h common/time.h common/type/convert.h
|
||||
@ -235,7 +244,7 @@ config/define.o: config/define.c common/assert.h common/debug.h common/error.aut
|
||||
config/load.o: config/load.c command/command.h common/debug.h common/error.auto.h common/error.h common/io/io.h common/lock.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/keyValue.h common/type/string.h common/type/stringList.h common/type/variant.h common/type/variantList.h config/config.auto.h config/config.h config/define.auto.h config/define.h config/load.h config/parse.h
|
||||
$(CC) $(CFLAGS) -c config/load.c -o config/load.o
|
||||
|
||||
config/parse.o: config/parse.c common/assert.h common/debug.h common/error.auto.h common/error.h common/ini.h common/io/read.h common/io/write.h common/lock.h common/log.h common/logLevel.h common/memContext.h common/regExp.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/keyValue.h common/type/string.h common/type/stringList.h common/type/variant.h common/type/variantList.h config/config.auto.h config/config.h config/define.auto.h config/define.h config/parse.auto.c config/parse.h storage/driver/posix/driverRead.h storage/driver/posix/driverWrite.h storage/fileRead.h storage/fileWrite.h storage/helper.h storage/info.h storage/storage.h version.h
|
||||
config/parse.o: config/parse.c common/assert.h common/debug.h common/error.auto.h common/error.h common/ini.h common/io/filter/filter.h common/io/filter/group.h common/io/read.h common/io/write.h common/lock.h common/log.h common/logLevel.h common/memContext.h common/regExp.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/keyValue.h common/type/string.h common/type/stringList.h common/type/variant.h common/type/variantList.h config/config.auto.h config/config.h config/define.auto.h config/define.h config/parse.auto.c config/parse.h storage/driver/posix/driverRead.h storage/driver/posix/driverWrite.h storage/fileRead.h storage/fileWrite.h storage/helper.h storage/info.h storage/storage.h version.h
|
||||
$(CC) $(CFLAGS) -c config/parse.c -o config/parse.o
|
||||
|
||||
crypto/cipherBlock.o: crypto/cipherBlock.c common/debug.h common/error.auto.h common/error.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/type/convert.h crypto/cipher.h crypto/cipherBlock.h crypto/crypto.h crypto/random.h
|
||||
@ -244,7 +253,7 @@ crypto/cipherBlock.o: crypto/cipherBlock.c common/debug.h common/error.auto.h co
|
||||
crypto/crypto.o: crypto/crypto.c common/debug.h common/log.h common/logLevel.h common/stackTrace.h common/type/convert.h crypto/crypto.h
|
||||
$(CC) $(CFLAGS) -c crypto/crypto.c -o crypto/crypto.o
|
||||
|
||||
crypto/hash.o: crypto/hash.c common/debug.h common/error.auto.h common/error.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/string.h crypto/crypto.h crypto/hash.h
|
||||
crypto/hash.o: crypto/hash.c common/debug.h common/error.auto.h common/error.h common/io/filter/filter.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/keyValue.h common/type/string.h common/type/variant.h common/type/variantList.h crypto/crypto.h crypto/hash.h
|
||||
$(CC) $(CFLAGS) -c crypto/hash.c -o crypto/hash.o
|
||||
|
||||
crypto/random.o: crypto/random.c common/debug.h common/error.auto.h common/error.h common/log.h common/logLevel.h common/stackTrace.h common/type/convert.h crypto/random.h
|
||||
@ -256,16 +265,16 @@ main.o: main.c command/archive/get/get.h command/archive/push/push.h command/com
|
||||
perl/config.o: perl/config.c common/debug.h common/error.auto.h common/error.h common/lock.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/keyValue.h common/type/string.h common/type/stringList.h common/type/variant.h common/type/variantList.h config/config.auto.h config/config.h config/define.auto.h config/define.h
|
||||
$(CC) $(CFLAGS) -c perl/config.c -o perl/config.o
|
||||
|
||||
perl/exec.o: perl/exec.c ../libc/LibC.h common/debug.h common/encode.h common/error.auto.h common/error.h common/lock.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/keyValue.h common/type/string.h common/type/stringList.h common/type/variant.h common/type/variantList.h config/config.auto.h config/config.h config/define.auto.h config/define.h config/load.h config/parse.h crypto/cipher.h crypto/cipherBlock.h crypto/hash.h crypto/random.h perl/config.h perl/embed.auto.c perl/exec.h perl/libc.auto.c postgres/pageChecksum.h storage/driver/posix/driver.h storage/driver/posix/driverRead.h storage/driver/posix/driverWrite.h storage/info.h version.h ../libc/xs/common/encode.xsh ../libc/xs/crypto/cipherBlock.xsh ../libc/xs/crypto/hash.xsh
|
||||
perl/exec.o: perl/exec.c ../libc/LibC.h common/debug.h common/encode.h common/error.auto.h common/error.h common/io/filter/filter.h common/lock.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/keyValue.h common/type/string.h common/type/stringList.h common/type/variant.h common/type/variantList.h config/config.auto.h config/config.h config/define.auto.h config/define.h config/load.h config/parse.h crypto/cipher.h crypto/cipherBlock.h crypto/hash.h crypto/random.h perl/config.h perl/embed.auto.c perl/exec.h perl/libc.auto.c postgres/pageChecksum.h storage/driver/posix/driver.h storage/driver/posix/driverRead.h storage/driver/posix/driverWrite.h storage/info.h version.h ../libc/xs/common/encode.xsh ../libc/xs/crypto/cipherBlock.xsh ../libc/xs/crypto/hash.xsh
|
||||
$(CC) $(CFLAGS) -c perl/exec.c -o perl/exec.o
|
||||
|
||||
postgres/info.o: postgres/info.c common/debug.h common/error.auto.h common/error.h common/io/read.h common/io/write.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/keyValue.h common/type/string.h common/type/stringList.h common/type/variant.h common/type/variantList.h postgres/info.h postgres/type.h postgres/version.h storage/driver/posix/driverRead.h storage/driver/posix/driverWrite.h storage/fileRead.h storage/fileWrite.h storage/helper.h storage/info.h storage/storage.h version.h
|
||||
postgres/info.o: postgres/info.c common/debug.h common/error.auto.h common/error.h common/io/filter/filter.h common/io/filter/group.h common/io/read.h common/io/write.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/keyValue.h common/type/string.h common/type/stringList.h common/type/variant.h common/type/variantList.h postgres/info.h postgres/type.h postgres/version.h storage/driver/posix/driverRead.h storage/driver/posix/driverWrite.h storage/fileRead.h storage/fileWrite.h storage/helper.h storage/info.h storage/storage.h version.h
|
||||
$(CC) $(CFLAGS) -c postgres/info.c -o postgres/info.o
|
||||
|
||||
postgres/pageChecksum.o: postgres/pageChecksum.c common/assert.h common/debug.h common/error.auto.h common/error.h common/log.h common/logLevel.h common/stackTrace.h common/type/convert.h postgres/pageChecksum.h postgres/type.h
|
||||
$(CC) $(CFLAGS) -funroll-loops -ftree-vectorize -c postgres/pageChecksum.c -o postgres/pageChecksum.o
|
||||
|
||||
storage/driver/posix/driver.o: storage/driver/posix/driver.c common/debug.h common/error.auto.h common/error.h common/io/read.h common/io/write.h common/log.h common/logLevel.h common/memContext.h common/regExp.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/keyValue.h common/type/string.h common/type/stringList.h common/type/variant.h common/type/variantList.h storage/driver/posix/driver.h storage/driver/posix/driverFile.h storage/driver/posix/driverRead.h storage/driver/posix/driverWrite.h storage/fileRead.h storage/fileWrite.h storage/info.h storage/storage.h version.h
|
||||
storage/driver/posix/driver.o: storage/driver/posix/driver.c common/debug.h common/error.auto.h common/error.h common/io/filter/filter.h common/io/filter/group.h common/io/read.h common/io/write.h common/log.h common/logLevel.h common/memContext.h common/regExp.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/keyValue.h common/type/string.h common/type/stringList.h common/type/variant.h common/type/variantList.h storage/driver/posix/driver.h storage/driver/posix/driverFile.h storage/driver/posix/driverRead.h storage/driver/posix/driverWrite.h storage/fileRead.h storage/fileWrite.h storage/info.h storage/storage.h version.h
|
||||
$(CC) $(CFLAGS) -c storage/driver/posix/driver.c -o storage/driver/posix/driver.o
|
||||
|
||||
storage/driver/posix/driverFile.o: storage/driver/posix/driverFile.c common/assert.h common/debug.h common/error.auto.h common/error.h common/logLevel.h common/memContext.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/string.h storage/driver/posix/driverFile.h
|
||||
@ -274,17 +283,17 @@ storage/driver/posix/driverFile.o: storage/driver/posix/driverFile.c common/asse
|
||||
storage/driver/posix/driverRead.o: storage/driver/posix/driverRead.c common/assert.h common/debug.h common/error.auto.h common/error.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/string.h storage/driver/posix/driverFile.h storage/driver/posix/driverRead.h
|
||||
$(CC) $(CFLAGS) -c storage/driver/posix/driverRead.c -o storage/driver/posix/driverRead.o
|
||||
|
||||
storage/driver/posix/driverWrite.o: storage/driver/posix/driverWrite.c common/assert.h common/debug.h common/error.auto.h common/error.h common/io/write.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/keyValue.h common/type/string.h common/type/stringList.h common/type/variant.h common/type/variantList.h storage/driver/posix/driver.h storage/driver/posix/driverFile.h storage/driver/posix/driverRead.h storage/driver/posix/driverWrite.h storage/fileWrite.h storage/info.h version.h
|
||||
storage/driver/posix/driverWrite.o: storage/driver/posix/driverWrite.c common/assert.h common/debug.h common/error.auto.h common/error.h common/io/filter/filter.h common/io/filter/group.h common/io/write.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/keyValue.h common/type/string.h common/type/stringList.h common/type/variant.h common/type/variantList.h storage/driver/posix/driver.h storage/driver/posix/driverFile.h storage/driver/posix/driverRead.h storage/driver/posix/driverWrite.h storage/fileWrite.h storage/info.h version.h
|
||||
$(CC) $(CFLAGS) -c storage/driver/posix/driverWrite.c -o storage/driver/posix/driverWrite.o
|
||||
|
||||
storage/fileRead.o: storage/fileRead.c common/assert.h common/debug.h common/error.auto.h common/error.h common/io/read.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/string.h storage/driver/posix/driverRead.h storage/fileRead.h
|
||||
storage/fileRead.o: storage/fileRead.c common/assert.h common/debug.h common/error.auto.h common/error.h common/io/filter/filter.h common/io/filter/group.h common/io/read.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/keyValue.h common/type/string.h common/type/variant.h common/type/variantList.h storage/driver/posix/driverRead.h storage/fileRead.h
|
||||
$(CC) $(CFLAGS) -c storage/fileRead.c -o storage/fileRead.o
|
||||
|
||||
storage/fileWrite.o: storage/fileWrite.c common/assert.h common/debug.h common/error.auto.h common/error.h common/io/write.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/string.h storage/driver/posix/driverWrite.h storage/fileWrite.h version.h
|
||||
storage/fileWrite.o: storage/fileWrite.c common/assert.h common/debug.h common/error.auto.h common/error.h common/io/filter/filter.h common/io/filter/group.h common/io/write.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/keyValue.h common/type/string.h common/type/variant.h common/type/variantList.h storage/driver/posix/driverWrite.h storage/fileWrite.h version.h
|
||||
$(CC) $(CFLAGS) -c storage/fileWrite.c -o storage/fileWrite.o
|
||||
|
||||
storage/helper.o: storage/helper.c common/debug.h common/error.auto.h common/error.h common/io/read.h common/io/write.h common/lock.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/keyValue.h common/type/string.h common/type/stringList.h common/type/variant.h common/type/variantList.h config/config.auto.h config/config.h config/define.auto.h config/define.h storage/driver/posix/driverRead.h storage/driver/posix/driverWrite.h storage/fileRead.h storage/fileWrite.h storage/helper.h storage/info.h storage/storage.h version.h
|
||||
storage/helper.o: storage/helper.c common/debug.h common/error.auto.h common/error.h common/io/filter/filter.h common/io/filter/group.h common/io/read.h common/io/write.h common/lock.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/keyValue.h common/type/string.h common/type/stringList.h common/type/variant.h common/type/variantList.h config/config.auto.h config/config.h config/define.auto.h config/define.h storage/driver/posix/driverRead.h storage/driver/posix/driverWrite.h storage/fileRead.h storage/fileWrite.h storage/helper.h storage/info.h storage/storage.h version.h
|
||||
$(CC) $(CFLAGS) -c storage/helper.c -o storage/helper.o
|
||||
|
||||
storage/storage.o: storage/storage.c common/assert.h common/debug.h common/error.auto.h common/error.h common/io/io.h common/io/read.h common/io/write.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/keyValue.h common/type/string.h common/type/stringList.h common/type/variant.h common/type/variantList.h common/wait.h storage/driver/posix/driver.h storage/driver/posix/driverRead.h storage/driver/posix/driverWrite.h storage/fileRead.h storage/fileWrite.h storage/info.h storage/storage.h version.h
|
||||
storage/storage.o: storage/storage.c common/assert.h common/debug.h common/error.auto.h common/error.h common/io/filter/filter.h common/io/filter/group.h common/io/io.h common/io/read.h common/io/write.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/keyValue.h common/type/string.h common/type/stringList.h common/type/variant.h common/type/variantList.h common/wait.h storage/driver/posix/driver.h storage/driver/posix/driverRead.h storage/driver/posix/driverWrite.h storage/fileRead.h storage/fileWrite.h storage/info.h storage/storage.h version.h
|
||||
$(CC) $(CFLAGS) -c storage/storage.c -o storage/storage.o
|
||||
|
117
src/common/io/filter/filter.c
Normal file
117
src/common/io/filter/filter.c
Normal file
@ -0,0 +1,117 @@
|
||||
/***********************************************************************************************************************************
|
||||
IO Filter
|
||||
***********************************************************************************************************************************/
|
||||
#include "common/assert.h"
|
||||
#include "common/debug.h"
|
||||
#include "common/io/filter/filter.h"
|
||||
#include "common/log.h"
|
||||
#include "common/memContext.h"
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Filter structure
|
||||
***********************************************************************************************************************************/
|
||||
struct IoFilter
|
||||
{
|
||||
MemContext *memContext; // Mem context of filter
|
||||
const String *type; // Filter type
|
||||
void *data; // Filter data
|
||||
IoFilterProcessIn processIn; // Process in function
|
||||
IoFilterResult result; // Result function
|
||||
};
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Create a new filter
|
||||
|
||||
Allocations will be in the memory context of the caller.
|
||||
***********************************************************************************************************************************/
|
||||
IoFilter *
|
||||
ioFilterNew(const String *type, void *data, IoFilterProcessIn processIn, IoFilterResult result)
|
||||
{
|
||||
FUNCTION_DEBUG_BEGIN(logLevelTrace);
|
||||
FUNCTION_DEBUG_PARAM(STRING, type);
|
||||
FUNCTION_DEBUG_PARAM(VOIDP, data);
|
||||
FUNCTION_DEBUG_PARAM(FUNCTIONP, processIn);
|
||||
FUNCTION_DEBUG_PARAM(FUNCTIONP, result);
|
||||
|
||||
FUNCTION_DEBUG_ASSERT(type != NULL);
|
||||
FUNCTION_DEBUG_ASSERT(data != NULL);
|
||||
FUNCTION_DEBUG_ASSERT(processIn != NULL);
|
||||
FUNCTION_DEBUG_ASSERT(result != NULL);
|
||||
FUNCTION_DEBUG_END();
|
||||
|
||||
IoFilter *this = memNew(sizeof(IoFilter));
|
||||
this->memContext = memContextCurrent();
|
||||
this->type = type;
|
||||
this->data = data;
|
||||
this->processIn = processIn;
|
||||
this->result = result;
|
||||
|
||||
FUNCTION_DEBUG_RESULT(IO_FILTER, this);
|
||||
}
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Filter input only (a result is expected)
|
||||
***********************************************************************************************************************************/
|
||||
void
|
||||
ioFilterProcessIn(IoFilter *this, const Buffer *input)
|
||||
{
|
||||
FUNCTION_TEST_BEGIN();
|
||||
FUNCTION_TEST_PARAM(IO_FILTER, this);
|
||||
FUNCTION_TEST_PARAM(BUFFER, input);
|
||||
|
||||
FUNCTION_TEST_ASSERT(this != NULL);
|
||||
FUNCTION_TEST_END();
|
||||
|
||||
this->processIn(this->data, input);
|
||||
|
||||
FUNCTION_TEST_RESULT_VOID();
|
||||
}
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Close the filter and return any results
|
||||
***********************************************************************************************************************************/
|
||||
const Variant *
|
||||
ioFilterResult(IoFilter *this)
|
||||
{
|
||||
FUNCTION_TEST_BEGIN();
|
||||
FUNCTION_TEST_PARAM(IO_FILTER, this);
|
||||
|
||||
FUNCTION_TEST_ASSERT(this != NULL);
|
||||
FUNCTION_TEST_END();
|
||||
|
||||
FUNCTION_TEST_RESULT(VARIANT, this->result ? this->result(this->data) : NULL);
|
||||
}
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Move the file object to a new context
|
||||
***********************************************************************************************************************************/
|
||||
IoFilter *
|
||||
ioFilterMove(IoFilter *this, MemContext *parentNew)
|
||||
{
|
||||
FUNCTION_TEST_BEGIN();
|
||||
FUNCTION_TEST_PARAM(IO_FILTER, this);
|
||||
FUNCTION_TEST_PARAM(MEM_CONTEXT, parentNew);
|
||||
|
||||
FUNCTION_TEST_ASSERT(parentNew != NULL);
|
||||
FUNCTION_TEST_END();
|
||||
|
||||
if (this != NULL)
|
||||
memContextMove(this->memContext, parentNew);
|
||||
|
||||
FUNCTION_TEST_RESULT(IO_FILTER, this);
|
||||
}
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Get filter type
|
||||
***********************************************************************************************************************************/
|
||||
const String *
|
||||
ioFilterType(IoFilter *this)
|
||||
{
|
||||
FUNCTION_TEST_BEGIN();
|
||||
FUNCTION_TEST_PARAM(IO_FILTER, this);
|
||||
|
||||
FUNCTION_TEST_ASSERT(this != NULL);
|
||||
FUNCTION_TEST_END();
|
||||
|
||||
FUNCTION_TEST_RESULT(CONST_STRING, this->type);
|
||||
}
|
46
src/common/io/filter/filter.h
Normal file
46
src/common/io/filter/filter.h
Normal file
@ -0,0 +1,46 @@
|
||||
/***********************************************************************************************************************************
|
||||
IO Filter
|
||||
***********************************************************************************************************************************/
|
||||
#ifndef IO_FILTER_FILTER_H
|
||||
#define IO_FILTER_FILTER_H
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Storage file read object
|
||||
***********************************************************************************************************************************/
|
||||
typedef struct IoFilter IoFilter;
|
||||
|
||||
#include "common/type/string.h"
|
||||
#include "common/type/variant.h"
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Function pointer types
|
||||
***********************************************************************************************************************************/
|
||||
typedef void (*IoFilterProcessIn)(void *data, const Buffer *);
|
||||
typedef Variant *(*IoFilterResult)(void *data);
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Constructor
|
||||
***********************************************************************************************************************************/
|
||||
IoFilter *ioFilterNew(const String *type, void *data, IoFilterProcessIn processIn, IoFilterResult result);
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Functions
|
||||
***********************************************************************************************************************************/
|
||||
void ioFilterProcessIn(IoFilter *this, const Buffer *input);
|
||||
const Variant *ioFilterResult(IoFilter *this);
|
||||
IoFilter *ioFilterMove(IoFilter *this, MemContext *parentNew);
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Getters
|
||||
***********************************************************************************************************************************/
|
||||
const String *ioFilterType(IoFilter *this);
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Macros for function logging
|
||||
***********************************************************************************************************************************/
|
||||
#define FUNCTION_DEBUG_IO_FILTER_TYPE \
|
||||
IoFilter *
|
||||
#define FUNCTION_DEBUG_IO_FILTER_FORMAT(value, buffer, bufferSize) \
|
||||
objToLog(value, "IoFilter", buffer, bufferSize)
|
||||
|
||||
#endif
|
174
src/common/io/filter/group.c
Normal file
174
src/common/io/filter/group.c
Normal file
@ -0,0 +1,174 @@
|
||||
/***********************************************************************************************************************************
|
||||
Filter Group
|
||||
***********************************************************************************************************************************/
|
||||
#include "common/assert.h"
|
||||
#include "common/debug.h"
|
||||
#include "common/io/filter/group.h"
|
||||
#include "common/io/io.h"
|
||||
#include "common/log.h"
|
||||
#include "common/memContext.h"
|
||||
#include "common/type/list.h"
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Filter group structure
|
||||
***********************************************************************************************************************************/
|
||||
struct IoFilterGroup
|
||||
{
|
||||
MemContext *memContext; // Mem context
|
||||
List *filterList; // List of filters to apply to read buffer
|
||||
KeyValue *filterResult; // Filter results (if any)
|
||||
};
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Create new filter group
|
||||
***********************************************************************************************************************************/
|
||||
IoFilterGroup *
|
||||
ioFilterGroupNew()
|
||||
{
|
||||
FUNCTION_DEBUG_VOID(logLevelTrace);
|
||||
|
||||
IoFilterGroup *this = NULL;
|
||||
|
||||
MEM_CONTEXT_NEW_BEGIN("IoFilterGroup")
|
||||
{
|
||||
this = memNew(sizeof(IoFilterGroup));
|
||||
this->memContext = memContextCurrent();
|
||||
}
|
||||
MEM_CONTEXT_NEW_END();
|
||||
|
||||
FUNCTION_DEBUG_RESULT(IO_FILTER_GROUP, this);
|
||||
}
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Add a filter
|
||||
***********************************************************************************************************************************/
|
||||
void
|
||||
ioFilterGroupAdd(IoFilterGroup *this, IoFilter *filter)
|
||||
{
|
||||
FUNCTION_DEBUG_BEGIN(logLevelTrace);
|
||||
FUNCTION_DEBUG_PARAM(IO_FILTER_GROUP, this);
|
||||
FUNCTION_DEBUG_PARAM(IO_FILTER, filter);
|
||||
|
||||
FUNCTION_TEST_ASSERT(this != NULL);
|
||||
FUNCTION_TEST_ASSERT(filter != NULL);
|
||||
FUNCTION_DEBUG_END();
|
||||
|
||||
// Create the filter list if it has not been created
|
||||
if (this->filterList == NULL)
|
||||
{
|
||||
MEM_CONTEXT_BEGIN(this->memContext)
|
||||
{
|
||||
this->filterList = lstNew(sizeof(IoFilter *));
|
||||
}
|
||||
MEM_CONTEXT_END();
|
||||
}
|
||||
|
||||
// Move the filter to this object's mem context
|
||||
ioFilterMove(filter, this->memContext);
|
||||
|
||||
// Add the filter
|
||||
lstAdd(this->filterList, &filter);
|
||||
|
||||
FUNCTION_DEBUG_RESULT_VOID();
|
||||
}
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Process filters
|
||||
***********************************************************************************************************************************/
|
||||
void
|
||||
ioFilterGroupProcess(IoFilterGroup *this, const Buffer *input)
|
||||
{
|
||||
FUNCTION_DEBUG_BEGIN(logLevelTrace);
|
||||
FUNCTION_DEBUG_PARAM(IO_FILTER_GROUP, this);
|
||||
FUNCTION_DEBUG_PARAM(BUFFER, input);
|
||||
|
||||
FUNCTION_DEBUG_ASSERT(this != NULL);
|
||||
FUNCTION_DEBUG_ASSERT(input != NULL);
|
||||
FUNCTION_DEBUG_END();
|
||||
|
||||
for (unsigned int filterIdx = 0; filterIdx < lstSize(this->filterList); filterIdx++)
|
||||
ioFilterProcessIn(*(IoFilter **)lstGet(this->filterList, filterIdx), input);
|
||||
|
||||
FUNCTION_DEBUG_RESULT_VOID();
|
||||
}
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Close filter group
|
||||
***********************************************************************************************************************************/
|
||||
void
|
||||
ioFilterGroupClose(IoFilterGroup *this)
|
||||
{
|
||||
FUNCTION_DEBUG_BEGIN(logLevelTrace);
|
||||
FUNCTION_DEBUG_PARAM(IO_FILTER_GROUP, this);
|
||||
|
||||
FUNCTION_TEST_ASSERT(this != NULL);
|
||||
FUNCTION_DEBUG_END();
|
||||
|
||||
for (unsigned int filterIdx = 0; filterIdx < lstSize(this->filterList); filterIdx++)
|
||||
{
|
||||
IoFilter *filter = *(IoFilter **)lstGet(this->filterList, filterIdx);
|
||||
|
||||
const Variant *filterResult = ioFilterResult(filter);
|
||||
|
||||
if (this->filterResult == NULL)
|
||||
{
|
||||
MEM_CONTEXT_BEGIN(this->memContext)
|
||||
{
|
||||
this->filterResult = kvNew();
|
||||
}
|
||||
MEM_CONTEXT_END();
|
||||
}
|
||||
|
||||
MEM_CONTEXT_TEMP_BEGIN()
|
||||
{
|
||||
kvPut(this->filterResult, varNewStr(ioFilterType(filter)), filterResult);
|
||||
}
|
||||
MEM_CONTEXT_TEMP_END();
|
||||
}
|
||||
|
||||
FUNCTION_DEBUG_RESULT_VOID();
|
||||
}
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Get filter results
|
||||
***********************************************************************************************************************************/
|
||||
const Variant *
|
||||
ioFilterGroupResult(const IoFilterGroup *this, const String *filterType)
|
||||
{
|
||||
FUNCTION_TEST_BEGIN();
|
||||
FUNCTION_TEST_PARAM(IO_FILTER_GROUP, this);
|
||||
FUNCTION_TEST_PARAM(STRING, filterType);
|
||||
|
||||
FUNCTION_TEST_ASSERT(this != NULL);
|
||||
FUNCTION_TEST_ASSERT(filterType != NULL);
|
||||
FUNCTION_TEST_END();
|
||||
|
||||
const Variant *result = NULL;
|
||||
|
||||
if (this->filterResult != NULL)
|
||||
{
|
||||
MEM_CONTEXT_TEMP_BEGIN()
|
||||
{
|
||||
result = kvGet(this->filterResult, varNewStr(filterType));
|
||||
}
|
||||
MEM_CONTEXT_TEMP_END();
|
||||
}
|
||||
|
||||
FUNCTION_TEST_RESULT(CONST_VARIANT, result);
|
||||
}
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Free the filter group
|
||||
***********************************************************************************************************************************/
|
||||
void
|
||||
ioFilterGroupFree(IoFilterGroup *this)
|
||||
{
|
||||
FUNCTION_DEBUG_BEGIN(logLevelTrace);
|
||||
FUNCTION_DEBUG_PARAM(IO_FILTER_GROUP, this);
|
||||
FUNCTION_DEBUG_END();
|
||||
|
||||
if (this != NULL)
|
||||
memContextFree(this->memContext);
|
||||
|
||||
FUNCTION_DEBUG_RESULT_VOID();
|
||||
}
|
45
src/common/io/filter/group.h
Normal file
45
src/common/io/filter/group.h
Normal file
@ -0,0 +1,45 @@
|
||||
/***********************************************************************************************************************************
|
||||
Filter Group
|
||||
***********************************************************************************************************************************/
|
||||
#ifndef IO_FILTER_GROUP_H
|
||||
#define IO_FILTER_GROUP_H
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Storage file read object
|
||||
***********************************************************************************************************************************/
|
||||
typedef struct IoFilterGroup IoFilterGroup;
|
||||
|
||||
#include "common/io/filter/filter.h"
|
||||
#include "common/type/string.h"
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Constructor
|
||||
***********************************************************************************************************************************/
|
||||
IoFilterGroup *ioFilterGroupNew();
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Functions
|
||||
***********************************************************************************************************************************/
|
||||
void ioFilterGroupAdd(IoFilterGroup *this, IoFilter *filter);
|
||||
void ioFilterGroupProcess(IoFilterGroup *this, const Buffer *input);
|
||||
void ioFilterGroupClose(IoFilterGroup *this);
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Getters
|
||||
***********************************************************************************************************************************/
|
||||
const Variant *ioFilterGroupResult(const IoFilterGroup *this, const String *filterType);
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Destructor
|
||||
***********************************************************************************************************************************/
|
||||
void ioFilterGroupFree(IoFilterGroup *this);
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Macros for function logging
|
||||
***********************************************************************************************************************************/
|
||||
#define FUNCTION_DEBUG_IO_FILTER_GROUP_TYPE \
|
||||
IoFilterGroup *
|
||||
#define FUNCTION_DEBUG_IO_FILTER_GROUP_FORMAT(value, buffer, bufferSize) \
|
||||
objToLog(value, "IoFilterGroup", buffer, bufferSize)
|
||||
|
||||
#endif
|
@ -2,6 +2,7 @@
|
||||
IO Read
|
||||
***********************************************************************************************************************************/
|
||||
#include "common/debug.h"
|
||||
#include "common/io/io.h"
|
||||
#include "common/io/read.h"
|
||||
#include "common/log.h"
|
||||
#include "common/memContext.h"
|
||||
@ -13,10 +14,13 @@ struct IoRead
|
||||
{
|
||||
MemContext *memContext; // Mem context of driver
|
||||
void *driver; // Driver object
|
||||
IoFilterGroup *filterGroup; // IO filters
|
||||
|
||||
IoReadOpen open; // Driver open
|
||||
IoReadProcess process; // Driver read
|
||||
IoReadProcess read; // Driver read
|
||||
IoReadClose close; // Driver close
|
||||
IoReadEof eof; // Driver eof
|
||||
|
||||
size_t size; // Total bytes read
|
||||
};
|
||||
|
||||
@ -26,24 +30,24 @@ Create a new read IO
|
||||
Allocations will be in the memory context of the caller.
|
||||
***********************************************************************************************************************************/
|
||||
IoRead *
|
||||
ioReadNew(void *driver, IoReadOpen open, IoReadProcess process, IoReadClose close, IoReadEof eof)
|
||||
ioReadNew(void *driver, IoReadOpen open, IoReadProcess read, IoReadClose close, IoReadEof eof)
|
||||
{
|
||||
FUNCTION_DEBUG_BEGIN(logLevelTrace);
|
||||
FUNCTION_DEBUG_PARAM(VOIDP, driver);
|
||||
FUNCTION_DEBUG_PARAM(FUNCTIONP, open);
|
||||
FUNCTION_DEBUG_PARAM(FUNCTIONP, process);
|
||||
FUNCTION_DEBUG_PARAM(FUNCTIONP, read);
|
||||
FUNCTION_DEBUG_PARAM(FUNCTIONP, close);
|
||||
FUNCTION_DEBUG_PARAM(FUNCTIONP, eof);
|
||||
|
||||
FUNCTION_TEST_ASSERT(driver != NULL);
|
||||
FUNCTION_TEST_ASSERT(process != NULL);
|
||||
FUNCTION_TEST_ASSERT(read != NULL);
|
||||
FUNCTION_DEBUG_END();
|
||||
|
||||
IoRead *this = memNew(sizeof(IoRead));
|
||||
this->memContext = memContextCurrent();
|
||||
this->driver = driver;
|
||||
this->open = open;
|
||||
this->process = process;
|
||||
this->read = read;
|
||||
this->close = close;
|
||||
this->eof = eof;
|
||||
|
||||
@ -78,8 +82,19 @@ ioRead(IoRead *this, Buffer *buffer)
|
||||
FUNCTION_TEST_ASSERT(buffer != NULL);
|
||||
FUNCTION_DEBUG_END();
|
||||
|
||||
size_t result = this->process(this->driver, buffer);
|
||||
this->size += result;
|
||||
// Read unless eof or the output buffer is full
|
||||
size_t result = 0;
|
||||
|
||||
if(!ioReadEof(this) && bufRemains(buffer) > 0)
|
||||
{
|
||||
size_t resultBytes = this->read(this->driver, buffer);
|
||||
result += resultBytes;
|
||||
this->size += resultBytes;
|
||||
|
||||
// Apply filters
|
||||
if (this->filterGroup != NULL)
|
||||
ioFilterGroupProcess(this->filterGroup, buffer);
|
||||
}
|
||||
|
||||
FUNCTION_DEBUG_RESULT(SIZE, result);
|
||||
}
|
||||
@ -96,6 +111,11 @@ ioReadClose(IoRead *this)
|
||||
FUNCTION_TEST_ASSERT(this != NULL);
|
||||
FUNCTION_DEBUG_END();
|
||||
|
||||
// Close the filter group and gather results
|
||||
if (this->filterGroup != NULL)
|
||||
ioFilterGroupClose(this->filterGroup);
|
||||
|
||||
// Close the driver if there is a close function
|
||||
if (this->close != NULL)
|
||||
this->close(this->driver);
|
||||
|
||||
@ -117,6 +137,40 @@ ioReadEof(const IoRead *this)
|
||||
FUNCTION_DEBUG_RESULT(BOOL, this->eof != NULL ? this->eof(this->driver) : false);
|
||||
}
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Get/set filters
|
||||
|
||||
Filters must be set before open and cannot be reset.
|
||||
***********************************************************************************************************************************/
|
||||
const IoFilterGroup *
|
||||
ioReadFilterGroup(const IoRead *this)
|
||||
{
|
||||
FUNCTION_TEST_BEGIN();
|
||||
FUNCTION_TEST_PARAM(IO_READ, this);
|
||||
|
||||
FUNCTION_TEST_ASSERT(this != NULL);
|
||||
FUNCTION_TEST_END();
|
||||
|
||||
FUNCTION_TEST_RESULT(IO_FILTER_GROUP, this->filterGroup);
|
||||
}
|
||||
|
||||
void
|
||||
ioReadFilterGroupSet(IoRead *this, IoFilterGroup *filterGroup)
|
||||
{
|
||||
FUNCTION_DEBUG_BEGIN(logLevelTrace);
|
||||
FUNCTION_DEBUG_PARAM(IO_READ, this);
|
||||
FUNCTION_DEBUG_PARAM(IO_FILTER_GROUP, filterGroup);
|
||||
|
||||
FUNCTION_TEST_ASSERT(this != NULL);
|
||||
FUNCTION_TEST_ASSERT(filterGroup != NULL);
|
||||
FUNCTION_TEST_ASSERT(this->filterGroup == NULL);
|
||||
FUNCTION_DEBUG_END();
|
||||
|
||||
this->filterGroup = filterGroup;
|
||||
|
||||
FUNCTION_DEBUG_RESULT_VOID();
|
||||
}
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Total bytes read
|
||||
***********************************************************************************************************************************/
|
||||
|
@ -9,6 +9,7 @@ IO read object
|
||||
***********************************************************************************************************************************/
|
||||
typedef struct IoRead IoRead;
|
||||
|
||||
#include "common/io/filter/group.h"
|
||||
#include "common/type/buffer.h"
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
@ -22,7 +23,7 @@ typedef bool (*IoReadEof)(void *driver);
|
||||
/***********************************************************************************************************************************
|
||||
Constructor
|
||||
***********************************************************************************************************************************/
|
||||
IoRead *ioReadNew(void *driver, IoReadOpen open, IoReadProcess process, IoReadClose close, IoReadEof eof);
|
||||
IoRead *ioReadNew(void *driver, IoReadOpen open, IoReadProcess read, IoReadClose close, IoReadEof eof);
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Functions
|
||||
@ -32,9 +33,11 @@ size_t ioRead(IoRead *this, Buffer *buffer);
|
||||
void ioReadClose(IoRead *this);
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Getters
|
||||
Getters/Setters
|
||||
***********************************************************************************************************************************/
|
||||
bool ioReadEof(const IoRead *this);
|
||||
const IoFilterGroup *ioReadFilterGroup(const IoRead *this);
|
||||
void ioReadFilterGroupSet(IoRead *this, IoFilterGroup *FilterGroup);
|
||||
size_t ioReadSize(const IoRead *this);
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
|
@ -13,9 +13,12 @@ struct IoWrite
|
||||
{
|
||||
MemContext *memContext; // Mem context of driver
|
||||
void *driver; // Driver object
|
||||
IoFilterGroup *filterGroup; // IO filters
|
||||
|
||||
IoWriteOpen open; // Driver open
|
||||
IoWriteProcess process; // Driver write
|
||||
IoWriteProcess write; // Driver write
|
||||
IoWriteClose close; // Driver close
|
||||
|
||||
size_t size; // Total bytes written
|
||||
};
|
||||
|
||||
@ -25,23 +28,23 @@ Create a new write IO
|
||||
Allocations will be in the memory context of the caller.
|
||||
***********************************************************************************************************************************/
|
||||
IoWrite *
|
||||
ioWriteNew(void *driver, IoWriteOpen open, IoWriteProcess process, IoWriteClose close)
|
||||
ioWriteNew(void *driver, IoWriteOpen open, IoWriteProcess write, IoWriteClose close)
|
||||
{
|
||||
FUNCTION_DEBUG_BEGIN(logLevelTrace);
|
||||
FUNCTION_DEBUG_PARAM(VOIDP, driver);
|
||||
FUNCTION_DEBUG_PARAM(FUNCTIONP, open);
|
||||
FUNCTION_DEBUG_PARAM(FUNCTIONP, process);
|
||||
FUNCTION_DEBUG_PARAM(FUNCTIONP, write);
|
||||
FUNCTION_DEBUG_PARAM(FUNCTIONP, close);
|
||||
|
||||
FUNCTION_TEST_ASSERT(driver != NULL);
|
||||
FUNCTION_TEST_ASSERT(process != NULL);
|
||||
FUNCTION_TEST_ASSERT(write != NULL);
|
||||
FUNCTION_DEBUG_END();
|
||||
|
||||
IoWrite *this = memNew(sizeof(IoWrite));
|
||||
this->memContext = memContextCurrent();
|
||||
this->driver = driver;
|
||||
this->open = open;
|
||||
this->process = process;
|
||||
this->write = write;
|
||||
this->close = close;
|
||||
|
||||
FUNCTION_DEBUG_RESULT(IO_WRITE, this);
|
||||
@ -80,7 +83,12 @@ ioWrite(IoWrite *this, const Buffer *buffer)
|
||||
// Only write if there is data to write
|
||||
if (buffer != NULL && bufSize(buffer) > 0)
|
||||
{
|
||||
this->process(this->driver, buffer);
|
||||
// Apply filters
|
||||
if (this->filterGroup != NULL)
|
||||
ioFilterGroupProcess(this->filterGroup, buffer);
|
||||
|
||||
// Write data
|
||||
this->write(this->driver, buffer);
|
||||
this->size += bufUsed(buffer);
|
||||
}
|
||||
|
||||
@ -99,12 +107,51 @@ ioWriteClose(IoWrite *this)
|
||||
FUNCTION_TEST_ASSERT(this != NULL);
|
||||
FUNCTION_DEBUG_END();
|
||||
|
||||
// Close the filter group and gather results
|
||||
if (this->filterGroup != NULL)
|
||||
ioFilterGroupClose(this->filterGroup);
|
||||
|
||||
// Close the driver if there is a close function
|
||||
if (this->close != NULL)
|
||||
this->close(this->driver);
|
||||
|
||||
FUNCTION_DEBUG_RESULT_VOID();
|
||||
}
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Get/set filters
|
||||
|
||||
Filters must be set before open and cannot be reset.
|
||||
***********************************************************************************************************************************/
|
||||
const IoFilterGroup *
|
||||
ioWriteFilterGroup(const IoWrite *this)
|
||||
{
|
||||
FUNCTION_TEST_BEGIN();
|
||||
FUNCTION_TEST_PARAM(IO_WRITE, this);
|
||||
|
||||
FUNCTION_TEST_ASSERT(this != NULL);
|
||||
FUNCTION_TEST_END();
|
||||
|
||||
FUNCTION_TEST_RESULT(IO_FILTER_GROUP, this->filterGroup);
|
||||
}
|
||||
|
||||
void
|
||||
ioWriteFilterGroupSet(IoWrite *this, IoFilterGroup *filterGroup)
|
||||
{
|
||||
FUNCTION_DEBUG_BEGIN(logLevelTrace);
|
||||
FUNCTION_DEBUG_PARAM(IO_WRITE, this);
|
||||
FUNCTION_DEBUG_PARAM(IO_FILTER_GROUP, filterGroup);
|
||||
|
||||
FUNCTION_TEST_ASSERT(this != NULL);
|
||||
FUNCTION_TEST_ASSERT(filterGroup != NULL);
|
||||
FUNCTION_TEST_ASSERT(this->filterGroup == NULL);
|
||||
FUNCTION_DEBUG_END();
|
||||
|
||||
this->filterGroup = filterGroup;
|
||||
|
||||
FUNCTION_DEBUG_RESULT_VOID();
|
||||
}
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Total bytes written
|
||||
***********************************************************************************************************************************/
|
||||
|
@ -9,6 +9,7 @@ IO write object
|
||||
***********************************************************************************************************************************/
|
||||
typedef struct IoWrite IoWrite;
|
||||
|
||||
#include "common/io/filter/group.h"
|
||||
#include "common/type/buffer.h"
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
@ -21,7 +22,7 @@ typedef void (*IoWriteClose)(void *driver);
|
||||
/***********************************************************************************************************************************
|
||||
Constructor
|
||||
***********************************************************************************************************************************/
|
||||
IoWrite *ioWriteNew(void *driver, IoWriteOpen open, IoWriteProcess process, IoWriteClose close);
|
||||
IoWrite *ioWriteNew(void *driver, IoWriteOpen open, IoWriteProcess write, IoWriteClose close);
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Functions
|
||||
@ -31,8 +32,10 @@ void ioWrite(IoWrite *this, const Buffer *buffer);
|
||||
void ioWriteClose(IoWrite *this);
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Getters
|
||||
Getters/Setters
|
||||
***********************************************************************************************************************************/
|
||||
const IoFilterGroup *ioWriteFilterGroup(const IoWrite *this);
|
||||
void ioWriteFilterGroupSet(IoWrite *this, IoFilterGroup *filterGroup);
|
||||
size_t ioWriteSize(const IoWrite *this);
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
|
@ -12,6 +12,11 @@ Cryptographic Hashes
|
||||
#include "crypto/crypto.h"
|
||||
#include "crypto/hash.h"
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Filter type constant
|
||||
***********************************************************************************************************************************/
|
||||
#define CRYPTO_HASH_FILTER_TYPE "hash"
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Track state during block encrypt/decrypt
|
||||
***********************************************************************************************************************************/
|
||||
@ -21,10 +26,11 @@ struct CryptoHash
|
||||
const EVP_MD *hashType; // Hash type
|
||||
EVP_MD_CTX *hashContext; // Message hash context
|
||||
Buffer *hash; // Hash in binary form
|
||||
IoFilter *filter; // Filter interface
|
||||
};
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
New digest object
|
||||
New hash object
|
||||
***********************************************************************************************************************************/
|
||||
CryptoHash *
|
||||
cryptoHashNew(const String *type)
|
||||
@ -61,6 +67,10 @@ cryptoHashNew(const String *type)
|
||||
|
||||
// Set free callback to ensure hash context is freed
|
||||
memContextCallback(this->memContext, (MemContextCallback)cryptoHashFree, this);
|
||||
|
||||
// Create filter interface
|
||||
this->filter = ioFilterNew(
|
||||
strNew(CRYPTO_HASH_FILTER_TYPE), this, (IoFilterProcessIn)cryptoHashProcess, (IoFilterResult)cryptoHashResult);
|
||||
}
|
||||
MEM_CONTEXT_NEW_END();
|
||||
|
||||
@ -70,7 +80,8 @@ cryptoHashNew(const String *type)
|
||||
/***********************************************************************************************************************************
|
||||
Add message data to the hash
|
||||
***********************************************************************************************************************************/
|
||||
void cryptoHashProcessC(CryptoHash *this, const unsigned char *message, size_t messageSize)
|
||||
void
|
||||
cryptoHashProcessC(CryptoHash *this, const unsigned char *message, size_t messageSize)
|
||||
{
|
||||
FUNCTION_DEBUG_BEGIN(logLevelTrace);
|
||||
FUNCTION_DEBUG_PARAM(CRYPTO_HASH, this);
|
||||
@ -94,7 +105,8 @@ void cryptoHashProcessC(CryptoHash *this, const unsigned char *message, size_t m
|
||||
/***********************************************************************************************************************************
|
||||
Add message data to the hash from a Buffer
|
||||
***********************************************************************************************************************************/
|
||||
void cryptoHashProcess(CryptoHash *this, Buffer *message)
|
||||
void
|
||||
cryptoHashProcess(CryptoHash *this, const Buffer *message)
|
||||
{
|
||||
FUNCTION_TEST_BEGIN();
|
||||
FUNCTION_TEST_PARAM(CRYPTO_HASH, this);
|
||||
@ -104,7 +116,7 @@ void cryptoHashProcess(CryptoHash *this, Buffer *message)
|
||||
FUNCTION_TEST_ASSERT(message != NULL);
|
||||
FUNCTION_TEST_END();
|
||||
|
||||
cryptoHashProcessC(this, bufPtr(message), bufSize(message));
|
||||
cryptoHashProcessC(this, bufPtr(message), bufUsed(message));
|
||||
|
||||
FUNCTION_TEST_RESULT_VOID();
|
||||
}
|
||||
@ -112,7 +124,8 @@ void cryptoHashProcess(CryptoHash *this, Buffer *message)
|
||||
/***********************************************************************************************************************************
|
||||
Add message data to the hash from a String
|
||||
***********************************************************************************************************************************/
|
||||
void cryptoHashProcessStr(CryptoHash *this, String *message)
|
||||
void
|
||||
cryptoHashProcessStr(CryptoHash *this, const String *message)
|
||||
{
|
||||
FUNCTION_TEST_BEGIN();
|
||||
FUNCTION_TEST_PARAM(CRYPTO_HASH, this);
|
||||
@ -130,7 +143,8 @@ void cryptoHashProcessStr(CryptoHash *this, String *message)
|
||||
/***********************************************************************************************************************************
|
||||
Get binary representation of the hash
|
||||
***********************************************************************************************************************************/
|
||||
const Buffer *cryptoHash(CryptoHash *this)
|
||||
const Buffer *
|
||||
cryptoHash(CryptoHash *this)
|
||||
{
|
||||
FUNCTION_DEBUG_BEGIN(logLevelTrace);
|
||||
FUNCTION_DEBUG_PARAM(CRYPTO_HASH, this);
|
||||
@ -164,7 +178,8 @@ const Buffer *cryptoHash(CryptoHash *this)
|
||||
/***********************************************************************************************************************************
|
||||
Get string representation of the hash
|
||||
***********************************************************************************************************************************/
|
||||
String *cryptoHashHex(CryptoHash *this)
|
||||
String *
|
||||
cryptoHashHex(CryptoHash *this)
|
||||
{
|
||||
FUNCTION_DEBUG_BEGIN(logLevelTrace);
|
||||
FUNCTION_DEBUG_PARAM(CRYPTO_HASH, this);
|
||||
@ -181,10 +196,49 @@ String *cryptoHashHex(CryptoHash *this)
|
||||
FUNCTION_DEBUG_RESULT(STRING, hashStr);
|
||||
}
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Get filter interface
|
||||
***********************************************************************************************************************************/
|
||||
IoFilter *
|
||||
cryptoHashFilter(CryptoHash *this)
|
||||
{
|
||||
FUNCTION_DEBUG_BEGIN(logLevelTrace);
|
||||
FUNCTION_DEBUG_PARAM(CRYPTO_HASH, this);
|
||||
|
||||
FUNCTION_DEBUG_ASSERT(this != NULL);
|
||||
FUNCTION_DEBUG_END();
|
||||
|
||||
FUNCTION_DEBUG_RESULT(IO_FILTER, this->filter);
|
||||
}
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Return filter result
|
||||
***********************************************************************************************************************************/
|
||||
const Variant *
|
||||
cryptoHashResult(CryptoHash *this)
|
||||
{
|
||||
FUNCTION_DEBUG_BEGIN(logLevelTrace);
|
||||
FUNCTION_DEBUG_PARAM(CRYPTO_HASH, this);
|
||||
|
||||
FUNCTION_DEBUG_ASSERT(this != NULL);
|
||||
FUNCTION_DEBUG_END();
|
||||
|
||||
Variant *result = NULL;
|
||||
|
||||
MEM_CONTEXT_BEGIN(this->memContext)
|
||||
{
|
||||
result = varNewStr(cryptoHashHex(this));
|
||||
}
|
||||
MEM_CONTEXT_END();
|
||||
|
||||
FUNCTION_DEBUG_RESULT(VARIANT, result);
|
||||
}
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Free memory
|
||||
***********************************************************************************************************************************/
|
||||
void cryptoHashFree(CryptoHash *this)
|
||||
void
|
||||
cryptoHashFree(CryptoHash *this)
|
||||
{
|
||||
FUNCTION_DEBUG_BEGIN(logLevelTrace);
|
||||
FUNCTION_DEBUG_PARAM(CRYPTO_HASH, this);
|
||||
|
@ -9,6 +9,7 @@ Hash object
|
||||
***********************************************************************************************************************************/
|
||||
typedef struct CryptoHash CryptoHash;
|
||||
|
||||
#include "common/io/filter/filter.h"
|
||||
#include "common/type/string.h"
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
@ -19,16 +20,33 @@ Hash types
|
||||
#define HASH_TYPE_SHA256 "sha256"
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Functions
|
||||
Constructor
|
||||
***********************************************************************************************************************************/
|
||||
CryptoHash *cryptoHashNew(const String *type);
|
||||
void cryptoHashProcess(CryptoHash *this, Buffer *message);
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Functions
|
||||
***********************************************************************************************************************************/
|
||||
void cryptoHashProcess(CryptoHash *this, const Buffer *message);
|
||||
void cryptoHashProcessC(CryptoHash *this, const unsigned char *message, size_t messageSize);
|
||||
void cryptoHashProcessStr(CryptoHash *this, String *message);
|
||||
void cryptoHashProcessStr(CryptoHash *this, const String *message);
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Getters
|
||||
***********************************************************************************************************************************/
|
||||
const Buffer *cryptoHash(CryptoHash *this);
|
||||
String *cryptoHashHex(CryptoHash *this);
|
||||
IoFilter *cryptoHashFilter(CryptoHash *this);
|
||||
const Variant *cryptoHashResult(CryptoHash *this);
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Destructor
|
||||
***********************************************************************************************************************************/
|
||||
void cryptoHashFree(CryptoHash *this);
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Helper functions
|
||||
***********************************************************************************************************************************/
|
||||
String *cryptoHashOne(const String *type, Buffer *message);
|
||||
String *cryptoHashOneC(const String *type, const unsigned char *message, size_t messageSize);
|
||||
String *cryptoHashOneStr(const String *type, String *message);
|
||||
|
@ -71,7 +71,7 @@ storageFileReadMove(StorageFileRead *this, MemContext *parentNew)
|
||||
Get file driver
|
||||
***********************************************************************************************************************************/
|
||||
StorageFileReadPosix *
|
||||
storageFileReadFileDriver(const StorageFileRead *this)
|
||||
storageFileReadDriver(const StorageFileRead *this)
|
||||
{
|
||||
FUNCTION_TEST_BEGIN();
|
||||
FUNCTION_TEST_PARAM(STORAGE_FILE_READ, this);
|
||||
|
@ -27,7 +27,7 @@ StorageFileRead *storageFileReadMove(StorageFileRead *this, MemContext *parentNe
|
||||
/***********************************************************************************************************************************
|
||||
Getters
|
||||
***********************************************************************************************************************************/
|
||||
StorageFileReadPosix *storageFileReadFileDriver(const StorageFileRead *this);
|
||||
StorageFileReadPosix *storageFileReadDriver(const StorageFileRead *this);
|
||||
IoRead *storageFileReadIo(const StorageFileRead *this);
|
||||
bool storageFileReadIgnoreMissing(const StorageFileRead *this);
|
||||
const String *storageFileReadName(const StorageFileRead *this);
|
||||
|
@ -285,7 +285,7 @@ storageMove(StorageFileRead *source, StorageFileWrite *destination)
|
||||
MEM_CONTEXT_TEMP_BEGIN()
|
||||
{
|
||||
// If the file can't be moved it will need to be copied
|
||||
if (!storageDriverPosixMove(storageFileReadFileDriver(source), storageFileWriteFileDriver(destination)))
|
||||
if (!storageDriverPosixMove(storageFileReadDriver(source), storageFileWriteFileDriver(destination)))
|
||||
{
|
||||
// Perform the copy
|
||||
storageCopyNP(source, destination);
|
||||
@ -314,6 +314,7 @@ storageNewRead(const Storage *this, const String *fileExp, StorageNewReadParam p
|
||||
FUNCTION_DEBUG_PARAM(STORAGE, this);
|
||||
FUNCTION_DEBUG_PARAM(STRING, fileExp);
|
||||
FUNCTION_DEBUG_PARAM(BOOL, param.ignoreMissing);
|
||||
FUNCTION_DEBUG_PARAM(IO_FILTER_GROUP, param.filterGroup);
|
||||
|
||||
FUNCTION_TEST_ASSERT(this != NULL);
|
||||
FUNCTION_DEBUG_END();
|
||||
@ -322,7 +323,12 @@ storageNewRead(const Storage *this, const String *fileExp, StorageNewReadParam p
|
||||
|
||||
MEM_CONTEXT_TEMP_BEGIN()
|
||||
{
|
||||
result = storageFileReadMove(storageFileReadNew(storagePathNP(this, fileExp), param.ignoreMissing), MEM_CONTEXT_OLD());
|
||||
result = storageFileReadNew(storagePathNP(this, fileExp), param.ignoreMissing);
|
||||
|
||||
if (param.filterGroup != NULL)
|
||||
ioReadFilterGroupSet(storageFileReadIo(result), param.filterGroup);
|
||||
|
||||
storageFileReadMove(result, MEM_CONTEXT_OLD());
|
||||
}
|
||||
MEM_CONTEXT_TEMP_END();
|
||||
|
||||
@ -344,6 +350,7 @@ storageNewWrite(const Storage *this, const String *fileExp, StorageNewWriteParam
|
||||
FUNCTION_DEBUG_PARAM(BOOL, param.noSyncFile);
|
||||
FUNCTION_DEBUG_PARAM(BOOL, param.noSyncPath);
|
||||
FUNCTION_DEBUG_PARAM(BOOL, param.noAtomic);
|
||||
FUNCTION_DEBUG_PARAM(IO_FILTER_GROUP, param.filterGroup);
|
||||
|
||||
FUNCTION_TEST_ASSERT(this != NULL);
|
||||
FUNCTION_DEBUG_ASSERT(this->write);
|
||||
@ -353,12 +360,15 @@ storageNewWrite(const Storage *this, const String *fileExp, StorageNewWriteParam
|
||||
|
||||
MEM_CONTEXT_TEMP_BEGIN()
|
||||
{
|
||||
result = storageFileWriteMove(
|
||||
storageFileWriteNew(
|
||||
result = storageFileWriteNew(
|
||||
storagePathNP(this, fileExp), param.modeFile != 0 ? param.modeFile : this->modeFile,
|
||||
param.modePath != 0 ? param.modePath : this->modePath, param.noCreatePath, param.noSyncFile, param.noSyncPath,
|
||||
param.noAtomic),
|
||||
MEM_CONTEXT_OLD());
|
||||
param.noAtomic);
|
||||
|
||||
if (param.filterGroup != NULL)
|
||||
ioWriteFilterGroupSet(storageFileWriteIo(result), param.filterGroup);
|
||||
|
||||
storageFileWriteMove(result, MEM_CONTEXT_OLD());
|
||||
}
|
||||
MEM_CONTEXT_TEMP_END();
|
||||
|
||||
|
@ -13,6 +13,7 @@ typedef struct Storage Storage;
|
||||
|
||||
#include "common/type/buffer.h"
|
||||
#include "common/type/stringList.h"
|
||||
#include "common/io/filter/group.h"
|
||||
#include "storage/fileRead.h"
|
||||
#include "storage/fileWrite.h"
|
||||
#include "storage/info.h"
|
||||
@ -129,6 +130,7 @@ storageNewRead
|
||||
typedef struct StorageNewReadParam
|
||||
{
|
||||
bool ignoreMissing;
|
||||
IoFilterGroup *filterGroup;
|
||||
} StorageNewReadParam;
|
||||
|
||||
#define storageNewReadP(this, pathExp, ...) \
|
||||
@ -149,6 +151,7 @@ typedef struct StorageNewWriteParam
|
||||
bool noSyncFile;
|
||||
bool noSyncPath;
|
||||
bool noAtomic;
|
||||
IoFilterGroup *filterGroup;
|
||||
} StorageNewWriteParam;
|
||||
|
||||
#define storageNewWriteP(this, pathExp, ...) \
|
||||
|
@ -122,18 +122,6 @@ unit:
|
||||
coverage:
|
||||
common/lock: full
|
||||
|
||||
# ----------------------------------------------------------------------------------------------------------------------------
|
||||
- name: io
|
||||
total: 4
|
||||
|
||||
coverage:
|
||||
common/io/io: full
|
||||
common/io/handle: full
|
||||
common/io/read: full
|
||||
common/io/bufferRead: full
|
||||
common/io/write: full
|
||||
common/io/bufferWrite: full
|
||||
|
||||
# ----------------------------------------------------------------------------------------------------------------------------
|
||||
- name: exit
|
||||
total: 3
|
||||
@ -204,6 +192,20 @@ unit:
|
||||
coverage:
|
||||
common/type/keyValue: full
|
||||
|
||||
# ----------------------------------------------------------------------------------------------------------------------------
|
||||
- name: io
|
||||
total: 4
|
||||
|
||||
coverage:
|
||||
common/io/bufferRead: full
|
||||
common/io/bufferWrite: full
|
||||
common/io/filter/filter: full
|
||||
common/io/filter/group: full
|
||||
common/io/handle: full
|
||||
common/io/io: full
|
||||
common/io/read: full
|
||||
common/io/write: full
|
||||
|
||||
# ----------------------------------------------------------------------------------------------------------------------------
|
||||
- name: encode
|
||||
total: 1
|
||||
|
@ -271,4 +271,11 @@ Macros to ease the use of common data types
|
||||
#define TEST_RESULT_U16_HEX(statement, resultExpected, ...) \
|
||||
TEST_RESULT(statement, resultExpected, uint16_t, "%04X", TEST_TYPE_FORMAT, ==, TEST_TYPE_COMPARE, __VA_ARGS__);
|
||||
|
||||
#define TEST_RESULT_UINT_PARAM(statement, resultExpected, typeOp, ...) \
|
||||
TEST_RESULT(statement, resultExpected, uint64_t, "%" PRIu64, TEST_TYPE_FORMAT, typeOp, TEST_TYPE_COMPARE, __VA_ARGS__);
|
||||
#define TEST_RESULT_UINT(statement, resultExpected, ...) \
|
||||
TEST_RESULT_UINT_PARAM(statement, resultExpected, ==, __VA_ARGS__);
|
||||
#define TEST_RESULT_UINT_NE(statement, resultExpected, ...) \
|
||||
TEST_RESULT_UINT_PARAM(statement, resultExpected, !=, __VA_ARGS__);
|
||||
|
||||
#endif
|
||||
|
@ -60,6 +60,46 @@ testIoWriteClose(void *driver)
|
||||
testIoWriteCloseCalled = true;
|
||||
}
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Test filter that counts total bytes
|
||||
***********************************************************************************************************************************/
|
||||
typedef struct IoTestFilterSize
|
||||
{
|
||||
MemContext *memContext;
|
||||
size_t size;
|
||||
IoFilter *filter;
|
||||
} IoTestFilterSize;
|
||||
|
||||
static void
|
||||
ioTestFilterSizeProcess(IoTestFilterSize *this, const Buffer *buffer)
|
||||
{
|
||||
this->size += bufUsed(buffer);
|
||||
}
|
||||
|
||||
static const Variant *
|
||||
ioTestFilterSizeResult(IoTestFilterSize *this)
|
||||
{
|
||||
return varNewUInt64(this->size);
|
||||
}
|
||||
|
||||
static IoTestFilterSize *
|
||||
ioTestFilterSizeNew(const char *type)
|
||||
{
|
||||
IoTestFilterSize *this = NULL;
|
||||
|
||||
MEM_CONTEXT_NEW_BEGIN("IoTestFilterSize")
|
||||
{
|
||||
this = memNew(sizeof(IoTestFilterSize));
|
||||
this->memContext = MEM_CONTEXT_NEW();
|
||||
|
||||
this->filter = ioFilterNew(
|
||||
strNew(type), this, (IoFilterProcessIn)ioTestFilterSizeProcess, (IoFilterResult)ioTestFilterSizeResult);
|
||||
}
|
||||
MEM_CONTEXT_NEW_END();
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Test Run
|
||||
***********************************************************************************************************************************/
|
||||
@ -104,8 +144,18 @@ testRun()
|
||||
}
|
||||
MEM_CONTEXT_TEMP_END();
|
||||
|
||||
IoFilterGroup *filterGroup = NULL;
|
||||
TEST_ASSIGN(filterGroup, ioFilterGroupNew(), " create new filter group");
|
||||
TEST_RESULT_VOID(ioFilterGroupAdd(filterGroup, ioTestFilterSizeNew("size")->filter), " add filter to filter group");
|
||||
TEST_RESULT_VOID(ioFilterGroupAdd(filterGroup, ioTestFilterSizeNew("size2")->filter), " add filter to filter group");
|
||||
TEST_RESULT_VOID(ioReadFilterGroupSet(ioBufferReadIo(bufferRead), filterGroup), " add filter group to read io");
|
||||
TEST_RESULT_PTR(ioFilterMove(NULL, memContextTop()), NULL, " move NULL filter to top context");
|
||||
TEST_RESULT_PTR(ioFilterGroupResult(filterGroup, strNew("size")), NULL, " check filter result is NULL");
|
||||
TEST_RESULT_PTR(ioFilterGroupResult(filterGroup, strNew("size2")), NULL, " check filter result is NULL");
|
||||
|
||||
TEST_RESULT_BOOL(ioReadEof(ioBufferReadIo(bufferRead)), false, " not eof");
|
||||
TEST_RESULT_SIZE(ioRead(ioBufferReadIo(bufferRead), buffer), 2, " read 2 bytes");
|
||||
TEST_RESULT_SIZE(ioRead(ioBufferReadIo(bufferRead), buffer), 0, " read 0 bytes (full buffer)");
|
||||
TEST_RESULT_BOOL(memcmp(bufPtr(buffer), "12", 2) == 0, true, " memcmp");
|
||||
TEST_RESULT_STR(strPtr(strNewBuf(buffer)), "12", " check read");
|
||||
TEST_RESULT_SIZE(ioReadSize(ioBufferReadIo(bufferRead)), 2, " read size is 2");
|
||||
@ -115,12 +165,20 @@ testRun()
|
||||
TEST_RESULT_SIZE(ioRead(ioBufferReadIo(bufferRead), buffer), 1, " read 1 byte");
|
||||
TEST_RESULT_STR(strPtr(strNewBuf(buffer)), "3", " check read");
|
||||
TEST_RESULT_BOOL(ioReadEof(ioBufferReadIo(bufferRead)), true, " eof");
|
||||
TEST_RESULT_BOOL(ioBufferRead(bufferRead, buffer), 0, " eof from driver");
|
||||
TEST_RESULT_SIZE(ioRead(ioBufferReadIo(bufferRead), buffer), 0, " read 0 bytes");
|
||||
TEST_RESULT_SIZE(ioReadSize(ioBufferReadIo(bufferRead)), 3, " read size is 3");
|
||||
TEST_RESULT_VOID(ioReadClose(ioBufferReadIo(bufferRead)), " close buffer read object");
|
||||
|
||||
TEST_RESULT_PTR(ioReadFilterGroup(ioBufferReadIo(bufferRead)), filterGroup, " check filter group");
|
||||
TEST_RESULT_UINT(varUInt64(ioFilterGroupResult(filterGroup, strNew("size"))), 3, " check filter result");
|
||||
TEST_RESULT_UINT(varUInt64(ioFilterGroupResult(filterGroup, strNew("size2"))), 3, " check filter result");
|
||||
|
||||
TEST_RESULT_VOID(ioBufferReadFree(bufferRead), " free buffer read object");
|
||||
TEST_RESULT_VOID(ioBufferReadFree(NULL), " free NULL buffer read object");
|
||||
|
||||
TEST_RESULT_VOID(ioFilterGroupFree(filterGroup), " free filter group object");
|
||||
TEST_RESULT_VOID(ioFilterGroupFree(NULL), " free NULL filter group object");
|
||||
}
|
||||
|
||||
// *****************************************************************************************************************************
|
||||
@ -149,6 +207,11 @@ testRun()
|
||||
}
|
||||
MEM_CONTEXT_TEMP_END();
|
||||
|
||||
IoFilterGroup *filterGroup = NULL;
|
||||
TEST_ASSIGN(filterGroup, ioFilterGroupNew(), " create new filter group");
|
||||
TEST_RESULT_VOID(ioFilterGroupAdd(filterGroup, ioTestFilterSizeNew("size")->filter), " add filter to filter group");
|
||||
TEST_RESULT_VOID(ioWriteFilterGroupSet(ioBufferWriteIo(bufferWrite), filterGroup), " add filter group to write io");
|
||||
|
||||
TEST_RESULT_VOID(ioWriteOpen(ioBufferWriteIo(bufferWrite)), " open buffer write object");
|
||||
TEST_RESULT_VOID(ioWrite(ioBufferWriteIo(bufferWrite), bufNewStr(strNew("ABC"))), " write 3 bytes");
|
||||
TEST_RESULT_VOID(ioWrite(ioBufferWriteIo(bufferWrite), bufNewStr(strNew(""))), " write 0 bytes");
|
||||
@ -162,6 +225,9 @@ testRun()
|
||||
|
||||
TEST_RESULT_VOID(ioWriteClose(ioBufferWriteIo(bufferWrite)), " close buffer write object");
|
||||
|
||||
TEST_RESULT_PTR(ioWriteFilterGroup(ioBufferWriteIo(bufferWrite)), filterGroup, " check filter group");
|
||||
TEST_RESULT_UINT(varUInt64(ioFilterGroupResult(filterGroup, strNew("size"))), 7, " check filter result");
|
||||
|
||||
TEST_RESULT_VOID(ioBufferWriteFree(bufferWrite), " free buffer write object");
|
||||
TEST_RESULT_VOID(ioBufferWriteFree(NULL), " free NULL buffer write object");
|
||||
}
|
||||
|
@ -11,9 +11,10 @@ testRun()
|
||||
FUNCTION_HARNESS_VOID();
|
||||
|
||||
// *****************************************************************************************************************************
|
||||
if (testBegin("cryptoHashNew(), cryptoHashProcess*(), cryptoHashStr(), and cryptoHashFree()"))
|
||||
if (testBegin("CryptoHash"))
|
||||
{
|
||||
CryptoHash *hash = NULL;
|
||||
IoFilter *hashFilter = NULL;
|
||||
|
||||
TEST_ERROR(cryptoHashNew(strNew(BOGUS_STR)), AssertError, "unable to load hash 'BOGUS'");
|
||||
|
||||
@ -30,13 +31,15 @@ testRun()
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
TEST_ASSIGN(hash, cryptoHashNew(strNew(HASH_TYPE_SHA1)), "create sha1 hash");
|
||||
TEST_ASSIGN(hashFilter, cryptoHashFilter(hash), "create sha1 hash");
|
||||
TEST_RESULT_VOID(cryptoHashProcessC(hash, (const unsigned char *)"1", 1), " add 1");
|
||||
TEST_RESULT_VOID(cryptoHashProcessStr(hash, strNew("2")), " add 2");
|
||||
TEST_RESULT_VOID(cryptoHashProcess(hash, bufNewStr(strNew("3"))), " add 3");
|
||||
TEST_RESULT_VOID(cryptoHashProcess(hash, bufNewStr(strNew("4"))), " add 4");
|
||||
TEST_RESULT_VOID(cryptoHashProcess(hash, bufNewStr(strNew("5"))), " add 5");
|
||||
TEST_RESULT_VOID(ioFilterProcessIn(hashFilter, bufNewStr(strNew("3"))), " add 3");
|
||||
TEST_RESULT_VOID(ioFilterProcessIn(hashFilter, bufNewStr(strNew("4"))), " add 4");
|
||||
TEST_RESULT_VOID(ioFilterProcessIn(hashFilter, bufNewStr(strNew("5"))), " add 5");
|
||||
|
||||
TEST_RESULT_STR(strPtr(cryptoHashHex(hash)), "8cb2237d0679ca88db6464eac60da96345513964", " check small hash");
|
||||
TEST_RESULT_STR(
|
||||
strPtr(varStr(ioFilterResult(hashFilter))), "8cb2237d0679ca88db6464eac60da96345513964", " check small hash");
|
||||
TEST_RESULT_VOID(cryptoHashFree(hash), " free hash");
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -74,7 +74,7 @@ testRun()
|
||||
StorageFileRead *file = NULL;
|
||||
|
||||
TEST_ASSIGN(file, storageNewReadP(storageTest, fileNoPerm, .ignoreMissing = true), "new read file");
|
||||
TEST_RESULT_PTR(storageFileReadFileDriver(file), file->fileDriver, " check file driver");
|
||||
TEST_RESULT_PTR(storageFileReadDriver(file), file->fileDriver, " check file driver");
|
||||
TEST_RESULT_BOOL(storageFileReadIgnoreMissing(file), true, " check ignore missing");
|
||||
TEST_RESULT_STR(strPtr(storageFileReadName(file)), strPtr(fileNoPerm), " check name");
|
||||
|
||||
@ -152,6 +152,9 @@ testRun()
|
||||
TEST_RESULT_VOID(ioRead(storageFileReadIo(file), outBuffer), " no data to load");
|
||||
TEST_RESULT_INT(bufUsed(outBuffer), 0, " buffer is empty");
|
||||
|
||||
TEST_RESULT_VOID(storageFileReadPosix(storageFileReadDriver(file), outBuffer), " no data to load from driver either");
|
||||
TEST_RESULT_INT(bufUsed(outBuffer), 0, " buffer is empty");
|
||||
|
||||
TEST_RESULT_BOOL(bufEq(buffer, expectedBuffer), true, " check file contents (all loaded)");
|
||||
TEST_RESULT_INT(ioReadSize(storageFileReadIo(file)), 9, " check size");
|
||||
|
||||
|
@ -483,6 +483,10 @@ testRun()
|
||||
|
||||
TEST_RESULT_BOOL(ioReadOpen(storageFileReadIo(file)), true, " open file");
|
||||
TEST_RESULT_VOID(ioReadClose(storageFileReadIo(file)), " close file");
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
TEST_ASSIGN(file, storageNewReadP(storageTest, fileName, .filterGroup = (IoFilterGroup *)55), "new read file with filters");
|
||||
TEST_RESULT_PTR(ioReadFilterGroup(storageFileReadIo(file)), (IoFilterGroup *)55, " check filter group is set");
|
||||
}
|
||||
|
||||
// *****************************************************************************************************************************
|
||||
@ -513,6 +517,11 @@ testRun()
|
||||
TEST_RESULT_VOID(ioWriteClose(storageFileWriteIo(file)), " close file");
|
||||
TEST_RESULT_INT(storageInfoNP(storageTest, strPath(fileName)).mode, 0700, " check path mode");
|
||||
TEST_RESULT_INT(storageInfoNP(storageTest, fileName).mode, 0600, " check file mode");
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
TEST_ASSIGN(
|
||||
file, storageNewWriteP(storageTest, fileName, .filterGroup = (IoFilterGroup *)55), "new write file with filters");
|
||||
TEST_RESULT_PTR(ioWriteFilterGroup(storageFileWriteIo(file)), (IoFilterGroup *)55, " check filter group is set");
|
||||
}
|
||||
|
||||
// *****************************************************************************************************************************
|
||||
|
Reference in New Issue
Block a user