Esempio n. 1
0
bool AdbConnection::login(){
	if(!m_up->ok()){
		ALOG(wxT("User Abort."));
		return false;
	}
	m_session = wxT("");
	AdbConReply* r = send(wxT("AUTH"), wxT("user="******"&pass="******"AdbConReply is NULL!"));
		return false;
	}
	switch(r->code){
		case rLOGIN_ACCEPTED_NEW_VER:
			m_cb->print(MSG_POP, L"New version available!");
		case rLOGIN_ACCEPTED:{
			m_session = r->data;
			loggd = true;
			delete r;
			return true;
		}
		case rLOGIN_FAILED:
			ALOG(wxT("Login Failed"));
			m_up->password = wxT("");
			m_up->rem_att--;
			if(showLoginDialog()){
				delete r;
				return login();
			}
			break;
		default:
			ALOG(r->message);
	}
	delete r;
	return false;
}
Esempio n. 2
0
AdbConReply* AdbConnection::send_layer0(wxString s, bool send_only){
	if(old){
		time_t td = m_sw.Time();

		if(td<m_opt->delay){
			ADEBUG(SP1("| Sleep: %d", m_opt->delay-td));
			wxThread::Sleep(m_opt->delay-td);
		}
		/*if(!send_only && m_cb->abort()){
			logout(true);
			return NULL;
		}*/
	} else old = true;

	m_sw.Start();

	wxString cen = s;
	int i = cen.Find(wxT("pass="******"&"), i);
		if(j>0&&j<=cen.Length()) cen = cen.substr(0, i+5)+wxT("xxxxx")+cen.substr(j);
	}

	ADEBUG(wxT("> ") + cen);
	
	//const char * outb = s.mb_str(wxConvUTF8);
	const wxCharBuffer outb = s.mb_str(wxConvUTF8);
	m_udp->SendTo((*m_remoteaddr), /*s.ToAscii().data()*/outb, strlen(outb.data()));//(wxUint32)s.Length()); 
	if(m_udp->Error())
		ADEBUG(wxT("! Failed to send datagram!"));
	
	if(send_only) return NULL;

	char buf[UDP_BUF_MAX];
	wxDateTime t0 = wxDateTime::UNow();
	do{	
		m_udp->RecvFrom((*m_remoteaddr),buf, UDP_BUF_MAX);
		if(m_cb->abort()){
			logout(true);
			return NULL;
		}
		wxTimeSpan delta = wxDateTime::UNow()-t0;
		if(delta.GetMilliseconds()>m_opt->timeout){
			AERROR(wxT("! Timed out!"));
			return NULL;
		}
	}while(m_udp->Error());	

	lastTimeUsed = m_sw.Time();
	m_sw.Start();
	
	buf[m_udp->LastCount()-1] = '\0';

	wxString replymsg(buf,wxConvUTF8);
	
	ADEBUG(wxT("< ")+replymsg);
	
	AdbConReply* r = new AdbConReply(replymsg);
	return r;
}
Esempio n. 3
0
bool AdbConnection::showLoginDialog(){
	if(m_up->rem_att<1){
		AERROR(wxT("Access Denied! No more login attempts allowed."));
		return false;
	}
	ALOG(wxString::Format(wxT("Logins left: %d"), m_up->rem_att));
	
	return m_cb->showLogin();
}
Esempio n. 4
0
File: asl.c Progetto: mingpen/OpenNT
VOID
ImageRetired (VOID)
{
    //
    // Image package was retired.  There's a mismated } somewhere
    // in the source.  Turn the variable flag back on to continue parsing
    //

    AERROR ("Too many '}'");
    AlLoc->Flags |= F_PVARIABLE;
}
Esempio n. 5
0
bool AdbConnection::connect(void){
	wxIPV4address m_localaddr;
	m_localaddr.AnyAddress();
    m_localaddr.Service(m_opt->local_port);
	m_udp = new wxDatagramSocket(m_localaddr, wxSOCKET_BLOCK); //, wxSOCKET_NOWAIT
	if(!m_udp->Ok()){
		AERROR(wxT("Could not create datagram socket! Try to change the port."));
		delete m_udp;
		m_udp=NULL;
		return false;
	}
	m_remoteaddr = new wxIPV4address();
	if(!m_remoteaddr->Hostname(m_opt->host)||!m_remoteaddr->Service(m_opt->remote_port)){
		AERROR(wxT("Failed to set remote host or port."));
		delete m_remoteaddr;
		m_remoteaddr = NULL;
		return false;
	}
	lastError = wxT("User Abort.");
	return true;
}
Esempio n. 6
0
static void set_minmaxdim(Shape_Info *shpp,uint32_t shape_flag)
{
	int i;

	/* set maxdim */
	if( shape_flag == AUTO_SHAPE ){
		SET_SHP_MAXDIM(shpp,0);
		for(i=0;i<N_DIMENSIONS;i++){
			if( BITMAP_SHAPE(shpp) ){
				if( SHP_TYPE_DIM(shpp,i) > 1 ) SET_SHP_MAXDIM(shpp,i);
			} else {
				if( SHP_MACH_DIM(shpp,i) > 1 ) SET_SHP_MAXDIM(shpp,i);
			}
		}
	} else {
		if( shape_flag == DT_SCALAR )
			SET_SHP_MAXDIM(shpp, 0);
		else if( shape_flag == DT_ROWVEC )
			SET_SHP_MAXDIM(shpp, 1);
		else if( shape_flag == DT_COLVEC )
			SET_SHP_MAXDIM(shpp, 2);
		else if( shape_flag == DT_IMAGE )
			SET_SHP_MAXDIM(shpp, 2);
		else if( shape_flag == DT_SEQUENCE )
			SET_SHP_MAXDIM(shpp, 3);
		else if( shape_flag == DT_HYPER_SEQ )
			SET_SHP_MAXDIM(shpp, 4);
		else {
			assert( AERROR("set_minmaxdim:  unexpected type flag!?") );
		}
	}

	/* set mindim */
	/* We used to use mach_dim here...  but for bitmaps we must use type dim */
	SET_SHP_MINDIM(shpp,N_DIMENSIONS-1);
	for(i=N_DIMENSIONS-1;i>=0;i--){
		if( BITMAP_SHAPE(shpp) ){
			if( SHP_TYPE_DIM(shpp,i) > 1 ) SET_SHP_MINDIM(shpp,i);
		} else {
			if( SHP_MACH_DIM(shpp,i) > 1 ) SET_SHP_MINDIM(shpp,i);
		}
	}

	// What is last_subi???
	/*SET_SHP_LAST_SUBI(shpp, SHP_MAXDIM(shpp) + 1 ); */
	SET_SHP_RANGE_MAXDIM(shpp,SHP_MAXDIM(shpp));
	SET_SHP_RANGE_MINDIM(shpp,SHP_MINDIM(shpp));
} // set_minmaxdim
Esempio n. 7
0
File: ascmenu.c Progetto: E-LLP/QuIP
static void init_print_fmt_names(void)
{
	int i;

//#ifdef CAUTIOUS
//	if( fmt_names_inited ){
//NWARN("CAUTIOUS:  unnecessary call to init_print_fmt_names!?");
//		return;
//	}
//#endif /* CAUTIOUS */
	assert( ! fmt_names_inited );

	/* BUG should insure that all formats are inited */
	for(i=0;i<N_PRINT_FORMATS;i++){
		switch(i){
			case FMT_POSTSCRIPT:
				print_fmt_name[i] = "postscript";
				break;
			case FMT_DECIMAL:
				print_fmt_name[i] = "decimal";
				break;
			case FMT_FLOAT:
				print_fmt_name[i] = "float";
				break;
			case FMT_HEX:
				print_fmt_name[i] = "hexadecimal";
				break;
			case FMT_OCTAL:
				print_fmt_name[i] = "octal";
				break;
			case FMT_UDECIMAL:
				print_fmt_name[i] = "unsigned_decimal";
				break;
//#ifdef CAUTIOUS
			default:
//				sprintf(DEFAULT_ERROR_STRING,
//	"CAUTIOUS:  Oops, no initialization for print format %d!?",i);
//				NERROR1(DEFAULT_ERROR_STRING);
				assert( AERROR("Missing format initialization!?") );
				break;
//#endif /* CAUTIOUS */
		}
	}
	fmt_names_inited=1;
}
Esempio n. 8
0
AdbConReply* AdbConnection::send(wxString op, wxString param, bool send_only){
	int timeouts = 0;
	AdbConReply* r;
	while(max_timeouts>timeouts++){
		r = send_layer1(op, param, send_only);
		if(m_cb->abort()) break;
		if(r==NULL) continue; // timeout
		if(!op.StartsWith(wxT("LOGOUT"))&&(r->code==rLOGIN_FIRST||r->code==rINVALID_SESSION)){
			if(remaining_auth_attempts<=0){
				AERROR(wxT("Invalid session."));
				return NULL;
			}
			remaining_auth_attempts--;
			if(login())
				return send(op, param, send_only);
			return NULL;
		}
		return r;
	}
	ALOG(getLastError());
	return NULL;
}
Esempio n. 9
0
File: ascmenu.c Progetto: E-LLP/QuIP
static Data_Obj *insure_ram_obj(QSP_ARG_DECL  Data_Obj *dp)
{
	Data_Obj *tmp_dp;
	char *tname;
	Data_Area *save_ap;
	Data_Obj *c_dp=NULL;

	if( OBJ_IS_RAM(dp) ) return dp;

	// This object lives on a different platform.
	// We create a copy in RAM, and download the data
	// using the platform download function.

	save_ap = curr_ap;
	curr_ap = ram_area_p;

	tname = getbuf( strlen(OBJ_NAME(dp)) + strlen(DNAME_PREFIX) + 1 );
	sprintf(tname,"%s%s",DNAME_PREFIX,OBJ_NAME(dp));
	tmp_dp = dup_obj(QSP_ARG  dp, tname);
	givbuf(tname);
	if( tmp_dp == NO_OBJ ){
		// This can happen if the object is subscripted,
		// as the bracket characters are illegal in names
		return NO_OBJ;
	}

	curr_ap = save_ap;

	// We can't download if the source data is not contiguous...
	//
	// We have a problem with bit precision, because the bits can
	// be non-contiguous when the long words are - any time the number of columns
	// is not evenly divided by the bits-per-word

	if( (! IS_CONTIGUOUS(dp)) && ! HAS_CONTIGUOUS_DATA(dp) ){
		Vec_Obj_Args oa1, *oap=&oa1;

advise("object is not contiguous, and does not have contiguous data...");
longlist(QSP_ARG  dp);
		save_ap = curr_ap;
		curr_ap = OBJ_AREA( dp );

		tname = getbuf( strlen(OBJ_NAME(dp)) + strlen(CNAME_PREFIX) + 1 );
		sprintf(tname,"%s%s",CNAME_PREFIX,OBJ_NAME(dp));
		c_dp = dup_obj(QSP_ARG  dp, tname );
		givbuf(tname);

		curr_ap = save_ap;

		// Now do the move...

		setvarg2(oap,c_dp,dp);
		if( IS_BITMAP(dp) ){
			SET_OA_SBM(oap,dp);
			SET_OA_SRC1(oap,NO_OBJ);
		}

		if( IS_REAL(dp) ) /* BUG case for QUAT too? */
			OA_ARGSTYPE(oap) = REAL_ARGS;
		else if( IS_COMPLEX(dp) ) /* BUG case for QUAT too? */
			OA_ARGSTYPE(oap) = COMPLEX_ARGS;
		else if( IS_QUAT(dp) ) /* BUG case for QUAT too? */
			OA_ARGSTYPE(oap) = QUATERNION_ARGS;
		else
			//ERROR1("CAUTIOUS:  insure_ram_obj:  bad argset type!?");
			assert( AERROR("insure_ram_obj:  bad argset type!?") );

//fprintf(stderr,"insure_ram_obj:  moving remote data to a contiguous object\n");  
		call_vfunc( QSP_ARG  FIND_VEC_FUNC(FVMOV), oap );
//fprintf(stderr,"insure_ram_obj:  DONE moving remote data to a contiguous object\n");  

		dp = c_dp;
	}

	gen_obj_dnload(QSP_ARG  tmp_dp, dp);

	if( c_dp != NO_OBJ )
		delvec(QSP_ARG  c_dp);

	// BUG - when to delete?
	// We try using the VOLATILE flag.  This will work as long as
	// the input object is not VOLATILE!?

	SET_OBJ_FLAG_BITS(tmp_dp, DT_VOLATILE ) ;

	return tmp_dp;
}