X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=mysql_selector.c;h=e545f0da6d5bf04f05a835dc3d17f7dc2ac41fcf;hp=b059de70b61cd49f8aa46e7c64411e8fb4617852;hb=8b351937ccfe70a0837e77d691ebc240674fb6f8;hpb=0a405367cdc8f3b0f49fb5ec3798378a2fc4589b diff --git a/mysql_selector.c b/mysql_selector.c index b059de70..e545f0da 100644 --- a/mysql_selector.c +++ b/mysql_selector.c @@ -25,7 +25,7 @@ #include "server.cmdline.h" #include "server.h" #include "vss.h" -#include "db.h" +#include "afs.h" #include #include #include @@ -538,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; @@ -578,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++) { @@ -626,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);