当前位置: 首页>>代码示例>>C++>>正文


C++ StringDelete函数代码示例

本文整理汇总了C++中StringDelete函数的典型用法代码示例。如果您正苦于以下问题:C++ StringDelete函数的具体用法?C++ StringDelete怎么用?C++ StringDelete使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了StringDelete函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: _secure_file_path

/*
 * Below function copies a file owned and managed by a user to a secured location so that it can be accessed securely.
 */
static int _secure_file_path( const char ** path,const char * source )
{
	int fd_source ;
	int fd_temp ;
	char buffer[ SIZE ] ;
	size_t len ;
	const char * temp_path ;
	struct stat ststr ;

	string_t st_path = _create_work_directory() ;

	StringAppend( st_path,"0-" ) ;
	temp_path = StringAppendInt( st_path,syscall( SYS_gettid ) ) ;

	zuluCryptSecurityDropElevatedPrivileges() ;

	fd_source = open( source,O_RDONLY ) ;

	if( fd_source == -1 ){
		StringDelete( &st_path ) ;
		return 0 ;
	}

	fstat( fd_source,&ststr ) ;

	if( ststr.st_size >= 3145728 ){
		/*
		 * headers are less than 3MB so we obvious have a wrong file
		 */
		StringDelete( &st_path ) ;
		return 0 ;
	}

	zuluCryptSecurityGainElevatedPrivileges() ;

	fd_temp = open( temp_path,O_WRONLY | O_CREAT,S_IRUSR | S_IWUSR | S_IRGRP |S_IROTH ) ;
	if( fd_temp == -1 ){
		close( fd_source ) ;
		StringDelete( &st_path ) ;
		return 0 ;
	}

	while( 1 ){
		len = read( fd_source,buffer,SIZE ) ;
		if( len < SIZE ){
			write( fd_temp,buffer,len ) ;
			break ;
		}else{
			write( fd_temp,buffer,len ) ;
		}
	}

	close( fd_source ) ;
	close( fd_temp ) ;

	zuluCryptSecurityDropElevatedPrivileges() ;

	*path = StringDeleteHandle( &st_path ) ;
	return 1 ;
}
开发者ID:aromis,项目名称:zuluCrypt,代码行数:63,代码来源:save_and_restore_volume_header.c

示例2: zuluCryptGetLoopDeviceAddress

char * zuluCryptGetLoopDeviceAddress( const char * device )
{
	char * z = NULL ;
	const char * e ;

	string_t st = StringVoid ;
	string_t xt = StringVoid ;

	int i ;
	int r ;

	z = zuluCryptLoopDeviceAddress_1( device ) ;

	if( z == NULL ){
		return NULL ;
	}else{
		st = String( "" ) ;

		for( i = 0 ; i < 255 ; i++ ){

			StringReplace( st,"/sys/block/loop" ) ;
			StringAppendInt( st,i ) ;

			xt = StringGetFromVirtualFile( StringAppend( st,"/loop/backing_file" ) ) ;

			e = StringRemoveRight( xt,1 ) ;
			r = StringsAreEqual( e,z ) ;

			StringDelete( &xt ) ;

			if( r ){

				StringReplace( st,"/dev/loop" ) ;
				e = StringAppendInt( st,i ) ;

				if( StringsAreNotEqual( device,e ) ){

					break ;
				}
			}else{
				StringReset( st ) ;
			}
		}

		StringFree( z ) ;

		if( StringIsEmpty( st ) ){

			StringDelete( &st ) ;
			return NULL ;
		}else{
			return StringDeleteHandle( &st ) ;
		}
	}
}
开发者ID:ParrotSec,项目名称:zulucrypt,代码行数:55,代码来源:create_loop_device.c

示例3: genResponse

