summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPieter Noordhuis <pcnoordhuis@gmail.com>2011-04-21 22:39:19 +0200
committerPieter Noordhuis <pcnoordhuis@gmail.com>2011-04-21 22:39:19 +0200
commitc9dc93e1de1f7561fe900787594ef64854bc121d (patch)
treeadb318318146a6357601f6afce1451b5902b948a
parent8419b060f2af3610e472cdb0231539bbb11636d1 (diff)
Move chrtos to hiredis.c (not used elsewhere)
-rw-r--r--hiredis.c24
-rw-r--r--util.h24
2 files changed, 24 insertions, 24 deletions
diff --git a/hiredis.c b/hiredis.c
index cfb0298..78d6bde 100644
--- a/hiredis.c
+++ b/hiredis.c
@@ -208,6 +208,30 @@ static void __redisReaderSetError(redisReader *r, int type, const char *str) {
r->errstr[len] = '\0';
}
+static size_t chrtos(char *buf, size_t size, char byte) {
+ size_t len = 0;
+
+ switch(byte) {
+ case '\\':
+ case '"':
+ len = snprintf(buf,size,"\"\\%c\"",byte);
+ break;
+ case '\n': len = snprintf(buf,size,"\"\\n\""); break;
+ case '\r': len = snprintf(buf,size,"\"\\r\""); break;
+ case '\t': len = snprintf(buf,size,"\"\\t\""); break;
+ case '\a': len = snprintf(buf,size,"\"\\a\""); break;
+ case '\b': len = snprintf(buf,size,"\"\\b\""); break;
+ default:
+ if (isprint(byte))
+ len = snprintf(buf,size,"\"%c\"",byte);
+ else
+ len = snprintf(buf,size,"\"\\x%02x\"",(unsigned char)byte);
+ break;
+ }
+
+ return len;
+}
+
static void __redisReaderSetErrorProtocolByte(redisReader *r, char byte) {
char cbuf[8], sbuf[128];
diff --git a/util.h b/util.h
index bf50659..d1170c7 100644
--- a/util.h
+++ b/util.h
@@ -38,28 +38,4 @@ static void redisOOM(void) {
exit(1);
}
-static size_t chrtos(char *buf, size_t size, char byte) {
- size_t len = 0;
-
- switch(byte) {
- case '\\':
- case '"':
- len = snprintf(buf,size,"\"\\%c\"",byte);
- break;
- case '\n': len = snprintf(buf,size,"\"\\n\""); break;
- case '\r': len = snprintf(buf,size,"\"\\r\""); break;
- case '\t': len = snprintf(buf,size,"\"\\t\""); break;
- case '\a': len = snprintf(buf,size,"\"\\a\""); break;
- case '\b': len = snprintf(buf,size,"\"\\b\""); break;
- default:
- if (isprint(byte))
- len = snprintf(buf,size,"\"%c\"",byte);
- else
- len = snprintf(buf,size,"\"\\x%02x\"",(unsigned char)byte);
- break;
- }
-
- return len;
-}
-
#endif