diff -u -w samba-1.9.17/source/Makefile samba-1/samba/source/Makefile
--- samba-1.9.17/source/Makefile	Tue Aug 26 02:52:06 1997
+++ samba-1/samba/source/Makefile	Sun Aug 31 15:18:49 1997
@@ -56,6 +56,11 @@
 # the directory where lock files go
 LOCKDIR = $(VARDIR)/locks
 
+# The directory where code page definition files go
+CODEPAGEDIR = $(LIBDIR)/codepages
+# The current codepage definition list.
+CODEPAGELIST= 437 850 852 932
+
 # set this to the default group you want your machine to appear in
 # for browsing. This can also be set in nmbd (see nmbd(8))
 WORKGROUP = WORKGROUP
@@ -603,14 +608,14 @@
 
 CFLAGS1 = $(FLAGS1) -DSMBLOGFILE=\"$(SMBLOGFILE)\" -DNMBLOGFILE=\"$(NMBLOGFILE)\"
 CFLAGS2 = -DCONFIGFILE=\"$(CONFIGFILE)\" -DLMHOSTSFILE=\"$(LMHOSTSFILE)\" 
-CFLAGS3 = -DLOCKDIR=\"$(LOCKDIR)\" -DSMBRUN=\"$(SMBRUN)\"
+CFLAGS3 = -DLOCKDIR=\"$(LOCKDIR)\" -DSMBRUN=\"$(SMBRUN)\" -DCODEPAGEDIR=\"$(CODEPAGEDIR)\"
 CFLAGS4 = -DWORKGROUP=\"$(WORKGROUP)\" -DGUEST_ACCOUNT=\"$(GUESTACCOUNT)\" 
 CFLAGS5 = $(CFLAGS1) $(CFLAGS2) $(CFLAGS3) $(CFLAGS4) $(FLAGSM) $(AFS_FLAGS) $(KRB5_FLAGS)
 CFLAGS  = $(CFLAGS5) $(PAM_FLAGS) $(DCE_FLAGS) $(DES_FLAGS) $(PASSWD_FLAGS) $(VTP_FLAGS)
 LIBS = $(LIBS1) $(LIBSM) $(PAM_LIBS) $(DCE_LIBS) $(KRB5_LIBS) $(DES_LIB)
 
 SPROGS = smbd nmbd
-PROGS1 = smbclient testparm testprns smbrun smbstatus smbpasswd 
+PROGS1 = smbclient testparm testprns smbrun smbstatus smbpasswd make_smbcodepage
 PROGS = $(PROGS1) nmblookup
 SCRIPTS = smbtar addtosmbpass
 
@@ -679,7 +684,11 @@
 	@echo Linking smbpasswd
 	@$(CC) $(CFLAGS) -o smbpasswd smbpasswd.o getsmbpass.o $(PARAMOBJ) $(LIBS)
 
-install: installbin installman installscripts
+make_smbcodepage: make_smbcodepage.o $(PARAMOBJ)
+	@echo Linking make_smbcodepage
+	@$(CC) $(CFLAGS) -o make_smbcodepage make_smbcodepage.o $(PARAMOBJ) $(LIBS)
+
+install: installbin installman installscripts installcp
 
 installbin: all
 	@$(SHELL) $(srcdir)installbin.sh $(INSTALLPERMS) $(BASEDIR) $(SBINDIR) $(LIBDIR) $(VARDIR) $(SPROGS)
@@ -688,6 +697,9 @@
 installscripts:
 	@$(SHELL) $(srcdir)installscripts.sh $(INSTALLPERMS) $(BINDIR) $(SCRIPTS)
 
+installcp:
+	@$(SHELL) $(srcdir)installcp.sh $(LIBDIR) $(CODEPAGEDIR) $(BINDIR) $(CODEPAGELIST)
+
 # revert to the previously installed version
 revert:
 	@$(SHELL) $(srcdir)revert.sh $(SBINDIR) $(SPROGS) $(SCRIPTS)
@@ -696,7 +708,7 @@
 installman:
 	@$(SHELL) $(srcdir)installman.sh $(MANDIR) $(srcdir)
 
-uninstall: uninstallman uninstallbin uninstallscripts
+uninstall: uninstallman uninstallbin uninstallscripts uninstallcp
 
 uninstallman:
 	@$(SHELL) $(srcdir)uninstallman.sh $(MANDIR) $(srcdir)
@@ -707,6 +719,9 @@
 
 uninstallscripts:
 	@$(SHELL) $(srcdir)uninstallscripts.sh $(INSTALLPERMS) $(BINDIR) $(SCRIPTS)
+
+uninstallcp:
+	@$(SHELL) $(srcdir)uninstallcp.sh $(CODEPAGEDIR) $(CODEPAGELIST)
 
 clean:
 	rm -f core *.o *~ $(PROGS) $(SPROGS)
diff -u -w samba-1.9.17/source/charset.c samba-1/samba/source/charset.c
--- samba-1.9.17/source/charset.c	Tue Aug 26 02:00:09 1997
+++ samba-1/samba/source/charset.c	Sun Aug 31 12:51:23 1997
@@ -28,6 +28,7 @@
  * Codepage definitions.
  */
 
+#if !defined(KANJI)
 /* lower->upper mapping for IBM Code Page 850 - MS-DOS Latin 1 */
 unsigned char cp_850[][4] = {
 /* dec col/row oct hex  description */
@@ -95,73 +96,12 @@
   {0x9C,0,0,0},     /* Pound        */
   {0,0,0,0}
 };
