paraslash.git
11 years agocommand_util: Fix make dependencies for *_command_list.h.
Andre Noll [Mon, 9 Apr 2012 23:43:38 +0000 (01:43 +0200)]
command_util: Fix make dependencies for *_command_list.h.

The *_command_list.h files depend on the .c files listed in the SF
header line of the .cmd command file because command_util.sh gets
the declaration of the command handlers from these files.

Unfortunately, make does not know about these dependencies, so we
have to mention them in the Makefile as well.

11 years agoMake (most) command handlers static.
Andre Noll [Sat, 7 Apr 2012 06:30:27 +0000 (08:30 +0200)]
Make (most) command handlers static.

Now that the array of commands for para_server and para_audiod are
read from a header file, the command handlers can be made static if
they are in the same file that defines the command array.

This patch makes all such handlers static and tweaks command_util.sh
to recognize also static functions.

11 years agocommand_util: Remove code for generating .c files.
Andre Noll [Thu, 28 Jun 2012 02:45:09 +0000 (04:45 +0200)]
command_util: Remove code for generating .c files.

Now that the *_command_list.c files are no longer needed we may remove
this mode from command_util.sh. This makes quite a few headers of
the .cmd files unused, so these can be removed as well.

11 years agocommand_util: Write array definition in header mode.
Andre Noll [Thu, 28 Jun 2012 02:23:32 +0000 (04:23 +0200)]
command_util: Write array definition in header mode.

This modifies command_util.sh so that when it is called in header mode,
it also defines a macro for the array of all commands. command.c and
audiod_command.c are changed to use the new preprocessor macro.

This allows to get rid of the *command_list.c files completely. We may
hence remove these files from the various lists of errlist objects
in configure.ac. and from error.h. A subsequent patch will clean up
the parts that have become unused by this commit.

11 years agocommand_util: Output array members with backslashes.
Andre Noll [Thu, 28 Jun 2012 01:08:00 +0000 (03:08 +0200)]
command_util: Output array members with backslashes.

This makes sure that the generated code for the definition of the
command array has backslashes at the end of each line.  Currently
this does not matter because make_array_member() is only called when
generating C code where new lines don't matter.

However, ending each line with a backslash allows to use the same
output for a cpp #define which can go into the header file.

11 years agocommand_util: Avoid empty output lines.
Andre Noll [Thu, 28 Jun 2012 00:51:28 +0000 (02:51 +0200)]
command_util: Avoid empty output lines.

Additional empty output lines do not matter for the generated C code or
the function declarations in the header files.  However, a subsequent
commit changes command_util.sh to  generate a preprocessor macro for
the header file, and there we can not afford empty lines unless they
end with a backslash to continue the line.

This patch makes sure that no superfluous newlines are printed in
the output.

11 years agocommand_util: replace dump_xxx() by make_xxx().
Andre Noll [Wed, 27 Jun 2012 23:18:23 +0000 (01:18 +0200)]
command_util: replace dump_xxx() by make_xxx().

This replace dump_array_member(), dump_completion() and dump_proto()
by their make_xxx counterpart.

This allows to iterate over all commands twice.

11 years agocommand_util: Kill HC and CC header lines.
Andre Noll [Wed, 27 Jun 2012 22:57:52 +0000 (00:57 +0200)]
command_util: Kill HC and CC header lines.

There is no point in pretty-printing the generated files. Nobody reads
these files anyway and doxygen ignores them as well.

11 years agosideband: Fix use after free bug.
Andre Noll [Fri, 29 Jun 2012 14:28:11 +0000 (16:28 +0200)]
sideband: Fix use after free bug.

Commit 32ffc06c (Pass command exit status via sideband to client.)
made para_server's command handler send the exit status of the command
to the client as an RC4-encrypted sideband packet.

However, the encryption key has already been freed when this packet
is sent. This may result in client errors about invalid or unexpected
sideband designators, but these errors occurred rather infrequently,
which makes this bug hard to trigger. Presumably the freed memory is
usually not being reused since the command handler is going to dye
anyway after the packet is sent.

This patch fixes the bug by deferring to free the crypto keys until
the exit code has been sent.

11 years agoMerge branch 't/decoder_fixes'
Andre Noll [Tue, 26 Jun 2012 20:07:55 +0000 (22:07 +0200)]
Merge branch 't/decoder_fixes'

97dbfe wmadec: Only decode one superframe at a time.
d6e017 flacdec: Only process a single flac audio frame.
1e1968 flacdec_close(): Be liberal in what you accept.
3f96f9 oggdec: Fix EOF handling on repositioning.
c7e2f7 oggdec: Realloc buffer to save memory.
634e75 oggdec: Do not decode more than necessary.

These changes are well tested and there are no known problems.

11 years agoMerge branch 't/sb'
Andre Noll [Sun, 24 Jun 2012 18:53:23 +0000 (20:53 +0200)]
Merge branch 't/sb'

Was cooking in next for several weeks with no problems so far.

