[easytag] Use g_base64_{de,en}code()
- From: David King <davidk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [easytag] Use g_base64_{de,en}code()
- Date: Tue, 22 Jan 2013 21:23:05 +0000 (UTC)
commit 7d5ead7cd36ac299813d76bb04580d7dddb2a24c
Author: Adrian Bunk <bunk stusta de>
Date: Mon Jan 21 20:54:00 2013 +0200
Use g_base64_{de,en}code()
There is no point in having own code for functionality already provided
by glib.
Makefile.am | 2 -
src/Makefile.mingw | 1 -
src/base64.c | 218 ----------------------------------------------------
src/base64.h | 42 ----------
src/cddb.c | 58 +-------------
src/ogg_tag.c | 11 +--
6 files changed, 4 insertions(+), 328 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index d63afb7..6c1a255 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -35,7 +35,6 @@ easytag_SOURCES = \
src/about.c \
src/ape_tag.c \
src/bar.c \
- src/base64.c \
src/browser.c \
src/browser.h \
src/cddb.c \
@@ -81,7 +80,6 @@ easytag_headers = \
src/about.h \
src/ape_tag.h \
src/bar.h \
- src/base64.h \
src/cddb.h \
src/charset.h \
src/crc32.h \
diff --git a/src/Makefile.mingw b/src/Makefile.mingw
index d4ed141..8c1f336 100644
--- a/src/Makefile.mingw
+++ b/src/Makefile.mingw
@@ -67,7 +67,6 @@ RC_SRC = win32/easytag.rc
DLL_C_SRC = about.c \
ape_tag.c \
bar.c \
- base64.c \
browser.c \
charset.c \
cddb.c \
diff --git a/src/cddb.c b/src/cddb.c
index cdba800..002050d 100644
--- a/src/cddb.c
+++ b/src/cddb.c
@@ -45,7 +45,6 @@
#include "easytag.h"
#include "et_core.h"
#include "browser.h"
-#include "base64.h"
#include "scan.h"
#include "log.h"
#include "misc.h"
@@ -4155,57 +4154,6 @@ Cddb_Get_Pixbuf_From_Server_Name (const gchar *server_name)
}
-/*
- * Function taken from gFTP.
- * The standard to Base64 encoding can be found in RFC2045
- */
-/*
-char *base64_encode (char *str)
-{
- char *newstr, *newpos, *fillpos, *pos;
- unsigned char table[64], encode[3];
- int i, num;
-
- // Build table
- for (i = 0; i < 26; i++)
- {
- table[i] = 'A' + i;
- table[i + 26] = 'a' + i;
- }
-
- for (i = 0; i < 10; i++)
- table[i + 52] = '0' + i;
-
- table[62] = '+';
- table[63] = '/';
-
-
- num = strlen (str) / 3;
- if (strlen (str) % 3 > 0)
- num++;
- newstr = g_malloc (num * 4 + 1);
- newstr[num * 4] = '\0';
- newpos = newstr;
-
- pos = str;
- while (*pos != '\0')
- {
- memset (encode, 0, sizeof (encode));
- for (i = 0; i < 3 && *pos != '\0'; i++)
- encode[i] = *pos++;
-
- fillpos = newpos;
- *newpos++ = table[encode[0] >> 2];
- *newpos++ = table[(encode[0] & 3) << 4 | encode[1] >> 4];
- *newpos++ = table[(encode[1] & 0xF) << 2 | encode[2] >> 6];
- *newpos++ = table[encode[2] & 0x3F];
- while (i < 3)
- fillpos[++i] = '=';
- }
- return (newstr);
-}
-*/
-
static gchar *
Cddb_Format_Proxy_Authentification (void)
{
@@ -4213,13 +4161,11 @@ Cddb_Format_Proxy_Authentification (void)
if (CDDB_USE_PROXY && CDDB_PROXY_USER_NAME != NULL && *CDDB_PROXY_USER_NAME != '\0')
{
-
- gchar *tempstr;
+ const gchar *tempstr;
gchar *str_encoded;
tempstr = g_strconcat(CDDB_PROXY_USER_NAME, ":", CDDB_PROXY_USER_PASSWORD, NULL);
- //str_encoded = base64_encode(tempstr);
- base64_encode (tempstr, strlen(tempstr), &str_encoded);
+ str_encoded = g_base64_encode((const guchar *)tempstr, strlen(tempstr));
ret = g_strdup_printf("Proxy-authorization: Basic %s\r\n", str_encoded);
g_free (str_encoded);
diff --git a/src/ogg_tag.c b/src/ogg_tag.c
index f0fcbae..e6fe6e1 100644
--- a/src/ogg_tag.c
+++ b/src/ogg_tag.c
@@ -38,7 +38,6 @@
#include "et_core.h"
#include "log.h"
#include "misc.h"
-#include "base64.h"
#include "picture.h"
#include "setting.h"
#include "charset.h"
@@ -511,8 +510,6 @@ gboolean Ogg_Tag_Read_File_Tag (gchar *filename, File_Tag *FileTag)
field_num = 0;
while ( (string = vorbis_comment_query(vc,"COVERART",field_num++)) != NULL )
{
- gchar *data;
- gint size;
Picture *pic;
pic = Picture_Allocate();
@@ -525,11 +522,7 @@ gboolean Ogg_Tag_Read_File_Tag (gchar *filename, File_Tag *FileTag)
pic->data = NULL;
// Decode picture data
- data = g_strdup(string);
- size = base64_decode(string, data);
- if ( data && (pic->data = g_memdup(data, size)) )
- pic->size = size;
- g_free(data);
+ pic->data = g_base64_decode (string, &pic->size);
if ( (string = vorbis_comment_query(vc,"COVERARTTYPE",field_num-1)) != NULL )
{
@@ -820,7 +813,7 @@ gboolean Ogg_Tag_Write_File_Tag (ET_File *ETFile)
g_free(string);
}
- base64_encode (pic->data, pic->size, &data_encoded);
+ data_encoded = g_base64_encode (pic->data, pic->size);
string = g_strdup_printf("COVERART=%s",data_encoded);
vorbis_comment_add(vc,string);
g_free(data_encoded);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]