void genResponse(int cid) {
  int power = motor[motorA];
  string tmpString;
  int index = 0;
  ubyte linebuff[20];
  StringFromChars(tmpString,rxbuffer);
  index = StringFind(tmpString, "/");
  StringDelete(tmpString, 0, index);
  index = StringFind(tmpString, "HTTP");
  StringDelete(tmpString, index, strlen(tmpString));
  writeDebugStreamLine("Request:%s", tmpString);
  nxtDisplayTextLine(2, "Request: ");
  nxtDisplayTextLine(3, tmpString);
  if (StringFind(tmpString, "MOTA") > 0) {
    StringDelete(tmpString, 0, 6);
    index = StringFind(tmpString, " ");
    if (index > -1)
      StringDelete(tmpString, index, strlen(tmpString));
    //power = RC_atoix(tmpString);
    power = clip(RC_atoix(tmpString), -100, 100);
    writeDebugStreamLine("Power:%d", power);
  } else {
    writeDebugStreamLine("NO POWER: %s", tmpString);
  }

  sendHeader(cid);
  while(nxtHS_Status == HS_SENDING) wait1Msec(5);

  wait1Msec(100);

  index = 0;
  linebuff[0] = 27; // escape;
  linebuff[1] = 'S'; // the CID;
  linebuff[2] = (ubyte)cid + 48; // the CID;
  index = appendToBuff(buffer, index, linebuff, 3);
  StringFormat(tmpString, "MotorA=%d", power);
  memcpy(linebuff, tmpString, strlen(tmpString));
  index = appendToBuff(buffer, index, linebuff, strlen(tmpString));
  linebuff[0] = 27; // escape;
  linebuff[1] = 'E'; // the CID;
  index = appendToBuff(buffer, index, endmarker, 2);
  writeRawHS(buffer, index);
  motor[motorA] = power;
  closeConn(1);
  memset(rxbuffer, 0, sizeof(rxbuffer));
  wait1Msec(100);
  clear_read_buffer();
}
开发者ID:sohamsankaran,项目名称:Newton,代码行数:48,代码来源:DIWIFI-test1.c

示例4: zuluCryptGetPartitionFromConfigFile

stringList_t zuluCryptGetPartitionFromConfigFile( const char * path )
{
	StringListIterator it  ;
	StringListIterator end ;

	stringList_t stl ;
	stringList_t stl_1 = StringListVoid ;

	string_t st = StringVoid ;

	zuluCryptSecurityGainElevatedPrivileges() ;
	st = StringGetFromFile( path ) ;
	zuluCryptSecurityDropElevatedPrivileges() ;

	stl = StringListStringSplit( st,'\n' ) ;

	StringDelete( &st ) ;

	StringListGetIterators( stl,&it,&end ) ;

	while( it != end ){
		stl_1 = _eval_path( *it,stl_1 ) ;
		it++ ;
	}

	StringListDelete( &stl ) ;

	return stl_1 ;
}
开发者ID:DarkDare,项目名称:zuluCrypt,代码行数:29,代码来源:volumes.c

示例5: zuluCryptGetPartitionFromCrypttab

/*
 * this function will parse /etc/crypttab to see if it has any entries to be used as system partition.
 *
 * sample example of the file content this function was build on.
 *

 * secret /dev/sda15 none
 * secret_1 UUID=d2d210b8-0b1f-419f-9172-9d509ea9af0c none
 *
 */
stringList_t zuluCryptGetPartitionFromCrypttab( void )
{
	stringList_t stl   = StringListVoid ;
	stringList_t stl_1 = StringListVoid ;
	stringList_t stz ;

	string_t st  ;

	StringListIterator it  ;
	StringListIterator end ;

	st = StringGetFromFile( "/etc/crypttab" ) ;

	stl = StringListStringSplit( st,'\n' ) ;

	StringDelete( &st ) ;

	StringListGetIterators( stl,&it,&end ) ;

	while( it != end ){
		st = *it ;
		it++ ;
		if( !StringStartsWith( st,"#" ) ){
			stz = StringListStringSplit( st,' ' ) ;
			st = StringListStringAtSecondPlace( stz ) ;
			stl_1 = _eval_path( st,stl_1 ) ;
			StringListDelete( &stz ) ;
		}
	}

	StringListDelete( &stl ) ;
	return stl_1 ;
}
开发者ID:DarkDare,项目名称:zuluCrypt,代码行数:43,代码来源:volumes.c

示例6: _zuluCryptResolveDevRoot

static char * _zuluCryptResolveDevRoot( void )
{
	const char * e ;
	char * dev ;
	string_t st      = StringGetFromVirtualFile( "/proc/cmdline" ) ;
	stringList_t stl = StringListStringSplit( st,' ' ) ;
	StringDelete( &st ) ;

	st = StringListHasSequence_1( stl,"root=/dev/" ) ;

	if( st != StringVoid ){

		e = StringContent( st ) + 5 ;
		dev = zuluCryptResolvePath( e ) ;
	}else{
		st = StringListHasSequence_1( stl,"root=UUID=" ) ;

		if( st != StringVoid ){
			/*
			 * zuluCryptDeviceFromUUID() is defined in ./blkid_evaluate_tag.c
			 */
			e = StringContent( st ) + 10 ;
			dev = zuluCryptDeviceFromUUID( e ) ;
		}else{
			dev = NULL ;
		}
	}
	StringListDelete( &stl ) ;
	return dev ;
}
开发者ID:DarkDare,项目名称:zuluCrypt,代码行数:30,代码来源:resolve_paths.c

示例7: mount_point_prefix_match_0

