summaryrefslogtreecommitdiff
path: root/source3/include
diff options
context:
space:
mode:
Diffstat (limited to 'source3/include')
-rw-r--r--source3/include/byteorder.h80
-rw-r--r--source3/include/charset.h61
-rw-r--r--source3/include/clitar.h17
-rw-r--r--source3/include/includes.h1154
-rw-r--r--source3/include/kanji.h130
-rw-r--r--source3/include/local.h167
-rw-r--r--source3/include/nameserv.h184
-rw-r--r--source3/include/smb.h1006
-rw-r--r--source3/include/trans2.h241
-rw-r--r--source3/include/version.h1
-rw-r--r--source3/include/vt_mode.h48
11 files changed, 3089 insertions, 0 deletions
diff --git a/source3/include/byteorder.h b/source3/include/byteorder.h
new file mode 100644
index 0000000000..899cd6c499
--- /dev/null
+++ b/source3/include/byteorder.h
@@ -0,0 +1,80 @@
+/*
+ Unix SMB/Netbios implementation.
+ Version 1.9.
+ SMB Byte handling
+ Copyright (C) Andrew Tridgell 1992-1995
+
+ 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
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ 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.
+*/
+
+/*
+ This file implements macros for machine independent short and
+ int manipulation
+*/
+
+#undef CAREFUL_ALIGNMENT
+
+/* we know that the 386 can handle misalignment and has the "right"
+ byteorder */
+#ifdef __i386__
+#define CAREFUL_ALIGNMENT 0
+#endif
+
+#ifndef CAREFUL_ALIGNMENT
+#define CAREFUL_ALIGNMENT 1
+#endif
+
+#define CVAL(buf,pos) (((unsigned char *)(buf))[pos])
+#define PVAL(buf,pos) ((unsigned)CVAL(buf,pos))
+#define SCVAL(buf,pos,val) (CVAL(buf,pos) = (val))
+
+
+#if CAREFUL_ALIGNMENT
+#define SVAL(buf,pos) (PVAL(buf,pos)|PVAL(buf,(pos)+1)<<8)
+#define IVAL(buf,pos) (SVAL(buf,pos)|SVAL(buf,(pos)+2)<<16)
+#define SSVALX(buf,pos,val) (CVAL(buf,pos)=(val)&0xFF,CVAL(buf,pos+1)=(val)>>8)
+#define SIVALX(buf,pos,val) (SSVALX(buf,pos,val&0xFFFF),SSVALX(buf,pos+2,val>>16))
+#define SVALS(buf,pos) ((int16)SVAL(buf,pos))
+#define IVALS(buf,pos) ((int32)IVAL(buf,pos))
+#define SSVAL(buf,pos,val) SSVALX((buf),(pos),((uint16)(val)))
+#define SIVAL(buf,pos,val) SIVALX((buf),(pos),((uint32)(val)))
+#define SSVALS(buf,pos,val) SSVALX((buf),(pos),((int16)(val)))
+#define SIVALS(buf,pos,val) SIVALX((buf),(pos),((int32)(val)))
+#else
+/* this handles things for architectures like the 386 that can handle
+ alignment errors */
+/*
+ WARNING: This section is dependent on the length of int16 and int32
+ being correct
+*/
+#define SVAL(buf,pos) (*(uint16 *)((char *)(buf) + (pos)))
+#define IVAL(buf,pos) (*(uint32 *)((char *)(buf) + (pos)))
+#define SVALS(buf,pos) (*(int16 *)((char *)(buf) + (pos)))
+#define IVALS(buf,pos) (*(int32 *)((char *)(buf) + (pos)))
+#define SSVAL(buf,pos,val) SVAL(buf,pos)=((uint16)(val))
+#define SIVAL(buf,pos,val) IVAL(buf,pos)=((uint32)(val))
+#define SSVALS(buf,pos,val) SVALS(buf,pos)=((int16)(val))
+#define SIVALS(buf,pos,val) IVALS(buf,pos)=((int32)(val))
+#endif
+
+
+/* now the reverse routines - these are used in nmb packets (mostly) */
+#define SREV(x) ((((x)&0xFF)<<8) | (((x)>>8)&0xFF))
+#define IREV(x) ((SREV(x)<<16) | (SREV((x)>>16)))
+
+#define RSVAL(buf,pos) SREV(SVAL(buf,pos))
+#define RIVAL(buf,pos) IREV(IVAL(buf,pos))
+#define RSSVAL(buf,pos,val) SSVAL(buf,pos,SREV(val))
+#define RSIVAL(buf,pos,val) SIVAL(buf,pos,IREV(val))
diff --git a/source3/include/charset.h b/source3/include/charset.h
new file mode 100644
index 0000000000..7091732223
--- /dev/null
+++ b/source3/include/charset.h
@@ -0,0 +1,61 @@
+/*
+ Unix SMB/Netbios implementation.
+ Version 1.9.
+ Character set handling
+ Copyright (C) Andrew Tridgell 1992-1995
+
+ 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
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ 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.
+*/
+
+#ifndef CHARSET_C
+
+extern char *dos_char_map;
+extern char *upper_char_map;
+extern char *lower_char_map;
+extern void add_char_string(char *s);
+extern void charset_initialise(void);
+
+#ifdef toupper
+#undef toupper
+#endif
+
+#ifdef tolower
+#undef tolower
+#endif
+
+#ifdef isupper
+#undef isupper
+#endif
+
+#ifdef islower
+#undef islower
+#endif
+
+#ifdef isdoschar
+#undef isdoschar
+#endif
+
+#ifdef isspace
+#undef isspace
+#endif
+
+#define toupper(c) upper_char_map[(char)(c)]
+#define tolower(c) lower_char_map[(char)(c)]
+#define isupper(c) (((char)(c)) != tolower(c))
+#define islower(c) (((char)(c)) != toupper(c))
+#define isdoschar(c) (dos_char_map[(char)(c)] != 0)
+#define isspace(c) ((c)==' ' || (c) == '\t')
+#endif
+
diff --git a/source3/include/clitar.h b/source3/include/clitar.h
new file mode 100644
index 0000000000..2305fceeec
--- /dev/null
+++ b/source3/include/clitar.h
@@ -0,0 +1,17 @@
+
+#define TBLOCK 512
+#define NAMSIZ 100
+union hblock {
+ char dummy[TBLOCK];
+ struct header {
+ char name[NAMSIZ];
+ char mode[8];
+ char uid[8];
+ char gid[8];
+ char size[12];
+ char mtime[12];
+ char chksum[8];
+ char linkflag;
+ char linkname[NAMSIZ];
+ } dbuf;
+};
diff --git a/source3/include/includes.h b/source3/include/includes.h
new file mode 100644
index 0000000000..cc2bbbfad7
--- /dev/null
+++ b/source3/include/includes.h
@@ -0,0 +1,1154 @@
+#ifndef _INCLUDES_H
+#define _INCLUDES_H
+/*
+ Unix SMB/Netbios implementation.
+ Version 1.9.
+ Machine customisation and include handling
+ Copyright (C) Andrew Tridgell 1994-1995
+
+ 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
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ 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.
+*/
+/*
+ This file does all the #includes's. This makes it easier to
+ port to a new unix. Hopefully a port will only have to edit the Makefile
+ and add a section for the new unix below.
+*/
+
+
+/* the first OS dependent section is to setup what includes will be used.
+ the main OS dependent section comes later on
+*/
+
+#ifdef ALTOS
+#define NO_UTIMEH
+#endif
+
+#ifdef MIPS
+#define POSIX_H
+#define NO_UTIMEH
+#endif
+
+#ifdef sun386
+#define NO_UTIMEH
+#endif
+
+#ifdef NEXT2
+#define NO_UTIMEH
+#endif
+
+#ifdef NEXT3_0
+#define NO_UTIMEH
+#define NO_UNISTDH
+#endif
+
+#ifdef APOLLO
+#define NO_UTIMEH
+#define NO_SYSMOUNTH
+#define NO_UNISTDH
+#endif
+
+#ifdef AIX
+#define NO_SYSMOUNTH
+#endif
+
+#ifdef M88K_R3
+#define SVR3H
+#define NO_RESOURCEH
+#endif
+
+#ifdef DNIX
+#define NO_SYSMOUNTH
+#define NO_NETIFH
+#define NO_RESOURCEH
+#define PRIME_NMBD 0
+#define NO_SETGROUPS
+#endif
+
+
+#ifdef ISC
+#define SYSSTREAMH
+#define NO_RESOURCEH
+#endif
+
+#ifdef QNX
+#define NO_RESOURCEH
+#define NO_SYSMOUNTH
+#define USE_MMAP 1
+#ifdef __386__
+ #define __i386__
+#endif
+#endif
+
+#ifdef NEWS42
+#define NO_UTIMEH
+#define NO_STRFTIME
+#define NO_UTIMBUF
+#define REPLACE_MKTIME
+#define NO_TM_NAME
+#endif
+
+#ifdef OS2
+#define NO_SYSMOUNTH
+#define NO_NETIFH
+#endif
+
+#ifdef LYNX
+#define NO_SYSMOUNTH
+#endif
+
+
+#if (defined(SHADOW_PWD)||defined(OSF1_ENH_SEC)||defined(SecureWare)||defined(PWDAUTH))
+#define PASSWORD_LENGTH 16
+#endif
+
+/* here is the general includes section - with some ifdefs generated
+ by the previous section
+*/
+#include "local.h"
+#include <stdio.h>
+#ifdef POSIX_STDLIBH
+#include <posix/stdlib.h>
+#else
+#include <stdlib.h>
+#endif
+#include <ctype.h>
+#include <time.h>
+#ifndef NO_UTIMEH
+#include <utime.h>
+#endif
+#include <sys/types.h>
+
+#ifdef SVR3H
+#include <sys/statfs.h>
+#include <sys/stream.h>
+#include <netinet/types.h>
+#include <netinet/ether.h>
+#include <netinet/ip_if.h>
+#endif
+
+#include <sys/socket.h>
+#include <sys/ioctl.h>
+#include <stddef.h>
+#ifdef POSIX_H
+#include <posix/utime.h>
+#include <bsd/sys/time.h>
+#include <bsd/netinet/in.h>
+#else
+#include <sys/time.h>
+#include <netinet/in.h>
+#endif
+#include <netdb.h>
+#include <signal.h>
+#include <errno.h>
+#include <sys/file.h>
+#include <sys/stat.h>
+#include <sys/param.h>
+#include <grp.h>
+#ifndef NO_RESOURCEH
+#include <sys/resource.h>
+#endif
+#ifndef NO_SYSMOUNTH
+#include <sys/mount.h>
+#endif
+#include <pwd.h>
+#ifdef __STDC__
+#include <stdarg.h>
+#else
+#include <varargs.h>
+#endif
+#ifndef NO_UNISTDH
+#include <unistd.h>
+#endif
+#include <sys/wait.h>
+#ifdef SYSSTREAMH
+#include <sys/stream.h>
+#endif
+#ifndef NO_NETIFH
+#ifdef POSIX_H
+#include <bsd/net/if.h>
+#else
+#include <net/if.h>
+#endif
+#endif
+
+#if USE_MMAP
+#include <sys/mman.h>
+#endif
+
+#if defined(GETPWANAM)
+#include <sys/types.h>
+#include <sys/label.h>
+#include <sys/audit.h>
+#include <pwdadj.h>
+#endif
+
+#if defined(SHADOW_PWD) && !defined(NETBSD) && !defined(CONVEX)
+#include <shadow.h>
+#endif
+
+/* this might be different on different systems */
+#ifdef QUOTAS
+#ifdef LINUX
+#ifdef __KERNEL__
+#undef __KERNEL__
+#include <sys/quota.h>
+#define __KERNEL__
+#else
+#include <sys/quota.h>
+#endif
+#include <mntent.h>
+#else
+#include <sys/quota.h>
+#ifndef CRAY
+#include <devnm.h>
+#else
+#include <mntent.h>
+#endif
+#endif
+#endif
+
+#ifdef SYSLOG
+#include <syslog.h>
+#endif
+
+
+
+/***************************************************************************
+Here come some platform specific sections
+***************************************************************************/
+
+
+#ifdef LINUX
+#include <arpa/inet.h>
+#include <dirent.h>
+#include <string.h>
+#include <sys/vfs.h>
+#include <netinet/in.h>
+#ifndef NO_ASMSIGNALH
+#include <asm/signal.h>
+#endif
+#define SIGNAL_CAST (__sighandler_t)
+#define USE_GETCWD
+#define USE_SETSID
+#define HAVE_BZERO
+#define HAVE_MEMMOVE
+#ifdef SHADOW_PWD
+#ifndef crypt
+#define crypt pw_encrypt
+#endif
+#endif
+#endif
+
+#ifdef SUNOS4
+#define SIGNAL_CAST (void (*)(int))
+#include <netinet/tcp.h>
+#include <dirent.h>
+#include <sys/acct.h>
+#include <sys/vfs.h>
+#include <string.h>
+#include <errno.h>
+#include <sys/wait.h>
+#include <signal.h>
+/* #include <termios.h> */
+#ifdef sun386
+#define NO_STRFTIME
+#define NO_UTIMBUF
+#define mktime timelocal
+typedef unsigned short mode_t;
+#else
+#include <utime.h>
+#define NO_STRERROR
+#endif
+#define REPLACE_GETPASS
+#define BSD_TERMIO
+#endif
+
+
+#ifdef SUNOS5
+#include <fcntl.h>
+#include <dirent.h>
+#include <sys/acct.h>
+#include <sys/statfs.h>
+#include <sys/statvfs.h>
+#include <sys/filio.h>
+#include <sys/sockio.h>
+#include <netinet/in_systm.h>
+#include <netinet/tcp.h>
+#include <netinet/ip.h>
+#include <string.h>
+#include <arpa/inet.h>
+#include <rpcsvc/ypclnt.h>
+#include <crypt.h>
+#include <termios.h>
+extern int gettimeofday (struct timeval *, void *);
+extern int gethostname (char *name, int namelen);
+extern int innetgr (const char *, const char *, const char *, const char *);
+#define USE_SETVBUF
+#define SIGNAL_CAST (void (*)(int))
+#ifndef SYSV
+#define SYSV
+#endif
+#define USE_WAITPID
+#define REPLACE_STRLEN
+#define USE_STATVFS
+#define USE_GETCWD
+#define USE_SETSID
+#define REPLACE_GETPASS
+#endif
+
+
+#ifdef ULTRIX
+#include <strings.h>
+#include <nfs/nfs_clnt.h>
+#include <nfs/vfs.h>
+#include <netinet/tcp.h>
+#ifdef ULTRIX_AUTH
+#include <auth.h>
+#endif
+char *getwd(char *);
+#define NOSTRDUP
+#ifdef __STDC__
+#define SIGNAL_CAST (void(*)(int))
+#endif
+#define USE_DIRECT
+#endif
+
+#ifdef SGI
+#include <netinet/tcp.h>
+#include <sys/statfs.h>
+#include <string.h>
+#include <signal.h>
+#ifndef SYSV
+#define SYSV
+#endif
+#define SIGNAL_CAST (void (*)())
+#define STATFS4
+#define USE_WAITPID
+#define USE_DIRECT
+#endif
+
+#ifdef SGI5
+#include <netinet/tcp.h>
+#include <sys/statvfs.h>
+#include <string.h>
+#include <signal.h>
+#include <dirent.h>
+#define USE_WAITPID
+#define NETGROUP
+#ifndef SYSV
+#define SYSV
+#endif
+#define SIGNAL_CAST (void (*)())
+#define USE_STATVFS
+#define USE_WAITPID
+#endif
+
+
+#ifdef MIPS
+#include <bsd/net/soioctl.h>
+#include <string.h>
+#include <dirent.h>
+#include <fcntl.h>
+#include <sys/statfs.h>
+#include <sys/wait.h>
+#include <sys/termio.h>
+#define SIGNAL_CAST (void (*)())
+typedef int mode_t;
+extern struct group *getgrnam();
+extern struct passwd *getpwnam();
+#define STATFS4
+#define NO_STRERROR
+#define REPLACE_STRSTR
+#endif /* MIPS */
+
+
+
+#ifdef DGUX
+#include <string.h>
+#include <dirent.h>
+#include <sys/statfs.h>
+#include <sys/statvfs.h>
+#include <fcntl.h>
+#include <termios.h>
+#define SYSV
+#define USE_WAITPID
+#define SIGNAL_CAST (void (*)(int))
+#define STATFS4
+#define USE_GETCWD
+#endif
+
+
+#ifdef SVR4
+#include <string.h>
+#include <sys/dir.h>
+#include <dirent.h>
+#include <sys/statfs.h>
+#include <sys/statvfs.h>
+#include <sys/vfs.h>
+#include <sys/filio.h>
+#include <fcntl.h>
+#include <sys/sockio.h>
+#include <netinet/tcp.h>
+#include <stropts.h>
+#include <termios.h>
+#define SYSV
+#define USE_WAITPID
+#define SIGNAL_CAST (void (*)(int))
+#define USE_STATVFS
+#define USE_GETCWD
+#define USE_SETSID
+#endif
+
+
+#ifdef OSF1
+#include <termios.h>
+#include <strings.h>
+#include <dirent.h>
+char *getwd(char *);
+char *mktemp(char *); /* No standard include */
+#include <netinet/in.h>
+#include <arpa/inet.h> /* both for inet_ntoa */
+#define SIGNAL_CAST ( void (*) (int) )
+#define STATFS3
+#define USE_F_FSIZE
+#include <netinet/tcp.h>
+#ifdef OSF1_ENH_SEC
+#include <pwd.h>
+#include <sys/types.h>
+#include <sys/security.h>
+#include <prot.h>
+#include <unistd.h>
+#define PASSWORD_LENGTH 16
+#define NEED_AUTH_PARAMETERS
+#endif /* OSF1_ENH_SEC */
+#endif
+
+
+#ifdef CLIX
+#include <dirent.h>
+#define SIGNAL_CAST (void (*)())
+#include <sys/fcntl.h>
+#include <sys/statfs.h>
+#include <string.h>
+#define NO_EID
+#define USE_WAITPID
+#define STATFS4
+#define NO_FSYNC
+#define USE_GETCWD
+#define USE_SETSID
+#define REPLACE_GETPASS
+#define NO_GETRLIMIT
+#endif /* CLIX */
+
+
+
+#ifdef BSDI
+#include <string.h>
+#include <netinet/tcp.h>
+#define SIGNAL_CAST (void (*)())
+#define USE_DIRECT
+#endif
+
+
+#ifdef NETBSD
+#include <strings.h>
+#include <netinet/tcp.h>
+/* you may not need this */
+#define NO_GETSPNAM
+#define SIGNAL_CAST (void (*)())
+#define USE_DIRECT
+#define REPLACE_INNETGR
+#endif
+
+
+
+#ifdef FreeBSD
+#include <strings.h>
+#include <netinet/tcp.h>
+#include <netinet/in_systm.h>
+#include <netinet/ip.h>
+#define SIGNAL_CAST (void (*)())
+#define USE_DIRECT
+#define REPLACE_INNETGR
+#endif
+
+
+
+#ifdef AIX
+#include <strings.h>
+#include <sys/dir.h>
+#include <sys/select.h>
+#include <dirent.h>
+#include <sys/statfs.h>
+#include <sys/vfs.h>
+#include <sys/id.h>
+#include <sys/priv.h>
+#include <netinet/tcp.h>
+#define SYSV
+#define USE_WAITPID
+#define SIGNAL_CAST (void (*)())
+#define DEFAULT_PRINTING PRINT_AIX
+#endif
+
+
+#ifdef HPUX
+#include <string.h>
+#include <dirent.h>
+#include <fcntl.h>
+#include <sys/vfs.h>
+#include <sys/types.h>
+#include <sys/termios.h>
+#include <netinet/tcp.h>
+#ifdef HPUX_10_TRUSTED
+#include <hpsecurity.h>
+#include <prot.h>
+#define NEED_AUTH_PARAMETERS
+#endif
+#define SIGNAL_CAST (void (*)(__harg))
+#define SELECT_CAST (int *)
+#define SYSV
+#define USE_WAITPID
+#define WAIT3_CAST2 (int *)
+#define USE_GETCWD
+#define USE_SETSID
+#define USE_SETRES
+#define DEFAULT_PRINTING PRINT_HPUX
+#define SIGCLD_IGNORE
+#endif
+
+
+#ifdef SEQUENT
+#include <signal.h>
+#include <string.h>
+#include <dirent.h>
+#include <sys/types.h>
+#include <sys/statfs.h>
+#include <sys/stat.h>
+#include <sys/buf.h>
+#include <sys/socket.h>
+#include <unistd.h>
+#include <fcntl.h>
+#define SIGNAL_CAST (void (*)(int))
+#define USE_WAITPID
+#define USE_GETCWD
+#define NO_EID
+#define STATFS4
+#define USE_DIRECT
+#endif
+
+#ifdef NEXT2
+#include <sys/types.h>
+#include <strings.h>
+#include <dirent.h>
+#include <sys/vfs.h>
+#define bzero(b,len) memset(b,0,len)
+#define mode_t int
+#define NO_UTIMBUF
+#include <libc.h>
+#define NOSTRDUP
+#define USE_DIRECT
+#define USE_WAITPID
+#endif
+
+
+#ifdef NEXT3_0
+#include <strings.h>
+#include <sys/dir.h>
+#include <sys/vfs.h>
+#define bzero(b,len) memset(b,0,len)
+#define NO_UTIMBUF
+#include <libc.h>
+#define NOSTRDUP
+#define USE_DIRECT
+#define mode_t int
+#define GID_TYPE int
+#define gid_t int
+#define SIGNAL_CAST (void (*)(int))
+#define WAIT3_CAST1 (union wait *)
+#define HAVE_GMTOFF
+#endif
+
+
+
+#ifdef APOLLO
+#include <string.h>
+#include <fcntl.h>
+#include <sys/statfs.h>
+#define NO_UTIMBUF
+#define USE_DIRECT
+#define USE_GETCWD
+#define SIGNAL_CAST (void (*)())
+#define HAVE_FCNTL_LOCK 0
+#define HAVE_GETTIMEOFDAY
+#define STATFS4
+#endif
+
+
+
+#ifdef SCO
+#include <sys/netinet/tcp.h>
+#include <sys/netinet/in_systm.h>
+#include <sys/netinet/ip.h>
+#include <dirent.h>
+#include <string.h>
+#include <fcntl.h>
+#include <sys/statfs.h>
+#include <sys/stropts.h>
+#include <limits.h>
+#ifdef EVEREST
+#include <unistd.h>
+#endif
+#ifdef NETGROUP
+#include <rpcsvc/ypclnt.h>
+#endif
+#ifdef SecureWare
+#include <sys/security.h>
+#include <sys/audit.h>
+#include <prot.h>
+#define crypt bigcrypt
+#endif
+#ifndef EVEREST
+ #define ftruncate(f,l) syscall(0x0a28,f,l)
+#endif
+#define SIGNAL_CAST (void (*)(int))
+#define USE_WAITPID
+#define USE_GETCWD
+#define USE_SETSID
+#ifdef SCO3_2_2
+#define NO_EID
+#else
+#ifndef EVEREST
+#define USE_IFREQ
+#endif
+#endif
+#define STATFS4
+#define NO_FSYNC
+#ifndef EVEREST
+#define NO_INITGROUPS
+#endif
+#define HAVE_PATHCONF
+#define NO_GETRLIMIT
+#endif
+
+
+
+/* Definitions for RiscIX */
+#ifdef RiscIX
+#define SIGNAL_CAST (void (*)(int))
+#include <sys/dirent.h>
+#include <sys/acct.h>
+#include <sys/vfs.h>
+#include <string.h>
+#include <utime.h>
+#include <signal.h>
+#define HAVE_GETTIMEOFDAY
+#define NOSTRCASECMP
+#define NOSTRDUP
+#endif
+
+
+
+#ifdef ISC
+#include <net/errno.h>
+#include <string.h>
+#include <sys/dir.h>
+#include <dirent.h>
+#include <sys/statfs.h>
+#include <fcntl.h>
+#include <sys/sioctl.h>
+#include <stropts.h>
+#include <limits.h>
+#include <netinet/tcp.h>
+#define FIONREAD FIORDCHK
+#define SYSV
+#define USE_WAITPID
+#define SIGNAL_CAST (void (*)(int))
+#define USE_GETCWD
+#define USE_SETSID
+#define USE_IFREQ
+#define NO_FTRUNCATE
+#define STATFS4
+#define NO_FSYNC
+#endif
+
+
+
+#ifdef AUX
+#include <fstab.h>
+#include <string.h>
+#include <dirent.h>
+#include <sys/vfs.h>
+#include <fcntl.h>
+#include <termios.h>
+#define SYSV
+#define USE_WAITPID
+#define SIGNAL_CAST (void (*)(int))
+char *strdup (char *);
+#define USE_GETCWD
+#endif
+
+
+#ifdef M88K_R3
+#include <string.h>
+#include <dirent.h>
+#include <fcntl.h>
+#include <termios.h>
+#define STATFS4
+#define SYSV
+#define USE_WAITPID
+#define SIGNAL_CAST (void (*)(int))
+char *strdup (char *);
+#define USE_GETCWD
+#define NO_FSYNC
+#define NO_EID
+#endif
+
+
+#ifdef DNIX
+#include <dirent.h>
+#include <string.h>
+#include <fcntl.h>
+#include <sys/statfs.h>
+#include <sys/stropts.h>
+#define NO_GET_BROADCAST
+#define USE_WAITPID
+#define USE_GETCWD
+#define USE_SETSID
+#define STATFS4
+#define NO_EID
+#define PF_INET AF_INET
+#define NO_STRERROR
+#define ftruncate(f,l) chsize(f,l)
+#endif /* DNIX */
+
+#ifdef CONVEX
+#define SIGNAL_CAST (void (*)(int))
+#include <netinet/tcp.h>
+#include <arpa/inet.h>
+#include <dirent.h>
+#include <string.h>
+#include <sys/vfs.h>
+#include <fcntl.h>
+#define DONT_REINSTALL_SIG
+#define USE_SIGBLOCK
+#define USE_WAITPID
+#define SIGNAL_CAST (_SigFunc_Ptr_t)
+#define NO_GETSPNAM
+#define HAVE_MEMMOVE
+extern char *mktemp(char *);
+extern int fsync(int);
+extern int seteuid(uid_t);
+extern int setgroups(int, int *);
+extern int initgroups(char *, int);
+extern int statfs(char *, struct statfs *);
+extern int setegid(gid_t);
+extern int getopt(int, char *const *, const char *);
+extern int chroot(char *);
+extern int gettimeofday(struct timeval *, struct timezone *);
+extern int gethostname(char *, int);
+extern char *crypt(char *, char *);
+extern char *getpass(char *);
+#endif
+
+
+#ifdef CRAY
+#define MAXPATHLEN 1024
+#include <dirent.h>
+#include <string.h>
+#include <fcntl.h>
+#include <sys/statfs.h>
+#define SIGNAL_CAST (void (*)(int))
+#define SIGCLD_IGNORE
+#define HAVE_FCNTL_LOCK 1
+#define USE_SETSID
+#define STATFS4
+#endif
+
+
+#ifdef ALTOS
+#include <unistd.h>
+#include <string.h>
+#include <dirent.h>
+#include <sys/fcntl.h>
+#include <sys/statfs.h>
+#define const
+#define uid_t int
+#define gid_t int
+#define mode_t int
+#define ptrdiff_t int
+#define HAVE_GETGRNAM 0
+#define NO_EID
+#define NO_FSYNC
+#define NO_FTRUNCATE
+#define NO_GETRLIMIT
+#define NO_INITGROUPS
+#define NO_SELECT
+#define NO_SETGROUPS
+#define NO_STRERROR
+#define NO_STRFTIME
+#define NO_TM_NAME
+#define NO_UTIMEH
+#define NOSTRCASECMP
+#define REPLACE_MKTIME
+#define REPLACE_RENAME
+#define REPLACE_STRSTR
+#define STATFS4
+#define USE_GETCWD
+#endif
+
+#ifdef QNX
+#define STATFS4
+#include <sys/statfs.h>
+#include <sys/select.h>
+#include <signal.h>
+#include <sys/dir.h>
+#define SIGNAL_CAST (void (*)())
+#define USE_WAITPID
+#define NO_INITGROUPS
+#define NO_SETGROUPS
+#define HAVE_TIMEZONE
+#define USE_GETCWD
+#define USE_SETSID
+#define HAVE_FCNTL_LOCK 1
+#define DEFAULT_PRINTING PRINT_QNX
+#endif
+
+
+#ifdef NEWS42
+#include <string.h>
+#include <dirent.h>
+#include <sys/vfs.h>
+#include <sys/timeb.h>
+typedef int mode_t;
+#endif
+
+#ifdef OS2
+#include <dirent.h>
+#include <sys/statfs.h>
+#include <string.h>
+#include <limits.h>
+#define SIGNAL_CAST (void (*)())
+#define HAVE_FCNTL_LOCK 0
+#define USE_WAITPID
+#define NO_GET_BROADCAST
+#define NO_EID
+#define NO_SETGROUPS
+#define NO_INITGROUPS
+#define NO_CRYPT
+#define NO_STATFS
+#define NO_CHROOT
+#define NO_CHOWN
+#define strcasecmp stricmp
+#define strncasecmp strnicmp
+#endif
+
+
+#ifdef LYNX
+#define SIGNAL_CAST (void (*)())
+#define WAIT3_CAST1 (union wait *)
+#define STATFS4
+#include <fcntl.h>
+#include <resource.h>
+#include <stat.h>
+#include <string.h>
+#include <dirent.h>
+#include <sys/statfs.h>
+#define USE_GETCWD
+#define USE_GETSID
+#endif
+
+
+/*******************************************************************
+end of the platform specific sections
+********************************************************************/
+
+#ifdef SecureWare
+#define NEED_AUTH_PARAMETERS
+#endif
+
+#ifdef REPLACE_GETPASS
+extern char *getsmbpass(char *);
+#define getpass(s) getsmbpass(s)
+#endif
+
+#ifdef REPLACE_INNETGR
+#define innetgr(group,host,user,dom) InNetGr(group,host,user,dom)
+#endif
+
+#ifndef FD_SETSIZE
+#define FD_SETSIZE 255
+#endif
+
+#ifndef MAXINT
+#define MAXINT ((((unsigned)1)<<(sizeof(int)*8-1))-1)
+#endif
+
+#ifndef __STDC__
+#define const
+#endif
+
+/* Now for some other grungy stuff */
+#ifdef NO_GETSPNAM
+struct spwd { /* fake shadow password structure */
+ char *sp_pwdp;
+};
+#endif
+
+#ifndef HAVE_BZERO
+#ifndef bzero
+#define bzero(p,s) memset(p,0,s)
+#endif
+#endif
+
+#ifndef HAVE_MEMMOVE
+#ifndef memmove
+#define memmove(d,s,n) MemMove(d,s,n)
+#endif
+#endif
+
+#ifdef USE_DIRECT
+#include <sys/dir.h>
+#endif
+
+/* some unixes have ENOTTY instead of TIOCNOTTY */
+#ifndef TIOCNOTTY
+#ifdef ENOTTY
+#define TIOCNOTTY ENOTTY
+#endif
+#endif
+
+#ifndef SIGHUP
+#define SIGHUP 1
+#endif
+
+/* if undefined then use bsd or sysv printing */
+#ifndef DEFAULT_PRINTING
+#ifdef SYSV
+#define DEFAULT_PRINTING PRINT_SYSV
+#else
+#define DEFAULT_PRINTING PRINT_BSD
+#endif
+#endif
+
+
+#ifdef AFS_AUTH
+#include <afs/stds.h>
+#include <afs/kautils.h>
+#endif
+
+#ifdef DFS_AUTH
+#include <dce/dce_error.h>
+#include <dce/sec_login.h>
+#endif
+
+#ifdef NO_UTIMBUF
+struct utimbuf {
+ time_t actime;
+ time_t modtime;
+};
+#endif
+
+#ifdef NO_STRERROR
+#ifndef strerror
+extern char *sys_errlist[];
+#define strerror(i) sys_errlist[i]
+#endif
+#endif
+
+#ifndef perror
+#define perror(m) printf("%s: %s\n",m,strerror(errno))
+#endif
+
+#ifndef MAXHOSTNAMELEN
+#define MAXHOSTNAMELEN 255
+#endif
+
+#include "version.h"
+#include "smb.h"
+#include "byteorder.h"
+#ifdef SMB_PASSWD
+#include "smbpass.h"
+#endif
+
+#include "kanji.h"
+#include "charset.h"
+
+#ifndef S_IFREG
+#define S_IFREG 0100000
+#endif
+
+#ifndef S_ISREG
+#define S_ISREG(x) ((S_IFREG & x)!=0)
+#endif
+
+#ifndef S_ISDIR
+#define S_ISDIR(x) ((S_IFDIR & x)!=0)
+#endif
+
+#ifdef UFC_CRYPT
+#define crypt ufc_crypt
+#endif
+
+#ifdef REPLACE_STRLEN
+#define strlen(s) Strlen(s)
+#endif
+
+#ifdef REPLACE_STRSTR
+#define strstr(s,p) Strstr(s,p)
+#endif
+
+#ifdef REPLACE_MKTIME
+#define mktime(t) Mktime(t)
+#endif
+
+#ifndef NGROUPS_MAX
+#define NGROUPS_MAX 128
+#endif
+
+#ifndef EDQUOT
+#define EDQUOT ENOSPC
+#endif
+
+#ifndef HAVE_GETGRNAM
+#define HAVE_GETGRNAM 1
+#endif
+
+#ifndef SOL_TCP
+#define SOL_TCP 6
+#endif
+
+/* default to using ftruncate workaround as this is safer than assuming
+it works and getting lots of bug reports */
+#ifndef FTRUNCATE_CAN_EXTEND
+#define FTRUNCATE_CAN_EXTEND 0
+#endif
+
+/* maybe this unix doesn't separate RD and WR locks? */
+#ifndef F_RDLCK
+#define F_RDLCK F_WRLCK
+#endif
+
+#ifndef ENOTSOCK
+#define ENOTSOCK EINVAL
+#endif
+
+#ifndef SIGCLD
+#define SIGCLD SIGCHLD
+#endif
+
+#ifndef HAVE_FCNTL_LOCK
+#define HAVE_FCNTL_LOCK 1
+#endif
+
+#ifndef WAIT3_CAST2
+#define WAIT3_CAST2 (struct rusage *)
+#endif
+
+#ifndef WAIT3_CAST1
+#define WAIT3_CAST1 (int *)
+#endif
+
+#ifndef QSORT_CAST
+#define QSORT_CAST (int (*)())
+#endif
+
+/* this is a rough check to see if this machine has a lstat() call.
+ it is not guaranteed to work */
+#if !(defined(S_ISLNK) || defined(S_IFLNK))
+#define lstat stat
+#endif
+
+/* Not all systems declare ERRNO in errno.h... and some systems #define it! */
+#ifndef errno
+extern int errno;
+#endif
+
+
+#ifdef NO_EID
+#define geteuid() getuid()
+#define getegid() getgid()
+#define seteuid(x) setuid(x)
+#define setegid(x) setgid(x)
+#endif
+
+
+#if (HAVE_FCNTL_LOCK == 0)
+/* since there is no locking available, system includes */
+/* for DomainOS 10.4 do not contain any of the following */
+/* #define's. So, to satisfy the compiler, add these */
+/* #define's, although they arn't really necessary. */
+#define F_GETLK 0
+#define F_SETLK 0
+#define F_WRLCK 0
+#define F_UNLCK 0
+#endif /* HAVE_FCNTL_LOCK == 0 */
+
+#ifdef NOSTRCASECMP
+#define strcasecmp(s1,s2) StrCaseCmp(s1,s2)
+#define strncasecmp(s1,s2,n) StrnCaseCmp(s1,s2,n)
+#endif
+
+#ifndef strcpy
+#define strcpy(dest,src) StrCpy(dest,src)
+#endif
+
+
+/* possibly wrap the malloc calls */
+#if WRAP_MALLOC
+
+/* undo the old malloc def if necessary */
+#ifdef malloc
+#define xx_old_malloc malloc
+#undef malloc
+#endif
+
+#define malloc(size) malloc_wrapped(size,__FILE__,__LINE__)
+
+/* undo the old realloc def if necessary */
+#ifdef realloc
+#define xx_old_realloc realloc
+#undef realloc
+#endif
+
+#define realloc(ptr,size) realloc_wrapped(ptr,size,__FILE__,__LINE__)
+
+/* undo the old free def if necessary */
+#ifdef free
+#define xx_old_free free
+#undef free
+#endif
+
+#define free(ptr) free_wrapped(ptr,__FILE__,__LINE__)
+
+/* and the malloc prototypes */
+void *malloc_wrapped(int,char *,int);
+void *realloc_wrapped(void *,int,char *,int);
+void free_wrapped(void *,char *,int);
+
+#endif
+
+
+#if WRAP_MEMCPY
+/* undo the old memcpy def if necessary */
+#ifdef memcpy
+#define xx_old_memcpy memcpy
+#undef memcpy
+#endif
+
+#define memcpy(d,s,l) memcpy_wrapped(d,s,l,__FILE__,__LINE__)
+void *memcpy_wrapped(void *d,void *s,int l,char *fname,int line);
+#endif
+
+#endif
diff --git a/source3/include/kanji.h b/source3/include/kanji.h
new file mode 100644
index 0000000000..4f18305c63
--- /dev/null
+++ b/source3/include/kanji.h
@@ -0,0 +1,130 @@
+/*
+ Unix SMB/Netbios implementation.
+ Version 1.9.
+ Kanji Extensions
+ Copyright (C) Andrew Tridgell 1992-1994
+
+ 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
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ 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.
+
+ Adding for Japanese language by <fujita@ainix.isac.co.jp> 1994.9.5
+ and extend coding system to EUC/SJIS/JIS/HEX at 1994.10.11
+ and add all jis codes sequence at 1995.8.16
+ Notes: Hexadecimal code by <ohki@gssm.otuka.tsukuba.ac.jp>
+*/
+#ifndef _KANJI_H_
+#define _KANJI_H_
+
+#ifdef KANJI
+
+/* FOR SHIFT JIS CODE */
+#define is_shift_jis(c) \
+ ((0x81 <= ((unsigned char) (c)) && ((unsigned char) (c)) <= 0x9f) \
+ || (0xe0 <= ((unsigned char) (c)) && ((unsigned char) (c)) <= 0xef))
+#define is_shift_jis2(c) \
+ (0x40 <= ((unsigned char) (c)) && ((unsigned char) (c)) <= 0xfc \
+ && ((unsigned char) (c)) != 0x7f)
+#define is_kana(c) ((0xa0 <= ((unsigned char) (c)) && ((unsigned char) (c)) <= 0xdf))
+
+#ifdef _KANJI_C_
+/* FOR EUC CODE */
+#define euc_kana (0x8e)
+#define is_euc_kana(c) (((unsigned char) (c)) == euc_kana)
+#define is_euc(c) (0xa0 < ((unsigned char) (c)) && ((unsigned char) (c)) < 0xff)
+
+/* FOR JIS CODE */
+/* default jis third shift code, use for output */
+#ifndef JIS_KSO
+#define JIS_KSO 'B'
+#endif
+#ifndef JIS_KSI
+#define JIS_KSI 'J'
+#endif
+/* in: \E$B or \E$@ */
+/* out: \E(J or \E(B or \E(H */
+#define jis_esc (0x1b)
+#define jis_so (0x0e)
+#define jis_so1 ('$')
+#define jis_so2 ('B')
+#define jis_si (0x0f)
+#define jis_si1 ('(')
+#define jis_si2 ('J')
+#define is_esc(c) (((unsigned char) (c)) == jis_esc)
+#define is_so1(c) (((unsigned char) (c)) == jis_so1)
+#define is_so2(c) (((unsigned char) (c)) == jis_so2 || ((unsigned char) (c)) == '@')
+#define is_si1(c) (((unsigned char) (c)) == jis_si1)
+#define is_si2(c) (((unsigned char) (c)) == jis_si2 || ((unsigned char) (c)) == 'B' \
+ || ((unsigned char) (c)) == 'H')
+#define is_so(c) (((unsigned char) (c)) == jis_so)
+#define is_si(c) (((unsigned char) (c)) == jis_si)
+#define junet_kana1 ('(')
+#define junet_kana2 ('I')
+#define is_juk1(c) (((unsigned char) (c)) == junet_kana1)
+#define is_juk2(c) (((unsigned char) (c)) == junet_kana2)
+
+#define _KJ_ROMAN (0)
+#define _KJ_KANJI (1)
+#define _KJ_KANA (2)
+
+/* FOR HEX */
+#define HEXTAG ':'
+#define hex2bin(x) \
+ ( ((int) '0' <= ((int) (x)) && ((int) (x)) <= (int)'9')? \
+ (((int) (x))-(int)'0'): \
+ ((int) 'a'<= ((int) (x)) && ((int) (x))<= (int) 'f')? \
+ (((int) (x)) - (int)'a'+10): \
+ (((int) (x)) - (int)'A'+10) )
+#define bin2hex(x) \
+ ( (((int) (x)) >= 10)? (((int) (x))-10 + (int) 'a'): (((int) (x)) + (int) '0') )
+
+#else /* not _KANJI_C_ */
+
+extern char* (*_dos_to_unix) (const char *str, BOOL overwrite);
+extern char* (*_unix_to_dos) (const char *str, BOOL overwrite);
+
+#define unix_to_dos (*_unix_to_dos)
+#define dos_to_unix (*_dos_to_unix)
+
+extern char *sj_strtok (char *s1, const char *s2);
+extern char *sj_strchr (const char *s, int c);
+extern char *sj_strrchr (const char *s, int c);
+extern char *sj_strstr (const char *s1, const char *s2);
+
+#define strchr sj_strchr
+#define strrchr sj_strrchr
+#define strstr sj_strstr
+#define strtok sj_strtok
+
+#endif /* _KANJI_C_ */
+
+#define UNKNOWN_CODE (-1)
+#define SJIS_CODE (0)
+#define EUC_CODE (1)
+#define JIS7_CODE (2)
+#define JIS8_CODE (3)
+#define JUNET_CODE (4)
+#define HEX_CODE (5)
+#define CAP_CODE (6)
+#define DOSV_CODE SJIS_CODE
+
+int interpret_coding_system (char *str, int def);
+
+#else
+
+#define unix_to_dos(x,y) (x)
+#define dos_to_unix(x,y) (x)
+
+#endif /* not KANJI */
+
+#endif /* _KANJI_H_ */
diff --git a/source3/include/local.h b/source3/include/local.h
new file mode 100644
index 0000000000..2775453e15
--- /dev/null
+++ b/source3/include/local.h
@@ -0,0 +1,167 @@
+/* local definitions for file server */
+#ifndef _LOCAL_H
+#define _LOCAL_H
+
+/* This defines the section name in the configuration file that will contain */
+/* global parameters - that is, parameters relating to the whole server, not */
+/* just services. This name is then reserved, and may not be used as a */
+/* a service name. It will default to "global" if not defined here. */
+#define GLOBAL_NAME "global"
+#define GLOBAL_NAME2 "globals"
+
+/* This defines the section name in the configuration file that will
+ refer to the special "homes" service */
+#define HOMES_NAME "homes"
+
+/* This defines the section name in the configuration file that will
+ refer to the special "printers" service */
+#define PRINTERS_NAME "printers"
+
+/* This defines the name of the printcap file. It is MOST UNLIKELY that
+ this will change BUT! Specifying a file with the format of a printcap
+ file but containing only a subset of the printers actually in your real
+ printcap file is a quick-n-dirty way to allow dynamic access to a subset
+ of available printers.
+*/
+#define PRINTCAP_NAME "/etc/printcap"
+
+/* set these to define the limits of the server. NOTE These are on a
+ per-client basis. Thus any one machine can't connect to more than
+ MAX_CONNECTIONS services, but any number of machines may connect at
+ one time. */
+#define MAX_CONNECTIONS 127
+#define MAX_OPEN_FILES 100
+
+/* the max number of connections that the smbstatus program will show */
+#define MAXSTATUS 1000
+
+/* max number of directories open at once */
+/* note that with the new directory code this no longer requires a
+ file handle per directory, but large numbers do use more memory */
+#define MAXDIR 64
+
+#define WORDMAX 0xFFFF
+
+
+/* separators for lists */
+#define LIST_SEP " \t,;:\n\r"
+
+#ifndef LOCKDIR
+#define LOCKDIR "/tmp/samba"
+#endif
+
+/* this is where browse lists are kept in the lock dir */
+#define SERVER_LIST "browse.dat"
+
+/* the print command on the server, %s is replaced with the filename */
+/* note that the -r removes the file after printing - you'll run out */
+/* of disk pretty quickly if you don't. This command is only used as */
+/* the default - it can be overridden in the configuration file. */
+#define PRINT_COMMAND "lpr -r %s"
+
+/* the lpq command on the server. the printername is passed as an argument */
+#ifndef LPQ_COMMAND
+#define LPQ_COMMAND "lpq -P"
+#endif
+
+/* shall guest entries in printer queues get changed to user entries,
+ so they can be deleted using the windows print manager? */
+#define LPQ_GUEST_TO_USER
+
+/* shall filenames with illegal chars in them get mangled in long
+ filename listings? */
+#define MANGLE_LONG_FILENAMES
+
+/* define this if you want to stop spoofing with .. and soft links
+ NOTE: This also slows down the server considerably */
+#define REDUCE_PATHS
+
+/* the size of the directory cache */
+#define DIRCACHESIZE 20
+
+/* what type of filesystem do we want this to show up as in a NT file
+ manager window? */
+#define FSTYPE_STRING "Samba"
+
+/* we have two time standards - local and GMT. This will try to sort them out.
+ */
+
+#define LOCAL_TO_GMT 1
+#define GMT_TO_LOCAL (-1)
+
+/* do you want smbd to send a 1 byte packet to nmbd to trigger it to start
+ when smbd starts? */
+#ifndef PRIME_NMBD
+#define PRIME_NMBD 1
+#endif
+
+/* do you want session setups at user level security with a invalid
+ password to be rejected or allowed in as guest? WinNT rejects them
+ but it can be a pain as it means "net view" needs to use a password
+
+ You have 3 choices:
+
+ GUEST_SESSSETUP = 0 means session setups with an invalid password
+ are rejected.
+
+ GUEST_SESSSETUP = 1 means session setups with an invalid password
+ are rejected, unless the username does not exist, in which case it
+ is treated as a guest login
+
+ GUEST_SESSSETUP = 2 means session setups with an invalid password
+ are treated as a guest login
+
+ Note that GUEST_SESSSETUP only has an effect in user or server
+ level security.
+ */
+#ifndef GUEST_SESSSETUP
+#define GUEST_SESSSETUP 0
+#endif
+
+/* the default pager to use for the client "more" command. Users can
+ override this with the PAGER environment variable */
+#ifndef PAGER
+#define PAGER "more"
+#endif
+
+/* the size of the uid cache used to reduce valid user checks */
+#define UID_CACHE_SIZE 4
+
+/* the following control timings of various actions. Don't change
+ them unless you know what you are doing. These are all in seconds */
+#define DEFAULT_SMBD_TIMEOUT (60*60*24*7)
+#define SMBD_RELOAD_CHECK (10)
+#define SHARE_MODES_CHECK (10)
+#define SHARE_MODES_CLEAN (300)
+#define IDLE_CLOSED_TIMEOUT (60)
+#define DPTR_IDLE_TIMEOUT (120)
+#define SMBD_SELECT_LOOP (10)
+#define NMBD_SELECT_LOOP (10)
+#define BROWSE_INTERVAL (60)
+#define REGISTRATION_INTERVAL (10*60)
+#define NMBD_INETD_TIMEOUT (120)
+#define NMBD_MAX_TTL (24*60*60)
+#define LPQ_LOCK_TIMEOUT (5)
+
+/* the following are in milliseconds */
+#define LOCK_RETRY_TIMEOUT (100)
+
+/* do you want to dump core (carefully!) when an internal error is
+ encountered? Samba will be careful to make the core file only
+ accessible to root */
+#define DUMP_CORE 1
+
+/* what is the longest significant password available on your system?
+ Knowing this speeds up password searches a lot */
+#ifndef PASSWORD_LENGTH
+#define PASSWORD_LENGTH 8
+#endif
+
+#define SMB_ALIGNMENT 1
+
+
+/* shall we support browse requests via a FIFO to nmbd? */
+#define ENABLE_FIFO 1
+
+
+#endif
diff --git a/source3/include/nameserv.h b/source3/include/nameserv.h
new file mode 100644
index 0000000000..168dd4ba86
--- /dev/null
+++ b/source3/include/nameserv.h
@@ -0,0 +1,184 @@
+/*
+ Unix SMB/Netbios implementation.
+ Version 1.9.
+ NBT netbios header - version 2
+ Copyright (C) Andrew Tridgell 1994-1995
+
+ 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
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ 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.
+
+*/
+
+#define MAX_DGRAM_SIZE 576
+#define MIN_DGRAM_SIZE 12
+
+#define NMB_PORT 137
+#define DGRAM_PORT 138
+#define SMB_PORT 139
+
+enum name_source {LMHOSTS, REGISTER, SELF, DNS, DNSFAIL};
+enum node_type {B_NODE=0, P_NODE=1, M_NODE=2, NBDD_NODE=3};
+enum packet_type {NMB_PACKET, DGRAM_PACKET};
+
+/* a netbios name structure */
+struct nmb_name {
+ char name[17];
+ char scope[64];
+ int name_type;
+};
+
+/* this is the structure used for the local netbios name list */
+struct name_record
+{
+ struct name_record *next;
+ struct name_record *prev;
+ struct nmb_name name;
+ time_t death_time;
+ struct in_addr ip;
+ BOOL unique;
+ enum name_source source;
+};
+
+/* this is used by the list of domains */
+struct domain_record
+{
+ struct domain_record *next;
+ struct domain_record *prev;
+ fstring name;
+ time_t lastannounce_time;
+ int announce_interval;
+ struct in_addr bcast_ip;
+};
+
+/* this is used to hold the list of servers in my domain */
+struct server_record
+{
+ struct server_record *next;
+ struct server_record *prev;
+ fstring name;
+ fstring comment;
+ uint32 servertype;
+ time_t death_time;
+};
+
+/* a resource record */
+struct res_rec {
+ struct nmb_name rr_name;
+ int rr_type;
+ int rr_class;
+ int ttl;
+ int rdlength;
+ char rdata[MAX_DGRAM_SIZE];
+};
+
+/* define a nmb packet. */
+struct nmb_packet
+{
+ struct {
+ int name_trn_id;
+ int opcode;
+ BOOL response;
+ struct {
+ BOOL bcast;
+ BOOL recursion_available;
+ BOOL recursion_desired;
+ BOOL trunc;
+ BOOL authoritative;
+ } nm_flags;
+ int rcode;
+ int qdcount;
+ int ancount;
+ int nscount;
+ int arcount;
+ } header;
+
+ struct {
+ struct nmb_name question_name;
+ int question_type;
+ int question_class;
+ } question;
+
+ struct res_rec *answers;
+ struct res_rec *nsrecs;
+ struct res_rec *additional;
+};
+
+
+/* a datagram - this normally contains SMB data in the data[] array */
+struct dgram_packet {
+ struct {
+ int msg_type;
+ struct {
+ enum node_type node_type;
+ BOOL first;
+ BOOL more;
+ } flags;
+ int dgm_id;
+ struct in_addr source_ip;
+ int source_port;
+ int dgm_length;
+ int packet_offset;
+ } header;
+ struct nmb_name source_name;
+ struct nmb_name dest_name;
+ int datasize;
+ char data[MAX_DGRAM_SIZE];
+};
+
+/* define a structure used to queue packets. this will be a linked
+ list of nmb packets */
+struct packet_struct
+{
+ struct packet_struct *next;
+ struct packet_struct *prev;
+ struct in_addr ip;
+ int port;
+ int fd;
+ time_t timestamp;
+ enum packet_type packet_type;
+ union {
+ struct nmb_packet nmb;
+ struct dgram_packet dgram;
+ } packet;
+};
+
+
+/* this defines a list of network interfaces */
+struct net_interface {
+ struct net_interface *next;
+ struct in_addr ip;
+ struct in_addr bcast;
+ struct in_addr netmask;
+};
+
+
+/* prototypes */
+void free_nmb_packet(struct nmb_packet *nmb);
+void free_packet(struct packet_struct *packet);
+struct packet_struct *read_packet(int fd,enum packet_type packet_type);
+BOOL send_packet(struct packet_struct *p);
+struct packet_struct *receive_packet(int fd,enum packet_type type,int timeout);
+void make_nmb_name(struct nmb_name *n,char *name,int type,char *this_scope);
+BOOL name_query(int fd,char *name,int name_type,
+ BOOL bcast,BOOL recurse,
+ struct in_addr to_ip, struct in_addr *ip,void (*fn)());
+BOOL name_status(int fd,char *name,int name_type,BOOL recurse,
+ struct in_addr to_ip,char *master,char *rname,
+ void (*fn)());
+BOOL send_mailslot_reply(char *mailslot,int fd,char *buf,int len,
+ char *srcname,char *dstname,
+ int src_type,int dest_type,
+ struct in_addr dest_ip,
+ struct in_addr src_ip);
+char *namestr(struct nmb_name *n);
diff --git a/source3/include/smb.h b/source3/include/smb.h
new file mode 100644
index 0000000000..b7faffa9e9
--- /dev/null
+++ b/source3/include/smb.h
@@ -0,0 +1,1006 @@
+/*
+ Unix SMB/Netbios implementation.
+ Version 1.9.
+ SMB parameters and setup
+ Copyright (C) Andrew Tridgell 1992-1995
+
+ 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
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ 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.
+*/
+#ifndef _SMB_H
+#define _SMB_H
+
+#ifndef MAX_CONNECTIONS
+#define MAX_CONNECTIONS 127
+#endif
+
+#ifndef MAX_OPEN_FILES
+#define MAX_OPEN_FILES 50
+#endif
+
+#ifndef GUEST_ACCOUNT
+#define GUEST_ACCOUNT "nobody"
+#endif
+
+#define BUFFER_SIZE (0xFFFF)
+#define SAFETY_MARGIN 1024
+
+#ifndef EXTERN
+# define EXTERN extern
+#endif
+
+#define False (0)
+#define True (1)
+#define BOOLSTR(b) ((b) ? "Yes" : "No")
+#define BITSETB(ptr,bit) ((((char *)ptr)[0] & (1<<(bit)))!=0)
+#define BITSETW(ptr,bit) ((SVAL(ptr,0) & (1<<(bit)))!=0)
+#define PTR_DIFF(p1,p2) ((ptrdiff_t)(((char *)(p1)) - (char *)(p2)))
+
+typedef int BOOL;
+
+/*
+ Samba needs type definitions for int16, int32, uint16 and uint32.
+
+ Normally these are signed and unsigned 16 and 32 bit integers, but
+ they actually only need to be at least 16 and 32 bits
+ respectively. Thus if your word size is 8 bytes just defining them
+ as signed and unsigned int will work.
+*/
+
+/* afs/stds.h defines int16 and int32 */
+#ifndef AFS_AUTH
+typedef short int16;
+typedef int int32;
+#endif
+
+#ifndef uint16
+typedef unsigned short uint16;
+#endif
+
+#ifndef uint32
+typedef unsigned int uint32;
+#endif
+
+#define SIZEOFWORD 2
+
+#ifndef DEF_CREATE_MASK
+#define DEF_CREATE_MASK (0755)
+#endif
+
+#ifndef DEFAULT_PIPE_TIMEOUT
+#define DEFAULT_PIPE_TIMEOUT 10000000 /* Ten seconds */
+#endif
+
+/* debugging code */
+#ifndef SYSLOG
+#define DEBUG(level,body) ((DEBUGLEVEL>=(level))?(Debug1 body):0)
+#else
+EXTERN int syslog_level;
+
+#define DEBUG(level,body) ((DEBUGLEVEL>=(level))? \
+ (syslog_level = (level), Debug1 body):0)
+#endif
+
+#define DIR_STRUCT_SIZE 43
+
+/* these define all the command types recognised by the server - there
+are lots of gaps so probably there are some rare commands that are not
+implemented */
+
+#define pSETDIR '\377'
+
+/* these define the attribute byte as seen by DOS */
+#define aRONLY (1L<<0)
+#define aHIDDEN (1L<<1)
+#define aSYSTEM (1L<<2)
+#define aVOLID (1L<<3)
+#define aDIR (1L<<4)
+#define aARCH (1L<<5)
+
+/* deny modes */
+#define DENY_DOS 0
+#define DENY_ALL 1
+#define DENY_WRITE 2
+#define DENY_READ 3
+#define DENY_NONE 4
+#define DENY_FCB 7
+
+/* share types */
+#define STYPE_DISKTREE 0 /* Disk drive */
+#define STYPE_PRINTQ 1 /* Spooler queue */
+#define STYPE_DEVICE 2 /* Serial device */
+#define STYPE_IPC 3 /* Interprocess communication (IPC) */
+
+/* SMB X/Open error codes for the ERRdos error class */
+#define ERRbadfunc 1 /* Invalid function (or system call) */
+#define ERRbadfile 2 /* File not found (pathname error) */
+#define ERRbadpath 3 /* Directory not found */
+#define ERRnofids 4 /* Too many open files */
+#define ERRnoaccess 5 /* Access denied */
+#define ERRbadfid 6 /* Invalid fid */
+#define ERRnomem 8 /* Out of memory */
+#define ERRbadmem 9 /* Invalid memory block address */
+#define ERRbadenv 10 /* Invalid environment */
+#define ERRbadaccess 12 /* Invalid open mode */
+#define ERRbaddata 13 /* Invalid data (only from ioctl call) */
+#define ERRres 14 /* reserved */
+#define ERRbaddrive 15 /* Invalid drive */
+#define ERRremcd 16 /* Attempt to delete current directory */
+#define ERRdiffdevice 17 /* rename/move across different filesystems */
+#define ERRnofiles 18 /* no more files found in file search */
+#define ERRbadshare 32 /* Share mode on file conflict with open mode */
+#define ERRlock 33 /* Lock request conflicts with existing lock */
+#define ERRfilexists 80 /* File in operation already exists */
+#define ERRbadpipe 230 /* Named pipe invalid */
+#define ERRpipebusy 231 /* All instances of pipe are busy */
+#define ERRpipeclosing 232 /* named pipe close in progress */
+#define ERRnotconnected 233 /* No process on other end of named pipe */
+#define ERRmoredata 234 /* More data to be returned */
+#define ERROR_EAS_DIDNT_FIT 275 /* Extended attributes didn't fit */
+#define ERROR_EAS_NOT_SUPPORTED 282 /* Extended attributes not suppored */
+#define ERRunknownlevel 124
+#define ERRunknownipc 2142
+
+
+/* here's a special one from observing NT */
+#define ERRnoipc 66 /* don't support ipc */
+
+/* Error codes for the ERRSRV class */
+
+#define ERRerror 1 /* Non specific error code */
+#define ERRbadpw 2 /* Bad password */
+#define ERRbadtype 3 /* reserved */
+#define ERRaccess 4 /* No permissions to do the requested operation */
+#define ERRinvnid 5 /* tid invalid */
+#define ERRinvnetname 6 /* Invalid servername */
+#define ERRinvdevice 7 /* Invalid device */
+#define ERRqfull 49 /* Print queue full */
+#define ERRqtoobig 50 /* Queued item too big */
+#define ERRinvpfid 52 /* Invalid print file in smb_fid */
+#define ERRsmbcmd 64 /* Unrecognised command */
+#define ERRsrverror 65 /* smb server internal error */
+#define ERRfilespecs 67 /* fid and pathname invalid combination */
+#define ERRbadlink 68 /* reserved */
+#define ERRbadpermits 69 /* Access specified for a file is not valid */
+#define ERRbadpid 70 /* reserved */
+#define ERRsetattrmode 71 /* attribute mode invalid */
+#define ERRpaused 81 /* Message server paused */
+#define ERRmsgoff 82 /* Not receiving messages */
+#define ERRnoroom 83 /* No room for message */
+#define ERRrmuns 87 /* too many remote usernames */
+#define ERRtimeout 88 /* operation timed out */
+#define ERRnoresource 89 /* No resources currently available for request. */
+#define ERRtoomanyuids 90 /* too many userids */
+#define ERRbaduid 91 /* bad userid */
+#define ERRuseMPX 250 /* temporarily unable to use raw mode, use MPX mode */
+#define ERRuseSTD 251 /* temporarily unable to use raw mode, use standard mode */
+#define ERRcontMPX 252 /* resume MPX mode */
+#define ERRbadPW /* reserved */
+#define ERRnosupport 0xFFFF
+#define ERRunknownsmb 22 /* from NT 3.5 response */
+
+
+/* Error codes for the ERRHRD class */
+
+#define ERRnowrite 19 /* read only media */
+#define ERRbadunit 20 /* Unknown device */
+#define ERRnotready 21 /* Drive not ready */
+#define ERRbadcmd 22 /* Unknown command */
+#define ERRdata 23 /* Data (CRC) error */
+#define ERRbadreq 24 /* Bad request structure length */
+#define ERRseek 25
+#define ERRbadmedia 26
+#define ERRbadsector 27
+#define ERRnopaper 28
+#define ERRwrite 29 /* write fault */
+#define ERRread 30 /* read fault */
+#define ERRgeneral 31 /* General hardware failure */
+#define ERRwrongdisk 34
+#define ERRFCBunavail 35
+#define ERRsharebufexc 36 /* share buffer exceeded */
+#define ERRdiskfull 39
+
+
+typedef char pstring[1024];
+typedef char fstring[128];
+typedef fstring string;
+
+typedef struct
+{
+ int size;
+ int mode;
+ int uid;
+ int gid;
+ /* these times are normally kept in GMT */
+ time_t mtime;
+ time_t atime;
+ time_t ctime;
+ pstring name;
+} file_info;
+
+
+/* Structure used when SMBwritebmpx is active */
+typedef struct
+ {
+ int wr_total_written; /* So we know when to discard this */
+ int32 wr_timeout;
+ int32 wr_errclass;
+ int32 wr_error; /* Cached errors */
+ BOOL wr_mode; /* write through mode) */
+ BOOL wr_discard; /* discard all further data */
+ } write_bmpx_struct;
+
+typedef struct
+{
+ int cnum;
+ int fd;
+ int pos;
+ int size;
+ int mode;
+ char *mmap_ptr;
+ int mmap_size;
+ write_bmpx_struct *wbmpx_ptr;
+ time_t open_time;
+ BOOL open;
+ BOOL can_lock;
+ BOOL can_read;
+ BOOL can_write;
+ BOOL share_mode;
+ BOOL share_pending;
+ BOOL print_file;
+ BOOL modified;
+ char *name;
+} files_struct;
+
+
+struct uid_cache {
+ int entries;
+ int list[UID_CACHE_SIZE];
+};
+
+typedef struct
+{
+ int service;
+ BOOL force_user;
+ int uid; /* uid of user who *opened* this connection */
+ int gid; /* gid of user who *opened* this connection */
+ struct uid_cache uid_cache;
+ void *dirptr;
+ BOOL open;
+ BOOL printer;
+ BOOL ipc;
+ BOOL read_only;
+ BOOL admin_user;
+ char *dirpath;
+ char *connectpath;
+ char *origpath;
+ char *user; /* name of user who *opened* this connection */
+ /* following groups stuff added by ih */
+ /* This groups info is valid for the user that *opened* the connection */
+ int ngroups;
+ gid_t *groups;
+ int *igroups; /* an integer version - some OSes are broken :-( */
+ time_t lastused;
+ BOOL used;
+ int num_files_open;
+} connection_struct;
+
+
+typedef struct
+{
+ int uid; /* uid of a validated user */
+ int gid; /* gid of a validated user */
+ fstring name; /* name of a validated user */
+ BOOL guest;
+ /* following groups stuff added by ih */
+ /* This groups info is needed for when we become_user() for this uid */
+ int user_ngroups;
+ gid_t *user_groups;
+ int *user_igroups; /* an integer version - some OSes are broken :-( */
+} user_struct;
+
+
+enum {LPQ_QUEUED,LPQ_PAUSED,LPQ_SPOOLING,LPQ_PRINTING};
+
+typedef struct
+{
+ int job;
+ int size;
+ int status;
+ int priority;
+ time_t time;
+ char user[30];
+ char file[100];
+} print_queue_struct;
+
+enum {LPSTAT_OK, LPSTAT_STOPPED, LPSTAT_ERROR};
+
+typedef struct
+{
+ fstring message;
+ int status;
+} print_status_struct;
+
+
+/* this is used for smbstatus */
+struct connect_record
+{
+ int magic;
+ int pid;
+ int cnum;
+ int uid;
+ int gid;
+ char name[24];
+ char addr[24];
+ char machine[128];
+ time_t start;
+};
+
+
+#define LOCKING_VERSION 2
+
+/* these are useful macros for checking validity of handles */
+#define VALID_FNUM(fnum) (((fnum) >= 0) && ((fnum) < MAX_OPEN_FILES))
+#define OPEN_FNUM(fnum) (VALID_FNUM(fnum) && Files[fnum].open)
+#define VALID_CNUM(cnum) (((cnum) >= 0) && ((cnum) < MAX_CONNECTIONS))
+#define OPEN_CNUM(cnum) (VALID_CNUM(cnum) && Connections[cnum].open)
+#define IS_IPC(cnum) (VALID_CNUM(cnum) && Connections[cnum].ipc)
+#define FNUM_OK(fnum,c) (OPEN_FNUM(fnum) && (c)==Files[fnum].cnum)
+
+#define CHECK_FNUM(fnum,c) if (!FNUM_OK(fnum,c)) \
+ return(ERROR(ERRDOS,ERRbadfid))
+#define CHECK_READ(fnum) if (!Files[fnum].can_read) \
+ return(ERROR(ERRDOS,ERRbadaccess))
+#define CHECK_WRITE(fnum) if (!Files[fnum].can_write) \
+ return(ERROR(ERRDOS,ERRbadaccess))
+#define CHECK_ERROR(fnum) if (HAS_CACHED_ERROR(fnum)) \
+ return(CACHED_ERROR(fnum))
+
+/* translates a connection number into a service number */
+#define SNUM(cnum) (Connections[cnum].service)
+
+/* access various service details */
+#define SERVICE(snum) (lp_servicename(snum))
+#define PRINTCAP (lp_printcapname())
+#define PRINTCOMMAND(snum) (lp_printcommand(snum))
+#define PRINTERNAME(snum) (lp_printername(snum))
+#define CAN_WRITE(cnum) (OPEN_CNUM(cnum) && !Connections[cnum].read_only)
+#define VALID_SNUM(snum) (lp_snum_ok(snum))
+#define GUEST_OK(snum) (VALID_SNUM(snum) && lp_guest_ok(snum))
+#define GUEST_ONLY(snum) (VALID_SNUM(snum) && lp_guest_only(snum))
+#define CAN_SETDIR(snum) (!lp_no_set_dir(snum))
+#define CAN_PRINT(cnum) (OPEN_CNUM(cnum) && lp_print_ok(SNUM(cnum)))
+#define POSTSCRIPT(cnum) (OPEN_CNUM(cnum) && lp_postscript(SNUM(cnum)))
+#define MAP_HIDDEN(cnum) (OPEN_CNUM(cnum) && lp_map_hidden(SNUM(cnum)))
+#define MAP_SYSTEM(cnum) (OPEN_CNUM(cnum) && lp_map_system(SNUM(cnum)))
+#define MAP_ARCHIVE(cnum) (OPEN_CNUM(cnum) && lp_map_archive(SNUM(cnum)))
+#define CREATE_MODE(cnum) (lp_create_mode(SNUM(cnum)) | 0700)
+#ifdef SMB_PASSWD
+#define SMBENCRYPT() (lp_encrypted_passwords())
+#else
+#define SMBENCRYPT() (False)
+#endif
+
+/* the basic packet size, assuming no words or bytes */
+#define smb_size 39
+
+/* offsets into message for common items */
+#define smb_com 8
+#define smb_rcls 9
+#define smb_reh 10
+#define smb_err 11
+#define smb_flg 13
+#define smb_flg2 14
+#define smb_reb 13
+#define smb_tid 28
+#define smb_pid 30
+#define smb_uid 32
+#define smb_mid 34
+#define smb_wct 36
+#define smb_vwv 37
+#define smb_vwv0 37
+#define smb_vwv1 39
+#define smb_vwv2 41
+#define smb_vwv3 43
+#define smb_vwv4 45
+#define smb_vwv5 47
+#define smb_vwv6 49
+#define smb_vwv7 51
+#define smb_vwv8 53
+#define smb_vwv9 55
+#define smb_vwv10 57
+#define smb_vwv11 59
+#define smb_vwv12 61
+#define smb_vwv13 63
+#define smb_vwv14 65
+#define smb_vwv15 67
+#define smb_vwv16 69
+#define smb_vwv17 71
+
+
+/* the complete */
+#define SMBmkdir 0x00 /* create directory */
+#define SMBrmdir 0x01 /* delete directory */
+#define SMBopen 0x02 /* open file */
+#define SMBcreate 0x03 /* create file */
+#define SMBclose 0x04 /* close file */
+#define SMBflush 0x05 /* flush file */
+#define SMBunlink 0x06 /* delete file */
+#define SMBmv 0x07 /* rename file */
+#define SMBgetatr 0x08 /* get file attributes */
+#define SMBsetatr 0x09 /* set file attributes */
+#define SMBread 0x0A /* read from file */
+#define SMBwrite 0x0B /* write to file */
+#define SMBlock 0x0C /* lock byte range */
+#define SMBunlock 0x0D /* unlock byte range */
+#define SMBctemp 0x0E /* create temporary file */
+#define SMBmknew 0x0F /* make new file */
+#define SMBchkpth 0x10 /* check directory path */
+#define SMBexit 0x11 /* process exit */
+#define SMBlseek 0x12 /* seek */
+#define SMBtcon 0x70 /* tree connect */
+#define SMBtconX 0x75 /* tree connect and X*/
+#define SMBtdis 0x71 /* tree disconnect */
+#define SMBnegprot 0x72 /* negotiate protocol */
+#define SMBdskattr 0x80 /* get disk attributes */
+#define SMBsearch 0x81 /* search directory */
+#define SMBsplopen 0xC0 /* open print spool file */
+#define SMBsplwr 0xC1 /* write to print spool file */
+#define SMBsplclose 0xC2 /* close print spool file */
+#define SMBsplretq 0xC3 /* return print queue */
+#define SMBsends 0xD0 /* send single block message */
+#define SMBsendb 0xD1 /* send broadcast message */
+#define SMBfwdname 0xD2 /* forward user name */
+#define SMBcancelf 0xD3 /* cancel forward */
+#define SMBgetmac 0xD4 /* get machine name */
+#define SMBsendstrt 0xD5 /* send start of multi-block message */
+#define SMBsendend 0xD6 /* send end of multi-block message */
+#define SMBsendtxt 0xD7 /* send text of multi-block message */
+
+/* Core+ protocol */
+#define SMBlockread 0x13 /* Lock a range and read */
+#define SMBwriteunlock 0x14 /* Unlock a range then write */
+#define SMBreadbraw 0x1a /* read a block of data with no smb header */
+#define SMBwritebraw 0x1d /* write a block of data with no smb header */
+#define SMBwritec 0x20 /* secondary write request */
+#define SMBwriteclose 0x2c /* write a file then close it */
+
+/* dos extended protocol */
+#define SMBreadBraw 0x1A /* read block raw */
+#define SMBreadBmpx 0x1B /* read block multiplexed */
+#define SMBreadBs 0x1C /* read block (secondary response) */
+#define SMBwriteBraw 0x1D /* write block raw */
+#define SMBwriteBmpx 0x1E /* write block multiplexed */
+#define SMBwriteBs 0x1F /* write block (secondary request) */
+#define SMBwriteC 0x20 /* write complete response */
+#define SMBsetattrE 0x22 /* set file attributes expanded */
+#define SMBgetattrE 0x23 /* get file attributes expanded */
+#define SMBlockingX 0x24 /* lock/unlock byte ranges and X */
+#define SMBtrans 0x25 /* transaction - name, bytes in/out */
+#define SMBtranss 0x26 /* transaction (secondary request/response) */
+#define SMBioctl 0x27 /* IOCTL */
+#define SMBioctls 0x28 /* IOCTL (secondary request/response) */
+#define SMBcopy 0x29 /* copy */
+#define SMBmove 0x2A /* move */
+#define SMBecho 0x2B /* echo */
+#define SMBopenX 0x2D /* open and X */
+#define SMBreadX 0x2E /* read and X */
+#define SMBwriteX 0x2F /* write and X */
+#define SMBsesssetupX 0x73 /* Session Set Up & X (including User Logon) */
+#define SMBffirst 0x82 /* find first */
+#define SMBfunique 0x83 /* find unique */
+#define SMBfclose 0x84 /* find close */
+#define SMBinvalid 0xFE /* invalid command */
+
+/* Extended 2.0 protocol */
+#define SMBtrans2 0x32 /* TRANS2 protocol set */
+#define SMBtranss2 0x33 /* TRANS2 protocol set, secondary command */
+#define SMBfindclose 0x34 /* Terminate a TRANSACT2_FINDFIRST */
+#define SMBfindnclose 0x35 /* Terminate a TRANSACT2_FINDNOTIFYFIRST */
+#define SMBulogoffX 0x74 /* user logoff */
+
+
+/* these are the TRANS2 sub commands */
+#define TRANSACT2_OPEN 0
+#define TRANSACT2_FINDFIRST 1
+#define TRANSACT2_FINDNEXT 2
+#define TRANSACT2_QFSINFO 3
+#define TRANSACT2_SETFSINFO 4
+#define TRANSACT2_QPATHINFO 5
+#define TRANSACT2_SETPATHINFO 6
+#define TRANSACT2_QFILEINFO 7
+#define TRANSACT2_SETFILEINFO 8
+#define TRANSACT2_FSCTL 9
+#define TRANSACT2_IOCTL 10
+#define TRANSACT2_FINDNOTIFYFIRST 11
+#define TRANSACT2_FINDNOTIFYNEXT 12
+#define TRANSACT2_MKDIR 13
+
+
+/* these are the trans2 sub fields for primary requests */
+#define smb_tpscnt smb_vwv0
+#define smb_tdscnt smb_vwv1
+#define smb_mprcnt smb_vwv2
+#define smb_mdrcnt smb_vwv3
+#define smb_msrcnt smb_vwv4
+#define smb_flags smb_vwv5
+#define smb_timeout smb_vwv6
+#define smb_pscnt smb_vwv9
+#define smb_psoff smb_vwv10
+#define smb_dscnt smb_vwv11
+#define smb_dsoff smb_vwv12
+#define smb_suwcnt smb_vwv13
+#define smb_setup smb_vwv14
+#define smb_setup0 smb_setup
+#define smb_setup1 (smb_setup+2)
+#define smb_setup2 (smb_setup+4)
+
+/* these are for the secondary requests */
+#define smb_spscnt smb_vwv2
+#define smb_spsoff smb_vwv3
+#define smb_spsdisp smb_vwv4
+#define smb_sdscnt smb_vwv5
+#define smb_sdsoff smb_vwv6
+#define smb_sdsdisp smb_vwv7
+#define smb_sfid smb_vwv8
+
+/* and these for responses */
+#define smb_tprcnt smb_vwv0
+#define smb_tdrcnt smb_vwv1
+#define smb_prcnt smb_vwv3
+#define smb_proff smb_vwv4
+#define smb_prdisp smb_vwv5
+#define smb_drcnt smb_vwv6
+#define smb_droff smb_vwv7
+#define smb_drdisp smb_vwv8
+
+/* where to find the base of the SMB packet proper */
+#define smb_base(buf) (((char *)(buf))+4)
+
+
+#define SUCCESS 0 /* The request was successful. */
+#define ERRDOS 0x01 /* Error is from the core DOS operating system set. */
+#define ERRSRV 0x02 /* Error is generated by the server network file manager.*/
+#define ERRHRD 0x03 /* Error is an hardware error. */
+#define ERRCMD 0xFF /* Command was not in the "SMB" format. */
+
+/* structure used to hold the incoming hosts info */
+struct from_host {
+ char *name; /* host name */
+ char *addr; /* host address */
+ struct sockaddr_in *sin; /* their side of the link */
+};
+
+/* and a few prototypes */
+BOOL user_ok(char *user,int snum);
+int sys_rename(char *from, char *to);
+int sys_select(fd_set *fds,struct timeval *tval);
+int sys_unlink(char *fname);
+int sys_open(char *fname,int flags,int mode);
+DIR *sys_opendir(char *dname);
+int sys_stat(char *fname,struct stat *sbuf);
+int sys_lstat(char *fname,struct stat *sbuf);
+int sys_mkdir(char *dname,int mode);
+int sys_rmdir(char *dname);
+int sys_chdir(char *dname);
+int sys_utime(char *fname,struct utimbuf *times);
+int sys_disk_free(char *path,int *bsize,int *dfree,int *dsize);
+void lpq_reset(int);
+void status_printjob(int cnum,int snum,int jobid,int status);
+void DirCacheAdd(char *path,char *name,char *dname,int snum);
+char *DirCacheCheck(char *path,char *name,int snum);
+void DirCacheFlush(int snum);
+int interpret_character_set(char *str, int def);
+char *dos2unix_format(char *, BOOL);
+char *unix2dos_format(char *, BOOL);
+BOOL fcntl_lock(int fd,int op,uint32 offset,uint32 count,int type);
+void BlockSignals(BOOL block);
+void msleep(int t);
+int file_lock(char *name,int timeout);
+void file_unlock(int fd);
+int find_service(char *service);
+int TvalDiff(struct timeval *tvalold,struct timeval *tvalnew);
+int smb_offset(char *p,char *buf);
+void sync_file(int fnum);
+int PutUniCode(char *dst,char *src);
+void map_username(char *user);
+void close_low_fds(void);
+void clean_share_files(void);
+int write_socket(int fd,char *buf,int len);
+char *readdirname(void *p);
+int dos_chmod(int cnum,char *fname,int mode,struct stat *st);
+int smb_numwords(char *buf);
+int get_share_mode(int cnum,struct stat *sbuf,int *pid);
+void del_share_mode(int fnum);
+BOOL set_share_mode(int fnum,int mode);
+int DSTDiff(time_t t);
+void TimeInit(void);
+void put_long_date(char *p,time_t t);
+time_t interpret_long_date(char *p);
+void dptr_idlecnum(int cnum);
+void dptr_closecnum(int cnum);
+void init_dptrs(void);
+void fault_setup();
+void set_socket_options(int fd, char *options);
+void putip(void *dest,void *src);
+void standard_sub_basic(char *s);
+void *OpenDir(char *name);
+void CloseDir(void *p);
+char *ReadDirName(void *p);
+BOOL SeekDir(void *p,int pos);
+int TellDir(void *p);
+int write_data(int fd,char *buffer,int N);
+BOOL server_cryptkey(char *buf);
+BOOL server_validate(char *buf);
+BOOL become_service(int cnum,BOOL do_chdir);
+BOOL snum_used(int snum);
+BOOL reload_services(BOOL test);
+void reopen_logs(void);
+int transfer_file(int infd,int outfd,int n,char *header,int headlen,int align);
+int str_checksum(char *s);
+time_t file_modtime(char *fname);
+BOOL do_match(char *str, char *regexp, int case_sig);
+BOOL is_a_socket(int fd);
+void _smb_setlen(char *buf,int len);
+void valid_initialise(void);
+BOOL is_8_3(char *fname);
+BOOL is_mangled(char *s);
+void standard_sub(int cnum,char *s);
+void del_printqueue(int cnum,int snum,int jobid);
+BOOL strisnormal(char *s);
+BOOL check_mangled_stack(char *s);
+int sys_chown(char *fname,int uid,int gid);
+int sys_chroot(char *dname);
+BOOL next_token(char **ptr,char *buff,char *sep);
+void invalidate_uid(int uid);
+char *fgets_slash(char *s,int maxlen,FILE *f);
+int read_udp_socket(int fd,char *buf,int len);
+void exit_server(char *reason);
+BOOL process_exists(int pid);
+BOOL chgpasswd(char *name,char *oldpass,char *newpass);
+void array_promote(char *array,int elsize,int element);
+void string_replace(char *s,char oldc,char newc);
+BOOL user_in_list(char *user,char *list);
+BOOL string_sub(char *s,char *pattern,char *insert);
+char *StrnCpy(char *dest,const char *src,int n);
+char *validated_username(int vuid);
+BOOL set_user_password(char *user,char *oldpass,char *newpass);
+int smb_buf_ofs(char *buf);
+char *skip_string(char *buf,int n);
+BOOL is_locked(int fnum,int cnum,uint32 count,uint32 offset);
+int read_file(int fnum,char *data,int pos,int mincnt,int maxcnt,int timeout,BOOL exact);
+int write_file(int fnum,char *data,int n);
+BOOL do_lock(int fnum,int cnum,uint32 count,uint32 offset,int *eclass,uint32 *ecode);
+int seek_file(int fnum,int pos);
+BOOL do_unlock(int fnum,int cnum,uint32 count,uint32 offset,int *eclass,uint32 *ecode);
+int get_printqueue(int snum,int cnum,print_queue_struct **queue,print_status_struct *status);
+void parse_connect(char *buf,char *service,char *user,char *password,int *pwlen,char *dev);
+int setup_groups(char *user,int uid, int gid, int *p_ngroups,
+ int **p_igroups, gid_t **p_groups);
+int make_connection(char *service,char *user,char *password, int pwlen, char *dev,int vuid);
+char *dptr_path(int key);
+char *dptr_wcard(int key);
+BOOL dptr_set_wcard(int key, char *wcard);
+BOOL dptr_set_attr(int key, uint16 attr);
+uint16 dptr_attr(int key);
+void dptr_close(int key);
+void dptr_closepath(char *path,int pid);
+int dptr_create(int cnum,char *path, BOOL expect_close,int pid);
+BOOL dptr_fill(char *buf,unsigned int key);
+BOOL dptr_zero(char *buf);
+void *dptr_fetch(char *buf,int *num);
+void *dptr_fetch_lanman2(char *params,int dptr_num);
+BOOL get_dir_entry(int cnum,char *mask,int dirtype,char *fname,int *size,int *mode,time_t *date,BOOL check_descend);
+void open_file(int fnum,int cnum,char *fname,int flags,int mode);
+void open_file_shared(int fnum,int cnum,char *fname,int share_mode,int ofun,int mode,int *Access,int *action);
+void close_file(int fnum);
+int reply_trans2(char *inbuf,char *outbuf,int length,int bufsize);
+int reply_trans(char *inbuf,char *outbuf);
+char *ufc_crypt(char *key,char *salt);
+BOOL authorise_login(int snum,char *user,char *password, int pwlen,
+ BOOL *guest,BOOL *force,int vuid);
+void add_session_user(char *user);
+int valid_uid(int uid);
+user_struct *get_valid_user_struct(int uid);
+BOOL password_ok(char *user,char *password, int pwlen, struct passwd *pwd, BOOL nt_password);
+void register_uid(int uid,int gid,char *name,BOOL guest);
+BOOL fromhost(int sock,struct from_host *f);
+BOOL strhasupper(char *s);
+BOOL strhaslower(char *s);
+int disk_free(char *path,int *bsize,int *dfree,int *dsize);
+char *uidtoname(int uid);
+char *gidtoname(int gid);
+int get_share_mode_byname(int cnum,char *fname,int *pid);
+int get_share_mode_by_fnum(int cnum,int fnum,int *pid);
+BOOL check_file_sharing(int cnum,char *fname);
+char *StrCpy(char *dest,char *src);
+int unix_error_packet(char *inbuf,char *outbuf,int def_class,uint32 def_code,int line);
+time_t make_unix_date2(void *date_ptr);
+int cached_error_packet(char *inbuf,char *outbuf,int fnum,int line);
+mode_t unix_mode(int cnum,int dosmode);
+BOOL check_name(char *name,int cnum);
+int error_packet(char *inbuf,char *outbuf,int error_class,uint32 error_code,int line);
+int find_free_file(void );
+BOOL unix_convert(char *name,int cnum);
+void unix_convert_lanman2(char *s,char *home,BOOL case_is_sig);
+void print_file(int fnum);
+int read_smb_length(int fd,char *inbuf,int timeout);
+int read_predict(int fd,int offset,char *buf,char **ptr,int num);
+void invalidate_read_prediction(int fd);
+void do_read_prediction();
+BOOL claim_connection(int cnum,char *name,int max_connections,BOOL Clear);
+BOOL yield_connection(int cnum,char *name,int max_connections);
+int count_chars(char *s,char c);
+int smbrun(char *,char *);
+BOOL name_map_mangle(char *OutName,BOOL need83,int snum);
+struct hostent *Get_Hostbyname(char *name);
+struct passwd *Get_Pwnam(char *user,BOOL allow_change);
+void Abort(void);
+void *Realloc(void *p,int size);
+void smb_setlen(char *buf,int len);
+int set_message(char *buf,int num_words,int num_bytes,BOOL zero);
+BOOL check_access(int snum);
+BOOL in_group(gid_t group, int current_gid, int ngroups, int *groups);
+BOOL string_set(char **dest,char *src);
+BOOL string_init(char **dest,char *src);
+void string_free(char **s);
+char *attrib_string(int mode);
+void unix_format(char *fname);
+BOOL directory_exist(char *dname,struct stat *st);
+time_t make_unix_date3(void *date_ptr);
+void put_dos_date3(char *buf,int offset,time_t unixdate);
+void make_dir_struct(char *buf,char *mask,char *fname,unsigned int size,int mode,time_t date);
+BOOL in_list(char *s,char *list,BOOL case_sensitive);
+void strupper(char *s);
+BOOL file_exist(char *fname,struct stat *sbuf);
+int read_with_timeout(int fd,char *buf,int mincnt,int maxcnt, long time_out, BOOL exact);
+void close_sockets(void );
+BOOL send_smb(int fd,char *buffer);
+BOOL send_keepalive(int client);
+int read_data(int fd,char *buffer,int N);
+int smb_len(char *buf);
+BOOL receive_smb(int fd,char *buffer,int timeout);
+void show_msg(char *buf);
+BOOL big_endian(void );
+BOOL become_user(int cnum, int uid);
+BOOL unbecome_user(void);
+void become_daemon(void);
+BOOL reduce_name(char *s,char *dir,BOOL widelinks);
+void strlower(char *s);
+void strnorm(char *s);
+char *smb_buf(char *buf);
+char *smb_trans2_param(char *buf);
+char *smb_trans2_data(char *buf);
+BOOL strequal(char *,char *);
+BOOL strnequal(char *,char *,int n);
+BOOL strcsequal(char *,char *);
+BOOL mask_match( char *str, char *regexp, int case_sig, BOOL trans2);
+int dos_mode(int ,char *,struct stat *);
+char *timestring();
+BOOL ip_equal(struct in_addr ip1,struct in_addr ip2);
+BOOL send_one_packet(char *buf,int len,struct in_addr ip,int port,int type);
+char *get_home_dir(char *);
+int set_filelen(int fd, long len);
+void put_dos_date(char *buf,int offset,time_t unixdate);
+void put_dos_date2(char *buf,int offset,time_t unixdate);
+int lp_keepalive(void);
+int name_len(char *s);
+void dos_clean_name(char *s);
+void unix_clean_name(char *s);
+time_t make_unix_date(void *date_ptr);
+BOOL lanman2_match( char *str, char *regexp, int case_sig, BOOL autoext);
+BOOL trim_string(char *s,char *front,char *back);
+int byte_checksum(char *buf,int len);
+BOOL yesno(char *p);
+uint32 file_size(char *file_name);
+void dos_format(char *fname);
+char *GetWd(char *s);
+int name_mangle(char *in,char *out,char name_type);
+int name_len(char *s);
+void create_mangled_stack(int size);
+int name_extract(char *buf,int ofs,char *name);
+void get_broadcast(struct in_addr *if_ipaddr, struct in_addr *if_bcast, struct in_addr *if_nmask);
+BOOL allow_access(char *deny_list,char *allow_list,struct from_host *client);
+#ifdef __STDC__
+int Debug1(char *, ...);
+#else
+int Debug1();
+#endif
+BOOL check_hosts_equiv(char *user);
+int chain_reply(int type,char *inbuf,char *inbuf2,char *outbuf,char *outbuf2,int size,int bufsize);
+void close_cnum(int cnum,int uid);
+char *smb_errstr(char *inbuf);
+void GetTimeOfDay(struct timeval *tval);
+struct tm *LocalTime(time_t *t,int);
+int TimeDiff(time_t t);
+BOOL set_filetime(char *fname,time_t mtime);
+char *dirname_dos(char *path,char *buf);
+BOOL get_myname(char *myname,struct in_addr *ip);
+void expand_mask(char *Mask, BOOL);
+BOOL sane_unix_date(time_t unixdate);
+time_t start_of_month(void);
+char *smb_fn_name(int cnum);
+void get_machine_info(void);
+int open_socket_in(int type, int port, int dlevel);
+int open_socket_out(int type,struct in_addr *addr, int port );
+struct in_addr *interpret_addr2(char *str);
+BOOL zero_ip(struct in_addr ip);
+int read_max_udp(int fd,char *buffer,int bufsize,int maxtime);
+int interpret_protocol(char *str,int def);
+int interpret_security(char *str,int def);
+int ChDir(char *path);
+int smb_buflen(char *buf);
+unsigned long interpret_addr(char *str);
+void mangle_name_83(char *s);
+BOOL lp_casesignames(void);
+void setup_logging(char *pname,BOOL interactive);
+#ifdef DFS_AUTH
+void dfs_unlogin(void);
+extern int dcelogin_atmost_once;
+#endif
+#if AJT
+void ajt_panic(void);
+#endif
+#ifdef NOSTRDUP
+char *strdup(char *s);
+#endif
+#ifdef REPLACE_STRLEN
+int Strlen(char *);
+#endif
+#ifdef REPLACE_STRSTR
+char *Strstr(char *s, char *p);
+#endif
+
+#ifndef MIN
+#define MIN(a,b) ((a)<(b)?(a):(b))
+#endif
+#ifndef MAX
+#define MAX(a,b) ((a)>(b)?(a):(b))
+#endif
+
+#ifndef ABS
+#define ABS(a) ((a)>0?(a):(-(a)))
+#endif
+
+#ifndef SIGNAL_CAST
+#define SIGNAL_CAST
+#endif
+
+#ifndef SELECT_CAST
+#define SELECT_CAST
+#endif
+
+
+/* Some POSIX definitions for those without */
+
+#ifndef S_IFDIR
+#define S_IFDIR 0x4000
+#endif
+#ifndef S_ISDIR
+#define S_ISDIR(mode) ((mode & 0xF000) == S_IFDIR)
+#endif
+#ifndef S_IRWXU
+#define S_IRWXU 00700 /* read, write, execute: owner */
+#endif
+#ifndef S_IRUSR
+#define S_IRUSR 00400 /* read permission: owner */
+#endif
+#ifndef S_IWUSR
+#define S_IWUSR 00200 /* write permission: owner */
+#endif
+#ifndef S_IXUSR
+#define S_IXUSR 00100 /* execute permission: owner */
+#endif
+#ifndef S_IRWXG
+#define S_IRWXG 00070 /* read, write, execute: group */
+#endif
+#ifndef S_IRGRP
+#define S_IRGRP 00040 /* read permission: group */
+#endif
+#ifndef S_IWGRP
+#define S_IWGRP 00020 /* write permission: group */
+#endif
+#ifndef S_IXGRP
+#define S_IXGRP 00010 /* execute permission: group */
+#endif
+#ifndef S_IRWXO
+#define S_IRWXO 00007 /* read, write, execute: other */
+#endif
+#ifndef S_IROTH
+#define S_IROTH 00004 /* read permission: other */
+#endif
+#ifndef S_IWOTH
+#define S_IWOTH 00002 /* write permission: other */
+#endif
+#ifndef S_IXOTH
+#define S_IXOTH 00001 /* execute permission: other */
+#endif
+
+
+/* these are used in NetServerEnum to choose what to receive */
+#define SV_TYPE_WORKSTATION 0x00000001
+#define SV_TYPE_SERVER 0x00000002
+#define SV_TYPE_SQLSERVER 0x00000004
+#define SV_TYPE_DOMAIN_CTRL 0x00000008
+#define SV_TYPE_DOMAIN_BAKCTRL 0x00000010
+#define SV_TYPE_TIME_SOURCE 0x00000020
+#define SV_TYPE_AFP 0x00000040
+#define SV_TYPE_NOVELL 0x00000080
+#define SV_TYPE_DOMAIN_MEMBER 0x00000100
+#define SV_TYPE_PRINTQ_SERVER 0x00000200
+#define SV_TYPE_DIALIN_SERVER 0x00000400
+#define SV_TYPE_SERVER_UNIX 0x00000800
+#define SV_TYPE_NT 0x00001000
+#define SV_TYPE_WFW 0x00002000
+#define SV_TYPE_SERVER_MFPN 0x00004000
+#define SV_TYPE_SERVER_NT 0x00008000
+#define SV_TYPE_POTENTIAL_BROWSER 0x00010000
+#define SV_TYPE_BACKUP_BROWSER 0x00020000
+#define SV_TYPE_MASTER_BROWSER 0x00040000
+#define SV_TYPE_DOMAIN_MASTER 0x00080000
+#define SV_TYPE_SERVER_OSF 0x00100000
+#define SV_TYPE_SERVER_VMS 0x00200000
+#define SV_TYPE_ALTERNATE_XPORT 0x20000000
+#define SV_TYPE_LOCAL_LIST_ONLY 0x40000000
+#define SV_TYPE_DOMAIN_ENUM 0x80000000
+#define SV_TYPE_ALL 0xFFFFFFFF
+
+
+
+/* protocol types. It assumes that higher protocols include lower protocols
+ as subsets */
+enum protocol_types {PROTOCOL_NONE,PROTOCOL_CORE,PROTOCOL_COREPLUS,PROTOCOL_LANMAN1,PROTOCOL_LANMAN2,PROTOCOL_NT1};
+
+/* security levels */
+enum security_types {SEC_SHARE,SEC_USER,SEC_SERVER};
+
+/* printing types */
+enum printing_types {PRINT_BSD,PRINT_SYSV,PRINT_AIX,PRINT_HPUX,PRINT_QNX};
+
+
+/* case handling */
+enum case_handling {CASE_LOWER,CASE_UPPER};
+
+
+/* Macros to get at offsets within smb_lkrng and smb_unlkrng
+ structures. We cannot define these as actual structures
+ due to possible differences in structure packing
+ on different machines/compilers. */
+
+#define SMB_LPID_OFFSET(indx) (10 * (indx))
+#define SMB_LKOFF_OFFSET(indx) ( 2 + (10 * (indx)))
+#define SMB_LKLEN_OFFSET(indx) ( 6 + (10 * (indx)))
+
+/* Macro to cache an error in a write_bmpx_struct */
+#define CACHE_ERROR(w,c,e) ((w)->wr_errclass = (c), (w)->wr_error = (e), \
+ w->wr_discard = True, -1)
+/* Macro to test if an error has been cached for this fnum */
+#define HAS_CACHED_ERROR(fnum) (Files[(fnum)].open && \
+ Files[(fnum)].wbmpx_ptr && \
+ Files[(fnum)].wbmpx_ptr->wr_discard)
+/* Macro to turn the cached error into an error packet */
+#define CACHED_ERROR(fnum) cached_error_packet(inbuf,outbuf,fnum,__LINE__)
+
+/* these are the datagram types */
+#define DGRAM_DIRECT_UNIQUE 0x10
+
+#define ERROR(class,x) error_packet(inbuf,outbuf,class,x,__LINE__)
+
+/* this is how errors are generated */
+#define UNIXERROR(defclass,deferror) unix_error_packet(inbuf,outbuf,defclass,deferror,__LINE__)
+
+#define ROUNDUP(x,g) (((x)+((g)-1))&~((g)-1))
+
+#endif
+/* _SMB_H */
diff --git a/source3/include/trans2.h b/source3/include/trans2.h
new file mode 100644
index 0000000000..cc366ccaea
--- /dev/null
+++ b/source3/include/trans2.h
@@ -0,0 +1,241 @@
+/*
+ Unix SMB/Netbios implementation.
+ Version 1.9.
+ SMB transaction2 handling
+ Copyright (C) Jeremy Allison 1994
+
+ Extensively modified by Andrew Tridgell, 1995
+
+ 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
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ 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.
+*/
+
+#ifndef _TRANS2_H_
+#define _TRANS2_H_
+
+/* Define the structures needed for the trans2 calls. */
+
+/*******************************************************
+ For DosFindFirst/DosFindNext - level 1
+
+MAXFILENAMELEN = 255;
+FDATE == uint16
+FTIME == uint16
+ULONG == uint32
+USHORT == uint16
+
+typedef struct _FILEFINDBUF {
+Byte offset Type name description
+-------------+-------+-------------------+--------------
+0 FDATE fdateCreation;
+2 FTIME ftimeCreation;
+4 FDATE fdateLastAccess;
+6 FTIME ftimeLastAccess;
+8 FDATE fdateLastWrite;
+10 FTIME ftimeLastWrite;
+12 ULONG cbFile file length in bytes
+16 ULONG cbFileAlloc size of file allocation unit
+20 USHORT attrFile
+22 UCHAR cchName length of name to follow (not including zero)
+23 UCHAR achName[MAXFILENAMELEN]; Null terminated name
+} FILEFINDBUF;
+*********************************************************/
+
+#define l1_fdateCreation 0
+#define l1_fdateLastAccess 4
+#define l1_fdateLastWrite 8
+#define l1_cbFile 12
+#define l1_cbFileAlloc 16
+#define l1_attrFile 20
+#define l1_cchName 22
+#define l1_achName 23
+
+/**********************************************************
+For DosFindFirst/DosFindNext - level 2
+
+typedef struct _FILEFINDBUF2 {
+Byte offset Type name description
+-------------+-------+-------------------+--------------
+0 FDATE fdateCreation;
+2 FTIME ftimeCreation;
+4 FDATE fdateLastAccess;
+6 FTIME ftimeLastAccess;
+8 FDATE fdateLastWrite;
+10 FTIME ftimeLastWrite;
+12 ULONG cbFile file length in bytes
+16 ULONG cbFileAlloc size of file allocation unit
+20 USHORT attrFile
+22 ULONG cbList Extended attribute list (always 0)
+26 UCHAR cchName length of name to follow (not including zero)
+27 UCHAR achName[MAXFILENAMELEN]; Null terminated name
+} FILEFINDBUF2;
+*************************************************************/
+
+#define l2_fdateCreation 0
+#define l2_fdateLastAccess 4
+#define l2_fdateLastWrite 8
+#define l2_cbFile 12
+#define l2_cbFileAlloc 16
+#define l2_attrFile 20
+#define l2_cbList 22
+#define l2_cchName 26
+#define l2_achName 27
+
+
+/**********************************************************
+For DosFindFirst/DosFindNext - level 260
+
+typedef struct _FILEFINDBUF260 {
+Byte offset Type name description
+-------------+-------+-------------------+--------------
+0 ULONG NextEntryOffset;
+4 ULONG FileIndex;
+8 LARGE_INTEGER CreationTime;
+16 LARGE_INTEGER LastAccessTime;
+24 LARGE_INTEGER LastWriteTime;
+32 LARGE_INTEGER ChangeTime;
+40 LARGE_INTEGER EndOfFile;
+48 LARGE_INTEGER AllocationSize;
+56 ULONG FileAttributes;
+60 ULONG FileNameLength;
+64 ULONG EaSize;
+68 CHAR ShortNameLength;
+70 UNICODE ShortName[12];
+94 UNICODE FileName[];
+*************************************************************/
+
+#define l260_achName 94
+
+
+/**********************************************************
+For DosQueryPathInfo/DosQueryFileInfo/DosSetPathInfo/
+DosSetFileInfo - level 1
+
+typedef struct _FILESTATUS {
+Byte offset Type name description
+-------------+-------+-------------------+--------------
+0 FDATE fdateCreation;
+2 FTIME ftimeCreation;
+4 FDATE fdateLastAccess;
+6 FTIME ftimeLastAccess;
+8 FDATE fdateLastWrite;
+10 FTIME ftimeLastWrite;
+12 ULONG cbFile file length in bytes
+16 ULONG cbFileAlloc size of file allocation unit
+20 USHORT attrFile
+} FILESTATUS;
+*************************************************************/
+
+/* Use the l1_ defines from DosFindFirst */
+
+/**********************************************************
+For DosQueryPathInfo/DosQueryFileInfo/DosSetPathInfo/
+DosSetFileInfo - level 2
+
+typedef struct _FILESTATUS2 {
+Byte offset Type name description
+-------------+-------+-------------------+--------------
+0 FDATE fdateCreation;
+2 FTIME ftimeCreation;
+4 FDATE fdateLastAccess;
+6 FTIME ftimeLastAccess;
+8 FDATE fdateLastWrite;
+10 FTIME ftimeLastWrite;
+12 ULONG cbFile file length in bytes
+16 ULONG cbFileAlloc size of file allocation unit
+20 USHORT attrFile
+22 ULONG cbList Length of EA's (0)
+} FILESTATUS2;
+*************************************************************/
+
+/* Use the l2_ #defines from DosFindFirst */
+
+/**********************************************************
+For DosQFSInfo/DosSetFSInfo - level 1
+
+typedef struct _FSALLOCATE {
+Byte offset Type name description
+-------------+-------+-------------------+--------------
+0 ULONG idFileSystem id of file system
+4 ULONG cSectorUnit number of sectors per allocation unit
+8 ULONG cUnit number of allocation units
+12 ULONG cUnitAvail Available allocation units
+16 USHORT cbSector bytes per sector
+} FSALLOCATE;
+*************************************************************/
+
+#define l1_idFileSystem 0
+#define l1_cSectorUnit 4
+#define l1_cUnit 8
+#define l1_cUnitAvail 12
+#define l1_cbSector 16
+
+/**********************************************************
+For DosQFSInfo/DosSetFSInfo - level 2
+
+typedef struct _FSINFO {
+Byte offset Type name description
+-------------+-------+-------------------+--------------
+0 FDATE vol_fdateCreation
+2 FTIME vol_ftimeCreation
+4 UCHAR vol_cch length of volume name (excluding NULL)
+5 UCHAR vol_szVolLabel[12] volume name
+} FSINFO;
+*************************************************************/
+
+#define SMB_QUERY_FS_LABEL_INFO 0x101
+#define SMB_QUERY_FS_VOLUME_INFO 0x102
+#define SMB_QUERY_FS_SIZE_INFO 0x103
+#define SMB_QUERY_FS_DEVICE_INFO 0x104
+#define SMB_QUERY_FS_ATTRIBUTE_INFO 0x105
+
+
+#define l2_vol_fdateCreation 0
+#define l2_vol_cch 4
+#define l2_vol_szVolLabel 5
+
+
+#define SMB_QUERY_FILE_BASIC_INFO 0x101
+#define SMB_QUERY_FILE_STANDARD_INFO 0x102
+#define SMB_QUERY_FILE_EA_INFO 0x103
+#define SMB_QUERY_FILE_NAME_INFO 0x104
+#define SMB_QUERY_FILE_ALLOCATION_INFO 0x105
+#define SMB_QUERY_FILE_END_OF_FILEINFO 0x106
+#define SMB_QUERY_FILE_ALL_INFO 0x107
+#define SMB_QUERY_FILE_ALT_NAME_INFO 0x108
+#define SMB_QUERY_FILE_STREAM_INFO 0x109
+
+#define SMB_FIND_FILE_DIRECTORY_INFO 0x101
+#define SMB_FIND_FILE_FULL_DIRECTORY_INFO 0x102
+#define SMB_FIND_FILE_NAMES_INFO 0x103
+#define SMB_FIND_FILE_BOTH_DIRECTORY_INFO 0x104
+
+#define SMB_SET_FILE_BASIC_INFO 0x101
+#define SMB_SET_FILE_DISPOSITION_INFO 0x102
+#define SMB_SET_FILE_ALLOCATION_INFO 0x103
+#define SMB_SET_FILE_END_OF_FILE_INFO 0x104
+
+#define DIRLEN_GUESS (45+MAX(l1_achName,l2_achName))
+
+/* Function prototypes */
+
+
+int reply_findnclose(char *inbuf,char *outbuf,int length,int bufsize);
+
+int reply_findclose(char *inbuf,char *outbuf,int length,int bufsize);
+
+#endif
+
+
+
diff --git a/source3/include/version.h b/source3/include/version.h
new file mode 100644
index 0000000000..9ad8b7d44b
--- /dev/null
+++ b/source3/include/version.h
@@ -0,0 +1 @@
+#define VERSION "1.9.16alpha1"
diff --git a/source3/include/vt_mode.h b/source3/include/vt_mode.h
new file mode 100644
index 0000000000..85b481122e
--- /dev/null
+++ b/source3/include/vt_mode.h
@@ -0,0 +1,48 @@
+/* vt_mode.h */
+/*
+support vtp-sessions
+
+written by Christian A. Lademann <cal@zls.com>
+*/
+
+/*
+02.05.95:cal:ported to samba-1.9.13
+*/
+
+#ifndef __vt_mode_h__
+# define __vt_mode_h__
+
+# define VT_CLOSED 0
+# define VT_OPEN 1
+
+# define MS_NONE 0
+# define MS_PTY 1
+# define MS_STREAM 2
+# define MS_VTY 3
+
+# define VT_MAXREAD 32
+
+
+# undef EXTERN
+
+# ifndef __vt_mode_c__
+# define EXTERN extern
+# define DEFAULT(v)
+# else
+# define EXTERN
+# define DEFAULT(v) =(v)
+# endif
+
+ EXTERN int VT_Status DEFAULT(VT_CLOSED),
+ VT_Fd DEFAULT(-1),
+ VT_ChildPID DEFAULT(-1);
+
+ EXTERN BOOL VT_Mode DEFAULT(False),
+ VT_ChildDied DEFAULT(False);
+
+ EXTERN char *VT_Line DEFAULT(NULL);
+
+# undef EXTERN
+
+
+#endif /* __vt_mode_h__ */