r23801: The FSF has moved around a lot. This fixes their Mass Ave address.
[nivanova/samba-autobuild/.git] / source3 / registry / reg_util.c
index 511e9b43354537ce5ee02d05cd8d894b5d8ab1d2..75050c185006afb75dc1f8c0841c5619c8306b8e 100644 (file)
@@ -5,7 +5,7 @@
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
+ *  the Free Software Foundation; either version 3 of the License, or
  *  (at your option) any later version.
  *  
  *  This program is distributed in the hope that it will be useful,
@@ -14,8 +14,7 @@
  *  GNU General Public License for more details.
  *  
  *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *  along with this program; if not, see <http://www.gnu.org/licenses/>.
  */
 
 /* Implementation of registry frontend view functions. */
@@ -128,26 +127,28 @@ char* reg_remaining_path( const char *key )
 /**********************************************************************
 *********************************************************************/
 
-int regval_convert_multi_sz( uint16 *multi_string, size_t multi_len, char ***values )
+int regval_convert_multi_sz( uint16 *multi_string, size_t byte_len, char ***values )
 {
        char **sz;
        int i;
        int num_strings = 0;
        fstring buffer;
        uint16 *wp;
+       size_t multi_len = byte_len / 2;
        
-       *values = NULL;
-
-       if ( !multi_string || !*values )
+       if ( !multi_string || !values )
                return 0;
 
+       *values = NULL;
+
        /* just count the NULLs */
        
        for ( i=0; (i<multi_len-1) && !(multi_string[i]==0x0 && multi_string[i+1]==0x0); i++ ) {
-               if ( multi_string[i] == 0x0 )
+               /* peek ahead */
+               if ( multi_string[i+1] == 0x0 )
                        num_strings++;
        }
-       
+
        if ( num_strings == 0 )
                return 0;
        
@@ -187,7 +188,7 @@ size_t regval_build_multi_sz( char **values, uint16 **buffer )
        uint16 *buf, *b;
        UNISTR2 sz;
 
-       if ( !values || !*buffer )
+       if ( !values || !buffer )
                return 0;
        
        /* go ahead and alloc some space */
@@ -199,7 +200,7 @@ size_t regval_build_multi_sz( char **values, uint16 **buffer )
        
        for ( i=0; values[i]; i++ ) {
                ZERO_STRUCT( sz );
-               
+               /* DEBUG(0,("regval_build_multi_sz: building [%s]\n",values[i])); */
                init_unistr2( &sz, values[i], UNI_STR_TERMINATE );
                
                /* Alloc some more memory.  Always add one one to account for the 
@@ -214,8 +215,8 @@ size_t regval_build_multi_sz( char **values, uint16 **buffer )
                buf = b;
 
                /* copy the unistring2 buffer and increment the size */ 
-               
-               memcpy( buf+buf_size, sz.buffer, sz.uni_str_len );
+               /* dump_data(1,sz.buffer,sz.uni_str_len*2); */
+               memcpy( buf+buf_size, sz.buffer, sz.uni_str_len*2 );
                buf_size += sz.uni_str_len;
                
                /* cleanup rather than leaving memory hanging around */
@@ -231,7 +232,3 @@ size_t regval_build_multi_sz( char **values, uint16 **buffer )
 }
 
 
-
-
-
-