fd864c Fix documentation of pass_buffer_as_shm().
32ffc0 Pass command exit status via sideband to client.
7dc1b5 Send command output via sideband.
0229d7 Introduce send_strerror().
d5a9e8 Simplify pass_buffer_as_shm().
3667d7 command.c: Improve get_status().
aa3fe7 Pass command via sideband.
9c2a26 Use sideband also for "proceed" handshake.
4744d9 Use sideband also for challenge response.
fa9e0e Send and receive challenge via sideband.
2830b9 Add sideband implementation.
e151db Implement client-server feature negotiation.
e31d5d afs: Rename sc_send_result() to afs_cb_result_handler().
68cb0a Introduce afs_max_size_handler_data and afs_max_size_handler().
d04b83 client: Improve error diagnostics.

11 years agoFix documentation of pass_buffer_as_shm().
Andre Noll [Mon, 18 Jun 2012 06:15:18 +0000 (08:15 +0200)]
Fix documentation of pass_buffer_as_shm().

Commit d5a9e8 renamed the argument "fd_ptr" to "fd" but missed
to rename this variable also in the long description.

11 years agowma: Doxify some comments.
Andre Noll [Fri, 1 Jun 2012 09:33:39 +0000 (11:33 +0200)]
wma: Doxify some comments.

struct coef_vlc_table->levels and struct getbit_context had undoxified
comments.

11 years agowma: Trivial whitespace fix.
Andre Noll [Fri, 1 Jun 2012 09:29:41 +0000 (11:29 +0200)]
wma: Trivial whitespace fix.

11 years agoAdd documentation of two more fields of struct private_wmadec_data.
Andre Noll [Fri, 1 Jun 2012 08:48:17 +0000 (10:48 +0200)]
Add documentation of two more fields of struct private_wmadec_data.

11 years agoMakefile: Warn for unused macros only on Linux.
Andre Noll [Mon, 4 Jun 2012 08:29:42 +0000 (10:29 +0200)]
Makefile: Warn for unused macros only on Linux.

We need these macros at several places, but each of them causes
a compilier warning on FreeBSD and NetBSD where these macros are
not used at all.

This patch moves the -Wunused-macros option to the Linux-only
section.

11 years agowmadec: Only decode one superframe at a time.
Andre Noll [Sat, 7 Apr 2012 01:02:33 +0000 (03:02 +0200)]
wmadec: Only decode one superframe at a time.

Similar to the previous commit for the flac decoder, this commit
removes the loop in wmadec_post_select(). This gives other tasks a
chance to run and simplifies the code.

Also, if the buffer was not filled completely, it is truncated to
the proper size to reduce memory usage of the decoder.

11 years agoflacdec: Only process a single flac audio frame.
Andre Noll [Sat, 7 Apr 2012 01:02:02 +0000 (03:02 +0200)]
flacdec: Only process a single flac audio frame.

This removes the loop in flacdec_post_select() which makes the
flac decoder decode as much as possible, but may starve other
tasks. Removing the loop gives other tasks a chance to run, thereby
avoiding buffer underruns. It simplifies the code too.

Also, resetting the number of unconsumed input bytes to zero at
each scheduler iteration has always been a mistake, so remove it.

11 years agoflacdec_close(): Be liberal in what you accept.
Andre Noll [Tue, 10 Apr 2012 05:38:20 +0000 (07:38 +0200)]
flacdec_close(): Be liberal in what you accept.

Functions like close() which terminate an instance of some subsystem
should always be idempotent, i.e. when calling such a function twice
with the same argument, the second call should be a noop.

However, flacdec_close() violates this rule because it dereferences
its private pointer unconditionally. This patch makes the function
idempotent.

11 years agooggdec: Fix EOF handling on repositioning.
Andre Noll [Sun, 3 Jun 2012 09:59:42 +0000 (11:59 +0200)]
oggdec: Fix EOF handling on repositioning.

If playback starts near the end of the file, it might happen that (a)
the read callback consumes all the remaining part in one go (so the
node status is BTR_EOF) and (b) the last ov_read() returned OV_HOLE.

(b) makes the decoder wait for more data which will never arrive due to
(a). Currently we error out without playing the last part of the file.

This patch makes ogg_post_select() return an error only if additionally
fn->min_iqs == 0, which indicates we did not hit OV_HOLE during the
last ov_read().

11 years agooggdec: Realloc buffer to save memory.
Andre Noll [Sun, 13 May 2012 19:54:46 +0000 (21:54 +0200)]
oggdec: Realloc buffer to save memory.

The ogg/vorbis decoder always allocates 32K buffers for the decoded
output data. If the buffer could not be filled completely due to
insufficient input data being available, the partially filled 32K
buffer is added to the output buffer tree.

This patch truncates (reallocates) the buffer if this has happened,
thereby reducing the memory footprint of the decoder.

11 years agoaudiod: Check pointers passed to btr_get_node_start().
Andre Noll [Sat, 7 Apr 2012 22:25:42 +0000 (00:25 +0200)]
audiod: Check pointers passed to btr_get_node_start().