- 
-/* lower->upper mapping for IBM Code Page 437 - MS-DOS Latin US */
-unsigned char cp_437[][4] = {
-/* 135  08/07  207  87  c cedilla */
-/* 128  08/00  200  80  C cedilla */	{0x87,0x80,1,1},
-/* 129  08/01  201  81  u diaeresis */
-/* 154  09/10  232  9A  U diaeresis */	{0x81,0x9A,1,1},
-/* 130  08/02  202  82  e acute */
-/* 144  09/00  220  90  E acute */	{0x82,0x90,1,1},
-/* 131  08/03  203  83  a circumflex */ {0x83,0x41,1,0},
-/* 132  08/04  204  84  a diaeresis */
-/* 142  08/14  216  8E  A diaeresis */	{0x84,0x8E,1,1},
-/* 133  08/05  205  85  a grave */      {0x85,0x41,1,0},
-/* 134  08/06  206  86  a ring */       {0x86,0x8F,1,1},
-/* 136  08/08  210  88  e circumflex */ {0x88,0x45,1,0},
-/* 137  08/09  211  89  e diaeresis */  {0x89,0x45,1,0},
-/* 138  08/10  212  8A  e grave */      {0x8A,0x45,1,0},
-/* 139  08/11  213  8B  i diaeresis */  {0x8B,0x49,1,0},
-/* 140  08/12  214  8C  i circumflex */ {0x8C,0x49,1,0},
-/* 141  08/13  215  8D  i grave */      {0x8D,0x49,1,0},
-/* 145  09/01  221  91  ae diphthong */
-/* 146  09/02  222  92  AE diphthong */	{0x91,0x92,1,1},
-/* 147  09/03  223  93  o circumflex */ {0x93,0x4F,1,0},
-/* 148  09/04  224  94  o diaeresis */
-/* 153  09/09  231  99  O diaeresis */	{0x94,0x99,1,1},
-/* 149  09/05  225  95  o grave */      {0x95,0x4F,1,0},
-/* 150  09/06  226  96  u circumflex */ {0x96,0x55,1,0},
-/* 151  09/07  227  97  u grave */      {0x97,0x55,1,0},
-/* 152  ??/??  201  98  u diaeresis */
-  {0x9B,0,0,0},     /* Cent         */
-  {0x9C,0,0,0},     /* Pound        */
-  {0x9D,0,0,0},     /* Yen          */
-/* 160  10/00  240  A0  a acute */      {0xA0,0x41,1,0},
-/* 161  10/01  241  A1  i acute */      {0xA1,0x49,1,0},
-/* 162  10/02  242  A2  o acute */      {0xA2,0x4F,1,0},
-/* 163  10/03  243  A3  u acute */      {0xA3,0x55,1,0},
-/* 164  10/04  244  A4  n tilde */
-/* 165  10/05  245  A5  N tilde */	{0xA4,0xA5,1,1},
-/* Punctuation... */
-  {0xA8,0,0,0}, 
-  {0xAD,0,0,0},
-  {0xAE,0,0,0},
-  {0xAF,0,0,0},
-/* Greek character set */
-  {0xE0,0,0,0},
-  {0xE1,0,0,0},
-  {0xE2,0,0,0},
-  {0xE3,0,0,0},
-  {0xE4,0,0,0},
-  {0xE5,0,0,0},
-  {0xE6,0,0,0},
-  {0xE7,0,0,0},
-  {0xE8,0,0,0},
-  {0xE9,0,0,0},
-  {0xEA,0,0,0},
-  {0xEB,0,0,0},
-  {0xEC,0,0,0},
-  {0xED,0,0,0},
-  {0xEE,0,0,0},
-  {0xEF,0,0,0},
-  {0,0,0,0}
-};
-
+#else /* KANJI */ 
 /* lower->upper mapping for IBM Code Page 932 - MS-DOS Japanese SJIS */
 unsigned char cp_932[][4] = {
   {0,0,0,0}
 };
+#endif /* KANJI */
  
 char xx_dos_char_map[256];
 char xx_upper_char_map[256];
