First cut at unicode sys_xx functions. Now to start moving upwards.....
authorJeremy Allison <jra@samba.org>
Wed, 22 Dec 1999 01:29:22 +0000 (01:29 +0000)
committerJeremy Allison <jra@samba.org>
Wed, 22 Dec 1999 01:29:22 +0000 (01:29 +0000)
Jeremy.
(This used to be commit b5eb009cc3cfd1adc044e91911d59acdb54c30cb)

source3/include/includes.h
source3/include/proto.h
source3/include/smb.h
source3/lib/system.c
source3/script/mkproto.awk

index e8eb8e28ea5057d1ccf112692806a1c70c1dbe85..b42f5e0115276658ddc637e41158a6ab6ca43826 100644 (file)
@@ -649,6 +649,31 @@ extern int errno;
 #define MAXCODEPAGELINES 256
 #endif
 
+/*
+ * Type for wide character dirent structure.
+ */
+
+typedef struct smb_wdirent {
+       SMB_INO_T       d_ino;
+       SMB_OFF_T       d_off;
+       unsigned short  d_reclen;
+       wpstring        d_name;
+} SMB_STRUCT_WDIRENT;
+
+/*
+ * Type for wide character passwd structure.
+ */
+
+typedef struct smb_wpasswd {
+       wfstring       pw_name;
+       char           *pw_passwd;
+       uid_t          pw_uid;
+       gid_t          pw_gid;
+       wpstring       pw_gecos;
+       wpstring       pw_dir;
+       wpstring       pw_shell;
+} SMB_STRUCT_WPASSWD;
+
 /***** automatically generated prototypes *****/
 #include "proto.h"
 
index 79abdf5f5606e1d0ede01feb55c032afb1705168..18762c32fb1758c2a8a2143aa2136f9190bdf24a 100644 (file)
@@ -182,6 +182,15 @@ int sys_getgroups(int setlen, gid_t *gidset);
 int sys_setgroups(int setlen, gid_t *gidset);
 struct passwd *sys_getpwnam(const char *name);
 struct passwd *sys_getpwuid(uid_t uid);
+int wsys_stat(const smb_ucs2_t *wfname,SMB_STRUCT_STAT *sbuf);
+int wsys_lstat(const smb_ucs2_t *wfname,SMB_STRUCT_STAT *sbuf);
+int wsys_creat(const smb_ucs2_t *wfname, mode_t mode);
+int wsys_open(const smb_ucs2_t *wfname, int oflag, mode_t mode);
+FILE *wsys_fopen(const smb_ucs2_t *wfname, const char *type);
+DIR *wsys_opendir(const smb_ucs2_t *wfname);
+smb_ucs2_t *wsys_getwd(smb_ucs2_t *s);
+int wsys_chown(const smb_ucs2_t *wfname, uid_t uid, gid_t gid);
+int wsys_chroot(const smb_ucs2_t *wfname);
 
 /*The following definitions come from  lib/time.c  */
 
@@ -423,11 +432,21 @@ void default_unicode_map(smb_ucs2_t **pp_cp_to_ucs2, uint16 **pp_ucs2_to_cp);
 BOOL load_unicode_map(const char *codepage, smb_ucs2_t **pp_cp_to_ucs2, uint16 **pp_ucs2_to_cp);
 BOOL load_dos_unicode_map(int codepage);
 BOOL load_unix_unicode_map(const char *unix_char_set);
+smb_ucs2_t *multibyte_to_unicode(smb_ucs2_t *dst, const char *src,
+                                 size_t dst_len, smb_ucs2_t *cp_to_ucs2);
 char *unicode_to_unix(char *dst, const smb_ucs2_t *src, size_t dst_len);
+smb_ucs2_t *unix_to_unicode(smb_ucs2_t *dst, const char *src, size_t dst_len);
 char *unicode_to_dos(char *dst, const smb_ucs2_t *src, size_t dst_len);
+smb_ucs2_t *dos_to_unicode(smb_ucs2_t *dst, const char *src, size_t dst_len);
 size_t wstrlen(const smb_ucs2_t *src);
+smb_ucs2_t *safe_wstrcpy(smb_ucs2_t *dest,const smb_ucs2_t *src, size_t maxlength);
+smb_ucs2_t *safe_wstrcat(smb_ucs2_t *dest, const smb_ucs2_t *src, size_t maxlength);
 int wstrcmp(const smb_ucs2_t *s1, const smb_ucs2_t *s2);
 int wstrncmp(const smb_ucs2_t *s1, const smb_ucs2_t *s2, size_t len);
