paraslash.git
8 years agot0005: Remove pointless assignment to regex,
Andre Noll [Wed, 14 Oct 2015 22:48:00 +0000 (00:48 +0200)]
t0005: Remove pointless assignment to regex,

This assignment at the end of the script has no effect.

8 years agoafs.h: Do not include regex.h.
Andre Noll [Sun, 6 Sep 2015 19:08:59 +0000 (21:08 +0200)]
afs.h: Do not include regex.h.

This is unnecessary as all source files which include afs.h included
regex.h before.

8 years agoaft.c: Prefer localtime() over localtime_r().
Andre Noll [Sat, 5 Sep 2015 19:49:16 +0000 (21:49 +0200)]
aft.c: Prefer localtime() over localtime_r().

While localtime(3) is required to behave as though tzset(3) was
called, localtime_r(3) does not have this requirement, and portable
code should thus call tzset(3) before localtime_r(3). This is not
the case for get_local_time() of aft.c.

As we are single-threaded here, we don't need the thread-safe version,
so it is easiest to switch to localtime(3).

8 years agoImprove lastplayed time format for ls and stat output.
Andre Noll [Sat, 5 Sep 2015 17:51:28 +0000 (19:51 +0200)]
Improve lastplayed time format for ls and stat output.

It is possible that the lastplayed time happens to be in the future.

Fix a whitespace issue while at it.

8 years agoMerge branch 'refs/heads/t/strerror'
Andre Noll [Tue, 8 Dec 2015 06:39:04 +0000 (07:39 +0100)]
Merge branch 'refs/heads/t/strerror'

Was cooking in next since 2015-09-27.

* refs/heads/t/strerror:
  error.h: Never call (para_)strerror() on osl errors.
  Clarify para_strerror().
  error.h: Remove is_errno().

8 years agobuild: Fix audiod_command.c dependency.
Andre Noll [Sun, 4 Oct 2015 20:25:06 +0000 (20:25 +0000)]
build: Fix audiod_command.c dependency.

The effect of these typos is that the dependencies are effectively
ignored. That is, changes to audiod_command.c do not cause a rebuild
of the command_list files.

The fix is trivial.

8 years agoplay: Handle empty arguments to --key-map gracefully.
Andre Noll [Sat, 3 Oct 2015 22:48:38 +0000 (22:48 +0000)]
play: Handle empty arguments to --key-map gracefully.

Executing para_play with an empty argument to --key-map results in
a read which starts one byte past the allocated buffer:

==24163== Invalid read of size 1
==24163==    at 0x402A1DA: index (mc_replace_strmem.c:223)
==24163==    by 0x804DA22: main (play.c:187)
==24163==  Address 0x498e331 is 0 bytes after a block of size 1 alloc'd

This patch fixes the issue by rejecting empty arguments as invalid.

8 years agoMerge branch 'refs/heads/t/command_handler_cleanups'
Andre Noll [Sun, 25 Oct 2015 15:06:43 +0000 (16:06 +0100)]
Merge branch 'refs/heads/t/command_handler_cleanups'

Cooking for about two months.

* refs/heads/t/command_handler_cleanups: (39 commits)
  com_addatt(): Return negative on errors
  com_rm(): In force mode, don't complain if no paths matched.
  aft: Unify handling of hash and path duplicates.
  afs: Provide pbout para_buffer for each callback.
  afs: Make afs callbacks more flexible.
  afs: Rename callback_function to afs_callback.
  com_check(): Add attribute checking.
  Let afs_event() return int.
  playlist_check_callback(): Return negative on errors
  mood_check_callback(): Return negative on errors
  com_mvblob(): Return negative on errors
  com_addblob(): Return negative on errors
  com_rmblob(): Return negative on errors, cleanup
  com_catblob(): Return negative on errors
  com_lsblob(): Return negative on errors
  rmatt: Cleanup callback.
  com_rmatt(): Return negative on errors
  com_mvatt(): Return negative on errors
  com_lsatt(): Return negative on errors
  com_init(): Return negative on errors
  ...

8 years agoaft.c: Clean up aft_hash_compare().
Andre Noll [Thu, 9 Apr 2015 13:57:45 +0000 (13:57 +0000)]
aft.c: Clean up aft_hash_compare().

This function is static and hence does not need doxygen comments. Also
break two overlong lines.

8 years agobuild: Fix m4 dependencies for BSD m4.
Andre Noll [Sat, 17 Oct 2015 14:47:01 +0000 (16:47 +0200)]
build: Fix m4 dependencies for BSD m4.

FreeBSD and NetBSD ship an m4 version which does not understand
the --debug=i option which we use to generate the .m4d dependency
files. This results in empty dependency files on those systems.

This was broken since m4 dependencies were introduced two years ago
in commit e249d105 (Generate ggo dependencies automatically). The
bug went unnoticed for so long because the problematic m4 command
is the first command of a pipeline (hence the exit code is lost),
and because the command redirects stderr, so the error message is
not printed to the terminal.

This commit fixes the bug by using the  (portable) -s option of
m4 rather than --debug. The -s option outputs line synchronization
directives which include the file name, so it is equally well suited
for generating the dependency files.

