-/*
+/*
Unix SMB/CIFS implementation.
minimal iconv implementation
Copyright (C) Andrew Tridgell 2001
Copyright (C) Jelmer Vernooij 2002
-
+
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/>.
*/
{"ASCII", ascii_pull, ascii_push},
{"646", ascii_pull, ascii_push},
{"ISO-8859-1", latin1_pull, latin1_push},
-#ifdef DEVELOPER
+#ifdef DEVELOPER
{"WEIRD", weird_pull, weird_push, true},
#endif
#ifdef DARWINOS
/* if there was an error then reset the internal state,
this ensures that we don't have a shift state remaining for
character sets like SJIS */
-static size_t sys_iconv(void *cd,
+static size_t sys_iconv(void *cd,
const char **inbuf, size_t *inbytesleft,
char **outbuf, size_t *outbytesleft)
{
- size_t ret = iconv((iconv_t)cd,
- discard_const_p(char *, inbuf), inbytesleft,
+ size_t ret = iconv((iconv_t)cd,
+ discard_const_p(char *, inbuf), inbytesleft,
outbuf, outbytesleft);
if (ret == (size_t)-1) iconv(cd, NULL, NULL, NULL, NULL);
return ret;
* It only knows about a very small number of character sets - just
* enough that Samba works on systems that don't have iconv.
**/
-_PUBLIC_ size_t smb_iconv(smb_iconv_t cd,
+_PUBLIC_ size_t smb_iconv(smb_iconv_t cd,
const char **inbuf, size_t *inbytesleft,
char **outbuf, size_t *outbytesleft)
{
/* in many cases we can go direct */
if (cd->direct) {
- return cd->direct(cd->cd_direct,
+ return cd->direct(cd->cd_direct,
inbuf, inbytesleft, outbuf, outbytesleft);
}
int i;
ret = (smb_iconv_t)talloc_named(mem_ctx,
- sizeof(*ret),
+ sizeof(*ret),
"iconv(%s,%s)", tocode, fromcode);
if (!ret) {
errno = ENOMEM;
from = &builtin_functions[i];
}
}
- if (strcasecmp(tocode, builtin_functions[i].name) == 0) {
+ if (strcasecmp(tocode, builtin_functions[i].name) == 0) {
if (use_builtin_handlers || builtin_functions[i].samba_internal_charset) {
to = &builtin_functions[i];
}
ret->pull = sys_iconv;
}
}
-
+
if (to == NULL) {
ret->cd_push = iconv_open(tocode, "UTF-16LE");
if (ret->cd_push == (iconv_t)-1)
if (ret->pull == NULL && from == NULL) {
goto failed;
}
-
+
if (ret->push == NULL && to == NULL) {
goto failed;
}
errno = E2BIG;
return -1;
}
-
+
return 0;
}
errno = E2BIG;
return -1;
}
-
+
return ir_count;
}
errno = EINVAL;
return -1;
}
-
+
if (sscanf(&(*inbuf)[1], "%04x", &v) != 1) {
errno = EILSEQ;
return -1;
errno = E2BIG;
return -1;
}
-
+
return 0;
}
while (*inbytesleft >= 2 && *outbytesleft >= 1) {
char buf[6];
- if ((*inbuf)[1] == 0 &&
+ if ((*inbuf)[1] == 0 &&
((*inbuf)[0] & 0x80) == 0 &&
(*inbuf)[0] != '@') {
(*outbuf)[0] = (*inbuf)[0];
errno = E2BIG;
return -1;
}
-
+
return 0;
}
if ((c[0] & 0xf0) == 0xe0) {
if (in_left < 3 ||
- (c[1] & 0xc0) != 0x80 ||
+ (c[1] & 0xc0) != 0x80 ||
(c[2] & 0xc0) != 0x80) {
errno = EILSEQ;
goto error;
if ((c[0] & 0xf8) == 0xf0) {
unsigned int codepoint;
if (in_left < 4 ||
- (c[1] & 0xc0) != 0x80 ||
+ (c[1] & 0xc0) != 0x80 ||
(c[2] & 0xc0) != 0x80 ||
(c[3] & 0xc0) != 0x80) {
errno = EILSEQ;
goto error;
}
- codepoint =
- (c[3]&0x3f) |
- ((c[2]&0x3f)<<6) |
+ codepoint =
+ (c[3]&0x3f) |
+ ((c[2]&0x3f)<<6) |
((c[1]&0x3f)<<12) |
((c[0]&0x7)<<18);
if (codepoint < 0x10000) {
c[0] = 0xe0 | (codepoint >> 12);
c[1] = 0x80 | ((codepoint >> 6) & 0x3f);
c[2] = 0x80 | (codepoint & 0x3f);
-
+
in_left -= 2;
out_left -= 3;
uc += 2;
errno = EILSEQ;
goto error;
}
- codepoint = 0x10000 + (uc[2] | ((uc[3] & 0x3)<<8) |
+ codepoint = 0x10000 + (uc[2] | ((uc[3] & 0x3)<<8) |
(uc[0]<<10) | ((uc[1] & 0x3)<<18));
-
+
if (out_left < 4) {
errno = E2BIG;
goto error;
c[1] = 0x80 | ((codepoint >> 12) & 0x3f);
c[2] = 0x80 | ((codepoint >> 6) & 0x3f);
c[3] = 0x80 | (codepoint & 0x3f);
-
+
in_left -= 4;
out_left -= 4;
uc += 4;
*outbytesleft = out_left;
*inbuf = (const char *)uc;
*outbuf = (char *)c;
-
+
return 0;
error:
unsigned int codepoint2;
if (in_left < 4) {
codepoint = 0xfffd;
- goto codepoint16;
+ goto codepoint16;
}
codepoint2 = uc[2] | (uc[3]<<8);
if ((codepoint2 & 0xfc00) != 0xdc00) {
codepoint16:
c[0] = codepoint & 0xFF;
c[1] = (codepoint>>8) & 0xFF;
-
+
in_left -= 2;
out_left -= 2;
uc += 2;
c += 2;
- continue;
+ continue;
}
if (in_left == 1) {
*outbytesleft = out_left;
*inbuf = (const char *)uc;
*outbuf = (char *)c;
-
+
return 0;
error:
-/*
+/*
Unix SMB/CIFS implementation.
very efficient functions to manage mapping a id (such as a fnum) to
Copyright (C) Andrew Tridgell 2004
- This code is derived from lib/idr.c in the 2.6 Linux kernel, which was
+ This code is derived from lib/idr.c in the 2.6 Linux kernel, which was
written by Jim Houston jim.houston@ccur.com, and is
Copyright (C) 2002 by Concurrent Computer Corporation
-
+
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
(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/>.
*/
#define set_bit(bit, v) (v) |= (1<<(bit))
#define clear_bit(bit, v) (v) &= ~(1<<(bit))
#define test_bit(bit, v) ((v) & (1<<(bit)))
-
+
struct idr_layer {
uint32_t bitmap;
struct idr_layer *ary[IDR_SIZE];
int layers, v, id;
idr_pre_get(idp);
-
+
id = starting_id;
build_up:
p = idp->top;
return -1;
}
- if ( idp->top && idp->top->count == 1 &&
+ if ( idp->top && idp->top->count == 1 &&
(idp->layers > 1) &&
idp->top->ary[0]) {
/* We can drop a layer */
* Copyright (C) Andrew Tridgell 1992-1998 Modified by Jeremy Allison 1995.
*
* Added afdgets() Jelmer Vernooij 2005
- *
+ *
* 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/>.
*/
*/
/**
-read a line from a file with possible \ continuation chars.
+read a line from a file with possible \ continuation chars.
Blanks at the start or end of a line are stripped.
The string will be allocated if s2 is NULL
**/
}
return(s);
case EOF:
- if (len <= 0 && !s2)
+ if (len <= 0 && !s2)
SAFE_FREE(s);
return(len>0?s:NULL);
case ' ':
if (!s2 && len > maxlen-3)
{
char *t;
-
+
maxlen *= 2;
t = realloc_p(s, char, maxlen);
if (!t) {
}
/**
- * Read one line (data until next newline or eof) and allocate it
+ * Read one line (data until next newline or eof) and allocate it
*/
_PUBLIC_ char *afdgets(int fd, TALLOC_CTX *mem_ctx, size_t hint)
{
char *p;
if (!fname || !*fname) return NULL;
-
+
fd = open(fname,O_RDONLY);
if (fd == -1) return NULL;
#ifdef HAVE_MMAP
if (munmap( start, size ) != 0) {
DEBUG( 1, ("map_file: Failed to unmap address %p "
- "of size %u - %s\n",
+ "of size %u - %s\n",
start, (unsigned int)size, strerror(errno) ));
return false;
}
if (!ret) {
talloc_free(p);
return NULL;
- }
-
+ }
+
talloc_steal(ret, p);
-
+
memset(ret, 0, sizeof(ret[0])*(i+2));
ret[0] = p;
/**
load a file into memory and return an array of pointers to lines in the file
-must be freed with talloc_free().
+must be freed with talloc_free().
**/
_PUBLIC_ char **file_lines_load(const char *fname, int *numlines, size_t maxsize, TALLOC_CTX *mem_ctx)
{