4cb493ab92afe6c13f5592880c4f5fbfa371d84c hiram Sun Feb 10 18:48:32 2019 -0800 make the chromosome list a sub-list from the top level refs #18869 diff --git src/hg/hubApi/hubApi.c src/hg/hubApi/hubApi.c index 1639d99..2f75c10 100644 --- src/hg/hubApi/hubApi.c +++ src/hg/hubApi/hubApi.c @@ -65,62 +65,55 @@ static long totalTracks = 0; static boolean measureTiming = FALSE; /* set by CGI parameters */ static boolean allTrackSettings = FALSE; /* checkbox setting */ static char **shortLabels = NULL; /* public hub short labels in array */ struct hubPublic *publicHubList = NULL; static int publicHubCount = 0; static char *defaultHub = "Plants"; static char *defaultDb = "ce11"; static long enteredMainTime = 0; /* will become = clock1000() on entry */ /* to allow calculation of when to bail out, taking too long */ static long timeOutSeconds = 100; static boolean timedOut = FALSE; /* ######################################################################### */ -#ifdef NOT -static void jsonInteger(FILE *f, char *tag, long long value) -/* output one json interger: "tag":value appropriately quoted and encoded */ -{ -fprintf(f,"\"%s\":%lld",tag, value); -} -#endif - static void jsonStringPrint(FILE *f, char *value) /* escape string for output */ { char *a = jsonStringEscape(value); if (isEmpty(a)) fprintf(f, "%s", "null"); else fprintf(f, "\"%s\"", a); freeMem(a); } static void jsonTagValue(FILE *f, char *tag, char *value) /* output one json string: "tag":"value" appropriately quoted and encoded */ { fprintf(f,"\"%s\":",tag); jsonStringPrint(f, value); } static struct jsonWrite *jsonStartOutput() /* begin json output */ { struct jsonWrite *jw = jsonWriteNew(); jsonWriteObjectStart(jw, NULL); -jsonWriteString(jw, "source", "UCSantaCurz"); +jsonWriteString(jw, "version", "0.1"); +jsonWriteString(jw, "source", "UCSantaCruz"); return jw; } static void jsonErrAbort(char *format, ...) /* Issue an error message in json format. */ { char errMsg[2048]; va_list args; va_start(args, format); vsnprintf(errMsg, sizeof(errMsg), format, args); fputc('{',stdout); jsonTagValue(stdout, "error", errMsg); fputc('}',stdout); } @@ -130,53 +123,30 @@ * TODO: need to figure out how to use the order of the columns as * they are in the 'desc' request */ { jsonWriteListStart(jw, NULL); jsonWriteString(jw, NULL, el->hubUrl); jsonWriteString(jw, NULL, el->shortLabel); jsonWriteString(jw, NULL, el->longLabel); jsonWriteString(jw, NULL, el->registrationTime); jsonWriteNumber(jw, NULL, (long long)el->dbCount); jsonWriteString(jw, NULL, el->dbList); jsonWriteString(jw, NULL, el->descriptionUrl); jsonWriteListEnd(jw); } -#ifdef NOT -/* This function should be in hg/lib/hubPublic.c */ -static void hubPublicJsonOutput(FILE *f, struct hubPublic *el) -/* Print out hubPublic element in JSON format. */ -{ -fputc('{',f); -jsonTagValue(f, "hubUrl", el->hubUrl); -fputc(',',f); -jsonTagValue(f, "shortLabel", el->shortLabel); -fputc(',',f); -jsonTagValue(f, "longLabel", el->longLabel); -fputc(',',f); -jsonTagValue(f, "registrationTime", el->registrationTime); -fputc(',',f); -jsonInteger(f, "dbCount", el->dbCount); -fputc(',',f); -jsonTagValue(f, "dbList", el->dbList); -fputc(',',f); -jsonTagValue(f, "descriptionUrl", el->descriptionUrl); -fputc('}',f); -} -#endif - static int publicHubCmpCase(const void *va, const void *vb) /* Compare two slNames, ignore case. */ { const struct hubPublic *a = *((struct hubPublic **)va); const struct hubPublic *b = *((struct hubPublic **)vb); return strcasecmp(a->shortLabel, b->shortLabel); } static void publicHubSortCase(struct hubPublic **pList) /* Sort slName list, ignore case. */ { slSort(pList, publicHubCmpCase); } static struct hubPublic *hubPublicLoad(char **row) @@ -215,42 +185,30 @@ sqlFreeResult(&sr); hDisconnectCentral(&conn); publicHubSortCase(&list); int listSize = slCount(list); AllocArray(shortLabels, listSize); struct hubPublic *el = list; int i = 0; for ( ; el != NULL; el = el->next ) { shortLabels[i++] = el->shortLabel; ++publicHubCount; } return list; } -#ifdef NOT -static void startHtml(char *title) -{ -printf ("\n\n%s\n", title); -} - -static void endHtml() -{ -printf ("\n"); -} -#endif - static boolean timeOutReached() { long nowTime = clock1000(); timedOut = FALSE; if ((nowTime - enteredMainTime) > (1000 * timeOutSeconds)) timedOut= TRUE; return timedOut; } static void trackSettings(struct trackDb *tdb) /* process the settingsHash for a track */ { hPrintf("