8 years agofade: Add missing line break for log message.
Andre Noll [Sat, 3 Oct 2015 21:38:08 +0000 (21:38 +0000)]
fade: Add missing line break for log message.

Fixes broken log output which looked like this:

21:33:48 21:33:48 sweet_dreams: waketime: 6:33client_cmd: /usr/local/bin/para_client stop

8 years agoweb: Clear DOT_FONTNAME in Doxyfile.
Andre Noll [Tue, 9 Jun 2015 17:42:31 +0000 (19:42 +0200)]
web: Clear DOT_FONTNAME in Doxyfile.

Doxygen-1.8.6. warns about DOT_FONTNAME being set:

Warning: doxygen no longer ships with the FreeSans font.
You may want to clear or change DOT_FONTNAME.
Otherwise you run the risk that the wrong font is being used for dot generated graphs.

The warning is harmless because the DOT_FONTNAME option has no effect
in our setup because HAVE_DOT is set to "NO". Setting DOT_FONTNAME
to the empty string, as recommended in the explanatory text after
the warning, silences the warning.

8 years agoweb: Update Doxyfile to doxygen-1.8.6.
Andre Noll [Tue, 9 Jun 2015 17:23:13 +0000 (19:23 +0200)]
web: Update Doxyfile to doxygen-1.8.6.

The system on which the public web pages are generated is now running
on Ubuntu-14.04 which ships doxygen-1.8.6. This version prints a
couple of warnings about obsolete tags in Doxyfile:

Warning: Tag `SYMBOL_CACHE_SIZE' at line 289 of file - has become obsolete.
To avoid this warning please remove this line from your configuration file or upgrade it using "doxygen -u"
Warning: Tag `SHOW_DIRECTORIES' at line 483 of file - has become obsolete.
To avoid this warning please remove this line from your configuration file or upgrade it using "doxygen -u"
Warning: Tag `HTML_ALIGN_MEMBERS' at line 820 of file - has become obsolete.
To avoid this warning please remove this line from your configuration file or upgrade it using "doxygen -u"
Warning: Tag `USE_INLINE_TREES' at line 989 of file - has become obsolete.
To avoid this warning please remove this line from your configuration file or upgrade it using "doxygen -u"

This patch is the result of running doxygen -u. With the patch applied,
the above warnings go away.

There is no need to be backwards compatible here because the web pages
are not created during a normal build.

8 years agoerror.h: Never call (para_)strerror() on osl errors.
Andre Noll [Wed, 12 Aug 2015 17:24:50 +0000 (19:24 +0200)]
error.h: Never call (para_)strerror() on osl errors.

In the (inlined) function para_strerror() of error.h we compile in
the call to osl_strerror() if and only if osl.h has been included
(in which case the preprocessor macro _OSL_H is defined). This is
wrong because an osl error code might well be passed to a function
defined in a compilation unit which does not include osl.h. If this
function calls para_strerror(), we will segfault or worse.

We need to check at link time whether osl_strerror is a defined
symbol rather than checking a preprocessor macro at compile time.
Fortunately, a little linker fu helps us out here. This patch
introduces a weak reference to osl_strerror to tell whether
osl_strerror is defined.

8 years agoClarify para_strerror().
Andre Noll [Mon, 10 Aug 2015 18:00:49 +0000 (20:00 +0200)]
Clarify para_strerror().

para_strerror() needs to distinguish three kinds of errors: paraslash
errors, errors from the osl library, and system (libc) errors. This
is achieved through dedicated bits in the error code which are
set for errors from osl and libc function calls. These bits tell
para_strerror() which function to call in order to obtain the text
that corresponds to the error code.

If such a dedicated bit is set, para_strerror() first clears the bit,
then calls the library strerror() function that corresponds to the
bit. The code to clear the bit is

num & ((1 << OSL_ERROR_BIT) - 1))

and similar for libc errors. However, this expression clears *all*
high bits, not only bit number OSL_ERROR_BIT. This is not a problem
since the higher bits are not set under normal circumstances, but it
is better to fix this anyway. The new code is

num & ~(1U << OSL_ERROR_BIT),

which turns off the osl error bit only.

8 years agoerror.h: Remove is_errno().
Andre Noll [Mon, 10 Aug 2015 17:34:45 +0000 (19:34 +0200)]
error.h: Remove is_errno().

There is only one caller of is_errno() which is converted to use
ERRNO_TO_PARA_ERROR() in this patch.

8 years agoMerge branch 'refs/heads/t/taggers'
Andre Noll [Sun, 27 Sep 2015 12:35:05 +0000 (12:35 +0000)]
Merge branch 'refs/heads/t/taggers'

Cooking in next since 2015-04-26.

* refs/heads/t/taggers:
  aac: Fix compilation without libmp4v2.
  The mp4 tagger.
  The mp3 tagger.
  The flac tagger.
  The ogg/speex tagger.
  The ogg/vorbis tagger.
  The ogg/opus tagger.
  The wma tagger.

8 years agobuild: maintainer-clean: Kill web_sync remove command.
Andre Noll [Mon, 7 Sep 2015 22:39:40 +0000 (00:39 +0200)]
build: maintainer-clean: Kill web_sync remove command.

This directory was used by a private script, but these days the script
creates its temporary files elsewhere. Hence it is no longer neccessary
to remove the directory in the receipe of the maintainer-clean target.

