removal of the use of unistrn2 function: replace it with unistr2_to_str
authorLuke Leighton <lkcl@samba.org>
Tue, 9 Feb 1999 19:51:44 +0000 (19:51 +0000)
committerLuke Leighton <lkcl@samba.org>
Tue, 9 Feb 1999 19:51:44 +0000 (19:51 +0000)
which is more appropriate.
(This used to be commit ac72fe1ab3d10f64a5945ccbd4ed3817e30f9f7b)

source3/include/proto.h
source3/lib/domain_namemap.c
source3/rpc_client/cli_lsarpc.c
source3/rpc_parse/parse_lsa.c
source3/rpc_parse/parse_misc.c
source3/rpc_server/srv_reg.c
source3/rpc_server/srv_samr.c
source3/rpcclient/display.c

index 8f2d73f95fab6b585a07b2cafb9a3fc02a993372..2ed35ee0af34c57b0994fe8be8db7c1c6174b063 100644 (file)
@@ -185,7 +185,7 @@ BOOL map_alias_sid(DOM_SID *psid, DOM_NAME_MAP *grp_info);
 BOOL map_group_sid(DOM_SID *psid, DOM_NAME_MAP *grp_info);
 BOOL lookupsmbpwnam(const char *unix_usr_name, DOM_NAME_MAP *grp);
 BOOL lookupsmbpwuid(uid_t uid, DOM_NAME_MAP *gmep);
-BOOL lookupsmbpwntnam(char *fullntname, DOM_NAME_MAP *gmep);
+BOOL lookupsmbpwntnam(const char *fullntname, DOM_NAME_MAP *gmep);
 BOOL lookupsmbpwsid(DOM_SID *sid, DOM_NAME_MAP *gmep);
 BOOL lookupsmbgrpnam(const char *unix_grp_name, DOM_NAME_MAP *grp);
 BOOL lookupsmbgrpsid(DOM_SID *sid, DOM_NAME_MAP *gmep);
@@ -1880,7 +1880,7 @@ void make_buf_unistr2(UNISTR2 *str, uint32 *ptr, char *buf);
 void copy_unistr2(UNISTR2 *str, UNISTR2 *from);
 void make_string2(STRING2 *str, char *buf, int len);
 void smb_io_string2(char *desc,  STRING2 *str2, uint32 buffer, prs_struct *ps, int depth);
-void make_unistr2(UNISTR2 *str, char *buf, int len);
+void make_unistr2(UNISTR2 *str, const char *buf, int len);
 void smb_io_unistr2(char *desc,  UNISTR2 *uni2, uint32 buffer, prs_struct *ps, int depth);
 void make_dom_rid2(DOM_RID2 *rid2, uint32 rid, uint8 type, uint32 idx);
 void smb_io_dom_rid2(char *desc,  DOM_RID2 *rid2, prs_struct *ps, int depth);
index f095c8d764b90aaac152fc1727d58770a236c7e7..892263f08490f13b2da477bfdc30f736e420b16f 100644 (file)
@@ -1070,7 +1070,7 @@ BOOL lookupsmbpwuid(uid_t uid, DOM_NAME_MAP *gmep)
 /*************************************************************************
  looks up by NT name, returns User Information.  
 *************************************************************************/
