aboutsummaryrefslogtreecommitdiffstats
path: root/src/dbUtils.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Switch to C99 types (retaining compat with old compilers)Eric Wong2008-09-291-1/+1
| | | | | | | | | | | | | | | Seeing the "mpd_" prefix _everywhere_ is mind-numbing as the mind needs to retrain itself to skip over the first 4 tokens of a type to get to its meaning. So avoid having extra characters on my terminal to make it easier to follow code at 2:30 am in the morning. Please report any new issues you may come across on Free toolchains. I realize how difficult it can be to build/maintain cross-compiling toolchains and I have no intention of forcing people to upgrade their toolchains to build mpd. Tested with gcc 2.95.4 and and gcc 4.3.1 on x86-32.
* allow searching for albums with an empty tagEric Wong2008-09-291-0/+2
| | | | | | | | | | | | | | | | | | | | tfing wrote: > I have quite some files with an empty album tag as they do not come > from a particular album. > > If I want to look for those files and browse them, this happens: > :: nc localhost 6600 > OK MPD 0.12.0 > find album "" > ACK [2@0] {find} too few arguments for "find" > > I'd like to be able to browse those files in a client like gmpc. > So these 2 items would have to be developed: > - list album should report that some files have an empty tag > - it should be possible to search for an empty tag with the find command Patch-by: Marc Pavot ref: http://musicpd.org/mantis/view.php?id=464
* Replace SongList with struct songvecEric Wong2008-09-231-2/+2
| | | | | | | 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).
* use strset.h instead of tagTracker.hMax Kellermann2008-09-081-6/+17
| | | | | | | With a large music database, the linear string collection in tagTracker.c becomes very slow. We implemented that in a quick'n'dirty fashion when we removed tree.c, and now we rewrite it using the fast hashed string set.
* tag: don't pass "fd" to printVisitedInTagTracker()Max Kellermann2008-09-071-1/+1
| | | | Pass the client struct instead of the raw file descriptor.
* pass "struct client" to dbUtils.c, song.c, tag_print.cMax Kellermann2008-09-071-34/+33
| | | | | | Don't pass the raw file descriptor around. This migration patch is rather large, because all of the sources have inter dependencies - we have to change all of them at the same time.
* directory: don't pass fd to traverseAllIn()Max Kellermann2008-09-071-15/+15
| | | | | | | | This patch continues the work of the previous patch: don't pass a file descriptor at all to traverseAllIn(). Since this fd was only used to report "directory not found" errors, we can easily move that check to the caller. This is a great relief, since it removes the dependency on a client connection from a lot of enumeration functions.
* directory: don't pass fd to traverseAllIn() callbacksMax Kellermann2008-09-071-36/+67
| | | | | | | | | | Database traversal should be generic, and not bound to a client connection. This is the first step: no file descriptor for the callback functions forEachSong() and forEachDir(). If a callback needs the file descriptor, it has to be passed in the void*data pointer somehow; some callbacks might need a new struct for passing more than one parameter. This might look a bit cumbersome right now, but our goal is to have a clean API.
* playlist: don't pass "fd" to storedPlaylist.c functionsMax Kellermann2008-09-071-4/+3
| | | | | Return an "enum playlist_result" value instead of calling commandError() in storedPlaylist.c.
* playlist: don't pass "fd" to playlist.c functionsMax Kellermann2008-09-071-2/+2
| | | | | | The playlist library shouldn't talk to the client if possible. Introduce the "enum playlist_result" type which the caller (i.e. command.c) may use to generate an error message.
* song: moved code to song_print.c, song_save.cMax Kellermann2008-09-071-0/+1
| | | | | | | 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.
* dbUtils, playlist, directory: pass constant pointersMax Kellermann2008-09-061-9/+10
| | | | The usual bunch of const pointer conversions.
* tag: converted MpdTag.items to a pointer listMax Kellermann2008-08-291-2/+2
| | | | | | This prepares the following patches, which aim to reduce MPD's memory usage: we plan to share tag_item instances, instead of just their values.
* tag: renamed MpdTag and MpdTagItem to struct tag, struct mpd_tag_itemMax Kellermann2008-08-291-1/+1
| | | | | Getting rid of CamelCase; not having typedefs also allows us to forward-declare the structures.
* converted MpdTagItem.type to an enumMax Kellermann2008-08-261-1/+1
| | | | | Don't use CPP macros when you can use C enum... this also allows better type checking.
* enable -Wpointer-arith, -Wstrict-prototypesMax Kellermann2008-08-261-9/+13
| | | | | | Also enable -Wunused-parameter - this forces us to add the gcc "unused" attribute to a lot of parameters (mostly library callback functions), but it's worth it during code refactorizations.
* eliminated duplicate initializationMax Kellermann2008-03-261-1/+1
| | | | | | | Local variables which are never read before the first assignment don't need initialization. Saves a few bytes of text. Also don't reset variables which are never read until function return. git-svn-id: https://svn.musicpd.org/mpd/trunk@7199 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* addToPlaylist/addSongToPlaylist: printId argument changed to added_idEric Wong2008-01-261-1/+1
| | | | | | | | | | | | Instead of printing out the Id from playlist.c, instead set the integer that added_id poitns to if added_id is non-NULL. This makes the API cleaner and will allow us to use additional commands to manipulate the newly-added song_id. Callers (handleAddId) that relied on printId to print it to the given fd have now been modified to print the ID at a higher-level; making playlist.c less-dependent on protocol details. git-svn-id: https://svn.musicpd.org/mpd/trunk@7149 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* fixed -Wshadow warningsMax Kellermann2008-01-261-2/+2
| | | | | Signed-off-by: Eric Wong <normalperson@yhbt.net> git-svn-id: https://svn.musicpd.org/mpd/trunk@7143 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* Committing pat's rewrite of the stored playlist code. This also adds twoJ. Alexander Treuman2007-05-161-1/+4
| | | | | new commands: playlistmove and playlistdelete. git-svn-id: https://svn.musicpd.org/mpd/trunk@6116 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* Forgot to change the associated fdprintf format to %li.J. Alexander Treuman2007-04-261-1/+1
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@5952 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* Changing SearchStats.playTime from int to unsigned long.J. Alexander Treuman2007-04-261-1/+1
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@5951 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* Adding count command. It's usage is identical to find, but instead ofJ. Alexander Treuman2007-04-251-0/+44
| | | | | | returning a list of matching songs, the number of results and total play time of the results are returned. git-svn-id: https://svn.musicpd.org/mpd/trunk@5950 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* The massive copyright updateAvuton Olrich2007-04-051-1/+1
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@5834 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* Moving a bunch of the LocateTagItem code to locate.[ch] so that it canJ. Alexander Treuman2007-02-241-187/+7
| | | | | later be used for playlist searching. git-svn-id: https://svn.musicpd.org/mpd/trunk@5419 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* Moving LOCATE_TAG_{FILE,ANY}_TYPE defines to dbUtils.h, so that we canJ. Alexander Treuman2006-12-111-2/+0
| | | | | compare the return value of getLocateTagItemType() to them. git-svn-id: https://svn.musicpd.org/mpd/trunk@5138 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* Fixing "find any" and "list * any" to actually find matches.J. Alexander Treuman2006-12-111-2/+6
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@5137 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* Adding functions for clearing/adding to stored playlists. Commands to makeJ. Alexander Treuman2006-11-201-0/+11
| | | | | use of these functions are still being worked on. git-svn-id: https://svn.musicpd.org/mpd/trunk@5075 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* add support for: list fileWarren Dukes2006-10-271-4/+10
| | | | | This behaves the same as: list filename git-svn-id: https://svn.musicpd.org/mpd/trunk@4952 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* Replace strdup and {c,re,m}alloc with x* variants to check for OOM errorsEric Wong2006-08-261-5/+5
| | | | | | | | | | | | | | | | | | | I'm checking for zero-size allocations and assert()-ing them, so we can more easily get backtraces and debug problems, but we'll also allow -DNDEBUG people to live on the edge if they wish. We do not rely on errno when checking for OOM errors because some implementations of malloc do not set it, and malloc is commonly overridden by userspace wrappers. I've spent some time looking through the source and didn't find any obvious places where we would explicitly allocate 0 bytes, so we shouldn't trip any of those assertions. We also avoid allocating zero bytes because C libraries don't handle this consistently (some return NULL, some not); and it's dangerous either way. git-svn-id: https://svn.musicpd.org/mpd/trunk@4690 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* labels should be on the left most column, no tabbingWarren Dukes2006-08-091-1/+1
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@4605 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* interface/connection malloc reductions from mpd-keEric Wong2006-07-301-38/+38
| | | | | | | | | | | | | | | | | | | | | | | | | | | This patch massively reduces the amount of heap allocations at the interface/command layer. Most commands with minimal output should not allocate memory from the heap at all. Things like repeatedly polling status, currentsong, and volume changes should be faster as a result, and more importantly, not a source of memory fragmentation. These changes should be safe in that there's no way for a remote-client to corrupt memory or otherwise do bad stuff to MPD, but an extra set of eyes to review would be good. Of course there's never any warranty :) No longer do we use FILE * structures in the interface, which means we don't have to allocate any new memory for most connections. Now, before you go on about losing the buffering that FILE * +implies+, remember that myfprintf() never took advantage of any of the stdio buffering features. To reduce the diff and make bugs easier to spot in the diff, I've kept myfprintf in places where we write to files (and not network interfaces). Expect myfprintf to go away entirely soon (we'll use fprintf for writing regular files). git-svn-id: https://svn.musicpd.org/mpd/trunk@4483 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* Add mpd-indent.shAvuton Olrich2006-07-201-144/+180
| | | | | | Indent the entire tree, hopefully we can keep it indented. git-svn-id: https://svn.musicpd.org/mpd/trunk@4410 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* sparse: ANSI-fy function declarationsEric Wong2006-07-171-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | These are just warnings from sparse, but it makes the output easier to read. I ran this through a quick perl script, but of course verified the output by looking at the diff and making sure the thing still compiles. here's the quick perl script I wrote to generate this patch: ----------- 8< ----------- use Tie::File; defined(my $pid = open my $fh, '-|') or die $!; if (!$pid) { open STDERR, '>&STDOUT' or die $!; exec 'sparse', @ARGV or die $!; } my $na = 'warning: non-ANSI function declaration of function'; while (<$fh>) { print STDERR $_; if (/^(.+?\.[ch]):(\d+):(\d+): $na '(\w+)'/o) { my ($f, $l, $pos, $func) = ($1, $2, $3, $4); $l--; tie my @x, 'Tie::File', $f or die "$!: $f"; print '-', $x[$l], "\n"; $x[$l] =~ s/\b($func\s*)\(\s*\)/$1(void)/; print '+', $x[$l], "\n"; untie @x; } } git-svn-id: https://svn.musicpd.org/mpd/trunk@4378 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* De-inline non-trivial, non-performance-critical functionsEric Wong2006-07-151-2/+2
| | | | | | Functions that should stay inlined should have an explanation attached to them. git-svn-id: https://svn.musicpd.org/mpd/trunk@4355 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* Change shank's email addressJ. Alexander Treuman2006-07-141-1/+1
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@4333 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* whoops, I don't know how that snuck into the lastAvuton Olrich2006-07-131-0/+7
| | | | | diff git-svn-id: https://svn.musicpd.org/mpd/trunk@4319 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* Huge header update, update the copyright and addAvuton Olrich2006-07-131-9/+18
| | | | | the GPL header where necessary git-svn-id: https://svn.musicpd.org/mpd/trunk@4317 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* Remove a couple more unused functionsAvuton Olrich2006-07-131-20/+0
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@4315 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* Declare functions not used outside dbUtils.c static.Avuton Olrich2006-07-131-16/+16
| | | | | Remove a disabled function from dbUtils.c out of main.c git-svn-id: https://svn.musicpd.org/mpd/trunk@4314 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* add "any" option for search and find, patch from Robert AnderssonWarren Dukes2005-02-281-3/+16
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@2997 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* fix bug in findWarren Dukes2004-11-131-1/+1
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@2638 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* don't store only relative paths in the directory structure, its probably notWarren Dukes2004-11-121-4/+4
| | | | | worth the savings in memory for the extra cpu it requires git-svn-id: https://svn.musicpd.org/mpd/trunk@2630 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* now more flexible list, search, find, where you can enter pairs ofWarren Dukes2004-11-121-24/+112
| | | | | "conditionals". Note that logical and is implied. git-svn-id: https://svn.musicpd.org/mpd/trunk@2624 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* ok, tagtracker now tracks title, this has the disadvantage of needing to sortWarren Dukes2004-11-111-7/+8
| | | | | | | | the title tracker list, and it wastes more memory. But it makes implementing list command elegant, since we've just visit tags, then print out the visited tags in tag tracker (which has the benefit of making sure everything is in sorted order) git-svn-id: https://svn.musicpd.org/mpd/trunk@2608 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* better saved memmory displayWarren Dukes2004-11-111-10/+27
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@2607 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* ok, optimize memory sage of directorys, by iteratively creating the directories,Warren Dukes2004-11-111-6/+8
| | | | | | | | this code needs some serious testing: Note: The song name optimization i think is worth it, saves about 200k of ram on my syste, however, having to create directory names iteratively each time we print probably isn't worth the cpu. We only save about 10k of ram for the computer todo alot more work, and the code maybe a little messier git-svn-id: https://svn.musicpd.org/mpd/trunk@2604 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* ok, now song->url is only the filename, not the full path to the songWarren Dukes2004-11-111-2/+13
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@2602 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* implement saved memory by not storing full pathWarren Dukes2004-11-111-3/+24
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@2601 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* this is brokenWarren Dukes2004-11-111-1/+1
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@2597 09075e82-0dd4-0310-85a5-a0d7c8717e4f