本文整理汇总了C++中FSString::Get方法的典型用法代码示例。如果您正苦于以下问题:C++ FSString::Get方法的具体用法?C++ FSString::Get怎么用?C++ FSString::Get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FSString
的用法示例。
在下文中一共展示了FSString::Get方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Symlink
int FSSys::Symlink( FSPath& path, FSString& str, int* err, FSCInfo* info )
{
if ( symlink( ( char* )str.Get( sys_charset_id ), ( char* )path.GetString( sys_charset_id ) ) )
{
SetError( err, errno );
return -1;
}
return 0;
}
示例2: Symlink
int FSSftp::Symlink ( FSPath& path, FSString& str, int* err, FSCInfo* info )
{
MutexLock lock( &mutex );
int ret = CheckSession( err, info );
if ( ret ) { return ret; }
if ( sftp_symlink( sftpSession, ( char* )str.Get( _operParam.charset ), ( char* )path.GetString( _operParam.charset ) ) )
{
if ( err ) { *err = sftp_get_error( sftpSession ); }
return -1;
}
return 0;
}
示例3: Symlink
int FSSftp::Symlink ( FSPath& path, FSString& str, int* err, FSCInfo* info )
{
MutexLock lock( &mutex );
int ret = CheckSession( err, info );
if ( ret ) { return ret; }
try
{
int ret;
WHILE_EAGAIN_( ret, libssh2_sftp_symlink( sftpSession, ( char* )str.Get( _operParam.charset ), ( char* )path.GetString( _operParam.charset, '/' ) ) );
CheckSFTP( ret );
}
catch ( int e )
{
if ( err ) { *err = e; }
return ( e == -2 ) ? -2 : -1;
}
return 0;
}
示例4: CheckSession
int FSSftp::CheckSession( int* err, FSCInfo* info )
{
if ( sshSession ) { return 0; }
try
{
unsigned ip;
int e;
if ( !GetHostIp( unicode_to_utf8( _operParam.server.Data() ).data(), &ip, &e ) )
{
throw int( e );
}
_sock.Create();
_sock.Connect( ntohl( ip ), _operParam.port );
sshSession = libssh2_session_init();
if ( !sshSession ) { throw int( SSH_INTERROR_X3 ); }
libssh2_session_set_blocking( sshSession, 0 );
WHILE_EAGAIN_( e, libssh2_session_handshake( sshSession, _sock.Id() ) );
if ( e ) { throw int( e - 1000 ); }
FSString userName = "";
if ( _operParam.user.Data()[0] )
{
userName = _operParam.user.Data();
}
else
{
#ifndef _WIN32
char* ret = getenv( "LOGNAME" );
if ( ret )
{
userName = FSString( sys_charset_id, ret );
_operParam.user = userName.GetUnicode();
MutexLock infoLock( &infoMutex );
_infoParam.user = userName.GetUnicode();
}
#endif
};
char* authList = 0;
char* charUserName = ( char* )userName.Get( _operParam.charset );
while ( true )
{
authList = libssh2_userauth_list( sshSession, charUserName, strlen( charUserName ) );
if ( authList ) { break; }
CheckSessionEagain();
WaitSocket( info );
}
//publickey,password,keyboard-interactive
static const char passId[] = "password";
static const char kInterId[] = "keyboard-interactive";
static unicode_t userSymbol = '@';
while ( true )
{
if ( !strncmp( authList, passId, strlen( passId ) ) )
{
FSPromptData data;
data.visible = false;
data.prompt = utf8_to_unicode( "Password:" ).data();
if ( !info->Prompt(
utf8_to_unicode( "SFTP_" ).data(),
carray_cat<unicode_t>( userName.GetUnicode(), &userSymbol, _operParam.server.Data() ).data(),
&data, 1 ) ) { throw int( SSH_INTERROR_STOPPED ); }
int ret;
WHILE_EAGAIN_( ret, libssh2_userauth_password( sshSession,
( char* )FSString( _operParam.user.Data() ).Get( _operParam.charset ),
( char* )FSString( data.prompt.Data() ).Get( _operParam.charset ) ) );
if ( ret ) { throw int( ret - 1000 ); }
break; //!!!
}
else if ( !strncmp( authList, kInterId, strlen( kInterId ) ) )
{
MutexLock lock( &kbdIntMutex );
kbdIntInfo = info;
//.........这里部分代码省略.........
示例5: CheckSession
int FSSftp::CheckSession( int* err, FSCInfo* info )
{
if ( sshSession ) { return 0; }
try
{
sshSession = ssh_new();
if ( !sshSession ) { throw int( SSH_INTERROR_X3 ); }
if ( ssh_options_set( sshSession, SSH_OPTIONS_HOST, unicode_to_utf8( _operParam.server.Data() ).ptr() ) )
{
throw int( SSH_INTERROR_X3 );
}
int port = _operParam.port;
if ( ssh_options_set( sshSession, SSH_OPTIONS_PORT, &port ) )
{
throw int( SSH_INTERROR_X3 );
}
FSString userName = "";
if ( _operParam.user.Data()[0] )
{
userName = _operParam.user.Data();
}
else
{
char* ret = getenv( "LOGNAME" );
if ( ret )
{
userName = FSString( sys_charset_id, ret );
_operParam.user = userName.GetUnicode();
MutexLock infoLock( &infoMutex );
_infoParam.user = userName.GetUnicode();
}
};
if ( ssh_options_set( sshSession, SSH_OPTIONS_USER, ( char* )userName.Get( _operParam.charset ) ) ) //есть сомнения, что надо все таки в utf8
{
throw int( SSH_INTERROR_X3 );
}
if ( ssh_connect( sshSession ) != SSH_OK )
{
throw int( SSH_INTERROR_CONNECT );
}
int method = ssh_userauth_list( sshSession, 0 );
int ret;
static unicode_t userSymbol = '@';
if ( method & SSH_AUTH_METHOD_PASSWORD )
{
FSPromptData data;
data.visible = false;
data.prompt = utf8_to_unicode( "Password:" ).ptr();
if ( !info->Prompt(
utf8_to_unicode( "SFTP_" ).ptr(),
carray_cat<unicode_t>( userName.GetUnicode(), &userSymbol, _operParam.server.Data() ).ptr(),
&data, 1 ) ) { throw int( SSH_INTERROR_STOPPED ); }
ret = ssh_userauth_password( sshSession,
( char* )FSString( _operParam.user.Data() ).Get( _operParam.charset ),
( char* )FSString( data.prompt.Data() ).Get( _operParam.charset ) );
}
if ( ret != SSH_AUTH_SUCCESS &&
( method & SSH_AUTH_METHOD_INTERACTIVE ) != 0 )
{
while ( true )
{
ret = ssh_userauth_kbdint( sshSession, 0, 0 );
if ( ret != SSH_AUTH_INFO ) { break; }
const char* instruction = ssh_userauth_kbdint_getinstruction( sshSession );
if ( !instruction ) { instruction = ""; }
int n = ssh_userauth_kbdint_getnprompts( sshSession );
if ( n <= 0 ) { continue; }
std::vector<FSPromptData> pData( n );
int i;
for ( i = 0; i < n; i++ )
//.........这里部分代码省略.........