PJ_DEF(void) pj_dns_dump_packet(const pj_dns_parsed_packet *res) { unsigned i; PJ_ASSERT_ON_FAIL(res != NULL, return); /* Header part */ PJ_LOG(3,(THIS_FILE, "Domain Name System packet (%s):", (PJ_DNS_GET_QR(res->hdr.flags) ? "response" : "query"))); PJ_LOG(3,(THIS_FILE, " Transaction ID: %d", res->hdr.id)); PJ_LOG(3,(THIS_FILE, " Flags: opcode=%d, authoritative=%d, truncated=%d, rcode=%d", PJ_DNS_GET_OPCODE(res->hdr.flags), PJ_DNS_GET_AA(res->hdr.flags), PJ_DNS_GET_TC(res->hdr.flags), PJ_DNS_GET_RCODE(res->hdr.flags))); PJ_LOG(3,(THIS_FILE, " Nb of queries: %d", res->hdr.qdcount)); PJ_LOG(3,(THIS_FILE, " Nb of answer RR: %d", res->hdr.anscount)); PJ_LOG(3,(THIS_FILE, " Nb of authority RR: %d", res->hdr.nscount)); PJ_LOG(3,(THIS_FILE, " Nb of additional RR: %d", res->hdr.arcount)); PJ_LOG(3,(THIS_FILE, "")); /* Dump queries */ if (res->hdr.qdcount) { PJ_LOG(3,(THIS_FILE, " Queries:")); for (i=0; i<res->hdr.qdcount; ++i) { dump_query(i, &res->q[i]); } PJ_LOG(3,(THIS_FILE, "")); } /* Dump answers */ if (res->hdr.anscount) { PJ_LOG(3,(THIS_FILE, " Answers RR:")); for (i=0; i<res->hdr.anscount; ++i) { dump_answer(i, &res->ans[i]); } PJ_LOG(3,(THIS_FILE, "")); } /* Dump NS sections */ if (res->hdr.anscount) { PJ_LOG(3,(THIS_FILE, " NS Authority RR:")); for (i=0; i<res->hdr.nscount; ++i) { dump_answer(i, &res->ns[i]); } PJ_LOG(3,(THIS_FILE, "")); } /* Dump Additional info sections */ if (res->hdr.arcount) { PJ_LOG(3,(THIS_FILE, " Additional Info RR:")); for (i=0; i<res->hdr.arcount; ++i) { dump_answer(i, &res->arr[i]); } PJ_LOG(3,(THIS_FILE, "")); } }
/* 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); }