GUAC-584: Add iconv-style function in common. Stub implementation and test.
This commit is contained in:
parent
bbf451a552
commit
dfc18e14a4
@ -29,6 +29,7 @@ noinst_LTLIBRARIES = libguac_common.la
|
||||
noinst_HEADERS = \
|
||||
guac_io.h \
|
||||
guac_dot_cursor.h \
|
||||
guac_iconv.h \
|
||||
guac_list.h \
|
||||
guac_pointer_cursor.h \
|
||||
guac_string.h
|
||||
@ -36,6 +37,7 @@ noinst_HEADERS = \
|
||||
libguac_common_la_SOURCES = \
|
||||
guac_io.c \
|
||||
guac_dot_cursor.c \
|
||||
guac_iconv.c \
|
||||
guac_list.c \
|
||||
guac_pointer_cursor.c \
|
||||
guac_string.c
|
||||
|
49
src/common/guac_iconv.c
Normal file
49
src/common/guac_iconv.c
Normal file
@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright (C) 2013 Glyptodon LLC
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "guac_iconv.h"
|
||||
|
||||
void guac_iconv(guac_iconv_read* reader, char** input, int in_remaining,
|
||||
guac_iconv_write* writer, char** output, int out_remaining) {
|
||||
/* STUB */
|
||||
}
|
||||
|
||||
int GUAC_READ_UTF8(char** input, int remaining) {
|
||||
/* STUB */
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int GUAC_READ_UTF16(char** input, int remaining) {
|
||||
/* STUB */
|
||||
return 0;
|
||||
}
|
||||
|
||||
void GUAC_WRITE_UTF8(char** output, int remaining, int value) {
|
||||
/* STUB */
|
||||
}
|
||||
|
||||
void GUAC_WRITE_UTF16(char** output, int remaining, int value) {
|
||||
/* STUB */
|
||||
}
|
||||
|
81
src/common/guac_iconv.h
Normal file
81
src/common/guac_iconv.h
Normal file
@ -0,0 +1,81 @@
|
||||
/*
|
||||
* Copyright (C) 2013 Glyptodon LLC
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef __GUAC_COMMON_ICONV_H
|
||||
#define __GUAC_COMMON_ICONV_H
|
||||
|
||||
#include "config.h"
|
||||
|
||||
/**
|
||||
* Function which reads a character from the given string data, returning
|
||||
* the Unicode codepoint read, updating the string pointer to point to the
|
||||
* byte immediately after the character read.
|
||||
*/
|
||||
typedef int guac_iconv_read(char** input, int remaining);
|
||||
|
||||
/**
|
||||
* Function writes the character having the given Unicode codepoint value to
|
||||
* the given string data, updating the string pointer to point to the byte
|
||||
* immediately after the character written.
|
||||
*/
|
||||
typedef void guac_iconv_write(char** output, int remaining, int value);
|
||||
|
||||
/**
|
||||
* Converts characters within a given string from one encoding to another,
|
||||
* as defined by the reader/writer functions specified. The input and output
|
||||
* string pointers will be updated based on the number of bytes read or
|
||||
* written.
|
||||
*
|
||||
* @param reader The reader function to use when reading the input string.
|
||||
* @param input Pointer to the beginning of the input string.
|
||||
* @param in_remaining The number of bytes remaining after the pointer to the
|
||||
* input string.
|
||||
* @param writer The writer function to use when writing the output string.
|
||||
* @param output Pointer to the beginning of the output string.
|
||||
* @param out_remaining The number of bytes remaining after the pointer to the
|
||||
* output string.
|
||||
*/
|
||||
void guac_iconv(guac_iconv_read* reader, char** input, int in_remaining,
|
||||
guac_iconv_write* writer, char** output, int out_remaining);
|
||||
|
||||
/**
|
||||
* Read function for UTF8.
|
||||
*/
|
||||
guac_iconv_read GUAC_READ_UTF8;
|
||||
|
||||
/**
|
||||
* Read function for UTF16.
|
||||
*/
|
||||
guac_iconv_read GUAC_READ_UTF16;
|
||||
|
||||
/**
|
||||
* Write function for UTF8.
|
||||
*/
|
||||
guac_iconv_write GUAC_WRITE_UTF8;
|
||||
|
||||
/**
|
||||
* Write function for UTF16.
|
||||
*/
|
||||
guac_iconv_write GUAC_WRITE_UTF16;
|
||||
|
||||
#endif
|
||||
|
@ -39,6 +39,7 @@ test_libguac_SOURCES = \
|
||||
client/buffer_pool.c \
|
||||
client/layer_pool.c \
|
||||
common/common_suite.c \
|
||||
common/guac_iconv.c \
|
||||
common/guac_string.c \
|
||||
protocol/suite.c \
|
||||
protocol/base64_decode.c \
|
||||
|
@ -45,7 +45,10 @@ int register_common_suite() {
|
||||
}
|
||||
|
||||
/* Add tests */
|
||||
if (CU_add_test(suite, "guac-string", test_guac_string) == NULL) {
|
||||
if (
|
||||
CU_add_test(suite, "guac-iconv", test_guac_iconv) == NULL
|
||||
|| CU_add_test(suite, "guac-string", test_guac_string) == NULL
|
||||
) {
|
||||
CU_cleanup_registry();
|
||||
return CU_get_error();
|
||||
}
|
||||
|
@ -44,5 +44,10 @@ int register_common_suite();
|
||||
*/
|
||||
void test_guac_string();
|
||||
|
||||
/**
|
||||
* Unit test for character conversion functions.
|
||||
*/
|
||||
void test_guac_iconv();
|
||||
|
||||
#endif
|
||||
|
||||
|
34
tests/common/guac_iconv.c
Normal file
34
tests/common/guac_iconv.c
Normal file
@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright (C) 2013 Glyptodon LLC
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "common_suite.h"
|
||||
#include "guac_iconv.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <CUnit/Basic.h>
|
||||
|
||||
void test_guac_iconv() {
|
||||
/* STUB */
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user