Implement ls --admissible=m/foo. 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.
Assume that score_open() and score_clear() always succeed. 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.
afs: Replace ->init of afs tables by table operations. 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.
Simplify row_belongs_to_score_table(). 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.
Rename admissible_file_loop() -> score_loop(). 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.
Remove get_num_admissible_files(). 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.
score.c: Remove event handler. Event handlers are optional, and the one for the score table did not do anything, so..
score.c: Merge score_add into score_update(). The function is simple and has only one caller.
score.c: Remove pointless assignment. The value is NULL anyway because the score table description was declared as a global static variable.
string: Rename para_malloc() -> alloc(). 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
score.c: Don't try to document possible error codes. Every single one of these was incomplete or outdated.
score.c: Remove pointless comments. Static functions don't need doxygen comments. The two comments removed by this commit did not add any value anyway.
score.c: Improve documentation of score_compare(). Reword the text to focus on why we dance twice. Also put it on dedox because it is static.
score.c: Shorten documentation of get_score_of_row(). This function is static, and its implementation is shorter than its documentation, which mostly consists of pointless boilerplate text.
Shorten copyright notice. 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 }'
doxygen: Add \ref to references. This way doxygen issues a warning if the file/function/structure no longer exists and a stale reference remains.
doxygen: Don't refer to libosl functions. They are not part of the tree, and there is no dedicated man page for them.
server: Convert com_lsatt() to lopsub. 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.
score.c: Add OSL_UNIQUE to storage flags of score column. The comparator for this column never returns 0 unless the objects being compared coincide.
Update year in copyright headers. 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.