/* returns an accession from Bioseq; allocates memory! */ CharPtr LIBCALL Misc_GetAccession(BioseqPtr pbs) { SeqIdPtr psi = NULL; SeqIdPtr psiThis = NULL; TextSeqIdPtr ptsi = NULL; CharPtr pacc = NULL; /* SK: NULL ptr check */ if (pbs == NULL) { ErrPostEx(SEV_ERROR,0,0, "Misc_GetAccession: NULL pbs."); return NULL; } psi = pbs->id; if (psi == NULL) { ErrPostEx(SEV_ERROR,0,0, "Misc_GetAccession: NULL Seq-id pointer."); return NULL; } psiThis = psi; while (psiThis != NULL) { if ((psiThis->choice == SEQID_GENBANK) || (psiThis->choice == SEQID_EMBL) || (psiThis->choice == SEQID_PIR) || (psiThis->choice == SEQID_SWISSPROT) || (psiThis->choice == SEQID_OTHER) || (psiThis->choice == SEQID_DDBJ) || (psiThis->choice == SEQID_PRF)) { ptsi = psiThis->data.ptrvalue; if (ptsi == NULL) { ErrPostEx(SEV_ERROR,0,0, "Misc_GetAccession: NULL TextSeq-id pointer."); return FALSE; } if (ptsi->accession != NULL) { pacc = StrSave(ptsi->accession); return pacc; } else { ErrPostEx(SEV_ERROR,0,0, "Misc_GetAccession: NULL pointer to accession."); return NULL; } } psiThis = psiThis->next; } return NULL; }
Int2 BlastFormattingInfoNew(EAlignView align_view, const SBlastOptions* search_options, const char* program_name, const char* db_name, const char* outfile_name, BlastFormattingInfo* *info_ptr) { BlastFormattingInfo* info; if (!outfile_name || !info_ptr || !search_options || align_view >= eAlignViewMax) return -1; info = *info_ptr = (BlastFormattingInfo*) calloc(1, sizeof(BlastFormattingInfo)); s_BlastFormattingOptionsNew(search_options->program, align_view, &info->format_options); info->search_options = search_options; info->program_name = strdup(program_name); if (db_name) info->db_name = strdup(db_name); if (align_view != eAlignViewXml && align_view < eAlignViewAsnText) { FILE* outfp; if ((outfp = FileOpen(outfile_name, "w")) == NULL) { ErrPostEx(SEV_WARNING, 0, 0, "Unable to open output file %s:", outfile_name); return -1; } info->outfp = outfp; } else { char write_mode[3]; /* AsnIoOpen requires a non-const argument, so use a local variable. */ char* filename_copy = strdup(outfile_name); if (align_view == eAlignViewXml) strcpy(write_mode, "wx"); else if (align_view == eAlignViewAsnText) strcpy(write_mode, "w"); else strcpy(write_mode, "wb"); if ((info->aip = AsnIoOpen(filename_copy, write_mode)) == NULL) { ErrPostEx(SEV_WARNING, 0, 0, "Unable to open output file %s:", filename_copy); return -1; } sfree(filename_copy); } info->is_seqalign_null = TRUE; /* will be updated in BLAST_FormatResults */ info->head_on_every_query = FALSE; /* One header for a file is the default. */ return 0; }
/* Replace an SLRI-Taxon record in the database */ Int2 DB_ReplaceTaxRec(SLRITaxonPtr stp) { Int4 bsLength=0; pABL Asnbuflen=NULL; Int4 taxid; CharPtr asn1; SQLHANDLE hstmt; CharPtr update = "update seqhound.taxdb set asn1=? where taxid = ?"; if(stp == NULL) { ErrPostEx(SEV_INFO, 3, 0, "DB_WriteTaxRec: Passed ASN.1 pointer is null."); return(-1); } CreateHandle(&hstmt,update,&henv,&hdbc); /*get the asn1 bioseq into a bytestore pointer so that we can put it into a buffer.*/ Asnbuflen = AssignASNMemChar((Pointer) stp, (AsnWriteFunc) SLRITaxonAsnWrite); /* SK: NULL ptr check */ if(Asnbuflen == NULL) { ErrPostEx(SEV_INFO, 3, 0, "DB_ReplaceTaxRec: NULL Asnbuflen."); return(-1); } asn1 = Asnbuflen->buf; bsLength = Asnbuflen->len; /*set up the input parameters */ SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_DEFAULT,SQL_BLOB, 0, 0, asn1, 0, (long*)&bsLength); SQLBindParameter(hstmt, 2, SQL_PARAM_INPUT, SQL_C_LONG,SQL_INTEGER, 0, 0, &taxid, 0, NULL); taxid = stp->taxId; /* execute statment */ if (SQLExecute (hstmt) != SQL_SUCCESS){ ErrPostEx(SEV_ERROR,0,0, "DB_ReplaceTax: unable to execute insert statement. "); print_err(hstmt); return FALSE; } asn1 = MemFree(asn1); /* pABLtmp->buf = MemFree(pABLtmp->buf);*/ FreeABL(Asnbuflen); if(SQLFreeStmt(hstmt, SQL_DROP) != SQL_SUCCESS){ print_err(hstmt); return FALSE; } return TRUE; }
/* Get a new Tax ID given an old Tax ID from the merged node database */ Int4 DB_GetTaxMergedNodeRecNewTIDByOldTID(Int4 oldTaxId) { CharPtr search_mergeddb = "select new_taxid from seqhound.mergedtaxdb where old_taxid=?"; SQLHANDLE hstmt; Int4 new_value = -1; Int2 sqlrc=SQL_SUCCESS; struct{ Int4 len; Int4 val; }new_id; /* search merged db*/ CreateHandle(&hstmt,search_mergeddb,&henv, &hdbc); SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_LONG,SQL_INTEGER, 0, 0, &oldTaxId, 0, NULL); /* set auto commit on */ SQLSetConnectAttr( hdbc, SQL_ATTR_AUTOCOMMIT, (SQLPOINTER)SQL_AUTOCOMMIT_ON, SQL_NTS); /* execute statment */ if (SQLExecute(hstmt) != SQL_SUCCESS){ ErrPostEx(SEV_ERROR,0,0,"DB_GetTaxMergedNodeRecNewTIDByOldTID:unable to execute select statement."); print_err(hstmt); SQLFreeStmt(hstmt, SQL_DROP); return FALSE; } SQLBindCol(hstmt,1,SQL_C_LONG,&new_id.val,10,(long*)&new_id.len); sqlrc = SQLFetch(hstmt); if(sqlrc == SQL_NO_DATA_FOUND){ ErrPostEx(SEV_INFO, 0, 0, "Old Tax ID: %ld not found in Mergedtaxdb.", oldTaxId); return(-1); } else if(sqlrc == SQL_SUCCESS || sqlrc == SQL_SUCCESS_WITH_INFO){ new_value = new_id.val; } else{ print_err(hstmt); return (-1); } /* Free statement handle. */ if(SQLFreeStmt(hstmt, SQL_DROP) != SQL_SUCCESS){ print_err(hstmt); return (-1); } return(new_value); }
/* returns accession version from Bioseq */ Int2 LIBCALL Misc_GetVersion(BioseqPtr pbs) { SeqIdPtr psi = NULL; SeqIdPtr psiThis = NULL; TextSeqIdPtr ptsi = NULL; /* SK: NULL ptr check */ if (pbs == NULL) { ErrPostEx(SEV_ERROR,0,0, "Misc_GetVersion: NULL pbs."); return INT2_MIN; } psi = pbs->id; if (psi == NULL) { ErrPostEx(SEV_ERROR,0,0, "Misc_GetVersion: NULL Seq-id pointer."); return INT2_MIN; } psiThis = psi; while (psiThis != NULL) { if ((psiThis->choice == SEQID_GENBANK) || (psiThis->choice == SEQID_EMBL) || (psiThis->choice == SEQID_PIR) || (psiThis->choice == SEQID_SWISSPROT) || (psiThis->choice == SEQID_OTHER) || (psiThis->choice == SEQID_DDBJ) || (psiThis->choice == SEQID_PRF)) { ptsi = psiThis->data.ptrvalue; if (ptsi == NULL) { ErrPostEx(SEV_ERROR,0,0, "Misc_GetVersion: NULL TextSeq-id pointer."); return FALSE; } if (ptsi->version != INT2_MIN) return ptsi->version; else { ErrPostEx(SEV_ERROR,0,0, "Misc_GetVersion: No version."); return INT2_MIN; } } psiThis = psiThis->next; } return INT2_MIN; }
NLM_EXTERN Nlm_FloatHi Nlm_GetElapsedTime(Nlm_StopWatchPtr pSW) { Nlm_FloatHi res = 0; #if defined(WIN32) FILETIME ft; if (pSW->start.dwLowDateTime > pSW->stop.dwLowDateTime) { ft.dwLowDateTime = (0xFFFFFFFFL - pSW->start.dwLowDateTime) + 1 + pSW->stop.dwLowDateTime; ft.dwHighDateTime = pSW->stop.dwHighDateTime - pSW->start.dwHighDateTime - 1; } else { ft.dwLowDateTime = pSW->stop.dwLowDateTime - pSW->start.dwLowDateTime; ft.dwHighDateTime = pSW->stop.dwHighDateTime - pSW->start.dwHighDateTime; } return res = (Nlm_FloatHi)ft.dwHighDateTime/5000000L*0x80000000L + (Nlm_FloatHi)ft.dwLowDateTime/10000000L; #elif defined(OS_UNIX) res = ((Nlm_FloatHi)pSW->stop - pSW->start) / pSW->rate; #else ErrPostEx(SEV_WARNING, 0, 0, "StopWatch is not implemented for this platform"); #endif return res; }
static void SaveSeqLocEntity (Uint2 entityID, SelectedSavePtr ssp) { ObjMgrDataPtr omdp; ObjMgrTypePtr omtp; if (entityID == 0 || ssp == NULL) { return; } omdp = ObjMgrGetDataStruct (ssp->omp, entityID); if (omdp == NULL) return; if (omdp->choicetype == OBJ_SEQENTRY || omdp->datatype != OBJ_SEQLOC) { return; /* not seqloc */ } omtp = ObjMgrTypeFind(ssp->omp, OBJ_SEQLOC, NULL, NULL); if (omtp == NULL) { ErrPostEx(SEV_ERROR,0,0,"Can't locate type record for [%d]", (int)OBJ_SEQLOC); return; } (*(omtp->asnwrite))(omdp->dataptr, ssp->aip, NULL); AsnPrintNewLine (ssp->aip); AsnIoFlush (ssp->aip); }
static Boolean SaveOneSelectedItem (GatherObjectPtr gop) { SelectedSavePtr ssp; SelStructPtr sel; ObjMgrTypePtr omtp; if (gop == NULL || gop->dataptr == NULL) return TRUE; ssp = (SelectedSavePtr) gop->userdata; if (ssp == NULL || ssp->aip == NULL || ssp->ssp == NULL) return TRUE; sel = ssp->ssp; while (sel != NULL && (sel->entityID != gop->entityID || sel->itemtype != gop->itemtype || sel->itemID != gop->itemID)) { sel = sel->next; } if (sel == NULL) return TRUE; omtp = ObjMgrTypeFind(ssp->omp, sel->itemtype, NULL, NULL); if (omtp == NULL) { ErrPostEx(SEV_ERROR,0,0,"Can't locate type record for [%d]", (int)sel->itemtype); return TRUE; } (*(omtp->asnwrite))(gop->dataptr, ssp->aip, NULL); AsnPrintNewLine (ssp->aip); AsnIoFlush (ssp->aip); return TRUE; }
/* Clears all items in StringStack */ Int4 SLRI_SSClear(SLRI_SStackPtr ssp) { SLRI_SStackItemPtr ssipCurr = NULL; SLRI_SStackItemPtr ssipTemp = NULL; if (ssp == NULL) { ErrPostEx(SEV_ERROR, 0, 0, "SLRI_SSClear: stack pointer is NULL"); return(-1); } ssipCurr = ssp->top; while (ssipCurr != NULL) { ssipTemp = ssipCurr->prev; ssipCurr = MemFree(ssipCurr); ssipCurr = ssipTemp; } /* Re-initialize pointers */ ssp->totalStackSize = 0; ssp->totalNumItems = 0; ssp->top = NULL; ssp->bottom = NULL; return(0); }
/* Returns a concatenation of all stack contents */ CharPtr SLRI_SSGetWholeString(SLRI_SStackPtr ssp) { SLRI_SStackItemPtr ssipCurr = NULL; CharPtr wholeString = NULL; if (ssp == NULL) { ErrPostEx(SEV_ERROR, 0, 0, "SLRI_SSGetWholeString: stack pointer is NULL"); return(NULL); } if (SLRI_SSIsEmpty(ssp)) { return(NULL); } wholeString = MemNew((ssp->totalStackSize + 1) * sizeof(Char)); /* Initialize wholeString with first item */ StringCpy(wholeString, ssp->bottom->string); /* Cycle through rest of stack to get remaining items */ ssipCurr = ssp->bottom->next; while (ssipCurr != NULL) { StringCat(wholeString, ssipCurr->string); ssipCurr = ssipCurr->next; } return(wholeString); }
/* Pushes a StringStack item onto StringStack */ Int4 SLRI_SSPush(SLRI_SStackPtr ssp, CharPtr string) { SLRI_SStackItemPtr newItem = NULL; if (ssp == NULL) { ErrPostEx(SEV_ERROR, 0, 0, "SLRI_SSPush: stack pointer is NULL"); return(-1); } newItem = MemNew(sizeof(SLRI_SStackItem)); newItem->string = string; newItem->prev = ssp->top; newItem->next = NULL; if (ssp->top != NULL) { ssp->top->next = newItem; } ssp->top = newItem; ssp->totalStackSize += StringLen(newItem->string); ssp->totalNumItems++; /* If first item, set bottom pointer to top */ if (ssp->bottom == NULL) { ssp->bottom = ssp->top; } return(0); }
NLM_EXTERN Nlm_CPUTimePtr Nlm_CPUTimeMeasure(void) { #if defined(WIN32) || defined(OS_UNIX) Nlm_CPUTimePtr pTime = (Nlm_CPUTimePtr) Nlm_MemNew(sizeof(Nlm_CPUTime)); if (pTime != NULL) { #endif #if defined(WIN32) GetProcessTimes(GetCurrentProcess(), &pTime->crtime, &pTime->extime, &pTime->systime, &pTime->usrtime ); #elif defined(OS_UNIX) times(&pTime->times); pTime->rate = sysconf(_SC_CLK_TCK); #else ErrPostEx(SEV_WARNING, 0, 0, "CPU time measuring is not implemented for this platform"); return NULL; #endif #if defined(WIN32) || defined(OS_UNIX) } return pTime; #endif }
/*************************************************************************** * CkQualEcnum: * -- Ec_num has text format, * but the text only allow digits, period, and hyphen (-) * 12-10-93 ****************************************************************************/ NLM_EXTERN int CkQualEcnum( GBQualPtr PNTR head_gbqp, GBQualPtr gbqp, GBQualPtr preq, Boolean error_msgs, Boolean perform_corrections ) { CharPtr str; int retval = GB_FEAT_ERR_NONE; retval = CkQualText(head_gbqp, gbqp, preq, NULL, FALSE, error_msgs, perform_corrections); if (retval == GB_FEAT_ERR_NONE){ str = gbqp->val; /* open double quote */ while (*str != '\0' && (*str == ' ' || *str == '\"')) str++; for (; *str != '\0' && *str != '\"'; str++) if (!IS_DIGIT(*str) && *str != '.' && *str != '-') { if (error_msgs){ ErrPostEx(SEV_ERROR, ERR_QUALIFIER_BadECnum, "At <%c>(%d) /%s=%s", *str, (int) *str, gbqp->qual,gbqp->val); } retval = GB_FEAT_ERR_DROP; if (perform_corrections){ DeleteGBQualFromList(head_gbqp, gbqp, preq); } break; } } return retval; } /* CkQualEcnum */
NLM_EXTERN MonitorPtr LIBCALL Nlm_MonitorIntNewEx (Nlm_CharPtr title, Nlm_Int4 n1, Nlm_Int4 n2, Nlm_Boolean hasCancelBtn) { AppMsgInfo *info = GetAppMsgInfo(); Monitor *pMon = (Monitor*) MemNew(sizeof(Monitor)); if (pMon != NULL) { MON_SET_MAGIC(pMon); pMon->type = MonType_Int; pMon->strTitle = title ? StrSave(title) : 0; pMon->num1 = n1; pMon->num2 = n2; pMon->cancel = FALSE; pMon->hasCancelBtn = (int) hasCancelBtn; if (!(*info->hookMonitor)(pMon,MonCode_Create)) { MonitorFree(pMon); /* only post an information message here; it is expected that the hook function would report the real reason that the monitor creation failed. */ ErrPostEx(SEV_INFO,0,0,"Unable to create monitor"); return NULL; } } return pMon; }
NLM_EXTERN int CkQualPosSeqaa(GBQualPtr PNTR head_gbqp, GBQualPtr gbqp, GBQualPtr preq, Boolean error_msgs, Boolean perform_corrections, CharPtr aa, CharPtr eptr) { CharPtr str; int retval = GB_FEAT_ERR_NONE; DelTailBlank(aa); if (ValidAminoAcid(aa) != 255) { str = eptr; while (*str != '\0' && (*str == ' ' || *str == ')')) str++; if (*str == '\0') { MemFree(aa); return retval; /* successful, format ok return */ } else { MemFree(aa); if (error_msgs){ ErrPostEx(SEV_ERROR, ERR_QUALIFIER_AA, "Extra text after end /%s=%s",gbqp->qual,gbqp->val); } retval = GB_FEAT_ERR_DROP; if (perform_corrections){ DeleteGBQualFromList(head_gbqp, gbqp, preq); } } } else { if (error_msgs){ ErrPostEx(SEV_ERROR, ERR_QUALIFIER_AA, "Bad aa abbreviation<%s>, /%s=%s", aa, gbqp->qual,gbqp->val); } retval = GB_FEAT_ERR_DROP; if (perform_corrections){ DeleteGBQualFromList(head_gbqp, gbqp, preq); } } return retval; }
/***************************************************************************** * FileWrite(buf, size, fp) *****************************************************************************/ NLM_EXTERN size_t LIBCALL Nlm_FileWrite (const void *ptr, size_t size, size_t n, FILE *stream) { size_t cnt; if (n && (SIZE_MAX / n) < size) { ErrPostEx(SEV_WARNING,E_Programmer,0,"FileWrite: size > SIZE_MAX"); return 0; } if (!ptr || !stream || !size) return 0; cnt = fwrite(ptr,size,n,stream); if (cnt != n) ErrPostEx(SEV_FATAL,E_File,E_FWrite,"File write error"); return cnt; }
/* -- SSH -- Create file <database_name> (without extention), which is concatenation of all FASTA files used. Used by RPS Blast. */ Boolean RPSConcatSequences(FILE *sfp, CharPtr fastaname) { FILE *fasta_fp, *fd; Char oneFileName[MAXLINELEN]; /*for reading one line per file*/ Char buffer[1024]; Int4 bytes; CharPtr chptr, last_non_space; if((fasta_fp = FileOpen(fastaname, "w")) == NULL) { ErrPostEx(SEV_FATAL, 1, 0, "concatenate sequences: " "Unable to open target fasta file %s: %s\n", fastaname, strerror(errno)); return FALSE; } rewind(sfp); while (fgets(oneFileName, MAXLINELEN, sfp)) { /* Remove trailing whitespace */ last_non_space = NULL; for(chptr = oneFileName; *chptr != NULLB; chptr++) { if (!isspace(*chptr)) last_non_space = chptr; } if (last_non_space != NULL) last_non_space[1] = NULLB; if((fd = FileOpen(oneFileName, "r")) == NULL) { ErrPostEx(SEV_FATAL, 1, 0, "concatenate sequences: " "Unable to open source fasta file %s: %s\n", oneFileName, strerror(errno)); FileClose(fasta_fp); return FALSE; } /* Now concatenating this file into set */ while((bytes = FileRead(buffer, 1, 1024, fd)) > 0) FileWrite(buffer, 1, bytes, fasta_fp); FileClose(fd); } FileClose(fasta_fp); return TRUE; }
NLM_EXTERN Nlm_Boolean LIBCALL Nlm_MonitorIntValue (MonitorPtr pMon, Nlm_Int4 ival) { AppMsgInfo *info = GetAppMsgInfo(); if ( !MON_IS_VALID(pMon) ) { ErrPostEx(SEV_WARNING,0,0,"MonitorIntValue: %s",_invalid_mon); return FALSE; } if (pMon->type != MonType_Int) { ErrPostEx(SEV_WARNING,0,0,"MonitorStrValue: %s",_invalid_type); return (Nlm_Boolean)(!pMon->cancel); } pMon->intValue = ival; (*info->hookMonitor)(pMon,MonCode_IntValue); return (Nlm_Boolean)(!pMon->cancel); }
Int2 LIBCALLBACK VSMFastaSortedProtSave (Pointer data) { OMProcControlPtr ompcp; Char filename[255]; FILE * fp; ValNode vn; SeqEntryPtr sep = NULL; ompcp = (OMProcControlPtr)data; if (ompcp == NULL) return OM_MSG_RET_ERROR; switch(ompcp->input_itemtype) { case OBJ_SEQENTRY: case OBJ_BIOSEQ: case OBJ_BIOSEQSET: break; default: ErrPostEx(SEV_ERROR, 0,0,"ToFasta: Can only write Seq-entry, Bioseq, or Bioseq-set"); return OM_MSG_RET_ERROR; } if (ompcp->input_choicetype == OBJ_SEQENTRY) sep = (SeqEntryPtr)(ompcp->input_choice); else { vn.next = NULL; vn.data.ptrvalue = ompcp->input_data; if (ompcp->input_itemtype == OBJ_BIOSEQ) vn.choice = 1; else vn.choice = 2; sep = &vn; } filename[0] = '\0'; if (GetOutputFileName(filename, (size_t)254, NULL)) { WatchCursor(); #ifdef WIN_MAC fp = FileOpen (filename, "r"); if (fp != NULL) { FileClose (fp); } else { FileCreate (filename, "TEXT", "ttxt"); } #endif fp = FileOpen(filename, "w"); WriteSortedProteinsToFile (fp, sep); FileClose(fp); ArrowCursor(); } return OM_MSG_RET_DONE; }
NLM_EXTERN Nlm_CPUTimePtr Nlm_CPUTimeFree(Nlm_CPUTimePtr pTime) { #if defined(WIN32) || defined(OS_UNIX) return (Nlm_CPUTimePtr) Nlm_MemFree(pTime); #else ErrPostEx(SEV_WARNING, 0, 0, "CPU time measuring is not implemented for this platform"); return NULL; #endif }
/***************************************************************************** * * FilePuts(ptr, fp) * *****************************************************************************/ NLM_EXTERN int LIBCALL Nlm_FilePuts (const char *ptr, FILE *fp) { int retval; if ((ptr == NULL) || (fp == NULL)) return EOF; if ((retval = fputs(ptr,fp)) ==EOF) ErrPostEx(SEV_FATAL,E_File,E_FWrite,"File write error"); return retval; }
/* Write an SLRITaxonGencode record to the database */ Int2 DB_WriteTaxGenCodeRec(SLRITaxonGencodePtr stgp) { Int4 bsLength=0; Int4 gencode_id; CharPtr asn1; pABL Asnbuflen=NULL; if(stgp == NULL) { ErrPostEx(SEV_INFO, 3, 0, "DB_WriteTaxGenCodeRec: Passed ASN.1 pointer is null."); return(-1); } /*get the asn1 bioseq into a bytestore pointer so that we can put it into a buffer.*/ Asnbuflen = AssignASNMemChar((Pointer) stgp, (AsnWriteFunc) SLRITaxonGencodeAsnWrite); /* SK: NULL ptr check */ if(Asnbuflen == NULL) { ErrPostEx(SEV_INFO, 3, 0, "DB_WriteTaxGenCodeRec: NULL Asnbuflen."); return(-1); } asn1 = Asnbuflen->buf; bsLength = Asnbuflen->len; /*set up the input parameters */ SQLBindParameter(hstmt_gcode, 1, SQL_PARAM_INPUT, SQL_C_LONG,SQL_INTEGER, 0, 0, &gencode_id, 0, NULL); SQLBindParameter(hstmt_gcode, 2, SQL_PARAM_INPUT, SQL_C_DEFAULT,SQL_BLOB, 0, 0, asn1, 0, (long*)&bsLength); gencode_id = stgp->gencode_id; /* execute statment */ if (SQLExecute (hstmt_gcode) != SQL_SUCCESS){ ErrPostEx(SEV_ERROR,0,0, "DB_WriteTaxGenCodeRec: unable to execute insert statement. "); print_err(hstmt_gcode); return FALSE; } asn1 = MemFree(asn1); /* pABLtmp->buf = MemFree(pABLtmp->buf);*/ FreeABL(Asnbuflen); return TRUE; }
NLM_EXTERN Nlm_StopWatchPtr Nlm_StopWatchFree(Nlm_StopWatchPtr pStopWatch) { #if defined(WIN32) || defined(OS_UNIX) return (Nlm_StopWatchPtr) Nlm_MemFree(pStopWatch); #else ErrPostEx(SEV_WARNING, 0, 0, "StopWatch is not implemented for this platform"); return NULL; #endif }
NLM_EXTERN Nlm_Boolean LIBCALL Nlm_MonitorStrValue (MonitorPtr pMon, Nlm_CharPtr sval) { AppMsgInfo *info = GetAppMsgInfo(); if ( ! MON_IS_VALID(pMon) ) { ErrPostEx(SEV_WARNING,0,0,"MonitorStrValue: %s",_invalid_mon); return FALSE; } if (pMon->type != MonType_Str) { ErrPostEx(SEV_WARNING,0,0,"MonitorStrValue: %s",_invalid_type); return (Nlm_Boolean)(!pMon->cancel); } if (pMon->strValue) MemFree((void*)pMon->strValue); pMon->strValue = sval ? StrSave(sval) : 0; (*info->hookMonitor)(pMon,MonCode_StrValue); return (Nlm_Boolean)(!pMon->cancel); }
Boolean LIBCALL VASTInit (void) { GetAppParam("mmdb", "VAST", "Database", "", database, PATH_MAX); if (database[0] == NULL) { ErrPostEx(SEV_FATAL,0,0, "MMDB config file / path to VAST data missing.\n"); return FALSE; } return TRUE; }
/***************************************************************************** * FileRead(buf, size, fp) *****************************************************************************/ NLM_EXTERN size_t LIBCALL Nlm_FileRead (void *ptr, size_t size, size_t n, FILE *stream) { if (n && (SIZE_MAX / n) < size) { ErrPostEx(SEV_WARNING,E_Programmer,0,"FileRead: size > SIZE_MAX"); return 0; } if (!ptr || !stream) return 0; return fread(ptr,size,n,stream); }
BiostrucAnnotSetPtr LIBCALL VASTBsAnnotSetGet (Int4 uid) { AsnIoPtr aip = NULL; AsnTypePtr atp = NULL; Char path[PATH_MAX]; Char compath[PATH_MAX]; Char tempfile[PATH_MAX]; Char pcId[20]; Int2 iFileExists = 0; BiostrucAnnotSetPtr pbsa = NULL; int iAvail = 1; FILE *pipe; sprintf(pcId, "%ld", (long) uid); path[0] = '\0'; StringCpy(path, database); StringCat(path, pcId); StringCat(path, ".bas"); #ifdef MMDB_UNIXCOMPRESSED compath[0] = '\0'; sprintf(compath, "%s -d -c %s.gz ", gunzip, path); pipe = popen(compath, "rb"); if (pipe == NULL) { ErrPostEx(SEV_FATAL,0,0, "VASTBsAnnotSetGet failed: Can't find gunzip in path.\n"); return NULL; } aip = AsnIoNew(ASNIO_BIN_IN, pipe, NULL, NULL, NULL); #else iFileExists = FileLength(path); if (iFileExists == 0) { return NULL; } aip = AsnIoOpen(path, "rb"); #endif if (aip) { pbsa = BiostrucAnnotSetAsnRead(aip, NULL); AsnIoClose (aip); } #ifdef MMDB_UNIXCOMPRESSED pclose(pipe); #endif if (!pbsa) return NULL; return pbsa; }
static ID1serverBackPtr NetID1servReadAsn(void) { ID1serverBackPtr id1bp=NULL; id1bp = ID1serverBackAsnRead(asnin, NULL); if (!id1bp) { ErrPostEx(SEV_ERROR, 0, 0, "Null message read from server"); } return id1bp; }
NLM_EXTERN Nlm_FloatHi Nlm_CPUTimeGetUser(Nlm_CPUTimePtr pTime) { #if defined(WIN32) return (Nlm_FloatHi)pTime->usrtime.dwHighDateTime * 0x80000000L/5000000L + (Nlm_FloatHi)pTime->usrtime.dwLowDateTime / 10000000L; #elif defined(OS_UNIX) return (Nlm_FloatHi)pTime->times.tms_utime / pTime->rate; #else ErrPostEx(SEV_WARNING, 0, 0, "CPU time measuring is not implemented for this platform"); return 0; #endif }
/*============================================================================*\ * Function: * SuggestInit * * Purpose: * Initializes Suggest API * * Parameters: * none * * Return: * TRUE if successful, FALSE otherwise * \*----------------------------------------------------------------------------*/ Boolean SuggestInit(void) { SuggestRequestPtr pRequest; SuggestResponsePtr pResponse; /* myNetInit = SuggestInit; */ if (!NetInit()) return FALSE; svcp = NI_GenericGetService(dispatcher, NULL, "SUGGEST", "Suggest", TRUE); if (svcp == NULL) { ErrPostEx(SEV_ERROR, 0, 0, "NI_ServiceGet [%s] (%s)", ni_errlist[ni_errno], ni_errtext); SuggestFini(); return FALSE; } pAsnIn = svcp->raip; pAsnOut = svcp->waip; pRequest = ValNodeNew(NULL); pRequest->choice = SuggestRequest_init; SuggestRequestAsnWrite (pRequest, pAsnOut, NULL); AsnIoReset(pAsnOut); SuggestRequestFree(pRequest); if ((pResponse = NetSuggestReadAsn()) == NULL) { return FALSE; } if (pResponse->choice == SuggestResponse_error) { ErrorFromServer(pResponse->data.ptrvalue); if (((SuggestErrorPtr)pResponse->data.ptrvalue)->level == Suggest_error_level_fatal) bSendFini = FALSE; SuggestFini(); SuggestResponseFree(pResponse->data.ptrvalue); return FALSE; } pResponse->data.ptrvalue = NULL; SuggestResponseFree(pResponse); return TRUE; }