5294e72024937d44e0e13e4f55ba408f351c2ac2 hiram Tue Apr 16 10:27:14 2019 -0700 updated error messages and error testing refs #18869 diff --git src/hg/hubApi/dataApi.h src/hg/hubApi/dataApi.h index a6e7e4b..a2122f9 100644 --- src/hg/hubApi/dataApi.h +++ src/hg/hubApi/dataApi.h @@ -24,49 +24,67 @@ #include "obscure.h" #include "errCatch.h" #include "vcf.h" #include "bedTabix.h" #include "bamFile.h" #include "jsonParse.h" #include "jsonWrite.h" #include "chromInfo.h" #include "wiggle.h" #include "hubPublic.h" #ifdef USE_HAL #include "halBlockViz.h" #endif +/* error return codes */ +#define err400 400 +#define err400Msg "Bad Request" +#define err404 404 +#define err404Msg "Not Found" +#define err429 429 +#define err429Msg "Two Many Requests" + +/* maximum number of words expected in PATH_INFO parsing + * so far only using 2 + */ #define MAX_PATH_INFO 32 +/* maximum amount of DNA allowed in a get sequence request */ +#define MAX_DNA_LENGTH 499999999 +/* this size is directly related to the max limit in needMem used in + * jsonWriteString + */ + /* limit amount of output to a maximum to avoid overload */ extern int maxItemsOutput; /* can be set in URL maxItemsOutput=N */ /* for debugging purpose, current bot delay value */ extern int botDelay; boolean debug; /* can be set in URL debug=1, to turn off: debug=0 */ /* default is to list all trackDb entries, composite containers too. * This option will limit to only the actual track entries with data */ extern boolean trackLeavesOnly; /* set by CGI parameter 'trackLeavesOnly' */ /* functions in hubApi.c */ struct hubPublic *hubPublicDbLoadAll(); struct dbDb *ucscDbDb(); /* return the dbDb table as an slList */ +/* ######################################################################### */ /* functions in apiUtils.c */ void apiFinishOutput(int errorCode, char *errorString, struct jsonWrite *jw); /* finish json output, potential output an error code other than 200 */ void apiErrAbort(int errorCode, char *errString, char *format, ...); /* Issue an error message in json format, and exit(0) */ struct jsonWrite *apiStartOutput(); /* begin json output with standard header information for all requests */ extern char *jsonTypeStrings[]; #define JSON_STRING 0 // "string", /* type 0 */ #define JSON_NUMBER 1 // "number", /* type 1 */ #define JSON_OBJECT 2 // "object", /* type 2 */ #define JSON_ARRAY 3 // "array", /* type 3 */ @@ -91,28 +109,36 @@ struct trackDb *findTrackDb(char *track, struct trackDb *tdb); /* search tdb structure for specific track, recursion on subtracks */ struct bbiFile *bigFileOpen(char *trackType, char *bigDataUrl); /* open bigDataUrl for correct trackType and error catch if failure */ int chromInfoCmp(const void *va, const void *vb); /* Compare to sort based on size */ boolean allowedBigBedType(char *type); /* return TRUE if the big* type is to be supported * add to this list as the big* supported types are expanded */ +// unsigned largestChrom(char *db, char **nameReturn, int *chromCount); +/* return the length and get the chrom name for the largest chrom + * from chromInfo table. For use is sample getData URLs + */ + +// unsigned largestChromInfo(struct chromInfo *ci, char **chromName); +/* find largest chrom in this chromInfo, return name and size */ + /* ######################################################################### */ /* functions in getData.c */ void apiGetData(char *words[MAX_PATH_INFO]); /* 'getData' function, words[1] is the subCommand */ /* ######################################################################### */ /* functions in list.c */ void apiList(char *words[MAX_PATH_INFO]); /* 'list' function words[1] is the subCommand */ #endif /* DATAAPH_H */