commit f8ddb22040652532551d675178950b809bce615c
parent 141d8e7b8f822258be4500e02f791d25f8fda7c5
Author: Claudio Alessi <smoppy@gmail.com>
Date: Sat, 13 May 2017 20:09:23 +0200
Utility to build STFL code fragments from files.
Diffstat:
1 file changed, 23 insertions(+), 0 deletions(-)
diff --git a/stflfrag.c b/stflfrag.c
@@ -0,0 +1,23 @@
+#include <langinfo.h>
+#include <stdio.h>
+#include <stfl.h>
+#include <string.h>
+
+int
+main(int argc, char **argv) {
+ struct stfl_form *form;
+ struct stfl_ipool *ipool;
+ const wchar_t *frag;
+ wchar_t file[256];
+
+ if(argc != 2)
+ return 1;
+ ipool = stfl_ipool_create(nl_langinfo(CODESET));
+ swprintf(file, sizeof file - 1, L"<%ls>", stfl_ipool_towc(ipool, argv[1]));
+ if(!(form = stfl_create(file)))
+ return 1;
+ frag = stfl_dump(form, NULL, NULL, 0);
+ wprintf(L"%ls", frag);
+ stfl_ipool_destroy(ipool);
+ return 0;
+}