Exemple #1
0
int SP_HiveSchemaManager :: alterTable( sqlite3 * handle, SP_HiveTableSchema * newTable,
			SP_HiveTableSchema * oldTable )
{
	SP_NKStringList newColumnList;

	for( int i = 0; i < newTable->getColumnCount(); i++ ) {
		const char * name = newTable->getColumnName( i );

		int index = oldTable->findColumn( name );

		if( index < 0 ) newColumnList.append( newTable->getColumnDefine( i ) );
	}

	int ret = 0;

	if( newColumnList.getCount() > 0 ) {
		for( int i = 0; 0 == ret && i < newColumnList.getCount(); i++ ) {
			SP_NKLog::log( LOG_DEBUG, "DEBUG: %s add column %s",
					oldTable->getTableName(), newColumnList.getItem( i ) );

			char sql[ 1024 ] = { 0 };
			snprintf( sql, sizeof( sql ), "alter table %s add column %s;",
					oldTable->getTableName(), newColumnList.getItem( i ) );

			ret = execWithLog( handle, sql );
		}
	}

	return ret;
}
Exemple #2
0
int SP_NKPop3Client :: getAllUidList( SP_NKPop3UidList * uidList )
{
	SP_NKStringList buffer;

	int ret = mPop3->uidl( &buffer );
	if( 0 == ret ) {
		const char * strBuf = buffer.getItem(0);

		for( const char * iter = strBuf; NULL != iter; ) {
			char line[ 256 ] = { 0 };
			SP_NKStr::strlcpy( line, iter, sizeof( line ) );

			if( '.' == line[0] ) break;

			char * pos = strchr( line, '\n' );
			if( NULL != pos ) {
				*pos = '\0';
				if( pos > line && '\r' == *( pos - 1 ) ) *( pos - 1 ) = '\0';
			}

			pos = strchr( line, ' ' );
			if( NULL == pos ) continue;
			pos++;

			SP_NKPop3Uid * uid = new SP_NKPop3Uid( pos, atoi( line ) );
			uidList->append( uid );

			iter = strchr( iter, '\n' );
			if( NULL != iter ) iter++;
		}
	}

	return ret;
}
Exemple #3
0
int SP_NKPop3Client :: fillMailSize( SP_NKPop3UidList * uidList )
{
	SP_NKStringList buffer;

	int ret = mPop3->list( &buffer );
	if( 0 == ret ) {
		const char * strBuf = buffer.getItem(0);

		for( const char * iter = strBuf; NULL != iter; ) {
			char line[ 256 ] = { 0 };
			SP_NKStr::strlcpy( line, iter, sizeof( line ) );

			if( '.' == line[0] ) break;

			char * pos = strchr( line, '\n' );
			if( NULL != pos ) {
				*pos = '\0';
				if( pos > line && '\r' == *( pos - 1 ) ) *( pos - 1 ) = '\0';
			}

			pos = strchr( line, ' ' );
			if( NULL == pos ) continue;
			pos++;

			const SP_NKPop3Uid * uid = uidList->find( atoi( line ) );
			if( NULL != uid ) {
				((SP_NKPop3Uid*)uid)->setSize( atoi( pos ) );
			}

			iter = strchr( iter, '\n' );
			if( NULL != iter ) iter++;
		}
	}

	return ret;
}