diff common/binverify.h @ 1081:edbf5e5e88f4

(issue118) Extend verify_binary to carry an open file * binverify.c: Change result to a structure containing an open fptr Use in Memory data for windows verification. * mainwindow.cpp, selftest.c: Handle the returend structure * binverifytest.cpp: Test for the exclusive read and update signature. * listutil.c: Add optional fptr parameter to read_file
author Andre Heinecke <andre.heinecke@intevation.de>
date Thu, 11 Sep 2014 12:05:24 +0200
parents 78798d3af8f0
children 2a1aa9df8f11
line wrap: on
line diff
--- a/common/binverify.h	Thu Sep 11 12:00:10 2014 +0200
+++ b/common/binverify.h	Thu Sep 11 12:05:24 2014 +0200
@@ -13,13 +13,14 @@
  */
 #include <stdbool.h>
 #include <stddef.h>
+#include <stdio.h>
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
 /**
- * @enum bin_verify_result
+ * @enum verify_result
  * @brief Result of a verification
  */
 typedef enum {
@@ -28,6 +29,19 @@
     VerifyInvalidSignature = 4, /*! Signature was invalid */
     VerifyInvalidCertificate = 5, /*! Certificate mismatch */
     VerifyReadFailed = 6, /*! File exists but could not read the file */
+} verify_result;
+
+/**
+ * A structure containing a verify_result and a reference to the
+ * verified file.
+ */
+typedef struct {
+    /*@{*/
+    verify_result result; /**< the result of the verification */
+    FILE *fptr; /**< Pointer to the open file struct of the verified file
+                    The ptr is only valid if verify_result is VerifyValid
+                    and needs to be closed by the caller in that case.*/
+    /*@}*/
 } bin_verify_result;
 
 /**
@@ -57,14 +71,15 @@
  */
 bin_verify_result verify_binary(const char *filename, size_t name_len);
 
+/**@def Max size of a valid binary in byte */
+#define MAX_VALID_BIN_SIZE (32 * 1024 * 1024)
+
 #ifdef WIN32
 /**
  * @brief windows implementation of verify_binary
  */
 bin_verify_result verify_binary_win(const char *filename, size_t name_len);
 #else /* WIN32 */
-/**@def Max size of a valid binary in byte */
-#define MAX_VALID_BIN_SIZE (32 * 1024 * 1024)
 
 /**
  * @brief linux implementation of verify_binary

http://wald.intevation.org/projects/trustbridge/