2 Unix SMB/CIFS implementation.
3 Samba utility functions
4 Copyright (C) Andrew Tridgell 1992-2001
5 Copyright (C) Simo Sorce 2001
6 Copyright (C) Jeremy Allison 2005
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
28 /* these 3 tables define the unicode case handling. They are loaded
29 at startup either via mmap() or read() from the lib directory */
30 static smb_ucs2_t
*upcase_table
;
31 static smb_ucs2_t
*lowcase_table
;
32 static uint8
*valid_table
;
33 static bool upcase_table_use_unmap
;
34 static bool lowcase_table_use_unmap
;
35 static bool valid_table_use_unmap
;
36 static bool initialized
;
39 * Destroy global objects allocated by load_case_tables()
41 void gfree_case_tables(void)
44 if ( upcase_table_use_unmap
)
45 unmap_file(upcase_table
, 0x20000);
47 SAFE_FREE(upcase_table
);
50 if ( lowcase_table
) {
51 if ( lowcase_table_use_unmap
)
52 unmap_file(lowcase_table
, 0x20000);
54 SAFE_FREE(lowcase_table
);
58 if ( valid_table_use_unmap
)
59 unmap_file(valid_table
, 0x10000);
61 SAFE_FREE(valid_table
);
67 * Load or generate the case handling tables.
69 * The case tables are defined in UCS2 and don't depend on any
70 * configured parameters, so they never need to be reloaded.
73 void load_case_tables(void)
75 char *old_locale
= NULL
, *saved_locale
= NULL
;
77 TALLOC_CTX
*frame
= NULL
;
84 frame
= talloc_stackframe();
86 upcase_table
= (smb_ucs2_t
*)map_file(data_path("upcase.dat"),
88 upcase_table_use_unmap
= ( upcase_table
!= NULL
);
90 lowcase_table
= (smb_ucs2_t
*)map_file(data_path("lowcase.dat"),
92 lowcase_table_use_unmap
= ( lowcase_table
!= NULL
);
95 /* Get the name of the current locale. */
96 old_locale
= setlocale(LC_ALL
, NULL
);
99 /* Save it as it is in static storage. */
100 saved_locale
= SMB_STRDUP(old_locale
);
103 /* We set back the locale to C to get ASCII-compatible toupper/lower functions. */
104 setlocale(LC_ALL
, "C");
107 /* we would like Samba to limp along even if these tables are
110 DEBUG(1,("creating lame upcase table\n"));
111 upcase_table
= (smb_ucs2_t
*)SMB_MALLOC(0x20000);
112 for (i
=0;i
<0x10000;i
++) {
117 for (i
=0;i
<256;i
++) {
119 SSVAL(&v
, 0, UCS2_CHAR(i
));
120 upcase_table
[v
] = UCS2_CHAR(islower(i
)?toupper(i
):i
);
124 if (!lowcase_table
) {
125 DEBUG(1,("creating lame lowcase table\n"));
126 lowcase_table
= (smb_ucs2_t
*)SMB_MALLOC(0x20000);
127 for (i
=0;i
<0x10000;i
++) {
130 lowcase_table
[v
] = i
;
132 for (i
=0;i
<256;i
++) {
134 SSVAL(&v
, 0, UCS2_CHAR(i
));
135 lowcase_table
[v
] = UCS2_CHAR(isupper(i
)?tolower(i
):i
);
139 #ifdef HAVE_SETLOCALE
140 /* Restore the old locale. */
142 setlocale (LC_ALL
, saved_locale
);
143 SAFE_FREE(saved_locale
);
149 static int check_dos_char_slowly(smb_ucs2_t c
)
155 len1
= convert_string(CH_UTF16LE
, CH_DOS
, &c
, 2, buf
, sizeof(buf
),False
);
159 len2
= convert_string(CH_DOS
, CH_UTF16LE
, buf
, len1
, &c2
, 2,False
);
167 * Load the valid character map table from <tt>valid.dat</tt> or
168 * create from the configured codepage.
170 * This function is called whenever the configuration is reloaded.
171 * However, the valid character table is not changed if it's loaded
172 * from a file, because we can't unmap files.
175 void init_valid_table(void)
177 static int mapped_file
;
179 const char *allowed
= ".!#$%&'()_-@^`~";
183 /* Can't unmap files, so stick with what we have */
187 valid_file
= (uint8
*)map_file(data_path("valid.dat"), 0x10000);
189 valid_table
= valid_file
;
191 valid_table_use_unmap
= True
;
195 /* Otherwise, we're using a dynamically created valid_table.
196 * It might need to be regenerated if the code page changed.
197 * We know that we're not using a mapped file, so we can
198 * free() the old one. */
199 SAFE_FREE(valid_table
);
201 /* use free rather than unmap */
202 valid_table_use_unmap
= False
;
204 DEBUG(2,("creating default valid table\n"));
205 valid_table
= (uint8
*)SMB_MALLOC(0x10000);
206 SMB_ASSERT(valid_table
!= NULL
);
207 for (i
=0;i
<128;i
++) {
208 valid_table
[i
] = isalnum(i
) || strchr(allowed
,i
);
211 lazy_initialize_conv();
213 for (;i
<0x10000;i
++) {
216 valid_table
[i
] = check_dos_char_slowly(c
);
220 /*******************************************************************
221 Write a string in (little-endian) unicode format. src is in
222 the current DOS codepage. len is the length in bytes of the
223 string pointed to by dst.
225 if null_terminate is True then null terminate the packet (adds 2 bytes)
227 the return value is the length in bytes consumed by the string, including the
228 null termination if applied
229 ********************************************************************/
231 size_t dos_PutUniCode(char *dst
,const char *src
, size_t len
, bool null_terminate
)
233 int flags
= null_terminate
? STR_UNICODE
|STR_NOALIGN
|STR_TERMINATE
234 : STR_UNICODE
|STR_NOALIGN
;
235 return push_ucs2(NULL
, dst
, src
, len
, flags
);
239 /*******************************************************************
240 Skip past a unicode string, but not more than len. Always move
241 past a terminating zero if found.
242 ********************************************************************/
244 char *skip_unibuf(char *src
, size_t len
)
246 char *srcend
= src
+ len
;
248 while (src
< srcend
&& SVAL(src
,0)) {
259 /* Copy a string from little-endian or big-endian unicode source (depending
260 * on flags) to internal samba format destination
263 int rpcstr_pull(char* dest
, void *src
, int dest_len
, int src_len
, int flags
)
272 return pull_ucs2(NULL
, dest
, src
, dest_len
, src_len
, flags
|STR_UNICODE
|STR_NOALIGN
);
275 /* Copy a string from little-endian or big-endian unicode source (depending
276 * on flags) to internal samba format destination. Allocates on talloc ctx.
279 int rpcstr_pull_talloc(TALLOC_CTX
*ctx
,
285 return pull_ucs2_base_talloc(ctx
,
290 flags
|STR_UNICODE
|STR_NOALIGN
);
294 /* Copy a string from a unistr2 source to internal samba format
295 destination. Use this instead of direct calls to rpcstr_pull() to avoid
296 having to determine whether the source string is null terminated. */
298 int rpcstr_pull_unistr2_fstring(char *dest
, UNISTR2
*src
)
300 return pull_ucs2(NULL
, dest
, src
->buffer
, sizeof(fstring
),
301 src
->uni_str_len
* 2, 0);
304 /* Helper function to return a talloc'ed string. I have implemented it with a
305 * copy because I don't really know how pull_ucs2 and friends calculate the
306 * target size. If this turns out to be a major bottleneck someone with deeper
307 * multi-byte knowledge needs to revisit this.
308 * I just did (JRA :-). No longer uses copy.
309 * My (VL) use is dsr_getdcname, which returns 6 strings, the alternative would
310 * have been to manually talloc_strdup them in rpc_client/cli_netlogon.c.
313 char *rpcstr_pull_unistr2_talloc(TALLOC_CTX
*ctx
, const UNISTR2
*src
)
318 if (!convert_string_talloc(ctx
, CH_UTF16LE
, CH_UNIX
, src
->buffer
,
319 src
->uni_str_len
* 2, (void *)&dest
,
325 /* Ensure we're returning a null terminated string. */
327 /* Did we already process the terminating zero ? */
328 if (dest
[dest_len
-1] != 0) {
329 size_t size
= talloc_get_size(dest
);
330 /* Have we got space to append the '\0' ? */
331 if (size
<= dest_len
) {
333 dest
= TALLOC_REALLOC_ARRAY(ctx
, dest
, char,
337 dest_len
= (size_t)-1;
342 dest
[dest_len
] = '\0';
352 /* Converts a string from internal samba format to unicode
355 int rpcstr_push(void *dest
, const char *src
, size_t dest_len
, int flags
)
357 return push_ucs2(NULL
, dest
, src
, dest_len
, flags
|STR_UNICODE
|STR_NOALIGN
);
360 /* Converts a string from internal samba format to unicode. Always terminates.
361 * Actually just a wrapper round push_ucs2_talloc().
364 int rpcstr_push_talloc(TALLOC_CTX
*ctx
, smb_ucs2_t
**dest
, const char *src
)
367 if (push_ucs2_talloc(ctx
, dest
, src
, &size
))
373 /*******************************************************************
374 Convert a (little-endian) UNISTR2 structure to an ASCII string.
375 ********************************************************************/
377 void unistr2_to_ascii(char *dest
, const UNISTR2
*str
, size_t maxlen
)
379 if ((str
== NULL
) || (str
->uni_str_len
== 0)) {
383 pull_ucs2(NULL
, dest
, str
->buffer
, maxlen
, str
->uni_str_len
*2, STR_NOALIGN
);
387 /*******************************************************************
388 Convert a (little-endian) UNISTR3 structure to an ASCII string.
389 ********************************************************************/
391 void unistr3_to_ascii(char *dest
, const UNISTR3
*str
, size_t maxlen
)
393 if ((str
== NULL
) || (str
->uni_str_len
== 0)) {
397 pull_ucs2(NULL
, dest
, str
->str
.buffer
, maxlen
, str
->uni_str_len
*2,
402 /*******************************************************************
403 Duplicate a UNISTR2 string into a null terminated char*
404 using a talloc context.
405 ********************************************************************/
407 char *unistr2_to_ascii_talloc(TALLOC_CTX
*ctx
, const UNISTR2
*str
)
411 if (!str
|| !str
->buffer
) {
414 if (pull_ucs2_base_talloc(ctx
,
419 STR_NOALIGN
) == (size_t)-1) {
425 /*******************************************************************
426 Return a string for displaying a UNISTR2. Guarentees to return a
427 valid string - "" if nothing else.
428 Changed to use talloc_tos() under the covers.... JRA.
429 ********************************************************************/
431 const char *unistr2_static(const UNISTR2
*str
)
435 if ((str
== NULL
) || (str
->uni_str_len
== 0)) {
439 dest
= unistr2_to_ascii_talloc(talloc_tos(), str
);
447 /*******************************************************************
448 Convert a wchar to upper case.
449 ********************************************************************/
451 smb_ucs2_t
toupper_w(smb_ucs2_t val
)
453 return upcase_table
[SVAL(&val
,0)];
456 /*******************************************************************
457 Convert a wchar to lower case.
458 ********************************************************************/
460 smb_ucs2_t
tolower_w( smb_ucs2_t val
)
462 return lowcase_table
[SVAL(&val
,0)];
465 /*******************************************************************
466 Determine if a character is lowercase.
467 ********************************************************************/
469 bool islower_w(smb_ucs2_t c
)
471 return upcase_table
[SVAL(&c
,0)] != c
;
474 /*******************************************************************
475 Determine if a character is uppercase.
476 ********************************************************************/
478 bool isupper_w(smb_ucs2_t c
)
480 return lowcase_table
[SVAL(&c
,0)] != c
;
483 /*******************************************************************
484 Determine if a character is valid in a 8.3 name.
485 ********************************************************************/
487 bool isvalid83_w(smb_ucs2_t c
)
489 return valid_table
[SVAL(&c
,0)] != 0;
492 /*******************************************************************
493 Count the number of characters in a smb_ucs2_t string.
494 ********************************************************************/
496 size_t strlen_w(const smb_ucs2_t
*src
)
501 for(len
= 0; *(COPY_UCS2_CHAR(&c
,src
)); src
++, len
++) {
508 /*******************************************************************
509 Count up to max number of characters in a smb_ucs2_t string.
510 ********************************************************************/
512 size_t strnlen_w(const smb_ucs2_t
*src
, size_t max
)
517 for(len
= 0; (len
< max
) && *(COPY_UCS2_CHAR(&c
,src
)); src
++, len
++) {
524 /*******************************************************************
526 ********************************************************************/
528 smb_ucs2_t
*strchr_w(const smb_ucs2_t
*s
, smb_ucs2_t c
)
531 while (*(COPY_UCS2_CHAR(&cp
,s
))) {
533 return (smb_ucs2_t
*)s
;
538 return (smb_ucs2_t
*)s
;
544 smb_ucs2_t
*strchr_wa(const smb_ucs2_t
*s
, char c
)
546 return strchr_w(s
, UCS2_CHAR(c
));
549 /*******************************************************************
551 ********************************************************************/
553 smb_ucs2_t
*strrchr_w(const smb_ucs2_t
*s
, smb_ucs2_t c
)
556 const smb_ucs2_t
*p
= s
;
557 int len
= strlen_w(s
);
564 if (c
== *(COPY_UCS2_CHAR(&cp
,p
))) {
565 return (smb_ucs2_t
*)p
;
571 /*******************************************************************
572 Wide version of strrchr that returns after doing strrchr 'n' times.
573 ********************************************************************/
575 smb_ucs2_t
*strnrchr_w(const smb_ucs2_t
*s
, smb_ucs2_t c
, unsigned int n
)
578 const smb_ucs2_t
*p
= s
;
579 int len
= strlen_w(s
);
581 if (len
== 0 || !n
) {
586 if (c
== *(COPY_UCS2_CHAR(&cp
,p
))) {
591 return (smb_ucs2_t
*)p
;
597 /*******************************************************************
599 ********************************************************************/
601 smb_ucs2_t
*strstr_w(const smb_ucs2_t
*s
, const smb_ucs2_t
*ins
)
606 if (!s
|| !*s
|| !ins
|| !*ins
) {
610 inslen
= strlen_w(ins
);
613 while ((r
= strchr_w(r
, *ins
))) {
614 if (strncmp_w(r
, ins
, inslen
) == 0) {
623 /*******************************************************************
624 Convert a string to lower case.
625 return True if any char is converted
626 ********************************************************************/
628 bool strlower_w(smb_ucs2_t
*s
)
633 while (*(COPY_UCS2_CHAR(&cp
,s
))) {
634 smb_ucs2_t v
= tolower_w(cp
);
636 COPY_UCS2_CHAR(s
,&v
);
644 /*******************************************************************
645 Convert a string to upper case.
646 return True if any char is converted
647 ********************************************************************/
649 bool strupper_w(smb_ucs2_t
*s
)
653 while (*(COPY_UCS2_CHAR(&cp
,s
))) {
654 smb_ucs2_t v
= toupper_w(cp
);
656 COPY_UCS2_CHAR(s
,&v
);
664 /*******************************************************************
665 Convert a string to "normal" form.
666 ********************************************************************/
668 void strnorm_w(smb_ucs2_t
*s
, int case_default
)
670 if (case_default
== CASE_UPPER
) {
677 int strcmp_w(const smb_ucs2_t
*a
, const smb_ucs2_t
*b
)
681 while ((*(COPY_UCS2_CHAR(&cpb
,b
))) && (*(COPY_UCS2_CHAR(&cpa
,a
)) == cpb
)) {
685 return (*(COPY_UCS2_CHAR(&cpa
,a
)) - *(COPY_UCS2_CHAR(&cpb
,b
)));
686 /* warning: if *a != *b and both are not 0 we return a random
687 greater or lesser than 0 number not realted to which
691 int strncmp_w(const smb_ucs2_t
*a
, const smb_ucs2_t
*b
, size_t len
)
696 while ((n
< len
) && (*(COPY_UCS2_CHAR(&cpb
,b
))) && (*(COPY_UCS2_CHAR(&cpa
,a
)) == cpb
)) {
701 return (len
- n
)?(*(COPY_UCS2_CHAR(&cpa
,a
)) - *(COPY_UCS2_CHAR(&cpb
,b
))):0;
704 /*******************************************************************
705 Case insensitive string comparison.
706 ********************************************************************/
708 int strcasecmp_w(const smb_ucs2_t
*a
, const smb_ucs2_t
*b
)
712 while ((*COPY_UCS2_CHAR(&cpb
,b
)) && toupper_w(*(COPY_UCS2_CHAR(&cpa
,a
))) == toupper_w(cpb
)) {
716 return (tolower_w(*(COPY_UCS2_CHAR(&cpa
,a
))) - tolower_w(*(COPY_UCS2_CHAR(&cpb
,b
))));
719 /*******************************************************************
720 Case insensitive string comparison, length limited.
721 ********************************************************************/
723 int strncasecmp_w(const smb_ucs2_t
*a
, const smb_ucs2_t
*b
, size_t len
)
728 while ((n
< len
) && *COPY_UCS2_CHAR(&cpb
,b
) && (toupper_w(*(COPY_UCS2_CHAR(&cpa
,a
))) == toupper_w(cpb
))) {
733 return (len
- n
)?(tolower_w(*(COPY_UCS2_CHAR(&cpa
,a
))) - tolower_w(*(COPY_UCS2_CHAR(&cpb
,b
)))):0;
736 /*******************************************************************
738 ********************************************************************/
740 bool strequal_w(const smb_ucs2_t
*s1
, const smb_ucs2_t
*s2
)
749 return(strcasecmp_w(s1
,s2
)==0);
752 /*******************************************************************
753 Compare 2 strings up to and including the nth char.
754 ******************************************************************/
756 bool strnequal_w(const smb_ucs2_t
*s1
,const smb_ucs2_t
*s2
,size_t n
)
761 if (!s1
|| !s2
|| !n
) {
765 return(strncasecmp_w(s1
,s2
,n
)==0);
768 /*******************************************************************
770 ********************************************************************/
772 smb_ucs2_t
*strdup_w(const smb_ucs2_t
*src
)
774 return strndup_w(src
, 0);
777 /* if len == 0 then duplicate the whole string */
779 smb_ucs2_t
*strndup_w(const smb_ucs2_t
*src
, size_t len
)
786 dest
= SMB_MALLOC_ARRAY(smb_ucs2_t
, len
+ 1);
788 DEBUG(0,("strdup_w: out of memory!\n"));
792 memcpy(dest
, src
, len
* sizeof(smb_ucs2_t
));
797 /*******************************************************************
798 Copy a string with max len.
799 ********************************************************************/
801 smb_ucs2_t
*strncpy_w(smb_ucs2_t
*dest
, const smb_ucs2_t
*src
, const size_t max
)
810 for (len
= 0; (*COPY_UCS2_CHAR(&cp
,(src
+len
))) && (len
< max
); len
++) {
811 cp
= *COPY_UCS2_CHAR(dest
+len
,src
+len
);
814 for ( /*nothing*/ ; len
< max
; len
++ ) {
815 cp
= *COPY_UCS2_CHAR(dest
+len
,&cp
);
821 /*******************************************************************
822 Append a string of len bytes and add a terminator.
823 ********************************************************************/
825 smb_ucs2_t
*strncat_w(smb_ucs2_t
*dest
, const smb_ucs2_t
*src
, const size_t max
)
835 start
= strlen_w(dest
);
836 len
= strnlen_w(src
, max
);
838 memcpy(&dest
[start
], src
, len
*sizeof(smb_ucs2_t
));
839 z
= *COPY_UCS2_CHAR(dest
+start
+len
,&z
);
844 smb_ucs2_t
*strcat_w(smb_ucs2_t
*dest
, const smb_ucs2_t
*src
)
854 start
= strlen_w(dest
);
857 memcpy(&dest
[start
], src
, len
*sizeof(smb_ucs2_t
));
858 z
= *COPY_UCS2_CHAR(dest
+start
+len
,&z
);
864 /*******************************************************************
865 Replace any occurence of oldc with newc in unicode string.
866 ********************************************************************/
868 void string_replace_w(smb_ucs2_t
*s
, smb_ucs2_t oldc
, smb_ucs2_t newc
)
872 for(;*(COPY_UCS2_CHAR(&cp
,s
));s
++) {
874 COPY_UCS2_CHAR(s
,&newc
);
879 /*******************************************************************
881 ********************************************************************/
883 bool trim_string_w(smb_ucs2_t
*s
, const smb_ucs2_t
*front
,
884 const smb_ucs2_t
*back
)
887 size_t len
, front_len
, back_len
;
895 if (front
&& *front
) {
896 front_len
= strlen_w(front
);
897 while (len
&& strncmp_w(s
, front
, front_len
) == 0) {
898 memmove(s
, (s
+ front_len
), (len
- front_len
+ 1) * sizeof(smb_ucs2_t
));
905 back_len
= strlen_w(back
);
906 while (len
&& strncmp_w((s
+ (len
- back_len
)), back
, back_len
) == 0) {
907 s
[len
- back_len
] = 0;
917 The *_wa() functions take a combination of 7 bit ascii
918 and wide characters They are used so that you can use string
919 functions combining C string constants with ucs2 strings
921 The char* arguments must NOT be multibyte - to be completely sure
922 of this only pass string constants */
924 int strcmp_wa(const smb_ucs2_t
*a
, const char *b
)
928 while (*b
&& *(COPY_UCS2_CHAR(&cp
,a
)) == UCS2_CHAR(*b
)) {
932 return (*(COPY_UCS2_CHAR(&cp
,a
)) - UCS2_CHAR(*b
));
935 int strncmp_wa(const smb_ucs2_t
*a
, const char *b
, size_t len
)
940 while ((n
< len
) && *b
&& *(COPY_UCS2_CHAR(&cp
,a
)) == UCS2_CHAR(*b
)) {
945 return (len
- n
)?(*(COPY_UCS2_CHAR(&cp
,a
)) - UCS2_CHAR(*b
)):0;
948 smb_ucs2_t
*strpbrk_wa(const smb_ucs2_t
*s
, const char *p
)
952 while (*(COPY_UCS2_CHAR(&cp
,s
))) {
954 for (i
=0; p
[i
] && cp
!= UCS2_CHAR(p
[i
]); i
++)
957 return (smb_ucs2_t
*)s
;
964 smb_ucs2_t
*strstr_wa(const smb_ucs2_t
*s
, const char *ins
)
973 inslen
= strlen(ins
);
976 while ((r
= strchr_w(r
, UCS2_CHAR(*ins
)))) {
977 if (strncmp_wa(r
, ins
, inslen
) == 0)
985 /*******************************************************************
986 Returns the length in number of wide characters.
987 ******************************************************************/
989 int unistrlen(uint16
*s
)
997 for (len
=0; SVAL(s
,0); s
++,len
++) {
1004 /*******************************************************************
1005 Strcpy for unicode strings. Returns length (in num of wide chars).
1007 ********************************************************************/
1009 int unistrcpy(uint16
*dst
, uint16
*src
)
1013 while (SVAL(src
,0)) {
1023 * Samba ucs2 type to UNISTR2 conversion
1025 * @param ctx Talloc context to create the dst strcture (if null) and the
1026 * contents of the unicode string.
1027 * @param dst UNISTR2 destination. If equals null, then it's allocated.
1028 * @param src smb_ucs2_t source.
1029 * @param max_len maximum number of unicode characters to copy. If equals
1030 * null, then null-termination of src is taken
1032 * @return copied UNISTR2 destination
1035 UNISTR2
* ucs2_to_unistr2(TALLOC_CTX
*ctx
, UNISTR2
* dst
, smb_ucs2_t
* src
)
1043 len
= strlen_w(src
);
1045 /* allocate UNISTR2 destination if not given */
1047 dst
= TALLOC_P(ctx
, UNISTR2
);
1052 dst
->buffer
= TALLOC_ARRAY(ctx
, uint16
, len
+ 1);
1057 /* set UNISTR2 parameters */
1058 dst
->uni_max_len
= len
+ 1;
1060 dst
->uni_str_len
= len
;
1062 /* copy the actual unicode string */
1063 strncpy_w(dst
->buffer
, src
, dst
->uni_max_len
);
1068 /*************************************************************
1069 ascii only toupper - saves the need for smbd to be in C locale.
1070 *************************************************************/
1072 int toupper_ascii(int c
)
1074 smb_ucs2_t uc
= toupper_w(UCS2_CHAR(c
));
1075 return UCS2_TO_CHAR(uc
);
1078 /*************************************************************
1079 ascii only tolower - saves the need for smbd to be in C locale.
1080 *************************************************************/
1082 int tolower_ascii(int c
)
1084 smb_ucs2_t uc
= tolower_w(UCS2_CHAR(c
));
1085 return UCS2_TO_CHAR(uc
);
1088 /*************************************************************
1089 ascii only isupper - saves the need for smbd to be in C locale.
1090 *************************************************************/
1092 int isupper_ascii(int c
)
1094 return isupper_w(UCS2_CHAR(c
));
1097 /*************************************************************
1098 ascii only islower - saves the need for smbd to be in C locale.
1099 *************************************************************/
1101 int islower_ascii(int c
)
1103 return islower_w(UCS2_CHAR(c
));