Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/dist/smbfs/lib/smb make compile on NetBSD - <sys/endian.h> i...



details:   https://anonhg.NetBSD.org/src/rev/606e12c0d463
branches:  trunk
changeset: 543143:606e12c0d463
user:      jdolecek <jdolecek%NetBSD.org@localhost>
date:      Tue Feb 18 09:52:03 2003 +0000

description:
make compile on NetBSD - <sys/endian.h> instead of <sys/mchain.h>, use
explicit width macros, disable some not-yet supported functionality
(conversion map upload, smb_dumptree())

diffstat:

 dist/smbfs/lib/smb/ctx.c     |  11 ++++++++++-
 dist/smbfs/lib/smb/kiconv.c  |   8 +++++++-
 dist/smbfs/lib/smb/mbuf.c    |  18 +++++++++---------
 dist/smbfs/lib/smb/nb_name.c |   4 ++--
 dist/smbfs/lib/smb/rap.c     |  13 +++++--------
 dist/smbfs/lib/smb/rq.c      |   4 +---
 dist/smbfs/lib/smb/subr.c    |   8 ++++++++
 7 files changed, 42 insertions(+), 24 deletions(-)

diffs (truncated from 309 to 300 lines):

diff -r 9a3ccadac202 -r 606e12c0d463 dist/smbfs/lib/smb/ctx.c
--- a/dist/smbfs/lib/smb/ctx.c  Tue Feb 18 09:47:48 2003 +0000
+++ b/dist/smbfs/lib/smb/ctx.c  Tue Feb 18 09:52:03 2003 +0000
@@ -45,7 +45,7 @@
 #include <pwd.h>
 #include <grp.h>
 #include <unistd.h>
-#include <sys/iconv.h>
+#include <netsmb/iconv.h>
 
 #define NB_NEEDRESOLVER
 
@@ -571,6 +571,7 @@
        int fd, i;
        char buf[20];
 
+#ifndef __NetBSD__
        /*
         * First, try to open as cloned device
         */
@@ -579,6 +580,8 @@
                ctx->ct_fd = fd;
                return 0;
        }
+#endif
+
        /*
         * well, no clone capabilities available - we have to scan
         * all devices in order to get free one
@@ -590,7 +593,11 @@
                        ctx->ct_fd = fd;
                        return 0;
                 }
+                if (errno == ENOENT)
+                        return ENOENT;
         }
+
+#ifndef __NetBSD
         /*
          * This is a compatibility with old /dev/net/nsmb device
          */
@@ -604,6 +611,8 @@
                 if (errno == ENOENT)
                         return ENOENT;
         }
+#endif
+
         return ENOENT;
 }
 
diff -r 9a3ccadac202 -r 606e12c0d463 dist/smbfs/lib/smb/kiconv.c
--- a/dist/smbfs/lib/smb/kiconv.c       Tue Feb 18 09:47:48 2003 +0000
+++ b/dist/smbfs/lib/smb/kiconv.c       Tue Feb 18 09:52:03 2003 +0000
@@ -32,11 +32,12 @@
  * from: Id: kiconv.c,v 1.3 2001/08/22 03:31:36 bp Exp 
  */
 
+#include <sys/param.h>
 #include <sys/types.h>
-#include <sys/iconv.h>
 #include <sys/sysctl.h>
 #include <ctype.h>
 #include <errno.h>
+#include <netsmb/iconv.h>
 
 #ifdef APPLE
 #include <sys/types.h>
@@ -46,6 +47,10 @@
 int
 kiconv_add_xlat_table(const char *to, const char *from, const u_char *table)
 {
+#ifdef __NetBSD__
+       /* XXX not supported on NetBSD (yet) */
+       return (0);
+#else
        struct iconv_add_in din;
        struct iconv_add_out dout;
        int olen;
@@ -71,5 +76,6 @@
                return errno;
 #endif
        return 0;
+#endif
 }
 
diff -r 9a3ccadac202 -r 606e12c0d463 dist/smbfs/lib/smb/mbuf.c
--- a/dist/smbfs/lib/smb/mbuf.c Tue Feb 18 09:47:48 2003 +0000
+++ b/dist/smbfs/lib/smb/mbuf.c Tue Feb 18 09:52:03 2003 +0000
@@ -33,7 +33,7 @@
  */
 
 #include <sys/types.h>
-#include <sys/mchain.h>
+#include <sys/endian.h>
 #include <ctype.h>
 #include <errno.h>
 #include <stdio.h>
@@ -264,7 +264,7 @@
 mb_put_int64be(struct mbdata *mbp, int64_t x)
 {
        MB_PUT(int64_t);
-       *p = htobeq(x);
+       *p = htobe64(x);
        return 0;
 }
 
@@ -272,7 +272,7 @@
 mb_put_int64le(struct mbdata *mbp, int64_t x)
 {
        MB_PUT(int64_t);
-       *p = htoleq(x);
+       *p = htole64(x);
        return 0;
 }
 
@@ -363,7 +363,7 @@
        u_int16_t v;
        int error = mb_get_uint16(mbp, &v);
 
-       *x = letohs(v);
+       *x = le16toh(v);
        return error;
 }
 
@@ -372,7 +372,7 @@
        u_int16_t v;
        int error = mb_get_uint16(mbp, &v);
 
-       *x = betohs(v);
+       *x = be16toh(v);
        return error;
 }
 
@@ -389,7 +389,7 @@
        int error;
 
        error = mb_get_uint32(mbp, &v);
-       *x = betohl(v);
+       *x = be32toh(v);
        return error;
 }
 