static int mount_point_prefix_match_0( const char * m_path,uid_t uid,string_t * m_point,int home_prefix )
{
	int st ;
	/*
	 * zuluCryptGetUserName() is defined in ../lib/user_home_path.c
	 */
	string_t uname ;
	/*
	 * below constant are set in ../constants.h
	 */
	const char * str ;

	if( home_prefix ){

		uname = zuluCryptGetUserHomePath( uid ) ;
		str = StringContent( uname ) ;
	}else{
		uname = zuluCryptGetUserName( uid ) ;
		StringPrepend( uname,"/run/media/private/" ) ;
		str = StringAppendChar( uname,'/' ) ;
	}

	st = StringPrefixEqual( m_path,str ) ;

	if( m_point ){
		*m_point = uname ;
	}else{
		StringDelete( &uname ) ;
	}

	return st ;
}
开发者ID:mschmidt79,项目名称:zuluCrypt,代码行数:32,代码来源:create_mount_point.c

示例8: getUserControlProgram

void getUserControlProgram(string& sFileName)
{
    byte   nParmToReadByte[2];
    int    nFileSize;
    TFileIOResult nIoResult;
    TFileHandle hFileHandle;

    sFileName = "";
    nParmToReadByte[1] = 0;
    hFileHandle = 0;
    OpenRead(hFileHandle, nIoResult, kConfigName, nFileSize);
    if (nIoResult == ioRsltSuccess)
    {
        for (int index = 0; index < nFileSize; ++index)
        {
            ReadByte(hFileHandle, nIoResult,  nParmToReadByte[0]);
            strcat(sFileName, nParmToReadByte);
        }

        //
        // Delete the ".rxe" file extension
        //
        int nFileExtPosition;

        nFileExtPosition = strlen(sFileName) - 4;
        if (nFileExtPosition > 0)
            StringDelete(sFileName, nFileExtPosition, 4);
    }
    Close(hFileHandle, nIoResult);
    return;
}
开发者ID:team3344,项目名称:FTC2011,代码行数:31,代码来源:JoystickDriver.c

示例9: _fileSystemIsSupported

static int _fileSystemIsSupported( const char * fs )
{
	string_t           st  = StringGetFromVirtualFile( "/proc/filesystems" ) ;
	stringList_t       stl = StringListStringSplit( st,'\n' ) ;
	StringListIterator it  = StringListBegin( stl ) ;
	StringListIterator end = StringListEnd( stl ) ;
	string_t xt ;
	int r = 0 ;

	while( it != end ){

		xt = *it ;

		it++ ;

		if( !StringStartsWith( xt,"nodev" ) ){

			if( StringContains( xt,fs ) ){

				r = 1 ;
				break ;
			}
		}
	}

	StringDelete( &st ) ;
	StringListDelete( &stl ) ;
	return r ;
}
开发者ID:DarkDare,项目名称:zuluCrypt,代码行数:29,代码来源:mount_fs_options.c

示例10: zuluCryptEXEVolumeInfo

int zuluCryptEXEVolumeInfo( const char * mapper,const char * device,uid_t uid )
{
	char * output ;
	int xt ;

	/*
	 * ZULUCRYPTlongMapperPath is set in ../constants.h
	 * zuluCryptCreateMapperName() is defined at ../lib/create_mapper_name.c
	 */
	string_t p = zuluCryptCreateMapperName( device,mapper,uid,ZULUCRYPTlongMapperPath ) ;

	zuluCryptSecurityGainElevatedPrivileges() ;
	/*
	 *zuluCryptVolumeStatus() is defined in ../lib/status.c
	 */
	output = zuluCryptVolumeStatus( StringContent( p ) ) ;

	zuluCryptSecurityDropElevatedPrivileges() ;

	if( output != NULL ){
		printf( "%s\n",output ) ;
		StringFree( output ) ;
		xt = 0 ;
	}else{
		printf( gettext( "ERROR: Could not get volume properties,volume is not open or was opened by a different user\n" ) ) ;
		xt = 2 ;
	}
	StringDelete( &p ) ;
	return xt ;
}
开发者ID:bankonme,项目名称:zuluCrypt,代码行数:30,代码来源:volume_info.c

示例11: zuluCryptOpenPlain

int zuluCryptOpenPlain( const char * device,const char * mapper,const char * mode,const char * pass,size_t pass_size )
{
	int lmode ;
	string_t st ;
	int fd ;
	int r ;
	if( StringPrefixMatch( device,"/dev/",5 ) ){
		return _open_plain( device,mapper,mode,pass,pass_size ) ;
	}else{
		if( StringHasComponent( mode,"ro" ) ){
			lmode = O_RDONLY ;
		}else{
			lmode = O_RDWR ;
		}
		/*
		 * zuluCryptAttachLoopDeviceToFile() is defined in ./create_loop.c
		 */
		if( zuluCryptAttachLoopDeviceToFile( device,lmode,&fd,&st ) ){
			r = _open_plain( device,mapper,mode,pass,pass_size ) ;
			StringDelete( &st ) ;
			close( fd ) ;
			return r ;
		}else{
			return 2 ;
		}
	}
}
开发者ID:ghostbunny,项目名称:zuluCrypt,代码行数:27,代码来源:open_plain.c

