⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 smb_macros.h

📁 samba-3.0.22.tar.gz 编译smb服务器的源码
💻 H
📖 第 1 页 / 共 2 页
字号:
/* this is how errors are generated */#define UNIXERROR(defclass,deferror) unix_error_packet(outbuf,defclass,deferror,NT_STATUS_OK,__LINE__,__FILE__)/* these are the datagram types */#define DGRAM_DIRECT_UNIQUE 0x10#define SMB_ROUNDUP(x,r) ( ((x)%(r)) ? ( (((x)+(r))/(r))*(r) ) : (x))/* Extra macros added by Ying Chen at IBM - speed increase by inlining. */#define smb_buf(buf) (((char *)(buf)) + smb_size + CVAL(buf,smb_wct)*2)#define smb_buflen(buf) (SVAL(buf,smb_vwv0 + (int)CVAL(buf, smb_wct)*2))/* the remaining number of bytes in smb buffer 'buf' from pointer 'p'. */#define smb_bufrem(buf, p) (smb_buflen(buf)-PTR_DIFF(p, smb_buf(buf)))/* 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) do { buf[0] = 0; buf[1] = (len&0x10000)>>16; \        buf[2] = (len&0xFF00)>>8; buf[3] = len&0xFF; } while (0)/*******************************************************************find the difference in milliseconds between two struct timevalvalues********************************************************************/#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)#define ip_service_equal(ip1,ip2) ( ((ip1).ip.s_addr == (ip2).ip.s_addr) && ((ip1).port == (ip2).port) )/***************************************************************** 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)/**************************************************************************** Return True if the offset is at zero.****************************************************************************/#define dptr_zero(buf) (IVAL(buf,1) == 0)/*******************************************************************copy an IP address from one buffer to another********************************************************************/#define putip(dest,src) memcpy(dest,src,4)/******************************************************************* Return True if a server has CIFS UNIX capabilities.********************************************************************/#define SERVER_HAS_UNIX_CIFS(c) ((c)->capabilities & CAP_UNIX)/**************************************************************************** Make a filename into unix format.****************************************************************************/#define IS_DIRECTORY_SEP(c) ((c) == '\\' || (c) == '/')#define unix_format(fname) string_replace(fname,'\\','/')#define unix_format_w(fname) string_replace_w(fname, UCS2_CHAR('\\'), UCS2_CHAR('/'))/**************************************************************************** Make a file into DOS format.****************************************************************************/#define dos_format(fname) string_replace(fname,'/','\\')/***************************************************************************** Check to see if we are a DC for this domain*****************************************************************************/#define IS_DC  (lp_server_role()==ROLE_DOMAIN_PDC || lp_server_role()==ROLE_DOMAIN_BDC) /***************************************************************************** Safe allocation macros.*****************************************************************************/#define SMB_MALLOC_ARRAY(type,count) (type *)malloc_array(sizeof(type),(count))#define SMB_REALLOC(p,s) Realloc((p),(s))#define SMB_REALLOC_ARRAY(p,type,count) (type *)realloc_array((p),sizeof(type),(count))#define SMB_CALLOC_ARRAY(type,count) (type *)calloc_array(sizeof(type),(count))#define SMB_XMALLOC_P(type) (type *)smb_xmalloc_array(sizeof(type),1)#define SMB_XMALLOC_ARRAY(type,count) (type *)smb_xmalloc_array(sizeof(type),(count))/* limiting size of ipc replies */#define SMB_REALLOC_LIMIT(ptr,size) SMB_REALLOC(ptr,MAX((size),4*1024))/* The new talloc is paranoid malloc checker safe. */#define TALLOC(ctx, size) talloc_named_const(ctx, size, __location__)#define TALLOC_P(ctx, type) (type *)talloc_named_const(ctx, sizeof(type), #type)#define TALLOC_ARRAY(ctx, type, count) (type *)_talloc_array(ctx, sizeof(type), count, #type)#define TALLOC_MEMDUP(ctx, ptr, size) _talloc_memdup(ctx, ptr, size, __location__)#define TALLOC_ZERO(ctx, size) _talloc_zero(ctx, size, __location__)#define TALLOC_ZERO_P(ctx, type) (type *)_talloc_zero(ctx, sizeof(type), #type)#define TALLOC_ZERO_ARRAY(ctx, type, count) (type *)_talloc_zero_array(ctx, sizeof(type), count, #type)#define TALLOC_REALLOC(ctx, ptr, count) _talloc_realloc(ctx, ptr, count, __location__)#define TALLOC_REALLOC_ARRAY(ctx, ptr, type, count) (type *)_talloc_realloc_array(ctx, ptr, sizeof(type), count, #type)#define talloc_destroy(ctx) talloc_free(ctx)#define TALLOC_FREE(ctx) do { if ((ctx) != NULL) {talloc_free(ctx); ctx=NULL;} } while(0)/* only define PARANOID_MALLOC_CHECKER with --enable-developer and not compiling   the smbmount utils */#if defined(DEVELOPER) && !defined(SMBMOUNT_MALLOC)#  define PARANOID_MALLOC_CHECKER 1#endif#if defined(PARANOID_MALLOC_CHECKER)#define PRS_ALLOC_MEM(ps, type, count) (type *)prs_alloc_mem_((ps),sizeof(type),(count))#define PRS_ALLOC_MEM_VOID(ps, size) prs_alloc_mem_((ps),(size),1)/* Get medieval on our ass about malloc.... *//* Restrictions on malloc/realloc/calloc. */#ifdef malloc#undef malloc#endif#define malloc(s) __ERROR_DONT_USE_MALLOC_DIRECTLY#ifdef realloc#undef realloc#endif#define realloc(p,s) __ERROR_DONT_USE_REALLOC_DIRECTLY#ifdef calloc#undef calloc#endif#define calloc(n,s) __ERROR_DONT_USE_CALLOC_DIRECTLY#ifdef strndup#undef strndup#endif#define strndup(s,n) __ERROR_DONT_USE_STRNDUP_DIRECTLY#ifdef strdup#undef strdup#endif#define strdup(s) __ERROR_DONT_USE_STRDUP_DIRECTLY#define SMB_MALLOC(s) malloc_(s)#define SMB_MALLOC_P(type) (type *)malloc_(sizeof(type))#define SMB_STRDUP(s) smb_xstrdup(s)#define SMB_STRNDUP(s,n) smb_xstrndup(s,n)#else#define _STRING_LINE_(s)    #s#define _STRING_LINE2_(s)   _STRING_LINE_(s)#define __LINESTR__       _STRING_LINE2_(__LINE__)#define __location__ __FILE__ ":" __LINESTR__#define PRS_ALLOC_MEM(ps, type, count) (type *)prs_alloc_mem((ps),sizeof(type),(count))#define PRS_ALLOC_MEM_VOID(ps, size) prs_alloc_mem((ps),(size),1)/* Regular malloc code. */#define SMB_MALLOC(s) malloc(s)#define SMB_MALLOC_P(type) (type *)malloc(sizeof(type))#define SMB_STRDUP(s) strdup(s)#define SMB_STRNDUP(s,n) strndup(s,n)#endif#define ADD_TO_ARRAY(mem_ctx, type, elem, array, num) \do { \	*(array) = ((mem_ctx) != NULL) ? \		TALLOC_REALLOC_ARRAY(mem_ctx, (*(array)), type, (*(num))+1) : \		SMB_REALLOC_ARRAY((*(array)), type, (*(num))+1); \	SMB_ASSERT((*(array)) != NULL); \	(*(array))[*(num)] = (elem); \	(*(num)) += 1; \} while (0)#define ADD_TO_LARGE_ARRAY(mem_ctx, type, elem, array, num, size) \	add_to_large_array((mem_ctx), sizeof(type), &(elem), (void **)(array), (num), (size));#endif /* _SMB_MACROS_H */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -