Commit Graph

29 Commits

Author SHA1 Message Date
Max Kellermann
53a749780a database: use strcmp() instead of g_str_has_prefix() 2009-11-01 15:54:06 +01:00
Max Kellermann
9bcfd3a47d text_file: allocate line buffers dynamically
Use a single GString buffer object in all functions loading the
database.  Enlarge it automatically for long lines.  This eliminates
the maximum line length for tag values.  There is still an upper limit
of 512 kB to prevent denial of service, but that's reasonable I guess.
2009-11-01 15:37:16 +01:00
Max Kellermann
f7ce4f6239 song: renamed attribute "url" to "uri" 2009-10-13 18:01:06 +02:00
Max Kellermann
111c4dac63 song_save: use GError for error handling 2009-07-05 08:29:52 +02:00
Max Kellermann
69ff9d757f song_save: no CamelCase
Renamed functions.
2009-07-05 08:29:50 +02:00
Max Kellermann
7d9316a52d song_save: don't call tag_free(NULL)
When a song was in the database twice (which shouldn't happen), and
the first song had no tag items, MPD calledd tag_free(NULL).  Add a
check to that source location, and an assertion to tag_free().
2009-04-28 19:57:49 +02:00
Max Kellermann
a899c210b9 log: removed DEBUG() and FATAL()
Use GLib the logging functions g_debug(), g_error() instead.
2009-03-15 18:23:00 +01:00
Avuton Olrich
0aee49bdf8 all: Update copyright header.
This updates the copyright header to all be the same, which is
pretty much an update of where to mail request for a copy of the GPL
and the years of the MPD project. This also puts all committers under
'The Music Player Project' umbrella. These entries should go
individually in the AUTHORS file, for consistancy.
2009-03-13 11:51:55 -07:00
Max Kellermann
75c2029b1c tag: no CamelCase
Renamed numOfItems to num_items.
2009-02-27 09:01:55 +01:00
Max Kellermann
642b861526 song_save: don't fail on empty tag values
If a tag value is an empty string, the space after the colon was
removed by g_strchomp().  Fix this by removing the space check and
using g_strchug() on the return value.
2009-01-14 13:44:14 +01:00
Max Kellermann
3c6a85d8f7 song_save: return value pointer from matchesAnMpdTagItemKey()
The matchesAnMpdTagItemKey() API becomes more powerful and flexible if
the return value is the value pointer instead of a boolean.  It also
removes (invalid and dangerous) assumptions about the string from its
caller.
2009-01-14 13:43:57 +01:00
Max Kellermann
7cc9ba45a9 song_save: itemType is "enum tag_type", not "int" 2009-01-14 13:38:47 +01:00
Max Kellermann
1452717459 song_save: check for colon and space when loading a tag
matchesAnMpdTagItemKey() broke when two tag items had the same prefix,
because it did not check if the tag name ended after the prefix.  Add
a check for the colon and the space after the tag name.
2009-01-13 23:43:16 +01:00
Max Kellermann
dec4e4ca85 don't include utils.h when it isn't used 2009-01-03 14:52:56 +01:00
Max Kellermann
859aac7242 utils: removed myFgets()
Replaced myFgets() with fgets() + g_strchomp().
2008-12-28 19:54:49 +01:00
Max Kellermann
68977af6e0 directory: eliminate CamelCase
CamelCase is ugly, rename the functions.
2008-10-08 11:07:58 +02:00
Max Kellermann
5e7b18f874 song: removed CamelCase
CamelCase is ugly...  rename all functions.
2008-10-08 11:05:34 +02:00
Max Kellermann
5e4be9e495 song: replaced all song constructors
Provide separate constructors for creating a remote song, a local
song, and one for loading data from a song file.  This way, we can add
more assertions.
2008-10-08 11:05:25 +02:00
Max Kellermann
d562ba5fbb song: converted typedef Song to struct song
Again, a data type which can be forward-declared.
2008-10-08 10:49:11 +02:00
Max Kellermann
25f67da58c directory: converted typedef Directory to struct directory
The struct can be forward-declared by other headers, which relaxes the
header dependencies.
2008-10-08 10:49:05 +02:00
Max Kellermann
c47f97e1dc song: use songvec_for_each() in songvec_print() / songvec_save()
songvec_for_each() has locking, use it instead of manually iterating
over the songvec items.
2008-10-07 22:10:42 +02:00
Eric Wong
f1c53fe0ed song: stop storing song_type
We already know if a song is a URL or not based on whether it
has parentDir defined or not.  Hopefully one day in the future
we can drop HTTP support from MPD entirely when an HTTP
filesystem comes along and we can access streams via open(2).
2008-10-06 18:52:13 +02:00
Eric Wong
267b2cd6e6 song: use flex arrays to store song->url
Reduce the number of allocations we make, so there's less
pressure on the allocator and less overhead to keep track
of the allocations in.
2008-10-06 18:46:52 +02:00
Eric Wong
43761441c9 song: get rid of newNullSong()
It didn't save us any lines of code nor did it do anything
useful since we would overwrite everything anyways.
2008-10-06 18:43:10 +02:00
Eric Wong
28d39948d7 songvec: remove songvec_prune
Any pruned files will be noticed during update and pruned
from the live database, so this inefficient function can
go away and never come back.
2008-09-23 22:37:33 +02:00
Eric Wong
cfc2dd3e94 Don't try to prune unless we're updating
Pruning is very expensive and we won't need it in the future
anyways.  This brings startup back to previous speeds (before
songvec changes).
2008-09-23 20:48:51 +02:00
Eric Wong
0bec1d3807 Replace SongList with struct songvec
Our linked-list implementation is wasteful and the
SongList isn't modified enough to benefit from being a linked
list.  So use a more compact array of song pointers which
saves ~200K on a library with ~9K songs (on x86-32).
2008-09-23 20:48:39 +02:00
Max Kellermann
59efed3e8e tag: added buffered versions of the tag_print.c code
Currently, when the tag cache is being serialized to hard disk, the
stdio buffer is flushed before every song, because tag_print.c
performs unbuffered writes on the raw file descriptor.  Unfortunately,
the fdprintf() API allows buffered I/O only for a client connection by
looking up the client pointer owning the file descriptor - for stdio,
this is not possible.  To re-enable proper stdio buffering, we have to
duplicate the tag_print.c code without fprintf() instead of our custom
fdprintf() hack.  Add this duplicated code to tag_save.c.
2008-09-07 13:36:05 +02:00
Max Kellermann
75aa8dad4c song: moved code to song_print.c, song_save.c
Move everything which dumps song information (via tag_print.c) to a
separate source file.  song_print.c gets code which writes song data
to the client; song_save.c is responsible for serializing songs from
the tag cache.
2008-09-07 13:35:01 +02:00