FreeRDP
winpr/libwinpr/crt/string.c File Reference
#include <winpr/config.h>
#include <winpr/assert.h>
#include <errno.h>
#include <stdio.h>
#include <ctype.h>
#include <wctype.h>
#include <wchar.h>
#include <winpr/crt.h>
#include <winpr/endian.h>
#include "../log.h"
#include "casing.h"

Macros

#define TAG   WINPR_TAG("crt")
 
#define MIN(x, y)   (((x) < (y)) ? (x) : (y))
 

Functions

static char hex2bin (char what)
 
static char unescape (const char *what, size_t *px)
 
char * winpr_str_url_decode (const char *str, size_t len)
 
static char * escape (char *dst, char what)
 
char * winpr_str_url_encode (const char *str, size_t len)
 
BOOL winpr_str_append (const char *what, char *buffer, size_t size, const char *separator)
 
int winpr_asprintf (char **s, size_t *slen, WINPR_FORMAT_ARG const char *templ,...)
 
int winpr_vasprintf (char **s, size_t *slen, WINPR_FORMAT_ARG const char *templ, va_list oap)
 
char * _strdup (const char *strSource)
 
WCHAR * _wcsdup (const WCHAR *strSource)
 
WCHAR * _wcsncat (WCHAR *dst, const WCHAR *src, size_t sz)
 
int _stricmp (const char *string1, const char *string2)
 
int _strnicmp (const char *string1, const char *string2, size_t count)
 
int _wcscmp (const WCHAR *string1, const WCHAR *string2)
 
int _wcsncmp (const WCHAR *string1, const WCHAR *string2, size_t count)
 
size_t _wcslen (const WCHAR *str)
 
size_t _wcsnlen (const WCHAR *str, size_t max)
 
WCHAR * _wcsstr (const WCHAR *str, const WCHAR *strSearch)
 
WCHAR * _wcschr (const WCHAR *str, WCHAR value)
 
WCHAR * _wcsrchr (const WCHAR *str, WCHAR c)
 
char * strtok_s (char *strToken, const char *strDelimit, char **context)
 
WCHAR * wcstok_s (WCHAR *strToken, const WCHAR *strDelimit, WCHAR **context)
 
LPSTR CharUpperA (LPSTR lpsz)
 
LPWSTR CharUpperW (LPWSTR lpsz)
 
DWORD CharUpperBuffA (LPSTR lpsz, DWORD cchLength)
 
DWORD CharUpperBuffW (LPWSTR lpsz, DWORD cchLength)
 
LPSTR CharLowerA (LPSTR lpsz)
 
LPWSTR CharLowerW (LPWSTR lpsz)
 
DWORD CharLowerBuffA (LPSTR lpsz, DWORD cchLength)
 
DWORD CharLowerBuffW (LPWSTR lpsz, DWORD cchLength)
 
BOOL IsCharAlphaA (CHAR ch)
 
BOOL IsCharAlphaW (WCHAR ch)
 
BOOL IsCharAlphaNumericA (CHAR ch)
 
BOOL IsCharAlphaNumericW (WCHAR ch)
 
BOOL IsCharUpperA (CHAR ch)
 
BOOL IsCharUpperW (WCHAR ch)
 
BOOL IsCharLowerA (CHAR ch)
 
BOOL IsCharLowerW (WCHAR ch)
 
size_t ConvertLineEndingToLF (char *str, size_t size)
 
char * ConvertLineEndingToCRLF (const char *str, size_t *size)
 
char * StrSep (char **stringp, const char *delim)
 
INT64 GetLine (char **lineptr, size_t *size, FILE *stream)
 
char * strndup (const char *src, size_t n)
 
const WCHAR * InitializeConstWCharFromUtf8 (const char *str, WCHAR *buffer, size_t len)
 Helper function to initialize const WCHAR pointer from a Utf8 string. More...
 

Variables

static const char rfc3986 []
 

Macro Definition Documentation

◆ MIN

#define MIN (   x,
  y 
)    (((x) < (y)) ? (x) : (y))

◆ TAG

#define TAG   WINPR_TAG("crt")

WinPR: Windows Portable Runtime String Manipulation (CRT)

Copyright 2012 Marc-Andre Moreau marca.nosp@m.ndre.nosp@m..more.nosp@m.au@g.nosp@m.mail..nosp@m.com

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Function Documentation

◆ _strdup()

char* _strdup ( const char *  strSource)

◆ _stricmp()

int _stricmp ( const char *  string1,
const char *  string2 
)
Here is the caller graph for this function:

◆ _strnicmp()

int _strnicmp ( const char *  string1,
const char *  string2,
size_t  count 
)
Here is the caller graph for this function:

◆ _wcschr()

