void addData() { FILE_ID fileid; float buf1[BUF_SIZE]; float buf2[BUF_SIZE]; int i; for (i=0;i<BUF_SIZE;i++) { buf1[i]=i; buf2[i]=i*2;//ff } fileid = DB_Open("/home/openrisc/junk.mbt"); DB_SetColumn(fileid,"EUR_USD",0); DB_SetColumn(fileid,"EUR_CAD",1); //// DB_SetFilePointer(fileid,100); // DB_ReadBuffer(fileid); DB_WriteColumn(0,buf1,BUF_SIZE,0); DB_WriteColumn(1,buf2,BUF_SIZE,0); //// DB_WriteBuffer(fileid); DB_Close(fileid); }
main(int argc, char *argv[]) { CONDITION ret; short id; char patid[50], studyuid[50], seriesuid[50], imageuid[50], dbname[50]; if (argc != 6) { printf("Usage: %s ImageUID PatID StudyUID SeriesUID dbname\n", argv[0]); exit(0); } strcpy(imageuid, argv[1]); strcpy(patid, argv[2]); strcpy(studyuid, argv[3]); strcpy(seriesuid, argv[4]); strcpy(dbname, argv[5]); printf(" ImageUID: %s\n", imageuid); printf("patient id: %s\n", patid); printf(" study uid: %s\n", studyuid); printf("series uid: %s\n", seriesuid); printf(" DB Name: %s\n", dbname); if (DB_Open(dbname, &id) == DB_NORMAL) printf("DB_Open succeeded\n"); else { printf("DB_Open failed\n"); exit(1); } if ((ret = DB_DelImage(id, patid, studyuid, seriesuid, imageuid)) == DB_NORMAL) printf("%s succeeded\n", argv[0]); else printf("Another error occurred: %08x\n", ret); if (DB_Close(id) == DB_NORMAL) printf("DB_Close succeeded\n"); else exit(0); }
/******************************************************************** * connection을 새로 Attach한다. * 이미 사용중인 connection 및 Recordset는 닫는다. * * return : None * * parameter : * [in] _ConnectionPtr conn : 사용할 Connection Object ********************************************************************/ void CAdo::DB_AttachConnection(_ConnectionPtr conn) { if(m_IsDBOpen == TRUE) DB_Close(); if(m_IsDBConn == TRUE) { DB_CloseConnection(); m_pCON.Release(); } m_pCON = conn; m_IsDBConn = TRUE; }
/******************************************************************** * 연결 문자열을 만든다. * 기존 파일명과 틀릴때에만 connection을 닫고, 연결문자열을 만든다. * * return : BOOL : TRUE | FALSE * * parameter : * [in] CString Filename : MDB 파일명 ********************************************************************/ BOOL CAdo::DB_Init(CString strFilename) { if(m_pRS == NULL || m_pCON == NULL) return FALSE; if(strFilename.IsEmpty()) return FALSE; if(FileCmp(strFilename) == TRUE) return TRUE; DB_Close(); m_strConnection = oleString + strFilename; return FALSE; }
static IndexFILE *free_index( IndexFILE *indexf ) { IndexFILE *next = indexf->next; SWISH *sw = indexf->sw; int i; /* Close any pending DB */ if ( indexf->DB ) DB_Close(sw, indexf->DB); /* free the meteEntry array */ if ( indexf->header.metaCounter) freeMetaEntries(&indexf->header); /* free the in-use cached meta list */ if ( indexf->meta_list ) efree(indexf->meta_list); /* free the in-use cached property list */ if ( indexf->prop_list ) efree(indexf->prop_list); /* free data loaded into header */ free_header(&indexf->header); /* free array of words for each letter (-k) $$$ eight bit */ for (i = 0; i < 256; i++) if ( indexf->keywords[i]) efree(indexf->keywords[i]); /* free the name of the index file */ efree( indexf->line ); /* free the stem cache if any */ free_word_hash_table( &indexf->hashstemcache); /* finally free up the index itself */ efree( indexf ); return next; }
main(int argc, char *argv[]) { CONDITION ret; short id; PatientLevel pat; char dbname[50]; if (argc != 5) { printf("Usage %s Birthdate Name PatientID dbname\n", argv[0]); exit(0); } strcpy(pat.BirthDate, argv[1]); strcpy(pat.Name, argv[2]); strcpy(pat.PatID, argv[3]); strcpy(dbname, argv[4]); printf(" Birthdate: %s\n", pat.BirthDate); printf(" Name: %s\n", pat.Name); printf("Patient ID: %s\n", pat.PatID); printf(" DB Name: %s\n", dbname); if (DB_Open(dbname, &id) == DB_NORMAL) printf("DB_Open succeeded\n"); else { printf("DB_Open failed\n"); exit(1); } if ((ret = DB_AddPatient(id, &pat)) == DB_NORMAL) printf("%s succeeded\n", argv[0]); else if (ret == DB_DUPATIENT) printf("duplicate patient encountered\n"); else printf("Another error occurred: %08x\n", ret); if (DB_Close(id) == DB_NORMAL) printf("DB_Close succeeded\n"); else exit(0); }
void showFileInfo(char *filename) { Field *field; Header *header; unsigned int fileID; int i; fileID = DB_Open(filename); header = DB_GetHeader(fileID); //field = DBField_GetByName(fileID,"EUR_USD"); printf("file name %s , total fields %d,total data %d \n",filename,header->nFields,header->totalRecords); // printf("file date: %d-%d-%d %d:%d:%d",header->initialTime.day for (i=0;i<header->nFields;i++) { field = DBField_GetByIndex(fileID,i); printf("%s mantisa:%f length:%d\n",field->name,field->mantisa,field->length); } DB_Close(fileID); }
void readData() { FILE_ID fileid; float buf1[BUF_SIZE1]; float buf2[BUF_SIZE2]; float buf3[BUF_SIZE1]; // int i; fileid = DB_Open("/home/openrisc/junk.mbt"); DB_SetColumn(fileid,"EUR_USD",2); DB_SetColumn(fileid,"EUR_CAD",3); //// DB_SetFilePointer(fileid,100); // DB_ReadBuffer(fileid); DB_ReadColumn(2,buf1,BUF_SIZE1,2800); DB_ReadColumn(3,buf2,BUF_SIZE2,2900); DB_ReadColumn(3,buf3,BUF_SIZE1,1500); DB_Close(fileid); }
void CreateMBTDataFile(char *filename) { Field *field; unsigned int fileID; // create the file, set header,close file fileID = DB_Create(filename); // create header record field = DBField_Create("EUR_USD",DB_LEN16,-1); DBHeader_AddField(fileID,field); field = DBField_Create("EUR_CAD",DB_LEN16,0); DBHeader_AddField(fileID,field); field = DBField_Create("EUR_JPY",DB_LEN16,1); DBHeader_AddField(fileID,field); // update file header DB_WriteHeader(fileID); DB_WriteFields(fileID); // close file DB_Close (fileID); }
/******************************************************************** * 레코드 셋을 오픈 한다. * 기존 recordset이 있으면 close 한다. * * return : BOOL : TRUE | FALSE * * parameter : * [in] CString sql : SQL Query SELECT 구문 * [in] CString Filename : MDB 파일명 ********************************************************************/ BOOL CAdo::DB_Open(CString sql, CString Filename) { HRESULT hr; VARIANT conn; if(m_pCON == NULL || m_pRS == NULL) { return FALSE; } if(Filename.IsEmpty() == FALSE) { AfxMessageBox("이름이 업네"); DB_Connection(Filename); } else { AfxMessageBox("이름이 있네"); DB_Connection(""); } if(m_IsDBConn == FALSE) { return FALSE; } if(m_IsDBOpen == TRUE) DB_Close(); try { // TRACE(sql); // TRACE("\n"); VariantInit(&conn); conn.pdispVal = m_pCON; conn.vt = VT_DISPATCH; hr = m_pRS->Open( (LPTSTR)(LPCTSTR)sql, conn, adOpenForwardOnly, adLockOptimistic, adCmdUnknown); //레코드셋 설정 쿼리 실행 ..... 필요한 부분 가져왓 } catch(_com_error &e) { TRACE("\tDescription: %s\n", (LPCTSTR) e.Description()); } catch(...) { TRACE("*** Unhandled Exception ***\n"); } if(SUCCEEDED(hr)) m_IsDBOpen = TRUE; sql.TrimLeft(); CString str = sql.Left(7); if(str.CollateNoCase("SELECT ")) //2개의 string 비교 { m_IsDBOpen = FALSE; } return SUCCEEDED(hr); }
/* GetStudyList ** ** Purpose: ** Get the list of studies in the database. ** ** Parameter Dictionary: ** None ** ** Return Values: ** TRUE ** FALSE ** ** Notes: ** ** Algorithm: ** Description of the algorithm (optional) and any other notes. */ Boolean GetStudyList() { short dbid; StudyLevel study; PatientLevel patient; Boolean got_a_patient = TRUE; Boolean got_a_study = TRUE; LIST_ITEM * item; int index = 0; if (DB_Open(db_file, &dbid) != DB_NORMAL) { printf("Error: Failed to open %s\n", db_file); return (FALSE); } lst_studylist = LST_Create(); if (lst_studylist == NULL) { printf("Error: LST_Create failed\n"); return (FALSE); } if (DB_GetPatient(dbid, &patient) != DB_NORMAL) got_a_patient = FALSE; while (got_a_patient) { got_a_study = TRUE; if (DB_GetStudy(dbid, patient.PatID, &study) != DB_NORMAL) got_a_study = FALSE; while (got_a_study) { item = (LIST_ITEM *) malloc(sizeof(LIST_ITEM)); if (item == NULL) { printf("Fatal Error: malloc failed\n"); exit(1); } ConvertPNameToName(patient.Name, item->PatientName); strcpy(item->AccessionNumber, study.AccessionNumber); strcpy(item->combo, study.AccessionNumber); strcat(item->combo, ", "); strcat(item->combo, item->PatientName); text_studylist[index] = item->combo; if (LST_Enqueue(&lst_studylist, item) != LST_NORMAL) { printf("Error: LST_Enqueue failed\n"); return (FALSE); } if (DB_GetNextStudy(dbid, &study) != DB_NORMAL) got_a_study = FALSE; } if (DB_GetNextPatient(dbid, &patient) != DB_NORMAL) got_a_patient = FALSE; index++; } if (DB_Close(dbid) != DB_NORMAL) { printf("Error: DB_Close failed in GetStudyList\n"); return FALSE; } return FALSE; }
/* makeDBEntry ** ** Purpose: ** Adds an image file to the database. ** The patient, study, series are created in the database if they don't ** already exist. If the image UID matches an existing one, the ** existing one is deleted before the new one is added. ** ** Parameter Dictionary: ** dbid DB database id ** imgfile Image file name ** prefmtImgfile Preformatted image file name ** ** Return Values: ** NONE ** ** Notes: ** ** Algorithm: ** Description of the algorithm (optional) and any other notes. */ void makeDBEntry(short dbid, char *imgfile, char *prefmtImgfile) { CONDITION cond; /* return condition status */ Query query; /* The Query structure */ DCM_OBJECT * object; /* Pointer to a DICOM object */ int parseCount; /* keeps track of the number of elements * parsed while converting from DCM object to * Query */ /* Initialize the query structure to all null characters */ (void) memset((void *) &query, '\0', sizeof(query)); /* Read the image file and convert it into an object representation */ cond = DCM_OpenFile(imgfile, (long) DCM_ORDERLITTLEENDIAN, &object); if (cond != DCM_NORMAL) myExit(DCMOPENFILEERROR); if (verbose) DCM_DumpElements(&object); /* Convert the object into the query structure */ cond = IAP_ObjectToQuery(&object, "", &query, &parseCount); if (verbose) { printf("Number of elements parsed = %d\n", parseCount); COND_DumpConditions(); printf("Query Structure created :- \n"); dump_query(&query); } if (ERROR(cond)) myExit(IAPOBJTOQUERYERROR); /* free the memory ocupied by the object */ cond = DCM_CloseObject(&object); if (cond != DCM_NORMAL) myExit(DCMCLOSEOBJERROR); /* * So far everything is fine. Now store the name of the preformatted * image file in the FileName field in the ImageLevel structure */ (void) sprintf(query.Image.FileName, "%.*s", sizeof(query.Image.FileName) - 2, prefmtImgfile); /* now create the PATIENT, STUDY and SERIES, if they don't already exist */ cond = DB_AddPatient(dbid, &query.Patient); if (cond != DB_NORMAL && cond != DB_DUPATIENT) myExit(DBADDPATERROR); cond = DB_AddStudy(dbid, query.Patient.PatID, &query.Study); if (cond != DB_NORMAL && cond != DB_DUPSTUDY) myExit(DBADDSTUDYERROR); cond = DB_AddSeries(dbid, query.Patient.PatID, query.Study.StudyUID, &query.Series); if (cond != DB_NORMAL && cond != DB_DUPSERIES) myExit(DBADDSERIESERROR); cond = DB_AddImage(dbid, query.Patient.PatID, query.Study.StudyUID, query.Series.SeriesUID, &query.Image); if (cond == DB_DUPIMAGE) { /* we just delete previous image and replace it by new one */ cond = DB_DelImage(dbid, query.Patient.PatID, query.Study.StudyUID, query.Series.SeriesUID, query.Image.ImageUID); if (cond != DB_NORMAL) myExit(DBDELIMGERROR); /* Now add this new image */ cond = DB_AddImage(dbid, query.Patient.PatID, query.Study.StudyUID, query.Series.SeriesUID, &query.Image); if (cond != DB_NORMAL) myExit(DBADDIMGERROR); } if (verbose) { dump_query(&query); DB_DumpDB(dbid); } /* As a last step, we close the data base */ cond = DB_Close(dbid); if (cond != DB_NORMAL) myExit(DBCLOSEERROR); }