-BOOL lookupsmbpwntnam(char *fullntname, DOM_NAME_MAP *gmep)
+BOOL lookupsmbpwntnam(const char *fullntname, DOM_NAME_MAP *gmep)
 {
        DEBUG(10,("lookupsmbpwntnam: nt user name %s\n", fullntname));
 
index 6f78f308dda644dbe93426c1e2411cb9aa285e80..4c55572b6268e791511b7a6cf3d730a5433f2dab 100644 (file)
@@ -427,9 +427,7 @@ BOOL lsa_query_info_pol(struct cli_state *cli, uint16 fnum,
                                {
                                        if (r_q.dom.id3.buffer_dom_name != 0)
                                        {
-                                               char *dom_name = unistrn2(r_q.dom.id3.uni_domain_name.buffer,
-                                                                         r_q.dom.id3.uni_domain_name.uni_str_len);
-                                               fstrcpy(domain_name, dom_name);
+                                               fstrcpy(domain_name, unistr2_to_str(&r_q.dom.id3.uni_domain_name));
                                        }
                                        if (r_q.dom.id3.buffer_dom_sid != 0)
                                        {
@@ -443,9 +441,7 @@ BOOL lsa_query_info_pol(struct cli_state *cli, uint16 fnum,
                                {
                                        if (r_q.dom.id5.buffer_dom_name != 0)
                                        {
-                                               char *dom_name = unistrn2(r_q.dom.id5.uni_domain_name.buffer,
-                                                                         r_q.dom.id5.uni_domain_name.uni_str_len);
-                                               fstrcpy(domain_name, dom_name);
+                                               fstrcpy(domain_name, unistr2_to_str(&r_q.dom.id5.uni_domain_name));
                                        }
                                        if (r_q.dom.id5.buffer_dom_sid != 0)
                                        {
index 239c0847afd6513b283eea62436583078246833a..cb88e715362b34c218c21667dcba43ca3f3e8cbe 100644 (file)
@@ -688,9 +688,10 @@ void make_q_lookup_names(LSA_Q_LOOKUP_NAMES *q_l, POLICY_HND *hnd,
 
        for (i = 0; i < num_names; i++)
        {
-               int len = strlen(names[i]);
+               const char* name = names[i];
+               int len = strlen(name);
                make_uni_hdr(&q_l->hdr_name[i], len, len, len != 0);
-               make_unistr2(&q_l->uni_name[i], names[i], len);
+               make_unistr2(&q_l->uni_name[i], name, len);
        }
 
        q_l->num_trans_entries  = 0;
index e1a7d3c6a595284c3b8fe907ac08cb3d582de690..bf3bba1249d5ef28fceffab958d33a4ceca7a49e 100644 (file)
@@ -563,7 +563,7 @@ void smb_io_string2(char *desc,  STRING2 *str2, uint32 buffer, prs_struct *ps, i
 /*******************************************************************
 creates a UNISTR2 structure.
 ********************************************************************/
-void make_unistr2(UNISTR2 *str, char *buf, int len)
+void make_unistr2(UNISTR2 *str, const char *buf, int len)
 {
        ZERO_STRUCTP(str);
 
@@ -573,7 +573,7 @@ void make_unistr2(UNISTR2 *str, 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);
+       struni2((char*)(str->buffer), buf);
 }
 
 /*******************************************************************
index b90912488f1b5ed70984250206cb8a0565d9f9c8..f98133626d50d0e96ed9fd8141c2f956c7c6ca40 100644 (file)
@@ -136,7 +136,7 @@ static void reg_reply_open_entry(REG_Q_OPEN_ENTRY *q_u,
                status = 0xC000000 | NT_STATUS_TOO_MANY_SECRETS; /* ha ha very droll */
        }
 
-       fstrcpy(name, unistrn2(q_u->uni_name.buffer, q_u->uni_name.uni_str_len));
+       fstrcpy(name, unistr2_to_str(&q_u->uni_name));
 
        if (status == 0x0)
        {
index 1fb64c10effec1fdeae92c23d2e22b687773b43f..8961660071dcaac0cf99f4c01739239eb6045a7b 100644 (file)
@@ -1527,8 +1527,8 @@ static void samr_reply_chgpasswd_user(SAMR_Q_CHGPASSWD_USER *q_u,
        fstring user_name;
        fstring wks;
 
-       fstrcpy(user_name, unistrn2(q_u->uni_user_name.buffer, q_u->uni_user_name.uni_str_len));
-       fstrcpy(wks      , unistrn2(q_u->uni_dest_host.buffer, q_u->uni_dest_host.uni_str_len));
+       fstrcpy(user_name, unistr2_to_str(&q_u->uni_user_name));
+       fstrcpy(wks      , unistr2_to_str(&q_u->uni_dest_host));
 
        DEBUG(5,("samr_chgpasswd_user: user: %s wks: %s\n", user_name, wks));
 
@@ -2340,8 +2340,7 @@ static void api_samr_unknown_32( uint16 vuid, prs_struct *data, prs_struct *rdat
           reply if the account already exists...
         */
 
-       fstrcpy(mach_acct, unistrn2(q_u.uni_mach_acct.buffer,
-                                   q_u.uni_mach_acct.uni_str_len));
+       fstrcpy(mach_acct, unistr2_to_str(&q_u.uni_mach_acct));
 
        become_root(True);
        sam_pass = getsam21pwntnam(mach_acct);
index d37b7283f8f20ae1891a2616f689463b01936c07..173a42bf73494f51ec251933071a564e65c0e633 100644 (file)
@@ -192,8 +192,8 @@ void display_srv_info_101(FILE *out_hnd, enum action_type action,
                        fstring name;
                        fstring comment;
 
-                       fstrcpy(name    , unistrn2(sv101->uni_name    .buffer, sv101->uni_name    .uni_str_len));
-                       fstrcpy(comment , unistrn2(sv101->uni_comment .buffer, sv101->uni_comment .uni_str_len));
+                       fstrcpy(name    , unistr2_to_str(&sv101->uni_name    ));
+                       fstrcpy(comment , unistr2_to_str(&sv101->uni_comment ));
 
                        display_server(out_hnd, action, name, sv101->srv_type, comment);
 
@@ -234,9 +234,9 @@ void display_srv_info_102(FILE *out_hnd, enum action_type action,SRV_INFO_102 *s
                        fstring comment;
                        fstring usr_path;
 
-                       fstrcpy(name    , unistrn2(sv102->uni_name    .buffer, sv102->uni_name    .uni_str_len));
-                       fstrcpy(comment , unistrn2(sv102->uni_comment .buffer, sv102->uni_comment .uni_str_len));
-                       fstrcpy(usr_path, unistrn2(sv102->uni_usr_path.buffer, sv102->uni_usr_path.uni_str_len));
+                       fstrcpy(name    , unistr2_to_str(&sv102->uni_name    ));
+                       fstrcpy(comment , unistr2_to_str(&sv102->uni_comment ));
+                       fstrcpy(usr_path, unistr2_to_str(&sv102->uni_usr_path));
 
                        display_server(out_hnd, action, name, sv102->srv_type, comment);
 
@@ -347,8 +347,8 @@ void display_conn_info_1(FILE *out_hnd, enum action_type action,
                        fstring usr_name;
                        fstring net_name;
 
-                       fstrcpy(usr_name, unistrn2(str1->uni_usr_name.buffer, str1->uni_usr_name.uni_str_len));
-                       fstrcpy(net_name, unistrn2(str1->uni_net_name.buffer, str1->uni_net_name.uni_str_len));
+                       fstrcpy(usr_name, unistr2_to_str(&str1->uni_usr_name));
+                       fstrcpy(net_name, unistr2_to_str(&str1->uni_net_name));
 
                        fprintf(out_hnd, "\tid       :\t%d\n", info1->id);
                        fprintf(out_hnd, "\ttype     :\t%s\n", get_share_type_str(info1->type));
@@ -503,8 +503,8 @@ void display_share_info_1(FILE *out_hnd, enum action_type action,
                        fstring remark  ;
                        fstring net_name;
 
-                       fstrcpy(net_name, unistrn2(str1->uni_netname.buffer, str1->uni_netname.uni_str_len));
-                       fstrcpy(remark  , unistrn2(str1->uni_remark .buffer, str1->uni_remark .uni_str_len));
+                       fstrcpy(net_name, unistr2_to_str(&str1->uni_netname));
+                       fstrcpy(remark  , unistr2_to_str(&str1->uni_remark ));
 
                        display_share(out_hnd, action, net_name, info1->type, remark);
 
@@ -545,10 +545,10 @@ void display_share_info_2(FILE *out_hnd, enum action_type action,
                        fstring path    ;
                        fstring passwd  ;
 
-                       fstrcpy(net_name, unistrn2(str2->uni_netname.buffer, str2->uni_netname.uni_str_len));
-                       fstrcpy(remark  , unistrn2(str2->uni_remark .buffer, str2->uni_remark .uni_str_len));
-                       fstrcpy(path    , unistrn2(str2->uni_path   .buffer, str2->uni_path   .uni_str_len));
-                       fstrcpy(passwd  , unistrn2(str2->uni_passwd .buffer, str2->uni_passwd .uni_str_len));
+                       fstrcpy(net_name, unistr2_to_str(&str2->uni_netname));
+                       fstrcpy(remark  , unistr2_to_str(&str2->uni_remark ));
+                       fstrcpy(path    , unistr2_to_str(&str2->uni_path   ));
+                       fstrcpy(passwd  , unistr2_to_str(&str2->uni_passwd ));
 
                        display_share2(out_hnd, action, net_name, info2->type, remark,
                                                              info2->perms, info2->max_uses, info2->num_uses,
@@ -698,8 +698,8 @@ void display_file_info_3(FILE *out_hnd, enum action_type action,
                        fstring path_name;
                        fstring user_name;
 
-                       fstrcpy(path_name, unistrn2(str3->uni_path_name.buffer, str3->uni_path_name.uni_str_len));
-                       fstrcpy(user_name, unistrn2(str3->uni_user_name.buffer, str3->uni_user_name.uni_str_len));
+                       fstrcpy(path_name, unistr2_to_str(&str3->uni_path_name));
+                       fstrcpy(user_name, unistr2_to_str(&str3->uni_user_name));
 
                        fprintf(out_hnd, "\tid       :\t%d\n", info3->id);
                        fprintf(out_hnd, "\tperms    :\t%s\n", get_file_mode_str(info3->perms));
@@ -1148,16 +1148,16 @@ void display_sam_user_info_21(FILE *out_hnd, enum action_type action, SAM_USER_I
                }
                case ACTION_ENUMERATE:
                {
-                       fprintf(out_hnd, "\t\tUser Name   :\t%s\n", unistrn2(usr->uni_user_name   .buffer, usr->uni_user_name   .uni_str_len)); /* username unicode string */
-                       fprintf(out_hnd, "\t\tFull Name   :\t%s\n", unistrn2(usr->uni_full_name   .buffer, usr->uni_full_name   .uni_str_len)); /* user's full name unicode string */
-                       fprintf(out_hnd, "\t\tHome Drive  :\t%s\n", unistrn2(usr->uni_home_dir    .buffer, usr->uni_home_dir    .uni_str_len)); /* home directory unicode string */
-                       fprintf(out_hnd, "\t\tDir Drive   :\t%s\n", unistrn2(usr->uni_dir_drive   .buffer, usr->uni_dir_drive   .uni_str_len)); /* home directory drive unicode string */
-                       fprintf(out_hnd, "\t\tProfile Path:\t%s\n", unistrn2(usr->uni_profile_path.buffer, usr->uni_profile_path.uni_str_len)); /* profile path unicode string */
-                       fprintf(out_hnd, "\t\tLogon Script:\t%s\n", unistrn2(usr->uni_logon_script.buffer, usr->uni_logon_script.uni_str_len)); /* logon script unicode string */
-                       fprintf(out_hnd, "\t\tDescription :\t%s\n", unistrn2(usr->uni_acct_desc   .buffer, usr->uni_acct_desc   .uni_str_len)); /* user description unicode string */
-                       fprintf(out_hnd, "\t\tWorkstations:\t%s\n", unistrn2(usr->uni_workstations.buffer, usr->uni_workstations.uni_str_len)); /* workstaions unicode string */
-                       fprintf(out_hnd, "\t\tUnknown Str :\t%s\n", unistrn2(usr->uni_unknown_str .buffer, usr->uni_unknown_str .uni_str_len)); /* unknown string unicode string */
-                       fprintf(out_hnd, "\t\tRemote Dial :\t%s\n", unistrn2(usr->uni_munged_dial .buffer, usr->uni_munged_dial .uni_str_len)); /* munged remote access unicode string */
+                       fprintf(out_hnd, "\t\tUser Name   :\t%s\n", unistr2_to_str(&usr->uni_user_name   )); /* username unicode string */
+                       fprintf(out_hnd, "\t\tFull Name   :\t%s\n", unistr2_to_str(&usr->uni_full_name   )); /* user's full name unicode string */
+                       fprintf(out_hnd, "\t\tHome Drive  :\t%s\n", unistr2_to_str(&usr->uni_home_dir    )); /* home directory unicode string */
+                       fprintf(out_hnd, "\t\tDir Drive   :\t%s\n", unistr2_to_str(&usr->uni_dir_drive   )); /* home directory drive unicode string */
+                       fprintf(out_hnd, "\t\tProfile Path:\t%s\n", unistr2_to_str(&usr->uni_profile_path)); /* profile path unicode string */
+                       fprintf(out_hnd, "\t\tLogon Script:\t%s\n", unistr2_to_str(&usr->uni_logon_script)); /* logon script unicode string */
+                       fprintf(out_hnd, "\t\tDescription :\t%s\n", unistr2_to_str(&usr->uni_acct_desc   )); /* user description unicode string */
+                       fprintf(out_hnd, "\t\tWorkstations:\t%s\n", unistr2_to_str(&usr->uni_workstations)); /* workstaions unicode string */
+                       fprintf(out_hnd, "\t\tUnknown Str :\t%s\n", unistr2_to_str(&usr->uni_unknown_str )); /* unknown string unicode string */
+                       fprintf(out_hnd, "\t\tRemote Dial :\t%s\n", unistr2_to_str(&usr->uni_munged_dial )); /* munged remote access unicode string */
 
                        fprintf(out_hnd, "\t\tLogon Time               :\t%s\n", http_timestring(nt_time_to_unix(&(usr->logon_time           ))));
                        fprintf(out_hnd, "\t\tLogoff Time              :\t%s\n", http_timestring(nt_time_to_unix(&(usr->logoff_time          ))));