the UNICODE issue...
authorLuke Leighton <lkcl@samba.org>
Thu, 11 Feb 1999 18:50:13 +0000 (18:50 +0000)
committerLuke Leighton <lkcl@samba.org>
Thu, 11 Feb 1999 18:50:13 +0000 (18:50 +0000)
(This used to be commit 73db80f34183324845407b00f58462ff2d7b47ea)

source3/include/proto.h
source3/lib/util_unistr.c
source3/libsmb/clientgen.c
source3/libsmb/smbencrypt.c
source3/rpc_parse/parse_misc.c
source3/rpc_parse/parse_reg.c
source3/rpc_parse/parse_rpc.c

index f649b40332352d3e44462c82325bd074bd6231c4..e564163421a81f0b415b2caff89d33ef4485790f 100644 (file)
@@ -572,7 +572,8 @@ char *unistr2_to_str(UNISTR2 *str);
 uint32 buffer2_to_uint32(BUFFER2 *str);
 char *buffer2_to_str(BUFFER2 *str);
 char *buffer2_to_multistr(BUFFER2 *str);
-int struni2(char *dst, const char *src);
+int str_to_unistr16(uint16 *dst, const char *src);
+int str_to_unistr8(char *dst, const char *src);
 char *unistr(char *buf);
 int unistrcpy(char *dst, char *src);
 
@@ -580,6 +581,12 @@ int unistrcpy(char *dst, char *src);
 
 int cli_set_port(struct cli_state *cli, int port);
 char *cli_errstr(struct cli_state *cli);
+BOOL cli_send_trans(struct cli_state *cli, int trans, 
+                           char *name, int pipe_name_len, 
+                           int fid, int flags,
+                           uint16 *setup, int lsetup, int msetup,
+                           char *param, int lparam, int mparam,
+                           char *data, int ldata, int mdata);
 BOOL cli_api_pipe(struct cli_state *cli, char *pipe_name, int pipe_name_len,
                   uint16 *setup, uint32 setup_count, uint32 max_setup_count,
                   char *params, uint32 param_count, uint32 max_param_count,
index 5e73fe6ada2f8842bd577607619c02194b936dfa..641f891f837d40133da2e0e54bc90d45c8dc393a 100644 (file)
@@ -193,6 +193,32 @@ char *buffer2_to_multistr(BUFFER2 *str)
        return lbuf;
 }
 
+/*******************************************************************
+create a null-terminated unicode string from a null-terminated ascii string.
+return number of unicode chars copied, excluding the null character.
+only handles ascii strings
+Unicode strings created are in little-endian format.
+********************************************************************/
+int str_to_unistr16(uint16 *dst, const char *src)
+{
+       size_t len = 0;
+
+       if (dst == NULL)
+               return 0;
+
+       if (src != NULL)
+       {
+               for (; *src && len < MAXUNI-2; len++, dst++, src++)
+               {
+                       *dst = *src;
+               }
+       }
+
+       *dst = 0;
+
+       return len;
+}
+
 /*******************************************************************
 create a null-terminated unicode string from a null-terminated ascii string.
 return number of unicode chars copied, excluding the null character.
@@ -200,7 +226,7 @@ only handles ascii strings
 Unicode strings created are in little-endian format.
 ********************************************************************/
 
-int struni2(char *dst, const char *src)
+int str_to_unistr8(char *dst, const char *src)
 {
        size_t len = 0;
 
index d40c95b9c1c04244c728eb74c1a797063f9814cf..60498c8fb25ac86ad5c0edc029b231520c883c5a 100644 (file)
@@ -226,7 +226,7 @@ static char *fix_char_ptr(unsigned int datap, unsigned int converter,
 /****************************************************************************
   send a SMB trans or trans2 request
   ****************************************************************************/
-static BOOL cli_send_trans(struct cli_state *cli, int trans, 
+BOOL cli_send_trans(struct cli_state *cli, int trans, 
                            char *name, int pipe_name_len, 
                            int fid, int flags,
                            uint16 *setup, int lsetup, int msetup,
index dd801e59820d47a6af4304539113a7ee109a7636..ead34aaa3d382cf284d8228a43acdaf488ba511c 100644 (file)
@@ -209,7 +209,7 @@ BOOL make_oem_passwd_hash(char data[516], const char *passwd, uchar old_pw_hash[
        generate_random_buffer((unsigned char *)data, 516, False);
        if (unicode)
        {
-               struni2( &data[512 - new_pw_len], passwd);
+               str_to_unistr8( &data[512 - new_pw_len], passwd);
        }
        else
        {
index bf3bba1249d5ef28fceffab958d33a4ceca7a49e..7c3f4469087a2fcce5ff5b044fc244cc07d8522e 100644 (file)
@@ -329,7 +329,7 @@ creates a UNISTR structure.
 void make_unistr(UNISTR *str, char *buf)
 {
        /* store the string (null-terminated copy) */
-       struni2((char *)(str->buffer), buf);
+       str_to_unistr16(str->buffer, buf);
 }
 
 /*******************************************************************
@@ -372,7 +372,7 @@ void make_buffer3_str(BUFFER3 *str, char *buf, int len)
        str->buf_len     = len * 2;
 
        /* store the string (null-terminated 8 bit chars into 16 bit chars) */
-       struni2(str->buffer, buf);
+       str_to_unistr8(str->buffer, buf);
 }
 
 /*******************************************************************
@@ -573,7 +573,7 @@ void make_unistr2(UNISTR2 *str, const char *buf, int len)
        str->uni_str_len = len;
 
        /* store the string (null-terminated 8 bit chars into 16 bit chars) */
-       struni2((char*)(str->buffer), buf);
+       str_to_unistr16((str->buffer), buf);
 }
 
 /*******************************************************************
index a3d8ebb64a645ead6a17b434a5918d76c742a7e2..84d96501053d4e13f4e68f42743a77a47a09bcd1 100644 (file)
@@ -769,7 +769,7 @@ void make_reg_r_info(REG_R_INFO *r_r,
                                uint32 status)
 {
        char buf[512];
-       int len = struni2(buf, os_type);
+       int len = str_to_unistr8(buf, os_type);
 
        r_r->ptr1 = 1;
        r_r->level = level;
index 12e94ace77d650565e07a8f4f799c9abbdb17c16..63f738466b17d2b131d030d409c0bfa5cc83b6eb 100644 (file)
@@ -707,9 +707,9 @@ void make_rpc_auth_ntlmssp_resp(RPC_AUTH_NTLMSSP_RESP *rsp,
 
        if (IS_BITS_SET_ALL(neg_flags, NTLMSSP_NEGOTIATE_UNICODE))
        {
-               struni2(rsp->domain, domain);
-               struni2(rsp->user  , user  );
-               struni2(rsp->wks   , wks   );
+               str_to_unistr8(rsp->domain, domain);
+               str_to_unistr8(rsp->user  , user  );
+               str_to_unistr8(rsp->wks   , wks   );
        }
        else
        {