Makefile.in: use CPPFLAGS also for target mysql.o
[paraslash.git] / mysql_selector.c
index f8885f9a0f50ea0dd185e4cbecbc3a0ab17d1d0e..e545f0da6d5bf04f05a835dc3d17f7dc2ac41fcf 100644 (file)
@@ -25,7 +25,7 @@
 #include "server.cmdline.h"
 #include "server.h"
 #include "vss.h"
-#include "db.h"
+#include "afs.h"
 #include <mysql/mysql.h>
 #include <mysql/mysql_version.h>
 #include <regex.h>
@@ -459,7 +459,8 @@ int com_laa(int fd, int argc, __a_unused char *argv[])
 /*
  * history
  */
-int com_hist(int fd, int argc, char *argv[]) {
+int com_hist(int fd, int argc, char *argv[])
+{
        int ret;
        void *result = NULL;
        char *q, *atts;
@@ -537,7 +538,7 @@ int com_mbox(int fd, int argc, char *argv[])
 
                if (!row[0])
                        goto out;
-               tmp = make_message("%s X-Attribute-%s: ', %s, '\n", query,
+               tmp = make_message("%sX-Attribute-%s: ', %s, '\n", query,
                        row[0], row[0]);
                free(query);
                query = tmp;
@@ -577,40 +578,38 @@ out:
        return ret;
 }
 
-/* get attributes by name. If verbose is not 0, get_a writes a string
- * into atts of the form 'att1="0",att2="1"', which is used in com_cam
- * for contructing a mysql update query.
- * never returns NULL in *NON VERBOSE* mode
+/*
+ * get attributes by name. If verbose is not 0, this function returns a string
+ * of the form 'att1="0",att2="1"'... which is used in com_cam() for
+ * constructing a mysql update query. Otherwise the space-separated list of all
+ * attributes which are set in the audio file given by name is returned.  Never
+ * returns NULL in *NON VERBOSE* mode.
  */
 static char *get_atts(char *name, int verbose)
 {
        char *atts = NULL, *buf, *ebn;
        void *result = NULL, *result2 = NULL;
        MYSQL_ROW row, row2;
-       int i, ret;
-       unsigned int num_fields;
+       int i;
+       unsigned num_fields;
 
-       ret = -E_NOATTS;
        result2 = get_all_attributes();
        if (!result2)
                goto out;
-       ret = -E_ESCAPE;
-       if (!(ebn = escaped_basename(name)))
+       ebn = escaped_basename(name);
+       if (!ebn)
                goto out;
        buf = make_message("select * from data where name='%s'", ebn);
        free(ebn);
-       ret = -E_NORESULT;
        result = get_result(buf);
        free(buf);
        if (!result)
                goto out;
-       ret = -E_EMPTY_RESULT;
        num_fields = mysql_num_fields(result);
        if (num_fields < 5)
                goto out;
        mysql_data_seek(result2, 4); /* skip Lastplayed, Numplayed... */
        row = mysql_fetch_row(result);
-       ret = -E_NOROW;
        if (!row)
                goto out;
        for (i = 4; i < num_fields; i++) {
@@ -625,7 +624,6 @@ static char *get_atts(char *name, int verbose)
                if (verbose)
                        atts = para_strcat(atts, is_set? "=\"1\"" : "=\"0\"");
        }
-       ret = 1;
 out:
        if (result2)
                mysql_free_result(result2);