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,
return ret;
}
-static uint16 tmpbuf[sizeof(pstring)];
-
void set_first_token(char *ptr)
{
last_ptr = ptr;
NOTE: oldc and newc must be 7 bit characters
**/
-void string_replace( pstring s, char oldc, char newc )
+void string_replace( char *s, char oldc, char newc )
{
char *p;
+ smb_ucs2_t *tmp;
+ size_t src_len, len;
/* this is quite a common operation, so we want it to be
fast. We optimise for the ascii case, knowing that all our
/* With compose characters we must restart from the beginning. JRA. */
p = s;
#endif
- push_ucs2(NULL, tmpbuf, p, sizeof(tmpbuf), STR_TERMINATE);
- string_replace_w(tmpbuf, UCS2_CHAR(oldc), UCS2_CHAR(newc));
- pull_ucs2(NULL, p, tmpbuf, -1, sizeof(tmpbuf), STR_TERMINATE);
+ src_len = strlen(p);
+ len = push_ucs2_allocate(&tmp, p);
+ if (len == -1) {
+ return;
+ }
+ string_replace_w(tmp, UCS2_CHAR(oldc), UCS2_CHAR(newc));
+ pull_ucs2(NULL, p, tmp, src_len+1, -1, STR_TERMINATE);
+ SAFE_FREE(tmp);
}
/**
BOOL strhasupper(const char *s)
{
- smb_ucs2_t *ptr;
- push_ucs2(NULL, tmpbuf,s, sizeof(tmpbuf), STR_TERMINATE);
- for(ptr=tmpbuf;*ptr;ptr++)
- if(isupper_w(*ptr))
- return True;
- return(False);
+ smb_ucs2_t *tmp, *p;
+ BOOL ret;
+
+ if (push_ucs2_allocate(&tmp, s) == -1) {
+ return False;
+ }
+
+ for(p = tmp; *p != 0; p++) {
+ if(isupper_w(*p)) {
+ break;
+ }
+ }
+
+ ret = (*p != 0);
+ SAFE_FREE(tmp);
+ return ret;
}
/**
BOOL strhaslower(const char *s)
{
- smb_ucs2_t *ptr;
- push_ucs2(NULL, tmpbuf,s, sizeof(tmpbuf), STR_TERMINATE);
- for(ptr=tmpbuf;*ptr;ptr++)
- if(islower_w(*ptr))
- return True;
- return(False);
+ smb_ucs2_t *tmp, *p;
+ BOOL ret;
+
+ if (push_ucs2_allocate(&tmp, s) == -1) {
+ return False;
+ }
+
+ for(p = tmp; *p != 0; p++) {
+ if(islower_w(*p)) {
+ break;
+ }
+ }
+
+ ret = (*p != 0);
+ SAFE_FREE(tmp);
+ return ret;
}
/**
of characters. UNIX charset format.
*******************************************************************/
-#define INCLUDE_LIST "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabdefghijklmnopqrstuvwxyz_/ \t.,"
+#define INCLUDE_LIST "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_/ \t.,"
#define INSIDE_DQUOTE_LIST "$`\n\"\\"
char *escape_shell_string(const char *src)
{
size_t srclen = strlen(src);
- char *ret = SMB_MALLOC((srclen * 2) + 1);
+ char *ret = SMB_MALLOC_ARRAY(char, (srclen * 2) + 1);
char *dest = ret;
BOOL in_s_quote = False;
BOOL in_d_quote = False;