WCHAR* _wcschr ( const WCHAR *  str,
WCHAR  value 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ _wcscmp()

int _wcscmp ( const WCHAR *  string1,
const WCHAR *  string2 
)
Here is the caller graph for this function:

◆ _wcsdup()

WCHAR* _wcsdup ( const WCHAR *  strSource)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ _wcslen()

size_t _wcslen ( const WCHAR *  str)
Here is the caller graph for this function:

◆ _wcsncat()

WCHAR* _wcsncat ( WCHAR *  dst,
const WCHAR *  src,
size_t  sz 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ _wcsncmp()

int _wcsncmp ( const WCHAR *  string1,
const WCHAR *  string2,
size_t  count 
)
Here is the caller graph for this function:

◆ _wcsnlen()

size_t _wcsnlen ( const WCHAR *  str,
size_t  max 
)
Here is the caller graph for this function:

◆ _wcsrchr()

WCHAR* _wcsrchr ( const WCHAR *  str,
WCHAR  c 
)
Here is the caller graph for this function:

◆ _wcsstr()

WCHAR* _wcsstr ( const WCHAR *  str,
const WCHAR *  strSearch 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ CharLowerA()

LPSTR CharLowerA ( LPSTR  lpsz)

◆ CharLowerBuffA()

DWORD CharLowerBuffA ( LPSTR  lpsz,
DWORD  cchLength 
)

◆ CharLowerBuffW()

DWORD CharLowerBuffW ( LPWSTR  lpsz,
DWORD  cchLength 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ CharLowerW()

LPWSTR CharLowerW ( LPWSTR  lpsz)
Here is the call graph for this function:

◆ CharUpperA()

LPSTR CharUpperA ( LPSTR  lpsz)
Here is the caller graph for this function:

◆ CharUpperBuffA()

DWORD CharUpperBuffA ( LPSTR  lpsz,
DWORD  cchLength 
)
Here is the caller graph for this function:

◆ CharUpperBuffW()

DWORD CharUpperBuffW ( LPWSTR  lpsz,
DWORD  cchLength 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ CharUpperW()

LPWSTR CharUpperW ( LPWSTR  lpsz)
Here is the call graph for this function:

◆ ConvertLineEndingToCRLF()

char* ConvertLineEndingToCRLF ( const char *  str,
size_t *  size 
)
Here is the caller graph for this function:

◆ ConvertLineEndingToLF()

size_t ConvertLineEndingToLF ( char *  str,
size_t  size 
)
Here is the caller graph for this function:

◆ escape()

static char* escape ( char *  dst,
char  what 
)
static
Here is the caller graph for this function:

◆ GetLine()

INT64 GetLine ( char **  lineptr,
size_t *  size,
FILE *  stream 
)
Here is the caller graph for this function:

◆ hex2bin()

static char hex2bin ( char  what)
static
Here is the caller graph for this function:

◆ InitializeConstWCharFromUtf8()

const WCHAR* InitializeConstWCharFromUtf8 ( const char *  str,
WCHAR *  buffer,
size_t  len 
)

Helper function to initialize const WCHAR pointer from a Utf8 string.

Parameters
strThe Utf8 string to use for initialization
bufferThe WCHAR buffer used to store the converted data
lenThe size of the buffer in number of WCHAR
Returns
The WCHAR string (a pointer to buffer)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ IsCharAlphaA()

BOOL IsCharAlphaA ( CHAR  ch)

◆ IsCharAlphaNumericA()

BOOL IsCharAlphaNumericA ( CHAR  ch)

◆ IsCharAlphaNumericW()

BOOL IsCharAlphaNumericW ( WCHAR  ch)

◆ IsCharAlphaW()

BOOL IsCharAlphaW ( WCHAR  ch)
Here is the caller graph for this function:

◆ IsCharLowerA()

BOOL IsCharLowerA ( CHAR  ch)

◆ IsCharLowerW()

BOOL IsCharLowerW ( WCHAR  ch)

◆ IsCharUpperA()

BOOL IsCharUpperA ( CHAR  ch)

◆ IsCharUpperW()

BOOL IsCharUpperW ( WCHAR  ch)

◆ strndup()

char* strndup ( const char *  src,
size_t  n 
)
Here is the caller graph for this function:

◆ StrSep()

char* StrSep ( char **  stringp,
const char *  delim 
)
Here is the caller graph for this function:

◆ strtok_s()

char* strtok_s ( char *  strToken,
const char *  strDelimit,
char **  context 
)
Here is the caller graph for this function:

◆ unescape()

static char unescape ( const char *  what,
size_t *  px 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ wcstok_s()

WCHAR* wcstok_s ( WCHAR *  strToken,
const WCHAR *  strDelimit,
WCHAR **  context 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ winpr_asprintf()

int winpr_asprintf ( char **  s,
size_t *  slen,
WINPR_FORMAT_ARG const char *  templ,
  ... 
)
Here is the call graph for this function:

◆ winpr_str_append()

BOOL winpr_str_append ( const char *  what,
char *  buffer,
size_t  size,
const char *  separator 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ winpr_str_url_decode()

char* winpr_str_url_decode ( const char *  str,
size_t  len 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ winpr_str_url_encode()

char* winpr_str_url_encode ( const char *  str,
size_t  len 
)

WinPR: Windows Portable Runtime String Manipulation (CRT)

Copyright 2012 Marc-Andre Moreau marca.nosp@m.ndre.nosp@m..more.nosp@m.au@g.nosp@m.mail..nosp@m.com Copyright 2016 David PHAM-VAN d.pha.nosp@m.mvan.nosp@m.@inuv.nosp@m.ika..nosp@m.com

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ winpr_vasprintf()

int winpr_vasprintf ( char **  s,
size_t *  slen,
WINPR_FORMAT_ARG const char *  templ,
va_list  oap 
)
Here is the caller graph for this function:

Variable Documentation

◆ rfc3986

const char rfc3986[]
static
Initial value:
= {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2d, 0x2e, 0x00,
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f,
0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x00, 0x00, 0x00, 0x00, 0x5f,
0x00, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f,
0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x00, 0x00, 0x00, 0x7e, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
}