Implemented new create enumerator function to get metadata request paths
authorSansar Choinyambuu <schoinya@hsr.ch>
Wed, 19 Oct 2011 07:18:58 +0000 (09:18 +0200)
committerAndreas Steffen <andreas.steffen@strongswan.org>
Mon, 28 Nov 2011 13:39:51 +0000 (14:39 +0100)
Modified existing file_enumerator function to include just measurement requests

src/libpts/pts/pts_database.c
src/libpts/pts/pts_database.h

index 2706173..c9ca98d 100644 (file)
@@ -49,11 +49,26 @@ METHOD(pts_database_t, create_file_enumerator, enumerator_t*,
                                "SELECT f.id, f.type, f.path FROM files AS f "
                                "JOIN product_file AS pf ON f.id = pf.file "
                                "JOIN products AS p ON p.id = pf.product "
-                               "WHERE p.name = ?",
+                               "WHERE p.name = ? AND f.measurement = 1",
                                DB_TEXT, product, DB_INT, DB_INT, DB_TEXT);
        return e;
 }
 
+METHOD(pts_database_t, create_file_meta_enumerator, enumerator_t*,
+       private_pts_database_t *this, char *product)
+{
+       enumerator_t *e;
+
+       /* look for all entries belonging to a product in the files table */
+       e = this->db->query(this->db,
+                               "SELECT f.type, f.path FROM files AS f "
+                               "JOIN product_file AS pf ON f.id = pf.file "
+                               "JOIN products AS p ON p.id = pf.product "
+                               "WHERE p.name = ? AND f.metadata = 1",
+                               DB_TEXT, product, DB_INT, DB_TEXT);
+       return e;
+}
+
 METHOD(pts_database_t, create_hash_enumerator, enumerator_t*,
        private_pts_database_t *this, char *product, pts_meas_algorithms_t algo,
        int id, bool is_dir)
@@ -99,6 +114,7 @@ pts_database_t *pts_database_create(char *uri)
        INIT(this,
                .public = {
                        .create_file_enumerator = _create_file_enumerator,
+                       .create_file_meta_enumerator = _create_file_meta_enumerator,
                        .create_hash_enumerator = _create_hash_enumerator,
                        .destroy = _destroy,
                },
index f2a6854..af2c87a 100644 (file)
@@ -33,14 +33,22 @@ typedef struct pts_database_t pts_database_t;
 struct pts_database_t {
 
        /**
-       * Get files to be measured by PTS
+       * Get files/directories to be measured by PTS
        *
        * @param product                software product (os, vpn client, etc.)
-       * @return                               enumerator over all matching files
+       * @return                               enumerator over all matching files/directories
        */
        enumerator_t* (*create_file_enumerator)(pts_database_t *this, char *product);
 
        /**
+       * Get files/directories to request metadata of
+       *
+       * @param product                software product (os, vpn client, etc.)
+       * @return                               enumerator over all matching files/directories
+       */
+       enumerator_t* (*create_file_meta_enumerator)(pts_database_t *this, char *product);
+
+       /**
        * Get stored measurement hash for single file or directory entries
        *
        * @param product                software product (os, vpn client, etc.)