2003-04-06 11:19:26 +00:00
/*
* Copyright ( C ) 2003 by Martin Pool
* Copyright ( C ) 2003 by Andrew Bartlett
*
* Test harness for push_ucs2
*/
# include "includes.h"
static int check_push_ucs2 ( const char * orig )
{
smb_ucs2_t * dest = NULL ;
char * orig2 = NULL ;
int ret ;
2008-04-29 14:36:24 -07:00
size_t converted_size ;
2003-04-06 11:19:26 +00:00
2009-03-18 16:19:19 +11:00
push_ucs2_talloc ( NULL , & dest , orig , & converted_size ) ;
pull_ucs2_talloc ( NULL , & orig2 , dest , & converted_size ) ;
2003-04-06 11:19:26 +00:00
ret = strcmp ( orig , orig2 ) ;
2003-04-06 12:01:44 +00:00
if ( ret ) {
fprintf ( stderr , " orig: %s \n " , orig ) ;
fprintf ( stderr , " orig (UNIX -> UCS2 -> UNIX): %s \n " , orig2 ) ;
}
2009-03-18 16:19:19 +11:00
TALLOC_FREE ( dest ) ;
TALLOC_FREE ( orig2 ) ;
2003-04-06 12:01:44 +00:00
return ret ;
2003-04-06 11:19:26 +00:00
}
int main ( int argc , char * argv [ ] )
{
2003-04-06 12:01:44 +00:00
int i , ret = 0 ;
2003-04-09 05:22:17 +00:00
int count = 1 ;
2003-04-08 08:05:01 +00:00
/* Needed to initialize character set */
2006-01-28 22:53:04 +00:00
lp_load ( " /dev/null " , True , False , False , True ) ;
2003-04-08 08:05:01 +00:00
2003-04-09 05:22:17 +00:00
if ( argc < 2 ) {
fprintf ( stderr , " usage: %s STRING1 [COUNT] \n "
2003-04-08 08:05:01 +00:00
" Checks that a string translated UNIX->UCS2->UNIX is unchanged \n "
" Should be always 0 \n " ,
2003-04-06 11:19:26 +00:00
argv [ 0 ] ) ;
return 2 ;
}
2003-04-09 05:22:17 +00:00
if ( argc > = 3 )
count = atoi ( argv [ 2 ] ) ;
2003-04-06 11:19:26 +00:00
2003-04-09 05:22:17 +00:00
for ( i = 0 ; ( ( i < count ) & & ( ! ret ) ) ; i + + )
2003-04-06 11:19:26 +00:00
ret = check_push_ucs2 ( argv [ 1 ] ) ;
printf ( " %d \n " , ret ) ;
return 0 ;
}