Rewrite grab-client code.
[paraslash.git] / mood.c
diff --git a/mood.c b/mood.c
index 590a68fb4d6e0ad3dedfd9efd6683bf69a7d9ec1..cb1534bce4a243ce8ea4a10101a4c1a693300b3c 100644 (file)
--- a/mood.c
+++ b/mood.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2007-2008 Andre Noll <maan@systemlinux.org>
+ * Copyright (C) 2007-2009 Andre Noll <maan@systemlinux.org>
  *
  * Licensed under the GPL v2. For licencing details see COPYING.
  */
@@ -7,6 +7,7 @@
 /** \file mood.c Paraslash's mood handling functions. */
 
 #include <fnmatch.h>
+#include <osl.h>
 #include "para.h"
 #include "error.h"
 #include "string.h"
@@ -84,7 +85,7 @@ typedef void mood_cleanup_function(void *);
  * Used for scoring and to determine whether a file is admissible.
  */
 struct mood_method {
-       /* The name of the method. */
+       /** The name of the method. */
        const char *name;
        /** Pointer to the mood parser. */
        mood_parser *parser;
@@ -392,17 +393,17 @@ static int parse_mood_line(char *mood_line, void *data)
 {
        struct mood_line_parser_data *mlpd = data;
        char **argv;
-       char *delim = " \t";
        unsigned num_words;
        char **w;
        int i, ret;
        enum mood_line_type mlt = ML_INVALID;
        struct mood_item *mi = NULL;
-       char *buf = para_strdup(mood_line);
 
        mlpd->line_num++;
-       num_words = split_args(buf, &argv, delim);
-       ret = 1;
+       ret = create_argv(mood_line, " \t", &argv);
+       if (ret < 0)
+               return ret;
+       num_words = ret;
        if (!num_words) /* empty line */
                goto out;
        w = argv;
@@ -493,8 +494,7 @@ success:
                (mlt == ML_DENY? "deny" : "score"), mi->method);
        ret = 1;
 out:
-       free(argv);
-       free(buf);
+       free_argv(argv);
        if (ret >= 0)
                return ret;
        if (mi) {
@@ -536,10 +536,10 @@ static int check_mood(struct osl_row *mood_row, void *data)
        struct osl_object mood_def;
        struct mood_line_parser_data mlpd = {.line_num = 0};
 
-       int ret2, ret = mood_get_name_and_def_by_row(mood_row, &mood_name, &mood_def);
+       int ret = mood_get_name_and_def_by_row(mood_row, &mood_name, &mood_def);
 
        if (ret < 0) {
-               ret2 = para_printf(pb, "failed to get mood definition: %s\n",
+               para_printf(pb, "failed to get mood definition: %s\n",
                        para_strerror(-ret));
                return ret;
        }
@@ -551,7 +551,7 @@ static int check_mood(struct osl_row *mood_row, void *data)
        ret = for_each_line_ro(mood_def.data, mood_def.size,
                parse_mood_line, &mlpd);
        if (ret < 0)
-               ret2 = para_printf(pb, "%s line %u: %s\n", mood_name, mlpd.line_num,
+               para_printf(pb, "%s line %u: %s\n", mood_name, mlpd.line_num,
                        para_strerror(-ret));
 out:
        osl_close_disk_object(&mood_def);
@@ -561,8 +561,8 @@ out:
 /**
  * Check all moods for syntax errors.
  *
+ * \param fd The afs socket.
  * \param query Unused.
- * \param result: Contains check messages.
  */
 void mood_check_callback(int fd, __a_unused const struct osl_object *query)
 {
@@ -971,7 +971,7 @@ int change_current_mood(char *mood_name)
                        .data = mood_name,
                        .size = strlen(mood_name) + 1
                };
-               ret = osl_get_row(moods_table, BLOBCOL_NAME, &obj, &row);
+               ret = osl(osl_get_row(moods_table, BLOBCOL_NAME, &obj, &row));
                if (ret < 0) {
                        PARA_NOTICE_LOG("no such mood: %s\n", mood_name);
                        return ret;