Move string.h to internal code
diff --git a/src/core/channel/call_op_string.c b/src/core/channel/call_op_string.c
index 9a7838c..7899139 100644
--- a/src/core/channel/call_op_string.c
+++ b/src/core/channel/call_op_string.c
@@ -37,8 +37,8 @@
#include <stdio.h>
#include <string.h>
+#include "src/core/support/string.h"
#include <grpc/support/alloc.h>
-#include <grpc/support/string.h>
#include <grpc/support/useful.h>
#define MAX_APPEND 1024
diff --git a/src/core/channel/channel_args.c b/src/core/channel/channel_args.c
index 36312e5..04ce519 100644
--- a/src/core/channel/channel_args.c
+++ b/src/core/channel/channel_args.c
@@ -33,9 +33,9 @@
#include <grpc/grpc.h>
#include "src/core/channel/channel_args.h"
+#include "src/core/support/string.h"
#include <grpc/support/alloc.h>
-#include <grpc/support/string.h>
#include <string.h>
diff --git a/src/core/channel/client_channel.c b/src/core/channel/client_channel.c
index fa75561..f6078aa 100644
--- a/src/core/channel/client_channel.c
+++ b/src/core/channel/client_channel.c
@@ -40,9 +40,9 @@
#include "src/core/channel/connected_channel.h"
#include "src/core/channel/metadata_buffer.h"
#include "src/core/iomgr/iomgr.h"
+#include "src/core/support/string.h"
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
-#include <grpc/support/string.h>
#include <grpc/support/sync.h>
#include <grpc/support/useful.h>
diff --git a/src/core/channel/connected_channel.c b/src/core/channel/connected_channel.c
index e01cb81..cfa76f9 100644
--- a/src/core/channel/connected_channel.c
+++ b/src/core/channel/connected_channel.c
@@ -37,12 +37,12 @@
#include <stdio.h>
#include <string.h>
+#include "src/core/support/string.h"
#include "src/core/transport/transport.h"
#include <grpc/byte_buffer.h>
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/slice_buffer.h>
-#include <grpc/support/string.h>
#define MAX_BUFFER_LENGTH 8192
/* the protobuf library will (by default) start warning at 100megs */
diff --git a/src/core/httpcli/httpcli.c b/src/core/httpcli/httpcli.c
index 2143eeb..d6fd8ca 100644
--- a/src/core/httpcli/httpcli.c
+++ b/src/core/httpcli/httpcli.c
@@ -44,9 +44,9 @@
#include "src/core/security/security_context.h"
#include "src/core/security/google_root_certs.h"
#include "src/core/security/secure_transport_setup.h"
+#include "src/core/support/string.h"
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
-#include <grpc/support/string.h>
typedef struct {
gpr_slice request_text;
diff --git a/src/core/httpcli/httpcli_security_context.c b/src/core/httpcli/httpcli_security_context.c
index c7b9b33..d074e16 100644
--- a/src/core/httpcli/httpcli_security_context.c
+++ b/src/core/httpcli/httpcli_security_context.c
@@ -36,9 +36,9 @@
#include <string.h>
#include "src/core/security/secure_transport_setup.h"
+#include "src/core/support/string.h"
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
-#include <grpc/support/string.h>
#include "src/core/tsi/ssl_transport_security.h"
typedef struct {
diff --git a/src/core/iomgr/resolve_address_posix.c b/src/core/iomgr/resolve_address_posix.c
index c9c2c53..f80eea7 100644
--- a/src/core/iomgr/resolve_address_posix.c
+++ b/src/core/iomgr/resolve_address_posix.c
@@ -44,9 +44,9 @@
#include "src/core/iomgr/iomgr_internal.h"
#include "src/core/iomgr/sockaddr_utils.h"
#include "src/core/iomgr/socket_utils_posix.h"
+#include "src/core/support/string.h"
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
-#include <grpc/support/string.h>
#include <grpc/support/thd.h>
#include <grpc/support/time.h>
diff --git a/src/core/iomgr/sockaddr_utils.c b/src/core/iomgr/sockaddr_utils.c
index eca14a4..5bb1124 100644
--- a/src/core/iomgr/sockaddr_utils.c
+++ b/src/core/iomgr/sockaddr_utils.c
@@ -37,8 +37,8 @@
#include <errno.h>
#include <string.h>
+#include "src/core/support/string.h"
#include <grpc/support/host_port.h>
-#include <grpc/support/string.h>
#include <grpc/support/log.h>
#include <grpc/support/port_platform.h>
diff --git a/src/core/iomgr/socket_utils_common_posix.c b/src/core/iomgr/socket_utils_common_posix.c
index 3a0639f..1854285 100644
--- a/src/core/iomgr/socket_utils_common_posix.c
+++ b/src/core/iomgr/socket_utils_common_posix.c
@@ -50,8 +50,8 @@
#include <errno.h>
#include "src/core/iomgr/sockaddr_utils.h"
+#include "src/core/support/string.h"
#include <grpc/support/host_port.h>
-#include <grpc/support/string.h>
#include <grpc/support/log.h>
#include <grpc/support/port_platform.h>
#include <grpc/support/sync.h>
diff --git a/src/core/iomgr/tcp_posix.c b/src/core/iomgr/tcp_posix.c
index 64996bd..a9b59df 100644
--- a/src/core/iomgr/tcp_posix.c
+++ b/src/core/iomgr/tcp_posix.c
@@ -44,10 +44,10 @@
#include <sys/socket.h>
#include <unistd.h>
+#include "src/core/support/string.h"
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/slice.h>
-#include <grpc/support/string.h>
#include <grpc/support/sync.h>
#include <grpc/support/time.h>
diff --git a/src/core/security/credentials.c b/src/core/security/credentials.c
index 628963e..db73c01 100644
--- a/src/core/security/credentials.c
+++ b/src/core/security/credentials.c
@@ -36,9 +36,9 @@
#include "src/core/httpcli/httpcli.h"
#include "src/core/iomgr/iomgr.h"
#include "src/core/security/json_token.h"
+#include "src/core/support/string.h"
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
-#include <grpc/support/string.h>
#include <grpc/support/sync.h>
#include <grpc/support/time.h>
diff --git a/src/core/security/json_token.c b/src/core/security/json_token.c
index 14ee758..82bd9b5 100644
--- a/src/core/security/json_token.c
+++ b/src/core/security/json_token.c
@@ -37,9 +37,9 @@
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
-#include <grpc/support/string.h>
#include "src/core/security/base64.h"
+#include "src/core/support/string.h"
#include <openssl/bio.h>
#include <openssl/evp.h>
diff --git a/src/core/security/secure_endpoint.c b/src/core/security/secure_endpoint.c
index e73767c..9f12cf5 100644
--- a/src/core/security/secure_endpoint.c
+++ b/src/core/security/secure_endpoint.c
@@ -32,11 +32,11 @@
*/
#include "src/core/security/secure_endpoint.h"
+#include "src/core/support/string.h"
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/slice_buffer.h>
#include <grpc/support/slice.h>
-#include <grpc/support/string.h>
#include <grpc/support/sync.h>
#include "src/core/tsi/transport_security_interface.h"
diff --git a/src/core/security/security_context.c b/src/core/security/security_context.c
index cce3c7f..58cd458 100644
--- a/src/core/security/security_context.c
+++ b/src/core/security/security_context.c
@@ -39,12 +39,12 @@
#include "src/core/channel/http_client_filter.h"
#include "src/core/security/credentials.h"
#include "src/core/security/secure_endpoint.h"
+#include "src/core/support/string.h"
#include "src/core/surface/lame_client.h"
#include "src/core/transport/chttp2/alpn.h"
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/slice_buffer.h>
-#include <grpc/support/string.h>
#include "src/core/tsi/fake_transport_security.h"
#include "src/core/tsi/ssl_transport_security.h"
diff --git a/src/core/statistics/census_rpc_stats.c b/src/core/statistics/census_rpc_stats.c
index 39094b5..dd3c07e 100644
--- a/src/core/statistics/census_rpc_stats.c
+++ b/src/core/statistics/census_rpc_stats.c
@@ -39,9 +39,9 @@
#include "src/core/statistics/census_tracing.h"
#include "src/core/statistics/window_stats.h"
#include "src/core/support/murmur_hash.h"
+#include "src/core/support/string.h"
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
-#include <grpc/support/string.h>
#include <grpc/support/sync.h>
#define NUM_INTERVALS 3
diff --git a/src/core/statistics/census_tracing.c b/src/core/statistics/census_tracing.c
index 1e61602..3c4ba66 100644
--- a/src/core/statistics/census_tracing.c
+++ b/src/core/statistics/census_tracing.c
@@ -38,10 +38,10 @@
#include "src/core/statistics/census_rpc_stats.h"
#include "src/core/statistics/hash_table.h"
+#include "src/core/support/string.h"
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/port_platform.h>
-#include <grpc/support/string.h>
#include <grpc/support/sync.h>
#include <grpc/support/time.h>
diff --git a/src/core/support/cmdline.c b/src/core/support/cmdline.c
index ff163a1..a55da9d 100644
--- a/src/core/support/cmdline.c
+++ b/src/core/support/cmdline.c
@@ -37,9 +37,9 @@
#include <stdio.h>
#include <string.h>
+#include "src/core/support/string.h"
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
-#include <grpc/support/string.h>
typedef enum { ARGTYPE_INT, ARGTYPE_BOOL, ARGTYPE_STRING } argtype;
diff --git a/src/core/support/host_port.c b/src/core/support/host_port.c
index 0250055..446c11e 100644
--- a/src/core/support/host_port.c
+++ b/src/core/support/host_port.c
@@ -35,8 +35,8 @@
#include <string.h>
+#include "src/core/support/string.h"
#include <grpc/support/log.h>
-#include <grpc/support/string.h>
int gpr_join_host_port(char **out, const char *host, int port) {
if (host[0] != '[' && strchr(host, ':') != NULL) {
diff --git a/src/core/support/string.c b/src/core/support/string.c
index 7e84437..9b5cac7 100644
--- a/src/core/support/string.c
+++ b/src/core/support/string.c
@@ -31,7 +31,7 @@
*
*/
-#include <grpc/support/string.h>
+#include "src/core/support/string.h"
#include <ctype.h>
#include <stddef.h>
diff --git a/src/core/support/string.h b/src/core/support/string.h
new file mode 100644
index 0000000..71bd3f8
--- /dev/null
+++ b/src/core/support/string.h
@@ -0,0 +1,87 @@
+/*
+ *
+ * Copyright 2014, Google Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#ifndef __GRPC_SUPPORT_STRING_H__
+#define __GRPC_SUPPORT_STRING_H__
+
+#include <stddef.h>
+
+#include <grpc/support/port_platform.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* String utility functions */
+
+/* Returns a copy of src that can be passed to gpr_free().
+ If allocation fails or if src is NULL, returns NULL. */
+char *gpr_strdup(const char *src);
+
+/* flag to include plaintext after a hexdump */
+#define GPR_HEXDUMP_PLAINTEXT 0x00000001
+
+/* Converts array buf, of length len, into a hexadecimal dump. Result should
+ be freed with gpr_free() */
+char *gpr_hexdump(const char *buf, size_t len, gpr_uint32 flags);
+
+/* Parses an array of bytes into an integer (base 10). Returns 1 on success,
+ 0 on failure. */
+int gpr_parse_bytes_to_uint32(const char *data, size_t length,
+ gpr_uint32 *result);
+
+/* minimum buffer size for calling ltoa */
+#define GPR_LTOA_MIN_BUFSIZE (3 * sizeof(long))
+
+/* Convert a long to a string in base 10; returns the length of the
+ output string (or 0 on failure) */
+int gpr_ltoa(long value, char *output);
+
+/* Reverse a run of bytes */
+void gpr_reverse_bytes(char *str, int len);
+
+/* printf to a newly-allocated string. The set of supported formats may vary
+ between platforms.
+
+ On success, returns the number of bytes printed (excluding the final '\0'),
+ and *strp points to a string which must later be destroyed with gpr_free().
+
+ On error, returns -1 and sets *strp to NULL. If the format string is bad,
+ the result is undefined. */
+int gpr_asprintf(char **strp, const char *format, ...);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __GRPC_SUPPORT_STRING_H__ */
diff --git a/src/core/surface/call.c b/src/core/surface/call.c
index 46502fb..1786523 100644
--- a/src/core/surface/call.c
+++ b/src/core/surface/call.c
@@ -35,11 +35,11 @@
#include "src/core/channel/channel_stack.h"
#include "src/core/channel/metadata_buffer.h"
#include "src/core/iomgr/alarm.h"
+#include "src/core/support/string.h"
#include "src/core/surface/channel.h"
#include "src/core/surface/completion_queue.h"
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
-#include <grpc/support/string.h>
#include <stdio.h>
#include <stdlib.h>
diff --git a/src/core/surface/channel_create.c b/src/core/surface/channel_create.c
index 41093d7..6939b92 100644
--- a/src/core/surface/channel_create.c
+++ b/src/core/surface/channel_create.c
@@ -48,10 +48,10 @@
#include "src/core/iomgr/tcp_client.h"
#include "src/core/surface/channel.h"
#include "src/core/surface/client.h"
+#include "src/core/support/string.h"
#include "src/core/transport/chttp2_transport.h"
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
-#include <grpc/support/string.h>
#include <grpc/support/sync.h>
#include <grpc/support/useful.h>
diff --git a/src/core/surface/client.c b/src/core/surface/client.c
index 74c79bd..fe3a81f 100644
--- a/src/core/surface/client.c
+++ b/src/core/surface/client.c
@@ -34,9 +34,9 @@
#include "src/core/surface/client.h"
#include "src/core/surface/call.h"
+#include "src/core/support/string.h"
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
-#include <grpc/support/string.h>
typedef struct { void *unused; } call_data;
diff --git a/src/core/surface/completion_queue.c b/src/core/surface/completion_queue.c
index 652f23e..e1cc114 100644
--- a/src/core/surface/completion_queue.c
+++ b/src/core/surface/completion_queue.c
@@ -37,13 +37,13 @@
#include <string.h>
#include "src/core/iomgr/pollset.h"
+#include "src/core/support/string.h"
#include "src/core/surface/call.h"
#include "src/core/surface/event_string.h"
#include "src/core/surface/surface_trace.h"
#include <grpc/support/alloc.h>
#include <grpc/support/atm.h>
#include <grpc/support/log.h>
-#include <grpc/support/string.h>
#define NUM_TAG_BUCKETS 31
diff --git a/src/core/surface/event_string.c b/src/core/surface/event_string.c
index 8ae2af7..e38ef06 100644
--- a/src/core/surface/event_string.c
+++ b/src/core/surface/event_string.c
@@ -35,7 +35,7 @@
#include <stdio.h>
-#include <grpc/support/string.h>
+#include "src/core/support/string.h"
#include <grpc/byte_buffer.h>
static size_t addhdr(char *p, grpc_event *ev) {
diff --git a/src/core/surface/lame_client.c b/src/core/surface/lame_client.c
index a5244db..056c986 100644
--- a/src/core/surface/lame_client.c
+++ b/src/core/surface/lame_client.c
@@ -36,11 +36,11 @@
#include <string.h>
#include "src/core/channel/channel_stack.h"
+#include "src/core/support/string.h"
#include "src/core/surface/channel.h"
#include "src/core/surface/call.h"
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
-#include <grpc/support/string.h>
typedef struct { void *unused; } call_data;
diff --git a/src/core/surface/secure_channel_create.c b/src/core/surface/secure_channel_create.c
index 3d57279..a231b27 100644
--- a/src/core/surface/secure_channel_create.c
+++ b/src/core/surface/secure_channel_create.c
@@ -48,13 +48,13 @@
#include "src/core/security/auth.h"
#include "src/core/security/security_context.h"
#include "src/core/security/secure_transport_setup.h"
+#include "src/core/support/string.h"
#include "src/core/surface/channel.h"
#include "src/core/surface/client.h"
#include "src/core/transport/chttp2_transport.h"
#include <grpc/grpc_security.h>
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
-#include <grpc/support/string.h>
#include <grpc/support/sync.h>
#include <grpc/support/useful.h>
#include "src/core/tsi/transport_security_interface.h"
diff --git a/src/core/surface/server.c b/src/core/surface/server.c
index cbdd3bf..9585e4e 100644
--- a/src/core/surface/server.c
+++ b/src/core/surface/server.c
@@ -40,12 +40,12 @@
#include "src/core/channel/channel_args.h"
#include "src/core/channel/connected_channel.h"
#include "src/core/iomgr/iomgr.h"
+#include "src/core/support/string.h"
#include "src/core/surface/call.h"
#include "src/core/surface/channel.h"
#include "src/core/surface/completion_queue.h"
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
-#include <grpc/support/string.h>
#include <grpc/support/useful.h>
typedef enum { PENDING_START, ALL_CALLS, CALL_LIST_COUNT } call_list;
diff --git a/src/core/transport/chttp2/frame_data.c b/src/core/transport/chttp2/frame_data.c
index 00b020b..dee61ce 100644
--- a/src/core/transport/chttp2/frame_data.c
+++ b/src/core/transport/chttp2/frame_data.c
@@ -35,9 +35,9 @@
#include <string.h>
+#include "src/core/support/string.h"
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
-#include <grpc/support/string.h>
#include <grpc/support/useful.h>
#include "src/core/transport/transport.h"
diff --git a/src/core/transport/chttp2/hpack_parser.c b/src/core/transport/chttp2/hpack_parser.c
index 64e08ff..c98b90e 100644
--- a/src/core/transport/chttp2/hpack_parser.c
+++ b/src/core/transport/chttp2/hpack_parser.c
@@ -38,10 +38,10 @@
#include <assert.h>
#include "src/core/transport/chttp2/bin_encoder.h"
+#include "src/core/support/string.h"
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/port_platform.h>
-#include <grpc/support/string.h>
#include <grpc/support/useful.h>
typedef enum {
diff --git a/src/core/transport/chttp2/timeout_encoding.c b/src/core/transport/chttp2/timeout_encoding.c
index 7217afa..23c4554 100644
--- a/src/core/transport/chttp2/timeout_encoding.c
+++ b/src/core/transport/chttp2/timeout_encoding.c
@@ -36,7 +36,7 @@
#include <stdio.h>
#include <string.h>
-#include <grpc/support/string.h>
+#include "src/core/support/string.h"
static int round_up(int x, int divisor) {
return (x / divisor + (x % divisor != 0)) * divisor;
diff --git a/src/core/transport/chttp2_transport.c b/src/core/transport/chttp2_transport.c
index 17b37d6..6dfffa1 100644
--- a/src/core/transport/chttp2_transport.c
+++ b/src/core/transport/chttp2_transport.c
@@ -37,6 +37,7 @@
#include <stdio.h>
#include <string.h>
+#include "src/core/support/string.h"
#include "src/core/transport/chttp2/frame_data.h"
#include "src/core/transport/chttp2/frame_goaway.h"
#include "src/core/transport/chttp2/frame_ping.h"
@@ -53,7 +54,6 @@
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/slice_buffer.h>
-#include <grpc/support/string.h>
#include <grpc/support/useful.h>
#define DEFAULT_WINDOW 65535