BOOL insert_value(unit_box *boxes, INDEX index, UNIT val, INDEX i,INDEX j) { BOOL ret = TRUE; INDEX ri = 0, ci = 0, bi = 0; bi = index; ri = GET_ROW(bi)*COLUMN + i; ci = GET_COLUMN(bi)*ROW + j; if(val > 0 && val <= TOTAL) { ret = (IS_FLAG(box[bi], val-1) || IS_FLAG(row[ri], val-1) || IS_FLAG(column[ci],val-1)) ? FALSE : TRUE; } else ret = FALSE; if(ret) { if(debug) printf("\nPREV VAL (%d, %d, %d) : %d",index, i, j, boxes[index].value[i][j]); boxes[index].value[i][j] = val; SET_FLAG(box[bi], val-1); SET_FLAG(row[ri], val-1); SET_FLAG(column[ci], val-1); if(debug) printf("\nNEW VAL (%d, %d, %d) : %d",index, i, j, boxes[index].value[i][j]); } return ret; }
void clone_link(WorkPtr work) { int r, s; int i, j, rootI, rootJ, *index; index = work->index; #ifndef NOAUXINFO for(r=work->i_beg; r<work->i_end; r++) { i = (index == NULL) ? r : index[r]; if (IGNORE_SEQ(i)) continue; if (seqInfo[i].len<window_len) continue; for(s=MAX(r+1,work->j_beg); s<work->j_end; s++) { j = (index == NULL) ? s : index[s]; rootI = mini_find_parent(i); rootJ = mini_find_parent(j); if ((rootI != rootJ) && !(IS_FLAG(FIX,rootI)&&IS_FLAG(FIX,rootJ) )) if ((strlen(seqID[i].clone)>0) && (strlen(seqID[j].clone)>0) && (strcmp(seqID[i].clone,seqID[j].clone)==0)) { make_uniond2(rootI,rootJ,0); } } } PLOCK(&find_parent_mutex); for(i=0; i<num_seqs; i++) tree[i].cluster = find_parent(i); PUNLOCK(&find_parent_mutex); #endif }
void TrafficInformation::Init(HANDLE h,int tMsg,int OpMode,FP_SizeItemList* il) { memset(this,0,sizeof(*this)); memset(Lines,' ',MAX_TRAF_LINES*MAX_TRAF_WIDTH); TitleMsg = tMsg; TotalStartTime = time(NULL); FullFileSize = -1; if(IS_FLAG(OpMode,OPM_FIND)) { ShowStatus = FALSE; } else if(IS_FLAG(OpMode,OPM_VIEW) || IS_FLAG(OpMode,OPM_EDIT)) { if(FTP_Info->GetOpt()->ShowSilentProgress) ShowStatus = TRUE; else ShowStatus = FALSE; } else ShowStatus = TRUE; if(il) for(int i = 0; i < il->Count(); i++) if(!IS_FLAG(il->List[i].FindData.dwFileAttributes,FILE_ATTRIBUTE_DIRECTORY) && il->List[i].FindData.dwReserved1 != MAX_DWORD) { TotalFullSize += ((__int64)il->List[i].FindData.nFileSizeHigh) << 32 | il->List[i].FindData.nFileSizeLow; TotalFiles++; } }
BOOL ITable::Assign( PHDBTableInfo p,DWORD fl ) { WORD n; Flags = fl | (p->Type & HDB_TBT_MASK); //Number of columns cCount = 0; while( p->CInfo[cCount].Name ) cCount++; if ( !cCount ) { SetError( "Table info for [%s] does not contains columns",p->Name ); return FALSE; } //Copy info memcpy( this, p, sizeof(*p) ); CInfo = NULL; Values = NULL; if ( IS_FLAG(Flags,HDB_DBF_NONCONST) ) { if ( !DupName( Name, p->Name ) ) return FALSE; } else Name = p->Name; //Create values Values = new HDBValue[ cCount+1 ]; if ( !Values ) return FALSE; //Create infos CInfo = new HDBColumnInfo[ cCount+1 ]; if ( !CInfo ) return FALSE; //Copy values infos and set RecSize RecSize = 0; for( n = 0; n <= cCount; n++ ) { ((HDBColumnInfo&)Values[n]) = p->CInfo[n]; Values[n].Value.Data = NULL; if ( IS_FLAG(Flags,HDB_DBF_NONCONST) ) { if ( !DupName( Values[n].Name, p->CInfo[n].Name ) ) return FALSE; } CInfo[n] = p->CInfo[n]; if ( IS_FLAG(Flags,HDB_DBF_NONCONST) ) { if ( !DupName( CInfo[n].Name, p->CInfo[n].Name ) ) return FALSE; } RecSize += Values[n].Size; } return TRUE; }
void complete_pairwise_cluster(WorkPtr work, int i, int * candidates, int num_cands) { int s, limit; int j, rootI, rootJ; int num_mat_pos, num_mat_rc; if (clonelink) clone_link(work); if (IGNORE_SEQ(i)) return; if (seqInfo[i].len<window_len) return; set_up_word_table(work, i); for(s=0; s<num_cands; s++) { j = candidates[s]; //printf(" Candidated %d\n",j); rootI = mini_find_parent(i); rootJ = mini_find_parent(j); assert(i<num_seqs); if ((rootI != rootJ) && !(IS_FLAG(FIX,rootI)&&IS_FLAG(FIX,rootJ) )) { // only try to cluster if not already clustered // and both are not fixed lcusters NUM_num_matches++; limit = seqInfo[j].len/BASESPERELT-1; check_heuristics(i,j,limit,&num_mat_pos,&num_mat_rc); if( (num_mat_pos >= NM_threshold) && (!IGNORE_SEQ(j)) && (d2(work,i,j,0)<=theta)) { merge_pair(work,rootI,i,rootJ,j,0); }; if ( rc_check && (num_mat_rc >= NM_threshold)&& (!IGNORE_SEQ(j)) && (d2(work,i,j,1)<=theta)){ merge_pair(work,rootI,i,rootJ,j,1); } } } clear_word_table(work,i); PLOCK(&find_parent_mutex); for(s=0; s<num_cands; s++) tree[candidates[s]].cluster = find_parent(candidates[s]); PUNLOCK(&find_parent_mutex); }
void ITable::Closeup( void ) { WORD n; if ( IS_FLAG(Flags,HDB_DBF_NONCONST) || IS_FLAG(Flags,HDB_DBF_NMDYNAMIC) ) { StrFree( Name ); for( n = 0; n < cCount; n++ ) { StrFree( Values[n].Name ); StrFree( CInfo[n].Name ); } } delete[] CInfo; CInfo = NULL; delete[] Values; Values = NULL; }
LPCSTR FTP::InsertCurrentToQueue(void) { PanelInfo pi, api; FP_SizeItemList backup,il; FTPCopyInfo ci; if(!FP_Info->Control(this, FCTL_GETPANELINFO, &pi) || !FP_Info->Control(INVALID_HANDLE_VALUE, FCTL_GETANOTHERPANELSHORTINFO, &api)) return FMSG(MErrGetPanelInfo); if(pi.SelectedItemsNumber <= 0 || pi.SelectedItemsNumber == 1 && !IS_FLAG(pi.SelectedItems[0].Flags,PPIF_SELECTED)) return FMSG(MErrNoSelection); backup.Add(pi.SelectedItems, pi.SelectedItemsNumber); BOOL rc = ExpandList(backup.Items(), backup.Count(), &il, TRUE); FP_Screen::FullRestore(); if(!rc) return GetLastError() == ERROR_CANCELLED ? NULL : FMSG(MErrExpandList); ci.Download = TRUE; if(api.PanelType != PTYPE_FILEPANEL || api.Plugin) ci.DestPath = ""; else ci.DestPath = api.CurDir; ListToQueque(&il, &ci); return NULL; }
LPCSTR FTP::InsertAnotherToQueue(void) { FP_SizeItemList backup,il; PanelInfo pi; FTPCopyInfo ci; if(!hConnect || ShowHosts) return FMSG(MQErrUploadHosts); if(!FP_Info->Control(INVALID_HANDLE_VALUE, FCTL_GETANOTHERPANELINFO, &pi)) return FMSG(MErrGetPanelInfo); if(pi.SelectedItemsNumber <= 0 || pi.SelectedItemsNumber == 1 && !IS_FLAG(pi.SelectedItems[0].Flags,PPIF_SELECTED)) return FMSG(MErrNoSelection); if(pi.PanelType != PTYPE_FILEPANEL || pi.Plugin) return FMSG(MErrNotFiles); backup.Add(pi.SelectedItems, pi.SelectedItemsNumber); BOOL rc = ExpandList(backup.Items(), backup.Count(), &il, FALSE); FP_Screen::FullRestore(); if(!rc) return GetLastError() == ERROR_CANCELLED ? NULL : FMSG(MErrExpandList); ci.Download = FALSE; GetCurPath(ci.DestPath); ListToQueque(&il, &ci); return NULL; }
CONSTSTR UnassembeInfo::HexDigit( DWORD Value,char Sign,BOOL Compress ) { static char str[ 20 ]; char ch,*m; if ( Sign == ' ' ) if ( ((signed)Value) < 0 ) { Value = (DWORD)( -((signed)Value) ); Sign = '-'; } else Sign = '+'; m = str + 2 + SNprintf( str+2,sizeof(str)-2, (Sign || Compress) ? "%X" : "%08X", Value ); if ( IS_FLAG(Flags,DISASM_HEXOUT) && Value > 9 ) *m++ = 'h'; *m = 0; ch = (char)toupper(str[2]); if ( ch >= 'A' && ch <= 'Z' ) { str[1] = '0'; if ( Sign ) { str[0] = Sign; return str; } else return str+1; } else if ( Sign ) { str[1] = Sign; return str+1; } else return str+2; }
static CONSTSTR addr_to_hex(DWORD addr, int useSign, int opSize) { char signchar = (char)( useSign ? '+' : 0 ); //Create digit if ( useSign || !IS_FLAG(Info->CurrentFlags,DISASM_FL_CODE) ) switch( opSize ) { case 1: if ( ((signed char)addr) < 0 ) { addr = (signed long)( -((signed char)addr) ); signchar = '-'; } break; case 2: if ( ((signed short)addr) < 0 ) { addr = (signed long)( -((signed short)addr) ); signchar = '-'; } break; case 4: default: opSize = 4; if ( ((signed long)addr) < 0 ) { addr = (signed long)( -((signed long)addr) ); signchar = '-'; } break; } //Call handler Info->Operand( addr,signchar,opSize ); return Info->HexDigit( addr, signchar, TRUE ); }
void FTP::ListToQueque(FP_SizeItemList* il, FTPCopyInfo* ci) { for(int n = 0; n < il->Count(); n++) { FAR_FIND_DATA* p = &il->Item(n)->FindData; //Skip dirs if(IS_FLAG(p->dwFileAttributes,FILE_ATTRIBUTE_DIRECTORY)) continue; //Skip deselected in list if(p->dwReserved1 == MAX_DWORD) continue; AddToQueque(p, ci->DestPath.c_str(), ci->Download); } }
void MergeSlaveClusterTable(int32_t *buffer, int rlen) { // Get the slave's cluster table and add to ours int i, id, rep, rep_root, last; int q; assert(rlen%MPIBUFRECSZ==0); assert(rlen<MPIBUFRECSZ*num_seqs); last = -1; for(i=0; i<rlen; ) { id = buffer[i]; i++; rep= buffer[i]; i++; #ifdef MPIORIENT int witness, orient; witness = buffer[i]; i++; orient = buffer[i]; i++; #endif PLOCK(&write_union_mutex); PLOCK(&find_parent_mutex); if (last != rep) { last = rep; rep_root = find_parent(rep); } id = find_parent(id); if (id == rep_root) { PUNLOCK(&find_parent_mutex); PUNLOCK(&write_union_mutex); continue; } // if (orient) invert_orientation(j); q = tree[rep_root].last; tree[q].next = id; tree[rep_root].last = tree[id].last; tree[id].cluster = rep_root; if (IS_FLAG(FIX,id)) SET_FLAG(FIX,rep_root); assert(tree[tree[rep_root].last].next<0); PUNLOCK(&write_union_mutex); PUNLOCK(&find_parent_mutex); } }
void FP_ItemList::Free(PluginPanelItem *List,int count) { PluginPanelItem *p = List; for(int i = 0; i < count; i++,List++) { //UserData if(IS_FLAG(List->Flags,PPIF_USERDATA)) { free((char*)List->UserData); List->UserData = 0; } //CustomColumn for(int n = 0; n < List->CustomColumnNumber; n++) free(List->CustomColumnData[n]); if(List->CustomColumnData) free(List->CustomColumnData); //Description if(List->Description) free(List->Description), List->Description = NULL; //Owner if(List->Owner) free(List->Owner), List->Owner = NULL; //Additionals if(FPIL_ADDEXIST(List)) { free(FPIL_ADDDATA(List)); List->Reserved[0] = 0; List->Reserved[1] = 0; } } free(p); }
intptr_t WINAPI ProcessPanelEventW(const struct ProcessPanelEventInfo *Info) { if(!Info->hPanel || INVALID_HANDLE_VALUE == Info->hPanel) return FALSE; switch(Info->Event) { case FE_CLOSE: PanelInfo PInfo; fInfo.PanelControl(Info->hPanel, FCTL_GETPANELINFO, 0, (void *)&PInfo); conf.SortMode = PInfo.SortMode; conf.PanelMode = PInfo.ViewMode; conf.SortOrder = IS_FLAG(PInfo.Flags, PFLAGS_REVERSESORTORDER); conf.Save(); break; } return FALSE; }
void FTPHost::MkUrl(String& str,LPCSTR Path,LPCSTR nm,BOOL sPwd) { bool defPara = StrCmp(User,"anonymous") == 0 && StrCmp(Password,Opt.DefaultPassword) == 0; if(!defPara && User[0]) { if(Password[0]) str.printf("ftp://%s:%s@%s", User, (sPwd || IS_FLAG(Opt.PwdSecurity,SEC_PLAINPWD)) ? Password : "", Host); else str.printf("ftp://%s@%s",User,Host); } else str.printf("ftp://%s",Host); if(Path && *Path) { if(*Path != '/') str.Add('/'); str.cat(Path); } if(nm && *nm) { int len = str.Length()-1; if(len >= 0 && str[len] != '/' && str[len] != '\\') str.Add('/'); str.Add(nm); } FixFTPSlash(str); }
BOOL FTP::ShowFilesList(FP_SizeItemList* il) { int cn,n,i,w, num; int Breaks[] = { VK_INSERT, VK_F2, 0 }, BNumber; char str[ 500 ]; PluginPanelItem *p; FarMenuItem *mi = NULL; char *m,*nm; if(!il || !il->Count()) return FALSE; //Create|Recreate mi = (FarMenuItem *)realloc(mi,il->Count()*sizeof(FarMenuItem)); memset(mi, 0, il->Count()*sizeof(FarMenuItem)); //Scan number of items w = cn = 0; for(i = n = 0; n < il->Count(); n++) { p = il->Item(n); p->NumberOfLinks = StrSlashCount(FTP_FILENAME(p)); p->FindData.dwReserved1 = 0; w = Max(w,static_cast<int>(strlen(PointToName(FTP_FILENAME(p)))) + (int)p->NumberOfLinks + 1); cn++; MNUM(mi[i++]) = n; } w = Min(Max(60,Min(w,MSZ)),FP_ConWidth()-8); if(!cn) return FALSE; //Calc length of size and count digits int szSize = 0, szCount = 0; for(n = 0; n < cn; n++) { p = il->Item(MNUM(mi[n])); FDigit(str, ((__int64)p->FindData.nFileSizeHigh) << 32 | p->FindData.nFileSizeLow, -1); szSize = Max(static_cast<int>(strlen(str)),szSize); if(IS_FLAG(p->FindData.dwFileAttributes,FILE_ATTRIBUTE_DIRECTORY)) { FDigit(str,p->FindData.dwReserved0,-1); szCount = Max(static_cast<int>(strlen(str)),szCount); } } //Filename width w -= szSize + szCount + 6; //Set menu item text for(n = 0; n < cn; n++) { p = il->Item(MNUM(mi[n])); m = mi[n].Text; for(i = 0; i < (int)p->NumberOfLinks; i++) { *(m++) = ' '; *(m++) = ' '; } nm = PointToName(FTP_FILENAME(p)); for(i = (int)(m - mi[n].Text); i < w; i++) if(*nm) *(m++) = *(nm++); else *(m++) = ' '; *(m++) = (*nm) ? FAR_SBMENU_CHAR : ' '; if(szSize) { *(m++) = ' '; *(m++) = FAR_VERT_CHAR; *(m++) = ' '; FDigit(str, ((__int64)p->FindData.nFileSizeHigh) << 32 | p->FindData.nFileSizeLow, -1); m += sprintf(m,"%*s",szSize,str); } if(szCount) { *(m++) = ' '; *(m++) = FAR_VERT_CHAR; *(m++) = ' '; if(IS_FLAG(p->FindData.dwFileAttributes,FILE_ATTRIBUTE_DIRECTORY)) FDigit(str,p->FindData.dwReserved0,-1); else str[0] = 0; m += sprintf(m,"%*s",szCount,str); } *m = 0; } num = -1; do { //Set selected for(n = 0; n < cn; n++) mi[n].Checked = il->Items()[ MNUM(mi[n])].FindData.dwReserved1 != MAX_DWORD; //Title __int64 tsz = 0,tcn = 0; for(n = 0; n < cn; n++) { p = il->Item(MNUM(mi[n])); if(p->FindData.dwReserved1 != MAX_DWORD && !IS_FLAG(p->FindData.dwFileAttributes,FILE_ATTRIBUTE_DIRECTORY)) { tsz += ((__int64)p->FindData.nFileSizeHigh) << 32 | p->FindData.nFileSizeLow; tcn++; } } StrCpy(str,FP_GetMsg(FMSG(MListTitle)),ARRAYSIZE(str)); StrCat(str," (",ARRAYSIZE(str)); StrCat(str,FDigit(NULL,tsz,-1),ARRAYSIZE(str)); if(il->TotalFullSize != tsz) { StrCat(str,"{",ARRAYSIZE(str)); StrCat(str,FDigit(NULL,il->TotalFullSize,-1),ARRAYSIZE(str)); StrCat(str,"}",ARRAYSIZE(str)); } StrCat(str,"/",ARRAYSIZE(str)); StrCat(str,FDigit(NULL,tcn,-1),ARRAYSIZE(str)); if(tcn != il->TotalFiles) { StrCat(str,"{",ARRAYSIZE(str)); StrCat(str,FDigit(NULL,il->TotalFiles,-1),ARRAYSIZE(str)); StrCat(str,"}",ARRAYSIZE(str)); } StrCat(str,")",ARRAYSIZE(str)); //Menu n = FP_Info->Menu(FP_Info->ModuleNumber,-1,-1,0,FMENU_SHOWAMPERSAND, str, FP_GetMsg(FMSG(MListFooter)), "FTPFilesList", Breaks, &BNumber, mi,cn); //key ESC if(n == -1) { num = FALSE; break; } //key Enter if(BNumber == -1) { num = TRUE; break; } //Set selected if(num != -1) mi[num].Selected = FALSE; num = n; mi[num].Selected = TRUE; //Process keys bool set; switch(BNumber) { /*INS*/ case 0: //Current p = il->Item(MNUM(mi[num])); //Next item n = num+1; //Switch selected set = p->FindData.dwReserved1 != MAX_DWORD; p->FindData.dwReserved1 = set ? MAX_DWORD : 0; //Switch all nested if(IS_FLAG(p->FindData.dwFileAttributes,FILE_ATTRIBUTE_DIRECTORY)) { i = StrSlashCount(FTP_FILENAME(p)); for(; n < cn; n++) { p = il->Item(MNUM(mi[n])); if(StrSlashCount(FTP_FILENAME(p)) <= i) break; p->FindData.dwReserved1 = set ? MAX_DWORD : 0; } } //INS-moves-down if(n < cn) { mi[num].Selected = FALSE; mi[n].Selected = TRUE; num = n; } break; /*F2*/ case 1: SaveList(il); break; } } while(true); free(mi); if(!num) return FALSE; return TRUE; }
void FP_ItemList::Copy(PluginPanelItem *dest,const PluginPanelItem *src,int cn) { if(!cn) return; memmove(dest, src, sizeof(*dest)*cn); for(; cn; cn--,src++,dest++) { //User data if(IS_FLAG(src->Flags,PPIF_USERDATA)) { DWORD sz = (src->UserData && !IsBadReadPtr((void*)src->UserData,sizeof(DWORD))) ? (*((DWORD*)src->UserData)) : 0; if(sz && !IsBadReadPtr((void*)src->UserData,sz)) { dest->UserData = (DWORD_PTR)malloc(sz+1); memmove((char*)dest->UserData,(char*)src->UserData,sz); } else { dest->UserData = 0; CLR_FLAG(dest->Flags,PPIF_USERDATA); } } //CustomColumn if(src->CustomColumnNumber) { dest->CustomColumnData = (LPSTR*)malloc(sizeof(LPSTR*)*src->CustomColumnNumber); for(int n = 0; n < src->CustomColumnNumber; n++) { dest->CustomColumnData[n] = strdup(src->CustomColumnData[n]); } } //Description if(src->Description) dest->Description = strdup(src->Description); //Owner if(src->Owner) dest->Owner = strdup(src->Owner); //Additionals if(FPIL_ADDEXIST(src)) { DWORD sz = FPIL_ADDSIZE(src); LPVOID ptr = malloc(sz); if(ptr) { memmove(ptr, FPIL_ADDDATA(src), sz); FPIL_ADDSET(dest, sz, ptr); } else FPIL_ADDSET(dest, 0, NULL); } } }
void rbgobj_define_property_accessors(VALUE klass) { GType gtype; GParamSpec** pspecs = NULL; guint i; GString* source; guint n_properties = 0; gtype = CLASS2GTYPE(klass); if (G_TYPE_IS_INTERFACE(gtype)){ #if GLIB_CHECK_VERSION(2,4,0) gpointer iface = g_type_default_interface_ref(gtype); pspecs = g_object_interface_list_properties(iface, &n_properties); g_type_default_interface_unref(iface); #endif } else { GObjectClass* oclass = G_OBJECT_CLASS(g_type_class_ref(gtype)); pspecs = g_object_class_list_properties(oclass, &n_properties); g_type_class_unref(oclass); } if (n_properties == 0) return; source = g_string_new(NULL); for (i = 0; i < n_properties; i++){ GParamSpec* pspec = pspecs[i]; char* buf; char* prop_name; char* p; if (pspec->owner_type != gtype) continue; buf = g_strdup(pspec->name); for (p = buf; *p; p++) if (*p == '-') *p = '_'; if (!strncmp(buf, "is_", 3)) prop_name = buf + 3; else prop_name = buf; if (g_hash_table_lookup(prop_exclude_list, prop_name)){ g_free(buf); continue; } if (pspec->flags & G_PARAM_READABLE){ g_string_append_printf( source, "def %s%s; get_property('%s'); end\n", prop_name, (G_PARAM_SPEC_VALUE_TYPE(pspec) == G_TYPE_BOOLEAN) ? "?" : "", pspec->name); } if (IS_FLAG(pspec->flags, G_PARAM_WRITABLE) && !IS_FLAG(pspec->flags, G_PARAM_CONSTRUCT_ONLY)){ g_string_append_printf(source, "def set_%s(val); set_property('%s', val); end\n", prop_name, pspec->name); #ifdef HAVE_NODE_ATTRASGN g_string_append_printf(source, "alias %s= set_%s\n", prop_name, prop_name); #else g_string_append_printf(source, "def %s=(val); set_property('%s', val); val; end\n", prop_name, pspec->name); #endif } g_free(buf); } if (source->len > 0) rb_funcall(klass, id_module_eval, 1, rb_str_new2(source->str)); g_string_free(source, TRUE); }
int FTP::MakeDirectory(String& Name,int OpMode) { PROC(("FTP::MakeDirectory",NULL)) FTPHost h; if(!ShowHosts && !hConnect) return FALSE; h.Init(); //Edit name if(!IS_SILENT(OpMode) && !IS_FLAG(OpMode,OPM_NODIALOG) && !EditDirectory(Name, ShowHosts ? h.HostDescr : NULL, TRUE)) return -1; //Correct name if(!Name[0]) return -1; //HOSTS if(ShowHosts) { if(Name.Cmp(".") || Name.Cmp("..") || FTPHost::CheckHost(HostsPath, Name.c_str())) { SetLastError(ERROR_ALREADY_EXISTS); return FALSE; } char str[MAX_PATH]; h.Folder = TRUE; StrCpy(h.Host, Name.c_str(), ARRAYSIZE(h.Host)); h.MkINIFile(str,NULL,""); StrCpy(h.Host, str, ARRAYSIZE(h.Host)); h.Write(HostsPath); SelectFile=Name; return TRUE; } //FTP FP_Screen scr; //Create directory do { //Try to create if(hConnect && FTPCreateDirectory(Name.c_str(), OpMode)) return TRUE; //If conection alive - report error if(FtpCmdLineAlive(hConnect) || IS_SILENT(OpMode)) return FALSE; //Try to reconnect if(!Reread()) return FALSE; //Repeat operation } while(true); }
BOOL idDeleteCB(PluginPanelItem* p,LPVOID dt) { PROC(("idDeleteCB", "%p,%p [%s]", p, dt, FTP_FILENAME(p))); int rres; FTPHost* h = FTPHost::Convert(p); char *CurName = FTP_FILENAME(p); char *m; if(((DeleteData*)dt)->ShowHosts && !h) return TRUE; //Ask if(IS_FLAG(p->FindData.dwFileAttributes,FILE_ATTRIBUTE_DIRECTORY)) { if(!((DeleteData*)dt)->DeleteAllFolders && IS_SILENT(((DeleteData*)dt)->OpMode)) { LPCSTR MsgItems[]= { ((DeleteData*)dt)->ShowHosts ? FP_GetMsg(MDeleteHostsTitle):FP_GetMsg(MDeleteTitle), ((DeleteData*)dt)->ShowHosts ? FP_GetMsg(MDeleteHostFolder):FP_GetMsg(MDeleteFolder), CurName, FP_GetMsg(MDeleteGroupDelete), FP_GetMsg(MDeleteGroupAll), FP_GetMsg(MDeleteGroupCancel) }; rres = FMessage(FMSG_WARNING|FMSG_DOWN, NULL, MsgItems, ARRAYSIZE(MsgItems), 3); switch(rres) { /*ESC*/ case -1: return FALSE; /*Del*/ case 0: break; /*DelAll*/ case 1: ((DeleteData*)dt)->DeleteAllFolders = TRUE; break; /*Cancel*/ case 2: return FALSE; } } } //Display SaveConsoleTitle::Text(CurName); FtpConnectMessage(((DeleteData*)dt)->hConnect, MDeleteTitle, PointToName(CurName)); //=============================== //Hosts if(((DeleteData*)dt)->ShowHosts) return FP_DeleteRegKeyAll(h->RegKey); //=============================== //FTP m = strrchr(CurName,'/'); if(m) CurName = m+1; if(IS_FLAG(p->FindData.dwFileAttributes,FILE_ATTRIBUTE_DIRECTORY)) { //FTP directory //Succ delete if(FtpRemoveDirectory(((DeleteData*)dt)->hConnect, CurName)) { if(Opt.UpdateDescriptions) p->Flags |= PPIF_PROCESSDESCR; return TRUE; } } else { //FTP file //Succ delete if(FtpDeleteFile(((DeleteData*)dt)->hConnect,CurName)) { if(Opt.UpdateDescriptions) p->Flags |= PPIF_PROCESSDESCR; return TRUE; } } //Error Log(("Del error: %s", ((DeleteData*)dt)->SkipAll ? "SkipAll" : "Ask")); if(((DeleteData*)dt)->SkipAll == FALSE) { rres = FtpConnectMessage(((DeleteData*)dt)->hConnect, MCannotDelete, CurName, -MCopySkip, MCopySkipAll); switch(rres) { /*skip*/ case 0: Log(("Skip")); return TRUE; /*skip all*/ case 1: ((DeleteData*)dt)->SkipAll = TRUE; Log(("SkipAll")); return TRUE; default: Log(("Other")); SetLastError(ERROR_CANCELLED); return FALSE; } } else return TRUE; }
void get_clustering(char * fname, int offset) { // read the clustering for sequences i to j // in the input file the sequence number will be give as 0..j-i FILE * cfn; char tmp[4095]; int res,curr,the_next,last,cnum,prev,validcurr; cfn = fopen(fname,"r"); if (cfn == NULL) { perror(fname); exit(1); } // Are we restoring from a checkpoint if (prog_opts.restore) { // first line of file will contain cnum=num_seqs; // round numbers. Find the min value for(res=1; res<numprocs; res++) { fscanf(cfn,"%d\n",&the_next); if(the_next<cnum) cnum = the_next; } prog_opts.restore= cnum; //printf("Restore value is %d",prog_opts.restore); } // Read the clusters do { res = fscanf(cfn, "%d", &cnum); cnum = cnum+offset; validcurr = cnum; if (res != 1) break; prev=cnum; while (fscanf(cfn, "%d", &curr)==1) { validcurr = curr+offset; tree[validcurr].cluster=cnum; tree[prev].next = validcurr; prev = validcurr; if (IS_FLAG(FIX,validcurr)) SET_FLAG(FIX,cnum); } tree[validcurr].next = -1; // now deal with resetting // find the first sequencein cluster that should NOT be reset // --- reset all sequences up to that point res = is_flag(RESET,cnum); for(curr=cnum; (curr != -1) && (is_flag(RESET,curr)); curr=the_next) { the_next = tree[curr].next; tree[curr].next=-1; tree[curr].rank=1; tree[curr].cluster=curr; tree[curr].last=curr; } prev=-1; cnum=last=curr; // Now find the last non-reset sequence for(curr=cnum; curr != -1; curr=tree[curr].next) last = curr; // Now go through the rest -- eithe reset or link up for(curr=cnum; curr != -1; curr=tree[curr].next) { if (IS_FLAG(RESET,curr)) { tree[curr].next=-1; tree[curr].rank=1; tree[curr].cluster=curr; tree[curr].last=curr; } else { // link up if (prev != -1) tree[prev].next = curr; tree[curr].cluster=cnum; tree[curr].last = last; tree[cnum].rank++; prev = curr; } } res = fscanf(cfn,"%[.]",tmp); assert(res==1); } while (1); }
void do_pairwise_cluster(WorkPtr work) { int r, s, limit; int i, j, rootI, rootJ, *index,k; uint16_t w0; int num_mat_pos, num_mat_rc,invert, samp_pos, samp_rc; index = work->index; if (clonelink) clone_link(work); //printf("Slave %d-t%d here ib=%d ie=%d; jb=%d je=%d,\n", // myid,work->thread_num,work->i_beg,work->i_end,work->j_beg,work->j_end); for(r=work->i_beg; r<work->i_end; r++) { i = (index == NULL) ? r : index[r]; //printf("%d %ld %ld %d\n",i,data,seq[i].seq,seq[i].len); if (IGNORE_SEQ(i)) continue; if (seqInfo[i].len<window_len) continue; set_up_word_table(work, i); for(s=MAX(r+1,work->j_beg); s<work->j_end; s++) { j = (index == NULL) ? s : index[s]; rootI = mini_find_parent(i); rootJ = mini_find_parent(j); if ((rootI != rootJ) && !(IS_FLAG(FIX,rootI)&&IS_FLAG(FIX,rootJ) )) { // only try to cluster if not already clustered // and both are not fixed lcusters num_mat_pos=num_mat_rc=samp_pos=samp_rc=0; NUM_num_matches++; limit = seqInfo[j].len/BASESPERELT-1; for(k=1; k < limit ;k=k+2) { if (work->tableP[seq[j][k]]) samp_pos ++; if (work->tableR[seq[j][k]]) samp_rc ++; } if ((samp_pos<=2) && (samp_rc<= 2) ) samp_pos=samp_rc=0; else for(k=0; k < limit;k=k+2) { w0 = seq[j][k]; if (work->tableP[w0]) samp_pos++; if (work->tableR[w0]) samp_rc++; } if (samp_pos >sample_thresh) num_mat_pos = tv_heuristic_pos(work,i,j); if (samp_rc > sample_thresh) num_mat_rc = tv_heuristic_rc(work,i,j); if( (num_mat_pos >= NM_threshold) && (!IGNORE_SEQ(j)) && (dist(work,i,j,0)<=theta)) { PLOCK(&invert_mutex); invert = (int) (tree[i].orient != tree[j].orient); PUNLOCK(&invert_mutex); if (dump_file != NULL) { PLOCK(&dump_mutex); fprintf(dump_file,"%d: %d %d %d\n", work->thread_num,i,j,1); fflush(dump_file); PUNLOCK(&dump_mutex); } make_uniond2(rootI,rootJ,invert); total_matches++; tree[i].match = j; if (tree[j].match==-1) { tree[j].match = i; } }; if ( rc_check && (num_mat_rc >= NM_threshold)&& (!IGNORE_SEQ(j)) && (dist(work,i,j,1)<=theta)){ PLOCK(&invert_mutex); invert = (tree[i].orient==tree[j].orient); PUNLOCK(&invert_mutex); if (dump_file != NULL) { PLOCK(&dump_mutex); fprintf(dump_file,"%d: %d %d %d\n", work->thread_num,i,j,-1); fflush(dump_file); PUNLOCK(&dump_mutex); } make_uniond2(rootI,rootJ,invert); total_matches++; tree[i].match = j; if (tree[j].match==-1) { tree[j].match = i; } } } } clear_word_table(work,i); } PLOCK(&find_parent_mutex); for(i=0; i<num_seqs; i++) tree[i].cluster = find_parent(i); PUNLOCK(&find_parent_mutex); }
void FTP::SaveList(FP_SizeItemList* il) { LPCSTR m; if((m=GetOtherPath(Opt.sli.path)) != NULL) { SayOutError(m); return; } strcat(Opt.sli.path,"ftplist.lst"); if(!AskSaveList(&Opt.sli)) return; FILE *f = fopen(Opt.sli.path, Opt.sli.Append ? "a" : "w"); if(!f) { SayOutError(FMSG(MFLErrCReate),FMSG_ERRORTYPE); return; } PluginPanelItem* p; int n; int level; char str[1024+2], BasePath[1024+2], CurrentUrlPath[1024+2]; CurrentUrlPath[0] = 0; _snprintf(BasePath, ARRAYSIZE(BasePath), "%s%s%s%s", Opt.sli.AddPrefix ? "ftp://" : "", Opt.sli.AddPasswordAndUser ? Message("%s:%s@",hConnect->UserName,hConnect->UserPassword) : "", hConnect->hostname, hConnect->CurDir.c_str()); AddEndSlash(BasePath,'/',ARRAYSIZE(BasePath)); if(Opt.sli.ListType == sltTree) fprintf(f,"BASE: \"%s\"\n",BasePath); for(n = 0; n < il->Count(); n++) { p = il->Item(n); if(p->FindData.dwReserved1 == MAX_DWORD) continue; //URLS -------------------------------------- if(Opt.sli.ListType == sltUrlList) { if(IS_FLAG(p->FindData.dwFileAttributes,FILE_ATTRIBUTE_DIRECTORY)) continue; FixFTPSlash(FTP_FILENAME(p)); _snprintf(str,ARRAYSIZE(str),"%s%s",BasePath,FTP_FILENAME(p)); if(Opt.sli.Quote) QuoteStr(str); fprintf(f,"%s\n",str); } else //TREE -------------------------------------- if(Opt.sli.ListType == sltTree) { StrCpy(str, FTP_FILENAME(p), ARRAYSIZE(str)); FixFTPSlash(str); for(m = str,level = 0; (m=strchr(m,'/')) != NULL; m++,level++); fprintf(f,"%*c", level*2+2, ' '); m = strrchr(str,'/'); if(m) m++; else m = str; fprintf(f,"%c%s", IS_FLAG(p->FindData.dwFileAttributes,FILE_ATTRIBUTE_DIRECTORY) ? '/' : ' ', m); if(Opt.sli.Size) { level = Max(1, Opt.sli.RightBound - 10 - level*2 - 2 - 1 - (int)strlen(m)); fprintf(f,"%*c",level,' '); if(IS_FLAG(p->FindData.dwFileAttributes,FILE_ATTRIBUTE_DIRECTORY)) fprintf(f,"<DIR>"); else fprintf(f,"%10I64u", ((__int64)p->FindData.nFileSizeHigh) << 32 | p->FindData.nFileSizeLow); } fprintf(f,"\n"); } else //GROUPS ------------------------------------ if(Opt.sli.ListType == sltGroup) { if(IS_FLAG(p->FindData.dwFileAttributes,FILE_ATTRIBUTE_DIRECTORY)) continue; FixFTPSlash(FTP_FILENAME(p)); _snprintf(str, ARRAYSIZE(str), "%s%s", BasePath, FTP_FILENAME(p)); if(!IS_FLAG(p->FindData.dwFileAttributes,FILE_ATTRIBUTE_DIRECTORY)) *strrchr(str,'/') = 0; if(StrCmp(CurrentUrlPath,str,-1,FALSE) != 0) { StrCpy(CurrentUrlPath, str, ARRAYSIZE(CurrentUrlPath)); fprintf(f,"\n[%s]\n", CurrentUrlPath); } StrCpy(str, FTP_FILENAME(p), ARRAYSIZE(str)); FixFTPSlash(str); m = strrchr(str,'/'); if(m) m++; else m = str; fprintf(f," %s", m); if(Opt.sli.Size) { level = Max(1, Opt.sli.RightBound - 10 - (int)strlen(m) - 1); fprintf(f,"%*c%10I64u", level,' ', ((__int64)p->FindData.nFileSizeHigh) << 32 | p->FindData.nFileSizeLow); } fprintf(f,"\n"); } } fclose(f); LPCSTR itms[] = { FMSG(MFLDoneTitle), FMSG(MFLFile), Opt.sli.path, FMSG(MFLDone), FMSG(MOk) }; FMessage(FMSG_LEFTALIGN,NULL,itms,5,1); }
BOOL MYRTLEXP isReadOnly( CONSTSTR fname ) { struct stat stbuf; return ( FIO_STAT(fname,&stbuf) && !IS_FLAG(stbuf.st_mode,S_IWRITE) ); }