src/hg/hgTables/hgTables.c 1.179
1.179 2009/03/17 20:48:36 kent
Starting to add filtering. Collects input now, but doesn't actually run filter.
Index: src/hg/hgTables/hgTables.c
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/hg/hgTables/hgTables.c,v
retrieving revision 1.178
retrieving revision 1.179
diff -b -B -U 4 -r1.178 -r1.179
--- src/hg/hgTables/hgTables.c 17 Mar 2009 18:10:47 -0000 1.178
+++ src/hg/hgTables/hgTables.c 17 Mar 2009 20:48:36 -0000 1.179
@@ -709,8 +709,64 @@
{
return strstr(type, "int") || strstr(type, "float") || strstr(type, "double");
}
+struct sqlFieldType *sqlFieldTypeNew(char *name, char *type)
+/* Create a new sqlFieldType */
+{
+struct sqlFieldType *ft;
+AllocVar(ft);
+ft->name = cloneString(name);
+ft->type = cloneString(type);
+return ft;
+}
+
+void sqlFieldTypeFree(struct sqlFieldType **pFt)
+/* Free resources used by sqlFieldType */
+{
+struct sqlFieldType *ft = *pFt;
+if (ft != NULL)
+ {
+ freeMem(ft->name);
+ freeMem(ft->type);
+ freez(pFt);
+ }
+}
+
+void sqlFieldTypeFreeList(struct sqlFieldType **pList)
+/* Free a list of dynamically allocated sqlFieldType's */
+{
+struct sqlFieldType *el, *next;
+
+for (el = *pList; el != NULL; el = next)
+ {
+ next = el->next;
+ sqlFieldTypeFree(&el);
+ }
+*pList = NULL;
+}
+
+struct sqlFieldType *sqlListFieldsAndTypes(struct sqlConnection *conn, char *table)
+/* Get list of fields including their names and types. The type currently is just
+ * a MySQL type string. */
+{
+struct sqlFieldType *ft, *list = NULL;
+char query[512];
+struct sqlResult *sr;
+char **row;
+safef(query, sizeof(query), "describe %s", table);
+sr = sqlGetResult(conn, query);
+while ((row = sqlNextRow(sr)) != NULL)
+ {
+ ft = sqlFieldTypeNew(row[0], row[1]);
+ slAddHead(&list, ft);
+ }
+sqlFreeResult(&sr);
+slReverse(&list);
+return list;
+}
+
+
struct trackDb *findTrackInGroup(char *name, struct trackDb *trackList,
struct grp *group)
/* Find named track that is in group (NULL for any group).
* Return NULL if can't find it. */