void Index::GetBatchFiles(String directory, String ext, std::vector<VFSFILE> *l) { directory.ReplaceAll("/", "\\"); unsigned long i = 0; while(i < (vfscount)) { fIndex->Seek(offset[i]); fIndex->Skip((12)); // skip vfsinfo to read fileinfo bool isRoot = false; if(!vfsname[i].Compare("ROOT.VFS")) { isRoot = true; } unsigned long j = 0; while(j < vinfo[i]->filecount) { if(isRoot) break; unsigned long thisoffset = fIndex->Position(); unsigned short len; fIndex->Read(len); char *tmp = new char[len]; fIndex->ReadData(tmp, len); fIndex->Skip(12); bool del = false; fIndex->Read(del); fIndex->Skip(10); if(strstr(tmp, directory.Str()) && strstr(tmp, ext.Str())) { if(!del) { VFSFILE vfs; fIndex->Seek(thisoffset); vfs.vfs = vfsname[i].Str(); fIndex->Read(vfs.strlen); vfs.path = new char[vfs.strlen]; fIndex->ReadData(vfs.path, vfs.strlen); fIndex->Read(vfs.offset); // 4 fIndex->Read(vfs.size); // 4 fIndex->Read(vfs.blockSize); // 4 fIndex->Read(vfs.deleted); // 1 fIndex->Read(vfs.compressiontype); // 1 fIndex->Read(vfs.encryptiontype); // 1 fIndex->Read(vfs.version); // 4 fIndex->Read(vfs.checksum); // 4 l->push_back(vfs); } } SAFE_DELETE_ARRAY(tmp); j++; } i++; } }
static TagInfo* TagsMenu(PTagArray pta) { EditorInfo ei; I.EditorControl(ECTL_GETINFO,&ei); MenuList sm; String s; TagArray& ta=*pta; int maxid=0,maxinfo=0; int i; for(i=0;i<ta.Count();i++) { TagInfo *ti=ta[i]; if(ti->name.Length()>maxid)maxid=ti->name.Length(); if(ti->info.Length()>maxinfo)maxinfo=ti->info.Length(); //if(ti->file.Length()>maxfile) } int maxfile=ei.WindowSizeX-8-maxid-maxinfo-1-1-1; for(i=0;i<ta.Count();i++) { TagInfo *ti=ta[i]; s.Sprintf("%c:%s%*s %s%*s %s",ti->type,ti->name.Str(),maxid-ti->name.Length(),"", ti->info.Length()?ti->info.Str():"",maxinfo-ti->info.Length(),"", TrimFilename(ti->file,maxfile).Str() ); sm<<MI(s.Str(),i); } int sel=Menu(GetMsg(MSelectSymbol),sm,0,MF_FILTER|MF_SHOWCOUNT); if(sel==-1)return NULL; return ta[sel]; }
MI_Result Context::Post( const Instance& indication, MI_Uint32 subscriptionIDCount, const String& bookmark) { return MI_PostIndication(m_context, indication.m_instance, subscriptionIDCount, bookmark.Str()); }
//---------------------------------------------------------------------------------------------------------------------------------------------------- String EditorControl::GetTextRange( LONG Begin, LONG End ) { TextRange Range; String Text; SIZE_T Length = End-Begin; Text.Resize(Length); Range.lpstrText = Text.Str(); Range.chrg.cpMin = Begin; Range.chrg.cpMax = End; EditFunc( SCI_GETTEXTRANGE, 0, (WPARAM)&Range ); return Text; }
MI_Result Context::Post(MI_Result result, const String& message) { if (NULL != m_result) { *m_result = result; return MI_RESULT_OK; } MI_Result r = MI_PostResultWithMessage(m_context, result, message.Str()); // invalidate context, since PostResult must be the last operation on // MI_Context m_context = 0; return r; }
void ParameterSearchBinaryCombo::ProcessCmdLineStr (String cmdLine) { char* arguments[60]; int argCount = 0; arguments[0] = strdup ("ParameterSearchBinaryCombo"); argCount++; while (!cmdLine.Empty ()) { String parmField = cmdLine.ExtractToken (" "); arguments[argCount] = strdup (parmField.Str ()); argCount++; } ParseCommandLine (argCount, arguments); } /* CommandLineStr */
ParameterJob::ParameterJob (RunLog& _log, String _desc ): log (_log) { accuracy = 0; startTime = 0; _desc.TrimLeft (); curStatus = _desc.ExtractChar (); if ((curStatus == '0') || (curStatus == '1') || (curStatus == '2') || (curStatus == '3') ) { // We Are Ok } else { log.Level (-1) << endl << "ParameterJob: We have an invalid Cur Status." << endl; osWaitForEnter (); } { String processsNumField = _desc.ExtractToken (" ,\t"); processNum = atoi (processsNumField.Str ()); } { String jobIdField = _desc.ExtractToken (" ,\t"); jobId = atoi (jobIdField.Str ()); } { String cParmStr = _desc.ExtractToken (" ,\t"); cParm = atoi (cParmStr.Str ()); } { String gammaParmStr = _desc.ExtractToken (" ,\t"); gammaParm = atof (gammaParmStr.Str ()); } { String aParmStr = _desc.ExtractToken (" ,\t"); aParm = atoi (aParmStr.Str ()); } { String accuracyField = _desc.ExtractToken (" ,\t"); accuracy = atof (accuracyField.Str ()); } }
template<> void Add(String& value){ unsigned short size = unsigned short(value.Length()); memcpy(mBuffer + mSize, value.Str(), size); mSize += size; mBuffer[mSize++] = 0; }
ParameterProcess::ParameterProcess (RunLog& _log, ImageClassList& imageClasses, String _desc ): log (_log) { highestAccuracy = (FFLOAT)0.0; startTime = 0; _desc.TrimLeft (); curStatus = _desc.ExtractChar (); if ((curStatus == '0') || (curStatus == '1') || (curStatus == '2') ) { // We Are Ok } else { log.Level (-1) << endl << "ParameterProcess: We have an invalid Cur Status[" << curStatus << "]." << endl; exit (-1); } { String processsNumField = _desc.ExtractToken (" ,\t"); processNum = atoi (processsNumField.Str ()); } { String jobIdField = _desc.ExtractToken (" ,\t"); jobId = atoi (jobIdField.Str ()); } { // Lets get the two Classes that we are running for String class0Name = _desc.ExtractToken (" ,\t"); String class1Name = _desc.ExtractToken (" ,\t"); if (class0Name == "NoName") { class0 = class1 = NULL; } else { class0 = imageClasses.LookUpByName (class0Name); class1 = imageClasses.LookUpByName (class1Name); if (!class0) { cerr << endl << "*** ERROR *** ParameterProcess, Invalid Class0[" << class0Name << "]." << endl << endl; exit (-1); } if (!class1) { cerr << endl << "*** ERROR *** ParameterProcess, Invalid Class0[" << class1Name << "]." << endl << endl; exit (-1); } } } { String cParmStr = _desc.ExtractToken (" ,\t"); cParm = atoi (cParmStr.Str ()); } { String gammaParmStr = _desc.ExtractToken (" ,\t"); gammaParm = atof (gammaParmStr.Str ()); } { String aParmStr = _desc.ExtractToken (" ,\t"); aParm = atoi (aParmStr.Str ()); } { String highestAccuracyField = _desc.ExtractToken (" ,\t"); highestAccuracy = (FFLOAT)atof (highestAccuracyField.Str ()); } }
void ParameterSearchBinaryCombo::UpdateCurrentStatusFile () { log.Level (20) << "ParameterSearchBinaryCombo::UpdateCurrentStatusFile - Updating Current Status File." << endl; int openAttempts = 0; statusFile = NULL; while ((!statusFile) && (openAttempts < 3)) { openAttempts++; log.Level (50) << "UpdateCurrentStatusFile Oppen Attempt[" << openAttempts << "]." << endl; statusFile = fopen (statusFileName, "w"); if (!statusFile) { log.Level (0) << "UpdateCurrentStatusFile - *** WARNING *** Can Not Open Status File[" << statusFileName << "] -Will Retry-." << endl; #ifdef WIN32 Sleep (2000); #else sleep (2); #endif } } if (!statusFile) { log.Level (-1) << "UpdateCurrentStatusFile - *** ERROR *** Can not Create Status File[" << statusFileName << "]." << endl; EndBlock (); exit (1); osWaitForEnter (); } log.Level (50) << "UpdateCurrentStatusFile - Status File Opened Successfully." << endl; String s; s = CommandLineStr (); fprintf (statusFile, "%s\n", s.Str ()); fprintf (statusFile, "%d\t %f\n", numOfProcesses, highestAccuracySoFar ); { // Generate Master Class List Line. String masterClassListLine; masterClassListLine << numOfClasses; for (int idx = 0; idx < numOfClasses; idx++) { masterClassListLine << "\t" << masterClassList[idx]->Name (); } fprintf (statusFile, "%s\n", masterClassListLine.Str ()); } { // Write Out Next Class IDX's fprintf (statusFile, "%d\t%d\n", nextClass0IDX, nextClass1IDX); } ParameterProcessListIterator jIDX (*processes); ParameterProcessPtr process; for (jIDX.Reset (); process = jIDX.CurPtr (); ++ jIDX) { fprintf (statusFile, "%s\n", process->ToString ().Str ()); } fclose (statusFile); statusFile = NULL; log.Level (50) << "UpdateCurrentStatusFile - Exiting." << endl; } /* UpdateCurrentStatusFile */
FARAPI(int) Configure(int item) { struct InitDialogItem InitItems[]={ /*Type X1 Y2 X2 Y2 F S Flags D Data */ /*00*/ DI_DOUBLEBOX, 3, 1,64,13, 0,0, 0,0,(char*)MPlugin, /*01*/ DI_TEXT, 5, 2, 0, 0, 0,0, 0,0,(char*)MPathToExe, /*02*/ DI_EDIT, 5, 3,62, 3, 1,0, 0,0,"", /*03*/ DI_TEXT, 5, 4, 0, 0, 0,0, 0,0,(char*)MCmdLineOptions, /*04*/ DI_EDIT, 5, 5,62, 5, 1,0, 0,0,"", /*05*/ DI_TEXT, 5, 6, 0, 0, 0,0, 0,0,(char*)MAutoloadFile, /*06*/ DI_EDIT, 5, 7,62, 7, 1,0, 0,0,"", /*07*/ DI_TEXT, 5, 8, 0, 0, 0,0, 0,0,(char*)MWordChars, /*08*/ DI_EDIT, 5, 9,62, 9, 1,0, 0,0,"", /*09*/ DI_CHECKBOX, 5, 10,62,10,1,0, 0,0,(char*)MCaseSensFilt, /*10*/ DI_TEXT, 5,11,62,10, 1,0,DIF_SEPARATOR|DIF_BOXCOLOR,0,"", /*11*/ DI_BUTTON, 0,12, 0, 0, 0,0,DIF_CENTERGROUP,1,(char *)MOk, /*12*/ DI_BUTTON, 0,12, 0, 0, 0,0,DIF_CENTERGROUP,0,(char *)MCancel }; struct FarDialogItem DialogItems[sizeof(InitItems)/sizeof(InitItems[0])]; InitDialogItems(InitItems,DialogItems,sizeof(InitItems)/sizeof(InitItems[0])); Registry r(HKEY_CURRENT_USER); if(!r.Open(rootKey)) { Msg(MRegFailed); return FALSE; } char buf[512]; if(r.Get("pathtoexe",buf,sizeof(buf))) { strcpy(DialogItems[2].Data.Data,buf); }else { strcpy(DialogItems[2].Data.Data,"ctags.exe"); } if(r.Get("commandline",buf,sizeof(buf))) { strcpy(DialogItems[4].Data.Data,buf); }else { wsprintf(DialogItems[4].Data.Data,"%s","--c++-types=+px --c-types=+px --fields=+n -R *"); } if(r.Get("autoload",buf,sizeof(buf))) { strcpy(DialogItems[6].Data.Data,buf); } if(r.Get("wordchars",buf,sizeof(buf))) { strcpy(DialogItems[8].Data.Data,buf); }else { String s; for(int i=0;i<256;i++) { if(isalnum(i) || i=='$' || i=='_' || i=='~') { s+=(char)i; } } strcpy(DialogItems[8].Data.Data,s.Str()); } if(r.Get("casesensfilt",buf,sizeof(buf))) { DialogItems[9].Param.Selected=!stricmp(buf,"true"); }else { DialogItems[9].Param.Selected=1; } int ExitCode=I.Dialog(I.ModuleNumber,-1,-1,68,15,"ctagscfg",DialogItems,sizeof(DialogItems)/sizeof(DialogItems[0])); if(ExitCode!=11)return FALSE; r.Set("pathtoexe",DialogItems[2].Data.Data); r.Set("commandline",DialogItems[4].Data.Data); r.Set("autoload",DialogItems[6].Data.Data); r.Set("wordchars",DialogItems[8].Data.Data); r.Set("casesensfilt",DialogItems[9].Param.Selected?"True":"False"); return TRUE; }
int Menu(const char *title,MenuList& lst,int sel,int flags=MF_LABELS,const void* param=NULL) { Vector<FarMenuItem> menu; menu.Init(lst.Count()); static const char labels[]="1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ"; static const int labelsCount=sizeof(labels)-1; int i=0; int j=0; char buf[16]; ZeroMemory(&menu[0],sizeof(FarMenuItem)*lst.Count()); if(!(flags&MF_FILTER)) { for(i=0;i<lst.Count();i++) { if((flags&MF_LABELS)) { if(i<labelsCount) { sprintf(buf,"&%c ",labels[i]); strcpy(menu[i].Text,buf); }else { strcpy(menu[i].Text," "); } strcat(menu[i].Text,lst[i].item.Substr(0,120)); }else { strcpy(menu[i].Text,lst[i].item.Substr(0,120)); } if(sel==i)menu[i].Selected=1; } String cnt; cnt.Sprintf(" %s%d ",GetMsg(MItemsCount),lst.Count()); int res=I.Menu(I.ModuleNumber,-1,-1,0,FMENU_WRAPMODE,title,flags&MF_SHOWCOUNT?cnt.Str():NULL, "content",NULL,NULL,&menu[0],lst.Count()); return res!=-1?lst[res].data:res; }else { String filter=param?(char*)param:""; Vector<int> idx; Vector<int> fk; static const char *filterkeys="1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_$\\\x08-_=|;':\",./<>? []*&^%#@!~"; int shift; for(i=0;filterkeys[i];i++) { DWORD k=VkKeyScan(filterkeys[i]); if(k==0xffff) { fk.Push(0); continue; } shift=(k&0xff00)>>8; if(shift==1)shift=4; else if (shift==2)shift=1; else if (shift==4)shift=2; k=(k&0xff)|(shift<<16); fk.Push(k); } fk.Push(0); #ifdef DEBUG //DebugBreak(); #endif int mode=0; for(;;) { int oldj=j; j=0; String match=""; int minit=0; int fnd=-1,oldfnd=-1; idx.Clean(); for(i=0;i<lst.Count();i++) { lst[i].item.SetNoCase(!config.casesens); if(filter.Length() && (fnd=lst[i].item.Index(filter))==-1)continue; if(!minit && fnd!=-1) { match=lst[i].item.Substr(fnd); minit=1; } if(oldfnd!=-1 && oldfnd!=fnd) { oldj=-1; } if(fnd!=-1 && filter.Length()) { int xfnd=-1; while((xfnd=lst[i].item.Index(filter,xfnd+1))!=-1) { for(int k=0;k<match.Length();k++) { if(xfnd+k>=lst[i].item.Length() || (config.casesens && match[k]!=lst[i].item[xfnd+k]) || (!config.casesens && tolower(match[k])!=tolower(lst[i].item[xfnd+k])) ) { match.Delete(k); break; } } } } idx.Push(i); strcpy(menu[j].Text,lst[i].item.Substr(0,120)); if(sel==j)menu[j].Selected=1; j++; if(fnd!=-1)oldfnd=fnd; } if((mode==0 && j==0) || (mode==1 && j==oldj)) { if(filter.Length()) { //DebugBreak(); filter.Delete(-1); continue; } } if(sel>j) { menu[j-1].Selected=1; } if(match.Length()>filter.Length() && j>1 && mode!=1) { filter=match; } String cnt; cnt.Sprintf(" %s%d ",GetMsg(MItemsCount),j); int bkey; String ftitle=title; ftitle+=" ["+filter+"]"; int res=I.Menu(I.ModuleNumber,-1,-1,0,FMENU_WRAPMODE|FMENU_SHOWAMPERSAND,ftitle, flags&MF_SHOWCOUNT?cnt.Str():NULL,"content",&fk[0],&bkey,&menu[0],j); if(res==-1 && bkey==-1)return -1; if(bkey==-1) { return lst[idx[res]].data; } int key=filterkeys[bkey]; if(key==8) { filter.Delete(-1); mode=1; continue; } filter+=(char)key; mode=0; sel=res; } } }
void ParameterSearch::UpdateCurrentStatusFile () { log.Level (20) << "ParameterSearch::UpdateCurrentStatusFile - Updating Current Status File." << endl; int openAttempts = 0; statusFile = NULL; while ((!statusFile) && (openAttempts < 3)) { openAttempts++; log.Level (50) << "UpdateCurrentStatusFile Oppen Attempt[" << openAttempts << "]." << endl; statusFile = fopen (statusFileName, "w"); if (!statusFile) { log.Level (0) << "UpdateCurrentStatusFile - *** WARNING *** Can Not Open Status File[" << statusFileName << "] -Will Retry-." << endl; #ifdef WIN32 Sleep (2000); #else sleep (2); #endif } } if (!statusFile) { log.Level (-1) << "UpdateCurrentStatusFile - *** ERROR *** Can not Create Status File[" << statusFileName << "]." << endl; EndBlock (); exit (1); osWaitForEnter (); } log.Level (50) << "UpdateCurrentStatusFile - Status File Opened Successfully." << endl; String s; s = CommandLineStr (); fprintf (statusFile, "%s\n", s.Str ()); fprintf (statusFile, "%d\t %d\t %f\n", numOfProcesses, nextJobId, highestAccuracySoFar ); fprintf (statusFile, "%d\t %f\t %d\n", nextC, nextGamma, nextA ); ParameterJobListIterator jIDX (*processes); ParameterJobPtr process; for (jIDX.Reset (); process = jIDX.CurPtr (); ++ jIDX) { fprintf (statusFile, "%s\n", process->ToString ().Str ()); } fclose (statusFile); statusFile = NULL; log.Level (50) << "UpdateCurrentStatusFile - Exiting." << endl; } /* UpdateCurrentStatusFile */