If the receiver or writer buffer tree node pointer is NULL, we'll segfault due
to a a NULL pointer dereference in btr_get_node_start(). Although this might
not be triggerable, it does not hurt to be defensive here.

11 years agooggdec: Do not decode more than necessary.
Andre Noll [Wed, 11 Apr 2012 21:16:00 +0000 (23:16 +0200)]
oggdec: Do not decode more than necessary.

Currently the ogg vorbis decoder decodes at least one buffer per
scheduler iteration and checks only then if its output queue is already
full. This is bad for several reasons, increased memory footprint is
one of them.

This patch adds an additional check at the beginning of
ogg_post_select() that causes the function to return early if the
output queue is full.

11 years agooss: Add proper error message on init.
Andre Noll [Wed, 16 May 2012 13:21:10 +0000 (15:21 +0200)]
oss: Add proper error message on init.

If the device node of the sound device (/dev/dsp) does not exist,
we currently fail with a "no such file or directory" error message
without mentioning the name of the device. This adds a log message
which clarifies what went wrong.

11 years agoPass command exit status via sideband to client.
Andre Noll [Sun, 26 Feb 2012 13:14:18 +0000 (14:14 +0100)]
Pass command exit status via sideband to client.

Currently the only way for the client side to tell whether a command
failed is to parse the command output. This patch changes command.c to
send an empty sideband packet at command termination. If the command
succeeded, the sideband designator is set to SBD_EXIT__SUCCESS,
otherwise it is SBD_EXIT__FAILURE.

The client checks for these sideband packets and terminates with
EXIT_FAILURE if it received the SBD_EXIT__FAILURE packet.

11 years agoSend command output via sideband.
Andre Noll [Sat, 5 May 2012 10:11:54 +0000 (12:11 +0200)]
Send command output via sideband.

The next step towards sideband connections is to send the output of
each command as a sideband packet. To this aim, afs_cb_result_handler(),
pass_buffer_as_shm() and the callback_result_handler typedef are modified
to receive an additional "band" parameter.

For regular command output the value of this parameter is SBD_OUTPUT,
the sideband designator for normal output. The client code is patched
to add the contents of received SBD_OUTPUT sidband packets to the
buffer tree for the normal ouput.

However, log messages, which are only written to the log output
of the server at the moment, may also passed to the client via the
SBD_XXX_LOG designators, where XXX is the name of one of the usual
log levels for para_log().

The patch contains quite a few changes of the form

if (use_sideband)
do_new_stuff()
else
do_it_as_before()

which is a bit ugly, but we may remove the old method in 0.5.0,
which will support only sideband connections.

11 years agoIntroduce send_strerror().
Andre Noll [Sat, 5 May 2012 10:10:08 +0000 (12:10 +0200)]
Introduce send_strerror().

There are many places in various command handlers where the error path
contains code like

sc_send_va_buffer(&cc->scc, "%s\n", para_strerror(-ret));

to send an error message to the client.  This patch simplifies all
these places by introducing the public function send_strerror() which
takes a command context structure and an error code, and executes the
above statement. All places where this was open-coded are changed
to call the new function instead.

11 years agoSimplify pass_buffer_as_shm().
Andre Noll [Sat, 5 May 2012 09:18:58 +0000 (11:18 +0200)]
Simplify pass_buffer_as_shm().

Currently, this function takes a pointer to the file descriptor. For
no good reason, we may as well pass the fd directly.

This patch also adds a comment about the callers of this function.

11 years agocommand.c: Improve get_status().
Andre Noll [Sat, 5 May 2012 09:04:23 +0000 (11:04 +0200)]
command.c: Improve get_status().

We know exactly the number of bytes in the result buffer. By returning
this information, the caller can use sc_send_bin_buffer() instead of
sc_send_buffer(), which safes one strlen() call.

11 years agoPass command via sideband.
Andre Noll [Thu, 5 Jan 2012 16:19:49 +0000 (17:19 +0100)]
Pass command via sideband.

This makes para_cclient pass the paraslash command and its arguments
as a sideband packet to para_server if possible.

For sideband connections the command and its arguments are stored as
NULL-terminated strings. This is better than separating by newlines
(as we do for non-sideband connections) because it allows for arguments
containing newlines.

Suitable helpers for creating and parsing a buffer of NULL-terminated
strings, are provided in client_common.c and command.c, respectively.

No change for non-sideband connections.

11 years agoUse sideband also for "proceed" handshake.
Andre Noll [Thu, 22 Dec 2011 22:24:54 +0000 (23:24 +0100)]
Use sideband also for "proceed" handshake.

This adds sideband-aware code for the next step of the connection
handshake. If sideband connections are supported at both ends,
the server side sends an empty sideband packet with designator
SBD_PROCEED if the client was authenticated successfully.  When the
client receives this packet, it enters the CL_RECEIVED_PROCEED state,
just as with non-sideband connections.

11 years agoUse sideband also for challenge response.
Andre Noll [Wed, 4 Jan 2012 20:47:55 +0000 (21:47 +0100)]
Use sideband also for challenge response.

