//================================================================================= void bTrack::writeBinnedProf(const char *fname){ if(fProfile==0) fProfile=new FloatArray(); fProfile->init(NA); name=strdup(fname); char pfil[4096]; readInputTrack(makeFileName(pfil,trackPath,name)); //================================================= Normalize errStatus="WriteBinnedProfile"; //============================ calculate min, max, average, std deviation // for(int i=0; i<profileLength; i++){ // float x=fProfile->get(i); //// if(trackType==BED_TRACK){ //// if(x == 0) fProfile->set(i,x=NA); //// } //// if(x!=NA) fProfile->set(i,x*1000); // } char wfil[4096]; makeFileName(pfil,trackPath,name); char *s=strrchr(pfil,'/'); if(s==0) s=wfil; s=strrchr(s,'.'); if(s) *s=0; sprintf(wfil,"%s_%i.bgr",pfil,binSize); FILE *f=gopen(wfil,"w"); fprintf(f,"track type=bedGraph name=\"%s\" description=\"Binned track. Binsize=%i\"\n",name, binSize); writeBedGr(f,fProfile, NA, NA); fclose(f); }
static void* tryEach(const char* picture, const char* value, int* dirEndsAt, void* arg, Method_Files_tryEachHandler fn) { char fileName[4097]; void* ret = fn(makeFileName(fileName, getenv("HOME"), "/.dit/", picture, value, dirEndsAt), arg); if (ret) return ret; ret = fn(makeFileName(fileName, SYSCONFDIR, "/dit/", picture, value, dirEndsAt), arg); if (ret) return ret; ret = fn(makeFileName(fileName, PKGDATADIR, "/", picture, value, dirEndsAt), arg); if (ret) return ret; return fn(makeFileName(fileName, ".", "/", picture, value, dirEndsAt), arg); }
// enumerate all plugins that had valid DatabasePluginInfo() static int FindDbPluginForProfile(const char*, DATABASELINK * dblink, LPARAM lParam) { TCHAR* tszProfile = ( TCHAR* )lParam; int res = DBPE_CONT; if ( dblink && dblink->cbSize == sizeof(DATABASELINK)) { char* szProfile = makeFileName(tszProfile); // liked the profile? int err = 0; if (dblink->grokHeader(szProfile, &err) == 0) { // added APIs? if ( !dblink->Load(szProfile, &pluginCoreLink)) { fillProfileName( tszProfile ); res = DBPE_DONE; } else res = DBPE_HALT; } else { res = DBPE_HALT; switch ( err ) { case EGROKPRF_CANTREAD: case EGROKPRF_UNKHEADER: // just not supported. res = DBPE_CONT; case EGROKPRF_VERNEWER: case EGROKPRF_DAMAGED: break; } } //if mir_free(szProfile); } return res; }
static QCString makeRef(const char * withoutExtension, const char * anchor) { if (!withoutExtension) return QCString(); QCString result = makeFileName(withoutExtension); if (!anchor) return result; return result+"#"+anchor; }
static int DetectDbProvider(const char*, DATABASELINK * dblink, LPARAM lParam) { int error; #ifdef _UNICODE char* fullpath = makeFileName(( TCHAR* )lParam ); #else char* fullpath = (char*)lParam; #endif int ret = dblink->grokHeader(fullpath, &error); #ifdef _UNICODE mir_free( fullpath ); #endif if ( ret == 0) { #ifdef _UNICODE char tmp[ MAX_PATH ]; dblink->getFriendlyName(tmp, SIZEOF(tmp), 1); MultiByteToWideChar(CP_ACP, 0, tmp, -1, (TCHAR*)lParam, MAX_PATH); #else dblink->getFriendlyName((TCHAR*)lParam, MAX_PATH, 1); #endif return DBPE_HALT; } return DBPE_CONT; }
static QCString makeRef(const char * withoutExtension, const char * anchor) { //printf("QHP::makeRef(%s,%s)\n",withoutExtension,anchor); if (!withoutExtension) return QCString(); QCString result = makeFileName(withoutExtension); if (!anchor) return result; return result+"#"+anchor; }
void Qhp::addIndexItem(Definition *context,MemberDef *md, const char *word) { (void)word; if (md) // member { static bool separateMemberPages = Config_getBool("SEPARATE_MEMBER_PAGES"); if (context==0) // global member { if (md->getGroupDef()) context = md->getGroupDef(); else if (md->getFileDef()) context = md->getFileDef(); } if (context==0) return; // should not happen QCString cfname = md->getOutputFileBase(); QCString cfiname = context->getOutputFileBase(); QCString level1 = context->name(); QCString level2 = word ? QCString(word) : md->name(); QCString contRef = separateMemberPages ? cfname : cfiname; QCString anchor = md->anchor(); QCString ref; // <keyword name="foo" id="MyApplication::foo" ref="doc.html#foo"/> ref = makeRef(contRef, anchor); QCString id = level1+"::"+level2; const char * attributes[] = { "name", level2, "id", id, "ref", ref, 0 }; m_index.openClose("keyword", attributes); } else if (context) // container { // <keyword name="Foo" id="Foo" ref="doc.html"/> QCString contRef = context->getOutputFileBase(); QCString level1 = word ? QCString(word) : context->name(); QCString ref = makeFileName(contRef); const char * attributes[] = { "name", level1, "id", level1, "ref", ref, 0 }; m_index.openClose("keyword", attributes); } }
int main(int argc, char **argv) { program_name = argv[0]; int i; int found = 0; int ok = 1; #ifdef CAPTURE_MODE FILE *dump; fprintf(stderr, "%s: invoked with %d arguments ...\n", argv[0], argc); for (i = 0; i < argc; i++) fprintf(stderr, "%2d: %s\n", i, argv[i]); if ((dump = fopen(DEBUG_FILE("pre-html-data"), "wb")) != NULL) { while((i = fgetc(stdin)) >= 0) fputc(i, dump); fclose(dump); } exit(1); #endif /* CAPTURE_MODE */ device = "html"; if (!font::load_desc()) fatal("cannot find devhtml/DESC exiting"); image_gen = font::image_generator; if (image_gen == NULL || (strcmp(image_gen, "") == 0)) fatal("devhtml/DESC must set the image_generator field, exiting"); postscriptRes = get_resolution(); i = scanArguments(argc, argv); setupAntiAlias(); checkImageDir(); makeFileName(); while (i < argc) { if (argv[i][0] != '-') { /* found source file */ ok = do_file(argv[i]); if (!ok) return 0; found = 1; } i++; } if (!found) do_file("-"); if (makeTempFiles()) return 1; ok = inputFile.do_image(argc, argv); if (ok == 0) { generateImages(regionFileName); ok = inputFile.do_html(argc, argv); } return ok; }
//****************************************************************************** //****************************************************************************** LOG::~LOG() { boost::mutex::scoped_lock l(logLocker); // const static std::string path = settings().logPath().size() ? settings().logPath() : settings().appPath(); const static bool logToFile = true; // !path.empty(); static boost::gregorian::date day = boost::gregorian::day_clock::local_day(); if (m_logFileName.empty()) { m_logFileName = makeFileName(); } std::cout << str().c_str(); try { std::string copy(str().c_str()); uiConnector.NotifyLogMessage(copy); if (logToFile) { boost::gregorian::date tmpday = boost::gregorian::day_clock::local_day(); if (day != tmpday) { m_logFileName = makeFileName(); day = tmpday; } std::ofstream file(m_logFileName.c_str(), std::ios_base::app); file << str().c_str(); } } catch (std::exception &) { } }
static INT_PTR GetProfileName(WPARAM wParam, LPARAM lParam) { if (!wParam || !lParam) return 1; char *dst = (char*)lParam; char *tmp = makeFileName(g_profileName); strncpy(dst, tmp, wParam); mir_free(tmp); dst[wParam-1] = 0; return 0; }
bool IndexMetaInfo::save(const vespalib::string &baseName) { vespalib::string fileName = makeFileName(baseName); vespalib::string newName = fileName + ".new"; vespalib::unlink(newName); vespalib::FilePointer f(fopen(newName.c_str(), "w")); if (!f.valid()) { LOG(warning, "could not open file for writing: %s", newName.c_str()); return false; } for (uint32_t i = 0; i < _snapshots.size(); ++i) { Snapshot &snap = _snapshots[i]; fprintf(f, "snapshot.%d.valid=%s\n", i, snap.valid? "true" : "false"); fprintf(f, "snapshot.%d.syncToken=%" PRIu64 "\n", i, snap.syncToken); fprintf(f, "snapshot.%d.dirName=%s\n", i, snap.dirName.c_str()); } if (ferror(f) != 0) { LOG(error, "Could not write to file %s", newName.c_str()); return false; } if (fflush(f) != 0) { LOG(error, "Could not flush file %s", newName.c_str()); return false; } if (fsync(fileno(f)) != 0) { LOG(error, "Could not fsync file %s", newName.c_str()); return false; } if (fclose(f.release()) != 0) { LOG(error, "Could not close file %s", newName.c_str()); return false; } if (rename(newName.c_str(), fileName.c_str()) != 0) { LOG(warning, "could not rename: %s->%s", newName.c_str(), fileName.c_str()); return false; } vespalib::File::sync(vespalib::dirname(fileName)); return true; }
void smooth(const char *fname){ outLC=1; initOutLC(); int l=profileLength; bTrack *tr=new bTrack(fname); for(int i=0,k=0; i<l; i+=wProfStep,k++){ double d; d=100.*k/(l/wProfStep); if(k%10000 ==0) verb("\nSmooother: %4.1f%% (%6i/%i) ",d,k,l/wProfStep); else if(k%1000 ==0) verb("."); double *pr1=tr->getProfile(i,0); // decode the first profile. Decoder uses hasCompl and complFg flags and combines profiles if(smoothProf==0) getMem(smoothProf,profWithFlanksLength+10, "storeCorrTrack"); if(smTmp==0) getMem(smTmp,profWithFlanksLength+10, "storeCorrTrack"); kern->fftx(pr1,0); calcSmoothProfile(&(kern->fx),0, 0); // calculate smooth ptrofile c=\int f*\rho addLCProf(LCorrelation.re,i); } char pfil[4096],wfil[4096]; makeFileName(pfil,trackPath,fname); char *s=strrchr(pfil,'/'); if(s==0) s=wfil; s=strrchr(s,'.'); if(s) *s=0; sprintf(wfil,"%s_sm.bgr",pfil); //================ normalize double tt=0,ee=0,dd=0,nn=0; for(int i=0; i<l; i++) { double x=lcProfile->get(i); ee+=x; nn++; dd+=x*x; } tt=ee; ee/=nn; dd=dd/nn-ee*ee; dd=sqrt(dd); for(int i=0; i<l; i++) { double x=lcProfile->get(i); if(smoothZ){if((x-ee)/dd < smoothZ) x=0;} else {x=x*tr->total/tt/binSize;} lcProfile->set(i,x); } FILE *f=gopen(wfil,"w"); char b[4096]; strcpy(b,fname); s=strrchr(b,'.'); if(s) *s=0; s=strchr(b,'/'); if(s==0) s=b; fprintf(f,"track type=bedGraph name=\"%s_Sm\" description=\"Smoothed track. Width=%.0f\"\n",s, kernelSigma); verb("\n Write Smooth profile...\n"); writeBedGr(f,lcProfile, NA, NA); verb(" Done\n"); }
void Logger::flush() { std::string temp; while(infos.readOnly(temp)) { std::string fileName = makeFileName(); FILE *hp = fopen(fileName.c_str(),"a+"); if (hp) { std::stringstream ss; ss << temp <<"\n"; fputs(ss.str().c_str(),hp); fclose(hp); } infos.pop(); } }
static void* handleForEachInDir(const char* dirName, void* arg) { const ForEachData* fed = (ForEachData*) arg; DIR* dir = opendir(dirName); while (dir) { struct dirent* entry = readdir(dir); if (!entry) break; if (entry->d_name[0] == '.') continue; char fileName[4097]; makeFileName(fileName, dirName, "/", "%s", entry->d_name, NULL); if (fed->fn(fed->data, fileName)) { if (dir) closedir(dir); return &handleForEachInDir; // a non-nil pointer to tell tryEach to stop. } } if (dir) closedir(dir); return NULL; }
bool IndexMetaInfo::load(const vespalib::string &baseName) { clear(); Parser parser(makeFileName(baseName)); while (parser.status() && parser.next()) { if (parser.parseArray("snapshot", _snapshots.size())) { Snapshot &snap = getCreateSnapshot(parser.idx()); parser.parseBool("valid", snap.valid); parser.parseInt64("syncToken", snap.syncToken); parser.parseString("dirName", snap.dirName); assert(snap.syncToken != static_cast<uint64_t>(-1)); } } std::sort(_snapshots.begin(), _snapshots.end()); return parser.status(); }
void Qhp::handlePrevSection() { /* <toc> <section title="My Application Manual" ref="index.html"> <section title="Chapter 1" ref="doc.html#chapter1"/> <section title="Chapter 2" ref="doc.html#chapter2"/> <section title="Chapter 3" ref="doc.html#chapter3"/> </section> </toc> */ if (m_prevSectionTitle.isNull()) { return; } // We skip "Main Page" as our extra root is pointing to that if (!((m_prevSectionLevel==1) && (m_prevSectionTitle=="Main Page"))) { QCString finalRef = makeFileName(m_prevSectionRef); const char * const attributes[] = { "title", m_prevSectionTitle, "ref", finalRef, NULL }; if (m_prevSectionLevel < m_sectionLevel) { // Section with children m_toc.open("section", attributes); } else { // Section without children m_toc.openClose("section", attributes); } } clearPrevSection(); }
// called by the UI, return 1 on success, use link to create profile, set error if any int makeDatabase(TCHAR * profile, DATABASELINK * link, HWND hwndDlg) { TCHAR buf[256]; int err=0; // check if the file already exists TCHAR * file = _tcsrchr(profile, '\\'); if (file) file++; if (_taccess(profile, 0) == 0) { // file already exists! mir_sntprintf(buf, SIZEOF(buf), TranslateTS( _T("The profile '%s' already exists. Do you want to move it to the ") _T("Recycle Bin? \n\nWARNING: The profile will be deleted if Recycle Bin is disabled.\n") _T("WARNING: A profile may contain confidential information and should be properly deleted.")), file ); if ( MessageBox(hwndDlg, buf, TranslateT("The profile already exists"), MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2) != IDYES ) return 0; // move the file SHFILEOPSTRUCT sf = {0}; sf.wFunc = FO_DELETE; sf.pFrom = buf; sf.fFlags = FOF_NOCONFIRMATION | FOF_NOERRORUI | FOF_SILENT | FOF_ALLOWUNDO; mir_sntprintf(buf, SIZEOF(buf), _T("%s\0"), profile); if ( SHFileOperation(&sf) != 0 ) { mir_sntprintf(buf, SIZEOF(buf),TranslateT("Couldn't move '%s' to the Recycle Bin, Please select another profile name."),file); MessageBox(0,buf,TranslateT("Problem moving profile"),MB_ICONINFORMATION|MB_OK); return 0; } // now the file should be gone! } // ask the database to create the profile CreatePathToFileT(profile); char *prf = makeFileName(profile); if (link->makeDatabase(prf, &err)) { mir_sntprintf(buf, SIZEOF(buf),TranslateT("Unable to create the profile '%s', the error was %x"),file, err); MessageBox(hwndDlg,buf,TranslateT("Problem creating profile"),MB_ICONERROR|MB_OK); mir_free(prf); return 0; } dbCreated = true; // the profile has been created! woot mir_free(prf); return 1; }
static __forceinline char* GetPathVarX(const char*, int code) { TCHAR szFullPath[MAX_PATH]; switch(code) { case 1: if (hAvatarFolder != NULL) _tcsncpy_s(szFullPath, tszAvatarRoot, _TRUNCATE); else mir_sntprintf(szFullPath, _T("%s\\%s\\AvatarCache"), g_profileDir, g_shortProfileName); break; case 2: mir_sntprintf(szFullPath, _T("%s\\%s\\Logs"), g_profileDir, g_shortProfileName); break; case 3: mir_sntprintf(szFullPath, _T("%s\\%s"), g_profileDir, g_shortProfileName); break; } return makeFileName(szFullPath); }
static INT_PTR GetProfileName(WPARAM wParam, LPARAM lParam) { if (!wParam || !lParam) return 1; char* dst = (char*)lParam; #if defined( _UNICODE ) char* tmp = makeFileName( g_profileName ); strncpy( dst, tmp, wParam ); mir_free( tmp ); #else strncpy( dst, g_profileName, wParam ); #endif if (wParam <= _tcslen(g_profileName)) { dst[wParam - 1] = 0; return 1; } return 0; }
// enumerate all plugins that had valid DatabasePluginInfo() static int FindDbPluginAutoCreate(const char*, DATABASELINK * dblink, LPARAM lParam) { TCHAR* tszProfile = ( TCHAR* )lParam; int res = DBPE_CONT; if (dblink && dblink->cbSize == sizeof(DATABASELINK)) { CreatePathToFileT( tszProfile ); int err; char *szProfile = makeFileName( tszProfile ); if (dblink->makeDatabase(szProfile, &err) == 0) { dbCreated = true; if ( !dblink->Load(szProfile, &pluginCoreLink)) { fillProfileName( tszProfile ); res = DBPE_DONE; } else res = DBPE_HALT; } mir_free(szProfile); } return res; }
void bTrack::makeBinTrack(){ Timer tm; verb ("****** Make binary track <%s> ******\n", name); writeLog(" Make binary track <%s>\n",name); //===================================================== prepare track file name if (pcorProfile!=0) verb("=== pcorProfile= <%s>\n",pcorProfile); trackType=getTrackType(name); //===================================================================================== initProfile(); //============ Allocate arrays char pfil[4096]; readInputTrack(makeFileName(pfil,trackPath,name)); //============ Read tracks //====================================================================== verb("Finalize profiles... \n"); finProfile(); //============ Calculate min,max,average; convert to bytes verb("Write profiles... \n"); writeProfilePrm(); writeByteProfile(); //============ write binary profiles writeLog(" Make binary track -> OK. Time=%s\n",tm.getTime()); return; }
void FileSeqPubCore::acquireImage() { int stepn = start_no_ + step_; //build a full path std::string filename = path_to_images_ + makeFileName(image_file_name_prefix_, stepn, image_extension_); ROS_INFO("image file: %s", filename.c_str()); //needed for ros image transport cv_img_ptr_->encoding = "mono8"; //OpenCV read from file try { cv_img_ptr_->image = cv::imread(filename.c_str(), CV_LOAD_IMAGE_GRAYSCALE); } catch (cv::Exception& e) { ROS_ERROR("Image did not load correctly! Exception: /t %s", e.what()); } }
String MediaDatabase::getFileName() { // static return makeFileName(_T("dat")); }
int stmd_RuleEntSelect(int time_type, int duration, char *table_type) { char condBuf[4096], tmpBuf[1024]; int sts_code; char str_time[10]; char query[4096], query_head[4096]; MYSQL_RES *result; MYSQL_ROW row; time_t now; char tm[DIR_NUM][8]; char path[60]; char fileName[60]; FILE *fp; int i; char title[4][16] = {"SYSTEM", "ITEM", "Session", "Block"}; char title1[5][16] = {"", "", "UpStream(Mbps)", "DnStream(Mbps)", "Total(Mbps)"}; char title2[5][16] = {"", "", "UpByte(MBytes)", "DnByte(MBytes)", "Total(MBytes)"}; int row_index; char SysName[2][8]; int realSysCnt =0; int realItemCnt =0, row_cnt=0 ; int snd_cnt = 1; now = time(0); if(time_type != STMD_WEEK) now = now - (printTIME[time_type]*60) - STAT_OFFSET_UNIT; else now = now - (printTIME[time_type]*60); getFilePath (path, tm, &now); // ~/LOG/STAT 까지 만든다. makeDirectory (time_type,path,tm); sprintf(fileName, "%s", path ); makeFileName ( fileName, STMD_RULE_ENT, time_type, tm ); if ( ( fp = fopen(fileName, APPEND ) ) == NULL ) { sprintf(trcBuf, "%s Open Fail\n", fileName); trclib_writeLog(FL, trcBuf); return -1; } //char title[4][16] = {"SYSTEM", "ITEM", "Session", "Block"}; //char title1[5][16] = {"", "", "UpStream(Mbps)", "DnStream(Mbps)", "Total(Mbps)"}; //char title2[5][16] = {"", "", "UpByte(MBytes)", "DnByte(MBytes)", "Total(MBytes)"}; switch (time_type) { case STMD_HOUR : sts_code = STSCODE_STM_PERIODIC_RULEENT_HOUR; sprintf(str_time, "%s", STMD_STR_HOUR); sprintf(query_head, "SELECT record_source, rule_ent_id, rule_ent_name, " " IFNULL(SUM(session),0), IFNULL(SUM(block_cnt),0), " " ROUND(IFNULL(SUM(upstream_volume)*8/1024/1024/3600,0),3), " " ROUND(IFNULL(SUM(downstream_volume)*8/1024/1024/3600,0),3), " " ROUND((IFNULL(SUM(upstream_volume),0) + IFNULL(SUM(downstream_volume),0))*8/1024/1024/3600,3), " " ROUND(IFNULL(SUM(upstream_volume)/1024/1024 ,0),3), " " ROUND(IFNULL(SUM(downstream_volume)/1024/1024 ,0),3), " " ROUND((IFNULL(SUM(upstream_volume),0) + IFNULL(SUM(downstream_volume),0))/1024/1024,3) " " from %s ", table_type); break; case STMD_DAY : sts_code = STSCODE_STM_PERIODIC_RULEENT_DAY; sprintf(str_time, "%s", STMD_STR_DAY); sprintf(query_head, "SELECT record_source, rule_ent_id, rule_ent_name, " " IFNULL(SUM(session),0), IFNULL(SUM(block_cnt),0), " " ROUND(IFNULL(SUM(upstream_volume)*8/1024/1024/86400,0),3), " " ROUND(IFNULL(SUM(downstream_volume)*8/1024/1024/86400,0),3), " " ROUND((IFNULL(SUM(upstream_volume),0) + IFNULL(SUM(downstream_volume),0))*8/1024/1024/86400,3), " " ROUND(IFNULL(SUM(upstream_volume)/1024/1024 ,0),3), " " ROUND(IFNULL(SUM(downstream_volume)/1024/1024 ,0),3), " " ROUND((IFNULL(SUM(upstream_volume),0) + IFNULL(SUM(downstream_volume),0))/1024/1024,3) " " from %s ", table_type); break; case STMD_WEEK : sts_code = STSCODE_STM_PERIODIC_RULEENT_WEEK; sprintf(str_time, "%s", STMD_STR_WEEK); sprintf(query_head, "SELECT record_source, rule_ent_id, rule_ent_name, " " IFNULL(SUM(session),0), IFNULL(SUM(block_cnt),0), " " ROUND(IFNULL(SUM(upstream_volume)*8/1024/1024/86400*7,0),3), " " ROUND(IFNULL(SUM(downstream_volume)*8/1024/1024/86400*7,0),3), " " ROUND((IFNULL(SUM(upstream_volume),0) + IFNULL(SUM(downstream_volume),0))*8/1024/1024/86400*7,3), " " ROUND(IFNULL(SUM(upstream_volume)/1024/1024 ,0),3), " " ROUND(IFNULL(SUM(downstream_volume)/1024/1024 ,0),3), " " ROUND((IFNULL(SUM(upstream_volume),0) + IFNULL(SUM(downstream_volume),0))/1024/1024,3) " " from %s ", table_type); break; case STMD_MONTH : sts_code = STSCODE_STM_PERIODIC_RULEENT_MONTH; sprintf(str_time, "%s", STMD_STR_MONTH); sprintf(query_head, "SELECT record_source, rule_ent_id, rule_ent_name, " " IFNULL(SUM(session),0), IFNULL(SUM(block_cnt),0), " " ROUND(IFNULL(SUM(upstream_volume)*8/1024/1024/86400*30,0),3), " " ROUND(IFNULL(SUM(downstream_volume)*8/1024/1024/86400*30,0),3), " " ROUND((IFNULL(SUM(upstream_volume),0) + IFNULL(SUM(downstream_volume),0))*8/1024/1024/86400*30,3), " " ROUND(IFNULL(SUM(upstream_volume)/1024/1024 ,0),3), " " ROUND(IFNULL(SUM(downstream_volume)/1024/1024 ,0),3), " " ROUND((IFNULL(SUM(upstream_volume),0) + IFNULL(SUM(downstream_volume),0))/1024/1024,3) " " from %s ", table_type); break; } sprintf(condBuf," %s %s\n S%04d RULE ENTRY PERIODIC STATISTICS MESSAGE\n", "SCE", // 현재는 OMP로 고정하지만 실질적인 시스템 이름으로 변경 필요 hslim_oper commlib_printTStamp(), // 현재시각 time stamp (년,월,일,시,분,초,요일) sts_code); sprintf(tmpBuf, " PERIOD = %s\n MEASURETIME = %s - %s\n\n", str_time, get_period_start_time(time_type), get_period_end_time(time_type)); strcat(condBuf,tmpBuf); sprintf(tmpBuf, " =======================================================================================\n"); strcat(condBuf, tmpBuf); sprintf(tmpBuf, "%3s %6s %-38s %-15s %-15s \n","",title[0],title[1],title[2],title[3]); strcat(condBuf, tmpBuf); sprintf(tmpBuf, "%3s %6s %-38s %-15s %-15s %-15s\n","","","",title1[2],title1[3],title1[4]); strcat(condBuf, tmpBuf); sprintf(tmpBuf, "%3s %6s %-38s %-15s %-15s %-15s\n","","","",title2[2],title2[3],title2[4]); strcat(condBuf, tmpBuf); sprintf(tmpBuf, " =======================================================================================\n"); strcat(condBuf, tmpBuf); for(i=0; i<SCE_CNT; i++ ) { sprintf(SysName[i], "%s", g_stSCE[i].sce_name); realSysCnt++; } for(i = 0; i < realSysCnt; i++) { realItemCnt = g_stSCEEntry[i].ruleEntryCnt; sprintf(query, "%s " " where record_source = '%s' AND (stat_date = '%s') " " group by record_source, rule_ent_id, rule_ent_name " " order by record_source, rule_ent_id, rule_ent_name ", query_head, SysName[i], get_period_select_time(time_type)); logPrint(trcLogId, FL, "periodic query: %s \n",query); if ( trcLogFlag == TRCLEVEL_SQL ) { sprintf(trcBuf, "query = %s\n", query); trclib_writeLog(FL, trcBuf); } if (stmd_mysql_query (query) < 0) { sprintf(trcBuf,">>> mysql_query fail; query:%s, err=%s\n", query,mysql_error(conn)); trclib_writeLogErr (FL,trcBuf); if(fp != NULL) fclose(fp); return -1; } row_cnt = 0; result = mysql_store_result(conn); while( (row = mysql_fetch_row(result)) != NULL) { row_index = 3; if(strlen(condBuf) > 3000) { strcat(condBuf, "\nCONTINUE\n"); stmd_txMsg2Cond (condBuf, (sts_code - STSCODE_TO_MSGID_STATISTICS), 1, snd_cnt++); fprintf (fp, "%s",condBuf); memset(condBuf, 0x00, sizeof(condBuf)); } if( row_cnt == 0 ) { sprintf(tmpBuf, "%3s %6s %-38s %-15s %-15s \n", "", row[0], row[2], row[row_index],row[row_index+1]); strcat(condBuf, tmpBuf); } else { sprintf(tmpBuf, "%3s %6s %-38s %-15s %-15s\n", "","", row[2], row[row_index],row[row_index+1]); strcat(condBuf, tmpBuf); } if(strlen(condBuf) > 3000) { strcat(condBuf, "\nCONTINUE\n"); stmd_txMsg2Cond (condBuf, (sts_code - STSCODE_TO_MSGID_STATISTICS), 1, snd_cnt++); fprintf (fp, "%s",condBuf); memset(condBuf, 0x00, sizeof(condBuf)); } sprintf(tmpBuf, "%3s %6s %-28s %15s %15s %15s\n", "", "", "", row[row_index+2], row[row_index+3], row[row_index+4] ); strcat(condBuf, tmpBuf); if(strlen(condBuf) > 3000) { strcat(condBuf, "\nCONTINUE\n"); stmd_txMsg2Cond (condBuf, (sts_code - STSCODE_TO_MSGID_STATISTICS), 1, snd_cnt++); fprintf (fp, "%s",condBuf); memset(condBuf, 0x00, sizeof(condBuf)); } sprintf(tmpBuf, "%3s %6s %-28s %15s %15s %15s\n", "", "", "", row[row_index+5], row[row_index+6], row[row_index+7] ); strcat(condBuf, tmpBuf); if(strlen(condBuf) > 3000) { strcat(condBuf, "\nCONTINUE\n"); stmd_txMsg2Cond (condBuf, (sts_code - STSCODE_TO_MSGID_STATISTICS), 1, snd_cnt++); fprintf (fp, "%s",condBuf); memset(condBuf, 0x00, sizeof(condBuf)); } row_cnt++; } mysql_free_result(result); // ????? // 여기는 수행되면 안됨. 5분 통계에서 이미 다 들어 가있음. #if 0 if( row_cnt == 0 ) // no query result set { for( j = 0; j < realItemCnt; j++ ) { if( g_stSCEEntry[i].stEntry[j].real == 1 && g_stSCEEntry[i].stEntry[j].eName != NULL ) { if( j == 0 ) { sprintf(tmpBuf, "%3s %6s %-38s %-15s %-15s\n", "", SysName[i], g_stSCEEntry[i].stEntry[j].eName, "0","0","0"); strcat(condBuf, tmpBuf); sprintf(tmpBuf, "%3s %6s %-38s %-15s %-15s %-15s\n", "", "", "", "0.000","0.000","0.000"); strcat(condBuf, tmpBuf); sprintf(tmpBuf, "%3s %6s %-38s %-15s %-15s %-15s\n", "", "", "", "0","0","0"); strcat(condBuf, tmpBuf); sprintf(tmpBuf, " --------------------------------------------------------------------------------------\n"); strcat(condBuf, tmpBuf); } else { sprintf(tmpBuf, "%3s %6s %-38s %-15s %-15s\n", "", "", g_stSCEEntry[i].stEntry[j].eName, "0","0","0"); strcat(condBuf, tmpBuf); sprintf(tmpBuf, "%3s %6s %-38s %-15s %-15s %-15s\n", "", "", "", "0.000","0.000","0.000"); strcat(condBuf, tmpBuf); sprintf(tmpBuf, "%3s %6s %-38s %-15s %-15s %-15s\n", "", "", "", "0","0","0"); strcat(condBuf, tmpBuf); sprintf(tmpBuf, " ---------------------------------------------------------------------------------------\n"); } } if(strlen(condBuf) > 3000) { stmd_cron_txMsg2Cond (condBuf, (sts_code - STSCODE_TO_MSGID_STATISTICS), 1, snd_cnt); fprintf (fp, "%s",condBuf); sprintf(condBuf, ""); } } } #endif sprintf(tmpBuf, " =======================================================================================\n"); strcat(condBuf, tmpBuf); } sprintf(tmpBuf, " COMPLETED\n\n\n"); strcat(condBuf, tmpBuf); if(fp != NULL) { fprintf (fp, "%s",condBuf); fclose(fp); } stmd_txMsg2Cond(condBuf, (sts_code - STSCODE_TO_MSGID_STATISTICS), 0, snd_cnt); return 1; }
void FTPServerConnection::onCommand(String cmd, String data) { cmd.toUpperCase(); debugf("FTP : cmd = %s, data = %s",cmd.c_str(),data.c_str()); // We ready to quit always :) if (cmd == "QUIT") { response(221); close(); return; } // Strong security check :) if (state == eFCS_Authorization) { if (cmd == "USER") { userName = data; response(331); } else if (cmd == "PASS") { if (server->checkUser(userName, data)) { userName = ""; state = eFCS_Active; response(230); } else response(430); } else { response(530); } return; } if (state == eFCS_Active) { if (cmd == "SYST") { response(215, "Windows_NT: Sming Framework"); // Why not? It's look like Windows :) } else if (cmd == "PWD") { response(257, "\"/\""); } else if (cmd == "PORT") { cmdPort(data); } else if (cmd == "EPRT") { cmdEPRT(data); } else if (cmd == "CWD") { if (data == "/") { directoryPrefix = ""; response(250); } else { directoryPrefix = directoryPrefix + data + "/"; response(250); } } else if (cmd == "TYPE") { // response(250); response(200); } /*else if (cmd == "SIZE") { response(213, String(fileGetSize(makeFileName(data, false)))); }*/ else if (cmd == "DELE") { String name = makeFileName(data, false); if (fileExist(name)) { fileDelete(name); response(250); } else response(550); } /*else if (cmd == "RNFR") // Bugs! { renameFrom = data; response(350); } else if (cmd == "RNTO") { if (fileExist(renameFrom)) { fileRename(renameFrom, data); response(250); } else response(550); }*/ else if (cmd == "RETR") { String name = makeFileName(data, false); if (fileExist(name)) { createDataConnection(new FTPDataRetrieve(this, makeFileName(data, false))); } else { response(550); } } else if (cmd == "STOR") { createDataConnection(new FTPDataStore(this, makeFileName(data, true))); } else if (cmd == "LIST") { createDataConnection(new FTPDataFileList(this)); } else if (cmd == "PASV") { response(500 , "Passive mode not supported"); } else if (cmd == "NOOP") { response(200); } else if (!server->onCommand(cmd, data, *this)) response(502, "Not supported"); return; } debugf("!!!CASE NOT IMPLEMENTED?!!!"); }
int stmd_LoadSelect(int time_type, char *table_type) { char condBuf[4096], tmpBuf[1024]; int sts_code; char str_time[10]; int select_cnt = 0; char query[4096]; MYSQL_RES *result; MYSQL_ROW row; time_t now; char tm[DIR_NUM][8]; char path[60]; char fileName[60]; FILE *fp; char itemRes[8][10]; int i,j; // char *title[]={"CPU","MEM","DISK","QUEUE","SESS"}; char *title[]={"CPU","MEM","HW","QUEUE"}; int row_index; char SysName[5][8]; int realSysCnt =0; int realItemCnt =0; for(i=0; i<sysCnt; i++ ){ sprintf(SysName[i], "%s", StatisticSystemInfo[i].sysName); realSysCnt++; } /* 10.13 TAP REMOVE sprintf(SysName[realSysCnt], "TAPA");realSysCnt++; sprintf(SysName[realSysCnt], "TAPB");realSysCnt++; */ sprintf(SysName[realSysCnt], "SCEA");realSysCnt++; sprintf(SysName[realSysCnt], "SCEB");realSysCnt++; now = time(0); if(time_type != STMD_WEEK) now = now - (printTIME[time_type]*60) - STAT_OFFSET_UNIT; else now = now - (printTIME[time_type]*60); getFilePath (path, tm, &now); // ~/LOG/STAT 까지 만든다. makeDirectory (time_type,path,tm); sprintf(fileName, "%s", path ); makeFileName ( fileName, STMD_LOAD, time_type, tm ); if ( ( fp = fopen(fileName, APPEND ) ) == NULL ){ sprintf(trcBuf, "%s Open Fail\n", fileName); trclib_writeLog(FL, trcBuf); return -1; } switch (time_type) { case STMD_HOUR : sts_code = STSCODE_STM_PERIODIC_LOAD_HOUR; sprintf(str_time, "%s", STMD_STR_HOUR); break; case STMD_DAY : sts_code = STSCODE_STM_PERIODIC_LOAD_DAY; sprintf(str_time, "%s", STMD_STR_DAY); break; case STMD_WEEK : sts_code = STSCODE_STM_PERIODIC_LOAD_WEEK; sprintf(str_time, "%s", STMD_STR_WEEK); break; case STMD_MONTH : sts_code = STSCODE_STM_PERIODIC_LOAD_MONTH; sprintf(str_time, "%s", STMD_STR_MONTH); break; } sprintf(condBuf," %s %s\n S%04d LOAD PERIODIC STATISTICS MESSAGE\n", //"BSDM", // 현재는 OMP로 고정하지만 실질적인 시스템 이름으로 변경 필요 hslim_oper "DSCM", // 현재는 OMP로 고정하지만 실질적인 시스템 이름으로 변경 필요 hslim_oper commlib_printTStamp(), // 현재시각 time stamp (년,월,일,시,분,초,요일) sts_code); sprintf(tmpBuf, " PERIOD = %s\n MEASURETIME = %s - %s\n\n", str_time, get_period_start_time(time_type), get_period_end_time(time_type)); strcat(condBuf,tmpBuf); sprintf(tmpBuf, " ==================================\n"); strcat(condBuf, tmpBuf); sprintf(tmpBuf, " SYSTEM ITEM AVG(%%) MAX(%%)\n"); strcat(condBuf, tmpBuf); sprintf(tmpBuf, " ==================================\n"); strcat(condBuf, tmpBuf); for(i = 0; i < realSysCnt; i++){ //if(!strcasecmp(SysName[i], "BSDM")) if(!strcasecmp(SysName[i], "DSCM")) realItemCnt=4; /* 10.13 TAP REMOVE else if(!strcasecmp(SysName[i], "TAPA") || !strcasecmp(SysName[i], "TAPB")) realItemCnt=3; */ else if(!strcasecmp(SysName[i], "SCEA") || !strcasecmp(SysName[i], "SCEB")) realItemCnt=3; else realItemCnt=4; // realItemCnt=5; sprintf(query, "SELECT " " IFNULL(AVG(avr_cpu0), 0), IFNULL(MAX(max_cpu0), 0)," " IFNULL(AVG(avr_memory), 0), IFNULL(MAX(max_memory), 0)," " IFNULL(AVG(avr_disk), 0), IFNULL(MAX(max_disk), 0)," " IFNULL(AVG(avr_msgQ), 0), IFNULL(MAX(max_msgQ), 0) " // " IFNULL(AVG(avr_sess), 0), IFNULL(MAX(max_sess), 0)" " from %s " " where system_name = '%s' AND (stat_date = '%s')", table_type, SysName[i], get_period_select_time(time_type)); if ( trcLogFlag == TRCLEVEL_SQL ) { sprintf(trcBuf, "query = %s\n", query); trclib_writeLog(FL, trcBuf); } if (stmd_mysql_query (query) < 0) { sprintf(trcBuf,">>> mysql_query fail; err=%s\n", mysql_error(conn)); trclib_writeLogErr (FL,trcBuf); if(fp != NULL) fclose(fp); return -1; } result = mysql_store_result(conn); while((row = mysql_fetch_row(result)) != NULL) { // for(j=0; j < 10; j++) for(j=0; j < 8; j++) { // SESS는 그댜로 출력 하자. add by helca 080930 strcpy(itemRes[j], row[j]); sprintf(itemRes[j], "%d.%d", atoi(itemRes[j])/10, atoi(itemRes[j])%10); /** session delete 0608 if(j<8) sprintf(itemRes[j], "%d.%d", atoi(itemRes[j])/10, atoi(itemRes[j])%10); else sprintf(itemRes[j], "%d", atoi(itemRes[j])); */ } row_index = 0; for(j=0; j < realItemCnt; j++) { if (j==0) { sprintf(tmpBuf, "%3s %-9s %-5s %8s %9s\n", "", SysName[i], title[j], itemRes[row_index],itemRes[row_index+1]); strcat(condBuf, tmpBuf); } else { sprintf(tmpBuf, "%3s %-9s %-5s %8s %9s\n", "", "", title[j], itemRes[row_index],itemRes[row_index+1]); strcat(condBuf, tmpBuf); } row_index += 2; } sprintf(tmpBuf, " ==================================\n"); strcat(condBuf, tmpBuf); select_cnt++; } mysql_free_result(result); if (select_cnt == 0) { for(j=0; j < realItemCnt; j++) { if (j==0) { sprintf(tmpBuf, "%3s %-9s %-5s %8s %9s\n", "", SysName[i], title[j], "0.0", "0.0"); strcat(condBuf, tmpBuf); } else { sprintf(tmpBuf, "%3s %-9s %-5s %8s %9s\n", "", "", title[j], "0.0", "0.0"); strcat(condBuf, tmpBuf); } } sprintf(tmpBuf, " ==================================\n"); strcat(condBuf, tmpBuf); } } sprintf(tmpBuf, " COMPLETED\n\n\n"); strcat(condBuf, tmpBuf); if(fp != NULL) { fprintf (fp, "%s",condBuf); fclose(fp); } stmd_txMsg2Cond(condBuf, (sts_code - STSCODE_TO_MSGID_STATISTICS), 0, 1); return 1; }
void bTrack::writeProfilePrm(const char *path){ //============================================= Write parameters char prmFname[4096]; makeFileName(prmFname,path,name,PRM_EXT); verb("write prm %s...\n",prmFname); FILE *f=xopen(prmFname, "wt"); if(f==0)return; fprintf(f,"#====== THIS IS GENERATED FILE. DO NOT EDIT! ========\n"); fprintf(f,"version=%s\n",version); fprintf(f,"#=== Input data ===\n"); fprintf(f,"trackType=%i\n",trackType); fprintf(f,"input=%s\n",name); fprintf(f,"#=== Parameters ===\n"); fprintf(f,"bin=%i\n",binSize); fprintf(f,"strand=%i\n",hasCompl); if(trackType == BROAD_PEAK) fprintf(f,"bpType=%i\n",bpType); if(cage) fprintf(f, "cage=%i\n", cage); fprintf(f,"#=== Statistics ===\n"); fprintf(f,"min=%g\n",minP); fprintf(f,"max=%g\n",maxP); fprintf(f,"average=%g\n",av); fprintf(f,"stdDev=%g\n",sd); unsigned int chk=getChkSum(bytes, profileLength); if(cbytes && hasCompl) chk+=getChkSum(cbytes, profileLength); fprintf(f,"chksum=%08x\n",chk); fprintf(f,"#=== Scale ===\n"); fprintf(f,"scale=%f\n",scaleFactor); fprintf(f,"total=%f\n",total); //==== calculate distribution int dstr[256]; float cdstr[256],nn=0; memset(dstr,0,sizeof(dstr)); for(int i=0; i<profileLength; i++){ int xx=bytes->get(i); if(xx!=NA) {int x=xx*128./MAX_SHORT; dstr[x+128]++;} if(cbytes && hasCompl){ xx=cbytes->get(i); if(xx!=NA) { int x=xx*128./MAX_SHORT; dstr[x+128]++; } } } cdstr[0]=0; nn=0; for(int i=0; i<256; i++){ nn+=dstr[i]; if(i>0) cdstr[i]=nn; } fprintf(f,"\n#***** Distribution ***** nn=%i pLength=%i\n",(int)nn,profileLength); for(int i=0; i<256; i++){ int b=(i-128.)/128.*MAX_SHORT; fprintf(f,"#%3i\t%f\t%i\t%.0f\t%5.2f\t%5.2f\n",i,getVal(b), dstr[i],cdstr[i], cdstr[i]*100./nn, (nn-cdstr[i])*100./nn); } fclose(f); }
void Confounder(){ bTrack *confdr=new bTrack(); if(confFile==0) confFile=strdup("confounder"); confdr->trackType=BED_GRAPH; confdr->hasCompl=0; confdr->name=confFile; confdr->initProfile(); VectorX v=VectorX(); VectorX cnf=VectorX(); FILE *f; char b[4096]; for(int i=0; i<nfiles; i++){ cnf.v[i]=eVectors->get(i,0); } verb("\n"); if(verbose) {verb("confounder: "); cnf.print(stdout);} double min=1.e+100, max=-1.e+100, e=0; int nn=0; int na0=0; verb("Make Confounder...\n"); for(int i=0; i<profileLength; i++){ if(i%1000000 ==0) verb("%5.1f%%\r",1.*i/profileLength*100); v.get(i); if(v.v[0]==NA) na0++; double w=v.scalar(cnf); if(w==NA){ fProfile->set(i,w); continue; } fProfile->set(i,w); //finProfile will divide by bisize e+=w; nn++; if(w<min) min=w; if(w>max) max=w; } verb("\n"); e/=nn; if(e < 0){ min=1.e+100; max=-1.e+100; e=0; for(int i=0; i<profileLength; i++){ double w=fProfile->get(i); if(w==NA) continue; fProfile->set(i,(w=-w)); e+=w; if(w<min) min=w; if(w>max) max=w; } } //================================================ Norm confdr->finProfile(); //=================================================== Write wig makeFileName(b,trackPath, confFile, BGR_EXT); f=gopen(b,"wt"); fprintf(f,"track type=bedGraph name=\"%s\" ", confFile); fprintf(f,"description=\"confounder\" \n"); for(int i=0; i<nfiles; i++){ fprintf(f,"#%s\n",files[i].fname); } verb("Write confounder profile...\n"); writeBedGr(f,fProfile); verb("\n"); fclose(f); confdr->writeProfilePrm(); confdr->writeByteProfile(); del(fProfile); fProfile=0; del(confdr); }
int stmd_LogonSelect(int time_type, char *table_type) { char condBuf[4096], tmpBuf[1024]; int sts_code; char str_time[10]; int select_cnt = 0, snd_cnt = 0; char query[4096]; MYSQL_RES *result; MYSQL_ROW row; time_t now; char tm[DIR_NUM][8]; char path[60]; char fileName[60]; FILE *fp; int i, j, row_index, realSysCnt = 2, realItemCnt = 0; char title[7][16]={"SYSTEM", "SM_CH_ID", "LOG_MOD", "LOG_REQ", "LOG_SUCC","LOG_FAIL","SUCC_RATE"}; //uamyd 20110515 succrate_added char title1[5][16]={"", "HBIT_0","HBIT_1","HBIT_2", "HBIT_3"}; char title2[5][16]={"", "HBIT_4","HBIT_5","HBIT_6", "HBIT_7"}; char title3[5][16]={"", "HBIT_8","HBIT_9","HBIT_10", "HBIT_11"}; char title4[5][16]={"", "HBIT_12","HBIT_13","HBIT_14", "HBIT_15"}; char title5[5][16]={"", "HBIT_16","HBIT_17","HBIT_18", "HBIT_19"}; char title6[5][16]={"", "HBIT_20","HBIT_21","HBIT_22", "HBIT_23"}; char title7[5][16]={"", "HBIT_24","HBIT_25","HBIT_26", "HBIT_27"}; char title8[5][16]={"", "HBIT_28","HBIT_29","HBIT_30", "HBIT_31"}; char title10[5][16]={"", "SM_INT_ERR","OP_ERR","OP_TIMEOUT", "ETC_FAIL"}; char title11[3][16]={"", "API_REQ_ERR","API_TIMEOUT"}; char SysName[2][8] = {"SCMA","SCMB"}; now = time(0); if(time_type != STMD_WEEK) now = now - (printTIME[time_type]*60) - STAT_OFFSET_UNIT; else now = now - (printTIME[time_type]*60); getFilePath (path, tm, &now); // ~/LOG/STAT 까지 만든다. makeDirectory (time_type,path,tm); sprintf(fileName, "%s", path ); makeFileName ( fileName, STMD_LOGON, time_type, tm ); if ( ( fp = fopen(fileName, APPEND ) ) == NULL ){ sprintf(trcBuf, "%s Open Fail\n", fileName); trclib_writeLog(FL, trcBuf); return -1; } switch (time_type) { case STMD_HOUR : sts_code = STSCODE_STM_PERIODIC_LOGON_HOUR; sprintf (str_time, "%s", STMD_STR_HOUR); break; case STMD_DAY : sts_code = STSCODE_STM_PERIODIC_LOGON_DAY; sprintf (str_time, "%s", STMD_STR_DAY); break; case STMD_WEEK : sts_code = STSCODE_STM_PERIODIC_LOGON_WEEK; sprintf (str_time, "%s", STMD_STR_WEEK); break; case STMD_MONTH : sts_code = STSCODE_STM_PERIODIC_LOGON_MONTH; sprintf (str_time, "%s", STMD_STR_MONTH); break; } sprintf(condBuf," %s %s\n S%04d LOGON PERIODIC STATISTICS MESSAGE\n", "SCM", // 현재는 OMP로 고정하지만 실질적인 시스템 이름으로 변경 필요 hslim_oper commlib_printTStamp(), // 현재시각 time stamp (년,월,일,시,분,초,요일) sts_code); sprintf(tmpBuf, " PERIOD = %s\n MEASURETIME = %s - %s\n\n", str_time, get_period_start_time(time_type), get_period_end_time(time_type)); strcat(condBuf,tmpBuf); sprintf(tmpBuf, " ====================================================================\n"); strcat(condBuf, tmpBuf); sprintf(tmpBuf, "%3s %8s %12s %12s\n","",title[0],title[1],title[2] ); strcat(condBuf, tmpBuf); sprintf(tmpBuf, "%3s %8s %12s %12s %12s %12s\n","","",title[3],title[4],title[5],title[6] ); //uamyd 20110515 succrate_added strcat(condBuf, tmpBuf); sprintf(tmpBuf, "%3s %8s %12s %12s %12s %12s\n", "","", title1[1], title1[2],title1[3],title1[4]); strcat(condBuf, tmpBuf); sprintf(tmpBuf, "%3s %8s %12s %12s %12s %12s\n", "","", title2[1], title2[2],title2[3],title2[4]); strcat(condBuf, tmpBuf); sprintf(tmpBuf, "%3s %8s %12s %12s %12s %12s\n", "","", title3[1], title3[2],title3[3],title3[4]); strcat(condBuf, tmpBuf); sprintf(tmpBuf, "%3s %8s %12s %12s %12s %12s\n", "","", title4[1], title4[2],title4[3],title4[4]); strcat(condBuf, tmpBuf); sprintf(tmpBuf, "%3s %8s %12s %12s %12s %12s\n", "","", title5[1], title5[2],title5[3],title5[4]); strcat(condBuf, tmpBuf); sprintf(tmpBuf, "%3s %8s %12s %12s %12s %12s\n", "","", title6[1], title6[2],title6[3],title6[4]); strcat(condBuf, tmpBuf); sprintf(tmpBuf, "%3s %8s %12s %12s %12s %12s\n", "","", title7[1], title7[2],title7[3],title7[4]); strcat(condBuf, tmpBuf); sprintf(tmpBuf, "%3s %8s %12s %12s %12s %12s\n", "","", title8[1], title8[2],title8[3],title8[4]); strcat(condBuf, tmpBuf); sprintf(tmpBuf, "%3s %8s %12s %12s %12s %12s\n", "","", title10[1], title10[2],title10[3],title10[4]); strcat(condBuf, tmpBuf); sprintf(tmpBuf, "%3s %8s %12s %12s\n", "","", title11[1], title11[2]); strcat(condBuf, tmpBuf); sprintf(tmpBuf, " ====================================================================\n"); strcat(condBuf, tmpBuf); for(i = 0; i < realSysCnt; i++) { realItemCnt = 1; sprintf(query, "SELECT system_name, sm_ch_id, log_mod, " " ifnull(sum(log_req), 0), ifnull(sum(log_succ), 0), ifnull(sum(log_fail), 0), " " ifnull(sum(HBIT_0), 0), ifnull(sum(HBIT_1), 0), ifnull(sum(HBIT_2), 0), " " ifnull(sum(HBIT_3), 0), " " ifnull(sum(HBIT_4), 0), ifnull(sum(HBIT_5), 0), ifnull(sum(HBIT_6), 0), " " ifnull(sum(HBIT_7), 0), " " ifnull(sum(HBIT_8), 0), ifnull(sum(HBIT_9), 0), ifnull(sum(HBIT_10), 0), " " ifnull(sum(HBIT_11), 0), " " ifnull(sum(HBIT_12), 0), ifnull(sum(HBIT_13), 0), ifnull(sum(HBIT_14), 0), " " ifnull(sum(HBIT_15), 0), " " ifnull(sum(HBIT_16), 0), ifnull(sum(HBIT_17), 0), ifnull(sum(HBIT_18), 0), " " ifnull(sum(HBIT_19), 0), " " ifnull(sum(HBIT_20), 0), ifnull(sum(HBIT_21), 0), ifnull(sum(HBIT_22), 0), " " ifnull(sum(HBIT_23), 0), " " ifnull(sum(HBIT_24), 0), ifnull(sum(HBIT_25), 0), ifnull(sum(HBIT_26), 0), " " ifnull(sum(HBIT_27), 0), " " ifnull(sum(HBIT_28), 0), ifnull(sum(HBIT_29), 0), ifnull(sum(HBIT_30), 0), " " ifnull(sum(HBIT_31), 0), " " ifnull(sum(sm_int_err),0), ifnull(sum(op_err),0), ifnull(sum(op_timeout),0), " " ifnull(sum(etc_fail),0), " " ifnull(sum(api_req_err),0), ifnull(sum(api_timeout),0) " " from %s " " where system_name = '%s' AND (stat_date = '%s') " " group by system_name, sm_ch_id, log_mod ", table_type, SysName[i], get_period_select_time(time_type)); if ( trcLogFlag == TRCLEVEL_SQL ) { sprintf(trcBuf, "query = %s\n", query); trclib_writeLog(FL, trcBuf); } if (stmd_mysql_query (query) < 0) { sprintf(trcBuf,">>> mysql_query fail; err=%s\n", mysql_error(conn)); trclib_writeLogErr (FL,trcBuf); if(fp != NULL) fclose(fp); return -1; } select_cnt = 0; result = mysql_store_result(conn); if(strlen(condBuf)) { stmd_txMsg2Cond(condBuf, (sts_code - STSCODE_TO_MSGID_STATISTICS), 1, snd_cnt++); fprintf (fp, "%s",condBuf); memset(condBuf, 0x00, sizeof(condBuf)); } while((row = mysql_fetch_row(result)) != NULL) { row_index = 1; if (select_cnt == 0) { sprintf(tmpBuf, "%3s %8s SM_CH%7s %12s\n", "",SysName[i],row[row_index],!atoi(row[row_index+1])?"LOG_ON":"LOG_OUT"); strcat(condBuf, tmpBuf); } else { sprintf(tmpBuf, "%3s %8s SM_CH%7s %12s\n", "","",row[row_index],!atoi(row[row_index+1])?"LOG_ON":"LOG_OUT"); strcat(condBuf, tmpBuf); } sprintf(tmpBuf, "%3s %8s %12s %12s %12s %12.1f\n", //uamyd 20110515 succrate_added "", "", row[row_index+2],row[row_index+3],row[row_index+4], atoi(row[row_index+2])==0?0.0:(((float)atoi(row[row_index+3])/(float)atoi(row[row_index+2]))*100)); //uamyd 20110515 succrate_added strcat(condBuf, tmpBuf ); for( j=5; j<34; j+=4 ){ //j = 5,9,13,17,21,25,29,33 sprintf(tmpBuf, "%3s %8s %12s %12s %12s %12s\n", "", "", row[row_index+j],row[row_index+j+1],row[row_index+j+2],row[row_index+j+3]); strcat(condBuf, tmpBuf ); } sprintf(tmpBuf, "%3s %8s %12s %12s %12s %12s\n", "", "", row[row_index+37],row[row_index+38],row[row_index+39],row[row_index+40]); strcat(condBuf, tmpBuf); sprintf(tmpBuf, "%3s %8s %12s %12s\n", "", "", row[row_index+41],row[row_index+42]); strcat(condBuf, tmpBuf); sprintf(tmpBuf, " ====================================================================\n"); strcat(condBuf, tmpBuf); select_cnt++; if(strlen(condBuf)) { stmd_txMsg2Cond(condBuf, (sts_code - STSCODE_TO_MSGID_STATISTICS), 1, snd_cnt++); fprintf (fp, "%s",condBuf); memset(condBuf, 0x00, sizeof(condBuf)); } } mysql_free_result(result); if (select_cnt == 0) { sprintf(tmpBuf, "%3s %8s %12s %12s\n", "",SysName[i], "-","-"); strcat(condBuf, tmpBuf); sprintf(tmpBuf, "%3s %8s %12s %12s %12s %12s\n", "", "", "0","0","0","0"); //uamyd 20110515 succrate_added strcat(condBuf, tmpBuf); for(j=0;j<9;j++){ sprintf(tmpBuf, "%3s %8s %12s %12s %12s %12s\n", "", "", "0","0","0","0"); strcat(condBuf, tmpBuf ); } sprintf(tmpBuf, "%3s %8s %12s %12s\n", "", "", "0","0"); strcat(condBuf, tmpBuf); sprintf(tmpBuf, " ====================================================================\n"); strcat(condBuf, tmpBuf); } } sprintf(tmpBuf, " COMPLETED\n\n\n"); strcat(condBuf, tmpBuf); if(fp != NULL) { fprintf (fp, "%s",condBuf); fclose(fp); } stmd_txMsg2Cond(condBuf, (sts_code - STSCODE_TO_MSGID_STATISTICS), 0, snd_cnt); return 1; }
/*=============================================================== routine : main return val : int input par : int argc char *argv[] function : main function ===============================================================*/ int main(int argc, char *argv[]) { double psnr; int headframe, tailframe, skipframe; char *srcname, c, *dd, filename[255]; register int i, j; clock_t start, end; fprintf(stderr, "\nstarting program...\n"); system("date"); start = clock(); /* パラメータの初期化 */ srcname = SRC_NAME; headframe = HEAD_FRAME; tailframe = TAIL_FRAME; skipframe = SKIP_FRAME; /* パラメータの設定 */ if (argc < 1) { fprintf(stderr, "usage : %s [option]\n", argv[0]); fprintf(stderr, " -s <string> source image filename\n"); fprintf(stderr, " -h help\n"); exit(1); } while (--argc > 0) { c = (*++argv)[0]; if (!(c == '-')) fprintf(stderr, "\nunknown option...\n"); else { c = (*argv)[1]; dd = &(*argv)[1]; switch (c) { case 'h': fprintf(stderr, "\nusage : command [option]\n"); fprintf(stderr, " -s <string> source image filename\n"); fprintf(stderr, " -h help\n"); exit(1); break; case 's': if (--argc > 0) { c = (*++argv)[0]; if (c == '-') fprintf(stderr, "\noption error...\n"); else srcname = (*argv); } else { fprintf(stderr, "\noption error \"%s\"...\n", (*argv)); exit(1); } break; default: fprintf(stderr, "\nunknown option...\n"); break; } } } fprintf(stderr, "image size = %dx%d pixel\n", SRC_X_SIZE, SRC_Y_SIZE); fprintf(stderr, "macro block size = %dx%d pixel\n", MB_SIZE, MB_SIZE); fprintf(stderr, "search window x = [-%d:+%d], y = [-%d:+%d]\n", SW_SIZE, SW_SIZE, SW_SIZE, SW_SIZE); fprintf(stderr, "head frame number = %d, tail frame number = %d (skip:%d)\n", headframe, tailframe, skipframe); /* 先頭フレーム名の作成 */ makeFileName(filename, srcname, headframe, ".cif"); fprintf(stderr, "\n[frame no.%d]\n", headframe); fprintf(stderr, "now loading frame data from \"%s\"...\n", filename); /* 先頭フレームの読み込み */ loadRawFloat(filename, premap); for (j = headframe + skipframe; j <= tailframe; j += skipframe) { /* 動きベクトルの初期化 */ for (i = 0; i < MB_X_NUM*MB_Y_NUM; i++) vecx[i] = vecy[i] = 0.0; /* フレーム番号情報の表示 */ fprintf(stderr, "\n[frame no.%d]-[frame no.%d]\n", j - skipframe, j); /* 次フレーム名の作成 */ makeFileName(filename, srcname, j, ".cif"); fprintf(stderr, "now loading frame data from \"%s\"...\n", filename); /* 次フレームの読み込み */ loadRawFloat(filename, crtmap); /* Three Step Search */ greedySearch(premap, crtmap, vecy, vecx); /* 予測画像の作成 */ makePrediction(premap, mcmap, vecy, vecx); /* PSNR の算出 */ psnr = getPsnrFloat(crtmap, mcmap); fprintf(stderr, "psnr = %f [dB]\n", psnr); /* フレームの複写 */ for (i = 0; i < SRC_Y_SIZE*SRC_X_SIZE; i++) premap[i] = crtmap[i]; } fprintf(stderr, "\ndone!!\n"); system("date"); end = clock(); fprintf(stderr, "TIME=%d[ms]\n",end-start); return 0; }