]> mj.ucw.cz Git - libucw.git/blobdiff - charset/stk-charconv.h
tableprinter: removed column type macros
[libucw.git] / charset / stk-charconv.h
index a8c6afd89d7c37ad60909e166adc6d52c2acea70..e6852c7762cd75c9437af6a05d9df4ef91bcee95 100644 (file)
@@ -1,32 +1,35 @@
 /*
- *     Sherlock Library -- Character Conversion with Allocation on the Stack 
+ *     Sherlock Library -- Character Conversion with Allocation on the Stack
  *
  *     (c) 2006 Pavel Charvat <pchar@ucw.cz>
+ *
+ *     This software may be freely distributed and used according to the terms
+ *     of the GNU Lesser General Public License.
  */
 
 #ifndef _CHARSET_STK_CHARCONV_H
 #define _CHARSET_STK_CHARCONV_H
 
-#include "charset/charconv.h"
+#include <charset/charconv.h>
 #include <alloca.h>
 
+#ifdef CONFIG_UCW_CLEAN_ABI
+#define stk_strconv_init ucw_stk_strconv_init
+#define stk_strconv_step ucw_stk_strconv_step
+#endif
+
 /* The following macros convert strings between given charsets (CONV_CHARSET_x). */
 
-#define stk_conv(s, cs_in, cs_out) \
-    ({ struct stk_conv_context _c; stk_conv_init(&_c, (s), (cs_in), (cs_out)); \
-       while (stk_conv_step(&_c, alloca(_c.len))); _c.c.dest_start; })
+#define stk_strconv(s, cs_in, cs_out) \
+    ({ struct conv_context _c; uint _l=stk_strconv_init(&_c, (s), (cs_in), (cs_out)); \
+       while (_l) _l=stk_strconv_step(&_c, alloca(_l), _l); _c.dest_start; })
 
-#define stk_conv_to_utf8(s, cs_in) stk_conv(s, cs_in, CONV_CHARSET_UTF8)
-#define stk_conv_from_utf8(s, cs_out) stk_conv(s, CONV_CHARSET_UTF8, cs_out)
-   
-/* Internal structure and routines. */
+#define stk_strconv_to_utf8(s, cs_in) stk_strconv(s, cs_in, CONV_CHARSET_UTF8)
+#define stk_strconv_from_utf8(s, cs_out) stk_strconv(s, CONV_CHARSET_UTF8, cs_out)
 
-struct stk_conv_context {
-  struct conv_context c;
-  uns len;
-};
+/* Internals */
 
-void stk_conv_init(struct stk_conv_context *c, byte *s, uns cs_in, uns cs_out);
-int stk_conv_step(struct stk_conv_context *c, byte *buf);
+uint stk_strconv_init(struct conv_context *c, const byte *s, uint cs_in, uint cs_out);
+uint stk_strconv_step(struct conv_context *c, byte *buf, uint len);
 
 #endif