@@ -400,7 +400,7 @@
        int error;
 
        error = mb_get_uint32(mbp, &v);
-       *x = letohl(v);
+       *x = le32toh(v);
        return error;
 }
 
@@ -417,7 +417,7 @@
        int error;
 
        error = mb_get_int64(mbp, &v);
-       *x = betohq(v);
+       *x = be64toh(v);
        return error;
 }
 
@@ -428,7 +428,7 @@
        int error;
 
        error = mb_get_int64(mbp, &v);
-       *x = letohq(v);
+       *x = le64toh(v);
        return error;
 }
 
diff -r 9a3ccadac202 -r 606e12c0d463 dist/smbfs/lib/smb/nb_name.c
--- a/dist/smbfs/lib/smb/nb_name.c      Tue Feb 18 09:47:48 2003 +0000
+++ b/dist/smbfs/lib/smb/nb_name.c      Tue Feb 18 09:52:03 2003 +0000
@@ -33,7 +33,7 @@
  */
 #include <sys/param.h>
 #include <sys/socket.h>
-#include <sys/mchain.h>                /* for endiand macros */
+#include <sys/endian.h>
 
 #include <ctype.h>
 #include <err.h>
@@ -139,7 +139,7 @@
        return len;
 }
 
-#define        NBENCODE(c)     (htoles((u_short)(((u_char)(c) >> 4) | \
+#define        NBENCODE(c)     (htole16((u_short)(((u_char)(c) >> 4) | \
                         (((u_char)(c) & 0xf) << 8)) + 0x4141))
 
 static void
diff -r 9a3ccadac202 -r 606e12c0d463 dist/smbfs/lib/smb/rap.c
--- a/dist/smbfs/lib/smb/rap.c  Tue Feb 18 09:47:48 2003 +0000
+++ b/dist/smbfs/lib/smb/rap.c  Tue Feb 18 09:52:03 2003 +0000
@@ -36,6 +36,7 @@
 #include <sys/param.h>
 #include <sys/errno.h>
 #include <sys/stat.h>
+#include <sys/endian.h>
 #include <ctype.h>
 #include <err.h>
 #include <stdio.h>
@@ -44,14 +45,10 @@
 #include <stdlib.h>
 #include <sysexits.h>
 
-#include <sys/mchain.h>
-
 #include <netsmb/smb_lib.h>
 #include <netsmb/smb_conn.h>
 #include <netsmb/smb_rap.h>
 
-/*#include <sys/ioctl.h>*/
-
 static int
 smb_rap_parserqparam(const char *s, char **next, int *rlen)
 {
@@ -289,7 +286,7 @@
                return error;
        switch (ptype) {
            case 'h':
-               *value = letohs(*(u_int16_t*)rap->r_npbuf);
+               *value = ntohs(*(u_int16_t*)rap->r_npbuf);
                break;
            default:
                return EINVAL;
@@ -319,8 +316,8 @@
        if (error)
                return error;
        rp = (u_int16_t*)rap->r_pbuf;
-       rap->r_result = letohs(*rp++);
-       conv = letohs(*rp++);
+       rap->r_result = le16toh(*rp++);
+       conv = le16toh(*rp++);
        rap->r_npbuf = (char*)rp;
        rap->r_entries = entries = 0;
        done = 0;
@@ -328,7 +325,7 @@
                ptype = *p;
                switch (ptype) {
                    case 'e':
-                       rap->r_entries = entries = letohs(*(u_int16_t*)rap->r_npbuf);
+                       rap->r_entries = entries = le16toh(*(u_int16_t*)rap->r_npbuf);
                        rap->r_npbuf += 2;
                        p++;
                        break;
diff -r 9a3ccadac202 -r 606e12c0d463 dist/smbfs/lib/smb/rq.c
--- a/dist/smbfs/lib/smb/rq.c   Tue Feb 18 09:47:48 2003 +0000
+++ b/dist/smbfs/lib/smb/rq.c   Tue Feb 18 09:52:03 2003 +0000
@@ -33,9 +33,9 @@
  */
 #include <sys/param.h>
 #include <sys/ioctl.h>
-#include <sys/errno.h>
 #include <sys/stat.h>
 #include <ctype.h>
+#include <errno.h>
 #include <err.h>
 #include <stdio.h>
 #include <unistd.h>
@@ -43,8 +43,6 @@
 #include <stdlib.h>
 #include <sysexits.h>
 
-#include <sys/mchain.h>
-
 #include <netsmb/smb_lib.h>
 #include <netsmb/smb_conn.h>
 #include <netsmb/smb_rap.h>
diff -r 9a3ccadac202 -r 606e12c0d463 dist/smbfs/lib/smb/subr.c
--- a/dist/smbfs/lib/smb/subr.c Tue Feb 18 09:47:48 2003 +0000
+++ b/dist/smbfs/lib/smb/subr.c Tue Feb 18 09:52:03 2003 +0000
@@ -44,6 +44,7 @@
 #include <stdlib.h>
 #include <stdarg.h>
 #include <err.h>
+#include <errno.h>
 
 #include <netsmb/netbios.h>
 #include <netsmb/smb_lib.h>
@@ -69,8 +70,10 @@
 smb_lib_init(void)
 {
        int error;
+#if __FreeBSD_version > 400000
        int kv;
        size_t kvlen = sizeof(kv);
+#endif
 
        if (smblib_initialized)
                return 0;
@@ -179,6 +182,10 @@
 void *
 smb_dumptree(void)
 {
+#ifdef __NetBSD__
+       /* XXX not supported on NetBSD */
+       return NULL;
+#else
        size_t len;
        void *p;



Home | Main Index | Thread Index | Old Index