8 years agostring.c: Kill E_STRTOLL.
Andre Noll [Sat, 5 Sep 2015 11:01:18 +0000 (13:01 +0200)]
string.c: Kill E_STRTOLL.

This error code is unnecessary because para_atoi64() returns it only
if strtoll(3) did not perform any conversion and we have already a
more descriptive error code for this case: E_ATOI_NO_DIGITS.

Two new comments to para_atoi64() explain this in detail.

8 years agobuild: Completion headers no longer depend .c file.
Andre Noll [Wed, 2 Sep 2015 22:26:06 +0000 (00:26 +0200)]
build: Completion headers no longer depend .c file.

Due to commit 6aea41e6 (command_util.bash: Kill make_proto()) this
dependency can be dropped.

8 years agoattribute.c: Remove pointless condition in attribute_open().
Andre Noll [Sat, 29 Aug 2015 10:35:42 +0000 (12:35 +0200)]
attribute.c: Remove pointless condition in attribute_open().

ret is known to be negative at this point.

8 years agobitstream.c: Convert GET_DATA macro to inline function.
Andre Noll [Wed, 1 Apr 2015 02:55:50 +0000 (02:55 +0000)]
bitstream.c: Convert GET_DATA macro to inline function.

There is no benefit from defining this as a macro. With the inline
function we get type safety for free, and the new version is better
readable.

8 years agoparaslash 0.5.5 v0.5.5
Andre Noll [Sun, 20 Sep 2015 09:22:40 +0000 (11:22 +0200)]
paraslash 0.5.5

8 years agoMerge branch 'refs/heads/t/com_ls_compat'
Andre Noll [Thu, 17 Sep 2015 18:07:02 +0000 (20:07 +0200)]
Merge branch 'refs/heads/t/com_ls_compat'

A single commit which adds support for the new syntax for the -l and -s options
of the ls command. These options should now be specified as -l=v rather than
-lv, for example. The old syntax still works, but support will be dropped in
v0.6.0.

* fdb039 Introduce new syntax for com_ls().

8 years agobuild: Avoid bashism in configure.ac.
Andre Noll [Mon, 14 Sep 2015 18:14:25 +0000 (20:14 +0200)]
build: Avoid bashism in configure.ac.

'==' is not portable. In fact, NetBSD's /bin/sh complains about
this. The fix is trivial.

8 years agobuild: Include flac afh only if libogg is available.
Andre Noll [Mon, 14 Sep 2015 18:08:19 +0000 (20:08 +0200)]
build: Include flac afh only if libogg is available.

In configure.ac we have

AC_DEFUN([NEED_FLAC_OBJECTS], [{
test "$HAVE_OGG" = 'yes' -a "$HAVE_FLAC" = 'yes'
}])

In particular, we do not include the flac audio format handler on
systems where libflac is installed but libogg is not. In afh_common.c,
however, we only check for HAVE_FLAC. This results in a build failure
on those systems.

Fix this by modifying the check in afh_common.c to match the check
in configure.ac.

8 years agocom_add(): Allow paths and afhi to exceed 64K.
Andre Noll [Sun, 6 Sep 2015 13:05:30 +0000 (15:05 +0200)]
com_add(): Allow paths and afhi to exceed 64K.

The add command has the unnecessary limitation that for each audio
file to be added, the length of the path plus the size of serialized
audio format handler info structure (afhi) must not exceed 64K.

An afhi bigger than that is quite possible, given that it contains
the meta information of the file, for example an ID3v2 tag which can
contain almost unlimited amounts of data. If the 64K limit is exceeded,
all kinds of bad things may happen. So this issue definitely needs
to be addressed.

Specifically, save_add_callback_buffer() must be fixed. In this
function we serialize the data to be passed from the add command
handler to its callback. This includes path, afhi and the chunk table,
which are all variable in size. To cope with variable sizes, the
start of the buffer contains fields in which the offsets are stored
at which afhi and chunk table are located, relative to the start of
the serialized buffer. The problem is that the offset fields are only
16 bit wide, allowing for a maximal size of 64K.

This commit makes the offsets 32 bit wide and reorders them a
bit. Also, the CAB_AUDIO_FORMAT_OFFSET identifier is renamed to
CAB_AUDIO_FORMAT_ID_OFFSET.

8 years agoMerge branch 'maint'
Andre Noll [Sun, 6 Sep 2015 14:07:43 +0000 (16:07 +0200)]
Merge branch 'maint'

8 years agoserver.h: Improve documentation of mmd struct.
Andre Noll [Wed, 1 Apr 2015 00:25:04 +0000 (00:25 +0000)]
server.h: Improve documentation of mmd struct.

This adds a sentence to the description of the structure which explains
how the misc_meta_data structure is used for communication betweeen
the server process and the command handlers. The patch also contains
some minor language improvements.

8 years agoFix help text of mvblob commands.
Andre Noll [Thu, 3 Sep 2015 22:00:04 +0000 (00:00 +0200)]
Fix help text of mvblob commands.

No references to @member@ are allowed here since there is only one
help text for all four mvblob commands.

This bug was introduced one year ago in commit aa4b3935 (Overhaul
help texts of server and afs commands).

