qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r..@apache.org
Subject svn commit: r1333032 - in /qpid/proton/trunk/proton-c: bindings/php/ bindings/python/ include/proton/ src/ src/engine/ src/sasl/ src/types/
Date Wed, 02 May 2012 13:19:02 GMT
Author: rhs
Date: Wed May  2 13:19:01 2012
New Revision: 1333032

URL: http://svn.apache.org/viewvc?rev=1333032&view=rev
Log:
removed wchar in favor of utf8

Modified:
    qpid/proton/trunk/proton-c/bindings/php/php.i
    qpid/proton/trunk/proton-c/bindings/python/python.i
    qpid/proton/trunk/proton-c/include/proton/engine.h
    qpid/proton/trunk/proton-c/include/proton/value.h
    qpid/proton/trunk/proton-c/src/engine/engine-internal.h
    qpid/proton/trunk/proton-c/src/engine/engine.c
    qpid/proton/trunk/proton-c/src/proton.c
    qpid/proton/trunk/proton-c/src/sasl/sasl.c
    qpid/proton/trunk/proton-c/src/types/decode.c
    qpid/proton/trunk/proton-c/src/types/string.c
    qpid/proton/trunk/proton-c/src/types/value-internal.h
    qpid/proton/trunk/proton-c/src/types/value.c
    qpid/proton/trunk/proton-c/src/util.c
    qpid/proton/trunk/proton-c/src/util.h

Modified: qpid/proton/trunk/proton-c/bindings/php/php.i
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/bindings/php/php.i?rev=1333032&r1=1333031&r2=1333032&view=diff
==============================================================================
--- qpid/proton/trunk/proton-c/bindings/php/php.i (original)
+++ qpid/proton/trunk/proton-c/bindings/php/php.i Wed May  2 13:19:01 2012
@@ -7,7 +7,6 @@
 %header %{
 /* Include the headers needed by the code in this wrapper file */
 #include <proton/driver.h>
-#include <wchar.h>
 
 #define zend_error_noreturn zend_error
 %}
@@ -20,68 +19,6 @@
     ZVAL_LONG($result, (long)$1);
 }
 
