[darwinbuild-changes] [34] trunk/darwinxref

source_changes at macosforge.org source_changes at macosforge.org
Wed Oct 4 01:39:40 PDT 2006


Revision: 34
          http://trac.macosforge.org/projects/darwinbuild/changeset/34
Author:   kevin
Date:     2006-10-04 01:39:40 -0700 (Wed, 04 Oct 2006)

Log Message:
-----------
- added DBHasBuild, DBCopyBuilds, and DBCopyChangedProjectNames API

Modified Paths:
--------------
    trunk/darwinxref/DBDataStore.c
    trunk/darwinxref/DBPlugin.h
    trunk/darwinxref/DBTclPlugin.c

Modified: trunk/darwinxref/DBDataStore.c
===================================================================
--- trunk/darwinxref/DBDataStore.c	2005-07-07 01:43:52 UTC (rev 33)
+++ trunk/darwinxref/DBDataStore.c	2006-10-04 08:39:40 UTC (rev 34)
@@ -184,6 +184,18 @@
 	return 0;
 }
 
+int DBHasBuild(CFStringRef build) {
+	char* cbuild = strdup_cfstr(build);
+	const char* sql = "SELECT 1 FROM properties WHERE build=%Q LIMIT 1";
+	return SQL_BOOLEAN(sql, cbuild);
+}
+
+CFArrayRef DBCopyBuilds() {
+	const char* sql = "SELECT DISTINCT build FROM properties";
+	return SQL_CFARRAY(sql);
+}
+
+
 CFArrayRef DBCopyPropNames(CFStringRef build, CFStringRef project) {
 	char* cbuild = strdup_cfstr(build);
 	char* cproj = strdup_cfstr(project);
@@ -206,6 +218,25 @@
 	return res;
 }
 
+CFArrayRef DBCopyChangedProjectNames(CFStringRef oldbuild, CFStringRef newbuild) {
+	char* coldbuild = strdup_cfstr(oldbuild);
+	char* cnewbuild = strdup_cfstr(newbuild);
+	CFArrayRef res = SQL_CFARRAY(
+		"SELECT DISTINCT new.project AS project FROM properties AS new LEFT JOIN properties AS old "
+			"ON (new.project=old.project AND new.property=old.property AND new.property='version') "
+			"WHERE new.build=%Q AND old.build=%Q "
+			"AND new.value<>old.value "
+		"UNION "
+		"SELECT DISTINCT project FROM properties "
+			"WHERE build=%Q "
+			"AND project NOT IN (SELECT project FROM properties WHERE build=%Q) "
+		"ORDER BY project", cnewbuild, coldbuild, cnewbuild, coldbuild);
+	free(coldbuild);
+	free(cnewbuild);
+	return res;
+}
+
+
 CFTypeID  DBCopyPropType(CFStringRef property) {
 	CFTypeID type = -1;
 	const DBPlugin* plugin = DBGetPluginWithName(property);

Modified: trunk/darwinxref/DBPlugin.h
===================================================================
--- trunk/darwinxref/DBPlugin.h	2005-07-07 01:43:52 UTC (rev 33)
+++ trunk/darwinxref/DBPlugin.h	2006-10-04 08:39:40 UTC (rev 34)
@@ -126,11 +126,15 @@
 // generally available routines
 
 CFStringRef DBGetCurrentBuild();
+int DBHasBuild(CFStringRef build);
+CFArrayRef DBCopyBuilds();
 
 CFTypeID  DBCopyPropType(CFStringRef property);
 CFArrayRef DBCopyPropNames(CFStringRef build, CFStringRef project);
 CFArrayRef DBCopyProjectNames(CFStringRef build);
 
+CFArrayRef DBCopyChangedProjectNames(CFStringRef oldbuild, CFStringRef newbuild);
+
 CFTypeRef DBCopyProp(CFStringRef build, CFStringRef project, CFStringRef property);
 CFStringRef DBCopyPropString(CFStringRef build, CFStringRef project, CFStringRef property);
 CFArrayRef DBCopyPropArray(CFStringRef build, CFStringRef project, CFStringRef property);

Modified: trunk/darwinxref/DBTclPlugin.c
===================================================================
--- trunk/darwinxref/DBTclPlugin.c	2005-07-07 01:43:52 UTC (rev 33)
+++ trunk/darwinxref/DBTclPlugin.c	2006-10-04 08:39:40 UTC (rev 34)
@@ -243,7 +243,38 @@
 	return TCL_OK;
 }
 
+int DBCopyProjectNamesCmd(ClientData data, Tcl_Interp* interp, int objc, Tcl_Obj* CONST objv[]) {
+	if (objc != 2) {
+		Tcl_WrongNumArgs(interp, 1, objv, "build");
+		return TCL_ERROR;
+	}
 
+	CFStringRef build = cfstr_tcl(objv[1]);
+	CFArrayRef array = DBCopyProjectNames(build);
+	if (array) {
+		Tcl_SetObjResult(interp, tcl_cfarray(array));
+		CFRelease(array);
+	}
+	return TCL_OK;
+}
+
+int DBCopyChangedProjectNamesCmd(ClientData data, Tcl_Interp* interp, int objc, Tcl_Obj* CONST objv[]) {
+	if (objc != 3) {
+		Tcl_WrongNumArgs(interp, 1, objv, "oldbuild newbuild");
+		return TCL_ERROR;
+	}
+
+	CFStringRef oldbuild = cfstr_tcl(objv[1]);
+	CFStringRef newbuild = cfstr_tcl(objv[2]);
+	CFArrayRef array = DBCopyChangedProjectNames(oldbuild, newbuild);
+	if (array) {
+		Tcl_SetObjResult(interp, tcl_cfarray(array));
+		CFRelease(array);
+	}
+	return TCL_OK;
+}
+
+
 int load_tcl_plugin(DBPlugin* plugin, const char* filename) {
 	Tcl_Interp* interp = Tcl_CreateInterp();
 
@@ -263,6 +294,9 @@
 	Tcl_CreateObjCommand(interp, "DBCommitTransaction", DBCommitTransactionCmd, (ClientData)plugin, (Tcl_CmdDeleteProc *)NULL);
 	Tcl_CreateObjCommand(interp, "DBRollbackTransaction", DBRollbackTransactionCmd, (ClientData)plugin, (Tcl_CmdDeleteProc *)NULL);
 
+	Tcl_CreateObjCommand(interp, "DBCopyProjectNames", DBCopyProjectNamesCmd, (ClientData)plugin, (Tcl_CmdDeleteProc *)NULL);
+	Tcl_CreateObjCommand(interp, "DBCopyChangedProjectNames", DBCopyChangedProjectNamesCmd, (ClientData)plugin, (Tcl_CmdDeleteProc *)NULL);
+
 	// Source the plugin file
 	Tcl_EvalFile(interp, filename);
 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/darwinbuild-changes/attachments/20061004/c543716f/attachment.html


More information about the darwinbuild-changes mailing list