*/
#include "includes.h"
-/**
- * @file
- *
- * @brief Character-set conversion routines built on our iconv.
- *
- * @note Samba's internal character set (at least in the 3.0 series)
- * is always the same as the one for the Unix filesystem. It is
- * <b>not</b> necessarily UTF-8 and may be different on machines that
- * need i18n filenames to be compatible with Unix software. It does
- * have to be a superset of ASCII. All multibyte sequences must start
- * with a byte with the high bit set.
- */
-
static pstring cvtbuf;
static smb_iconv_t conv_handles[NUM_CHARSETS][NUM_CHARSETS];
-/****************************************************************************
- Return the name of a charset to give to iconv().
-****************************************************************************/
+/**
+ * @file
+ *
+ * Character set conversion routines.
+ *
+ * @sa lib/iconv.c
+ **/
+
+/**
+ * Return the name of a charset to give to iconv().
+ **/
static const char *charset_name(charset_t ch)
{
const char *ret = NULL;
}
}
-/****************************************************************************
+/**
Initialize iconv conversion descriptors.
-****************************************************************************/
+**/
void init_iconv(void)
{
/**
* Convert string from one encoding to another, making error checking etc
*
- * @param descriptor conversion descriptor, created in init_iconv()
* @param src pointer to source string (multibyte or singlebyte)
* @param srclen length of the source string in bytes
* @param dest pointer to destination string (multibyte or singlebyte)
* @param destlen maximal length allowed for string
- * @retval the number of bytes occupied in the destination
+ * @returns the number of bytes occupied in the destination
**/
-
size_t convert_string(charset_t from, charset_t to,
void const *src, size_t srclen,
void *dest, size_t destlen)
* @param dest always set at least to NULL
* @note -1 is not accepted for srclen.
*
- * @retval Size in bytes of the converted string; or -1 in case of error.
+ * @returns Size in bytes of the converted string; or -1 in case of error.
**/
size_t convert_string_allocate(charset_t from, charset_t to,
return destlen;
}
+
/**
* Convert between character sets, allocating a new buffer using talloc for the result.
*
* @param dest always set at least to NULL
* @note -1 is not accepted for srclen.
*
- * @retval Size in bytes of the converted string; or -1 in case of error.
+ * @returns Size in bytes of the converted string; or -1 in case of error.
**/
-
size_t convert_string_talloc(TALLOC_CTX *ctx, charset_t from, charset_t to,
void const *src, size_t srclen, void **dest)
{
}
-/****************************************************************************
-copy a string from a char* unix src to a dos codepage string destination
-return the number of bytes occupied by the string in the destination
-flags can have:
- STR_TERMINATE means include the null termination
- STR_UPPER means uppercase in the destination
-dest_len is the maximum length in bytes allowed in the destination. If dest_len
-is -1 then no maxiumum is used
-****************************************************************************/
-
+/**
+ * Copy a string from a char* unix src to a dos codepage string destination.
+ *
+ * @return the number of bytes occupied by the string in the destination.
+ *
+ * @param flags can include
+ * <dl>
+ * <dt>STR_TERMINATE</dt> <dd>means include the null termination</dd>
+ * <dt>STR_UPPER</dt> <dd>means uppercase in the destination</dd>
+ * </dl>
+ *
+ * @param dest_len the maximum length in bytes allowed in the
+ * destination. If @p dest_len is -1 then no maximum is used.
+ **/
size_t push_ascii(void *dest, const char *src, size_t dest_len, int flags)
{
size_t src_len = strlen(src);
return push_ascii(dest, src, sizeof(pstring), STR_TERMINATE);
}
-/****************************************************************************
- Copy a string from a dos codepage source to a unix char* destination.
- Flags can have:
- STR_TERMINATE means the string in src is null terminated.
- if STR_TERMINATE is set then src_len is ignored.
- src_len is the length of the source area in bytes.
- Return the number of bytes occupied by the string in src.
- The resulting string in "dest" is always null terminated.
-****************************************************************************/
-
+/**
+ * Copy a string from a dos codepage source to a unix char* destination.
+ *
+ * The resulting string in "dest" is always null terminated.
+ *
+ * @param flags can have:
+ * <dl>
+ * <dt>STR_TERMINATE</dt>
+ * <dd>STR_TERMINATE means the string in @p src
+ * is null terminated, and src_len is ignored.</dd>
+ * </dl>
+ *
+ * @param src_len is the length of the source area in bytes.
+ * @returns the number of bytes occupied by the string in @p src.
+ **/
size_t pull_ascii(char *dest, const void *src, size_t dest_len, size_t src_len, int flags)
{
size_t ret;
return pull_ascii(dest, src, sizeof(fstring), -1, STR_TERMINATE);
}
-/****************************************************************************
- Copy a string from a char* src to a unicode destination.
- Return the number of bytes occupied by the string in the destination.
- Flags can have:
- STR_TERMINATE means include the null termination.
- STR_UPPER means uppercase in the destination.
- STR_NOALIGN means don't do alignment.
- dest_len is the maximum length allowed in the destination. If dest_len
- is -1 then no maxiumum is used.
-****************************************************************************/
-
+/**
+ * Copy a string from a char* src to a unicode destination.
+ *
+ * @returns the number of bytes occupied by the string in the destination.
+ *
+ * @param flags can have:
+ *
+ * <dl>
+ * <dt>STR_TERMINATE <dd>means include the null termination.
+ * <dt>STR_UPPER <dd>means uppercase in the destination.
+ * <dt>STR_NOALIGN <dd>means don't do alignment.
+ * </dl>
+ *
+ * @param dest_len is the maximum length allowed in the
+ * destination. If dest_len is -1 then no maxiumum is used.
+ **/
size_t push_ucs2(const void *base_ptr, void *dest, const char *src, size_t dest_len, int flags)
{
size_t len=0;
return len;
}
+
/**
- * Copy a string from a unix char* src to a UCS2 destination, allocating a buffer using talloc
+ * Copy a string from a unix char* src to a UCS2 destination,
+ * allocating a buffer using talloc().
*
* @param dest always set at least to NULL
*
- * @retval The number of bytes occupied by the string in the destination
+ * @returns The number of bytes occupied by the string in the destination
* or -1 in case of error.
**/
-
size_t push_ucs2_talloc(TALLOC_CTX *ctx, smb_ucs2_t **dest, const char *src)
{
size_t src_len = strlen(src)+1;
return convert_string_talloc(ctx, CH_UNIX, CH_UCS2, src, src_len, (void **)dest);
}
+
/**
* Copy a string from a unix char* src to a UCS2 destination, allocating a buffer
*
* @param dest always set at least to NULL
*
- * @retval The number of bytes occupied by the string in the destination
+ * @returns The number of bytes occupied by the string in the destination
* or -1 in case of error.
**/
return convert_string_allocate(CH_UNIX, CH_UCS2, src, src_len, (void **)dest);
}
-/****************************************************************************
+/**
Copy a string from a char* src to a UTF-8 destination.
Return the number of bytes occupied by the string in the destination
Flags can have:
STR_UPPER means uppercase in the destination
dest_len is the maximum length allowed in the destination. If dest_len
is -1 then no maxiumum is used.
-****************************************************************************/
+**/
size_t push_utf8(void *dest, const char *src, size_t dest_len, int flags)
{
*
* @param dest always set at least to NULL
*
- * @retval The number of bytes occupied by the string in the destination
+ * @returns The number of bytes occupied by the string in the destination
**/
size_t push_utf8_talloc(TALLOC_CTX *ctx, char **dest, const char *src)
*
* @param dest always set at least to NULL
*
- * @retval The number of bytes occupied by the string in the destination
+ * @returns The number of bytes occupied by the string in the destination
**/
size_t push_utf8_allocate(char **dest, const char *src)
return convert_string_allocate(CH_UNIX, CH_UTF8, src, src_len, (void **)dest);
}
-/****************************************************************************
+/**
Copy a string from a ucs2 source to a unix char* destination.
Flags can have:
STR_TERMINATE means the string in src is null terminated.
src_len is the length of the source area in bytes
Return the number of bytes occupied by the string in src.
The resulting string in "dest" is always null terminated.
-****************************************************************************/
+**/
size_t pull_ucs2(const void *base_ptr, char *dest, const void *src, size_t dest_len, size_t src_len, int flags)
{
*
* @param dest always set at least to NULL
*
- * @retval The number of bytes occupied by the string in the destination
+ * @returns The number of bytes occupied by the string in the destination
**/
size_t pull_ucs2_talloc(TALLOC_CTX *ctx, char **dest, const smb_ucs2_t *src)
*
* @param dest always set at least to NULL
*
- * @retval The number of bytes occupied by the string in the destination
+ * @returns The number of bytes occupied by the string in the destination
**/
size_t pull_ucs2_allocate(void **dest, const smb_ucs2_t *src)
return convert_string_allocate(CH_UCS2, CH_UNIX, src, src_len, dest);
}
-/****************************************************************************
+/**
Copy a string from a utf-8 source to a unix char* destination.
Flags can have:
STR_TERMINATE means the string in src is null terminated.
src_len is the length of the source area in bytes
Return the number of bytes occupied by the string in src.
The resulting string in "dest" is always null terminated.
-****************************************************************************/
+**/
size_t pull_utf8(char *dest, const void *src, size_t dest_len, size_t src_len, int flags)
{
*
* @param dest always set at least to NULL
*
- * @retval The number of bytes occupied by the string in the destination
+ * @returns The number of bytes occupied by the string in the destination
**/
size_t pull_utf8_talloc(TALLOC_CTX *ctx, char **dest, const char *src)
*
* @param dest always set at least to NULL
*
- * @retval The number of bytes occupied by the string in the destination
+ * @returns The number of bytes occupied by the string in the destination
**/
size_t pull_utf8_allocate(void **dest, const char *src)
return convert_string_allocate(CH_UTF8, CH_UNIX, src, src_len, dest);
}
-/****************************************************************************
+/**
Copy a string from a char* src to a unicode or ascii
dos codepage destination choosing unicode or ascii based on the
flags in the SMB buffer starting at base_ptr.
STR_NOALIGN means don't do alignment.
dest_len is the maximum length allowed in the destination. If dest_len
is -1 then no maxiumum is used.
-****************************************************************************/
+**/
size_t push_string(const void *base_ptr, void *dest, const char *src, size_t dest_len, int flags)
{
}
-/****************************************************************************
+/**
Copy a string from a unicode or ascii source (depending on
the packet flags) to a char* destination.
Flags can have:
src_len is the length of the source area in bytes.
Return the number of bytes occupied by the string in src.
The resulting string in "dest" is always null terminated.
-****************************************************************************/
+**/
size_t pull_string(const void *base_ptr, char *dest, const void *src, size_t dest_len, size_t src_len, int flags)
{
return 0;
}
-/****************************************************************************
+/**
Convert from ucs2 to unix charset and return the
allocated and converted string or NULL if an error occurred.
You must provide a zero terminated string.
The returning string will be zero terminated.
-****************************************************************************/
+**/
char *acnv_u2ux(const smb_ucs2_t *src)
{
return dest;
}
-/****************************************************************************
+/**
Convert from unix to ucs2 charset and return the
allocated and converted string or NULL if an error occurred.
You must provide a zero terminated string.
The returning string will be zero terminated.
-****************************************************************************/
+**/
smb_ucs2_t *acnv_uxu2(const char *src)
{
return dest;
}
-/****************************************************************************
+/**
Convert from ucs2 to dos charset and return the
allocated and converted string or NULL if an error occurred.
You must provide a zero terminated string.
The returning string will be zero terminated.
-****************************************************************************/
+**/
char *acnv_u2dos(const smb_ucs2_t *src)
{
return dest;
}
-/****************************************************************************
+/**
Convert from dos to ucs2 charset and return the
allocated and converted string or NULL if an error occurred.
You must provide a zero terminated string.
The returning string will be zero terminated.
-****************************************************************************/
+**/
smb_ucs2_t *acnv_dosu2(const char *src)
{
#include "includes.h"
static BOOL enlarge_hash_table(hash_table *table);
-static int primes[] =
+static unsigned primes[] =
{17, 37, 67, 131, 257, 521, 1031, 2053, 4099, 8209, 16411};
/****************************************************************************
****************************************************************************
*/
-BOOL hash_table_init(hash_table *table, int num_buckets, compare_function compare_func)
+BOOL hash_table_init(hash_table *table, unsigned num_buckets, compare_function compare_func)
{
- int i;
+ unsigned i;
ubi_dlList *bucket;
table->num_elements = 0;
{
hash_element *hash_elem;
ubi_dlNodePtr lru_item;
- int i = 0;
+ unsigned int i = 0;
for (hash_elem = (hash_element *)(ubi_dlFirst(hash_chain)); i < hash_chain->count;
i++, hash_elem = (hash_element *)(ubi_dlNext(hash_elem))) {
hash_element *hash_elem;
ubi_dlNodePtr lru_item;
ubi_dlList *bucket;
+ size_t string_length;
/*
* If the hash table size has not reached the MAX_HASH_TABLE_SIZE,
* string.
*/
- if(!(hash_elem = (hash_element *) malloc(sizeof(hash_element) + strlen(key)))) {
+ string_length = strlen(key);
+ if(!(hash_elem = (hash_element *) malloc(sizeof(hash_element) + string_length))) {
DEBUG(0,("hash_insert: malloc fail !\n"));
return (hash_element *)NULL;
}
- safe_strcpy((char *) hash_elem->key, key, strlen(key)+1);
+ safe_strcpy((char *) hash_elem->key, key, string_length);
hash_elem->value = (char *)value;
hash_elem->bucket = bucket;
void hash_clear(hash_table *table)
{
- int i;
+ unsigned int i;
ubi_dlList *bucket = table->buckets;
hash_element *hash_elem;
for (i = 0; i < table->size; bucket++, i++) {
memset(buf, 0, sizeof(buf));
slprintf(buf, sizeof(buf) - 1, "%u\n", (unsigned int) sys_getpid());
- if (write(fd, buf, strlen(buf)) != strlen(buf)) {
+ if (write(fd, buf, strlen(buf)) != (ssize_t)strlen(buf)) {
DEBUG(0,("ERROR: can't write to file %s: %s\n",
pidFile, strerror(errno)));
exit(1);
****************************************************************************/
BOOL null_mtime(time_t mtime)
{
- if (mtime == 0 || mtime == 0xFFFFFFFF || mtime == (time_t)-1)
+ if (mtime == 0 || mtime == (time_t)0xFFFFFFFF || mtime == (time_t)-1)
return(True);
return(False);
}
int n;
if (global_myname() == NULL || *global_myname() == '\0') {
- fstring name;
-
- fstrcpy( name, myhostname() );
- p = strchr( name, '.' );
- if (p)
- *p = 0;
- if (!set_global_myname(name)) {
+ if (!set_global_myname(myhostname())) {
DEBUG( 0, ( "init_structs: malloc fail.\n" ) );
return False;
}
Like atoi but gets the value up to the separator character.
****************************************************************************/
-static char *Atoic(char *p, int *n, char *c)
+static const char *Atoic(const char *p, int *n, const char *c)
{
- if (!isdigit((int)*p)) {
+ if (!isdigit((const int)*p)) {
DEBUG(5, ("Atoic: malformed number\n"));
return NULL;
}
Reads a list of numbers.
*************************************************************************/
-char *get_numlist(char *p, uint32 **num, int *count)
+const char *get_numlist(const char *p, uint32 **num, int *count)
{
int val;
Get my own domain name.
****************************************************************************/
-BOOL get_mydomname(char *my_domname)
+BOOL get_mydomname(fstring my_domname)
{
pstring hostname;
char *p;
return False;
}
+/*******************************************************************
+ Is the name specified our workgroup/domain.
+ Returns true if it is equal, false otherwise.
+********************************************************************/
+
+BOOL is_myworkgroup(const char *s)
+{
+ BOOL ret = False;
+
+ if (strequal(s, lp_workgroup())) {
+ ret=True;
+ }
+
+ DEBUG(8, ("is_myworkgroup(\"%s\") returns %d\n", s, ret));
+ return(ret);
+}
+
/*******************************************************************
Set the horrid remote_arch string based on an enum.
********************************************************************/
Simple case insensitive interface to a UNIX wildcard matcher.
*******************************************************************/
-BOOL unix_wild_match(char *pattern, char *string)
+BOOL unix_wild_match(const char *pattern, const char *string)
{
pstring p2, s2;
char *p;
while ((n = read(fd, buf, sizeof(buf))) > 0) {
tp = Realloc(p, total + n + 1);
if (!tp) {
- DEBUG(0,("file_pload: failed to exand buffer!\n"));
+ DEBUG(0,("file_pload: failed to expand buffer!\n"));
close(fd);
SAFE_FREE(p);
return NULL;
}
if (p) p[total] = 0;
+ /* FIXME: Perhaps ought to check that the command completed
+ * successfully (returned 0); if not the data may be
+ * truncated. */
sys_pclose(fd);
if (size) *size = total;
if (fd == -1) {
return False;
}
- if (write(fd, packet, length) != length) {
+ if (write(fd, packet, length) != (size_t)length) {
return False;
}
close(fd);
SEC_DESC *sd;
SEC_ACL *new_dacl, *the_acl;
SEC_ACE *new_ace_list = NULL;
- int new_ace_list_ndx = 0, i;
+ unsigned int new_ace_list_ndx = 0, i;
size_t size;
/* Currently we only process the dacl when creating the child. The
#include "includes.h"
-/****************************************************************************
- Get the next token from a string, return False if none found.
- Handles double-quotes.
- Based on a routine by GJC@VILLAGE.COM.
- Extensively modified by Andrew.Tridgell@anu.edu.au
-****************************************************************************/
-
+/**
+ * Get the next token from a string, return False if none found.
+ * Handles double-quotes.
+ *
+ * Based on a routine by GJC@VILLAGE.COM.
+ * Extensively modified by Andrew.Tridgell@anu.edu.au
+ **/
BOOL next_token(const char **ptr,char *buff, const char *sep, size_t bufsize)
{
const char *s;
return(True);
}
-/****************************************************************************
+/**
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 char *last_ptr=NULL;
last_ptr = ptr;
}
-/****************************************************************************
+/**
Convert list of tokens to array; dependent on above routine.
Uses last_ptr from above - bit of a hack.
-****************************************************************************/
+**/
char **toktocliplist(int *ctok, const char *sep)
{
return ret;
}
-/*******************************************************************
+/**
Case insensitive string compararison.
-********************************************************************/
+**/
int StrCaseCmp(const char *s, const char *t)
{
return strcmp(buf1,buf2);
}
-/*******************************************************************
+/**
Case insensitive string compararison, length limited.
-********************************************************************/
+**/
int StrnCaseCmp(const char *s, const char *t, size_t n)
{
return strncmp(buf1,buf2,n);
}
-/*******************************************************************
+/**
Compare 2 strings.
-********************************************************************/
+**/
BOOL strequal(const char *s1, const char *s2)
{
return(StrCaseCmp(s1,s2)==0);
}
-/*******************************************************************
+/**
Compare 2 strings up to and including the nth char.
-******************************************************************/
+**/
BOOL strnequal(const char *s1,const char *s2,size_t n)
{
return(StrnCaseCmp(s1,s2,n)==0);
}
-/*******************************************************************
+/**
Compare 2 strings (case sensitive).
-********************************************************************/
+**/
BOOL strcsequal(const char *s1,const char *s2)
{
return(strcmp(s1,s2)==0);
}
-/***************************************************************************
+/**
Do a case-insensitive, whitespace-ignoring string compare.
-***************************************************************************/
+**/
int strwicmp(const char *psz1, const char *psz2)
{
}
-/*******************************************************************
+/**
Convert a string to upper case, but don't modify it.
-********************************************************************/
+**/
char *strupper_static(const char *s)
{
return str;
}
-/*******************************************************************
+/**
Convert a string to "normal" form.
-********************************************************************/
+**/
void strnorm(char *s)
{
strlower(s);
}
-/*******************************************************************
+/**
Check if a string is in "normal" case.
-********************************************************************/
+**/
BOOL strisnormal(const char *s)
{
}
-/****************************************************************************
+/**
String replace.
NOTE: oldc and newc must be 7 bit characters
-****************************************************************************/
+**/
void string_replace(char *s,char oldc,char newc)
{
pull_ucs2(NULL, s, tmpbuf, -1, sizeof(tmpbuf), STR_TERMINATE);
}
-/*******************************************************************
+/**
Skip past some strings in a buffer.
-********************************************************************/
+**/
char *skip_string(char *buf,size_t n)
{
return(buf);
}
-/*******************************************************************
+/**
Count the number of characters in a string. Normally this will
be the same as the number of bytes in a string for single byte strings,
but will be different for multibyte.
-********************************************************************/
+**/
size_t str_charnum(const char *s)
{
return strlen_w(tmpbuf2);
}
-/*******************************************************************
+/**
Count the number of characters in a string. Normally this will
be the same as the number of bytes in a string for single byte strings,
but will be different for multibyte.
-********************************************************************/
+**/
size_t str_ascii_charnum(const char *s)
{
return strlen(tmpbuf2);
}
-/*******************************************************************
+/**
Trim the specified elements off the front and back of a string.
-********************************************************************/
+**/
BOOL trim_string(char *s,const char *front,const char *back)
{
return ret;
}
-/****************************************************************************
+/**
Does a string have any uppercase chars in it?
-****************************************************************************/
+**/
BOOL strhasupper(const char *s)
{
return(False);
}
-/****************************************************************************
+/**
Does a string have any lowercase chars in it?
-****************************************************************************/
+**/
BOOL strhaslower(const char *s)
{
return(False);
}
-/****************************************************************************
+/**
Find the number of 'c' chars in a string
-****************************************************************************/
+**/
size_t count_chars(const char *s,char c)
{
return(count);
}
-/*******************************************************************
+/**
Return True if a string consists only of one particular character.
-********************************************************************/
+**/
BOOL str_is_all(const char *s,char c)
{
return True;
}
-/*******************************************************************
+/**
Safe string copy into a known length string. maxlength does not
include the terminating zero.
-********************************************************************/
+**/
char *safe_strcpy(char *dest,const char *src, size_t maxlength)
{
return NULL;
}
+#ifdef DEVELOPER
+ /* We intentionally write out at the extremity of the destination
+ * string. If the destination is too short (e.g. pstrcpy into mallocd
+ * or fstring) then this should cause an error under a memory
+ * checker. */
+ dest[maxlength] = '\0';
+#endif
+
if (!src) {
*dest = 0;
return dest;
len = strlen(src);
if (len > maxlength) {
- DEBUG(0,("ERROR: string overflow by %d in safe_strcpy [%.50s]\n",
- (int)(len-maxlength), src));
+ DEBUG(0,("ERROR: string overflow by %u (%u - %u) in safe_strcpy [%.50s]\n",
+ (unsigned int)(len-maxlength), len, maxlength, src));
len = maxlength;
}
return dest;
}
-/*******************************************************************
+/**
Safe string cat into a string. maxlength does not
include the terminating zero.
-********************************************************************/
+**/
char *safe_strcat(char *dest, const char *src, size_t maxlength)
{
return dest;
}
-/*******************************************************************
+/**
Paranoid strcpy into a buffer of given length (includes terminating
zero. Strips out all but 'a-Z0-9' and the character in other_safe_chars
and replaces with '_'. Deliberately does *NOT* check for multibyte
characters. Don't change it !
-********************************************************************/
+**/
char *alpha_strcpy(char *dest, const char *src, const char *other_safe_chars, size_t maxlength)
{
return dest;
}
-/****************************************************************************
+/**
Like strncpy but always null terminates. Make sure there is room!
The variable n should always be one less than the available size.
-****************************************************************************/
+**/
char *StrnCpy(char *dest,const char *src,size_t n)
{
return(dest);
}
-/****************************************************************************
+/**
Like strncpy but copies up to the character marker. always null terminates.
returns a pointer to the character marker in the source string (src).
-****************************************************************************/
+**/
char *strncpyn(char *dest, const char *src, size_t n, char c)
{
return p;
}
-/*************************************************************
+/**
Routine to get hex characters and turn them into a 16 byte array.
the array can be variable length, and any non-hex-numeric
characters are skipped. "0xnn" or "0Xnn" is specially catered
valid examples: "0A5D15"; "0x15, 0x49, 0xa2"; "59\ta9\te3\n"
-**************************************************************/
+**/
size_t strhex_to_str(char *p, size_t len, const char *strhex)
{
return num_chars;
}
-/****************************************************************************
+/**
Check if a string is part of a list.
-****************************************************************************/
+**/
BOOL in_list(char *s,char *list,BOOL casesensitive)
{
/* this is used to prevent lots of mallocs of size 1 */
static char *null_string = NULL;
-/****************************************************************************
+/**
Set a string value, allocing the space for the string
-****************************************************************************/
+**/
static BOOL string_init(char **dest,const char *src)
{
return(True);
}
-/****************************************************************************
+/**
Free a string value.
-****************************************************************************/
+**/
void string_free(char **s)
{
SAFE_FREE(*s);
}
-/****************************************************************************
+/**
Set a string value, deallocating any existing space, and allocing the space
for the string
-****************************************************************************/
+**/
BOOL string_set(char **dest,const char *src)
{
return(string_init(dest,src));
}
-/****************************************************************************
+/**
Substitute a string for a pattern in another string. Make sure there is
enough room!
Any of " ; ' $ or ` in the insert string are replaced with _
if len==0 then the string cannot be extended. This is different from the old
use of len==0 which was for no length checks to be done.
-****************************************************************************/
+**/
void string_sub(char *s,const char *pattern, const char *insert, size_t len)
{
string_sub(s, pattern, insert, sizeof(pstring));
}
-/****************************************************************************
+/**
Similar to string_sub, but it will accept only allocated strings
and may realloc them so pay attention at what you pass on no
pointers inside strings, no pstrings or const may be passed
as string.
-****************************************************************************/
+**/
char *realloc_string_sub(char *string, const char *pattern, const char *insert)
{
return string;
}
-/****************************************************************************
+/**
Similar to string_sub() but allows for any character to be substituted.
Use with caution!
if len==0 then the string cannot be extended. This is different from the old
use of len==0 which was for no length checks to be done.
-****************************************************************************/
+**/
void all_string_sub(char *s,const char *pattern,const char *insert, size_t len)
{
}
}
-/****************************************************************************
+/**
Similar to all_string_sub but for unicode strings.
Return a new allocated unicode string.
similar to string_sub() but allows for any character to be substituted.
Use with caution!
-****************************************************************************/
+**/
smb_ucs2_t *all_string_sub_w(const smb_ucs2_t *s, const smb_ucs2_t *pattern,
const smb_ucs2_t *insert)
return all_string_sub_w(s, p, i);
}
-/****************************************************************************
+/**
Splits out the front and back at a separator.
-****************************************************************************/
+**/
void split_at_last_component(char *path, char *front, char sep, char *back)
{
}
}
-/****************************************************************************
+/**
Write an octal as a string.
-****************************************************************************/
+**/
const char *octal_string(int i)
{
}
-/****************************************************************************
+/**
Truncate a string at a specified length.
-****************************************************************************/
+**/
char *string_truncate(char *s, int length)
{
return s;
}
-/****************************************************************************
+/**
Strchr and strrchr_m are very hard to do on general multi-byte strings.
We convert via ucs2 for now.
-****************************************************************************/
+**/
char *strchr_m(const char *s, char c)
{
return (char *)(s+strlen(s2));
}
-/*******************************************************************
+/**
Convert a string to lower case.
-********************************************************************/
+**/
void strlower_m(char *s)
{
unix_strlower(s,strlen(s)+1,s,strlen(s)+1);
}
-/*******************************************************************
+/**
Duplicate convert a string to lower case.
-********************************************************************/
+**/
char *strdup_lower(const char *s)
{
return t;
}
-/*******************************************************************
+/**
Convert a string to upper case.
-********************************************************************/
+**/
void strupper_m(char *s)
{
unix_strupper(s,strlen(s)+1,s,strlen(s)+1);
}
-/*******************************************************************
+/**
Convert a string to upper case.
-********************************************************************/
+**/
char *strdup_upper(const char *s)
{
return t;
}
-/*******************************************************************
+/**
Return a RFC2254 binary string representation of a buffer.
Used in LDAP filters.
Caller must free.
-********************************************************************/
+**/
char *binary_string(char *buf, int len)
{
return s;
}
-/*******************************************************************
+/**
Just a typesafety wrapper for snprintf into a pstring.
-********************************************************************/
+**/
int pstr_sprintf(pstring s, const char *fmt, ...)
{
return ret;
}
-/*******************************************************************
+/**
Just a typesafety wrapper for snprintf into a fstring.
-********************************************************************/
+**/
int fstr_sprintf(fstring s, const char *fmt, ...)
{
}
#ifndef HAVE_STRNDUP
-/*******************************************************************
+/**
Some platforms don't have strndup.
-********************************************************************/
+**/
char *strndup(const char *s, size_t n)
{
#endif
#ifndef HAVE_STRNLEN
-/*******************************************************************
+/**
Some platforms don't have strnlen
-********************************************************************/
+**/
size_t strnlen(const char *s, size_t n)
{
}
#endif
-/***********************************************************
+/**
List of Strings manipulation functions
-***********************************************************/
+**/
#define S_LIST_ABS 16 /* List Allocation Block Size */
return True;
}
-/***********************************************************
- Return true if all the elements of the list match exactly.
-***********************************************************/
-
+/**
+ * Return true if all the elements of the list match exactly.
+ **/
BOOL str_list_compare(char **list1, char **list2)
{
int num;
}
-/***********************************************************
+/**
Unescape a URL encoded string, in place.
-***********************************************************/
+**/
void rfc1738_unescape(char *buf)
{
static const char *b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
-/***************************************************************************
-decode a base64 string into a DATA_BLOB - simple and slow algorithm
- ***************************************************************************/
+/**
+ * Decode a base64 string into a DATA_BLOB - simple and slow algorithm
+ **/
DATA_BLOB base64_decode_data_blob(const char *s)
{
int bit_offset, byte_offset, idx, i, n;
return decoded;
}
-/***************************************************************************
-decode a base64 string in-place - wrapper for the above
-***************************************************************************/
+/**
+ * Decode a base64 string in-place - wrapper for the above
+ **/
void base64_decode_inplace(char *s)
{
DATA_BLOB decoded = base64_decode_data_blob(s);
s[decoded.length] = '\0';
}
-/***************************************************************************
-encode a base64 string into a malloc()ed string caller to free.
-
-From SQUID: adopted from http://ftp.sunet.se/pub2/gnu/vm/base64-encode.c with adjustments
-***************************************************************************/
+/**
+ * Encode a base64 string into a malloc()ed string caller to free.
+ *
+ *From SQUID: adopted from http://ftp.sunet.se/pub2/gnu/vm/base64-encode.c with adjustments
+ **/
char * base64_encode_data_blob(DATA_BLOB data)
{
int bits = 0;
return (c == c2);
}
-/*******************************************************************
-load the valid character map table
-********************************************************************/
+/**
+ * Load the valid character map table from <tt>valid.dat</tt> or
+ * create from the configured codepage.
+ *
+ * This function is called whenever the configuration is reloaded.
+ * However, the valid character table is not changed if it's loaded
+ * from a file, because we can't unmap files.
+ **/
void init_valid_table(void)
{
static int initialised;
return;
}
+ /* Otherwise, using a dynamically loaded one. */
if (valid_table) free(valid_table);
DEBUG(2,("creating default valid table\n"));
}
+
/*******************************************************************
Write a string in (little-endian) unicode format. src is in
the current DOS codepage. len is the length in bytes of the
}
/* simulate fwrite() */
-int x_fwrite(const void *p, size_t size, size_t nmemb, XFILE *f)
+size_t x_fwrite(const void *p, size_t size, size_t nmemb, XFILE *f)
{
- int ret, total=0;
+ ssize_t ret;
+ size_t total=0;
/* we might be writing unbuffered */
if (f->buftype == X_IONBF ||
while (total < size*nmemb) {
- int n = f->bufsize - f->bufused;
+ size_t n = f->bufsize - f->bufused;
n = MIN(n, (size*nmemb)-total);
if (n == 0) {
if (!pwd) {
new_sam_acct = NULL;
- return NT_STATUS_UNSUCCESSFUL;
+ return NT_STATUS_INVALID_PARAMETER;
}
if (!NT_STATUS_IS_OK(nt_status = pdb_init_sam(new_sam_acct))) {
pdb_free_sam(&sam_account);
if (pdb_getgrsid(&map, *sid, MAPPING_WITHOUT_PRIV)) {
- if (map.gid!=-1) {
+ if (map.gid!=(gid_t)-1) {
DEBUG(5,("local_lookup_sid: mapped group %s to gid %u\n", map.nt_name, (unsigned int)map.gid));
} else {
DEBUG(5,("local_lookup_sid: mapped group %s to no unix gid. Returning name.\n", map.nt_name));
if (pdb_getgrsid(&map, *psid, MAPPING_WITHOUT_PRIV)) {
/* the SID is in the mapping table but not mapped */
- if (map.gid==-1)
+ if (map.gid==(gid_t)-1)
return False;
*pgid = map.gid;
/*************************************************************
Change a password entry in the local smbpasswd file.
- FIXME!! The function needs to be abstracted into the
- passdb interface or something. It is currently being called
- by _api_samr_create_user() in rpc_server/srv_samr.c,
- in SWAT and by smbpasswd/pdbedit.
+It is currently being called by SWAT and by smbpasswd.
--jerry
*************************************************************/
/*******************************************************************
chmod a file - but preserve some bits
********************************************************************/
-int file_chmod(connection_struct *conn,char *fname,int dosmode,SMB_STRUCT_STAT *st)
+int file_chmod(connection_struct *conn,char *fname, uint32 dosmode,SMB_STRUCT_STAT *st)
{
SMB_STRUCT_STAT st1;
int mask=0;
*/
static BOOL is_mangled_component(const char *name)
{
- int len, i;
+ unsigned int len, i;
M_DEBUG(10,("is_mangled_component %s ?\n", name));
static BOOL check_cache(char *name)
{
u32 hash, multiplier;
- int i;
+ unsigned int i;
const char *prefix;
char extension[4];
char *dot_p;
char lead_chars[7];
char extension[4];
- int extension_length, i;
- int prefix_len;
+ unsigned int extension_length, i;
+ unsigned int prefix_len;
u32 hash, v;
char new_name[13];