@@ -231,12 +171,152 @@
 }
 
 /****************************************************************************
+load the client codepage.
+****************************************************************************/
+
+typedef unsigned char (*codepage_p)[4];
+
+static codepage_p load_client_codepage( int client_codepage )
+{
+  pstring codepage_file_name;
+  unsigned char buf[8];
+  FILE *fp = NULL;
+  unsigned int size;
+  codepage_p cp_p = NULL;
+  struct stat st;
+
+  DEBUG(5, ("load_client_codepage: loading codepage %d.\n", client_codepage));
+
+  if(strlen(CODEPAGEDIR) + 14 > sizeof(codepage_file_name))
+  {
+    DEBUG(0,("load_client_codepage: filename too long to load\n"));
+    return NULL;
+  }
+
+  strcpy(codepage_file_name, CODEPAGEDIR);
+  strcat(codepage_file_name, "/");
+  strcat(codepage_file_name, "codepage.");
+  sprintf( &codepage_file_name[strlen(codepage_file_name)], "%03d",
+           client_codepage);
+
+  if(!file_exist(codepage_file_name,&st))
+  {
+    DEBUG(0,("load_client_codepage: filename %s does not exist.\n",
+              codepage_file_name));
+    return NULL;
+  }
+
+  /* Check if it is at least big enough to hold the required
+     data. Should be 2 byte version, 2 byte codepage, 4 byte length, 
+     plus zero or more bytes of data. Note that the data cannot be more
+     than 512 bytes - giving a max size of 520.
+   */
+  size = (unsigned int)st.st_size;
+
+  if( size < CODEPAGE_HEADER_SIZE || size > (CODEPAGE_HEADER_SIZE + 256))
+  {
+    DEBUG(0,("load_client_codepage: file %s is an incorrect size for a \
+code page file.\n", codepage_file_name));
+    return NULL;
+  }
+
+  /* Read the first 8 bytes of the codepage file - check
+     the version number and code page number. All the data
+     is held in little endian format.
+   */
+
+  if((fp = fopen( codepage_file_name, "r")) == NULL)
+  {
+    DEBUG(0,("load_client_codepage: cannot open file %s. Error was %s\n",
+              codepage_file_name, strerror(errno)));
+    return NULL;
+  }
+
+  if(fread( buf, 1, CODEPAGE_HEADER_SIZE, fp)!=CODEPAGE_HEADER_SIZE)
+  {
+    DEBUG(0,("load_client_codepage: cannot read header from file %s. Error was %s\n",
+              codepage_file_name, strerror(errno)));
+    goto clean_and_exit;
+  }
+
+  /* Check the version value */
+  if(SVAL(buf,CODEPAGE_VERSION_OFFSET) != CODEPAGE_FILE_VERSION_ID)
+  {
+    DEBUG(0,("load_client_codepage: filename %s has incorrect version id. \
+Needed %hu, got %hu.\n", 
+          codepage_file_name, (uint16)CODEPAGE_FILE_VERSION_ID, 
+          SVAL(buf,CODEPAGE_VERSION_OFFSET)));
+    goto clean_and_exit;
+  }
+
+  /* Check the codepage matches */
+  if(SVAL(buf,CODEPAGE_CLIENT_CODEPAGE_OFFSET) != (uint16)client_codepage)
+  {
+    DEBUG(0,("load_client_codepage: filename %s has incorrect codepage. \
+Needed %hu, got %hu.\n", 
+           codepage_file_name, (uint16)client_codepage, 
+           SVAL(buf,CODEPAGE_CLIENT_CODEPAGE_OFFSET)));
+    goto clean_and_exit;
+  }
+
+  /* Check the length is correct. */
+  if(IVAL(buf,CODEPAGE_LENGTH_OFFSET) != 
+                 (unsigned int)(size - CODEPAGE_HEADER_SIZE))
+  {
+    DEBUG(0,("load_client_codepage: filename %s has incorrect size headers. \
+Needed %u, got %u.\n", codepage_file_name, size - CODEPAGE_HEADER_SIZE, 
+               IVAL(buf,CODEPAGE_LENGTH_OFFSET)));
+    goto clean_and_exit;
+  }
+
+  size -= CODEPAGE_HEADER_SIZE; /* Remove header */
+
+  /* Make sure the size is a multiple of 4. */
+  if((size % 4 ) != 0)
+  {
+    DEBUG(0,("load_client_codepage: filename %s has a codepage size not a \
+multiple of 4.\n", codepage_file_name));
+    goto clean_and_exit;
+  }
+
+  /* Allocate space for the code page file and read it all in. */
+  if((cp_p = (codepage_p)malloc( size  + 4 )) == NULL)
+  {
+    DEBUG(0,("load_client_codepage: malloc fail.\n"));
+    goto clean_and_exit;
+  }
+
+  if(fread( (char *)cp_p, 1, size, fp)!=size)
+  {
+    DEBUG(0,("load_client_codepage: read fail on file %s. Error was %s.\n",
+              codepage_file_name, strerror(errno)));
+    goto clean_and_exit;
+  }
+
+  /* Ensure array is correctly terminated. */
+  memset(((char *)cp_p) + size, '\0', 4);
+
+  fclose(fp);
+  return cp_p;
+
+clean_and_exit:
+
+  /* pseudo destructor :-) */
+
+  if(fp != NULL)
+    fclose(fp);
+  if(cp_p)
+    free((char *)cp_p);
+  return NULL;
+}
+
+/****************************************************************************
 initialise the client codepage.
 ****************************************************************************/
 void codepage_initialise(int client_codepage)
 {
   int i;
-  unsigned char (*cp)[4] = NULL;
+  codepage_p cp = NULL;
   static BOOL done = False;
 
   if(done == True) 
@@ -252,35 +332,26 @@
   /*
    * Known client codepages - these can be added to.
    */
-  switch(client_codepage)
+  cp = load_client_codepage( client_codepage );
+
+  if(cp == NULL)
   {
-    case 850:
-      cp = cp_850;
-      break;
-    case 437:
-      cp = cp_437;
-      break;
-    case 932:
-      cp = cp_932;
-      break;
-    default:
 #ifdef KANJI
-      /* Use default codepage - currently 932 */
-      DEBUG(6,("codepage_initialise: Using default client codepage %d\n", 
-               932));
+    DEBUG(6,("codepage_initialise: loading dynamic codepage file %s/codepage.%d \
+for code page %d failed. Using default client codepage 932\n", 
+             CODEPAGEDIR, client_codepage, client_codepage));
       cp = cp_932;
 #else /* KANJI */
-      /* Use default codepage - currently 850 */
-      DEBUG(6,("codepage_initialise: Using default client codepage %d\n", 
-               850));
+    DEBUG(6,("codepage_initialise: loading dynamic codepage file %s/codepage.%d \
+for code page %d failed. Using default client codepage 850\n", 
+             CODEPAGEDIR, client_codepage, client_codepage));
       cp = cp_850;
 #endif /* KANJI */
-      break;
   }
 
   if(cp)
   {
-    for(i = 0; (cp[i][0] != '\0') && (cp[i][1] != '\0'); i++)
+    for(i = 0; !((cp[i][0] == '\0') && (cp[i][1] == '\0')); i++)
       add_dos_char(cp[i][0], (BOOL)cp[i][2], cp[i][1], (BOOL)cp[i][3]);
   }
 
diff -u -w samba-1.9.17/source/charset.h samba-1/samba/source/charset.h
--- samba-1.9.17/source/charset.h	Fri Jul 18 21:44:43 1997
+++ samba-1/samba/source/charset.h	Sun Aug 31 12:51:24 1997
@@ -63,3 +63,13 @@
 #define issafe(c) (isalnum((c&0xff)) || strchr("-._",c))
 #endif
 
+/* Dynamic codepage files defines. */
+
+/* Version id for dynamically loadable codepage files. */
+#define CODEPAGE_FILE_VERSION_ID 0x1
+/* Version 1 codepage file header size. */
+#define CODEPAGE_HEADER_SIZE 8
+/* Offsets for codepage file header entries. */
+#define CODEPAGE_VERSION_OFFSET 0
+#define CODEPAGE_CLIENT_CODEPAGE_OFFSET 2
+#define CODEPAGE_LENGTH_OFFSET 4
diff -u -w samba-1.9.17/source/clientutil.c samba-1/samba/source/clientutil.c
--- samba-1.9.17/source/clientutil.c	Thu Jul 31 19:55:08 1997
+++ samba-1/samba/source/clientutil.c	Sun Aug 31 12:51:24 1997
@@ -428,6 +428,12 @@
   else
     pass = (char *)getpass("Password: ");
 
+  if(pass == NULL)
+  {
+    DEBUG(0, ("cli_send_login : no password available - logon failed.\n"));
+    return False;
+  }
+
   if (Protocol >= PROTOCOL_LANMAN1 && use_setup)
     {
       fstring pword;
diff -u -w samba-1.9.17/source/clitar.c samba-1/samba/source/clitar.c
--- samba-1.9.17/source/clitar.c	Mon Jul 28 20:06:18 1997
+++ samba-1/samba/source/clitar.c	Thu Aug 28 18:36:52 1997
@@ -376,8 +376,7 @@
 if s1 is an "initial" string (up to directory marker).  Thus, if s2 is 
 a file in any subdirectory of s1, declare a match.
 ***************************************************************************/
-static
-int strslashcmp(char *s1, char *s2)
+static int strslashcmp(char *s1, char *s2)
 {
   char *s1_0=s1;
 
diff -u -w samba-1.9.17/source/includes.h samba-1/samba/source/includes.h
--- samba-1.9.17/source/includes.h	Wed Aug 20 02:11:54 1997
+++ samba-1/samba/source/includes.h	Sun Aug 31 12:51:25 1997
@@ -308,7 +308,9 @@
 #define USE_STATVFS
 #define USE_GETCWD
 #define USE_SETSID
+#ifndef REPLACE_GETPASS
 #define REPLACE_GETPASS
+#endif /* REPLACE_GETPASS */
 #define USE_SIGPROCMASK
 #endif
 
@@ -459,7 +461,9 @@
 #define NO_FSYNC
 #define USE_GETCWD
 #define USE_SETSID
+#ifndef REPLACE_GETPASS
 #define REPLACE_GETPASS
+#endif /* REPLACE_GETPASS */
 #define NO_GETRLIMIT
 #endif	/* CLIX */
 
diff -u -w samba-1.9.17/source/ipc.c samba-1/samba/source/ipc.c
--- samba-1.9.17/source/ipc.c	Wed Aug 20 02:11:54 1997
+++ samba-1/samba/source/ipc.c	Sun Aug 31 12:52:46 1997
@@ -480,7 +480,7 @@
   /* the client expects localtime */
   t -= TimeDiff(t);
 
-  PACKI(desc,"W",((snum%0xFF)<<8) | (queue->job%0xFF)); /* uJobId */
+  PACKI(desc,"W",printjob_encode(snum, queue->job)); /* uJobId */
   if (uLevel == 1) {
     PACKS(desc,"B21",queue->user); /* szUserName */
     PACKS(desc,"B","");		/* pad */
@@ -1405,11 +1405,10 @@
   char *str1 = param+2;
   char *str2 = skip_string(str1,1);
   char *p = skip_string(str2,1);
-  int jobid = (SVAL(p,0)&0xFF); /* the snum and jobid are encoded
-				   by the print queue api */
-  int snum = (SVAL(p,0)>>8);  
+  int jobid, snum;
   int i, count;
 
+  printjob_decode(SVAL(p,0), &snum, &jobid);
 
   /* check it's a supported varient */
   if (!(strcsequal(str1,"W") && strcsequal(str2,"")))
@@ -1429,7 +1428,7 @@
       count = get_printqueue(snum,cnum,&queue,NULL);
   
       for (i=0;i<count;i++)
-  	if ((queue[i].job%0xFF) == jobid)
+  	if ((queue[i].job&0xFF) == jobid)
   	  {
  	    switch (function) {
 	    case 81:		/* delete */ 
@@ -1538,14 +1537,14 @@
   char *str1 = param+2;
   char *str2 = skip_string(str1,1);
   char *p = skip_string(str2,1);
-  int jobid = (SVAL(p,0)&0xFF); /* the snum and jobid are encoded
- 				   by the print queue api */
-  int snum = (SVAL(p,0)>>8);
+  int jobid, snum;
   int uLevel = SVAL(p,2);
   int function = SVAL(p,4);	/* what is this ?? */
   int i;
   char *s = data;
    
+  printjob_decode(SVAL(p,0), &snum, &jobid);
+   
   *rparam_len = 4;
   *rparam = REALLOC(*rparam,*rparam_len);
   
@@ -1565,7 +1564,7 @@
 	lpq_reset(snum);
 	count = get_printqueue(snum,cnum,&queue,NULL);
 	for (i=0;i<count;i++)	/* find job */
-	  if ((queue[i].job%0xFF) == jobid) break;
+	  if ((queue[i].job&0xFF) == jobid) break;
  	    
 	if (i==count) {
 	  desc.errcode=NERR_JobNotFound;
@@ -2317,7 +2316,6 @@
   char *str1 = param+2;
   char *str2 = skip_string(str1,1);
   char *p = skip_string(str2,1);
-  int uJobId = SVAL(p,0);
   int uLevel,cbBuf;
   int count;
   int i;
@@ -2333,20 +2331,19 @@
   bzero(&desc,sizeof(desc));
   bzero(&status,sizeof(status));
 
-  DEBUG(3,("WPrintJobGetInfo uLevel=%d uJobId=0x%X\n",uLevel,uJobId));
+  DEBUG(3,("WPrintJobGetInfo uLevel=%d uJobId=0x%X\n",uLevel,SVAL(p,0)));
 
   /* check it's a supported varient */
   if (strcmp(str1,"WWrLh") != 0) return False;
   if (!check_printjob_info(&desc,uLevel,str2)) return False;
 
-  snum = (unsigned int)uJobId >> 8; /*## valid serice number??*/
-  job = uJobId & 0xFF;
+  printjob_decode(SVAL(p,0), &snum, &job);
 
   if (snum < 0 || !VALID_SNUM(snum)) return(False);
 
   count = get_printqueue(snum,cnum,&queue,&status);
   for (i = 0; i < count; i++) {
-    if ((queue[i].job % 0xFF) == job) break;
+    if ((queue[i].job & 0xFF) == job) break;
   }
   if (mdrcnt > 0) *rdata = REALLOC(*rdata,mdrcnt);
   desc.base = *rdata;
diff -u -w samba-1.9.17/source/mangle.c samba-1/samba/source/mangle.c
--- samba-1.9.17/source/mangle.c	Thu May  8 17:35:38 1997
+++ samba-1/samba/source/mangle.c	Thu Aug 28 20:20:22 1997
@@ -414,9 +414,9 @@
   while (*start) {
     while ((*start) && (*start != '('))
       start++;
-    start++;                    /* Skip the ( */
     if (!*start)
       continue;                 /* Always check for the end. */
+    start++;                    /* Skip the ( */
     end = start;                /* Search for the ' ' or a ')' */
     DEBUG(5,("Start of first in pair '%s'\n", start));
     while ((*end) && !((*end == ' ') || (*end == ')')))
diff -u -w samba-1.9.17/source/mkproto.awk samba-1/samba/source/mkproto.awk
--- samba-1.9.17/source/mkproto.awk	Fri Aug 16 13:55:54 1996
+++ samba-1/samba/source/mkproto.awk	Sun Aug 31 12:52:59 1997
@@ -64,7 +64,7 @@
   next;
 }
 
-!/^unsigned|^mode_t|^DIR|^user|^int|^char|^uint|^struct|^BOOL|^void|^time|^shm_offset_t/ {
+!/^unsigned|^mode_t|^DIR|^user|^int|^char|^uint|^struct|^BOOL|^void|^time|^smb_shm_offset_t|^shm_offset_t/ {
   next;
 }
 
diff -u -w samba-1.9.17/source/nameannounce.c samba-1/samba/source/nameannounce.c
--- samba-1.9.17/source/nameannounce.c	Thu Jul 31 19:55:13 1997
+++ samba-1/samba/source/nameannounce.c	Thu Sep  4 11:59:30 1997
@@ -430,7 +430,7 @@
                     NMB_QUERY,NAME_QUERY_DOM_SRV_CHK,
                     name, type, 0,0,0,
                     work->work_group,NULL,
-                    False, True, ipzero, ipzero);
+                    ipzero, ipzero);
         }
       else if(lp_wins_support()) 
         {
diff -u -w samba-1.9.17/source/namepacket.c samba-1/samba/source/namepacket.c
--- samba-1.9.17/source/namepacket.c	Tue Aug 26 02:00:10 1997
+++ samba-1/samba/source/namepacket.c	Mon Sep  1 18:36:57 1997
@@ -183,10 +183,12 @@
 
 
 /****************************************************************************
-  reply to a netbios name packet 
+  reply to a netbios name packet.  see rfc1002.txt
   ****************************************************************************/
 void reply_netbios_packet(struct packet_struct *p1,int trn_id,
-				int rcode, int rcv_code, int opcode, BOOL recurse,
+				int rcode, int rcv_code, int opcode,
+                BOOL recursion_available,
+                BOOL recursion_desired,
 				struct nmb_name *rr_name,int rr_type,int rr_class,int ttl,
 				char *data,int len)
 {
@@ -197,6 +199,11 @@
   
   p = *p1;
 
+  if (recursion_available && lp_wins_server())
+  {
+    DEBUG(0,("reply_netbios_packet: r_a not to be used when not a WINS server\n"));
+  }
+
   switch (rcv_code)
   {
     case NMB_STATUS:
@@ -240,8 +247,8 @@
   nmb->header.opcode = opcode;
   nmb->header.response = True;
   nmb->header.nm_flags.bcast = False;
-  nmb->header.nm_flags.recursion_available = (lp_wins_support() ? True : False );
-  nmb->header.nm_flags.recursion_desired = (lp_wins_support() ? recurse : False );
+  nmb->header.nm_flags.recursion_available = recursion_available;
+  nmb->header.nm_flags.recursion_desired = recursion_desired;
   nmb->header.nm_flags.trunc = False;
   nmb->header.nm_flags.authoritative = True;
   
diff -u -w samba-1.9.17/source/nameresp.c samba-1/samba/source/nameresp.c
--- samba-1.9.17/source/nameresp.c	Wed Aug 13 00:37:31 1997
+++ samba-1/samba/source/nameresp.c	Thu Sep  4 11:59:30 1997
@@ -117,7 +117,7 @@
       
       add_name_respond(d,n->fd,d->myip, n->response_id ,&n->name,
 		       n->nb_flags, GET_TTL(0),
-		       n->reply_to_ip, False, n->reply_to_ip);
+		       n->reply_to_ip, True, n->reply_to_ip);
       
       if (!n->bcast && n->num_msgs == 0)
 	{
@@ -250,7 +250,6 @@
 				int fd,int quest_type,enum state_type state,
 			    char *name,int name_type,int nb_flags, time_t ttl,
 				int server_type, char *my_name, char *my_comment,
-			    BOOL bcast,BOOL recurse,
 				struct in_addr send_ip, struct in_addr reply_to_ip)
 {
   /* XXXX note: please see rfc1001.txt section 10 for details on this
@@ -267,7 +266,6 @@
 
       if (!zero_ip(real_wins_ip))
 	{
-	  bcast = False;
 	  send_ip = real_wins_ip;
 	}
       else
@@ -283,7 +281,7 @@
   return queue_netbios_packet(wins_subnet,fd, quest_type, state, 
 		       name, name_type, nb_flags, ttl,
                server_type,my_name,my_comment,
-		       bcast, recurse, send_ip, reply_to_ip);
+		       False, True, send_ip, reply_to_ip);
 }
 
 
diff -u -w samba-1.9.17/source/nameserv.c samba-1/samba/source/nameserv.c
--- samba-1.9.17/source/nameserv.c	Thu Jul 31 19:55:17 1997
+++ samba-1/samba/source/nameserv.c	Thu Sep  4 11:59:30 1997
@@ -103,7 +103,7 @@
       /* not a WINS server: we have to release them on the network */
       queue_netbios_pkt_wins(ClientNMB,NMB_REL,NAME_RELEASE,
 			     name, type, 0, 0,0,NULL,NULL,
-			     False, True, ipzero, ipzero);
+			     ipzero, ipzero);
     }
   }
   else
@@ -163,7 +163,7 @@
   	  queue_netbios_pkt_wins(ClientNMB,
 				 re_reg ? NMB_REG_REFRESH : NMB_REG, NAME_REGISTER,
 			     name, type, nb_flags, GET_TTL(0),0,NULL,NULL,
-			     False, True, ipzero, ipzero);
+			     ipzero, ipzero);
     }
   }
   else
@@ -308,7 +308,7 @@
 									   NAME_QUERY_DOMAIN,
 									   myworkgroup, 0x1b,
 									   0, 0,0,NULL,NULL,
-									   False, True, ipzero, ipzero);
+									   ipzero, ipzero);
 			}
 		}
 	}
