void sendFileByAcc(struct sqlConnection *conn, char* acc) /* send file identified by acc (=cdwValidFile.licensePlate), suggests a canonical filename of the format * <licensePlate>.<originalExtension> * Example URL: http://hgwdev.soe.ucsc.edu/cgi-bin/cdwGetFile?acc=SCH000FSW */ { struct cdwValidFile *vf = cdwValidFileFromLicensePlate(conn, acc); if (vf==NULL) errExit("%s is not a valid accession in the CDW.", acc); struct cdwFile *ef = cdwFileFromId(conn, vf->fileId); char* filePath = cdwPathForFileId(conn, vf->fileId); mustHaveAccess(conn, ef); // use the license plate as the basename of the downloaded file. // Take the extension from the submitted filename, as cdwFile.format is not the same as the extension // e.g. format=fasta -> fa.gz char *submitExt = skipBeyondDelimit(basename(ef->submitFileName), '.'); char suggestName[8000]; safef(suggestName, sizeof(suggestName), "%s.%s", vf->licensePlate, submitExt); apacheSendX(vf->format, filePath, suggestName); }
void warnWithBackTrace(char *format, ...) /* Issue a warning message and append backtrace. */ { va_list args; va_start(args, format); struct dyString *dy = newDyString(255); dyStringAppend(dy, format); #define STACK_LIMIT 20 char **strings = NULL; int count = 0; // developer: this is an occasionally useful means of getting stack info without crashing // however, it is not supported on cygwin. Conditionally compile this in when desired. // The define is at top to include execinfo.h #ifdef BACKTRACE_EXISTS void *buffer[STACK_LIMIT]; count = backtrace(buffer, STACK_LIMIT); strings = backtrace_symbols(buffer, count); #endif///def BACKTRACE_EXISTS if (strings == NULL) dyStringAppend(dy,"\nno backtrace_symbols available in errabort::warnWithBackTrace()."); else { int ix = 1; dyStringAppend(dy,"\nBACKTRACE (use on cmdLine):"); if (strings[1] != NULL) { strSwapChar(strings[1],' ','\0'); dyStringPrintf(dy,"\naddr2line -Cfise %s",strings[1]); strings[1] += strlen(strings[1]) + 1; } for (; ix < count && strings[ix] != NULL; ix++) { strings[ix] = skipBeyondDelimit(strings[ix],'['); strSwapChar(strings[ix],']','\0'); dyStringPrintf(dy," %s",strings[ix]); } free(strings); } vaWarn(dyStringCannibalize(&dy), args); va_end(args); }