diff options
Diffstat (limited to 'mg_db.c')
-rw-r--r-- | mg_db.c | 24 |
1 files changed, 11 insertions, 13 deletions
@@ -193,9 +193,7 @@ char* mgSQLStringImp::quoted() const { if (!m_quoted) - { - asprintf(&m_quoted,"'%s'",unquoted()); - } + msprintf(&m_quoted,"'%s'",unquoted()); return m_quoted; } @@ -372,7 +370,7 @@ mgDb::Sync(char * const * path_argv) if (!item->Valid(true)) { char *b; - asprintf(&b,"DELETE FROM tracks WHERE id=%ld",item->getItemid()); + msprintf(&b,"DELETE FROM tracks WHERE id=%ld",item->getItemid()); count += Execute(b); free(b); } @@ -1018,7 +1016,7 @@ mgSQLString mgDb::Build_cddbid(const mgSQLString& artist) const { char *s; - asprintf(&s,"%ld-%.9s",random(),artist.original()); + msprintf(&s,"%ld-%.9s",random(),artist.original()); mgSQLString result = mgSQLString(s); free(s); return result; @@ -1029,7 +1027,7 @@ mgDb::getAlbum(const char *filename,const mgSQLString& c_album, const mgSQLString& c_artist) { char *b; - asprintf(&b,"SELECT cddbid FROM album" + msprintf(&b,"SELECT cddbid FROM album" " WHERE title=%s AND artist=%s",c_album.quoted(),c_artist.quoted()); mgSQLString result(get_col0(b)); free(b); @@ -1044,13 +1042,13 @@ mgDb::getAlbum(const char *filename,const mgSQLString& c_album, mgSQLString c_directory(directory); free(directory); char *where; - asprintf(&where,"WHERE tracks.sourceid=album.cddbid " + msprintf(&where,"WHERE tracks.sourceid=album.cddbid " "AND %s=%s " "AND album.title=%s", Directory().c_str(),c_directory.quoted(), c_album.quoted()); // how many artists will the album have after adding this one? - asprintf(&b,"SELECT distinct album.artist FROM album, tracks %s ",where); + msprintf(&b,"SELECT distinct album.artist FROM album, tracks %s ",where); mgQuery q(DbHandle(),b); free(b); long new_album_artists = q.Rows(); @@ -1066,10 +1064,10 @@ mgDb::getAlbum(const char *filename,const mgSQLString& c_album, if (new_album_artists>1 && strcmp(buf.original(),"Various Artists")) // is the album multi artist and not yet marked as such? { - asprintf(&b,"SELECT album.cddbid FROM album, tracks %s",where); + msprintf(&b,"SELECT album.cddbid FROM album, tracks %s",where); result=mgSQLString(get_col0(b)); free(b); - asprintf(&b,"UPDATE album SET artist='Various Artists' WHERE cddbid=%s",result.quoted()); + msprintf(&b,"UPDATE album SET artist='Various Artists' WHERE cddbid=%s",result.quoted()); Execute(b); free(b); // here we could change all tracks.sourceid to result and delete @@ -1081,7 +1079,7 @@ mgDb::getAlbum(const char *filename,const mgSQLString& c_album, { // no usable album found result=Build_cddbid(c_artist); char *b; - asprintf(&b,"INSERT INTO album (title,artist,cddbid) " + msprintf(&b,"INSERT INTO album (title,artist,cddbid) " "VALUES(%s,%s,%s)", c_album.quoted(),c_artist.quoted(),result.quoted()); int rows = Execute(b); @@ -1142,7 +1140,7 @@ mgDb::DefineGenre(const string genre) if (c!='a') sprintf(strchr(g,0)," %c",c); char *b; - asprintf(&b,"INSERT INTO genre (id,genre) VALUES('z%c','%s')",c,g); + msprintf(&b,"INSERT INTO genre (id,genre) VALUES('z%c','%s')",c,g); Execute(b); free(b); } @@ -1169,7 +1167,7 @@ mgDb::DefineGenre(const string genre) } char *b; mgSQLString c_genre(genre); - asprintf(&b,"INSERT INTO genre (id,genre) VALUES('%s',%s)",newid,c_genre.quoted()); + msprintf(&b,"INSERT INTO genre (id,genre) VALUES('%s',%s)",newid,c_genre.quoted()); Execute(b); free(b); m_Genres[genre]=newid; |