示例12: mount_FUSEfs_0

static int mount_FUSEfs_0( m_struct * mst )
{
	int status ;
	const char * opts ;

	process_t p = Process( ZULUCRYPTmount ) ;
	string_t st = set_mount_options( mst ) ;

	opts = _mount_options( mst->m_flags,st ) ;

	if( StringsAreEqual( mst->fs,"ntfs" ) ){
		if( StringHasComponent( opts,"ignore_case" ) ){
			ProcessSetArgumentList( p,"-n","-t","lowntfs-3g","-o",opts,mst->device,mst->m_point,ENDLIST ) ;
		}else{
			ProcessSetArgumentList( p,"-n","-t","ntfs-3g","-o",opts,mst->device,mst->m_point,ENDLIST ) ;
		}
	}else{
		ProcessSetArgumentList( p,"-t",mst->fs,"-o",opts,mst->device,mst->m_point,ENDLIST ) ;
	}

	ProcessStart( p ) ;

	status = ProcessExitStatus( p ) ;

	ProcessDelete( &p ) ;
	StringDelete( &st ) ;

	return status ;
}
开发者ID:Hasimir,项目名称:zuluCrypt,代码行数:29,代码来源:mount_volume.c

示例13: _get_result

static void _get_result( arguments * args )
{
	string_t st ;

	int fd ;

	const char * device = args->opts->device ;

	if( StringPrefixEqual( device,"/dev/" ) ){

		_get_result_0( device,args ) ;
	}else{
		/*
		 * zuluCryptAttachLoopDeviceToFile() is defined in create_loop_device.c
		 */
		if( zuluCryptAttachLoopDeviceToFile( device,args->opts->open_mode,&fd,&st ) ){

			_get_result_0( StringContent( st ),args ) ;

			StringDelete( &st ) ;

			close( fd ) ;
		}else{
			_get_error( args ) ;
		}
	}
}
开发者ID:DarkDare,项目名称:zuluCrypt,代码行数:27,代码来源:resolve_paths.c

示例14: open_loop_device_1

static int open_loop_device_1( string_t * loop_device )
{
	string_t st = String( "" ) ;
	int i ;
	int fd ;
	const char * path ;
	struct loop_info64 l_info ;
	int r = 0 ;

	for( i = 0 ; i < 255 ; i++ ){

		StringReplace( st,"/dev/loop" ) ;
		path = StringAppendInt( st,i ) ;
		fd = open( path,O_RDONLY ) ;

		if( fd == -1 ){
			r = 0 ;
			break ;
		}
		if( ioctl( fd,LOOP_GET_STATUS64,&l_info ) != 0 ){

			if( errno == ENXIO) {
				*loop_device = StringCopy( st ) ;
				close( fd ) ;
				r = 1 ;
				break ;
			}
		}
		close( fd ) ;
	}
	StringDelete( &st ) ;
	return r ;
}
开发者ID:ParrotSec,项目名称:zulucrypt,代码行数:33,代码来源:create_loop_device.c

示例15: zuluCryptCreateTCrypt

int zuluCryptCreateTCrypt( const char * device,const char * file_system,const char * rng,
			   const char * key,size_t key_len,int key_source,
			   u_int64_t hidden_volume_size,
			   const char * file_system_h,const char * key_h,size_t key_len_h,int key_source_h )
{
	int fd ;
	string_t q = StringVoid ;
	int r ;
	if( StringPrefixEqual( device,"/dev/" ) ){
		r = _create_tcrypt_volume( device,file_system,rng,key,key_len,key_source,
					   hidden_volume_size,file_system_h,key_h,key_len_h,key_source_h ) ;
	}else{
		/*
		 * zuluCryptAttachLoopDeviceToFile() is defined in create_loop_device.c
		 */
		if( zuluCryptAttachLoopDeviceToFile( device,O_RDWR,&fd,&q ) ){
			device = StringContent( q ) ;
			r = _create_tcrypt_volume( device,file_system,rng,key,key_len,key_source,
						   hidden_volume_size,file_system_h,key_h,key_len_h,key_source_h ) ;
			close( fd ) ;
			StringDelete( &q ) ;
		}else{
			r = 3 ;
		}
	}

	return r ;
}
开发者ID:aromis,项目名称:zuluCrypt,代码行数:28,代码来源:create_tcrypt.c


注:本文中的StringDelete函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。