From: Andre Noll Date: Sat, 11 Jul 2009 14:58:40 +0000 (+0200) Subject: Merge branch 'master' into next X-Git-Tag: v0.4.0~51^2~4 X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=commitdiff_plain;h=aef566e9c8680629bac1ea84893b8b3ccd13da77;ds=sidebyside Merge branch 'master' into next Conflicts: mood.c --- aef566e9c8680629bac1ea84893b8b3ccd13da77 diff --cc error.h index 79931bf4,95640da9..c9031f82 --- a/error.h +++ b/error.h @@@ -111,8 -150,8 +111,7 @@@ extern const char **para_errlist[] #define MOOD_ERRORS \ - PARA_ERROR(MOOD_SYNTAX, "mood syntax error"), \ PARA_ERROR(NO_MOOD, "no mood available"), \ - PARA_ERROR(NOT_ADMISSIBLE, "file is not admissible"), \ PARA_ERROR(DUMMY_ROW, "attempted to access blob dummy object"), \ diff --cc mood.c index ae71dab0,24d1de29..26d68dc5 --- a/mood.c +++ b/mood.c @@@ -107,9 -164,93 +107,9 @@@ static uint64_t int_sqrt(uint64_t x return res; } - /* returns 1 if row matches score item, negative otherwise */ - static int add_item_score(const struct osl_row *row, struct mood_item *item, long *score, - long *score_arg_sum) -static int mm_no_attributes_set_parser(const char *arg, __a_unused void **ignored) -{ - if (arg && *arg) - PARA_WARNING_LOG("ignored junk at eol: %s\n", arg); - return 1; -} - -static int mm_no_attributes_set_score_function(__a_unused const char *path, - const struct afs_info *afsi, - __a_unused const struct afh_info *afhi, - __a_unused const void *data) -{ - if (!afsi->attributes) - return 100; - return -100; -} - -static int mm_played_rarely_score_function(__a_unused const char *path, - const struct afs_info *afsi, - __a_unused const struct afh_info *afhi, - __a_unused const void *data) -{ - unsigned num; - int ret = get_num_admissible_files(&num); - - if (ret < 0) - return 0; - if (statistics.num_played_sum - num * afsi->num_played - > int_sqrt(statistics.num_played_qd * num)) - return 100; - return -100; -} - -static int mm_played_rarely_parser(const char *arg, __a_unused void **ignored) -{ - if (arg && *arg) - PARA_WARNING_LOG("ignored junk at eol: %s\n", arg); - return 1; -} - -static int mm_path_matches_score_function(const char *path, - __a_unused const struct afs_info *afsi, - __a_unused const struct afh_info *afhi, - const void *data) -{ - if (fnmatch(data, path, 0)) - return -100; - return 100; -} - -static int mm_path_matches_parser(const char *arg, void **data) -{ - *data = para_strdup(arg); - return 1; -} - -static void mm_path_matches_cleanup(void *data) -{ - free(data); -} - -static int mm_is_set_parser(const char *arg, void **bitnum) -{ - unsigned char *c = para_malloc(1); - int ret = get_attribute_bitnum_by_name(arg, c); - - if (ret >= 0) - *bitnum = c; - else - free(c); - return ret; -} - -static int mm_is_set_score_function(__a_unused const char *path, - __a_unused const struct afs_info *afsi, - __a_unused const struct afh_info *afhi, - const void *data) -{ - const unsigned char *bn = data; - if (afsi->attributes & (1ULL << *bn)) - return 100; - return -100; -} - + /* returns 1 if row matches score item, 0 if not, negative on errors */ + static int get_item_score(const struct osl_row *row, struct mood_item *item, + long *score, long *score_arg_sum) { struct afs_info afsi; struct afh_info afhi;