2817c6f81dd844b54f6232d688c001e6a12f9ebb hiram Wed Feb 13 11:17:54 2019 -0800 beginning to partition the code out to files refs #18869 diff --git src/hg/hubApi/hubApi.c src/hg/hubApi/hubApi.c index 96ba815..cb478e5 100644 --- src/hg/hubApi/hubApi.c +++ src/hg/hubApi/hubApi.c @@ -1,16 +1,18 @@ /* hubApi - access mechanism to hub data resources. */ +#include "dataApi.h" +#ifdef NOT #include "common.h" #include "linefile.h" #include "hash.h" #include "options.h" #include "jksql.h" #include "htmshell.h" #include "web.h" #include "cheapcgi.h" #include "cart.h" #include "hui.h" #include "udc.h" #include "knetUdc.h" #include "genbank.h" #include "trackHub.h" #include "hgConfig.h" @@ -19,30 +21,32 @@ #include "bigWig.h" #include "hubConnect.h" #include "obscure.h" #include "errCatch.h" #include "vcf.h" #include "bedTabix.h" #include "bamFile.h" #include "jsonParse.h" #include "jsonWrite.h" #include "chromInfo.h" #ifdef USE_HAL #include "halBlockViz.h" #endif +#endif + /* +------------------+------------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +------------------+------------------+------+-----+---------+-------+ | hubUrl | longblob | NO | PRI | NULL | | | shortLabel | varchar(255) | NO | | NULL | | | longLabel | varchar(255) | NO | | NULL | | | registrationTime | varchar(255) | NO | | NULL | | | dbCount | int(10) unsigned | NO | | NULL | | | dbList | blob | YES | | NULL | | | descriptionUrl | longblob | YES | | NULL | | +------------------+------------------+------+-----+---------+-------+ */ struct hubPublic @@ -63,59 +67,61 @@ static struct hash *oldVars = NULL; static struct hash *trackCounter = NULL; 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 struct jsonWrite *jsonStartOutput() /* begin json output with standard header information for all requests */ { time_t timeNow = time(NULL); // struct tm tm; // gmtime_r(&timeNow, &tm); struct jsonWrite *jw = jsonWriteNew(); jsonWriteObjectStart(jw, NULL); jsonWriteString(jw, "apiVersion", "0.1"); jsonWriteString(jw, "source", "UCSantaCruz"); jsonWriteDateFromUnix(jw, "downloadTime", (long long) timeNow); jsonWriteNumber(jw, "downloadTimeStamp", (long long) timeNow); return jw; } static void jsonErrAbort(char *format, ...) /* Issue an error message in json format, and exit(0) */ { char errMsg[2048]; va_list args; va_start(args, format); vsnprintf(errMsg, sizeof(errMsg), format, args); struct jsonWrite *jw = jsonStartOutput(); jsonWriteString(jw, "error", errMsg); jsonWriteObjectEnd(jw); fputs(jw->dy->string,stdout); exit(0); } +#endif static void hubPublicJsonData(struct jsonWrite *jw, struct hubPublic *el) /* Print array data for one row from hubPublic table, order here * must be same as was stated in the columnName header element * 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); @@ -765,30 +771,31 @@ char *dataTime = sqlTableUpdate(conn, "trackDb"); time_t dataTimeStamp = sqlDateToUnixTime(dataTime); replaceChar(dataTime, ' ', 'T'); hFreeConn(&conn); struct trackDb *tdbList = hTrackDb(db); struct jsonWrite *jw = jsonStartOutput(); jsonWriteString(jw, "db", db); jsonWriteString(jw, "dataTime", dataTime); jsonWriteNumber(jw, "dataTimeStamp", (long long)dataTimeStamp); freeMem(dataTime); recursiveTrackList(jw, tdbList, "tracks"); jsonWriteObjectEnd(jw); fputs(jw->dy->string,stdout); } /* static void trackDbJsonOutput(char *db, FILE *f) */ +#ifdef NOT static void getTrackData() { } static void getSequenceData() /* given at least a db=name and chrom=chr, optionally start and end */ { char *db = cgiOptionalString("db"); char *chrom = cgiOptionalString("chrom"); char *start = cgiOptionalString("start"); char *end = cgiOptionalString("end"); if (isEmpty(db)) jsonErrAbort("missing URL db= name for endpoint '/getData/sequence"); if (isEmpty(chrom)) @@ -812,30 +819,31 @@ jsonWriteNumber(jw, "end", (long long)ci->size); } else { jsonWriteNumber(jw, "start", (long long)sqlSigned(start)); jsonWriteNumber(jw, "end", (long long)sqlSigned(end)); } jsonWriteString(jw, "dna", seq->dna); jsonWriteObjectEnd(jw); fputs(jw->dy->string,stdout); freeDnaSeq(&seq); } else jsonErrAbort("can not find specified chrom=%s in sequence for endpoint '/getData/sequence?db=%s&chrom=%s", chrom, db, chrom); } +#endif #define MAX_PATH_INFO 32 static void apiGetData(char *words[MAX_PATH_INFO]) /* 'getData' function, words[1] is the subCommand */ { if (sameWord("track", words[1])) getTrackData(); else if (sameWord("sequence", words[1])) getSequenceData(); else jsonErrAbort("do not recognize endpoint function: '/%s/%s'", words[0], words[1]); } static void apiList(char *words[MAX_PATH_INFO]) /* 'list' function words[1] is the subCommand */