aboutsummaryrefslogtreecommitdiffstats
path: root/src/utils.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* utils: move string_array_contains() to string_util.cMax Kellermann2010-12-231-13/+0
|
* Update copyright notices.Avuton Olrich2009-12-311-1/+1
|
* include config.h in all sourcesMax Kellermann2009-11-121-1/+1
| | | | | | After we've been hit by Large File Support problems several times in the past week (which only occur on 32 bit platforms, which I don't have), this is yet another attempt to fix the issue.
* utils: removed function set_nonblocking()Max Kellermann2009-11-081-30/+0
| | | | It's not used anymore, its features have been moved to fd_util.c.
* utils: renamed stringFoundInStringArray()Max Kellermann2009-11-061-7/+9
| | | | | No CamelCase. Use bool instead of int. Make both arguments mandatory.
* mapper, update, ...: use g_build_filename(), G_DIR_SEPARATOR, ...Max Kellermann2009-10-201-1/+1
| | | | | Try to be as portable as possible, use GLib path name functions and macros.
* utils: use g_ascii_strcasecmp() instead of strcasecmp()Max Kellermann2009-04-281-1/+1
| | | | | strcasecmp() is locale dependent, making it a bad choice for internal string comparisons.
* More debugging for Win32 ioctlsocket: complain if it's not a WinsockSean McNamara2009-03-271-3/+12
| | | | socket, because there is no ioctl for non-sockets on Windows
* all: Update copyright header.Avuton Olrich2009-03-131-6/+7
| | | | | | | | 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.
* utils: use g_usleep() instead of my_usleep()Max Kellermann2009-02-191-14/+0
| | | | | | | Now that I've found this nice function in the GLib docs, we can finally remove our custom sleep function. Still all those callers of g_usleep() have to be migrated one day to use events, instead of regular polling.
* use config_get_string() instead of config_get_param()Max Kellermann2009-01-251-5/+4
| | | | | config_get_string() is easier to use than config_get_param() because it unpacks the config_param struct.
* conf: no CamelCase, part IMax Kellermann2009-01-171-1/+1
| | | | Renamed functions, types, variables.
* added missing explicit config.h includesMax Kellermann2009-01-081-2/+1
|
* utils: removed unused functionsMax Kellermann2009-01-031-55/+3
| | | | | Removed all allocation functions, xwrite(), xread(), ARRAY_SIZE(). Those have been superseded by GLib.
* tag: use g_strescape() to eliminate evil charactersMax Kellermann2009-01-031-7/+0
| | | | | This always allocates strings on the heap, but we can delete the stripReturnChar() function now.
* listen: use GLib instead of utils.hMax Kellermann2009-01-031-14/+0
|
* main_notify: make the read side of the pipe blockingMax Kellermann2008-12-301-10/+0
| | | | | | Currently, both sides of the pipe are blocking, although we do not need blocking read(). Convert it back to blocking. Eliminate the select() from wait_main_task().
* utils: port set_nonblocking() to WIN32Max Kellermann2008-12-301-0/+6
| | | | | | The new WIN32 version of set_nonblocking() can only deal with sockets, i.e. it will fail on main_notify.c. On WIN32, we have to reimplement main_notify.c anyway, so this is not a big deal.
* utils: implement my_usleep() with Sleep() on WIN32Max Kellermann2008-12-301-0/+8
| | | | Sleep() has only millisecond granularity, but good enough for now.
* utils: implement parsePath() with g_strdup() on WIN32Max Kellermann2008-12-291-2/+10
| | | | | | On WIN32, parsePath() now simply duplicates the input string. There is currently nothing special we can do here. The old code was not portable on WIN32.
* utils: use g_get_home_dir()Max Kellermann2008-12-291-6/+4
| | | | | Use g_get_home_dir() to get the home directory of the current user. This will be portable to win32.
* utils: make variables more local in parsePath()Max Kellermann2008-12-291-16/+22
| | | | Declare variables where they are really used.
* utils: use GLib loggingMax Kellermann2008-12-291-14/+13
|
* Remove xpthread_* wrappersThomas Jansen2008-12-281-28/+0
|
* utils: removed myFgets()Max Kellermann2008-12-281-12/+0
| | | | Replaced myFgets() with fgets() + g_strchomp().
* utils: moving stringFoundInStringArray() from decoder into utilsViliam Mateicka2008-12-091-0/+11
|
* replaced mpd_malloc by G_GNUC_MALLOCThomas Jansen2008-12-021-4/+4
| | | | | We want to remove gcc.h eventually. This takes care of all the G_GNUC_MALLOC macros.
* replaced mpd_likely/mpd_unlikely by G_LIKELY/G_UNLIKELYThomas Jansen2008-12-021-7/+8
| | | | | We want to remove gcc.h eventually. This takes care of all the G_LIKELY/G_UNLIKELY macros.
* utils: use GUINT32_FROM_LE() instead of readLEuint32()Max Kellermann2008-11-011-7/+0
| | | | Eliminate code already provided by GLib.
* log: don't use utils.hMax Kellermann2008-10-291-20/+0
| | | | Prefer GLib over utils.h.
* utils: use g_str_has_prefix() instead of prefixcmp()Max Kellermann2008-10-281-10/+0
| | | | Remove duplicated code from MPD.
* locate: use g_utf8_casefold() instead of string_toupper()Max Kellermann2008-10-151-18/+0
| | | | | | string_toupper() and strDupToUpper() were not able to deal with character sets other than US-ASCII. Use GLib's g_utf8_casefold() for strings.
* don't include os_compat.hMax Kellermann2008-10-081-0/+11
| | | | | When there are standardized headers, use these instead of the bloated os_compat.h.
* Add prefixcmp() (stol^H^H^H^Hborrowed from git)Eric Wong2008-09-231-0/+10
| | | | | | | This allows us to avoid the nasty repetition in strncmp(foo, bar, strlen(foo)). We'll miss out on the compiler optimizing strlen() into sizeof() - 1 for string literals for this; but we don't use this it for performance-critical functions anyways...
* utils: pthread_{mutex,cond}_init can fail, so check for itEric Wong2008-06-301-0/+14
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@7394 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* utils: add new unforgiving utility functionsEric Wong2008-06-301-0/+24
| | | | | | We'll be using pipes when waiting for I/O, and condition variables at other times. git-svn-id: https://svn.musicpd.org/mpd/trunk@7391 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* clean up CPP includesMax Kellermann2008-04-121-1/+2
| | | | | | | | | Try to only include headers which are really needed. We should particularly check all "headers including other headers". The long-term goal is to have a manageable, small API for plugins (decoders, output) without so many mpd internals cluttering the namespace. git-svn-id: https://svn.musicpd.org/mpd/trunk@7319 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* notify: cleanupsEric Wong2008-03-261-0/+15
| | | | | | | | * move set_nonblock{,ing}() into utils.c since we use it elsewhere, too * add proper error checking to set_nonblocking() * use os_compat.h instead of individually #includ-ing system headers git-svn-id: https://svn.musicpd.org/mpd/trunk@7217 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* fix "unreachable code" warningMax Kellermann2008-03-261-1/+2
| | | | | | There is unreachable code at several positions, e.g. after an #if/#end, or after an endless loop. Remove that. git-svn-id: https://svn.musicpd.org/mpd/trunk@7197 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* Cleanup #includes of standard system headers and put them in one placeEric Wong2008-01-031-13/+1
| | | | | | | | | | | | | This will make refactoring features easier, especially now that pthreads support and larger refactorings are on the horizon. Hopefully, this will make porting to other platforms (even non-UNIX-like ones for masochists) easier, too. os_compat.h will house all the #includes for system headers considered to be the "core" of MPD. Headers for optional features will be left to individual source files. git-svn-id: https://svn.musicpd.org/mpd/trunk@7130 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* Revert r7111 and begin to properly fix storedPlaylist codeEric Wong2008-01-011-5/+1
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@7112 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* Don't let xstrdup(s) crash crash when s is NULL, but return Null in steadQball Cow2007-12-311-1/+5
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@7111 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* Merge branches/ew r7104Eric Wong2007-12-281-5/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | thread-safety work in preparation for rewrite to use pthreads Expect no regressions against trunk (r7078), possibly minor performance improvements in update (due to fewer heap allocations), but increased stack usage. Applied the following patches: * maxpath_str for reentrancy (temporary fix, reverted) * path: start working on thread-safe variants of these methods * Re-entrancy work on path/character-set conversions * directory.c: exploreDirectory() use reentrant functions here * directory/update: more use of reentrant functions + cleanups * string_toupper: a strdup-less version of strDupToUpper * get_song_url: a static-variable-free version of getSongUrl() * Use reentrant/thread-safe get_song_url everywhere * replace rmp2amp with the reentrant version, rmp2amp_r * Get rid of the non-reentrant/non-thread-safe rpp2app, too. * buffer2array: assert strdup() returns a usable value in unit tests * replace utf8ToFsCharset and fsCharsetToUtf8 with thread-safe variants * fix storing playlists w/o absolute paths * parent_path(), a reentrant version of parentPath() * parentPath => parent_path for reentrancy and thread-safety * allow "make test" to automatically run embedded unit tests * remove convStrDup() and maxpath_str() * use MPD_PATH_MAX everywhere instead of MAXPATHLEN * path: get rid of appendSlash, pfx_path and just use pfx_dir * get_song_url: fix the ability to play songs in the top-level music_directory git-svn-id: https://svn.musicpd.org/mpd/trunk@7106 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* Adding parsePath and making parseConfigFilePath use it.J. Alexander Treuman2007-06-131-0/+58
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@6622 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
* utils.c: fix xreallocEric Wong2006-09-071-5/+6
| | | | | | | | | | | (based on suggested patch by Jan-Benedict Glaw): > While hacking mpd, I noticed that an assert()ion in xrealloc is wrong. > A null size is perfectly legal, so we shouldn't assert on that. Since some C libraries return NULL when size == 0, we'll make sure we get a free()-able pointer since some of those C libraries also barf on free(NULL). git-svn-id: https://svn.musicpd.org/mpd/trunk@4740 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* Replace strdup and {c,re,m}alloc with x* variants to check for OOM errorsEric Wong2006-08-261-3/+55
| | | | | | | | | | | | | | | | | | | 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
* Add mpd-indent.shAvuton Olrich2006-07-201-29/+36
| | | | | | 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
* [CLEANUP] Cleanup whitespace->tabsAvuton Olrich2006-07-151-22/+21
| | | | | | Remove dead code Static where possible git-svn-id: https://svn.musicpd.org/mpd/trunk@4345 09075e82-0dd4-0310-85a5-a0d7c8717e4f