diff -u -w samba-1.9.17/source/nameservreply.c samba-1/samba/source/nameservreply.c
--- samba-1.9.17/source/nameservreply.c	Wed Aug 13 00:37:32 1997
+++ samba-1/samba/source/nameservreply.c	Thu Sep  4 11:59:35 1997
@@ -42,7 +42,8 @@
 send a registration / release response: pos/neg
 **************************************************************************/
 static void send_name_response(int fd, struct in_addr from_ip,
-				int name_trn_id, int opcode, BOOL success, BOOL recurse,
+				int name_trn_id, int opcode, BOOL success,
+                BOOL recursion_available, BOOL recursion_desired,
 				struct nmb_name *reply_name, int nb_flags, int ttl,
 				struct in_addr ip)
 {
@@ -56,7 +57,7 @@
     /* NEGATIVE RESPONSE */
     rcode = 6;
   }
-  else if (opcode == NMB_REG && recurse == False)
+  else if (opcode == NMB_REG && !recursion_available)
   {
     /* END-NODE CHALLENGE REGISTRATION RESPONSE */
 	rcode = 0;
@@ -73,7 +74,8 @@
   p.packet_type = NMB_PACKET;
 
   reply_netbios_packet(&p,name_trn_id,
-		       rcode,opcode,opcode,recurse,
+		       rcode,opcode,opcode,
+               recursion_available, recursion_desired,
 		       reply_name, 0x20, 0x1,
 		       ttl, 
 		       rdata, 6);
@@ -93,8 +95,10 @@
                     nb_flags,ttl,REGISTER,register_ip,False,True);
 
   /* reply yes or no to the host that requested the name */
+  /* see rfc1002.txt - 4.2.10 and 4.2.11 */
   send_name_response(fd,from_ip, response_id, NMB_REG,
-                     new_owner, False,
+                     new_owner,
+                     True, True,
                      name, nb_flags, ttl, reply_to_ip);
 }
 
@@ -160,7 +164,7 @@
   
   /* Send a NAME RELEASE RESPONSE (pos/neg) see rfc1002.txt 4.2.10-11 */
   send_name_response(p->fd,p->ip, nmb->header.name_trn_id, NMB_REL,
-		     success, nmb->header.nm_flags.recursion_desired,
+		     success, False, False,
 		     &nmb->question.question_name, nb_flags, 0, ip);
 }
 
@@ -301,7 +305,8 @@
 
     /* send WAIT ACKNOWLEDGEMENT see rfc1002.txt 4.2.16 */
     reply_netbios_packet(p,nmb->header.name_trn_id,
-		       0,NMB_WAIT_ACK,NMB_WAIT_ACK,False,
+		       0,NMB_WAIT_ACK,NMB_WAIT_ACK,
+               False,False,
 		       reply_name, 0x0a, 0x01,
 		       15*1000, /* 15 seconds long enough to wait? */
 		       rdata, 2);
@@ -311,16 +316,18 @@
 			 NAME_REGISTER_CHALLENGE,
 			 reply_name->name,reply_name->name_type,
 	                 nb_flags,0,0,NULL,NULL,