+smb_ucs2_t *wstrstr(const smb_ucs2_t *s1, const smb_ucs2_t *s2);
+smb_ucs2_t *wstrchr(const smb_ucs2_t *s, smb_ucs2_t c);
+smb_ucs2_t *wstrrchr(const smb_ucs2_t *s, smb_ucs2_t c);
+smb_ucs2_t *wstrtok(smb_ucs2_t *s1, const smb_ucs2_t *s2);
 
 /*The following definitions come from  libsmb/clientgen.c  */
 
index de269f1d7d46bff0e41933503bf77d6aa67977e9..ec1aaf22733becbd7b230cd5b2862555faa12a94 100644 (file)
@@ -333,6 +333,16 @@ implemented */
 typedef char pstring[1024];
 typedef char fstring[128];
 
+/*
+ * SMB UCS2 (16-bit unicode) internal type.
+ */
+
+typedef uint16 smb_ucs2_t;
+
+/* ucs2 string types. */
+typedef smb_ucs2_t wpstring[1024];
+typedef smb_ucs2_t wfstring[128];
+
 /* pipe string names */
 #define PIPE_LANMAN   "\\PIPE\\LANMAN"
 #define PIPE_SRVSVC   "\\PIPE\\srvsvc"
@@ -1792,10 +1802,4 @@ struct nmb_name {
 #define MAP_TO_GUEST_ON_BAD_USER 1
 #define MAP_TO_GUEST_ON_BAD_PASSWORD 2
 
-/*
- * SMB UCS2 (16-bit unicode) internal type.
- */
-
-typedef uint16 smb_ucs2_t;
-
 #endif /* _SMB_H */
index a59f94a6a962d0507f63c22c3d7a4f64b45663bf..710f30bac8b40ac495241d42fe028986313671e9 100644 (file)
@@ -722,3 +722,172 @@ struct passwd *sys_getpwuid(uid_t uid)
 {
        return setup_pwret(getpwuid(uid));
 }
+
+/**************************************************************************
+ The following are the UNICODE versions of *all* system interface functions
+ called within Samba. Ok, ok, the exceptions are the gethostbyXX calls,
+ which currently are left as ascii as they are not used other than in name
+ resolution.
+****************************************************************************/
+
+/**************************************************************************
+ Wide stat. Just narrow and call sys_xxx.
+****************************************************************************/
+
+int wsys_stat(const smb_ucs2_t *wfname,SMB_STRUCT_STAT *sbuf)
+{
+       pstring fname;
+       return sys_stat(unicode_to_unix(fname,wfname,sizeof(fname)), sbuf);
+}
+
+/**************************************************************************
+ Wide lstat. Just narrow and call sys_xxx.
+****************************************************************************/
+
+int wsys_lstat(const smb_ucs2_t *wfname,SMB_STRUCT_STAT *sbuf)
+{
+       pstring fname;
+       return sys_lstat(unicode_to_unix(fname,wfname,sizeof(fname)), sbuf);
+}
+
+/**************************************************************************
+ Wide creat. Just narrow and call sys_xxx.
+****************************************************************************/
+
+int wsys_creat(const smb_ucs2_t *wfname, mode_t mode)
+{
+       pstring fname;
+       return sys_creat(unicode_to_unix(fname,wfname,sizeof(fname)), mode);
+}
+
+/**************************************************************************
+ Wide open. Just narrow and call sys_xxx.
+****************************************************************************/
+
+int wsys_open(const smb_ucs2_t *wfname, int oflag, mode_t mode)
+{
+       pstring fname;
+       return sys_open(unicode_to_unix(fname,wfname,sizeof(fname)), oflag, mode);
+}
+
+/**************************************************************************
+ Wide fopen. Just narrow and call sys_xxx.
+****************************************************************************/
+
+FILE *wsys_fopen(const smb_ucs2_t *wfname, const char *type)
+{
+       pstring fname;
+       return sys_fopen(unicode_to_unix(fname,wfname,sizeof(fname)), type);
+}
+
+/**************************************************************************
+ Wide opendir. Just narrow and call sys_xxx.
+****************************************************************************/
+
+DIR *wsys_opendir(const smb_ucs2_t *wfname)
+{
+       pstring fname;
+       return opendir(unicode_to_unix(fname,wfname,sizeof(fname)));
+}
+
+/**************************************************************************
+ Wide readdir. Return a structure pointer containing a wide filename.
+****************************************************************************/
+
+SMB_STRUCT_WDIRENT *wsys_readdir(DIR *dirp)
+{
+       static SMB_STRUCT_WDIRENT retval;
+       SMB_STRUCT_DIRENT *dirval = sys_readdir(dirp);
+
+       if(!dirval)
+               return NULL;
+
+       retval.d_ino = (SMB_INO_T)dirval->d_ino;
+       retval.d_off = (SMB_OFF_T)dirval->d_off;
+       unix_to_unicode(retval.d_name,dirval->d_name,sizeof(retval.d_name));
+       retval.d_reclen = wstrlen(retval.d_name);
+
+       return &retval;
+}
+
+/**************************************************************************
+ Wide getwd. Call sys_xxx and widen. Assumes s points to a wpstring.
+****************************************************************************/
+
+smb_ucs2_t *wsys_getwd(smb_ucs2_t *s)
+{
+       pstring fname;
+       char *p = sys_getwd(fname);
+
+       if(!p)
+               return NULL;
+
+       return unix_to_unicode(s, p, sizeof(wpstring));
+}
+
+/**************************************************************************
+ Wide chown. Just narrow and call sys_xxx.
+****************************************************************************/
+
+int wsys_chown(const smb_ucs2_t *wfname, uid_t uid, gid_t gid)
+{
+       pstring fname;
+       return chown(unicode_to_unix(fname,wfname,sizeof(fname)), uid, gid);
+}
+
+/**************************************************************************
+ Wide chroot. Just narrow and call sys_xxx.
+****************************************************************************/
+
+int wsys_chroot(const smb_ucs2_t *wfname)
+{
+       pstring fname;
+       return chroot(unicode_to_unix(fname,wfname,sizeof(fname)));
+}
+
+/**************************************************************************
+ Wide getpwnam. Return a structure pointer containing wide names.
+****************************************************************************/
+
+SMB_STRUCT_WPASSWD *wsys_getpwnam(const smb_ucs2_t *wname)
+{
+       static SMB_STRUCT_WPASSWD retval;
+       fstring name;
+       struct passwd *pwret = sys_getpwnam(unicode_to_unix(name,wname,sizeof(name)));
+
+       if(!pwret)
+               return NULL;
+
+       unix_to_unicode(retval.pw_name, pwret->pw_name, sizeof(retval.pw_name));
+       retval.pw_passwd = pwret->pw_passwd;
+       retval.pw_uid = pwret->pw_uid;
+       retval.pw_gid = pwret->pw_gid;
+       unix_to_unicode(retval.pw_gecos, pwret->pw_gecos, sizeof(retval.pw_gecos));
+       unix_to_unicode(retval.pw_dir, pwret->pw_dir, sizeof(retval.pw_dir));
+       unix_to_unicode(retval.pw_shell, pwret->pw_shell, sizeof(retval.pw_shell));
+
+       return &retval;
+}
+
+/**************************************************************************
+ Wide getpwuid. Return a structure pointer containing wide names.
+****************************************************************************/
+
+SMB_STRUCT_WPASSWD *wsys_getpwuid(uid_t uid)
+{
+       static SMB_STRUCT_WPASSWD retval;
+       struct passwd *pwret = sys_getpwuid(uid);
+
+       if(!pwret)
+               return NULL;
+
+       unix_to_unicode(retval.pw_name, pwret->pw_name, sizeof(retval.pw_name));
+       retval.pw_passwd = pwret->pw_passwd;
+       retval.pw_uid = pwret->pw_uid;
+       retval.pw_gid = pwret->pw_gid;
+       unix_to_unicode(retval.pw_gecos, pwret->pw_gecos, sizeof(retval.pw_gecos));
+       unix_to_unicode(retval.pw_dir, pwret->pw_dir, sizeof(retval.pw_dir));
+       unix_to_unicode(retval.pw_shell, pwret->pw_shell, sizeof(retval.pw_shell));
+
+       return &retval;
+}
index fd0cbcd2f8fa0a457d47d040be988b753ff24c5d..c24dfac98cc6ce122a3217852c1f2da1d3de7b23 100644 (file)
@@ -98,7 +98,7 @@ END {
     gotstart = 1;
   }
 
-  if( $0 ~ /^TDB_CONTEXT|^TDB_DATA/ ) {
+  if( $0 ~ /^TDB_CONTEXT|^TDB_DATA|^smb_ucs2_t/ ) {
     gotstart = 1;
   }