This changes server and client to exchange the challenge response
as a sideband packet if both ends support sideband connections. The
SBD_CHALLENGE_RESPONSE designator is used for this purpose. On the
client side the changes are less intrusive due to an additional
cleanup of the state handling.

During connection setup the client's idea of the state of
the connection is monitored in the ->status variable of struct
client_task. If the client is in the CL_SENT_AUTH state, it receives
the challenge and sends the hash of the decrypted challenge back to the
server. Either operation may fail, and it seems cleaner to separate
the two. So this patch adds the new state CL_RECEIVED_CHALLENGE. The
clients enters this state once it decrypted the received challenge.

11 years agoSend and receive challenge via sideband.
Andre Noll [Wed, 4 Jan 2012 20:46:11 +0000 (21:46 +0100)]
Send and receive challenge via sideband.

If both server and client support sideband connections, the challenge
is now sent as a sideband packet using the dedicated SBD_CHALLENGE
designator.

11 years agoAdd sideband implementation.
Andre Noll [Sun, 18 Dec 2011 19:18:49 +0000 (20:18 +0100)]
Add sideband implementation.

This adds the new source files sideband.[ch] to the repository and
links the corresponding object file into para_server, para_audiod
and para_client.

The sideband API enables the command handlers of para_server to send a
multiplexed output stream. The client side (para_client or para_audiod)
demultiplex the received stream afterwards.

The design is as simple as it can be: Each data buffer is preceded
by a 5-byte header containing the length and the band designator,
a one-byte number which specifies the type of the data which follows.

The server-side and the client-side implement their own variant of the
send_sb() and recv_sb() functions for sending and receiving sideband
packets. Two implementations are necessary because the underlying
file descriptor is blocking on the server side (command handlers of
para_server) while it is non-blocking on the client side (para_client
and para_audiod).

The sideband API allows to optionally filter all data (including the
sideband header) through an arbitrary transformation. This patch adds
a suitable transformation as a new public function performs RC4 to
the crypto API.

To keep the patch within reasonable size, this commit does not contain
any users of the new sideband API yet. Subsequent commits will teach
the authentication handshake code and the command handlers to send
and receive data as sideband packets.

11 years agoImplement client-server feature negotiation.
Andre Noll [Sat, 3 Dec 2011 13:42:12 +0000 (14:42 +0100)]
Implement client-server feature negotiation.

The server announces a list of supported features and the client may
request any subset of features.

The only supported feature is "sideband". It has no effect at the
moment but this will change in subsequent patches.

TODO: Documentation, remove "foo" feature.

11 years agoafs: Rename sc_send_result() to afs_cb_result_handler().
Andre Noll [Mon, 16 Jan 2012 21:41:06 +0000 (22:41 +0100)]
afs: Rename sc_send_result() to afs_cb_result_handler().

The old name was rather confusing because the "sc" prefix indicates
that this function is part of the stream cipher crypto API, which is
not the case.

11 years agoIntroduce afs_max_size_handler_data and afs_max_size_handler().
Andre Noll [Mon, 16 Jan 2012 21:14:41 +0000 (22:14 +0100)]
Introduce afs_max_size_handler_data and afs_max_size_handler().

Whenever the maximal size of a para buffer is reached, para_printf()
calls the specified max size handler. This handler takes, in addition
to the actual buffer and its size, a void * context pointer.  Currently
all commands simply pass a pointer to the underlying file descriptor
here since this is the only context the handler needs to know about.

However, this is going to change since with sideband connections the
handler needs to know also the sideband designator.

To meet this future need, this patch introduces struct
afs_max_size_handler_data, which consists of the file descriptor only
at the moment, as well as a simple wrapper for pass_buffer_as_shm().

11 years agoclient: Improve error diagnostics.
Andre Noll [Sun, 26 Feb 2012 11:53:43 +0000 (12:53 +0100)]
client: Improve error diagnostics.

If an error occurs in the post_select() method of the client task,
the scheduler removes this task from the task list and then returns
zero to indicate that the task list has become empty.

Currently, client.c looks only at the return value of schedule() and
therefore returns success in this case.  This patch makes client.c
additionally check the task error state of the client task and
prints an error message if it was negative and different from an
EOF condition.

11 years agoMerge branch 't/remove_no_default_filters'
Andre Noll [Sat, 5 May 2012 10:50:37 +0000 (12:50 +0200)]
Merge branch 't/remove_no_default_filters'

We have printed a warning for several month if this option was
still used. This should be enough.

11 years agoRemove --no_default_filters option.
Andre Noll [Sun, 24 Jun 2012 17:26:16 +0000 (19:26 +0200)]
Remove --no_default_filters option.

This option was deprecated in paraslash-0.4.10 and can go away now.

11 years agoMerge branch 't/doc'
Andre Noll [Sat, 5 May 2012 10:48:27 +0000 (12:48 +0200)]
Merge branch 't/doc'

11 years agodaemon.c: daemon_set_default_log_colors() returns void.
Andre Noll [Tue, 24 Apr 2012 06:43:32 +0000 (08:43 +0200)]
daemon.c: daemon_set_default_log_colors() returns void.

