X-Git-Url: http://git.tuebingen.mpg.de/?a=blobdiff_plain;f=afs.c;h=f0fa57fcb6087a5d812fc282712eb7fd1701cc8f;hb=a9bdbe2c8a73675be499fc95b935f3839e30c575;hp=071f657ce69c79812d29a982f69cc5c0bbf8f8b7;hpb=0b6e7a20c19d642f9d8e65683e1525c91dd3de39;p=paraslash.git diff --git a/afs.c b/afs.c index 071f657c..f0fa57fc 100644 --- a/afs.c +++ b/afs.c @@ -12,9 +12,11 @@ #include #include #include +#include #include #include #include +#include #include "server.cmdline.h" #include "para.h" @@ -706,7 +708,7 @@ static int open_afs_tables(void) int i, ret; get_database_dir(); - PARA_NOTICE_LOG("opening %u osl tables in %s\n", NUM_AFS_TABLES, + PARA_NOTICE_LOG("opening %d osl tables in %s\n", NUM_AFS_TABLES, database_dir); for (i = 0; i < NUM_AFS_TABLES; i++) { ret = afs_tables[i].open(database_dir); @@ -888,7 +890,7 @@ static int execute_server_command(fd_set *rfds) return ret; buf[n] = '\0'; if (strcmp(buf, "new")) - return -E_BAD_CMD; + return -ERRNO_TO_PARA_ERROR(EINVAL); return open_next_audio_file(); } @@ -1070,23 +1072,24 @@ out: return ret; } -int com_init(struct command_context *cc) +static int com_init(struct command_context *cc, struct lls_parse_result *lpr) { int i, j, ret; uint32_t table_mask = (1 << (NUM_AFS_TABLES + 1)) - 1; struct osl_object query = {.data = &table_mask, .size = sizeof(table_mask)}; + unsigned num_inputs = lls_num_inputs(lpr); ret = make_database_dir(); if (ret < 0) return ret; - if (cc->argc != 1) { + if (num_inputs > 0) { table_mask = 0; - for (i = 1; i < cc->argc; i++) { + for (i = 0; i < num_inputs; i++) { for (j = 0; j < NUM_AFS_TABLES; j++) { struct afs_table *t = &afs_tables[j]; - if (strcmp(cc->argv[i], t->name)) + if (strcmp(lls_input(i, lpr), t->name)) continue; table_mask |= (1 << j); break; @@ -1098,6 +1101,7 @@ int com_init(struct command_context *cc) return send_callback_request(com_init_callback, &query, afs_cb_result_handler, cc); } +EXPORT_SERVER_CMD_HANDLER(init); /** * Flags for the check command. @@ -1202,7 +1206,7 @@ __must_check int afs_event(enum afs_events event, struct para_buffer *pb, continue; ret = t->event_handler(event, pb, data); if (ret < 0) { - PARA_CRIT_LOG("table %s, event %d: %s\n", t->name, + PARA_CRIT_LOG("table %s, event %u: %s\n", t->name, event, para_strerror(-ret)); return ret; }