| Commit message (Collapse) | Author | Age |
| |\
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Switch to SPDX licence identifiers
A single patch which replaces the first comment line of most .c and .h files
containing the copyright notice by standardized SPDX (Software/System Package
Data Exchange) nomenclature.
* t/spdx:
Switch to SPDX identifiers.
|
| | |
| |
| |
| |
| |
| |
| |
| | |
Generated with
sed -i 's|Copyright.*Andre Noll.*|SPDX-License-Identifier: GPL-2.0 */|g' *.c *.h
followed by manually tweaking the result a bit. No license change intended.
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Currently code outside of score.c needs to deal with two types of osl table
rows: rows of the audio file table and rows of the score table. This foils
type safety because the row pointers to different tables have the same type.
We currently expose score rows to functions outside of score.c because the
code in aft.c loops over the score table, and the osl loop callback receives
a pointer to the current row as its first argument.
This commit implements the static call_callback() in score.c, used as the
osl callback, to avoid exposing the score row. The new function decodes the
cells of the row to obtain the aft row and the score. These two values are
then passed to the callback function passed to score_loop().
|
| | |
| |
| |
| | |
It corresponds to the ->get() selector method.
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Currently mood.c and playlist.c contain similar public functions. For example,
there is mood_load() and playlist_load(), mood_loop() and playlist_loop().
Introduce struct selector_ops which contains methods such as ->load()
and loop(). We define two instances of the new structure, one for the mood
selector and one for the playlist selector. The structures can be constant,
but need to be public. The methods can be static.
The score table is now regarded as owned by the mood or playlist. It is no
longer listed in afs_tables[] and afs_table_operations can go away.
We don't need the global score_table variable anymore because all public
functions of score.c now take a pointer to the table to operate on. Similarly,
current_mood and current_playlist can be removed.
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
The way mood.c and playlist.c call score_delete() ends up looking up the
row in the score table twice. The problem is that score_delete() returns
negative if the given row does not belong to the score table. All call sites
handle this by first calling row_belongs_to_score_table(), which results in
an additional lookup.
Change score_delete() to return zero in the "row does not belong to the score
table" case, and one if the row did exist (and was removed successfully). This
not only avoids the double lookup but also simplifies the callers a bit.
|
| |/
|
|
|
|
| |
We no longer need the percent parameter since the only remaining caller
passes zero. Rename the function to score_move_to_end() since this it what
it now does.
|
| |
|
|
|
| |
The users outside of error.h may as well call osl(), which leaves only
a single caller in error.h. Open-code the macro there and remove it.
|
| |
|
|
| |
Every .c file includes it anyway.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Currently there can be only one score table at a time because the
functions of score.c refer to the global score_table variable.
To implement the new feature, we need to overcome this restriction
so that the callback of the ls command can populate an independent
score table to print its output without interfering with the score
table that is currently active.
This commit changes most functions of score.c to receive an additional
table pointer argument. All current users of the score table pass a
NULL pointer to instruct the functions to operate on the global score
table as before.
However, if the ls command is invoked with an optional mood argument
to -a. the callback calls mood_load(), followed by mood_loop() and
mood_unload(). The former returns an opaque handle which is then
passed to the other two functions to instruct them to operate on the
temporary score table instead of the global one.
To make the feature work for playlists as well, analogous functionality
is implemented in playlist.c. The new mop_loop() of aft.c performs
the disambiguation in a similar way as the activate_mood_or_playlist()
does. It is a bit simpler though, since the ls command does not have
to deal with NULL arguments and does not need to fall back to the
dummy mood.
|
| |
|
|
|
|
|
|
|
| |
Since the score table has only volatile columns, the only possible
error is memory exhaustion, in which case we can only abort
anyway. This patch changes score_open() to abort if osl_open()
fails. This allows us to let score_clear() return void. We can't get
rid of the return value of score_open(), however, since a pointer to
this function is stored the afs table operations structure.
|
| |
|
|
|
|
| |
This is simpler, avoids the run-time initialization, and allows us
to mark the instances of the operations structures constant. Improve
the documentation a bit while at it.
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
This function was over-engineered because only one caller passed a
non-NULL rank pointer without actually using the rank for anything
other than printing it in a log message. So drop the rank parameter
and adjust the callers and the log message accordingly.
Moreover, the function returned int rather than bool to be able to
also return an error code in case the osl lookup function fails. This
should never happen though, because the only possible errors are
invalid row or table pointers, and these indicate a bug. So abort in
this case and let the function return bool.
|
| |
|
|
|
|
|
|
|
| |
The function simply iterates the entries of the score table. The new
name is shorter, more to the point, and indicates that the function
is implemented in score.c.
Streamline the documentation while at it and swap the arguments,
as the reversed order is more natural.
|
| |
|
|
|
|
|
|
|
| |
This public function had only one caller outside of score.c and this
caller already knows the number of admissible files because this
number is also stored in the afs statistics structure.
Open-coding the remaining caller in score.c allows us to remove the
public function.
|
| |
|
|
|
| |
Event handlers are optional, and the one for the score table did not
do anything, so..
|
| |
|
|
| |
The function is simple and has only one caller.
|
| |
|
|
|
| |
The value is NULL anyway because the score table description was
declared as a global static variable.
|
| |
|
|
|
|
|
| |
Just because it's shorter and matches the naming of the new allocators
we are about to introduce. The bulk of this patch was created with
sed -i 's/para_malloc/alloc/g' *.c *.h yy/mp.y
|
| |
|
|
| |
Every single one of these was incomplete or outdated.
|
| |
|
|
|
| |
Static functions don't need doxygen comments. The two comments removed
by this commit did not add any value anyway.
|
| |
|
|
|
| |
Reword the text to focus on why we dance twice. Also put it on dedox
because it is static.
|
| |
|
|
|
| |
This function is static, and its implementation is shorter than its
documentation, which mostly consists of pointless boilerplate text.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The GPLv2 line does not add any additional information, so drop
it. This leaves a single line of legalese text for most files, which
is about the amount of screen real estate it deserves.
This patch was created with the following script (plus some manual
fixups):
awk '{
if (NR <= 5) {
gs = gensub(/.*Copyright.* ([0-9]+).*Andre Noll.*/, "\\1", "g")
if (gs != $0)
year = gs
next
}
if (NR == 6 && year != "")
printf("/* Copyright (C) %s Andre Noll <maan@tuebingen.mpg.de>, see file COPYING. */\n", year)
print
}'
|
| |
|
|
|
| |
This way doxygen issues a warning if the file/function/structure no
longer exists and a stale reference remains.
|
| |
|
|
|
| |
They are not part of the tree, and there is no dedicated man page
for them.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This is the first afs subcommand which needs to pass a pattern list
to its callback. The new send_lls_callback_request() provides this
functionality. It serializes the parse result into a buffer and passes
this buffer to the callback.
Since there are non-lopsub commands which also pass a pattern list,
action_if_pattern_matches() is patched to receive the pattern
list either from the serialized parse result or in the old way via
pmd->data. To achieve this, a parse result pointer is added to struct
pattern_match_data. If this pointer is not NULL, we are dealing with
a subcommand that has been converted.
Since the ls subcommand has not been converted yet, lopsub will
regard "ls" as a uniqe abbreviation of the lsatt command, which
breaks t0004. To work around this, we deactivate prefix matching by
only accepting exact matches in run_command(). This workaround can
be removed after com_ls() has been converted.
|
| |
|
|
|
| |
The comparator for this column never returns 0 unless the objects
being compared coincide.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Done with
files=$(git grep -l 'Copyright (C) [0-9]\{4\}\(-2014\)* Andre Noll')
sed --in-place= -e 's/Copyright (C) \([0-9]\{4\}\)-2014 Andre Noll/Copyright (C) \1 Andre Noll/1' $files
In previous years we ran a similar script to set the second year in
the range to the current year. This is kind of silly, so let's get
rid of this useless information.
This commit replaces "Copyright (C) A-B" by "Copyright (C) A" in
all file headers, i.e. only the first year (A) is left in. Accurate
information including time stamps for each change can be obtained
from the git history.
|
| |
|
|
| |
Found by cppcheck.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
| |
The mail server on systemlinux.org was down for more than a week
lately, so let's use an alternative official address. This commit
changes all maan@systemlinux.org addresses to maan@tuebingen.mpg.de.
Most .c and .h files contain the email address in the copyright header,
so they must all be patched. Three other files contain the address
for a different reason:
* README lists email and git, gitweb and home page URLs
* configure.ac needs it for configure -h
* version.c contains it for the -V option of all commands
|
| |
|
|
|
|
|
|
|
| |
This year, we're really on time. The changes in this patch were
created by the following silly script:
files=$(git grep -l 'Copyright (C) [0-9]\{4\}\(-2013\)* Andre Noll')
sed --in-place= -e 's/Copyright (C) \([0-9]\{4\}\)-2013 Andre Noll/Copyright (C) \1-2014 Andre Noll/1' $files
sed --in-place= -e 's/Copyright (C) 2013 Andre Noll/Copyright (C) 2013-2014 Andre Noll/1' $files
|
| |
|
|
|
| |
Remove a stray "and" and the list of possible errors, which is not
very useful and possibly incomplete.
|
| |
|
|
| |
Better late than never.
|
| | |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The score of an audio file in the score table is defined as a quantity
which is sizeof(long) bytes large, i.e. 4 bytes on 32bit systems and
8 bytes on 64 bit systems. This is not a problem per se because the
score column lives only in memory, so we do not have to worry about
incompatibilities of the on-disk layout.
However, at several places in score.c we cast the pointer to the osl
object to (int *) rather than (long *). When writing to the object on
a 64 bit machine, this will only set 4 out of the 8 allocated bytes,
the other four bytes stay uninitialized. The "ls" command uses the
correct cast to (long *) and reads the full 8 bytes. This causes
valgrind to complain:
==5433== Conditional jump or move depends on uninitialised value(s)
==5433== at 0x4164F4: prepare_ls_row (aft.c:1334)
==5433== by 0x4E2F421: osl_rbtree_loop (osl.c:1457)
==5433== by 0x418935: admissible_file_loop (score.c:255)
==5433== by 0x41601A: com_ls_callback (aft.c:1363)
==5433== by 0x411FDE: command_post_select (afs.c:842)
==5433== by 0x41B67A: schedule (sched.c:76)
==5433== by 0x411ACF: afs_init (afs.c:986)
==5433== by 0x408863: main (server.c:451)
==5433==
==5433== Conditional jump or move depends on uninitialised value(s)
==5433== at 0x41650A: prepare_ls_row (aft.c:1334)
==5433== by 0x4E2F421: osl_rbtree_loop (osl.c:1457)
==5433== by 0x418935: admissible_file_loop (score.c:255)
==5433== by 0x41601A: com_ls_callback (aft.c:1363)
==5433== by 0x411FDE: command_post_select (afs.c:842)
==5433== by 0x41B67A: schedule (sched.c:76)
==5433== by 0x411ACF: afs_init (afs.c:986)
==5433== by 0x408863: main (server.c:451)
Fix this bug by always casting to (long *).
|
| | |
|
| |
|
|
| |
Hey, this is earlier than last year :)
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
A wrapper for regcomp() that logs an error message if the regcomp() failed
and uses a return value according to the paraslash rules. Currently there is
only one user of regular expressions, is_v4_dot_quad(), which is converted
to para_regex(), but new callers will be added soon.
Unfortunately, this change made it necessary to include regex.h in all .c files
that use string.h. Clean up the order in which headers are included a bit while
we're at it.
Maybe I should rethink the rule "Only .c files shall include header files"...
|
| | |
|
| | |
|
| | |
|
| |
|
|
|
|
|
| |
This function is called whenever the afs_info struct changed,
for example if the user executed a touch command. Simply
ignore the request to update the score in case the file is not
contained in the score table.
|
| | |
|
| |
|
|
| |
Add documentation and an assertion for (num > 0).
|
| | |
|
| |
|
|
|
|
|
|
|
| |
The score tables stores in one of its columns a pointer to
a row in the audio file table. This means for each admissible
file we're allocating space for a void* pointer to store the
aft pointer.
It's simpler and probably faster to store the afs pointer directly,
but of course that pointer must not be freed by the osl.
|
| | |
|
| |
|
|
|
|
|
|
|
|
|
| |
Add blob event handling. This definitely needs some
more fine-tuning, but that can be changed gradually
thanks to the generic event handling code.
In playlist mode there's nothing to do, as we're
not interested in any blob events. So install only
a dummy handler for the scoring system and decide
whether to reload the score table in mood.c.
|
| | |
|