Beispiel #1
0
BOOL freerdp_client_parse_rdp_file_buffer_unicode(rdpFile* file, BYTE* buffer, size_t size)
{
    int length;
    WCHAR* line;
    WCHAR* type;
    WCHAR* context;
    WCHAR *d1, *d2;
    WCHAR *beg, *end;
    WCHAR *name, *value;

    line = wcstok_s((WCHAR*) buffer, CR_LF_STR_W, &context);

    while (line != NULL)
    {
        length = _wcslen(line);

        if (length > 1)
        {
            beg = line;
            end = &line[length - 1];

            if (beg[0] == '/')
            {
                /* FreeRDP option */
                freerdp_client_parse_rdp_file_option_unicode(file, line);
                goto next_line;
            }

            d1 = _wcschr(line, ':');

            if (!d1)
                goto next_line; /* not first delimiter */

            type = &d1[1];
            d2 = _wcschr(type, ':');

            if (!d2)
                goto next_line; /* no second delimiter */

            if ((d2 - d1) != 2)
                goto next_line; /* improper type length */

            if (d2 == end)
                goto next_line; /* no value */

            *d1 = 0;
            *d2 = 0;
            name = beg;
            value = &d2[1];

            if (*type == 'i')
            {
                /* integer type */
                freerdp_client_parse_rdp_file_integer_unicode(file, name, value);
            }
            else if (*type == 's')
            {
                /* string type */
                freerdp_client_parse_rdp_file_string_unicode(file, name, value);
            }
            else if (*type == 'b')
            {
                /* binary type */
            }
        }

next_line:
        line = wcstok_s(NULL, CR_LF_STR_W, &context);
    }

    return TRUE;
}
Beispiel #2
0
static BOOL freerdp_client_parse_rdp_file_buffer_unicode(rdpFile* file, const BYTE* buffer,
        size_t size)
{
	BOOL rc = FALSE;
	int index;
	int length;
	const WCHAR* line;
	WCHAR* type;
	WCHAR* context;
	WCHAR* d1, *d2;
	const WCHAR* name, *value;
	WCHAR* copy = (WCHAR*)calloc(1, size + sizeof(WCHAR));

	if (!copy)
		return FALSE;

	memcpy(copy, buffer, size);
	index = 0;
	line = wcstok_s(copy, CR_LF_STR_W, &context);

	while (line != NULL)
	{
		length = (int) _wcslen(line);

		if (length > 1)
		{
			const WCHAR* beg = line;

			if (!freerdp_client_parse_rdp_file_add_line_unicode(file, line, index))
				goto fail;

			if (beg[0] == '/')
			{
				/* FreeRDP option */
				freerdp_client_parse_rdp_file_option_unicode(file, line, index);
				goto next_line;
			}

			d1 = _wcschr(line, ':');

			if (!d1)
				goto next_line; /* not first delimiter */

			type = &d1[1];
			d2 = _wcschr(type, ':');

			if (!d2)
				goto next_line; /* no second delimiter */

			if ((d2 - d1) != 2)
				goto next_line; /* improper type length */

			*d1 = 0;
			*d2 = 0;
			name = beg;
			value = &d2[1];

			if (*type == 'i')
			{
				/* integer type */
				if (!freerdp_client_parse_rdp_file_integer_unicode(file, name, value, index))
					goto fail;
			}
			else if (*type == 's')
			{
				/* string type */
				if (!freerdp_client_parse_rdp_file_string_unicode(file, name, value, index))
					goto fail;
			}
			else if (*type == 'b')
			{
				/* binary type */
			}
		}

	next_line:
		line = wcstok_s(NULL, CR_LF_STR_W, &context);
		index++;
	}

	rc = TRUE;
fail:
	free(copy);
	return rc;
}