Remove the incorrect documentation of the (non existing) return
value.

11 years agoClient: Simplify signal handling.
Andre Noll [Mon, 9 Apr 2012 19:07:23 +0000 (21:07 +0200)]
Client: Simplify signal handling.

There is no point in having a sighandler which just calls another one.
This patch makes i9e_signal_dispatch() the handler for SIGINT and
removes the pointless wrapper.

11 years agorecv.h: Fix typo in documentation.
Andre Noll [Sat, 14 Apr 2012 22:04:29 +0000 (00:04 +0200)]
recv.h: Fix typo in documentation.

The sentence contains the word "the" twice.

11 years agoFix a typo in the documentation of struct ggo_help.
Andre Noll [Sat, 14 Apr 2012 21:59:52 +0000 (23:59 +0200)]
Fix a typo in the documentation of struct ggo_help.

s/exexutables/executables.

11 years agoAdd some more starting points to main page.
Andre Noll [Sat, 14 Apr 2012 21:28:57 +0000 (23:28 +0200)]
Add some more starting points to main page.

This adds links to struct writer_node, the flacdec filter and to
interactive.c to the main doxygen web page. It also fixes a typo.

11 years agoAdd some missing documentation.
Andre Noll [Sat, 14 Apr 2012 21:17:03 +0000 (23:17 +0200)]
Add some missing documentation.

This makes doxygen a bit happier.

12 years agobtr_slice_out_node(): Set parent to NULL.
Andre Noll [Sat, 7 Apr 2012 22:30:23 +0000 (00:30 +0200)]
btr_slice_out_node(): Set parent to NULL.

Without this, a subsequent btr_remove_node() on the spliced
out node could segfault.

12 years agointeractive: Init task status.
Andre Noll [Sat, 7 Apr 2012 18:04:05 +0000 (20:04 +0200)]
interactive: Init task status.

The log messages of the scheduler print the task status, so all
tasks should fill out the task.status field. The interactive task
missed to to so. Fix is trivial.

12 years agoIntroduce clear_afhi().
Andre Noll [Tue, 23 Aug 2011 17:41:27 +0000 (19:41 +0200)]
Introduce clear_afhi().

aft.c and afh.c contain identical code to free all members of an
instance of struct afh_info. This commit introduces the public
function clear_afhi(), and patches both aft.c and afh.c to call the
new function.

12 years agohttp_recv: Trivial cleanup.
Andre Noll [Wed, 24 Aug 2011 12:38:39 +0000 (14:38 +0200)]
http_recv: Trivial cleanup.

This variant to specify the size of an allocation is to be preferred
because (a) it's shorter, and (b) it breaks at compile time if "tmp" is
renamed but the argument to sizeof() was not updated accordingly.

12 years agoDefine status item list in afh_common.c.
Andre Noll [Thu, 5 Apr 2012 23:18:23 +0000 (01:18 +0200)]
Define status item list in afh_common.c.

The status_item_list array is needed for the audio format handler info
struct (afhi), so all executables which contain afh_common.o need it.
Currently, afh.c and command.c define their own instance for para_afh
and para_server respectively.

Moving the definition of the array to afc.c saves one instance. No
big deal.

12 years agobtr_remove_node(): Loglevel adjustments.
Andre Noll [Thu, 5 Apr 2012 23:18:23 +0000 (01:18 +0200)]
btr_remove_node(): Loglevel adjustments.

These two log messages got a bit too noisy. Degrade loglevel to info.

12 years agointeractive: Set stderr to nonbuffered mode.
Andre Noll [Thu, 5 Apr 2012 23:18:23 +0000 (01:18 +0200)]
interactive: Set stderr to nonbuffered mode.

fdopen() might return a stream which is fully buffered or line buffered.
We want unbuffered unconditionally, so explicitly set the stream to
unbuffered mode.

12 years agointeractive: Remove pointless return statement.
Andre Noll [Thu, 5 Apr 2012 23:18:23 +0000 (01:18 +0200)]
interactive: Remove pointless return statement.

i9e_pre_select() returns void anyway.

12 years agonew codename, reset version to git
Andre Noll [Fri, 30 Mar 2012 14:18:14 +0000 (16:18 +0200)]
new codename, reset version to git

12 years agothe paraslash-0.4.10 release tarball
Andre Noll [Fri, 30 Mar 2012 14:10:28 +0000 (16:10 +0200)]
the paraslash-0.4.10 release tarball

12 years agoparaslash 0.4.10 v0.4.10
Andre Noll [Fri, 30 Mar 2012 14:07:52 +0000 (16:07 +0200)]
paraslash 0.4.10

12 years agoMerge branch 't/gui_improvements'
Andre Noll [Thu, 29 Mar 2012 17:58:04 +0000 (19:58 +0200)]
Merge branch 't/gui_improvements'

      gui: Make some functions return void.
      gui: Rename client_cmd_cmdline() to para_cmd().
      gui: Check return value of para_exec_cmdline_pid().
      gui: Also display command's stderr output.

12 years agoMerge branch 't/configure_fix'
Andre Noll [Sun, 25 Mar 2012 18:32:23 +0000 (20:32 +0200)]
Merge branch 't/configure_fix'

      configure: Fix warning message.

12 years agoMerge branch 't/id3_conf'
Andre Noll [Sun, 25 Mar 2012 15:53:07 +0000 (17:53 +0200)]
Merge branch 't/id3_conf'

configure: Add --with-id3tag-headers/libs.
Link against libz if compiling with libid3tag support.

12 years agomood.c: Silence gcc warning.
Andre Noll [Sun, 25 Mar 2012 12:51:25 +0000 (14:51 +0200)]
mood.c: Silence gcc warning.

The newly released gcc-4.7.0 complains about "m" being used
uninitialized in change_current_mood(). gcc is wrong, but this is
not obvious to see: In change_current_mood(), "m" is only going to
be used if load_mood() returns non-negative. This happens only on
success, when load_mood() returns 1. In this case "m" was previously
set to mlpd.m which was initialized to NULL at the top of load_mood()
and later set to the newly allocated mood structure.

This patch makes it easier for gcc by initializing "m" to NULL
upfront. This causes the warning to go away.

12 years agoLink against libz if compiling with libid3tag support.
Andre Noll [Tue, 13 Mar 2012 15:37:36 +0000 (16:37 +0100)]
Link against libz if compiling with libid3tag support.

libid3tag depends on libz. On Linux, libz is automatically linked to
para_server and para_afh but at least on FreeBSD compilation fails
due to undefined references to "uncompress" and "compress2".

This patch explicitly adds -lz to $server_ld_flags and $afh_ldflags
if libid3tag was detected.

12 years agoconfigure: Add --with-id3tag-headers/libs.
Andre Noll [Wed, 7 Mar 2012 17:16:52 +0000 (18:16 +0100)]
configure: Add --with-id3tag-headers/libs.

If libid3tag was intalled at a non-standard location, the configure
script would not find it. Currently there is no way to tell configure
to look for libid3tag elsewhere.

This adds two new options, --with-id3tag-headers and --with-id3tag-libs,
to overcome this shortcoming.

12 years agogui: Also display command's stderr output.
Andre Noll [Tue, 13 Mar 2012 21:17:18 +0000 (22:17 +0100)]
gui: Also display command's stderr output.

Currently, both para_cmd() and display_cmd() redirect stderr to
/dev/null, so any error messages of the command being executed do
not make it to the bottom window. This is inconvenient at times,
and makes debugging hard.

This patch prints the stderr output in the bottom window using
COLOR_ERRMSG.

As for the implementation, the global command_pipe integer
variable becomes an integer array of length two which contains
the two file descriptors for stdout and stderr. We also need two
buffers in do_select(), so command_buf becomes a two-dimensional
array. do_select() now has to monitor two file descriptors per command
and it returns only after the peer has closed both fds.

12 years agogui: Check return value of para_exec_cmdline_pid().
Andre Noll [Tue, 13 Mar 2012 21:30:34 +0000 (22:30 +0100)]
gui: Check return value of para_exec_cmdline_pid().

external_cmd() calls this function to execute the given command.
However, as para_exec_cmdline_pid() may fail, e.g. because the
underlying call to fork() failed due to hitting the RLIMIT_NPROC
resource limit, we must check the return value. The other two command
dispatchers got this right, but external_cmd() did not.

12 years agogui: Rename client_cmd_cmdline() to para_cmd().
Andre Noll [Tue, 13 Mar 2012 21:19:25 +0000 (22:19 +0100)]
gui: Rename client_cmd_cmdline() to para_cmd().

The new name is shorter to type and it matches the naming convention
of the other command dispatchers, external_cmd() and display_cmd().

12 years agogui: Make some functions return void.
Andre Noll [Tue, 13 Mar 2012 20:11:16 +0000 (21:11 +0100)]
gui: Make some functions return void.

All callers of these functions ignore the return value, so get rid
of it.

12 years agoconfigure: Fix warning message.
Andre Noll [Wed, 7 Mar 2012 16:01:05 +0000 (17:01 +0100)]
configure: Fix warning message.

If libogg is installed but speex is not, configure prints "vorbis/speex
require ogg", which is a rather bad explanation of the problem at hand.

This simple patch should fix it.

12 years agoMerge branch 't/t0004_fix'
Andre Noll [Sun, 18 Mar 2012 20:02:33 +0000 (21:02 +0100)]
Merge branch 't/t0004_fix'

This topic has been cooking for some weeks now and was tested
successfully on all supported operating systems.

12 years agomanual: Explain how to compile from git.
Andre Noll [Thu, 15 Mar 2012 12:01:03 +0000 (13:01 +0100)]
manual: Explain how to compile from git.

Mention that autogen.sh should be executed first when compiling from git or
gitweb snapshots.

12 years agodoc: Avoid \0 in comments.
Andre Noll [Wed, 14 Mar 2012 13:41:50 +0000 (14:41 +0100)]
doc: Avoid \0 in comments.

Doxygen treats \0 as a command, spits out a warning and produces
no output.

12 years agoMerge branch 't/audioc_cleanups'
Andre Noll [Sun, 4 Mar 2012 21:40:27 +0000 (22:40 +0100)]
Merge branch 't/audioc_cleanups'

Has been cooking for long enough.

12 years agoFix t0004-server.
Andre Noll [Sun, 5 Feb 2012 13:39:37 +0000 (14:39 +0100)]
Fix t0004-server.

Currently we try to generate an ssh key and start para_server
even if the ssh-keygen executable was not found or para_server
was not built.

Fix this by starting para_server only of both executables exist.

12 years agoconfigure.ac: Do not include server-only objects unconditionally.
Andre Noll [Sun, 5 Feb 2012 13:18:11 +0000 (14:18 +0100)]
configure.ac: Do not include server-only objects unconditionally.

We included the list of server-only objects in $all_errlist_objs
even if para_server is not going to be built (because libosl was
not found). This confuses t0004-server which bases the decision
whether it should skip its tests on whether server.o is contained
in $all_errlist_objs.

So add these objects to $all_errlist_objs only if libosl is detected.

12 years agoconfigure.ac: Remove fec from objects for para_recv.
Andre Noll [Sun, 5 Feb 2012 13:10:05 +0000 (14:10 +0100)]
configure.ac: Remove fec from objects for para_recv.

para_recv does not need this object.

12 years agoconfigure.ac: Kill $gui_other_objs.
Andre Noll [Sun, 5 Feb 2012 12:36:49 +0000 (13:36 +0100)]
configure.ac: Kill $gui_other_objs.

Just treat these two objects as ordinary objects which do
not define own error codes.

12 years agoconfigure.ac: Try to link against libogg and lm if necessary.
Andre Noll [Mon, 27 Feb 2012 12:44:26 +0000 (13:44 +0100)]
configure.ac: Try to link against libogg and lm if necessary.

This seems to be necessary on FreeBSD, and does hopefully not hurt
on other systems.

12 years agoMerge branch 't/mmap_sanity'
Andre Noll [Sun, 26 Feb 2012 13:23:59 +0000 (14:23 +0100)]
Merge branch 't/mmap_sanity'

Conflicts:
error.h

12 years agoMerge branch 't/write_consolidation'
Andre Noll [Sat, 18 Feb 2012 12:21:38 +0000 (13:21 +0100)]
Merge branch 't/write_consolidation'

This topic branch has been cooking in next for two weeks with no
problems.

12 years agoaudioc: Improve documentation of main().
Andre Noll [Fri, 13 Jan 2012 22:59:12 +0000 (23:59 +0100)]
audioc: Improve documentation of main().

12 years agoMerge branch 't/deprecate_no_default_filters'
Andre Noll [Sun, 12 Feb 2012 03:14:57 +0000 (04:14 +0100)]
Merge branch 't/deprecate_no_default_filters'

12 years agoaudioc: Fix memory leak in configfile_exists().
Andre Noll [Fri, 13 Jan 2012 22:54:08 +0000 (23:54 +0100)]
audioc: Fix memory leak in configfile_exists().

In case the config file does not exist, the function returns NULL
without freeing the config_file buffer.

This patch also makes config_file non-static. As configfile_exists()
is called at most once, it is pointless to have a static variable
there. The condition "if (!config_file)" is always true, so we can
get rid of the conditional alltogether.

12 years agoaudioc: Do not leak command buffer.
Andre Noll [Fri, 13 Jan 2012 22:43:05 +0000 (23:43 +0100)]
audioc: Do not leak command buffer.

This buffer contains the command to be sent to para_audiod. It is
allocated but never freed.

12 years agoaudioc.c: Always free IO buffer.
Andre Noll [Fri, 13 Jan 2012 22:39:56 +0000 (23:39 +0100)]
audioc.c: Always free IO buffer.

This 8K buffer is allocated but never freed.

12 years agoFix memory leak in audioc.c.
Andre Noll [Fri, 13 Jan 2012 22:38:14 +0000 (23:38 +0100)]
Fix memory leak in audioc.c.

We leak cf which is allocated and returned by configfile_exists().

12 years agoImprove error diagnostics of mmap_full_file().
Andre Noll [Thu, 8 Dec 2011 20:01:01 +0000 (21:01 +0100)]
Improve error diagnostics of mmap_full_file().

On mmap errors, this function used to return the error code it got
from mmap(). Unfortunately, in at least two cases, this results in
rather obscure error messages:

$ para_afh -i .
main: No such device
$ touch foo; para_afh -i foo
main: Invalid argument

This simple patch specifically checks whether the given fd refers
to a directory or an empty file so that the error messages become
more readable:

$ para_afh -i .
main: failed to mmap "."
main: Is a directory
$ touch foo; para_afh -i foo
main: failed to mmap "foo"
main: file is empty

12 years agograb_client.c: Fix another documentation bug
Andre Noll [Mon, 30 Jan 2012 16:26:23 +0000 (17:26 +0100)]
grab_client.c: Fix another documentation bug

In gc_activate(), the pointer to the scheduler struct is called "s"
rather than "sched".

12 years agoMerge commit '1678ee'
Andre Noll [Mon, 30 Jan 2012 07:30:40 +0000 (08:30 +0100)]
Merge commit '1678ee'

12 years agoaudiod: Deprecate the --no_default_filters option.
Andre Noll [Thu, 1 Dec 2011 18:25:47 +0000 (19:25 +0100)]
audiod: Deprecate the --no_default_filters option.

This option does not make much sense anymore these days as we have
sane defaults in case no filter was given. We prefer deprecation over
removal because this allows to switch between old and new versions
without having to edit the config file.

The option will be removed after the next release.

12 years agopara_client: Fix a memory leak.
Andre Noll [Sun, 22 Jan 2012 21:45:21 +0000 (22:45 +0100)]
para_client: Fix a memory leak.

The main function of para_client first calls client_parse_config()
to decide whether to start an interactive session, run in completion
mode or execute the given command. In the third case case we call
client_open() which calls client_parse_config() again, thereby
leaking the client_task structure which was returned by the first
call to client_parse_config().

Fix this leak by calling client_connect() instead of client_open().

12 years agoFix a typo in the manual.
Andre Noll [Sat, 21 Jan 2012 13:53:32 +0000 (14:53 +0100)]
Fix a typo in the manual.

12 years agoReplace PARA_VSNPRINTF by xvasprintf().
Andre Noll [Fri, 6 Jan 2012 03:15:34 +0000 (04:15 +0100)]
Replace PARA_VSNPRINTF by xvasprintf().

The PARA_VSNPRINTF macro is rather clumsy, and too large to be inlined.
Moreover, it does not return the length of the formated string, so
users have to call strlen() after the call to PARA_VSNPRINTF(). This
is extra work which can easily be avoided since the number of bytes
written is returned by the underlying call to vsnprintf().

This patch replaces the macro by the public function xvasprintf(),
which is similar to the non-standard vasprintf() on GNU systems. It
also adds xasprintf(), a similar variant which takes a variable number
of arguments.

Unlike PARA_VSNPRINTF, xasprintf() and xvasprintf() return the number
of bytes written. This relies on vsnprintf() conforming to the C99
standard and breaks in particular on glibc 2.0 systems. Since glibc
2.0 is about 15 years old, this is unlikely to cause problems on
real systems.

All users which called strlen() right after xvasprintf() are changed
to use the return value of xvasprintf() instead.

12 years agocommand: Introduce struct command_context.
Andre Noll [Sat, 24 Dec 2011 00:22:58 +0000 (01:22 +0100)]
command: Introduce struct command_context.

This exposes a couple of variables which were previously local to
handle_connect() to the command handlers, allowing them to make use
of the full command context.

All newly exposed variables are stored in an instance of the new
structure, and the command handlers now take a pointer to such
a structure.

The patch is large but also straight forward.

12 years agoIntroduce xwritev().
Andre Noll [Fri, 23 Dec 2011 17:28:45 +0000 (18:28 +0100)]
Introduce xwritev().

For the sideband API we will need to write two buffers one after
another. This patch adds the new public function xwritev() to fd.c
which takes an arbitrary number of buffers and calls writev() to
perform the write.

With this function in place, xwrite() becomes a trivial wrapper
for xwritev().

12 years agoRename write_nonblock() to xwrite().
Andre Noll [Tue, 20 Dec 2011 16:37:28 +0000 (17:37 +0100)]
Rename write_nonblock() to xwrite().

This function is not only useful for non-blocking file descriptors,
so the name was misleading. Rename it to xwrite() for the lack of
a better name.

12 years agosc_send_buffer(): Return an error on short writes.
Andre Noll [Sun, 11 Dec 2011 19:28:31 +0000 (20:28 +0100)]
sc_send_buffer(): Return an error on short writes.

This allows all callers to just check for negative return values.

12 years agosc_send_bin_buffer: Use write_nonblock() rather than write_all().
Andre Noll [Sun, 11 Dec 2011 19:27:27 +0000 (20:27 +0100)]
sc_send_bin_buffer: Use write_nonblock() rather than write_all().

The write_nonblock() variant is safer here as it allows to let the
callers deal with short writes.

Despite the name, write_nonblock() can be used for both blocking and
non-blocking fds. It will be renamed in a subsequent patch.

12 years agosc_send_result(): Error out on short writes.
Andre Noll [Sun, 11 Dec 2011 19:23:14 +0000 (20:23 +0100)]
sc_send_result(): Error out on short writes.

This affects only afs command handlers, where short writes should
never happen as the socket fd is set to blocking mode. But still.

12 years agoafh: Use write_all rather than plain write().
Andre Noll [Sun, 11 Dec 2011 19:21:53 +0000 (20:21 +0100)]
afh: Use write_all rather than plain write().

We are currently using plain write() to write out the audio
file header. If this results in a short write, or if the write
is interrupted, we should just try again. So it's safer to call
write_all() here.