8 years agormblob: Generate proper BLOB_REMOVE_EVENT.
Andre Noll [Fri, 4 Sep 2015 07:24:12 +0000 (09:24 +0200)]
rmblob: Generate proper BLOB_REMOVE_EVENT.

com_rmblob_callback() of blob.c is responsible for removing blobs from
any of the four blob tables (images, lyrics, moods, playlists). After
a blob has been removed, the function generates an AFS event to tell
the other tables about the removal.

However, the call to afs_event() passes the event identifier
BLOB_RENAME rather than BLOB_REMOVE to the event handlers, which is
clearly incorrect. Fortunately, this does not matter because the only
event handler which cares about blob events is the one in mood.c,
and this handler treats the two events identically. Nevertheless,
it's is a bug that should be fixed.

This bug was introduced eight years ago when event handling was
introduced: commit 02d818d9 (Complete afs event handling).

8 years agocom_addatt(): Return negative on errors
Andre Noll [Thu, 3 Sep 2015 19:35:51 +0000 (21:35 +0200)]
com_addatt(): Return negative on errors

8 years agoIntroduce new syntax for com_ls().
Andre Noll [Wed, 26 Aug 2015 20:24:02 +0000 (22:24 +0200)]
Introduce new syntax for com_ls().

The ls command is the only command that takes one-letter arguments
which immediately follow the option. For example, -lv activates
verbose listing mode. If we ever want to support short option combining
(like in rm -rf) for paraslash commands, the one-letter arguments are
problematic because, in the above example, -lv can also be interpreted
as -l -v.

This commit encourages a different syntax for the -l and -s options
of the ls command while keeping the one-letter options working
for backwards compatibility. The new official way to enable verbose
listing mode is -l=v. This is analogous to how the "stat" and "touch"
commands expect their arguments.

The ls completer and the documentation are also updated according to
the new syntax.

8 years agocom_rm(): In force mode, don't complain if no paths matched.
Andre Noll [Mon, 31 Aug 2015 20:00:17 +0000 (22:00 +0200)]
com_rm(): In force mode, don't complain if no paths matched.

The documentation says that the rm command stays silent and exits
successfully if none of the given patterns matched any path of the
audio file table.

This was true until commit b02b7155 (com_rm(): Return negative on
errors), which effectively made -f a no-op by mistake. Since then
the rm command prints an error message and fails if there is no
match.

This patch restores the documented behaviour.

8 years agosetatt: Do not abort if no pattern is given.
Andre Noll [Sat, 29 Aug 2015 13:10:25 +0000 (15:10 +0200)]
setatt: Do not abort if no pattern is given.

It is an error if no pattern is given to the setatt command.
For example,

setatt foo+ bar-

should result in a syntax error because no file name pattern is given.
The code in aft.c contains an assertion to detect this type of error,
but the afs proccess terminates if the condition of the assert
statement is not fulfilled:

