[70378] branches/gsoc10-configfiles/base/src/cregistry
and.damore at macports.org
and.damore at macports.org
Sat Aug 7 14:02:44 PDT 2010
Revision: 70378
http://trac.macports.org/changeset/70378
Author: and.damore at macports.org
Date: 2010-08-07 14:02:43 -0700 (Sat, 07 Aug 2010)
Log Message:
-----------
adding md5 to reg_entry_map
Modified Paths:
--------------
branches/gsoc10-configfiles/base/src/cregistry/entry.c
branches/gsoc10-configfiles/base/src/cregistry/entry.h
branches/gsoc10-configfiles/base/src/cregistry/sql.c
Modified: branches/gsoc10-configfiles/base/src/cregistry/entry.c
===================================================================
--- branches/gsoc10-configfiles/base/src/cregistry/entry.c 2010-08-07 20:56:49 UTC (rev 70377)
+++ branches/gsoc10-configfiles/base/src/cregistry/entry.c 2010-08-07 21:02:43 UTC (rev 70378)
@@ -860,6 +860,60 @@
}
/**
+ * gsoc10-configfiles
+ * Maps files to the given port in the filemap. The list of files must not
+ * contain files that are already mapped to the given port.
+ *
+ * @param [in] entry the entry to map the files to
+ * @param [in] tupels a list of tupels to map in form {file checksum}
+ * @param [in] tupel_count the number of tupels
+ * @param [out] errPtr on error, a description of the error that occurred
+ * @return true if success; false if failure
+ */
+int reg_entry_map_with_md5(reg_entry* entry, char** tupels, int tupel_count,
+ reg_error* errPtr) {
+ reg_registry* reg = entry->reg;
+ int result = 1;
+ sqlite3_stmt* stmt = NULL;
+ char* insert = "INSERT INTO registry.files (id, path, mtime, active, md5sum) "
+ "VALUES (?, ?, 0, 0, ?)";
+ if ((sqlite3_prepare(reg->db, insert, -1, &stmt, NULL) == SQLITE_OK)
+ && (sqlite3_bind_int64(stmt, 1, entry->id) == SQLITE_OK)) {
+ int i;
+ for (i=0; i<tupel_count && result; i++) {
+ if (sqlite3_bind_text(stmt, 2, tupels[i], -1, SQLITE_STATIC)
+ == SQLITE_OK) {
+ int r;
+ do {
+ r = sqlite3_step(stmt);
+ switch (r) {
+ case SQLITE_DONE:
+ sqlite3_reset(stmt);
+ break;
+ case SQLITE_BUSY:
+ break;
+ default:
+ reg_sqlite_error(reg->db, errPtr, insert);
+ result = 0;
+ break;
+ }
+ } while (r == SQLITE_BUSY);
+ } else {
+ reg_sqlite_error(reg->db, errPtr, insert);
+ result = 0;
+ }
+ }
+ } else {
+ reg_sqlite_error(reg->db, errPtr, insert);
+ result = 0;
+ }
+ if (stmt) {
+ sqlite3_finalize(stmt);
+ }
+ return result;
+}
+
+/**
* Unaps files from the given port in the filemap. The files must be owned by
* the given entry.
*
Modified: branches/gsoc10-configfiles/base/src/cregistry/entry.h
===================================================================
--- branches/gsoc10-configfiles/base/src/cregistry/entry.h 2010-08-07 20:56:49 UTC (rev 70377)
+++ branches/gsoc10-configfiles/base/src/cregistry/entry.h 2010-08-07 21:02:43 UTC (rev 70378)
@@ -75,6 +75,8 @@
int reg_entry_propset(reg_entry* entry, char* key, char* value,
reg_error* errPtr);
+int reg_entry_map_with_md5(reg_entry* entry, char** tupels, int tupel_count,
+ reg_error* errPtr);
int reg_entry_map(reg_entry* entry, char** files, int file_count,
reg_error* errPtr);
int reg_entry_unmap(reg_entry* entry, char** files, int file_count,
Modified: branches/gsoc10-configfiles/base/src/cregistry/sql.c
===================================================================
--- branches/gsoc10-configfiles/base/src/cregistry/sql.c 2010-08-07 20:56:49 UTC (rev 70377)
+++ branches/gsoc10-configfiles/base/src/cregistry/sql.c 2010-08-07 21:02:43 UTC (rev 70378)
@@ -130,7 +130,7 @@
/* file map */
"CREATE TABLE registry.files (id INTEGER, path TEXT, actual_path TEXT, "
- "active INT, mtime DATETIME, md5sum TEXT, editable INT, "
+ "active INT, mtime DATETIME, md5sum TEXT, editable INT, is_config INT, modified INT, "
"FOREIGN KEY(id) REFERENCES ports(id))",
"CREATE INDEX registry.file_port ON files (id)",
"CREATE INDEX registry.file_path ON files(path)",
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-changes/attachments/20100807/97ffcbd8/attachment.html>
More information about the macports-changes
mailing list