[SCM] Samba Shared Repository - branch v3-2-test updated - initial-v3-2-unstable-65-g315215e

Jeremy Allison jra at samba.org
Thu Oct 18 01:45:10 GMT 2007


The branch, v3-2-test has been updated
       via  315215e20e1e470c5077122a2e250ecb3d45ce9b (commit)
      from  354bdd38e8714b789daffc897cd843a8d401be45 (commit)

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-2-test


- Log -----------------------------------------------------------------
commit 315215e20e1e470c5077122a2e250ecb3d45ce9b
Author: Jeremy Allison <jra at samba.org>
Date:   Wed Oct 17 12:10:12 2007 -0700

    Reformatting fix for new coding guidelines. BOOL ->bool.
    Jeremy.

-----------------------------------------------------------------------

Summary of changes:
 source/lib/util_str.c |  584 +++++++++++++++++++++++++++----------------------
 1 files changed, 320 insertions(+), 264 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source/lib/util_str.c b/source/lib/util_str.c
index fbd9c1c..2fd2228 100644
--- a/source/lib/util_str.c
+++ b/source/lib/util_str.c
@@ -1,23 +1,23 @@
-/* 
+/*
    Unix SMB/CIFS implementation.
    Samba utility functions
-   
+
    Copyright (C) Andrew Tridgell 1992-2001
    Copyright (C) Simo Sorce      2001-2002
    Copyright (C) Martin Pool     2003
    Copyright (C) James Peach	 2006
    Copyright (C) Jeremy Allison  1992-2007
-   
+
    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 3 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, see <http://www.gnu.org/licenses/>.
 */
@@ -30,26 +30,26 @@
  **/
 
 /**
- * Internal function to get the next token from a string, return False if none
+ * Internal function to get the next token from a string, return false if none
  * found.  Handles double-quotes.  This is the work horse function called by
  * next_token() and next_token_no_ltrim().
  *
- * Based on a routine by GJC at VILLAGE.COM. 
+ * Based on a routine by GJC at VILLAGE.COM.
  * Extensively modified by Andrew.Tridgell at anu.edu.au
  */
