diff options
author | Luke Leighton <lkcl@samba.org> | 2000-03-27 01:33:43 +0000 |
---|---|---|
committer | Luke Leighton <lkcl@samba.org> | 2000-03-27 01:33:43 +0000 |
commit | 4acd40ee0015dd417a7a008f7fd2a183f8e30225 (patch) | |
tree | ccea834b4dd7c5f818de35196c4aafabb39d95c4 /source3/lib/util.c | |
parent | 3a290ce80c6d6fc117127e46b2741bba2abff34d (diff) | |
download | samba-4acd40ee0015dd417a7a008f7fd2a183f8e30225.tar.gz samba-4acd40ee0015dd417a7a008f7fd2a183f8e30225.tar.bz2 samba-4acd40ee0015dd417a7a008f7fd2a183f8e30225.zip |
moved nmblib-specific code from util.c to nmblib.c.
(This used to be commit 1b9077a1d5295bc8522b83ebed2d41d5dbd28a27)
Diffstat (limited to 'source3/lib/util.c')
-rw-r--r-- | source3/lib/util.c | 191 |
1 files changed, 0 insertions, 191 deletions
diff --git a/source3/lib/util.c b/source3/lib/util.c index 3c86570af1..7d10f9ccd2 100644 --- a/source3/lib/util.c +++ b/source3/lib/util.c @@ -194,144 +194,6 @@ char *get_numlist(char *p, uint32 **num, int *count) return p; } -#define TRUNCATE_NETBIOS_NAME 1 - -/******************************************************************* - convert, possibly using a stupid microsoft-ism which has destroyed - the transport independence of netbios (for CIFS vendors that usually - use the Win95-type methods, not for NT to NT communication, which uses - DCE/RPC and therefore full-length unicode strings...) a dns name into - a netbios name. - - the netbios name (NOT necessarily null-terminated) is truncated to 15 - characters. - - ******************************************************************/ -char *dns_to_netbios_name(char *dns_name) -{ - static char netbios_name[16]; - int i; - StrnCpy(netbios_name, dns_name, 15); - netbios_name[15] = 0; - -#ifdef TRUNCATE_NETBIOS_NAME - /* ok. this is because of a stupid microsoft-ism. if the called host - name contains a '.', microsoft clients expect you to truncate the - netbios name up to and including the '.' this even applies, by - mistake, to workgroup (domain) names, which is _really_ daft. - */ - for (i = 15; i >= 0; i--) - { - if (netbios_name[i] == '.') - { - netbios_name[i] = 0; - break; - } - } -#endif /* TRUNCATE_NETBIOS_NAME */ - - return netbios_name; -} - - -/**************************************************************************** -interpret the weird netbios "name". Return the name type -****************************************************************************/ -static int name_interpret(char *in,char *out) -{ - int ret; - int len = (*in++) / 2; - - *out=0; - - if (len > 30 || len<1) return(0); - - while (len--) - { - if (in[0] < 'A' || in[0] > 'P' || in[1] < 'A' || in[1] > 'P') { - *out = 0; - return(0); - } - *out = ((in[0]-'A')<<4) + (in[1]-'A'); - in += 2; - out++; - } - *out = 0; - ret = out[-1]; - -#ifdef NETBIOS_SCOPE - /* Handle any scope names */ - while(*in) - { - *out++ = '.'; /* Scope names are separated by periods */ - len = *(unsigned char *)in++; - StrnCpy(out, in, len); - out += len; - *out=0; - in += len; - } -#endif - return(ret); -} - -/**************************************************************************** -mangle a name into netbios format - - Note: <Out> must be (33 + strlen(scope) + 2) bytes long, at minimum. -****************************************************************************/ -int name_mangle( char *In, char *Out, char name_type ) - { - int i; - int c; - int len; - char buf[20]; - char *p = Out; - extern pstring global_scope; - - /* Safely copy the input string, In, into buf[]. */ - (void)memset( buf, 0, 20 ); - if (strcmp(In,"*") == 0) - buf[0] = '*'; - else - (void)slprintf( buf, sizeof(buf) - 1, "%-15.15s%c", In, name_type ); - - /* Place the length of the first field into the output buffer. */ - p[0] = 32; - p++; - - /* Now convert the name to the rfc1001/1002 format. */ - for( i = 0; i < 16; i++ ) - { - c = toupper( buf[i] ); - p[i*2] = ( (c >> 4) & 0x000F ) + 'A'; - p[(i*2)+1] = (c & 0x000F) + 'A'; - } - p += 32; - p[0] = '\0'; - - /* Add the scope string. */ - for( i = 0, len = 0; NULL != global_scope; i++, len++ ) - { - switch( global_scope[i] ) - { - case '\0': - p[0] = len; - if( len > 0 ) - p[len+1] = 0; - return( name_len(Out) ); - case '.': - p[0] = len; - p += (len + 1); - len = -1; - break; - default: - p[len+1] = global_scope[i]; - break; - } - } - - return( name_len(Out) ); - } /* name_mangle */ /******************************************************************* check if a file exists - call vfs_file_exist for samba files @@ -939,59 +801,6 @@ SMB_OFF_T transfer_file(int infd,int outfd,SMB_OFF_T n,char *header,int headlen, } - -/**************************************************************************** -find a pointer to a netbios name -****************************************************************************/ -static char *name_ptr(char *buf,int ofs) -{ - unsigned char c = *(unsigned char *)(buf+ofs); - - if ((c & 0xC0) == 0xC0) - { - uint16 l = RSVAL(buf, ofs) & 0x3FFF; - DEBUG(5,("name ptr to pos %d from %d is %s\n",l,ofs,buf+l)); - return(buf + l); - } - else - return(buf+ofs); -} - -/**************************************************************************** -extract a netbios name from a buf -****************************************************************************/ -int name_extract(char *buf,int ofs,char *name) -{ - char *p = name_ptr(buf,ofs); - int d = PTR_DIFF(p,buf+ofs); - pstrcpy(name,""); - if (d < -50 || d > 50) return(0); - return(name_interpret(p,name)); -} - -/**************************************************************************** -return the total storage length of a mangled name -****************************************************************************/ -int name_len(char *s1) -{ - /* NOTE: this argument _must_ be unsigned */ - unsigned char *s = (unsigned char *)s1; - int len; - - /* If the two high bits of the byte are set, return 2. */ - if (0xC0 == (*s & 0xC0)) - return(2); - - /* Add up the length bytes. */ - for (len = 1; (*s); s += (*s) + 1) { - len += *s + 1; - SMB_ASSERT(len < 80); - } - - return(len); -} /* name_len */ - - /******************************************************************* sleep for a specified number of milliseconds ********************************************************************/ |