/* retrieves the context for the session */
board = board_of_req(req);
- INFO("method 'new' called for boardid %d", board->id);
+ AFB_INFO("method 'new' called for boardid %d", board->id);
/* reset the game */
memset(board->board, ' ', sizeof board->board);
/* retrieves the context for the session */
board = board_of_req(req);
- INFO("method 'board' called for boardid %d", board->id);
+ AFB_INFO("method 'board' called for boardid %d", board->id);
/* describe the board */
description = describe(board);
/* retrieves the context for the session */
board = board_of_req(req);
- INFO("method 'move' called for boardid %d", board->id);
+ AFB_INFO("method 'move' called for boardid %d", board->id);
/* retrieves the arguments of the move */
index = afb_req_value(req, "index");
/* checks validity of arguments */
if (i < 0 || i > 8) {
- WARNING("can't move to %s: %s", index?:"?", index?"wrong value":"not set");
+ AFB_WARNING("can't move to %s: %s", index?:"?", index?"wrong value":"not set");
afb_req_fail(req, "error", "bad request");
return;
}
/* checks validity of the state */
if (winner(board->board) != 0) {
- WARNING("can't move to %s: game is terminated", index);
+ AFB_WARNING("can't move to %s: game is terminated", index);
afb_req_fail(req, "error", "game terminated");
return;
}
/* checks validity of the move */
if (board->board[i] != ' ') {
- WARNING("can't move to %s: room occupied", index);
+ AFB_WARNING("can't move to %s: room occupied", index);
afb_req_fail(req, "error", "occupied");
return;
}
/* applies the move */
- INFO("method 'move' for boardid %d, index=%s", board->id, index);
+ AFB_INFO("method 'move' for boardid %d, index=%s", board->id, index);
add_move(board, i);
/* replies */
/* retrieves the context for the session */
board = board_of_req(req);
- INFO("method 'level' called for boardid %d", board->id);
+ AFB_INFO("method 'level' called for boardid %d", board->id);
/* retrieves the arguments */
level = afb_req_value(req, "level");
/* check validity of arguments */
if (l < 1 || l > 10) {
- WARNING("can't set level to %s: %s", level?:"?", level?"wrong value":"not set");
+ AFB_WARNING("can't set level to %s: %s", level?:"?", level?"wrong value":"not set");
afb_req_fail(req, "error", "bad request");
return;
}
/* set the level */
- INFO("method 'level' for boardid %d, level=%d", board->id, l);
+ AFB_INFO("method 'level' for boardid %d, level=%d", board->id, l);
board->level = l;
/* replies */
/* retrieves the context for the session */
board = board_of_req(req);
- INFO("method 'join' called for boardid %d", board->id);
+ AFB_INFO("method 'join' called for boardid %d", board->id);
/* retrieves the arguments */
id = afb_req_value(req, "boardid");
return;
bad_request:
- WARNING("can't join boardid %s: %s", id ? : "?", !id ? "no boardid" : atoi(id) ? "not found" : "bad boardid");
+ AFB_WARNING("can't join boardid %s: %s", id ? : "?", !id ? "no boardid" : atoi(id) ? "not found" : "bad boardid");
afb_req_fail(req, "error", "bad request");
return;
}
/* retrieves the context for the session */
board = board_of_req(req);
- INFO("method 'undo' called for boardid %d", board->id);
+ AFB_INFO("method 'undo' called for boardid %d", board->id);
/* checks the state */
if (board->moves == 0) {
- WARNING("can't undo");
+ AFB_WARNING("can't undo");
afb_req_fail(req, "error", "bad request");
return;
}
/* retrieves the context for the session */
board = board_of_req(req);
- INFO("method 'play' called for boardid %d", board->id);
+ AFB_INFO("method 'play' called for boardid %d", board->id);
/* checks validity of the state */
if (winner(board->board) != 0 || board->moves == 9) {
- WARNING("can't play: game terminated (%s)", winner(board->board) ? "has winner" : "no room left");
+ AFB_WARNING("can't play: game terminated (%s)", winner(board->board) ? "has winner" : "no room left");
afb_req_fail(req, "error", "game terminated");
return;
}
/* retrieves the context for the session */
board = board_of_req(req);
- INFO("method 'wait' called for boardid %d", board->id);
+ AFB_INFO("method 'wait' called for boardid %d", board->id);
/* creates the waiter and enqueues it */
waiter = calloc(1, sizeof *waiter);