head 1.4; access; symbols pkgsrc-2013Q2:1.4.0.54 pkgsrc-2013Q2-base:1.4 pkgsrc-2012Q4:1.4.0.52 pkgsrc-2012Q4-base:1.4 pkgsrc-2011Q4:1.4.0.50 pkgsrc-2011Q4-base:1.4 pkgsrc-2011Q2:1.4.0.48 pkgsrc-2011Q2-base:1.4 pkgsrc-2009Q4:1.4.0.46 pkgsrc-2009Q4-base:1.4 pkgsrc-2008Q4:1.4.0.44 pkgsrc-2008Q4-base:1.4 pkgsrc-2008Q3:1.4.0.42 pkgsrc-2008Q3-base:1.4 cube-native-xorg:1.4.0.40 cube-native-xorg-base:1.4 pkgsrc-2008Q2:1.4.0.38 pkgsrc-2008Q2-base:1.4 pkgsrc-2008Q1:1.4.0.36 pkgsrc-2008Q1-base:1.4 pkgsrc-2007Q4:1.4.0.34 pkgsrc-2007Q4-base:1.4 pkgsrc-2007Q3:1.4.0.32 pkgsrc-2007Q3-base:1.4 pkgsrc-2007Q2:1.4.0.30 pkgsrc-2007Q2-base:1.4 pkgsrc-2007Q1:1.4.0.28 pkgsrc-2007Q1-base:1.4 pkgsrc-2006Q4:1.4.0.26 pkgsrc-2006Q4-base:1.4 pkgsrc-2006Q3:1.4.0.24 pkgsrc-2006Q3-base:1.4 pkgsrc-2006Q2:1.4.0.22 pkgsrc-2006Q2-base:1.4 pkgsrc-2006Q1:1.4.0.20 pkgsrc-2006Q1-base:1.4 pkgsrc-2005Q4:1.4.0.18 pkgsrc-2005Q4-base:1.4 pkgsrc-2005Q3:1.4.0.16 pkgsrc-2005Q3-base:1.4 pkgsrc-2005Q2:1.4.0.14 pkgsrc-2005Q2-base:1.4 pkgsrc-2005Q1:1.4.0.12 pkgsrc-2005Q1-base:1.4 pkgsrc-2004Q4:1.4.0.10 pkgsrc-2004Q4-base:1.4 pkgsrc-2004Q3:1.4.0.8 pkgsrc-2004Q3-base:1.4 pkgsrc-2004Q2:1.4.0.6 pkgsrc-2004Q2-base:1.4 pkgsrc-2004Q1:1.4.0.4 pkgsrc-2004Q1-base:1.4 pkgsrc-2003Q4:1.4.0.2 pkgsrc-2003Q4-base:1.4 netbsd-1-6:1.1.0.8 netbsd-1-6-RELEASE-base:1.1 pkgviews:1.1.0.4 pkgviews-base:1.1 buildlink2:1.1.0.2 buildlink2-base:1.1 netbsd-1-5-PATCH003:1.1; locks; strict; comment @# @; 1.4 date 2003.01.03.15.24.59; author wiz; state dead; branches; next 1.3; 1.3 date 2002.12.17.19.40.08; author wiz; state Exp; branches; next 1.2; 1.2 date 2002.08.31.02.14.39; author wiz; state dead; branches; next 1.1; 1.1 date 2001.08.03.17.07.25; author wiz; state Exp; branches; next ; desc @@ 1.4 log @Update to 0.26: * Fixed filepointers leaks when ID3v2 tag is missing for files using ID3 tags (thanks to Martijn van Buul), * NetBSD patches from Thomas Klausner, * Some bugfixes in the CDDB search, * Updated character conversion for CD-Rom filesystems, * Fixed a crash when applying the CDDB result to a list with less files, * Fixed a memory bug when using the menu entry 'Reload the directory', * Added a man page (thanks to George Pauliuc), * When sorting the files, they are sorted also by ascending filename by default, * When tag entries have the focus, PageUp and PageDown keys select the previous or the next file, * Polish translation updated (thanks to Maciej Kasprzyk), * Italian translation updated (thanks to Lorenzo Cappelletti), * Ukrainian translation updated (thanks to Cawko Xakep). @ text @$NetBSD: patch-ab,v 1.3 2002/12/17 19:40:08 wiz Exp $ --- src/cddb.c.orig Sun Nov 10 15:42:26 2002 +++ src/cddb.c @@@@ -27,6 +27,7 @@@@ #include #include #include +#include #include #include @@@@ -80,6 +81,7 @@@@ gint Cddb_Open_Connection (gchar *host, void Cddb_Close_Connection (gint socket_id); gint Cddb_Read_Line (gint socket_id, gchar *cddb_out); gint Cddb_Read_Http_Header (gint socket_id, gchar *cddb_out); +gint Cddb_Read_Cddb_Header (gint socket_id, gchar *cddb_out); gboolean Cddb_Search_Album_List_From_String (void); gboolean Cddb_Get_Album_Tracks_List (GtkCList *clist, gint row, gint column); @@@@ -837,7 +839,7 @@@@ gint Cddb_Open_Connection (gchar *host, bzero((void *)&sockaddr,sizeof(sockaddr)); // Initialize with zero memcpy(&sockaddr.sin_addr.s_addr,*(hostent->h_addr_list),sizeof(sockaddr.sin_addr.s_addr)); sockaddr.sin_family = AF_INET; - sockaddr.sin_port = g_htons(port); + sockaddr.sin_port = htons(port); // Create socket if( (socket_id = socket(AF_INET,SOCK_STREAM,0)) < 0 ) @@@@ -893,14 +895,14 @@@@ void Cddb_Close_Connection (gint socket_ * Read one line (of the connection) into cddb_out. And return the number of bytes read. * If bytes_read=0 => no more data. * - * Server answser is like this : + * Server answser is formated like this : * - * HTTP/1.1 200 OK\r\n - * Server: Apache/1.3.19 (Unix) PHP/4.0.4pl1\r\n - * Connection: close\r\n + * HTTP/1.1 200 OK\r\n } + * Server: Apache/1.3.19 (Unix) PHP/4.0.4pl1\r\n } "Header" + * Connection: close\r\n } * \r\n - * \n - * [...] + * \n } + * [...] } "Body" */ gint Cddb_Read_Line (gint socket_id, gchar *cddb_out) { @@@@ -931,24 +933,57 @@@@ gint Cddb_Read_Line (gint socket_id, gch return bytes_returned; } + /* + * Read HTTP header data : from "HTTP/1.1 200 OK" to the blank line + */ + gint Cddb_Read_Http_Header (gint socket_id, gchar *cddb_out) { gint bytes_returned = 0; gint bytes_read; + if ( (bytes_read=Cddb_Read_Line(socket_id,cddb_out)) < 0 ) + return -1; // Error! + // First line must be "HTTP/1.1 200 OK" + if ( strncmp("HTTP",cddb_out,4)!=0 || strstr(cddb_out,"200 OK")==NULL ) + return -1; + // Read until end of the http header + while ( (bytes_read=Cddb_Read_Line(socket_id,cddb_out)) > 0 && strlen(cddb_out) > 0 ) + bytes_returned += bytes_read; + + return bytes_returned; +} + + +/* + * Read CDDB header data when requesting a file (cmd=cddb+read++) + * Must be read after the HTTP header. + * Take one line like this : "210 rock 780dfe09 CD database entry follows (until terminating `.')" + */ + +gint Cddb_Read_Cddb_Header (gint socket_id, gchar *cddb_out) +{ + gint bytes_read; + + if ( (bytes_read=Cddb_Read_Line(socket_id,cddb_out)) < 0 ) + return -1; // Error! + + // Some request receive some strange data at the beginning (2 or 3 characters)... so we read one line more... + if ( !cddb_out || strlen(cddb_out) < 10 ) if ( (bytes_read=Cddb_Read_Line(socket_id,cddb_out)) < 0 ) return -1; // Error! - // First line must be "HTTP/1.1 200 OK" - if ( strncmp("HTTP",cddb_out,4)!=0 ) - return bytes_returned; - // Read until end of the http header - while ( (bytes_read=Cddb_Read_Line(socket_id,cddb_out)) > 0 ) - bytes_returned += bytes_read; + + // Read the line + // 200 - exact match + // 210 - multiple exact matches + // 211 - inexact match + if ( cddb_out[0] != '2' ) + return -1; - return bytes_returned; + return bytes_read; } -*/ + /* @@@@ -1245,15 +1280,15 @@@@ gboolean Cddb_Search_Album_List_From_Str while (gtk_events_pending()) gtk_main_iteration(); cddb_out = g_malloc0(CDDB_ANSWER_LINE_SIZE+1); // Parse server answer : Check returned code in the first line - bytes_read_total = bytes_read = Cddb_Read_Line(socket_id,cddb_out); - if ( !cddb_out || bytes_read <= 0 || strncmp(cddb_out,"HTTP/1.1 200 OK",15) != 0 ) + if ( !cddb_out || (bytes_read=Cddb_Read_Http_Header(socket_id,cddb_out)) <= 0 ) { - msg = g_strdup(_("The server returned a wrong answer!")); + msg = g_strdup_printf(_("The server returned a wrong answer! (%s)"),cddb_out); gtk_statusbar_push(GTK_STATUSBAR(CddbStatusBar),CddbStatusBarContext,msg); g_print("%s\n",msg); g_free(msg); return FALSE; } + bytes_read_total = bytes_read; // Read other lines,and get list of matching albums // Composition of a line : @@@@ -1353,9 +1388,8 @@@@ gboolean Cddb_Get_Album_Tracks_List (Gtk gint socket_id; CddbAlbum *cddbalbum = NULL; GList *TrackOffsetList = NULL; - gchar *cddb_in; - gchar *cddb_out; - gint bytes_written, bytes_read; + gchar *cddb_in, *cddb_out, *msg; + gint bytes_written, bytes_read, bytes_read1, bytes_read_total; gboolean read_track_offset = FALSE; @@@@ -1405,19 +1439,27 @@@@ gboolean Cddb_Get_Album_Tracks_List (Gtk gtk_statusbar_push(GTK_STATUSBAR(CddbStatusBar),CddbStatusBarContext,_("Receptionning data ...")); while (gtk_events_pending()) gtk_main_iteration(); cddb_out = g_malloc0(CDDB_ANSWER_LINE_SIZE+1); - // Parse server answer : Check returned code in the first line - bytes_read = Cddb_Read_Line(socket_id,cddb_out); - if ( !cddb_out || bytes_read <= 0 || strncmp(cddb_out,"HTTP/1.1 200 OK",15) != 0 ) + // Parse server answer : Check HTTP Header and CDDB Header + if ( !cddb_out + || (bytes_read =Cddb_Read_Http_Header(socket_id,cddb_out)) <= 0 + || (bytes_read1=Cddb_Read_Cddb_Header(socket_id,cddb_out)) <= 0 ) { - gchar *msg = g_strdup(_("The server returned a wrong answer!")); + gchar *msg = g_strdup_printf(_("The server returned a wrong answer! (%s)"),cddb_out); gtk_statusbar_push(GTK_STATUSBAR(CddbStatusBar),CddbStatusBarContext,msg); g_print("%s\n",msg); g_free(msg); return FALSE; } + bytes_read_total = bytes_read + bytes_read1; while ( !CddbStopSearch && (bytes_read=Cddb_Read_Line(socket_id,cddb_out)) > 0 ) { + bytes_read_total += bytes_read; + msg = g_strdup_printf(_("Receptionning data (%s) ..."),Convert_Size_1(bytes_read_total)); + gtk_statusbar_push(GTK_STATUSBAR(CddbStatusBar),CddbStatusBarContext,msg); + while (gtk_events_pending()) gtk_main_iteration(); + g_free(msg); + if (!cddb_out) continue; // Empty line? //g_print("%s\n",cddb_out); @@@@ -1581,12 +1623,11 @@@@ gboolean Cddb_Set_Track_Infos_To_File_Li for (clist_row=0;clist_rowrows;clist_row++) { - ET_File *etfile; CddbTrackAlbum *cddbtrackalbum = NULL; cddbtrackalbum = gtk_clist_get_row_data(GTK_CLIST(CddbTrackCList),clist_row); - etfile = (ET_File *)etfilelist->data; if (cddbtrackalbum && etfilelist) { + ET_File *etfile = (ET_File *)etfilelist->data; File_Name *FileName = ET_File_Name_Item_New(); File_Tag *FileTag = ET_File_Tag_Item_New(); ET_Copy_File_Tag_Item(etfilelist->data,FileTag); @ 1.3 log @Update to 0.25b (including the patches for 0.25a and 0.25b in patches/). * Ability to stop the saving of all files, * Improvement of the directory browser, when renaming a directory, * Ability to set also the filename from CDDB results, * Ability to search a word in the album list of the CDDB window, * Don't loose unsupported tag items for the Ogg files, * Added CDDB support (from http protocol), * New possibilities for sorting the list of files (type, size, duration, birate, ...), * Old versions of ID3v2 tags are automatically updated to ID3v2.3, * Fixed renaming files or directories (the old method was better than the newer one, with patch from Alan Swanson), * Use of 'mkstemp' instead of 'mktemp', * Added ability to open a file with an external program, * Added ability to use arguments when opening a directory or a file with an external program (for example : 'xmms -e'), * Some fixes when deleting files : the total size and total duration are updated, * Invalid characters are replaced when renaming the file from the scanner, * Re-added preprocessor instructions in the file vcedit.h (forgotten when updating this file from vorbis-tools-1.0), * Fix for an unsupported ID3v2 tag : we get data of the ID3v1 tag (for example: ID3v2.4 tag with id3lib-3.8.0), * Added check of validity of playlist content mask, * Fixed reading of informations of mpeg header, and calculation of song time, with files containing an ID3v2 tag (patch from Artur Polaczynski), * Fixed the popup menu in entries field : now we don't need to click two times the left mouse button (patch from Maciej Kasprzyk), * Corrections in text menu (thanks to Artur Polaczynski), * Fixed renaming of directory, * Number of files to save is displayed in the progress bar, * Code clean up for scanners, * Various fixes, * Logo "updated", * translation updates @ text @d1 1 a1 1 $NetBSD$ @ 1.2 log @Update to 0.23. Lots of changes since 0.15, too many to mention. @ text @d1 1 a1 1 $NetBSD: patch-ab,v 1.1 2001/08/03 17:07:25 wiz Exp $ d3 9 a11 8 --- src/Makefile.orig Tue Mar 13 21:57:31 2001 +++ src/Makefile @@@@ -23,7 +23,7 @@@@ $(CC) $(GFLAGS) $(OPT) -c $< $(BINARY): $(OBJS) - $(CC) $(OBJS) $(GLIBS) $(ID3_LIB) $(OPT) -o $(BINARY) + $(CC) $(OBJS) $(GLIBS) $(ID3_LIB) $(OPT) -lz -lstdc++ -o $(BINARY) d13 5 d19 8 d28 166 @ 1.1 log @Update to 0.15. Lots of changes, most important of which is partial ID3v2 support via id3lib. @ text @d1 1 a1 1 $NetBSD$ @