]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: fix base64 warnings (move impl to .c file)
authorSage Weil <sage@newdream.net>
Thu, 19 Nov 2009 20:44:55 +0000 (12:44 -0800)
committerSage Weil <sage@newdream.net>
Thu, 19 Nov 2009 20:44:55 +0000 (12:44 -0800)
src/Makefile.am
src/common/base64.c [new file with mode: 0644]
src/common/base64.h [new file with mode: 0644]
src/include/base64.h [deleted file]
src/rgw/rgw_admin.cc
src/rgw/rgw_main.cc
src/rgw/rgw_op.cc

index 563719e82932e4531e3afc6367afcb72c4d6c526..2f3cd824d1f39942ce7d08df44c80cda54ee061e 100644 (file)
@@ -323,6 +323,7 @@ libcommon_files = \
        common/ConfUtils.cc \
        common/MemoryModel.cc \
        common/armor.c \
+       common/base64.c \
        common/str_list.cc \
        mon/MonMap.cc \
        mon/MonClient.cc \
@@ -446,6 +447,7 @@ noinst_HEADERS = \
        cm.txt\
         common/arch.h\
         common/armor.h\
+       common/base64.h\
        common/debug.h\
        common/lockdep.h\
        common/BackTrace.h\
@@ -486,7 +488,6 @@ noinst_HEADERS = \
        include/LogEntry.h\
        include/assert.h\
         include/atomic.h\
-       include/base64.h\
         include/bitmapper.h\
         include/blobhash.h\
         include/buffer.h\
diff --git a/src/common/base64.c b/src/common/base64.c
new file mode 100644 (file)
index 0000000..c124532
--- /dev/null
@@ -0,0 +1,51 @@
+#include <openssl/bio.h>
+#include <openssl/evp.h>
+#include <openssl/buffer.h>
+
+#include <string.h>
+
+int encode_base64(const char *in, int in_len, char *out, int out_len)
+{
+  BIO *bmem, *b64;
+  BUF_MEM *bptr; 
+
+  b64 = BIO_new(BIO_f_base64());
+  bmem = BIO_new(BIO_s_mem());
+  b64 = BIO_push(b64, bmem);
+  BIO_write(b64, in, in_len);
+  if (BIO_flush(b64) < 0) {
+    return -1;
+  }
+  BIO_get_mem_ptr(b64, &bptr); 
+
+  int len = BIO_pending(bmem);
+  if (out_len <= len) {
+    return -1;
+  }
+  memcpy(out, bptr->data, len);
+  out[len - 1] = '\0';
+
+  BIO_free_all(b64); 
+
+  return 0;
+}
+
+int decode_base64(const char *in, int in_len, char *out, int out_len)
+{
+  BIO *b64, *bmem;
+  int ret;
+  char in_eol[in_len + 2];
+  memcpy(in_eol, in, in_len);
+  in_eol[in_len] = '\n';
+  in_eol[in_len + 1] = '\0';
+
+  b64 = BIO_new(BIO_f_base64());
+  bmem = BIO_new_mem_buf((unsigned char *)in_eol, in_len + 1);
+  bmem = BIO_push(b64, bmem);
+
+  ret = BIO_read(bmem, out, out_len);
+
+  BIO_free_all(bmem);
+
+  return ret;
+}
diff --git a/src/common/base64.h b/src/common/base64.h
new file mode 100644 (file)
index 0000000..a5c9670
--- /dev/null
@@ -0,0 +1,9 @@
+#ifndef __BASE64_H
+#define __BASE64_H
+
+extern "C" {
+  int encode_base64(const char *in, int in_len, char *out, int out_len);
+  int decode_base64(const char *in, int in_len, char *out, int out_len);
+}
+
+#endif
diff --git a/src/include/base64.h b/src/include/base64.h
deleted file mode 100644 (file)
index 4e926d3..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-#ifndef __BASE64_H
-#define __BASE64_H
-
-#include <openssl/bio.h>
-#include <openssl/evp.h>
-#include <openssl/buffer.h>
-
-#include <string.h>
-
-static int encode_base64(const char *in, int in_len, char *out, int out_len)
-{
-  BIO *bmem, *b64;
-  BUF_MEM *bptr; 
-
-  b64 = BIO_new(BIO_f_base64());
-  bmem = BIO_new(BIO_s_mem());
-  b64 = BIO_push(b64, bmem);
-  BIO_write(b64, in, in_len);
-  if (BIO_flush(b64) < 0) {
-    return -1;
-  }
-  BIO_get_mem_ptr(b64, &bptr); 
-
-  int len = BIO_pending(bmem);
-  if (out_len <= len) {
-    return -1;
-  }
-  memcpy(out, bptr->data, len);
-  out[len - 1] = '\0';
-
-  BIO_free_all(b64); 
-
-  return 0;
-}
-
-static int decode_base64(const char *in, int in_len, char *out, int out_len)
-{
-  BIO *b64, *bmem;
-  int ret;
-  char in_eol[in_len + 2];
-  memcpy(in_eol, in, in_len);
-  in_eol[in_len] = '\n';
-  in_eol[in_len + 1] = '\0';
-
-  b64 = BIO_new(BIO_f_base64());
-  bmem = BIO_new_mem_buf((unsigned char *)in_eol, in_len + 1);
-  bmem = BIO_push(b64, bmem);
-
-  ret = BIO_read(bmem, out, out_len);
-
-  BIO_free_all(bmem);
-
-  return ret;
-}
-
-#endif
index 4f7ab8d69569e12f1090e7a6ba9cb4b961f06672..f5f8c0f84abfd9673d6aead8ee896fe76c0f3ad0 100644 (file)
@@ -10,7 +10,7 @@ using namespace std;
 #include <openssl/rand.h>
 #include "common/common_init.h"
 
-#include "include/base64.h"
+#include "common/base64.h"
 #include "rgw_user.h"
 #include "rgw_access.h"
 #include "rgw_acl.h"
index 3501c7d51e11480e83a108955b63909724f91f5d..25c7792773419fda51677bfe2fa1dfd4acabf0b3 100644 (file)
@@ -27,7 +27,7 @@
 #include <sstream>
 
 #include "include/types.h"
-#include "include/base64.h"
+#include "common/base64.h"
 #include "common/BackTrace.h"
 
 using namespace std;
index bda64086ee7bb91d8521247b9350af69c1ba7fe3..e289c18c974a55053e193ac8ee8550b87c5a01a2 100644 (file)
@@ -4,7 +4,7 @@
 
 #include <sstream>
 
-#include "include/base64.h"
+#include "common/base64.h"
 
 #include "rgw_access.h"
 #include "rgw_op.h"