2011-09-04 00:36:27 +04:00
|
|
|
/**
|
2012-10-09 07:02:04 +04:00
|
|
|
* FreeRDP: A Remote Desktop Protocol Implementation
|
2011-09-04 00:36:27 +04:00
|
|
|
* String Utils
|
|
|
|
*
|
|
|
|
* Copyright 2011 Marc-Andre Moreau <marcandre.moreau@gmail.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.
|
|
|
|
*/
|
|
|
|
|
2012-08-15 01:09:01 +04:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2012-10-09 07:21:26 +04:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
2012-09-24 02:41:07 +04:00
|
|
|
#include <freerdp/utils/unicode.h>
|
2011-09-04 00:36:27 +04:00
|
|
|
|
|
|
|
#include <freerdp/utils/string.h>
|
|
|
|
|
2012-09-24 02:41:07 +04:00
|
|
|
void freerdp_string_read_length32(STREAM* s, rdpString* string)
|
2011-09-04 00:36:27 +04:00
|
|
|
{
|
2012-10-09 11:26:39 +04:00
|
|
|
stream_read_UINT32(s, string->length);
|
2012-10-09 07:21:26 +04:00
|
|
|
string->unicode = (char*) malloc(string->length);
|
2011-09-04 00:36:27 +04:00
|
|
|
stream_read(s, string->unicode, string->length);
|
2012-09-24 04:11:50 +04:00
|
|
|
freerdp_UnicodeToAsciiAlloc((WCHAR*) string->unicode, &string->ascii, string->length / 2);
|
2011-09-04 00:36:27 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void freerdp_string_free(rdpString* string)
|
|
|
|
{
|
|
|
|
if (string->unicode != NULL)
|
2012-10-09 07:21:26 +04:00
|
|
|
free(string->unicode);
|
2011-09-04 00:36:27 +04:00
|
|
|
|
|
|
|
if (string->ascii != NULL)
|
2012-10-09 07:21:26 +04:00
|
|
|
free(string->ascii);
|
2011-09-04 00:36:27 +04:00
|
|
|
}
|