You've already forked pgbackrest
							
							
				mirror of
				https://github.com/pgbackrest/pgbackrest.git
				synced 2025-10-30 23:37:45 +02:00 
			
		
		
		
	Add ProtocolCommand object.
This formalizes the creation of protocol commands, which was previously done by creating KeyValue objects manually.
This commit is contained in:
		| @@ -63,6 +63,10 @@ | ||||
|                         <p>Add separate <cmd>archive-get-async</cmd> command.</p> | ||||
|                     </release-item> | ||||
|  | ||||
|                     <release-item> | ||||
|                         <p>Add <code>ProtocolCommand</code> object.</p> | ||||
|                     </release-item> | ||||
|  | ||||
|                     <release-item> | ||||
|                         <p>Add <code>exists()</code> to remote storage.</p> | ||||
|                     </release-item> | ||||
|   | ||||
							
								
								
									
										22
									
								
								src/Makefile
									
									
									
									
									
								
							
							
						
						
									
										22
									
								
								src/Makefile
									
									
									
									
									
								
							| @@ -141,6 +141,7 @@ SRCS = \ | ||||
| 	postgres/pageChecksum.c \ | ||||
| 	protocol/server.c \ | ||||
| 	protocol/client.c \ | ||||
| 	protocol/command.c \ | ||||
| 	protocol/helper.c \ | ||||
| 	storage/driver/posix/storage.c \ | ||||
| 	storage/driver/posix/common.c \ | ||||
| @@ -200,7 +201,7 @@ command/help/help.o: command/help/help.c common/assert.h common/debug.h common/e | ||||
| command/info/info.o: command/info/info.c command/archive/common.h command/info/info.h 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/handleWrite.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/time.h common/type/buffer.h common/type/convert.h common/type/json.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 crypto/crypto.h crypto/hash.h info/info.h info/infoArchive.h info/infoBackup.h info/infoPg.h perl/exec.h postgres/interface.h storage/fileRead.h storage/fileWrite.h storage/helper.h storage/info.h storage/storage.h | ||||
| 	$(CC) $(CFLAGS) -c command/info/info.c -o command/info/info.o | ||||
|  | ||||
| command/remote/remote.o: command/remote/remote.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/handleRead.h common/io/handleWrite.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/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 config/protocol.h protocol/client.h protocol/helper.h protocol/server.h storage/driver/remote/protocol.h | ||||
| command/remote/remote.o: command/remote/remote.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/handleRead.h common/io/handleWrite.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/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 config/protocol.h protocol/client.h protocol/command.h protocol/helper.h protocol/server.h storage/driver/remote/protocol.h | ||||
| 	$(CC) $(CFLAGS) -c command/remote/remote.c -o command/remote/remote.o | ||||
|  | ||||
| common/debug.o: common/debug.c common/assert.h common/debug.h common/error.auto.h common/error.h common/logLevel.h common/stackTrace.h common/type/convert.h | ||||
| @@ -218,7 +219,7 @@ common/error.o: common/error.c common/error.auto.c common/error.auto.h common/er | ||||
| common/exec.o: common/exec.c common/assert.h common/debug.h common/error.auto.h common/error.h common/exec.h common/io/filter/filter.h common/io/filter/group.h common/io/handleRead.h common/io/handleWrite.h common/io/io.h common/io/read.h common/io/read.intern.h common/io/write.h common/io/write.intern.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 common/wait.h | ||||
| 	$(CC) $(CFLAGS) -c common/exec.c -o common/exec.o | ||||
|  | ||||
| common/exit.o: common/exit.c command/command.h common/assert.h common/debug.h common/error.auto.h common/error.h common/exit.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/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 perl/exec.h protocol/client.h protocol/helper.h | ||||
| common/exit.o: common/exit.c command/command.h common/assert.h common/debug.h common/error.auto.h common/error.h common/exit.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/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 perl/exec.h protocol/client.h protocol/command.h protocol/helper.h | ||||
| 	$(CC) $(CFLAGS) -c common/exit.c -o common/exit.o | ||||
|  | ||||
| common/fork.o: common/fork.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 | ||||
| @@ -350,7 +351,7 @@ config/load.o: config/load.c command/command.h common/assert.h common/debug.h co | ||||
| 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/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 config/parse.auto.c config/parse.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 | ||||
|  | ||||
| config/protocol.o: config/protocol.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/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 config/protocol.h protocol/client.h protocol/server.h | ||||
| config/protocol.o: config/protocol.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/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 config/protocol.h protocol/client.h protocol/command.h protocol/server.h | ||||
| 	$(CC) $(CFLAGS) -c config/protocol.c -o config/protocol.o | ||||
|  | ||||
| crypto/cipherBlock.o: crypto/cipherBlock.c common/assert.h common/debug.h common/error.auto.h common/error.h common/io/filter/filter.h common/io/filter/filter.intern.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/cipherBlock.h crypto/crypto.h | ||||
| @@ -425,13 +426,16 @@ postgres/interface/v110.o: postgres/interface/v110.c common/assert.h common/debu | ||||
| 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 | ||||
| 	$(CC) $(CFLAGS) -funroll-loops -ftree-vectorize -c postgres/pageChecksum.c -o postgres/pageChecksum.o | ||||
|  | ||||
| protocol/client.o: protocol/client.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/io/write.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/json.h common/type/keyValue.h common/type/string.h common/type/variant.h common/type/variantList.h protocol/client.h version.h | ||||
| protocol/client.o: protocol/client.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/io/write.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/json.h common/type/keyValue.h common/type/string.h common/type/variant.h common/type/variantList.h protocol/client.h protocol/command.h version.h | ||||
| 	$(CC) $(CFLAGS) -c protocol/client.c -o protocol/client.o | ||||
|  | ||||
| protocol/helper.o: protocol/helper.c common/assert.h common/debug.h common/error.auto.h common/error.h common/exec.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/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 config/exec.h config/protocol.h crypto/crypto.h protocol/client.h protocol/helper.h protocol/server.h | ||||
| protocol/command.o: protocol/command.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/json.h common/type/keyValue.h common/type/string.h common/type/variant.h common/type/variantList.h protocol/command.h | ||||
| 	$(CC) $(CFLAGS) -c protocol/command.c -o protocol/command.o | ||||
|  | ||||
| protocol/helper.o: protocol/helper.c common/assert.h common/debug.h common/error.auto.h common/error.h common/exec.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/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 config/exec.h config/protocol.h crypto/crypto.h protocol/client.h protocol/command.h protocol/helper.h protocol/server.h | ||||
| 	$(CC) $(CFLAGS) -c protocol/helper.c -o protocol/helper.o | ||||
|  | ||||
| protocol/server.o: protocol/server.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/io/write.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/json.h common/type/keyValue.h common/type/list.h common/type/string.h common/type/variant.h common/type/variantList.h protocol/client.h protocol/server.h version.h | ||||
| protocol/server.o: protocol/server.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/io/write.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/json.h common/type/keyValue.h common/type/list.h common/type/string.h common/type/variant.h common/type/variantList.h protocol/client.h protocol/command.h protocol/server.h version.h | ||||
| 	$(CC) $(CFLAGS) -c protocol/server.c -o protocol/server.o | ||||
|  | ||||
| storage/driver/posix/common.o: storage/driver/posix/common.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/common.h | ||||
| @@ -446,13 +450,13 @@ storage/driver/posix/fileWrite.o: storage/driver/posix/fileWrite.c common/assert | ||||
| storage/driver/posix/storage.o: storage/driver/posix/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/read.h common/io/write.h common/log.h common/logLevel.h common/memContext.h common/regExp.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 storage/driver/posix/common.h storage/driver/posix/fileRead.h storage/driver/posix/fileWrite.h storage/driver/posix/storage.h storage/fileRead.h storage/fileWrite.h storage/info.h storage/storage.h storage/storage.intern.h | ||||
| 	$(CC) $(CFLAGS) -c storage/driver/posix/storage.c -o storage/driver/posix/storage.o | ||||
|  | ||||
| storage/driver/remote/fileRead.o: storage/driver/remote/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/http/client.h common/io/http/header.h common/io/http/query.h common/io/read.h common/io/read.intern.h common/io/write.h common/log.h common/logLevel.h common/memContext.h common/regExp.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 protocol/client.h protocol/server.h storage/driver/remote/fileRead.h storage/driver/remote/protocol.h storage/driver/remote/storage.h storage/fileRead.h storage/fileRead.intern.h storage/fileWrite.h storage/info.h storage/storage.h storage/storage.intern.h | ||||
| storage/driver/remote/fileRead.o: storage/driver/remote/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/http/client.h common/io/http/header.h common/io/http/query.h common/io/read.h common/io/read.intern.h common/io/write.h common/log.h common/logLevel.h common/memContext.h common/regExp.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 protocol/client.h protocol/command.h protocol/server.h storage/driver/remote/fileRead.h storage/driver/remote/protocol.h storage/driver/remote/storage.h storage/fileRead.h storage/fileRead.intern.h storage/fileWrite.h storage/info.h storage/storage.h storage/storage.intern.h | ||||
| 	$(CC) $(CFLAGS) -c storage/driver/remote/fileRead.c -o storage/driver/remote/fileRead.o | ||||
|  | ||||
| storage/driver/remote/protocol.o: storage/driver/remote/protocol.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/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 protocol/server.h storage/driver/remote/protocol.h storage/fileRead.h storage/fileWrite.h storage/helper.h storage/info.h storage/storage.h storage/storage.intern.h | ||||
| 	$(CC) $(CFLAGS) -c storage/driver/remote/protocol.c -o storage/driver/remote/protocol.o | ||||
|  | ||||
| storage/driver/remote/storage.o: storage/driver/remote/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/http/client.h common/io/http/header.h common/io/http/query.h common/io/read.h common/io/write.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 protocol/client.h protocol/helper.h protocol/server.h storage/driver/remote/fileRead.h storage/driver/remote/protocol.h storage/driver/remote/storage.h storage/fileRead.h storage/fileWrite.h storage/info.h storage/storage.h storage/storage.intern.h | ||||
| storage/driver/remote/storage.o: storage/driver/remote/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/http/client.h common/io/http/header.h common/io/http/query.h common/io/read.h common/io/write.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 protocol/client.h protocol/command.h protocol/helper.h protocol/server.h storage/driver/remote/fileRead.h storage/driver/remote/protocol.h storage/driver/remote/storage.h storage/fileRead.h storage/fileWrite.h storage/info.h storage/storage.h storage/storage.intern.h | ||||
| 	$(CC) $(CFLAGS) -c storage/driver/remote/storage.c -o storage/driver/remote/storage.o | ||||
|  | ||||
| storage/driver/s3/fileRead.o: storage/driver/s3/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/http/client.h common/io/http/header.h common/io/http/query.h common/io/read.h common/io/read.intern.h common/io/write.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 storage/driver/s3/fileRead.h storage/driver/s3/storage.h storage/fileRead.h storage/fileRead.intern.h storage/fileWrite.h storage/info.h storage/storage.h storage/storage.intern.h | ||||
| @@ -467,7 +471,7 @@ storage/fileRead.o: storage/fileRead.c common/assert.h common/debug.h common/err | ||||
| 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/fileWrite.h storage/fileWrite.intern.h version.h | ||||
| 	$(CC) $(CFLAGS) -c storage/fileWrite.c -o storage/fileWrite.o | ||||
|  | ||||
| storage/helper.o: storage/helper.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/http/client.h common/io/http/header.h common/io/http/query.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/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 protocol/client.h protocol/helper.h storage/driver/posix/fileRead.h storage/driver/posix/fileWrite.h storage/driver/posix/storage.h storage/driver/remote/storage.h storage/driver/s3/storage.h storage/fileRead.h storage/fileWrite.h storage/helper.h storage/info.h storage/storage.h storage/storage.intern.h | ||||
| storage/helper.o: storage/helper.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/http/client.h common/io/http/header.h common/io/http/query.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/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 protocol/client.h protocol/command.h protocol/helper.h storage/driver/posix/fileRead.h storage/driver/posix/fileWrite.h storage/driver/posix/storage.h storage/driver/remote/storage.h storage/driver/s3/storage.h storage/fileRead.h storage/fileWrite.h storage/helper.h storage/info.h storage/storage.h storage/storage.intern.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/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/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 common/wait.h storage/fileRead.h storage/fileWrite.h storage/info.h storage/storage.h storage/storage.intern.h | ||||
|   | ||||
| @@ -64,8 +64,10 @@ configProtocolOption(ProtocolClient *client, const VariantList *paramList) | ||||
|  | ||||
|     MEM_CONTEXT_TEMP_BEGIN() | ||||
|     { | ||||
|         KeyValue *command = kvPut(kvNew(), varNewStr(PROTOCOL_COMMAND_STR), varNewStr(PROTOCOL_COMMAND_CONFIG_OPTION_STR)); | ||||
|         kvPut(command, varNewStr(PROTOCOL_PARAMETER_STR), varNewVarLst(paramList)); | ||||
|         ProtocolCommand *command = protocolCommandNew(PROTOCOL_COMMAND_CONFIG_OPTION_STR); | ||||
|  | ||||
|         for (unsigned int paramIdx = 0; paramIdx < varLstSize(paramList); paramIdx++) | ||||
|             protocolCommandParamAdd(command, varLstGet(paramList, paramIdx)); | ||||
|  | ||||
|         memContextSwitch(MEM_CONTEXT_OLD()); | ||||
|         result = varVarLst(protocolClientExecute(client, command, true)); | ||||
|   | ||||
| @@ -17,7 +17,6 @@ STRING_EXTERN(PROTOCOL_GREETING_NAME_STR,                           PROTOCOL_GRE | ||||
| STRING_EXTERN(PROTOCOL_GREETING_SERVICE_STR,                        PROTOCOL_GREETING_SERVICE); | ||||
| STRING_EXTERN(PROTOCOL_GREETING_VERSION_STR,                        PROTOCOL_GREETING_VERSION); | ||||
|  | ||||
| STRING_EXTERN(PROTOCOL_COMMAND_STR,                                 PROTOCOL_COMMAND); | ||||
| STRING_EXTERN(PROTOCOL_COMMAND_NOOP_STR,                            PROTOCOL_COMMAND_NOOP); | ||||
| STRING_EXTERN(PROTOCOL_COMMAND_EXIT_STR,                            PROTOCOL_COMMAND_EXIT); | ||||
|  | ||||
| @@ -25,8 +24,6 @@ STRING_EXTERN(PROTOCOL_ERROR_STR,                                   PROTOCOL_ERR | ||||
|  | ||||
| STRING_EXTERN(PROTOCOL_OUTPUT_STR,                                  PROTOCOL_OUTPUT); | ||||
|  | ||||
| STRING_EXTERN(PROTOCOL_PARAMETER_STR,                               PROTOCOL_PARAMETER); | ||||
|  | ||||
| /*********************************************************************************************************************************** | ||||
| Object type | ||||
| ***********************************************************************************************************************************/ | ||||
| @@ -174,18 +171,18 @@ protocolClientReadOutput(ProtocolClient *this, bool outputRequired) | ||||
| Write the protocol command | ||||
| ***********************************************************************************************************************************/ | ||||
| void | ||||
| protocolClientWriteCommand(ProtocolClient *this, const KeyValue *command) | ||||
| protocolClientWriteCommand(ProtocolClient *this, const ProtocolCommand *command) | ||||
| { | ||||
|     FUNCTION_LOG_BEGIN(logLevelTrace); | ||||
|         FUNCTION_LOG_PARAM(PROTOCOL_CLIENT, this); | ||||
|         FUNCTION_LOG_PARAM(KEY_VALUE, command); | ||||
|         FUNCTION_LOG_PARAM(PROTOCOL_COMMAND, command); | ||||
|     FUNCTION_LOG_END(); | ||||
|  | ||||
|     ASSERT(this != NULL); | ||||
|     ASSERT(command != NULL); | ||||
|  | ||||
|     // Write out the command | ||||
|     ioWriteLine(this->write, kvToJson(command, 0)); | ||||
|     ioWriteLine(this->write, protocolCommandJson(command)); | ||||
|     ioWriteFlush(this->write); | ||||
|  | ||||
|     // Reset the keep alive time | ||||
| @@ -198,11 +195,11 @@ protocolClientWriteCommand(ProtocolClient *this, const KeyValue *command) | ||||
| Execute a protocol command and get the output | ||||
| ***********************************************************************************************************************************/ | ||||
| const Variant * | ||||
| protocolClientExecute(ProtocolClient *this, const KeyValue *command, bool outputRequired) | ||||
| protocolClientExecute(ProtocolClient *this, const ProtocolCommand *command, bool outputRequired) | ||||
| { | ||||
|     FUNCTION_LOG_BEGIN(logLevelTrace); | ||||
|         FUNCTION_LOG_PARAM(PROTOCOL_CLIENT, this); | ||||
|         FUNCTION_LOG_PARAM(KEY_VALUE, command); | ||||
|         FUNCTION_LOG_PARAM(PROTOCOL_COMMAND, command); | ||||
|         FUNCTION_LOG_PARAM(BOOL, outputRequired); | ||||
|     FUNCTION_LOG_END(); | ||||
|  | ||||
| @@ -247,7 +244,7 @@ protocolClientNoOp(ProtocolClient *this) | ||||
|  | ||||
|     MEM_CONTEXT_TEMP_BEGIN() | ||||
|     { | ||||
|         protocolClientExecute(this, kvPut(kvNew(), varNewStr(PROTOCOL_COMMAND_STR), varNewStr(PROTOCOL_COMMAND_NOOP_STR)), false); | ||||
|         protocolClientExecute(this, protocolCommandNew(PROTOCOL_COMMAND_NOOP_STR), false); | ||||
|     } | ||||
|     MEM_CONTEXT_TEMP_END(); | ||||
|  | ||||
| @@ -294,7 +291,7 @@ protocolClientToLog(const ProtocolClient *this) | ||||
| } | ||||
|  | ||||
| /*********************************************************************************************************************************** | ||||
| Free the file | ||||
| Free object | ||||
| ***********************************************************************************************************************************/ | ||||
| void | ||||
| protocolClientFree(ProtocolClient *this) | ||||
| @@ -310,7 +307,7 @@ protocolClientFree(ProtocolClient *this) | ||||
|         // Send an exit command but don't wait to see if it succeeds | ||||
|         MEM_CONTEXT_TEMP_BEGIN() | ||||
|         { | ||||
|             protocolClientWriteCommand(this, kvPut(kvNew(), varNewStr(PROTOCOL_COMMAND_STR), varNewStr(PROTOCOL_COMMAND_EXIT_STR))); | ||||
|             protocolClientWriteCommand(this, protocolCommandNew(PROTOCOL_COMMAND_EXIT_STR)); | ||||
|         } | ||||
|         MEM_CONTEXT_TEMP_END(); | ||||
|  | ||||
|   | ||||
| @@ -20,6 +20,7 @@ typedef enum | ||||
|  | ||||
| #include "common/io/read.h" | ||||
| #include "common/io/write.h" | ||||
| #include "protocol/command.h" | ||||
|  | ||||
| /*********************************************************************************************************************************** | ||||
| Constants | ||||
| @@ -31,8 +32,6 @@ Constants | ||||
| #define PROTOCOL_GREETING_VERSION                                   "version" | ||||
|     STRING_DECLARE(PROTOCOL_GREETING_VERSION_STR); | ||||
|  | ||||
| #define PROTOCOL_COMMAND                                            "cmd" | ||||
|     STRING_DECLARE(PROTOCOL_COMMAND_STR); | ||||
| #define PROTOCOL_COMMAND_EXIT                                       "exit" | ||||
|     STRING_DECLARE(PROTOCOL_COMMAND_EXIT_STR); | ||||
| #define PROTOCOL_COMMAND_NOOP                                       "noop" | ||||
| @@ -44,9 +43,6 @@ Constants | ||||
| #define PROTOCOL_OUTPUT                                             "out" | ||||
|     STRING_DECLARE(PROTOCOL_OUTPUT_STR); | ||||
|  | ||||
| #define PROTOCOL_PARAMETER                                          "param" | ||||
|     STRING_DECLARE(PROTOCOL_PARAMETER_STR); | ||||
|  | ||||
| /*********************************************************************************************************************************** | ||||
| Constructor | ||||
| ***********************************************************************************************************************************/ | ||||
| @@ -55,11 +51,11 @@ ProtocolClient *protocolClientNew(const String *name, const String *service, IoR | ||||
| /*********************************************************************************************************************************** | ||||
| Functions | ||||
| ***********************************************************************************************************************************/ | ||||
| const Variant *protocolClientExecute(ProtocolClient *this, const KeyValue *command, bool outputRequired); | ||||
| const Variant *protocolClientExecute(ProtocolClient *this, const ProtocolCommand *command, bool outputRequired); | ||||
| ProtocolClient *protocolClientMove(ProtocolClient *this, MemContext *parentNew); | ||||
| void protocolClientNoOp(ProtocolClient *this); | ||||
| const Variant *protocolClientReadOutput(ProtocolClient *this, bool outputRequired); | ||||
| void protocolClientWriteCommand(ProtocolClient *this, const KeyValue *command); | ||||
| void protocolClientWriteCommand(ProtocolClient *this, const ProtocolCommand *command); | ||||
|  | ||||
| /*********************************************************************************************************************************** | ||||
| Getters | ||||
|   | ||||
							
								
								
									
										152
									
								
								src/protocol/command.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										152
									
								
								src/protocol/command.c
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,152 @@ | ||||
| /*********************************************************************************************************************************** | ||||
| Protocol Command | ||||
| ***********************************************************************************************************************************/ | ||||
| #include "common/debug.h" | ||||
| #include "common/log.h" | ||||
| #include "common/memContext.h" | ||||
| #include "common/type/json.h" | ||||
| #include "common/type/keyValue.h" | ||||
| #include "protocol/command.h" | ||||
|  | ||||
| /*********************************************************************************************************************************** | ||||
| Constants | ||||
| ***********************************************************************************************************************************/ | ||||
| STRING_EXTERN(PROTOCOL_KEY_COMMAND_STR,                             PROTOCOL_KEY_COMMAND); | ||||
| STRING_EXTERN(PROTOCOL_KEY_PARAMETER_STR,                           PROTOCOL_KEY_PARAMETER); | ||||
|  | ||||
| /*********************************************************************************************************************************** | ||||
| Object type | ||||
| ***********************************************************************************************************************************/ | ||||
| struct ProtocolCommand | ||||
| { | ||||
|     MemContext *memContext; | ||||
|     const String *command; | ||||
|     Variant *parameterList; | ||||
| }; | ||||
|  | ||||
| /*********************************************************************************************************************************** | ||||
| Create object | ||||
| ***********************************************************************************************************************************/ | ||||
| ProtocolCommand * | ||||
| protocolCommandNew(const String *command) | ||||
| { | ||||
|     FUNCTION_TEST_BEGIN(); | ||||
|         FUNCTION_TEST_PARAM(STRING, command); | ||||
|     FUNCTION_TEST_END(); | ||||
|  | ||||
|     ASSERT(command != NULL); | ||||
|  | ||||
|     ProtocolCommand *this = NULL; | ||||
|  | ||||
|     MEM_CONTEXT_NEW_BEGIN("ProtocolCommand") | ||||
|     { | ||||
|         this = memNew(sizeof(ProtocolCommand)); | ||||
|         this->memContext = memContextCurrent(); | ||||
|  | ||||
|         this->command = strDup(command); | ||||
|     } | ||||
|     MEM_CONTEXT_NEW_END(); | ||||
|  | ||||
|     FUNCTION_TEST_RETURN(this); | ||||
| } | ||||
|  | ||||
| /*********************************************************************************************************************************** | ||||
| Read the command output | ||||
| ***********************************************************************************************************************************/ | ||||
| ProtocolCommand * | ||||
| protocolCommandParamAdd(ProtocolCommand *this, const Variant *param) | ||||
| { | ||||
|     FUNCTION_TEST_BEGIN(); | ||||
|         FUNCTION_TEST_PARAM(PROTOCOL_COMMAND, this); | ||||
|         FUNCTION_TEST_PARAM(VARIANT, param); | ||||
|     FUNCTION_TEST_END(); | ||||
|  | ||||
|     ASSERT(this != NULL); | ||||
|  | ||||
|     MEM_CONTEXT_BEGIN(this->memContext) | ||||
|     { | ||||
|         // Create parameter list if not already created | ||||
|         if (this->parameterList == NULL) | ||||
|             this->parameterList = varNewVarLst(varLstNew()); | ||||
|  | ||||
|         // Add parameter to the list | ||||
|         varLstAdd(varVarLst(this->parameterList), varDup(param)); | ||||
|     } | ||||
|     MEM_CONTEXT_END(); | ||||
|  | ||||
|     FUNCTION_TEST_RETURN(this); | ||||
| } | ||||
|  | ||||
| /*********************************************************************************************************************************** | ||||
| Move object to a new context | ||||
| ***********************************************************************************************************************************/ | ||||
| ProtocolCommand * | ||||
| protocolCommandMove(ProtocolCommand *this, MemContext *parentNew) | ||||
| { | ||||
|     FUNCTION_TEST_BEGIN(); | ||||
|         FUNCTION_TEST_PARAM(PROTOCOL_COMMAND, this); | ||||
|         FUNCTION_TEST_PARAM(MEM_CONTEXT, parentNew); | ||||
|     FUNCTION_TEST_END(); | ||||
|  | ||||
|     ASSERT(parentNew != NULL); | ||||
|  | ||||
|     if (this != NULL) | ||||
|         memContextMove(this->memContext, parentNew); | ||||
|  | ||||
|     FUNCTION_TEST_RETURN(this); | ||||
| } | ||||
|  | ||||
| /*********************************************************************************************************************************** | ||||
| Get write interface | ||||
| ***********************************************************************************************************************************/ | ||||
| String * | ||||
| protocolCommandJson(const ProtocolCommand *this) | ||||
| { | ||||
|     FUNCTION_TEST_BEGIN(); | ||||
|         FUNCTION_TEST_PARAM(PROTOCOL_COMMAND, this); | ||||
|     FUNCTION_TEST_END(); | ||||
|  | ||||
|     ASSERT(this != NULL); | ||||
|  | ||||
|     String *result = NULL; | ||||
|  | ||||
|     MEM_CONTEXT_TEMP_BEGIN() | ||||
|     { | ||||
|         KeyValue *command = kvPut(kvNew(), varNewStr(PROTOCOL_KEY_COMMAND_STR), varNewStr(this->command)); | ||||
|  | ||||
|         if (this->parameterList != NULL) | ||||
|             kvPut(command, varNewStr(PROTOCOL_KEY_PARAMETER_STR), this->parameterList); | ||||
|  | ||||
|         memContextSwitch(MEM_CONTEXT_OLD()); | ||||
|         result = kvToJson(command, 0); | ||||
|         memContextSwitch(MEM_CONTEXT_TEMP()); | ||||
|     } | ||||
|     MEM_CONTEXT_TEMP_END(); | ||||
|  | ||||
|     FUNCTION_TEST_RETURN(result); | ||||
| } | ||||
|  | ||||
| /*********************************************************************************************************************************** | ||||
| Render as string for logging | ||||
| ***********************************************************************************************************************************/ | ||||
| String * | ||||
| protocolCommandToLog(const ProtocolCommand *this) | ||||
| { | ||||
|     return strNewFmt("{command: %s}", strPtr(this->command)); | ||||
| } | ||||
|  | ||||
| /*********************************************************************************************************************************** | ||||
| Free object | ||||
| ***********************************************************************************************************************************/ | ||||
| void | ||||
| protocolCommandFree(ProtocolCommand *this) | ||||
| { | ||||
|     FUNCTION_TEST_BEGIN(); | ||||
|         FUNCTION_TEST_PARAM(PROTOCOL_COMMAND, this); | ||||
|     FUNCTION_TEST_END(); | ||||
|  | ||||
|     if (this != NULL) | ||||
|         memContextFree(this->memContext); | ||||
|  | ||||
|     FUNCTION_TEST_RETURN_VOID(); | ||||
| } | ||||
							
								
								
									
										53
									
								
								src/protocol/command.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										53
									
								
								src/protocol/command.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,53 @@ | ||||
| /*********************************************************************************************************************************** | ||||
| Protocol Command | ||||
| ***********************************************************************************************************************************/ | ||||
| #ifndef PROTOCOL_COMMAND_H | ||||
| #define PROTOCOL_COMMAND_H | ||||
|  | ||||
| /*********************************************************************************************************************************** | ||||
| Object type | ||||
| ***********************************************************************************************************************************/ | ||||
| typedef struct ProtocolCommand ProtocolCommand; | ||||
|  | ||||
| #include "common/type/variant.h" | ||||
|  | ||||
| /*********************************************************************************************************************************** | ||||
| Constants | ||||
| ***********************************************************************************************************************************/ | ||||
| #define PROTOCOL_KEY_COMMAND                                        "cmd" | ||||
|     STRING_DECLARE(PROTOCOL_KEY_COMMAND_STR); | ||||
| #define PROTOCOL_KEY_PARAMETER                                      "param" | ||||
|     STRING_DECLARE(PROTOCOL_KEY_PARAMETER_STR); | ||||
|  | ||||
| /*********************************************************************************************************************************** | ||||
| Constructor | ||||
| ***********************************************************************************************************************************/ | ||||
| ProtocolCommand *protocolCommandNew(const String *command); | ||||
|  | ||||
| /*********************************************************************************************************************************** | ||||
| Functions | ||||
| ***********************************************************************************************************************************/ | ||||
| ProtocolCommand *protocolCommandMove(ProtocolCommand *this, MemContext *parentNew); | ||||
| ProtocolCommand *protocolCommandParamAdd(ProtocolCommand *this, const Variant *param); | ||||
|  | ||||
| /*********************************************************************************************************************************** | ||||
| Getters | ||||
| ***********************************************************************************************************************************/ | ||||
| String *protocolCommandJson(const ProtocolCommand *this); | ||||
|  | ||||
| /*********************************************************************************************************************************** | ||||
| Destructor | ||||
| ***********************************************************************************************************************************/ | ||||
| void protocolCommandFree(ProtocolCommand *this); | ||||
|  | ||||
| /*********************************************************************************************************************************** | ||||
| Macros for function logging | ||||
| ***********************************************************************************************************************************/ | ||||
| String *protocolCommandToLog(const ProtocolCommand *this); | ||||
|  | ||||
| #define FUNCTION_LOG_PROTOCOL_COMMAND_TYPE                                                                                         \ | ||||
|     ProtocolCommand * | ||||
| #define FUNCTION_LOG_PROTOCOL_COMMAND_FORMAT(value, buffer, bufferSize)                                                            \ | ||||
|     FUNCTION_LOG_STRING_OBJECT_FORMAT(value, protocolCommandToLog, buffer, bufferSize) | ||||
|  | ||||
| #endif | ||||
| @@ -110,8 +110,8 @@ protocolServerProcess(ProtocolServer *this) | ||||
|             { | ||||
|                 // Read command | ||||
|                 KeyValue *commandKv = varKv(jsonToVar(ioReadLine(this->read))); | ||||
|                 String *command = varStr(kvGet(commandKv, varNewStr(PROTOCOL_COMMAND_STR))); | ||||
|                 VariantList *paramList = varVarLst(kvGet(commandKv, varNewStr(PROTOCOL_PARAMETER_STR))); | ||||
|                 String *command = varStr(kvGet(commandKv, varNewStr(PROTOCOL_KEY_COMMAND_STR))); | ||||
|                 VariantList *paramList = varVarLst(kvGet(commandKv, varNewStr(PROTOCOL_KEY_PARAMETER_STR))); | ||||
|  | ||||
|                 // Process command | ||||
|                 bool found = false; | ||||
| @@ -243,7 +243,7 @@ protocolServerToLog(const ProtocolServer *this) | ||||
| } | ||||
|  | ||||
| /*********************************************************************************************************************************** | ||||
| Free the file | ||||
| Free object | ||||
| ***********************************************************************************************************************************/ | ||||
| void | ||||
| protocolServerFree(ProtocolServer *this) | ||||
|   | ||||
| @@ -121,14 +121,9 @@ storageDriverRemoteFileReadOpen(StorageDriverRemoteFileRead *this) | ||||
|  | ||||
|     MEM_CONTEXT_TEMP_BEGIN() | ||||
|     { | ||||
|         // Add parameters | ||||
|         Variant *param = varNewVarLst(varLstNew()); | ||||
|         varLstAdd(varVarLst(param), varNewStr(this->name)); | ||||
|         varLstAdd(varVarLst(param), varNewBool(this->ignoreMissing)); | ||||
|  | ||||
|         // Construct command | ||||
|         KeyValue *command = kvPut(kvNew(), varNewStr(PROTOCOL_COMMAND_STR), varNewStr(PROTOCOL_COMMAND_STORAGE_OPEN_READ_STR)); | ||||
|         kvPut(command, varNewStr(PROTOCOL_PARAMETER_STR), param); | ||||
|         ProtocolCommand *command = protocolCommandNew(PROTOCOL_COMMAND_STORAGE_OPEN_READ_STR); | ||||
|         protocolCommandParamAdd(command, varNewStr(this->name)); | ||||
|         protocolCommandParamAdd(command, varNewBool(this->ignoreMissing)); | ||||
|  | ||||
|         result = varBool(protocolClientExecute(this->client, command, true)); | ||||
|     } | ||||
|   | ||||
| @@ -87,13 +87,8 @@ storageDriverRemoteExists(StorageDriverRemote *this, const String *path) | ||||
|  | ||||
|     MEM_CONTEXT_TEMP_BEGIN() | ||||
|     { | ||||
|         // Add parameters | ||||
|         Variant *param = varNewVarLst(varLstNew()); | ||||
|         varLstAdd(varVarLst(param), varNewStr(path)); | ||||
|  | ||||
|         // Construct command | ||||
|         KeyValue *command = kvPut(kvNew(), varNewStr(PROTOCOL_COMMAND_STR), varNewStr(PROTOCOL_COMMAND_STORAGE_EXISTS_STR)); | ||||
|         kvPut(command, varNewStr(PROTOCOL_PARAMETER_STR), param); | ||||
|         ProtocolCommand *command = protocolCommandNew(PROTOCOL_COMMAND_STORAGE_EXISTS_STR); | ||||
|         protocolCommandParamAdd(command, varNewStr(path)); | ||||
|  | ||||
|         result = varBool(protocolClientExecute(this->client, command, true)); | ||||
|     } | ||||
| @@ -142,15 +137,10 @@ storageDriverRemoteList(StorageDriverRemote *this, const String *path, bool erro | ||||
|  | ||||
|     MEM_CONTEXT_TEMP_BEGIN() | ||||
|     { | ||||
|         // Add parameters | ||||
|         Variant *param = varNewVarLst(varLstNew()); | ||||
|         varLstAdd(varVarLst(param), varNewStr(path)); | ||||
|         varLstAdd(varVarLst(param), varNewBool(errorOnMissing)); | ||||
|         varLstAdd(varVarLst(param), varNewStr(expression)); | ||||
|  | ||||
|         // Construct command | ||||
|         KeyValue *command = kvPut(kvNew(), varNewStr(PROTOCOL_COMMAND_STR), varNewStr(PROTOCOL_COMMAND_STORAGE_LIST_STR)); | ||||
|         kvPut(command, varNewStr(PROTOCOL_PARAMETER_STR), param); | ||||
|         ProtocolCommand *command = protocolCommandNew(PROTOCOL_COMMAND_STORAGE_LIST_STR); | ||||
|         protocolCommandParamAdd(command, varNewStr(path)); | ||||
|         protocolCommandParamAdd(command, varNewBool(errorOnMissing)); | ||||
|         protocolCommandParamAdd(command, varNewStr(expression)); | ||||
|  | ||||
|         result = strLstMove(strLstNewVarLst(varVarLst(protocolClientExecute(this->client, command, true))), MEM_CONTEXT_OLD()); | ||||
|     } | ||||
|   | ||||
| @@ -579,11 +579,12 @@ unit: | ||||
|  | ||||
|       # ---------------------------------------------------------------------------------------------------------------------------- | ||||
|       - name: protocol | ||||
|         total: 5 | ||||
|         total: 6 | ||||
|         perlReq: true | ||||
|  | ||||
|         coverage: | ||||
|           protocol/client: full | ||||
|           protocol/command: full | ||||
|           protocol/helper: full | ||||
|           protocol/server: full | ||||
|  | ||||
|   | ||||
| @@ -126,6 +126,36 @@ testRun(void) | ||||
|             "remote protocol params with replacements"); | ||||
|     } | ||||
|  | ||||
|     // ***************************************************************************************************************************** | ||||
|     if (testBegin("ProtocolCommand")) | ||||
|     { | ||||
|         ProtocolCommand *command = NULL; | ||||
|  | ||||
|         MEM_CONTEXT_TEMP_BEGIN() | ||||
|         { | ||||
|             TEST_ASSIGN(command, protocolCommandNew(strNew("command1")), "create command"); | ||||
|             TEST_RESULT_PTR(protocolCommandParamAdd(command, varNewStr(strNew("param1"))), command, "add param"); | ||||
|             TEST_RESULT_PTR(protocolCommandParamAdd(command, varNewStr(strNew("param2"))), command, "add param"); | ||||
|  | ||||
|             TEST_RESULT_PTR(protocolCommandMove(command, MEM_CONTEXT_OLD()), command, "move protocol command"); | ||||
|             TEST_RESULT_PTR(protocolCommandMove(NULL, MEM_CONTEXT_OLD()), NULL, "move null protocol command"); | ||||
|         } | ||||
|         MEM_CONTEXT_TEMP_END(); | ||||
|  | ||||
|         TEST_RESULT_STR(strPtr(protocolCommandToLog(command)), "{command: command1}", "check log"); | ||||
|         TEST_RESULT_STR( | ||||
|             strPtr(protocolCommandJson(command)), "{\"cmd\":\"command1\",\"param\":[\"param1\",\"param2\"]}", "check json"); | ||||
|  | ||||
|         // ------------------------------------------------------------------------------------------------------------------------- | ||||
|         TEST_ASSIGN(command, protocolCommandNew(strNew("command2")), "create command"); | ||||
|         TEST_RESULT_STR(strPtr(protocolCommandToLog(command)), "{command: command2}", "check log"); | ||||
|         TEST_RESULT_STR(strPtr(protocolCommandJson(command)), "{\"cmd\":\"command2\"}", "check json"); | ||||
|  | ||||
|         // ------------------------------------------------------------------------------------------------------------------------- | ||||
|         TEST_RESULT_VOID(protocolCommandFree(command), "free command"); | ||||
|         TEST_RESULT_VOID(protocolCommandFree(NULL), "free null command"); | ||||
|     } | ||||
|  | ||||
|     // ***************************************************************************************************************************** | ||||
|     if (testBegin("ProtocolClient")) | ||||
|     { | ||||
| @@ -241,9 +271,11 @@ testRun(void) | ||||
|  | ||||
|                 // Get command output | ||||
|                 const VariantList *output = NULL; | ||||
|                 KeyValue *command = kvPut(kvNew(), varNewStr(PROTOCOL_COMMAND_STR), varNewStr(strNew("test"))); | ||||
|  | ||||
|                 TEST_ASSIGN(output, varVarLst(protocolClientExecute(client, command, true)), "execute command with output"); | ||||
|                 TEST_ASSIGN( | ||||
|                     output, | ||||
|                     varVarLst(protocolClientExecute(client, protocolCommandNew(strNew("test")), true)), | ||||
|                     "execute command with output"); | ||||
|                 TEST_RESULT_UINT(varLstSize(output), 2, "check output size"); | ||||
|                 TEST_RESULT_STR(strPtr(varStr(varLstGet(output, 0))), "value1", "check value1"); | ||||
|                 TEST_RESULT_STR(strPtr(varStr(varLstGet(output, 1))), "value2", "check value2"); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user