-static BOOL next_token_internal(const char **ptr,
+static bool next_token_internal(const char **ptr,
                                 char *buff,
                                 const char *sep,
                                 size_t bufsize,
-                                BOOL ltrim)
+                                bool ltrim)
 {
 	char *s;
 	char *pbuf;
-	BOOL quoted;
+	bool quoted;
 	size_t len=1;
 
 	if (!ptr)
-		return(False);
+		return(false);
 
 	s = (char *)*ptr;
 
@@ -62,14 +62,15 @@ static BOOL next_token_internal(const char **ptr,
 		while (*s && strchr_m(sep,*s))
 			s++;
 	}
-	
+
 	/* nothing left? */
 	if (! *s)
-		return(False);
-	
+		return(false);
+
 	/* copy over the token */
 	pbuf = buff;
-	for (quoted = False; len < bufsize && *s && (quoted || !strchr_m(sep,*s)); s++) {
+	for (quoted = false; len < bufsize && *s &&
+			(quoted || !strchr_m(sep,*s)); s++) {
 		if ( *s == '\"' ) {
 			quoted = !quoted;
 		} else {
@@ -77,53 +78,53 @@ static BOOL next_token_internal(const char **ptr,
 			*pbuf++ = *s;
 		}
 	}
-	
-	*ptr = (*s) ? s+1 : s;  
+
+	*ptr = (*s) ? s+1 : s;
 	*pbuf = 0;
-	
-	return(True);
+
+	return(true);
 }
 
 /*
- * Get the next token from a string, return False if none found.  Handles
+ * Get the next token from a string, return false if none found.  Handles
  * double-quotes.  This version trims leading separator characters before
  * looking for a token.
  */
-BOOL next_token(const char **ptr, char *buff, const char *sep, size_t bufsize)
+bool next_token(const char **ptr, char *buff, const char *sep, size_t bufsize)
 {
-    return next_token_internal(ptr, buff, sep, bufsize, True);
+    return next_token_internal(ptr, buff, sep, bufsize, true);
 }
 
 /*
- * Get the next token from a string, return False if none found.  Handles
+ * Get the next token from a string, return false if none found.  Handles
  * double-quotes.  This version does not trim leading separator characters
  * before looking for a token.
  */
-BOOL next_token_no_ltrim(const char **ptr,
+bool next_token_no_ltrim(const char **ptr,
                          char *buff,
                          const char *sep,
                          size_t bufsize)
 {
-    return next_token_internal(ptr, buff, sep, bufsize, False);
+    return next_token_internal(ptr, buff, sep, bufsize, false);
 }
 
 /**
-This is like next_token but is not re-entrant and "remembers" the first 
+This is like next_token but is not re-entrant and "remembers" the first
 parameter so you can pass NULL. This is useful for user interface code
 but beware the fact that it is not re-entrant!
 **/
 
 static const char *last_ptr=NULL;
 
-BOOL next_token_nr(const char **ptr,char *buff, const char *sep, size_t bufsize)
+bool next_token_nr(const char **ptr,char *buff, const char *sep, size_t bufsize)
 {
-	BOOL ret;
+	bool ret;
 	if (!ptr)
 		ptr = &last_ptr;
 
 	ret = next_token(ptr, buff, sep, bufsize);
 	last_ptr = *ptr;
-	return ret;	
+	return ret;
 }
 
 void set_first_token(char *ptr)
@@ -159,14 +160,14 @@ char **toktocliplist(int *ctok, const char *sep)
 		while(*s && strchr_m(sep,*s))
 			*s++=0;
 	} while(*s);
-	
+
 	*ctok=ictok;
 	s=(char *)last_ptr;
-	
+
 	if (!(ret=iret=SMB_MALLOC_ARRAY(char *,ictok+1)))
 		return NULL;
-	
-	while(ictok--) {    
+
+	while(ictok--) {
 		*iret++=s;
 		if (ictok > 0) {
 			while(*s++)
@@ -207,7 +208,7 @@ char **toktocliplist(int *ctok, const char *sep)
  * different, we'd need to restart the whole thing.
  *
  * Even better is to implement strcasecmp for each encoding and use a
- * function pointer. 
+ * function pointer.
  **/
 int StrCaseCmp(const char *s, const char *t)
 {
@@ -227,7 +228,8 @@ int StrCaseCmp(const char *s, const char *t)
 		else if (!*pt)
 			return +1; /* t is a prefix */
 		else if ((*ps & 0x80) || (*pt & 0x80))
-			/* not ascii anymore, do it the hard way from here on in */
+			/* not ascii anymore, do it the hard way
+			 * from here on in */
 			break;
 
 		us = toupper_ascii(*ps);
@@ -242,19 +244,21 @@ int StrCaseCmp(const char *s, const char *t)
 
 	size = push_ucs2_allocate(&buffer_s, ps);
 	if (size == (size_t)-1) {
-		return strcmp(ps, pt); 
+		return strcmp(ps, pt);
 		/* Not quite the right answer, but finding the right one
-		   under this failure case is expensive, and it's pretty close */
+		   under this failure case is expensive, and it's pretty
+		   close */
 	}
-	
+
 	size = push_ucs2_allocate(&buffer_t, pt);
 	if (size == (size_t)-1) {
 		SAFE_FREE(buffer_s);
-		return strcmp(ps, pt); 
+		return strcmp(ps, pt);
 		/* Not quite the right answer, but finding the right one
-		   under this failure case is expensive, and it's pretty close */
+		   under this failure case is expensive, and it's pretty
+		   close */
 	}
-	
+
 	ret = strcasecmp_w(buffer_s, buffer_t);
 	SAFE_FREE(buffer_s);
 	SAFE_FREE(buffer_t);
@@ -329,12 +333,12 @@ int StrnCaseCmp(const char *s, const char *t, size_t len)
  *
  * @note The comparison is case-insensitive.
  **/
-BOOL strequal(const char *s1, const char *s2)
+bool strequal(const char *s1, const char *s2)
 {
 	if (s1 == s2)
-		return(True);
+		return(true);
 	if (!s1 || !s2)
-		return(False);
+		return(false);
 
 	return(StrCaseCmp(s1,s2)==0);
 }
@@ -344,12 +348,12 @@ BOOL strequal(const char *s1, const char *s2)
  *
  * @note The comparison is case-insensitive.
  **/
-BOOL strnequal(const char *s1,const char *s2,size_t n)
+bool strnequal(const char *s1,const char *s2,size_t n)
 {
 	if (s1 == s2)
-		return(True);
+		return(true);
 	if (!s1 || !s2 || !n)
-		return(False);
+		return(false);
 
 	return(StrnCaseCmp(s1,s2,n)==0);
 }
@@ -358,13 +362,13 @@ BOOL strnequal(const char *s1,const char *s2,size_t n)
  Compare 2 strings (case sensitive).
 **/
 
-BOOL strcsequal(const char *s1,const char *s2)
+bool strcsequal(const char *s1,const char *s2)
 {
 	if (s1 == s2)
-		return(True);
+		return(true);
 	if (!s1 || !s2)
-		return(False);
-  
+		return(false);
+
 	return(strcmp(s1,s2)==0);
 }
 
@@ -389,8 +393,8 @@ int strwicmp(const char *psz1, const char *psz2)
 			psz1++;
 		while (isspace((int)*psz2))
 			psz2++;
-		if (toupper_ascii(*psz1) != toupper_ascii(*psz2) || *psz1 == '\0'
-		    || *psz2 == '\0')
+		if (toupper_ascii(*psz1) != toupper_ascii(*psz2) ||
+				*psz1 == '\0' || *psz2 == '\0')
 			break;
 		psz1++;
 		psz2++;
@@ -434,7 +438,7 @@ void strnorm(char *s, int case_default)
  Check if a string is in "normal" case.
 **/
 
-BOOL strisnormal(const char *s, int case_default)
+bool strisnormal(const char *s, int case_default)
 {
 	if (case_default == CASE_UPPER)
 		return(!strhaslower(s));
@@ -558,15 +562,15 @@ size_t str_ascii_charnum(const char *s)
 	return ret;
 }
 
-BOOL trim_char(char *s,char cfront,char cback)
+bool trim_char(char *s,char cfront,char cback)
 {
-	BOOL ret = False;
+	bool ret = false;
 	char *ep;
 	char *fp = s;
 
 	/* Ignore null or empty strings. */
 	if (!s || (s[0] == '\0'))
-		return False;
+		return false;
 
 	if (cfront) {
 		while (*fp && *fp == cfront)
@@ -574,17 +578,17 @@ BOOL trim_char(char *s,char cfront,char cback)
 		if (!*fp) {
 			/* We ate the string. */
 			s[0] = '\0';
-			return True;
+			return true;
 		}
 		if (fp != s)
-			ret = True;
+			ret = true;
 	}
 
 	ep = fp + strlen(fp) - 1;
 	if (cback) {
 		/* Attempt ascii only. Bail for mb strings. */
 		while ((ep >= fp) && (*ep == cback)) {
-			ret = True;
+			ret = true;
 			if ((ep > fp) && (((unsigned char)ep[-1]) & 0x80)) {
 				/* Could be mb... bail back to tim_string. */
 				char fs[2], bs[2];
@@ -602,7 +606,7 @@ BOOL trim_char(char *s,char cfront,char cback)
 		if (ep < fp) {
 			/* We ate the string. */
 			s[0] = '\0';
-			return True;
+			return true;
 		}
 	}
 
@@ -615,16 +619,16 @@ BOOL trim_char(char *s,char cfront,char cback)
  Trim the specified elements off the front and back of a string.
 **/
 
-BOOL trim_string(char *s,const char *front,const char *back)
+bool trim_string(char *s,const char *front,const char *back)
 {
-	BOOL ret = False;
+	bool ret = false;
 	size_t front_len;
 	size_t back_len;
 	size_t len;
 
 	/* Ignore null or empty strings. */
 	if (!s || (s[0] == '\0'))
-		return False;
+		return false;
 
 	front_len	= front? strlen(front) : 0;
 	back_len	= back? strlen(back) : 0;
@@ -637,15 +641,16 @@ BOOL trim_string(char *s,const char *front,const char *back)
 			 * easily overlap. Found by valgrind. JRA. */
 			memmove(s, s+front_len, (len-front_len)+1);
 			len -= front_len;
-			ret=True;
+			ret=true;
 		}
 	}
-	
+
 	if (back_len) {
-		while ((len >= back_len) && strncmp(s+len-back_len,back,back_len)==0) {
+		while ((len >= back_len) &&
+				strncmp(s+len-back_len,back,back_len)==0) {
 			s[len-back_len]='\0';
 			len -= back_len;
-			ret=True;
+			ret=true;
 		}
 	}
 	return ret;
@@ -655,13 +660,13 @@ BOOL trim_string(char *s,const char *front,const char *back)
  Does a string have any uppercase chars in it?
 **/
 
-BOOL strhasupper(const char *s)
+bool strhasupper(const char *s)
 {
 	smb_ucs2_t *tmp, *p;
-	BOOL ret;
+	bool ret;
 
 	if (push_ucs2_allocate(&tmp, s) == -1) {
-		return False;
+		return false;
 	}
 
 	for(p = tmp; *p != 0; p++) {
@@ -679,13 +684,13 @@ BOOL strhasupper(const char *s)
  Does a string have any lowercase chars in it?
 **/
 
-BOOL strhaslower(const char *s)
+bool strhaslower(const char *s)
 {
 	smb_ucs2_t *tmp, *p;
-	BOOL ret;
+	bool ret;
 
 	if (push_ucs2_allocate(&tmp, s) == -1) {
-		return False;
+		return false;
 	}
 
 	for(p = tmp; *p != 0; p++) {
@@ -726,12 +731,17 @@ size_t count_chars(const char *s,char c)
  include the terminating zero.
 **/
 
-char *safe_strcpy_fn(const char *fn, int line, char *dest,const char *src, size_t maxlength)
+char *safe_strcpy_fn(const char *fn,
+		int line,
+		char *dest,
+		const char *src,
+		size_t maxlength)
 {
 	size_t len;
 
 	if (!dest) {
-		DEBUG(0,("ERROR: NULL dest in safe_strcpy, called from [%s][%d]\n", fn, line));
+		DEBUG(0,("ERROR: NULL dest in safe_strcpy, "
+			"called from [%s][%d]\n", fn, line));
 		return NULL;
 	}
 
@@ -742,38 +752,44 @@ char *safe_strcpy_fn(const char *fn, int line, char *dest,const char *src, size_
 	if (!src) {
 		*dest = 0;
 		return dest;
-	}  
+	}
 
 	len = strnlen(src, maxlength+1);
 
 	if (len > maxlength) {
-		DEBUG(0,("ERROR: string overflow by %lu (%lu - %lu) in safe_strcpy [%.50s]\n",
-			 (unsigned long)(len-maxlength), (unsigned long)len, 
+		DEBUG(0,("ERROR: string overflow by "
+			"%lu (%lu - %lu) in safe_strcpy [%.50s]\n",
+			 (unsigned long)(len-maxlength), (unsigned long)len,
 			 (unsigned long)maxlength, src));
 		len = maxlength;
 	}
-      
+
 	memmove(dest, src, len);
 	dest[len] = 0;
 	return dest;
-}  
+}
 
 /**
  Safe string cat into a string. maxlength does not
  include the terminating zero.
 **/
-char *safe_strcat_fn(const char *fn, int line, char *dest, const char *src, size_t maxlength)
+char *safe_strcat_fn(const char *fn,
+		int line,
+		char *dest,
+		const char *src,
+		size_t maxlength)
 {
 	size_t src_len, dest_len;
 
 	if (!dest) {
-		DEBUG(0,("ERROR: NULL dest in safe_strcat, called from [%s][%d]\n", fn, line));
+		DEBUG(0,("ERROR: NULL dest in safe_strcat, "
+			"called from [%s][%d]\n", fn, line));
 		return NULL;
 	}
 
 	if (!src)
 		return dest;
-	
+
 	src_len = strnlen(src, maxlength + 1);
 	dest_len = strnlen(dest, maxlength + 1);
 
@@ -782,7 +798,8 @@ char *safe_strcat_fn(const char *fn, int line, char *dest, const char *src, size
 #endif
 
 	if (src_len + dest_len > maxlength) {
-		DEBUG(0,("ERROR: string overflow by %d in safe_strcat [%.50s]\n",
+		DEBUG(0,("ERROR: string overflow by %d "
+			"in safe_strcat [%.50s]\n",
 			 (int)(src_len + dest_len - maxlength), src));
 		if (maxlength > dest_len) {
 			memcpy(&dest[dest_len], src, maxlength - dest_len);
@@ -802,7 +819,13 @@ char *safe_strcat_fn(const char *fn, int line, char *dest, const char *src, size
  and replaces with '_'. Deliberately does *NOT* check for multibyte
  characters. Don't change it !


-- 
Samba Shared Repository


More information about the samba-cvs mailing list