-			 False, False, n->ip_flgs[0].ip, p->ip);
+			 False, False,
+             n->ip_flgs[0].ip, p->ip);
   }
   else
   {
-    /* Send a NAME REGISTRATION RESPONSE (pos/neg) see rfc1002.txt 4.2.13-14
+    /* Send a NAME REGISTRATION RESPONSE (pos/neg) see rfc1002.txt 4.2.5-6
        or an END-NODE CHALLENGE REGISTRATION RESPONSE see rfc1002.txt 4.2.7
      */
 
   	send_name_response(p->fd,p->ip, nmb->header.name_trn_id, NMB_REG,
-			success, nmb->header.nm_flags.recursion_desired,
+			success,
+            True, True,
 			reply_name, nb_flags, ttl, ip);
   }
 }
@@ -471,7 +478,7 @@
   
   /* Send a POSITIVE NAME STATUS RESPONSE */
   reply_netbios_packet(p,nmb->header.name_trn_id,
-			   0,NMB_STATUS,0,True,
+			   0,NMB_STATUS,0,False, False,
 		       &nmb->question.question_name,
 		       0x21, 0x01,
 		       0, rdata,PTR_DIFF(buf,rdata));
@@ -507,7 +514,10 @@
   struct nmb_packet *nmb = &p->packet.nmb;
   struct nmb_name *question = &nmb->question.question_name;
   int name_type = question->name_type;
+
   BOOL bcast = nmb->header.nm_flags.bcast;
+  BOOL query_is_to_wins_server = (!bcast && 
+             nmb->header.nm_flags.recursion_desired);
   int ttl=0;
   int rcode = 0;
   int nb_flags = 0;
@@ -516,26 +526,31 @@
   struct subnet_record *d = NULL;
   BOOL success = True;
   struct name_record *n = NULL;
+  BOOL acting_as_wins_server = lp_wins_support();
 
   /* directed queries are for WINS server: broadcasts are local SELF queries.
      the exception is Domain Master names.  */
 
-  int search = bcast ? FIND_LOCAL | FIND_WINS: FIND_WINS;
-
-  if (search & FIND_LOCAL)
+  if (query_is_to_wins_server)
   {
-    if (!(d = find_req_subnet(p->ip, bcast)))
+    /* queries to the WINS server involve the WINS server subnet */
+    if (!(d = wins_subnet))
     {
-      DEBUG(3,("name query: bcast %s not known\n",
+      DEBUG(3,("name query: wins search %s not known\n",
 				    inet_ntoa(p->ip)));
       success = False;
     }
   }
   else
   {
-    if (!(d = wins_subnet))
+    /* queries to the WINS client involve, unfortunately, the WINS subnet
+       because it contains WINS client (SELF) entries, as _well_ as WINS
+       server entries.  not good.
+     */
+
+    if (!(d = find_subnet(*iface_bcast(p->ip))))
     {
-      DEBUG(3,("name query: wins search %s not known\n",
+      DEBUG(3,("name query: interface for %s not known\n",
 				    inet_ntoa(p->ip)));
       success = False;
     }
@@ -544,12 +559,6 @@
   DEBUG(3,("Name query from %s for name %s<0x%x>\n", 
                   inet_ntoa(p->ip), question->name, question->name_type));
   
-  if (search == 0)
-  {
-    /* eh? no criterion for searching database. help! */
-    success = False;
-  }
-
   if (!bcast && (name_type == 0x1d) && lp_wins_support())
   {
     /* see WINS manager HELP - 'How WINS Handles Special Names' */
@@ -560,7 +569,7 @@
   if (success)
   {
     /* look up the name in the cache */
-    n = find_name_search(&d, question, search, p->ip);
+    n = find_name_search(&d, question, FIND_LOCAL, p->ip);
 
     /* it is a name that already failed DNS lookup or it's expired */
     if (n && (n->source == DNSFAIL ||
@@ -644,8 +653,13 @@
       putip(&rdata[2],(char *)&retip);
   }
   
+  /* see rfc1002.txt 4.2.13 */
+
   reply_netbios_packet(p,nmb->header.name_trn_id,
-			   rcode,NMB_QUERY,0,True,
+     rcode,NMB_QUERY,0,
+     (query_is_to_wins_server && acting_as_wins_server ? 
+              True : False), /* recursion_available flag */
+     True, /* recursion_desired_flag */ 
 		       &nmb->question.question_name,
                0x20, 0x01,
 		       ttl,
diff -u -w samba-1.9.17/source/nmbsync.c samba-1/samba/source/nmbsync.c
--- samba-1.9.17/source/nmbsync.c	Tue Aug 26 02:00:10 1997
+++ samba-1/samba/source/nmbsync.c	Sun Aug 31 12:51:34 1997
@@ -20,6 +20,8 @@
    
 */
 
+/* We *must have REPLACE_GETPASS defined here before the includes. */
+#define REPLACE_GETPASS
 #include "includes.h"
 
 extern int ClientNMB;
diff -u -w samba-1.9.17/source/printing.c samba-1/samba/source/printing.c
--- samba-1.9.17/source/printing.c	Thu May  8 17:35:40 1997
+++ samba-1/samba/source/printing.c	Sun Aug 31 12:51:34 1997
@@ -929,7 +929,7 @@
   
   if (!printername || !*printername)
     {
-      DEBUG(6,("replacing printer name with service (snum=(%s,%d))\n",
+      DEBUG(6,("xx replacing printer name with service (snum=(%s,%d))\n",
 	    lp_servicename(snum),snum));
       printername = lp_servicename(snum);
     }
@@ -1080,3 +1080,23 @@
 }
 
 
+
+/****************************************************************************
+we encode print job numbers over the wire so that when we get them back we can
+tell not only what print job they are but also what service it belongs to,
+this is to overcome the problem that windows clients tend to send the wrong
+service number when doing print queue manipulation!
+****************************************************************************/
+int printjob_encode(int snum, int job)
+{
+	return ((snum&0xFF)<<8) | (job & 0xFF);
+}
+
+/****************************************************************************
+and now decode them again ...
+****************************************************************************/
+void printjob_decode(int jobid, int *snum, int *job)
+{
+	(*snum) = (jobid >> 8) & 0xFF;
+	(*job) = jobid & 0xFF;
+}
diff -u -w samba-1.9.17/source/proto.h samba-1/samba/source/proto.h
--- samba-1.9.17/source/proto.h	Fri Aug 22 05:35:23 1997
+++ samba-1/samba/source/proto.h	Thu Sep  4 11:59:36 1997
@@ -146,6 +146,7 @@
 char *lp_interfaces(void);
 char *lp_socket_address(void);
 char *lp_nis_home_map_name(void);
+char *lp_announce_version(void);
 char *lp_netbios_aliases(void);
 BOOL lp_dns_proxy(void);
 BOOL lp_wins_support(void);
@@ -189,6 +190,7 @@
 int lp_lpqcachetime(void);
 int lp_syslog(void);
 int lp_client_code_page(void);
+int lp_announce_as(void);
 char *lp_preexec(int );
 char *lp_postexec(int );
 char *lp_rootpreexec(int );
@@ -268,10 +270,10 @@
 int lp_numservices(void);
 void lp_dump(void);
 int lp_servicenumber(char *pszServiceName);
+char *volume_label(int snum);
 int lp_default_server_announce(void);
 int lp_major_announce_version(void);
 int lp_minor_announce_version(void);
-char *volume_label(int snum);
 
 /*The following definitions come from  locking.c  */
 
@@ -293,6 +295,18 @@
 void del_share_mode(share_lock_token token, int fnum);
 BOOL set_share_mode(share_lock_token token,int fnum);
 
+/*The following definitions come from  make_smbcodepage.c  */
+
+void codepage_usage(const char *progname);
+void read_line( char **buf, char *line_buf, int size);
+int clean_data( char **buf, uint32 *size);
+BOOL parse_byte(char *buf, unsigned char *bp);
+BOOL parse_bool(char *buf, unsigned char *bp);
+void parse_error(char *buf, char *msg);
+int do_compile(int codepage, const char *input_file, const char *output_file);
+int do_decompile( int codepage, const char *input_file, const char *output_file);
+int main(int argc, char **argv);
+
 /*The following definitions come from  mangle.c  */
 
 int str_checksum(char *s);
@@ -460,7 +474,9 @@
 			     int nb_flags,BOOL bcast,BOOL recurse,
 			     struct in_addr to_ip);
 void reply_netbios_packet(struct packet_struct *p1,int trn_id,
-				int rcode, int rcv_code, int opcode, BOOL recurse,
+				int rcode, int rcv_code, int opcode,
+                BOOL recursion_available,
+                BOOL recursion_desired,
 				struct nmb_name *rr_name,int rr_type,int rr_class,int ttl,
 				char *data,int len);
 void queue_packet(struct packet_struct *packet);
@@ -486,7 +502,6 @@
 				int fd,int quest_type,enum state_type state,
 			    char *name,int name_type,int nb_flags, time_t ttl,
 				int server_type, char *my_name, char *my_comment,
-			    BOOL bcast,BOOL recurse,
 				struct in_addr send_ip, struct in_addr reply_to_ip);
 struct response_record *queue_netbios_packet(struct subnet_record *d,
 			int fd,int quest_type,enum state_type state,char *name,
@@ -613,6 +628,8 @@
 		   print_status_struct *status);
 void del_printqueue(int cnum,int snum,int jobid);
 void status_printjob(int cnum,int snum,int jobid,int status);
+int printjob_encode(int snum, int job);
+void printjob_decode(int jobid, int *snum, int *job);
 
 /*The following definitions come from  quotas.c  */
 
@@ -620,6 +637,7 @@
 BOOL disk_quotas(char *path, int *bsize, int *dfree, int *dsize);
 BOOL disk_quotas(char *path, int *bsize, int *dfree, int *dsize);
 BOOL disk_quotas(char *path, int *bsize, int *dfree, int *dsize);
+BOOL disk_quotas(char *path, int *bsize, int *dfree, int *dsize);
 
 /*The following definitions come from  replace.c  */
 
@@ -726,22 +744,22 @@
 BOOL yield_connection(int cnum,char *name,int max_connections);
 BOOL claim_connection(int cnum,char *name,int max_connections,BOOL Clear);
 void exit_server(char *reason);
-void standard_sub(int cnum,char *string);
+void standard_sub(int cnum,char *str);
 char *smb_fn_name(int type);
 int chain_reply(char *inbuf,char *outbuf,int size,int bufsize);
 int construct_reply(char *inbuf,char *outbuf,int size,int bufsize);
 
 /*The following definitions come from  shmem.c  */
 
-smb_shm_offset_t smb_shm_alloc(int size);
-smb_shm_offset_t smb_shm_addr2offset(void *addr);
-smb_shm_offset_t smb_shm_get_userdef_off(void);
 BOOL smb_shm_create_hash_table( unsigned int size );
 BOOL smb_shm_open( char *file_name, int size);
 BOOL smb_shm_close( void );
+smb_shm_offset_t smb_shm_alloc(int size);
 BOOL smb_shm_free(smb_shm_offset_t offset);
+smb_shm_offset_t smb_shm_get_userdef_off(void);
 BOOL smb_shm_set_userdef_off(smb_shm_offset_t userdef_off);
 void * smb_shm_offset2addr(smb_shm_offset_t offset);
+smb_shm_offset_t smb_shm_addr2offset(void *addr);
 BOOL smb_shm_lock_hash_entry( unsigned int entry);
 BOOL smb_shm_unlock_hash_entry( unsigned int entry );
 BOOL smb_shm_get_usage(int *bytes_free,
@@ -951,7 +969,7 @@
 void reset_globals_after_fork();
 char *client_name(void);
 char *client_addr(void);
-void standard_sub_basic(char *string);
+void standard_sub_basic(char *str);
 BOOL same_net(struct in_addr ip1,struct in_addr ip2,struct in_addr mask);
 int PutUniCode(char *dst,char *src);
 struct hostent *Get_Hostbyname(char *name);
diff -u -w samba-1.9.17/source/reply.c samba-1/samba/source/reply.c
--- samba-1.9.17/source/reply.c	Fri Aug 22 05:35:23 1997
+++ samba-1/samba/source/reply.c	Thu Sep  4 11:59:37 1997
@@ -261,7 +261,26 @@
   if (connection_num < 0)
     return(connection_error(inbuf,outbuf,connection_num));
 
+  if (Protocol < PROTOCOL_NT1)
+  {
   set_message(outbuf,2,strlen(devicename)+1,True);
+    strcpy(smb_buf(outbuf),devicename);
+  }
+  else
+  {
+    char *fsname = "NTFS";
+    char *p;
+
+    set_message(outbuf,3,3,True);
+
+    p = smb_buf(outbuf);
+    strcpy(p,devicename); p = skip_string(p,1); /* device name */
+    strcpy(p,fsname); p = skip_string(p,1); /* filesystem type e.g NTFS */
+
+    set_message(outbuf,3,PTR_DIFF(p,smb_buf(outbuf)),False);
+
+    SSVAL(outbuf, smb_vwv2, 0x0); /* optional support */
+  }
   
   DEBUG(3,("%s tconX service=%s user=%s cnum=%d\n",timestring(),service,user,connection_num));
   
@@ -269,8 +288,6 @@
   SSVAL(inbuf,smb_tid,connection_num);
   SSVAL(outbuf,smb_tid,connection_num);
 
-  strcpy(smb_buf(outbuf),devicename);
-
   return chain_reply(inbuf,outbuf,length,bufsize);
 }
 
@@ -2463,7 +2480,7 @@
       {
 	put_dos_date2(p,0,queue[i].time);
 	CVAL(p,4) = (queue[i].status==LPQ_PRINTING?2:3);
-	SSVAL(p,5,queue[i].job);
+	SSVAL(p,5,printjob_encode(SNUM(cnum), queue[i].job));
 	SIVAL(p,7,queue[i].size);
 	CVAL(p,11) = 0;
 	StrnCpy(p+12,queue[i].user,16);
diff -u -w samba-1.9.17/source/server.c samba-1/samba/source/server.c
--- samba-1.9.17/source/server.c	Fri Aug 22 05:35:24 1997
+++ samba-1/samba/source/server.c	Thu Sep  4 11:59:38 1997
@@ -397,7 +397,7 @@
       if (!name_map_mangle(name2,False,SNUM(cnum))) continue;
 
       if ((mangled && mangled_equal(name,name2))
-	  || fname_equal(name, dname))
+	  || fname_equal(name, name2)) /* name2 here was changed to dname - since 1.9.16p2 - not sure of reason (jra) */
 	{
 	  /* we've found the file, change it's name and return */
 	  if (docache) DirCacheAdd(path,name,dname,SNUM(cnum));
@@ -1978,12 +1978,26 @@
   {0,0,0}
 };
 
+/* Mapping for old clients. */
+
+struct
+{
+  int new_smb_error;
+  int old_smb_error;
+  int protocol_level;
+  char *valid_remote_arch;
+} old_client_errmap[] =
+{
+  {ERRbaddirectory, ERRbadpath, (int)PROTOCOL_NT1, "WinNT"},
+  {0,0,0}
+};
 
 /****************************************************************************
   create an error packet from errno
 ****************************************************************************/
 int unix_error_packet(char *inbuf,char *outbuf,int def_class,uint32 def_code,int line)
 {
+  extern fstring remote_arch;
   int eclass=def_class;
   int ecode=def_code;
   int i=0;
@@ -2009,6 +2023,29 @@
 	}
     }
 
+  /* Make sure we don't return error codes that old
+     clients don't understand. */
+
+  /* JRA - unfortunately, WinNT needs some error codes
+     for apps to work correctly, Win95 will break if
+     these error codes are returned. But they both
+     negotiate the *same* protocol. So we need to use
+     the revolting 'remote_arch' string to tie break.
+
+     There must be a better way of doing this...
+  */
+
+  for(i = 0; old_client_errmap[i].new_smb_error != 0; i++)
+  {
+    if(((Protocol < old_client_errmap[i].protocol_level) ||
+       !strcsequal( old_client_errmap[i].valid_remote_arch, remote_arch)) &&
+       (old_client_errmap[i].new_smb_error == ecode))
+    {
+      ecode = old_client_errmap[i].old_smb_error;
+      break;
+    }
+  }
+
   return(error_packet(inbuf,outbuf,eclass,ecode,line));
 }
 
@@ -3471,12 +3508,12 @@
 /****************************************************************************
 do some standard substitutions in a string
 ****************************************************************************/
-void standard_sub(int cnum,char *string)
+void standard_sub(int cnum,char *str)
 {
   if (VALID_CNUM(cnum)) {
     char *p, *s, *home;
 
-    for ( s=string ; (p=strchr(s, '%')) != NULL ; s=p ) {
+    for ( s=str ; (p=strchr(s, '%')) != NULL ; s=p ) {
       switch (*(p+1)) {
         case 'H' : if ((home = get_home_dir(Connections[cnum].user))!=NULL)
                      string_sub(p,"%H",home);
@@ -3492,7 +3529,7 @@
       }
     }
   }
-  standard_sub_basic(string);
+  standard_sub_basic(str);
 }
 
 /*
diff -u -w samba-1.9.17/source/trans2.c samba-1/samba/source/trans2.c
--- samba-1.9.17/source/trans2.c	Tue Aug 26 02:29:20 1997
+++ samba-1/samba/source/trans2.c	Sun Aug 31 12:53:09 1997
@@ -341,7 +341,7 @@
 	  strcpy(pathreal,Connections[cnum].dirpath);
           if(needslash)
   	    strcat(pathreal,"/");
-	  strcat(pathreal,fname);
+	  strcat(pathreal,dname);
 	  if (sys_stat(pathreal,&sbuf) != 0) 
 	    {
 	      DEBUG(5,("get_lanman2_dir_entry:Couldn't stat [%s] (%s)\n",pathreal,strerror(errno)));
@@ -368,12 +368,10 @@
 	}
     }
 
-
+  name_map_mangle(fname,False,SNUM(cnum));
 
   p = pdata;
   nameptr = p;
-
-  name_map_mangle(fname,False,SNUM(cnum));
 
   nt_extmode = mode ? mode : NT_FILE_ATTRIBUTE_NORMAL;
 
diff -u -w samba-1.9.17/source/util.c samba-1/samba/source/util.c
--- samba-1.9.17/source/util.c	Tue Aug 26 02:00:10 1997
+++ samba-1/samba/source/util.c	Thu Sep  4 11:59:39 1997
@@ -91,7 +91,11 @@
   if (!interactive) {
     char *p = strrchr(pname,'/');
     if (p) pname = p+1;
+#ifdef LOG_DAEMON
     openlog(pname, LOG_PID, LOG_DAEMON);
+#else /* LOG_DAEMON - for old systems that have no facility codes. */
+    openlog(pname, LOG_PID);
+#endif /* LOG_DAEMON */
   }
 #endif
   if (interactive) {
@@ -3301,13 +3305,13 @@
 Rewritten by Stefaan A Eeckels <Stefaan.Eeckels@ecc.lu> and
 Paul Rippin <pr3245@nopc.eurostat.cec.be>
 ********************************************************************/
-void standard_sub_basic(char *string)
+void standard_sub_basic(char *str)
   {
   char *s, *p;
     char pidstr[10];
   struct passwd *pass;
 
-  for (s = string ; (p = strchr(s,'%')) != NULL ; s = p )
+  for (s = str ; (p = strchr(s,'%')) != NULL ; s = p )
   {
     switch (*(p+1))
   {