Skip to content

Commit c1fb4a0

Browse files
committed
tests: add utf8filter passthrough program
1 parent 4d613fc commit c1fb4a0

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ Makefile.in
8181
/tests/oxcmail_ie
8282
/tests/ucvttest
8383
/tests/udb
84+
/tests/utf8filter
8485
/tests/utiltest
8586
/tests/vcard
8687
/tests/zendfake

Makefile.am

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ mapi_la_LDFLAGS += -Wl,--allow-shlib-undefined
241241
endif
242242
EXTRA_mapi_la_DEPENDENCIES = default.sym
243243

244-
noinst_PROGRAMS = dldcheck tests/bdump tests/bodyconv tests/compress tests/dnsbl_check tests/exrpctest tests/gxl-383 tests/jsontest tests/lzxpress tests/oxcmail_ie tests/ucvttest tests/udb tests/utiltest tests/vcard tools/tzdump
244+
noinst_PROGRAMS = dldcheck tests/bdump tests/bodyconv tests/compress tests/dnsbl_check tests/exrpctest tests/gxl-383 tests/jsontest tests/lzxpress tests/oxcmail_ie tests/ucvttest tests/udb tests/utf8filter tests/utiltest tests/vcard tools/tzdump
245245
if HAVE_ESEDB
246246
noinst_PROGRAMS += tests/epv_unpack
247247
endif
@@ -272,6 +272,8 @@ tests_oxcmail_ie_SOURCES = tests/oxcmail_ie.cpp
272272
tests_oxcmail_ie_LDADD = ${libHX_LIBS} libgromox_common.la libgromox_mapi.la
273273
tests_ucvttest_SOURCES = tests/ucvttest.cpp
274274
tests_ucvttest_LDADD = libgromox_mapi.la
275+
tests_utf8filter_SOURCES = tests/utf8filter.cpp
276+
tests_utf8filter_LDADD = ${libHX_LIBS} libgromox_common.la
275277
tests_utiltest_SOURCES = tests/utiltest.cpp
276278
tests_utiltest_LDADD = ${libHX_LIBS} libgromox_common.la libgromox_mapi.la
277279
tests_vcard_SOURCES = tests/vcard.cpp

tests/utf8filter.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#include <cstdlib>
2+
#include <cstring>
3+
#include <memory>
4+
#include <libHX/io.h>
5+
#include <gromox/defs.h>
6+
#include <gromox/util.hpp>
7+
using namespace gromox;
8+
int main(int argc, char **argv)
9+
{
10+
size_t size = 0;
11+
std::unique_ptr<char[], stdlib_delete> buf(HX_slurp_fd(STDIN_FILENO, &size));
12+
if (buf == nullptr)
13+
return EXIT_FAILURE;
14+
utf8_filter(buf.get());
15+
auto z = strlen(buf.get());
16+
auto ret = HXio_fullwrite(STDOUT_FILENO, buf.get(), z);
17+
if (ret < 0 || static_cast<size_t>(ret) != z)
18+
return EXIT_FAILURE;
19+
return EXIT_SUCCESS;
20+
}

0 commit comments

Comments
 (0)