para_server (afs): aft.c:2557: com_setatt_callback: Assertion `p < (char *)query->data + query->size' failed.

This patch turns the assertion into a normal check which merely causes
the command to fail if no pattern was given.

The bug was introduced two years ago in commit 73299ebf (com_setatt():
Allow to specify a file name pattern).

8 years agoaudiod_command.c: Trivial whitespace fix.
Andre Noll [Tue, 18 Aug 2015 18:33:16 +0000 (20:33 +0200)]
audiod_command.c: Trivial whitespace fix.

8 years agoMerge branch 'maint'
Andre Noll [Sun, 30 Aug 2015 11:22:19 +0000 (13:22 +0200)]
Merge branch 'maint'

* maint:
  lsatt: Fix sort order.
  server: Avoid segfault in com_sender().

8 years agolsatt: Fix sort order.
Andre Noll [Fri, 28 Aug 2015 20:33:57 +0000 (22:33 +0200)]
lsatt: Fix sort order.

The -i option had the opposite effect of what the documentation
says. That is, lsatt -i sorted the attribute list by name while the
default was to sort by id. This patch reverts the logic in com_lsatt()
to let the implementation match the documentation.

8 years agoserver: Avoid segfault in com_sender().
Andre Noll [Sat, 22 Aug 2015 14:21:53 +0000 (16:21 +0200)]
server: Avoid segfault in com_sender().

If exactly one argument is given to the sender command, and this
argument is the name of an existing sender, the sender command
segfaults due to the NULL pointer dereference. The problem is an
off-by-one bug in the check for the number of arguments.

This patch makes sure we never dereference argv[2] if it is NULL.

8 years agoMerge branch 'maint'
Andre Noll [Sat, 29 Aug 2015 10:54:58 +0000 (12:54 +0200)]
Merge branch 'maint'

* maint:
  mood: Clear the score table on attribute changes.

8 years agoFix typo in server.c.
Andre Noll [Mon, 10 Aug 2015 20:28:05 +0000 (22:28 +0200)]
Fix typo in server.c.

The full stop needs to be a comma.

8 years agomm.c: Add documentation of mood comparator macros.
Andre Noll [Sun, 14 Jun 2015 13:02:11 +0000 (15:02 +0200)]
mm.c: Add documentation of mood comparator macros.

This makes doxygen a bit happier, and it's good to document the
preprocessor magic anyway.

8 years agooggdec: Add documentation of output size constants.
Andre Noll [Wed, 1 Apr 2015 02:18:29 +0000 (02:18 +0000)]
oggdec: Add documentation of output size constants.

The OGGDEC_MAX_OUTPUT_SIZE and OGGDEC_OUTPUT_CHUNK_SIZE defines in
oggdec_filter.c are undocumented. This commit adds comments for both which
explain the meaning of the two sizes.

8 years agospxdec: Fix typo in comment.
Andre Noll [Sat, 20 Jun 2015 21:10:47 +0000 (23:10 +0200)]
spxdec: Fix typo in comment.

8 years agoaudiod_command.c: Fix typo in comment.
Andre Noll [Sun, 9 Aug 2015 19:10:10 +0000 (21:10 +0200)]
audiod_command.c: Fix typo in comment.

8 years agoaft: Unify handling of hash and path duplicates.
Andre Noll [Mon, 1 Jun 2015 07:36:28 +0000 (09:36 +0200)]
aft: Unify handling of hash and path duplicates.

These are symmetric but were not treated as such. Specifically:

* We ignored fatal errors for finding hash sisters while path
brothers were handled strictly.

* For hash sisters, we had a helper which implicitly special
cased the non-fatal E_OSL_RB_KEY_NOT_FOUND case while the
same check was open-coded for path brothers.

This adds the find_path_brother() helper which is analogous to
find_hash_sister() and fixes up the latter function to perform strict
error checking rather than relying on the implementation detail that
osl_get_row() sets the result pointer to NULL if no entry was found.

8 years agoafs: Provide pbout para_buffer for each callback.
Andre Noll [Wed, 8 Apr 2015 03:35:21 +0000 (03:35 +0000)]
afs: Provide pbout para_buffer for each callback.

Most afs callbacks define a para_buffer to pass output from the
callback to the command handler. Hence the code which defines and
initializes the para_buffer is duplicated many times.

This commit gets rid of the duplication by moving the initialization
to the common call_callback(). The para_buffer becomes part of
struct afs_callback_arg, a pointer to which is passed to every
callback. The buffer is also flushed and freed in call_callback()
so that the callbacks don't need to care about it any more. This also
allows to make flush_and_free_pb() static since only a single caller
in afs.c remains.

This change simplifies the callbacks considerably. The callbacks of the
rm, setatt, lsatt, lsblob and touch commands don't even need their own
"action_data" structure any more since it was only necessary to pass
the para_buffer to the ->action method.

8 years agoafs: Make afs callbacks more flexible.
Andre Noll [Tue, 12 May 2015 07:44:42 +0000 (09:44 +0200)]
afs: Make afs callbacks more flexible.

Currently we pass the information for callbacks (an int and a pointer
to an osl_object) as separate arguments. If additional information
must be passed to some callbacks, every callback must be modified to
match the new prototype, even those which won't use the new argument.

This commit introduces struct afs_callback_arg which contains the two
callback arguments and changes all callbacks to receive a pointer
to such a structure. This is an equivalent transformation with no
visible change in semantics.

With this commit in place it is easy to provide additional information
by simply extending struct afs_callback as appropriate.

8 years agoafs: Rename callback_function to afs_callback.
Andre Noll [Wed, 8 Apr 2015 00:35:41 +0000 (00:35 +0000)]
afs: Rename callback_function to afs_callback.

The new name is more descriptive, and shorter. Pure rename commit,
no real changes.

8 years agocom_check(): Add attribute checking.
Andre Noll [Tue, 7 Apr 2015 21:18:34 +0000 (21:18 +0000)]
com_check(): Add attribute checking.

The afs info stored in the audio file table contains the attribute
bit mask of each audio file. If there is a bit set which does
not correspond to an attribute defined in the attribute table, we
have an inconsistency. This commit adds a check that reports such
inconsistencies.

com_check(), which is part of afs.c, calls the attribute check
callback of attribute.c via the callback mechanism. The callback
computes the logical or of all defined bits and passes this bit mask
to aft_check_attributes() of aft.c to check each audio file against
the mask. Hence two new public functions are required.

8 years agoLet afs_event() return int.
Andre Noll [Thu, 9 Apr 2015 12:51:49 +0000 (12:51 +0000)]
Let afs_event() return int.

It is usually a critical error if an afs event handler returns an
error. Currently we only print a log message an continue in this
case. The callers of afs_event() which trigger the event have no way
to tell that something went wrong, since this function returns void.

By returning int instead of void the callers can abort in the error
case. Most of the callers are afs callbacks. These can propagate the
error code to the command handler process, which will translate the
error code into a string and send it to the client.  All callbacks
are changed in this way.

8 years agoplaylist_check_callback(): Return negative on errors
Andre Noll [Sun, 5 Apr 2015 16:04:20 +0000 (16:04 +0000)]
playlist_check_callback(): Return negative on errors

8 years agomood_check_callback(): Return negative on errors
Andre Noll [Sun, 5 Apr 2015 15:48:57 +0000 (15:48 +0000)]
mood_check_callback(): Return negative on errors

8 years agocom_mvblob(): Return negative on errors
Andre Noll [Sun, 5 Apr 2015 15:34:39 +0000 (15:34 +0000)]
com_mvblob(): Return negative on errors

8 years agocom_addblob(): Return negative on errors
Andre Noll [Sun, 5 Apr 2015 15:18:48 +0000 (15:18 +0000)]
com_addblob(): Return negative on errors

8 years agocom_rmblob(): Return negative on errors, cleanup
Andre Noll [Sun, 5 Apr 2015 14:50:32 +0000 (14:50 +0000)]
com_rmblob(): Return negative on errors, cleanup

8 years agocom_catblob(): Return negative on errors
Andre Noll [Sun, 5 Apr 2015 14:43:59 +0000 (14:43 +0000)]
com_catblob(): Return negative on errors

8 years agocom_lsblob(): Return negative on errors
Andre Noll [Sun, 5 Apr 2015 14:40:44 +0000 (14:40 +0000)]
com_lsblob(): Return negative on errors

8 years agormatt: Cleanup callback.
Andre Noll [Sun, 5 Apr 2015 22:22:04 +0000 (22:22 +0000)]
rmatt: Cleanup callback.

Get rid of struct remove_attribute_action_data, since only the para
buffer is necessary. This changes the code to pass a pointer to the
para buffer itself as the data pointer for ->action() of the pattern
matching loop.

8 years agocom_rmatt(): Return negative on errors
Andre Noll [Sun, 5 Apr 2015 22:21:56 +0000 (22:21 +0000)]
com_rmatt(): Return negative on errors

8 years agocom_mvatt(): Return negative on errors
Andre Noll [Sun, 5 Apr 2015 14:12:42 +0000 (14:12 +0000)]
com_mvatt(): Return negative on errors

8 years agocom_lsatt(): Return negative on errors
Andre Noll [Sun, 5 Apr 2015 13:49:10 +0000 (13:49 +0000)]
com_lsatt(): Return negative on errors

8 years agocom_init(): Return negative on errors
Andre Noll [Sun, 5 Apr 2015 13:40:12 +0000 (13:40 +0000)]
com_init(): Return negative on errors

8 years agocom_check(): Return negative on errors
Andre Noll [Sun, 5 Apr 2015 13:35:13 +0000 (13:35 +0000)]
com_check(): Return negative on errors

8 years agocom_setatt(): Return negative on errors
Andre Noll [Sun, 5 Apr 2015 13:21:51 +0000 (13:21 +0000)]
com_setatt(): Return negative on errors

8 years agocommand_util.bash: Kill make_proto().
Andre Noll [Tue, 13 Jan 2015 23:52:02 +0000 (00:52 +0100)]
command_util.bash: Kill make_proto().

It is always a bad idea to parse C code with a regex in a script. In
addition, it is completely unnecessary in this case.

This commit changes command_util.bash to define, in addition to the
old XXX_CMD_ARRAY, another preprocessor macro XXX__COMMAND_HANDLERS
containing the comma separated list of command handlers without
any type information instead of grepping the source files. A simple
typedef is used to declare all command handlers.

Avoiding all the grep/sed calls reduces the (warm cache) make dep
time by ~10%.

8 years agocom_cpsi(): Return negative on errors
Andre Noll [Sun, 5 Apr 2015 13:19:48 +0000 (13:19 +0000)]
com_cpsi(): Return negative on errors

8 years agoaudiod: Clean up fd closing logic in command handlers.
Andre Noll [Tue, 13 Jan 2015 22:53:28 +0000 (23:53 +0100)]
audiod: Clean up fd closing logic in command handlers.

audiod_command.c contains this comment:

/*
 * command handlers don't close their fd on errors (ret < 0) so that
 * its caller can send an error message. Otherwise (ret >= 0) it's up
 * to each individual command to close the fd if necessary.
 */

This is a somewhat weird rule and this commit gets rid of it. Instead,
from now on the command handlers must not close their file descriptor
and handle_connect() closes it unconditionally.

The grab and stat commands need special treatment, which was the reason
for imposing the above rule. They need to keep the file descriptor open
to send the status items or the grabbed stream to the client. This
patch makes these two handlers create a copy of the descriptor with
dup(2). The new approach is simpler and less error-prone.

8 years agocom_rm(): Return negative on errors
Andre Noll [Sun, 5 Apr 2015 13:12:18 +0000 (13:12 +0000)]
com_rm(): Return negative on errors

8 years agoserver: Remove command pointer from struct command_context.
Andre Noll [Tue, 13 Jan 2015 23:00:41 +0000 (00:00 +0100)]
server: Remove command pointer from struct command_context.

Command handlers should not know about this implementation detail.

This commit also changes parse_sb_command() to not only parse the
command line but to actually run the command in case the caller has
sufficient permissions. The function is renamed to run_command()
to reflect this change.

We use the opportunity to clean up the allocation and freeing of
the command buffer and the argument vector. Both are now freed in
the same function they were allocated, which is considered good
programming practice.

8 years agocom_touch(): Return negative on errors
Andre Noll [Sun, 5 Apr 2015 12:59:22 +0000 (12:59 +0000)]
com_touch(): Return negative on errors

8 years agoserver: Reduce scope of struct server_command.
Andre Noll [Tue, 13 Jan 2015 23:00:05 +0000 (00:00 +0100)]
server: Reduce scope of struct server_command.

This structure is only needed in command.c, so we can make it local
to this file. As structures defined in .c files are not included
in doxygen, the reference to struct server_command in server.h must
be removed.

8 years agocom_add(): Return negative on errors
Andre Noll [Sun, 5 Apr 2015 12:54:14 +0000 (12:54 +0000)]
com_add(): Return negative on errors

8 years agoaudiod: Reduce scope of struct audiod_command.
Andre Noll [Tue, 13 Jan 2015 23:49:52 +0000 (00:49 +0100)]
audiod: Reduce scope of struct audiod_command.

This structure is only used in audiod_command.c, so move the
declaration from audiod.h to audiod_command.c.

8 years agocom_select() callback: Return negative on errors.
Andre Noll [Sun, 5 Apr 2015 00:58:35 +0000 (00:58 +0000)]
com_select() callback: Return negative on errors.

8 years agoaction_if_pattern_matches(): Always count matching rows.
Andre Noll [Sun, 5 Apr 2015 14:07:28 +0000 (14:07 +0000)]
action_if_pattern_matches(): Always count matching rows.

We missed to do this if PM_NO_PATTERN_MATCHES_EVERYTHING is set.

8 years agoafs: Pass sideband error packet on callback failures.
Andre Noll [Sat, 4 Apr 2015 23:20:00 +0000 (23:20 +0000)]
afs: Pass sideband error packet on callback failures.

This changes the afs callback mechanism to honor negative return
values from a callback. We now send a special "callback failure"
sideband packet to the command handler in this case. This packet
contains the (negative) return value of the callback.

The dispatcher for afs callback results reads the error code and passes
it back via the callback request functions to the caller of the command
handler in handle_connect(). The latter already does the right thing:
It translates the error code into a string and sends this string to
the client.

This commit changes the callback of the ls command to return negative
on errors. With the patch applied the command

para_client ls /does/not/exist

now exits with status 1.

Other afs commands will make use of the new feature in subsequent
commits.

8 years agoLet afs callbacks return an error code.
Andre Noll [Sat, 4 Apr 2015 21:45:11 +0000 (21:45 +0000)]
Let afs callbacks return an error code.

It was a design mistake that callbacks have no way to tell whether
they were successful. This commit changes the callback_function
typedef so that callbacks return int instead of void.

Naturally, every callback must be adjusted accordingly. Doing so would
make the patch a bit large, so as a first step we make all callbacks
(except path_brother_callback() and hash_sister_callback() which
are special) return zero. The return value is ignored at the moment,
so the changes of this commit have no effect yet.

8 years agoafs: Introduce flush_and_free_pb().
Andre Noll [Sun, 26 Apr 2015 16:58:22 +0000 (18:58 +0200)]
afs: Introduce flush_and_free_pb().

This kills some code which is duplicated in all command handlers.

8 years agoDo not check return value of WRITE_STATUS_ITEM().
Andre Noll [Thu, 7 May 2015 16:17:54 +0000 (18:17 +0200)]
Do not check return value of WRITE_STATUS_ITEM().

The previous commit removed error checking from para_printf(), but
one instance remains: the WRITE_STATUS_ITEM() macro which also calls
para_printf(). This patch removes the error checking code of this
macro and adjusts all callers.

8 years agoDo not check the return value of para_printf().
Andre Noll [Sun, 5 Apr 2015 02:30:10 +0000 (02:30 +0000)]
Do not check the return value of para_printf().

This function rarely fails, and if it does, we don't care too much. On
the other hand, checking the return value of each call to para_printf()
clutters the code considerably, especially in the error paths where
there is already an error code we have to keep.

This commit simply removes all error checking for para_printf(),
resulting in code which is easier to follow and less error-prone.

8 years agoblob: Simplify stdin_command().
Andre Noll [Sun, 5 Apr 2015 15:04:24 +0000 (15:04 +0000)]
blob: Simplify stdin_command().

This function has only a single caller which passes a pointer to
afs_cb_result_handler() as the result handler. Also the first and
last parameter are both pointers to the command_context structure.

This commit gets rid of the two arguments of the function and updates
the documentation accordingly. Since it is a static function, we
don't need doxygen comments for all arguments.

8 years agoImprove doxygen description of mood.c.
Andre Noll [Sat, 4 Apr 2015 21:34:22 +0000 (21:34 +0000)]
Improve doxygen description of mood.c.

8 years agoplaylist_check_callback(): Remove incorrect documentation.
Andre Noll [Sat, 4 Apr 2015 21:27:41 +0000 (21:27 +0000)]
playlist_check_callback(): Remove incorrect documentation.

The function returns void, so remove the text about its return value.

8 years agoafs.c: Remove outdated comment.
Andre Noll [Sat, 4 Apr 2015 21:02:01 +0000 (21:02 +0000)]
afs.c: Remove outdated comment.

The call_calback() does not write anything to the given fd.

8 years agocom_init: Remove pointless initialization.
Andre Noll [Sat, 4 Apr 2015 20:42:25 +0000 (20:42 +0000)]
com_init: Remove pointless initialization.

8 years agoUnify version command handlers.
Andre Noll [Sat, 4 Apr 2015 20:22:53 +0000 (20:22 +0000)]
Unify version command handlers.

para_audiod's version command supports the -v flag, but the one of
para_server does not and always prints the full version text. This
adds the -v flag to the server command and makes it behave identical
to its counterpart.

8 years agoaudiod: Document and fix command handler return values.
Andre Noll [Sat, 4 Apr 2015 19:51:25 +0000 (19:51 +0000)]
audiod: Document and fix command handler return values.

It has always been the case that a positive return value from a
command handler causes audiod to dump all audiod status items to all
clients. This behaviour is not documented though, and some command
handlers get it wrong. In fact, the help, stat, tasks, grab, version
commands all return positive values although those commands never
change any status items.

This comment documents the meaning of the return value and fixes up
the above command handlers.

8 years agobuild: Unify spelling of commands and directories.
Andre Noll [Wed, 27 Aug 2014 21:33:41 +0000 (23:33 +0200)]
build: Unify spelling of commands and directories.

Always spell commands in upper case and directories in lower case.

This is a first step to auto-generate Makefile.in.

8 years agomood: Clear the score table on attribute changes.
Andre Noll [Sat, 20 Jun 2015 18:26:33 +0000 (20:26 +0200)]
mood: Clear the score table on attribute changes.

Although the comment in mood.c correctly states that the score table
must be cleared and reloaded if an attribute is added, removed or
renamed, the mood event handler misses to clear the score table.
Therefore, after reload_current_mood() has reloaded the mood object,
insertion of admissible files fails with

afs_event: table moods, event 0: key already exists in rbtree

This results in an unmodified set of admissible files.

The only other caller of reload_current_mood() clears the score table
right before the function call, so the easiest fix is to move the
call to clear_score_table() into reload_current_mood().

8 years agoclient: Add details to --key-file option.
Andre Noll [Mon, 30 Mar 2015 21:39:13 +0000 (21:39 +0000)]
client: Add details to --key-file option.

The new text lists the locations where para_clients looks for
private keys.

8 years agoclient.m4: Adjust coding style of ggo options.
Andre Noll [Mon, 30 Mar 2015 21:30:02 +0000 (21:30 +0000)]
client.m4: Adjust coding style of ggo options.

All other commands use one line per directive of each option, which
improves the readability of the ggo file. This commit changes the
.m4 file for the client options to match this style of specifying
the gengetopt options.

No real changes.

8 years agodaemon: Improve daemon_log_welcome().
Andre Noll [Mon, 15 Dec 2014 19:20:44 +0000 (20:20 +0100)]
daemon: Improve daemon_log_welcome().

This function is used within para_server and para_audiod. Adding the
"para_" prefix in daemon_log_welcome() rather than its callers avoids
the duplication. Also rename the "whoami" parameter to "name" and add
documentation for it. Finally, the build date is not really important
in the log message, so simply remove it.

8 years agosetatt: Print meaningful error message.
Andre Noll [Mon, 19 Jan 2015 19:39:21 +0000 (20:39 +0100)]
setatt: Print meaningful error message.

An attempt to set or unset a non-existing attribute currently results in

key not found in rbtree

which is a bit cryptic. This commit adds another message that clarifies
what went wrong.

8 years agovss: Perform stream change actions in vss_post_select().
Andre Noll [Sun, 21 Dec 2014 19:05:47 +0000 (19:05 +0000)]
vss: Perform stream change actions in vss_post_select().

The pre_select methods should only set the scheduler timeouts and
manipulate fd sets.

Clean up the documentation a bit while at it.

8 years agoaft.c: Remove condition which is always false.
Andre Noll [Mon, 22 Dec 2014 01:15:19 +0000 (01:15 +0000)]
aft.c: Remove condition which is always false.

aft_open() returns early if ret is non-negative, so ret is known to
be negative at this point.

Upgrade the log message severity on open failure from INFO to NOTICE
while at it.

8 years agoaft.c: Silence noisy warnings in com_add().
Andre Noll [Wed, 24 Dec 2014 02:55:52 +0000 (02:55 +0000)]
aft.c: Silence noisy warnings in com_add().

If the -a option to com_add() is not given, we ignore paths for which
guess_audio_format() returns negative. Currently the add command sends
a warning to the client for each skipped file, which may result in
very verbose output. This commit silences the warning.

8 years agoweb: fix htaccess description of snapshot tarball.
Andre Noll [Sun, 3 May 2015 10:51:13 +0000 (12:51 +0200)]
web: fix htaccess description of snapshot tarball.

Without this, the snapshot tarball file on the download web page is
annotated as "release tarball" rather than "current master snapshot".

Fix this by adding two additional patterns to the .htaccess file.

8 years agobuild: Add -Wunused-macros to CPPFLAGS on Linux.
Andre Noll [Wed, 1 Apr 2015 02:50:27 +0000 (02:50 +0000)]
build: Add -Wunused-macros to CPPFLAGS on Linux.

We already specify -Wunused which combines all -Wunused options but
does not activate the -Wunused-macros cpp warning.

8 years agoMerge branch 'maint'
Andre Noll [Sat, 30 May 2015 09:54:47 +0000 (11:54 +0200)]
Merge branch 'maint'