summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source3/include/proto.h13
-rw-r--r--source3/include/smb.h75
-rw-r--r--source3/lib/util.c138
-rw-r--r--source3/smbd/blocking.c1
-rw-r--r--source3/smbd/dir.c12
-rw-r--r--source3/smbd/nttrans.c1
-rw-r--r--source3/smbd/process.c2
7 files changed, 76 insertions, 166 deletions
diff --git a/source3/include/proto.h b/source3/include/proto.h
index f78f19cb40..aa6e4104c1 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -269,7 +269,6 @@ char *tmpdir(void);
BOOL in_group(gid_t group, gid_t current_gid, int ngroups, gid_t *groups);
char *Atoic(char *p, int *n, char *c);
char *get_numlist(char *p, uint32 **num, int *count);
-void putip(void *dest,void *src);
char *dns_to_netbios_name(char *dns_name);
int name_mangle( char *In, char *Out, char name_type );
BOOL file_exist(char *fname,SMB_STRUCT_STAT *sbuf);
@@ -278,16 +277,9 @@ time_t file_modtime(char *fname);
BOOL directory_exist(char *dname,SMB_STRUCT_STAT *st);
SMB_OFF_T get_file_size(char *file_name);
char *attrib_string(uint16 mode);
-void unix_format(char *fname);
-void dos_format(char *fname);
void show_msg(char *buf);
-int smb_len(char *buf);
-void _smb_setlen(char *buf,int len);
void smb_setlen(char *buf,int len);
int set_message(char *buf,int num_words,int num_bytes,BOOL zero);
-int smb_buflen(char *buf);
-char *smb_buf(char *buf);
-int smb_offset(char *p,char *buf);
void dos_clean_name(char *s);
void unix_clean_name(char *s);
BOOL reduce_name(char *s,char *dir,BOOL widelinks);
@@ -295,20 +287,17 @@ void expand_mask(char *Mask,BOOL doext);
void make_dir_struct(char *buf,char *mask,char *fname,SMB_OFF_T size,int mode,time_t date);
void close_low_fds(void);
int set_blocking(int fd, BOOL set);
-int TvalDiff(struct timeval *tvalold,struct timeval *tvalnew);
SMB_OFF_T transfer_file(int infd,int outfd,SMB_OFF_T n,char *header,int headlen,int align);
int name_extract(char *buf,int ofs,char *name);
int name_len(char *s1);
void msleep(int t);
BOOL unix_do_match(char *str, char *regexp, BOOL case_sig);
-BOOL exact_match(char *str, char *regexp, BOOL case_sig);
BOOL mask_match(char *str, char *regexp, BOOL case_sig, BOOL trans2);
void become_daemon(void);
BOOL yesno(char *p);
int set_filelen(int fd, SMB_OFF_T len);
void *Realloc(void *p,size_t size);
BOOL get_myname(char *my_name);
-BOOL ip_equal(struct in_addr ip1,struct in_addr ip2);
int interpret_protocol(char *str,int def);
BOOL is_ipaddress(const char *str);
uint32 interpret_addr(char *str);
@@ -343,7 +332,6 @@ char *tab_depth(int depth);
int str_checksum(const char *s);
void zero_free(void *p, size_t size);
int set_maxfiles(int requested_max);
-void reg_get_subkey(char *full_keyname, char *key_name, char *subkey_name);
BOOL reg_split_key(char *full_keyname, uint32 *reg_type, char *key_name);
char *smbd_mktemp(char *template);
void *memdup(void *p, size_t size);
@@ -2604,7 +2592,6 @@ void dptr_idlecnum(connection_struct *conn);
void dptr_closepath(char *path,uint16 spid);
int dptr_create(connection_struct *conn,char *path, BOOL old_handle, BOOL expect_close,uint16 spid);
BOOL dptr_fill(char *buf1,unsigned int key);
-BOOL dptr_zero(char *buf);
void *dptr_fetch(char *buf,int *num);
void *dptr_fetch_lanman2(int dptr_num);
BOOL dir_check_ftype(connection_struct *conn,int mode,SMB_STRUCT_STAT *st,int dirtype);
diff --git a/source3/include/smb.h b/source3/include/smb.h
index 8d4a367179..58c43e76c7 100644
--- a/source3/include/smb.h
+++ b/source3/include/smb.h
@@ -1382,6 +1382,76 @@ struct bitmap {
/* where to find the base of the SMB packet proper */
#define smb_base(buf) (((char *)(buf))+4)
+/* Extra macros added by Ying Chen at IBM - speed increase by inlining. */
+#define smb_buf(buf) (buf + smb_size + CVAL(buf,smb_wct)*2)
+#define smb_buflen(buf) (SVAL(buf,smb_vwv0 + (int)CVAL(buf, smb_wct)*2))
+
+/* Note that chain_size must be available as an extern int to this macro. */
+#define smb_offset(p,buf) (PTR_DIFF(p,buf+4) + chain_size)
+
+#define smb_len(buf) (PVAL(buf,3)|(PVAL(buf,2)<<8)|((PVAL(buf,1)&1)<<16))
+#define _smb_setlen(buf,len) buf[0] = 0; buf[1] = (len&0x10000)>>16; \
+ buf[2] = (len&0xFF00)>>8; buf[3] = len&0xFF;
+
+/*********************************************************
+* Routine to check if a given string matches exactly.
+* Case can be significant or not.
+**********************************************************/
+
+#define exact_match(str, regexp, case_sig) \
+ ((case_sig?strcmp(str,regexp):strcasecmp(str,regexp)) == 0)
+
+/*******************************************************************
+find the difference in milliseconds between two struct timeval
+values
+********************************************************************/
+
+#define TvalDiff(tvalold,tvalnew) \
+ (((tvalnew)->tv_sec - (tvalold)->tv_sec)*1000 + \
+ ((int)(tvalnew)->tv_usec - (int)(tvalold)->tv_usec)/1000)
+
+/****************************************************************************
+true if two IP addresses are equal
+****************************************************************************/
+
+#define ip_equal(ip1,ip2) ((ip1).s_addr == (ip2).s_addr)
+
+/*****************************************************************
+ splits out the last subkey of a key
+ *****************************************************************/
+
+#define reg_get_subkey(full_keyname, key_name, subkey_name) \
+ split_at_last_component(full_keyname, key_name, '\\', subkey_name)
+
+/****************************************************************************
+ Used by dptr_zero.
+****************************************************************************/
+
+#define DPTR_MASK ((uint32)(((uint32)1)<<31))
+
+/****************************************************************************
+ Return True if the offset is at zero.
+****************************************************************************/
+
+#define dptr_zero(buf) ((IVAL(buf,1)&~DPTR_MASK) == 0)
+
+/*******************************************************************
+copy an IP address from one buffer to another
+********************************************************************/
+
+#define putip(dest,src) memcpy(dest,src,4)
+
+/****************************************************************************
+ Make a filename into unix format.
+****************************************************************************/
+
+#define unix_format(fname) string_replace(fname,'\\','/')
+
+/****************************************************************************
+ Make a file into DOS format.
+****************************************************************************/
+
+#define dos_format(fname) string_replace(fname,'/','\\')
/* we don't allow server strings to be longer than 48 characters as
otherwise NT will not honour the announce packets */
@@ -1641,6 +1711,11 @@ extern int unix_ERR_class;
extern int unix_ERR_code;
/*
+ * Used in chaining code.
+ */
+extern int chain_size;
+
+/*
* Map the Core and Extended Oplock requesst bits down
* to common bits (EXCLUSIVE_OPLOCK & BATCH_OPLOCK).
*/
diff --git a/source3/lib/util.c b/source3/lib/util.c
index 001baa0e3e..0db12e92c6 100644
--- a/source3/lib/util.c
+++ b/source3/lib/util.c
@@ -194,15 +194,6 @@ char *get_numlist(char *p, uint32 **num, int *count)
return p;
}
-/*******************************************************************
-copy an IP address from one buffer to another
-********************************************************************/
-void putip(void *dest,void *src)
-{
- memcpy(dest,src,4);
-}
-
-
#define TRUNCATE_NETBIOS_NAME 1
/*******************************************************************
@@ -434,24 +425,6 @@ char *attrib_string(uint16 mode)
return(attrstr);
}
-
-
-/****************************************************************************
- make a file into unix format
-****************************************************************************/
-void unix_format(char *fname)
-{
- string_replace(fname,'\\','/');
-}
-
-/****************************************************************************
- make a file into dos format
-****************************************************************************/
-void dos_format(char *fname)
-{
- string_replace(fname,'/','\\');
-}
-
/*******************************************************************
show a smb message structure
********************************************************************/
@@ -496,24 +469,6 @@ void show_msg(char *buf)
dump_data(10, smb_buf(buf), bcc);
}
-/*******************************************************************
- return the length of an smb packet
-********************************************************************/
-int smb_len(char *buf)
-{
- return( PVAL(buf,3) | (PVAL(buf,2)<<8) | ((PVAL(buf,1)&1)<<16) );
-}
-
-/*******************************************************************
- set the length of an smb packet
-********************************************************************/
-void _smb_setlen(char *buf,int len)
-{
- buf[0] = 0;
- buf[1] = (len&0x10000)>>16;
- buf[2] = (len&0xFF00)>>8;
- buf[3] = len&0xFF;
-}
/*******************************************************************
set the length and marker of an smb packet
@@ -542,46 +497,6 @@ int set_message(char *buf,int num_words,int num_bytes,BOOL zero)
}
/*******************************************************************
-return the number of smb words
-********************************************************************/
-static int smb_numwords(char *buf)
-{
- return (CVAL(buf,smb_wct));
-}
-
-/*******************************************************************
-return the size of the smb_buf region of a message
-********************************************************************/
-int smb_buflen(char *buf)
-{
- return(SVAL(buf,smb_vwv0 + smb_numwords(buf)*2));
-}
-
-/*******************************************************************
- return a pointer to the smb_buf data area
-********************************************************************/
-static int smb_buf_ofs(char *buf)
-{
- return (smb_size + CVAL(buf,smb_wct)*2);
-}
-
-/*******************************************************************
- return a pointer to the smb_buf data area
-********************************************************************/
-char *smb_buf(char *buf)
-{
- return (buf + smb_buf_ofs(buf));
-}
-
-/*******************************************************************
-return the SMB offset into an SMB buffer
-********************************************************************/
-int smb_offset(char *p,char *buf)
-{
- return(PTR_DIFF(p,buf+4) + chain_size);
-}
-
-/*******************************************************************
reduce a file name, removing .. elements.
********************************************************************/
void dos_clean_name(char *s)
@@ -797,15 +712,6 @@ static void expand_one(char *Mask,int len)
}
/****************************************************************************
-parse out a directory name from a path name. Assumes dos style filenames.
-****************************************************************************/
-static void dirname_dos(char *path,char *buf)
-{
- split_at_last_component(path, buf, '\\', NULL);
-}
-
-
-/****************************************************************************
expand a wildcard expression, replacing *s with ?s
****************************************************************************/
void expand_mask(char *Mask,BOOL doext)
@@ -821,7 +727,7 @@ void expand_mask(char *Mask,BOOL doext)
/* parse the directory and filename */
if (strchr(Mask,'\\'))
- dirname_dos(Mask,dirpart);
+ split_at_last_component(Mask,dirpart,'\\',NULL);
filename_dos(Mask,filepart);
@@ -956,19 +862,6 @@ int set_blocking(int fd, BOOL set)
#undef FLAG_TO_SET
}
-
-/*******************************************************************
-find the difference in milliseconds between two struct timeval
-values
-********************************************************************/
-int TvalDiff(struct timeval *tvalold,struct timeval *tvalnew)
-{
- return((tvalnew->tv_sec - tvalold->tv_sec)*1000 +
- ((int)tvalnew->tv_usec - (int)tvalold->tv_usec)/1000);
-}
-
-
-
/****************************************************************************
transfer some data between two fd's
****************************************************************************/
@@ -1375,16 +1268,6 @@ static BOOL do_match(char *str, char *regexp, int case_sig, BOOL win9x_semantics
}
/*********************************************************
-* Routine to check if a given string matches exactly.
-* Case can be significant or not.
-**********************************************************/
-
-BOOL exact_match(char *str, char *regexp, BOOL case_sig)
-{
- return ((case_sig?strcmp(str,regexp):strcasecmp(str,regexp)) == 0);
-}
-
-/*********************************************************
* Routine to match a given string with a regexp - uses
* simplified regexp that takes * and ? only. Case can be
* significant or not.
@@ -1805,16 +1688,6 @@ BOOL get_myname(char *my_name)
return(True);
}
-
-/****************************************************************************
-true if two IP addresses are equal
-****************************************************************************/
-BOOL ip_equal(struct in_addr ip1,struct in_addr ip2)
-{
- return ip1.s_addr == ip2.s_addr;
-}
-
-
/****************************************************************************
interpret a protocol description string, with a default
****************************************************************************/
@@ -3153,15 +3026,6 @@ int set_maxfiles(int requested_max)
#endif
}
-
-/*****************************************************************
- splits out the last subkey of a key
- *****************************************************************/
-void reg_get_subkey(char *full_keyname, char *key_name, char *subkey_name)
-{
- split_at_last_component(full_keyname, key_name, '\\', subkey_name);
-}
-
/*****************************************************************
splits out the start of the key (HKLM or HKU) and the rest of the key
*****************************************************************/
diff --git a/source3/smbd/blocking.c b/source3/smbd/blocking.c
index 292eb2455e..c90f475b46 100644
--- a/source3/smbd/blocking.c
+++ b/source3/smbd/blocking.c
@@ -22,7 +22,6 @@
#include "includes.h"
extern int DEBUGLEVEL;
extern int Client;
-extern int chain_size;
extern char *OutBuffer;
/****************************************************************************
diff --git a/source3/smbd/dir.c b/source3/smbd/dir.c
index cae6281e91..f3f261f0b2 100644
--- a/source3/smbd/dir.c
+++ b/source3/smbd/dir.c
@@ -493,8 +493,6 @@ int dptr_create(connection_struct *conn,char *path, BOOL old_handle, BOOL expect
return(dptr->dnum);
}
-#define DPTR_MASK ((uint32)(((uint32)1)<<31))
-
/****************************************************************************
Fill the 5 byte server reserved dptr field.
****************************************************************************/
@@ -516,16 +514,6 @@ BOOL dptr_fill(char *buf1,unsigned int key)
return(True);
}
-
-/****************************************************************************
- Return True if the offset is at zero.
-****************************************************************************/
-
-BOOL dptr_zero(char *buf)
-{
- return((IVAL(buf,1)&~DPTR_MASK) == 0);
-}
-
/****************************************************************************
Fetch the dir ptr and seek it given the 5 byte server field.
****************************************************************************/
diff --git a/source3/smbd/nttrans.c b/source3/smbd/nttrans.c
index 81536156e5..f4015d50df 100644
--- a/source3/smbd/nttrans.c
+++ b/source3/smbd/nttrans.c
@@ -27,7 +27,6 @@ extern int Protocol;
extern int Client;
extern int smb_read_error;
extern int global_oplock_break;
-extern int chain_size;
extern BOOL case_sensitive;
extern BOOL case_preserve;
extern BOOL short_case_preserve;
diff --git a/source3/smbd/process.c b/source3/smbd/process.c
index d3551b96b1..7d6e171d05 100644
--- a/source3/smbd/process.c
+++ b/source3/smbd/process.c
@@ -561,7 +561,6 @@ static int construct_reply(char *inbuf,char *outbuf,int size,int bufsize)
int type = CVAL(inbuf,smb_com);
int outsize = 0;
int msg_type = CVAL(inbuf,0);
- extern int chain_size;
GetTimeOfDay(&smb_last_time);
@@ -726,7 +725,6 @@ int chain_reply(char *inbuf,char *outbuf,int size,int bufsize)
int outsize2;
char inbuf_saved[smb_wct];
char outbuf_saved[smb_wct];
- extern int chain_size;
int wct = CVAL(outbuf,smb_wct);
int outsize = smb_size + 2*wct + SVAL(outbuf,smb_vwv0+2*wct);