r23792: convert Samba4 to GPLv3
[kai/samba-autobuild/.git] / source4 / lib / util / util_str.c
index ec6a1cbbead4c0a5a78f9486801066d134e61781..80a22773d4501325f94a35b24076d7a436556f2e 100644 (file)
@@ -9,7 +9,7 @@
    
    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 2 of the License, or
+   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,
    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, write to the Free Software
-   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
 #include "includes.h"
-#include "smb.h"
+#include "libcli/raw/smb.h"
 #include "pstring.h"
-#include "lib/ldb/include/ldb.h"
-#include "system/iconv.h"
+#include "system/locale.h"
 
 /**
  * @file
 /**
  Trim the specified elements off the front and back of a string.
 **/
-_PUBLIC_ BOOL trim_string(char *s,const char *front,const char *back)
+_PUBLIC_ 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;
@@ -59,7 +57,7 @@ _PUBLIC_ 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;
                }
        }
        
@@ -67,7 +65,7 @@ _PUBLIC_ BOOL trim_string(char *s,const char *front,const char *back)
                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;
@@ -76,7 +74,7 @@ _PUBLIC_ BOOL trim_string(char *s,const char *front,const char *back)
 /**
  Find the number of 'c' chars in a string
 **/
-_PUBLIC_ size_t count_chars(const char *s, char c)
+_PUBLIC_ _PURE_ size_t count_chars(const char *s, char c)
 {
        size_t count = 0;
 
@@ -219,7 +217,7 @@ _PUBLIC_ size_t strhex_to_str(char *p, size_t len, const char *strhex)
 /** 
  * Parse a hex string and return a data blob. 
  */
-_PUBLIC_ DATA_BLOB strhex_to_data_blob(const char *strhex) 
+_PUBLIC_ _PURE_ DATA_BLOB strhex_to_data_blob(const char *strhex) 
 {
        DATA_BLOB ret_blob = data_blob(NULL, strlen(strhex)/2+1);
 
@@ -246,29 +244,6 @@ _PUBLIC_ void hex_encode(const unsigned char *buff_in, size_t len, char **out_he
                slprintf(&hex_buffer[i*2], 3, "%02X", buff_in[i]);
 }
 
-/**
- Check if a string is part of a list.
-**/
-_PUBLIC_ BOOL in_list(const char *s, const char *list, BOOL casesensitive)
-{
-       pstring tok;
-       const char *p=list;
-
-       if (!list)
-               return(False);
-
-       while (next_token(&p,tok,LIST_SEP,sizeof(tok))) {
-               if (casesensitive) {
-                       if (strcmp(tok,s) == 0)
-                               return(True);
-               } else {
-                       if (strcasecmp_m(tok,s) == 0)
-                               return(True);
-               }
-       }
-       return(False);
-}
-
 /**
  Set a string value, allocing the space for the string
 **/