-
-// wchar_t *WCHAR_INPUT
-//
-// support for wchar_t * input arguments: convert PHP string to wchar_t string.
-//
-%typemap(in) wchar_t * {
-    if (Z_TYPE_PP($input) != IS_STRING) {
-        convert_to_string_ex($input);
-    }
-    const char *src = Z_STRVAL_PP($input);
-    const size_t inLen = Z_STRLEN_PP($input);
-
-    if (src) {
-      // determine size needed for converted buffer
-      mbstate_t state = {};
-      const char *tmp = src;
-      size_t wlen = mbsnrtowcs( NULL, &tmp, inLen, 0, &state );
-      if (wlen == (size_t)-1) {
-        SWIG_PHP_Error(E_ERROR, "Cannot convert string argument $argnum of $symname to wchar_t
string.");
-      }
-      // include additional nul terminator in case source does not include one
-      $1 = malloc(sizeof(wchar_t) * (wlen + 2));
-
-      tmp = src;
-      wlen = mbsnrtowcs( $1, &tmp, inLen, wlen+1, &state);
-      if (wlen == (size_t)-1) {
-        SWIG_PHP_Error(E_ERROR, "Cannot convert string argument $argnum of $symname to wchar_t
string.");
-      }
-      $1[wlen] = (wchar_t)0;
-    } else {
-      $1 == NULL;
-    }
- }
-%typemap(freearg) wchar_t * {
-    free($1);   // free the buffer holding the wchar_t buffer
- }
-
-// convert wchar_t * return value to a PHP string
-%typemap(out) wchar_t * {
-    // determine size needed for converted buffer
-    const wchar_t *tmp = $1;
-    if (tmp) {
-      mbstate_t state = {};
-      size_t slen = wcsrtombs( NULL, &tmp, 0, &state);
-      if (slen == (size_t)-1) {
-        SWIG_PHP_Error(E_ERROR, "Cannot convert wchar_t return value from $symname to string.");
-      }
-
-      char *str = emalloc(sizeof(char) * slen+1);
-      tmp = $1;
-      slen = wcsrtombs( str, &tmp, slen+1, &state);
-      if (slen == (size_t)-1) {
-        SWIG_PHP_Error(E_ERROR, "Cannot convert wchar_t return value from $symname to string.");
-      }
-
-      ZVAL_STRINGL($result, str, slen, 0);  // 0 == assume ownership of buffer
-    } else {
-      ZVAL_NULL($result);
-    }
- }
-
-
 // (char **OUTPUT_BUFFER, ssize_t *OUTPUT_LEN)
 //
 // typemap for binary buffer output arguments.  Given an uninitialized pointer for a

Modified: qpid/proton/trunk/proton-c/bindings/python/python.i
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/bindings/python/python.i?rev=1333032&r1=1333031&r2=1333032&view=diff
==============================================================================
--- qpid/proton/trunk/proton-c/bindings/python/python.i (original)
+++ qpid/proton/trunk/proton-c/bindings/python/python.i Wed May  2 13:19:01 2012
@@ -10,7 +10,6 @@
 typedef unsigned int size_t;
 typedef signed int ssize_t;
 
-%include <cwstring.i>
 %include <cstring.i>
 
 %cstring_output_withsize(char *OUTPUT, size_t *OUTPUT_SIZE)

Modified: qpid/proton/trunk/proton-c/include/proton/engine.h
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/include/proton/engine.h?rev=1333032&r1=1333031&r2=1333032&view=diff
==============================================================================
--- qpid/proton/trunk/proton-c/include/proton/engine.h (original)
+++ qpid/proton/trunk/proton-c/include/proton/engine.h Wed May  2 13:19:01 2012
@@ -72,8 +72,8 @@ pn_connection_t *pn_connection();
 
 pn_state_t pn_connection_state(pn_connection_t *connection);
 pn_error_t *pn_connection_error(pn_connection_t *connection);
-void pn_connection_set_container(pn_connection_t *connection, const wchar_t *container);
-void pn_connection_set_hostname(pn_connection_t *connection, const wchar_t *hostname);
+void pn_connection_set_container(pn_connection_t *connection, const char *container);
+void pn_connection_set_hostname(pn_connection_t *connection, const char *hostname);
 
 pn_delivery_t *pn_work_head(pn_connection_t *connection);
 pn_delivery_t *pn_work_next(pn_delivery_t *delivery);
@@ -102,8 +102,8 @@ void pn_transport_destroy(pn_transport_t
 // session
 pn_state_t pn_session_state(pn_session_t *session);
 pn_error_t *pn_session_error(pn_session_t *session);
-pn_link_t *pn_sender(pn_session_t *session, const wchar_t *name);
-pn_link_t *pn_receiver(pn_session_t *session, const wchar_t *name);
+pn_link_t *pn_sender(pn_session_t *session, const char *name);
+pn_link_t *pn_receiver(pn_session_t *session, const char *name);
 void pn_session_open(pn_session_t *session);
 void pn_session_close(pn_session_t *session);
 void pn_session_destroy(pn_session_t *session);
@@ -114,10 +114,10 @@ bool pn_is_receiver(pn_link_t *link);
 pn_state_t pn_link_state(pn_link_t *link);
 pn_error_t *pn_link_error(pn_link_t *link);
 pn_session_t *pn_get_session(pn_link_t *link);
-void pn_set_source(pn_link_t *link, const wchar_t *source);
-void pn_set_target(pn_link_t *link, const wchar_t *target);
-wchar_t *pn_remote_source(pn_link_t *link);
-wchar_t *pn_remote_target(pn_link_t *link);
+void pn_set_source(pn_link_t *link, const char *source);
+void pn_set_target(pn_link_t *link, const char *target);
+char *pn_remote_source(pn_link_t *link);
+char *pn_remote_target(pn_link_t *link);
 pn_delivery_t *pn_delivery(pn_link_t *link, pn_delivery_tag_t tag);
 pn_delivery_t *pn_current(pn_link_t *link);
 bool pn_advance(pn_link_t *link);

Modified: qpid/proton/trunk/proton-c/include/proton/value.h
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/include/proton/value.h?rev=1333032&r1=1333031&r2=1333032&view=diff
==============================================================================
--- qpid/proton/trunk/proton-c/include/proton/value.h (original)
+++ qpid/proton/trunk/proton-c/include/proton/value.h Wed May  2 13:19:01 2012
@@ -184,9 +184,9 @@ pn_symbol_t *pn_symbol_dup(pn_symbol_t *
 
 /* string */
 
-pn_string_t *pn_string(wchar_t *wcs);
-size_t pn_string_size(pn_string_t *str);
-wchar_t *pn_string_wcs(pn_string_t *str);
+pn_string_t *pn_string(const char *utf8);
+pn_string_t *pn_stringn(const char *utf8, size_t size);
+const char *pn_string_utf8(pn_string_t *str);
 
 /* binary */
 

Modified: qpid/proton/trunk/proton-c/src/engine/engine-internal.h
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/src/engine/engine-internal.h?rev=1333032&r1=1333031&r2=1333032&view=diff
==============================================================================
--- qpid/proton/trunk/proton-c/src/engine/engine-internal.h (original)
+++ qpid/proton/trunk/proton-c/src/engine/engine-internal.h Wed May  2 13:19:01 2012
@@ -125,8 +125,8 @@ struct pn_connection_t {
   pn_delivery_t *work_tail;
   pn_delivery_t *tpwork_head;
   pn_delivery_t *tpwork_tail;
-  wchar_t *container;
-  wchar_t *hostname;
+  char *container;
+  char *hostname;
 };
 
 struct pn_session_t {
@@ -140,12 +140,12 @@ struct pn_session_t {
 
 struct pn_link_t {
   pn_endpoint_t endpoint;
-  wchar_t *name;
+  char *name;
   pn_session_t *session;
-  wchar_t *local_source;
-  wchar_t *local_target;
-  wchar_t *remote_source;
-  wchar_t *remote_target;
+  char *local_source;
+  char *local_target;
+  char *remote_source;
+  char *remote_target;
   pn_delivery_t *head;
   pn_delivery_t *tail;
   pn_delivery_t *current;

Modified: qpid/proton/trunk/proton-c/src/engine/engine.c
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/src/engine/engine.c?rev=1333032&r1=1333031&r2=1333032&view=diff
==============================================================================
--- qpid/proton/trunk/proton-c/src/engine/engine.c (original)
+++ qpid/proton/trunk/proton-c/src/engine/engine.c Wed May  2 13:19:01 2012
@@ -25,25 +25,11 @@
 #include <proton/framing.h>
 #include <proton/value.h>
 #include "protocol.h"
-#include <wchar.h>
 #include <inttypes.h>
 
 #include <stdarg.h>
 #include <stdio.h>
 
-#define wcsdup my_wcsdup
-
-wchar_t *my_wcsdup(const wchar_t *src)
-{
-  if (src) {
-    wchar_t *dest = malloc((wcslen(src)+1)*sizeof(wchar_t));
-    if (!dest) return NULL;
-    return wcscpy(dest, src);
-  } else {
-    return 0;
-  }
-}
-
 // delivery buffers
 
 void pn_delivery_buffer_init(pn_delivery_buffer_t *db, pn_sequence_t next, size_t capacity)
@@ -431,16 +417,16 @@ pn_error_t *pn_connection_error(pn_conne
   return &connection->endpoint.error;
 }
 
-void pn_connection_set_container(pn_connection_t *connection, const wchar_t *container)
+void pn_connection_set_container(pn_connection_t *connection, const char *container)
 {
   if (connection->container) free(connection->container);
-  connection->container = wcsdup(container);
+  connection->container = strdup(container);
 }
 
-void pn_connection_set_hostname(pn_connection_t *connection, const wchar_t *hostname)
+void pn_connection_set_hostname(pn_connection_t *connection, const char *hostname)
 {
   if (connection->hostname) free(connection->hostname);
-  connection->hostname = wcsdup(hostname);
+  connection->hostname = strdup(hostname);
 }
 
 pn_delivery_t *pn_work_head(pn_connection_t *connection)
@@ -724,11 +710,11 @@ pn_error_t *pn_transport_error(pn_transp
   return &transport->endpoint.error;
 }
 
-void pn_link_init(pn_link_t *link, int type, pn_session_t *session, const wchar_t *name)
+void pn_link_init(pn_link_t *link, int type, pn_session_t *session, const char *name)
 {
   pn_endpoint_init(&link->endpoint, type, session->connection);
   pn_add_link(session, link);
-  link->name = wcsdup(name);
+  link->name = strdup(name);
   link->local_source = NULL;
   link->local_target = NULL;
   link->remote_source = NULL;
@@ -739,26 +725,26 @@ void pn_link_init(pn_link_t *link, int t
   link->credit = 0;
 }
 
-void pn_set_source(pn_link_t *link, const wchar_t *source)
+void pn_set_source(pn_link_t *link, const char *source)
 {
   if (!link) return;
   if (link->local_source) free(link->local_source);
-  link->local_source = wcsdup(source);
+  link->local_source = strdup(source);
 }
 
-void pn_set_target(pn_link_t *link, const wchar_t *target)
+void pn_set_target(pn_link_t *link, const char *target)
 {
   if (!link) return;
   if (link->local_target) free(link->local_target);
-  link->local_target = wcsdup(target);
+  link->local_target = strdup(target);
 }
 
-wchar_t *pn_remote_source(pn_link_t *link)
+char *pn_remote_source(pn_link_t *link)
 {
   return link ? link->remote_source : NULL;
 }
 
-wchar_t *pn_remote_target(pn_link_t *link)
+char *pn_remote_target(pn_link_t *link)
 {
   return link ? link->remote_target : NULL;
 }
@@ -790,7 +776,7 @@ pn_link_state_t *pn_handle_state(pn_sess
   return ssn_state->handles[handle];
 }
 
-pn_link_t *pn_sender(pn_session_t *session, const wchar_t *name)
+pn_link_t *pn_sender(pn_session_t *session, const char *name)
 {
   if (!session) return NULL;
   pn_link_t *snd = malloc(sizeof(pn_link_t));
@@ -799,7 +785,7 @@ pn_link_t *pn_sender(pn_session_t *sessi
   return snd;
 }
 
-pn_link_t *pn_receiver(pn_session_t *session, const wchar_t *name)
+pn_link_t *pn_receiver(pn_session_t *session, const char *name)
 {
   if (!session) return NULL;
   pn_link_t *rcv = malloc(sizeof(pn_link_t));
@@ -1056,7 +1042,7 @@ pn_link_state_t *pn_find_link(pn_session
   {
     pn_link_t *link = ssn_state->session->links[i];
     if (link->endpoint.type == type &&
-        !wcsncmp(pn_string_wcs(name), link->name, pn_string_size(name)))
+        !strcmp(pn_string_utf8(name), link->name))
     {
       return pn_link_get_state(ssn_state, link);
     }
@@ -1076,9 +1062,9 @@ void pn_do_attach(pn_dispatcher_t *disp)
   if (!link_state) {
     pn_link_t *link;
     if (is_sender) {
-      link = (pn_link_t *) pn_sender(ssn_state->session, pn_string_wcs(name));
+      link = (pn_link_t *) pn_sender(ssn_state->session, pn_string_utf8(name));
     } else {
-      link = (pn_link_t *) pn_receiver(ssn_state->session, pn_string_wcs(name));
+      link = (pn_link_t *) pn_receiver(ssn_state->session, pn_string_utf8(name));
     }
     link_state = pn_link_get_state(ssn_state, link);
   }
@@ -1093,9 +1079,9 @@ void pn_do_attach(pn_dispatcher_t *disp)
     remote_target = pn_tag_value(pn_to_tag(remote_target));
   // XXX: dup src/tgt
   if (remote_source.type == LIST)
-    link_state->link->remote_source = wcsdup(pn_string_wcs(pn_to_string(pn_list_get(pn_to_list(remote_source),
SOURCE_ADDRESS))));
+    link_state->link->remote_source = strdup(pn_string_utf8(pn_to_string(pn_list_get(pn_to_list(remote_source),
SOURCE_ADDRESS))));
   if (remote_target.type == LIST)
-    link_state->link->remote_target = wcsdup(pn_string_wcs(pn_to_string(pn_list_get(pn_to_list(remote_target),
TARGET_ADDRESS))));
+    link_state->link->remote_target = strdup(pn_string_utf8(pn_to_string(pn_list_get(pn_to_list(remote_target),
TARGET_ADDRESS))));
 
   if (!is_sender) {
     link_state->delivery_count = pn_to_int32(pn_list_get(args, ATTACH_INITIAL_DELIVERY_COUNT));

Modified: qpid/proton/trunk/proton-c/src/proton.c
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/src/proton.c?rev=1333032&r1=1333031&r2=1333032&view=diff
==============================================================================
--- qpid/proton/trunk/proton-c/src/proton.c (original)
+++ qpid/proton/trunk/proton-c/src/proton.c Wed May  2 13:19:01 2012
@@ -130,7 +130,7 @@ void server_callback(pn_connector_t *cto
 
   pn_link_t *link = pn_link_head(conn, PN_LOCAL_UNINIT | PN_REMOTE_ACTIVE);
   while (link) {
-    printf("%ls, %ls\n", pn_remote_source(link), pn_remote_target(link));
+    printf("%s, %s\n", pn_remote_source(link), pn_remote_target(link));
     pn_set_source(link, pn_remote_source(link));
     pn_set_target(link, pn_remote_target(link));
     pn_link_open(link);
@@ -209,8 +209,8 @@ struct client_context {
   const char *mechanism;
   const char *username;
   const char *password;
-  wchar_t hostname[1024];
-  wchar_t address[1024];
+  const char *hostname;
+  const char *address;
 };
 
 void client_callback(pn_connector_t *ctor)
@@ -260,10 +260,8 @@ void client_callback(pn_connector_t *cto
 
     char container[1024];
     if (gethostname(container, 1024)) pn_fatal("hostname lookup failed");
-    wchar_t wcontainer[1024];
-    mbstowcs(wcontainer, container, 1024);
 
-    pn_connection_set_container(connection, wcontainer);
+    pn_connection_set_container(connection, container);
     pn_connection_set_hostname(connection, ctx->hostname);
 
     pn_session_t *ssn = pn_session(connection);
@@ -271,7 +269,7 @@ void client_callback(pn_connector_t *cto
     pn_session_open(ssn);
 
     if (ctx->send_count) {
-      pn_link_t *snd = pn_sender(ssn, L"sender");
+      pn_link_t *snd = pn_sender(ssn, "sender");
       pn_set_target(snd, ctx->address);
       pn_link_open(snd);
 
@@ -283,7 +281,7 @@ void client_callback(pn_connector_t *cto
     }
 
     if (ctx->recv_count) {
-      pn_link_t *rcv = pn_receiver(ssn, L"receiver");
+      pn_link_t *rcv = pn_receiver(ssn, "receiver");
       pn_set_source(rcv, ctx->address);
       pn_link_open(rcv);
       pn_flow(rcv, ctx->recv_count);
@@ -399,8 +397,8 @@ int main(int argc, char **argv)
     ctx.username = user;
     ctx.password = pass;
     ctx.mechanism = mechanism;
-    mbstowcs(ctx.hostname, host, 1024);
-    mbstowcs(ctx.address, address, 1024);
+    ctx.hostname = host;
+    ctx.address = address;
     if (!pn_connector(drv, host, port, &ctx)) pn_fatal("connector failed\n");
     while (!ctx.done) {
       pn_driver_wait(drv, -1);

Modified: qpid/proton/trunk/proton-c/src/sasl/sasl.c
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/src/sasl/sasl.c?rev=1333032&r1=1333031&r2=1333032&view=diff
==============================================================================
--- qpid/proton/trunk/proton-c/src/sasl/sasl.c (original)
+++ qpid/proton/trunk/proton-c/src/sasl/sasl.c Wed May  2 13:19:01 2012
@@ -54,18 +54,6 @@ void pn_do_challenge(pn_dispatcher_t *di
 void pn_do_response(pn_dispatcher_t *disp);
 void pn_do_outcome(pn_dispatcher_t *disp);
 
-#define strdup my_strdup
-
-char *my_strdup(const char *s)
-{
-  if (!s) return NULL;
-  size_t size = strlen(s);
-  char *r = malloc(size + 1);
-  memcpy(r, s, size);
-  r[size] = '\0';
-  return r;
-}
-
 pn_sasl_t *pn_sasl()
 {
   pn_sasl_t *sasl = malloc(sizeof(pn_sasl_t));

Modified: qpid/proton/trunk/proton-c/src/types/decode.c
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/src/types/decode.c?rev=1333032&r1=1333031&r2=1333032&view=diff
==============================================================================
--- qpid/proton/trunk/proton-c/src/types/decode.c (original)
+++ qpid/proton/trunk/proton-c/src/types/decode.c Wed May  2 13:19:01 2012
@@ -20,7 +20,6 @@
  */
 
 #include <proton/codec.h>
-#include <iconv.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <wchar.h>
@@ -191,18 +190,7 @@ void pn_decode_binary(void *ctx, size_t 
 void pn_decode_utf8(void *ctx, size_t size, char *bytes) {
   pn_value_t *value = next_value(ctx);
   value->type = STRING;
-  size_t remaining = (size+1)*sizeof(wchar_t);
-  wchar_t buf[size+1];
-  iconv_t cd = iconv_open("WCHAR_T", "UTF-8");
-  wchar_t *out = buf;
-  size_t n = iconv(cd, &bytes, &size, (char **)&out, &remaining);
-  if (n == -1)
-  {
-    perror("pn_decode_utf8");
-  }
-  *out = L'\0';
-  iconv_close(cd);
-  value->u.as_string = pn_string(buf);
+  value->u.as_string = pn_stringn(bytes, size);
 }
 void pn_decode_symbol(void *ctx, size_t size, char *bytes) {
   pn_value_t *value = next_value(ctx);

Modified: qpid/proton/trunk/proton-c/src/types/string.c
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/src/types/string.c?rev=1333032&r1=1333031&r2=1333032&view=diff
==============================================================================
--- qpid/proton/trunk/proton-c/src/types/string.c (original)
+++ qpid/proton/trunk/proton-c/src/types/string.c Wed May  2 13:19:01 2012
@@ -24,12 +24,17 @@
 #include <stdlib.h>
 #include "value-internal.h"
 
-pn_string_t *pn_string(wchar_t *wcs)
+pn_string_t *pn_string(const char *utf8)
 {
-  size_t size = wcslen(wcs);
-  pn_string_t *str = malloc(sizeof(pn_string_t) + (size+1)*sizeof(wchar_t));
+  return pn_stringn(utf8, strlen(utf8));
+}
+
+pn_string_t *pn_stringn(const char *utf8, size_t size)
+{
+  pn_string_t *str = malloc(sizeof(pn_string_t) + (size+1)*sizeof(char));
   str->size = size;
-  wcscpy(str->wcs, wcs);
+  strncpy(str->utf8, utf8, size);
+  str->utf8[size] = '\0';
   return str;
 }
 
@@ -38,21 +43,16 @@ void pn_free_string(pn_string_t *str)
   free(str);
 }
 
-size_t pn_string_size(pn_string_t *str)
-{
-  return str->size;
-}
-
-wchar_t *pn_string_wcs(pn_string_t *str)
+const char *pn_string_utf8(pn_string_t *str)
 {
-  return str->wcs;
+  return str->utf8;
 }
 
 uintptr_t pn_hash_string(pn_string_t *s)
 {
-  wchar_t *c;
+  char *c;
   uintptr_t hash = 1;
-  for (c = s->wcs; *c; c++)
+  for (c = s->utf8; *c; c++)
   {
     hash = 31*hash + *c;
   }
@@ -62,7 +62,7 @@ uintptr_t pn_hash_string(pn_string_t *s)
 int pn_compare_string(pn_string_t *a, pn_string_t *b)
 {
   if (a->size == b->size)
-    return wmemcmp(a->wcs, b->wcs, a->size);
+    return memcmp(a->utf8, b->utf8, a->size);
   else
     return b->size - a->size;
 }

Modified: qpid/proton/trunk/proton-c/src/types/value-internal.h
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/src/types/value-internal.h?rev=1333032&r1=1333031&r2=1333032&view=diff
==============================================================================
--- qpid/proton/trunk/proton-c/src/types/value-internal.h (original)
+++ qpid/proton/trunk/proton-c/src/types/value-internal.h Wed May  2 13:19:01 2012
@@ -31,7 +31,7 @@ struct pn_symbol_t {
 
 struct pn_string_t {
   size_t size;
-  wchar_t wcs[];
+  char utf8[];
 };
 
 struct pn_binary_t {

Modified: qpid/proton/trunk/proton-c/src/types/value.c
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/src/types/value.c?rev=1333032&r1=1333031&r2=1333032&view=diff
==============================================================================
--- qpid/proton/trunk/proton-c/src/types/value.c (original)
+++ qpid/proton/trunk/proton-c/src/types/value.c Wed May  2 13:19:01 2012
@@ -23,11 +23,9 @@
 #include <proton/util.h>
 #include <stdarg.h>
 #include <stdbool.h>
-#include <wchar.h>
 #include <string.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <iconv.h>
 #include <arpa/inet.h>
 #include "encodings.h"
 #include "value-internal.h"
@@ -257,8 +255,8 @@ int pn_vscan(pn_value_t *value, const ch
       break;
     case 'S':
       value->type = STRING;
-      wchar_t *wcs = va_arg(ap, wchar_t *);
-      value->u.as_string = pn_string(wcs);
+      char *utf8 = va_arg(ap, char *);
+      value->u.as_string = pn_string(utf8);
       break;
     case 'z':
       value->type = BINARY;
@@ -471,7 +469,7 @@ int pn_format_value(char **pos, char *li
       if ((e = pn_format_symbol(pos, limit, v.u.as_symbol))) return e;
       break;
     case STRING:
-      if ((e = pn_fmt(pos, limit, "%ls", v.u.as_string->wcs))) return e;
+      if ((e = pn_fmt(pos, limit, "%s", v.u.as_string->utf8))) return e;
       break;
     case BINARY:
       if ((e = pn_format_binary(pos, limit, v.u.as_binary))) return e;
@@ -624,10 +622,6 @@ size_t pn_encode(pn_value_t v, char *out
 {
   char *old = out;
   size_t size = pn_encode_sizeof(v);
-  iconv_t cd;
-  char *inbuf;
-  size_t insize;
-  char *outbuf;
 
   switch (v.type)
   {
@@ -674,13 +668,7 @@ size_t pn_encode(pn_value_t v, char *out
     pn_write_symbol(&out, out + size, v.u.as_symbol->size, v.u.as_symbol->name);
     return out - old;
   case STRING:
-    cd = iconv_open("UTF-8", "WCHAR_T");
-    insize = 4*v.u.as_string->size;
-    inbuf = (char *)v.u.as_string->wcs;
-    outbuf = out + 5;
-    iconv(cd, &inbuf, &insize, &outbuf, &size);
-    iconv_close(cd);
-    pn_write_utf8(&out, out + size, outbuf - out - 5, out + 5);
+    pn_write_utf8(&out, out + size, v.u.as_string->size, v.u.as_string->utf8);
     return out - old;
   case BINARY:
     pn_write_binary(&out, out + size, v.u.as_binary->size, v.u.as_binary->bytes);

Modified: qpid/proton/trunk/proton-c/src/util.c
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/src/util.c?rev=1333032&r1=1333031&r2=1333032&view=diff
==============================================================================
--- qpid/proton/trunk/proton-c/src/util.c (original)
+++ qpid/proton/trunk/proton-c/src/util.c Wed May  2 13:19:01 2012
@@ -121,3 +121,14 @@ bool pn_env_bool(const char *name)
   return v && (!strcasecmp(v, "true") || !strcasecmp(v, "1") ||
                !strcasecmp(v, "yes"));
 }
+
+char *pn_strdup(const char *src)
+{
+  if (src) {
+    char *dest = malloc((strlen(src)+1)*sizeof(char));
+    if (!dest) return NULL;
+    return strcpy(dest, src);
+  } else {
+    return NULL;
+  }
+}

Modified: qpid/proton/trunk/proton-c/src/util.h
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/src/util.h?rev=1333032&r1=1333031&r2=1333032&view=diff
==============================================================================
--- qpid/proton/trunk/proton-c/src/util.h (original)
+++ qpid/proton/trunk/proton-c/src/util.h Wed May  2 13:19:01 2012
@@ -88,4 +88,7 @@ bool pn_env_bool(const char *name);
       (TAIL) = (NODE)-> PFX ## prev;                             \
   }
 
+char *pn_strdup(const char *src);
+#define strdup pn_strdup
+
 #endif /* util.h */



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


Mime
View raw message