Example #1
0
static const char*
komi_formatter (char *dest, size_t size, int menu_item, const char *unknown)
{
    (void) unknown;
    snprint_fixed (dest, size, menu_item);
    return dest;
}
Example #2
0
static void
output_header_props (void)
{
    char buffer[128];

    rb->strlcpy (buffer, "GM[1]FF[4]CA[UTF-8]AP[Rockbox Goban:1.0]ST[2]\n\n",
                 sizeof (buffer));
    write_file (sgf_fd, buffer, rb->strlen (buffer));

    /* board size */
    if (board_width != board_height)
    {
        rb->snprintf (buffer, sizeof (buffer), "%s[%d:%d]",
                      prop_names[PROP_SIZE], board_width, board_height);
    }
    else
    {
        rb->snprintf (buffer, sizeof (buffer), "%s[%d]",
                      prop_names[PROP_SIZE], board_width);
    }

    write_file (sgf_fd, buffer, rb->strlen (buffer));

    rb->snprintf (buffer, sizeof (buffer), "%s[", prop_names[PROP_KOMI]);
    write_file (sgf_fd, buffer, rb->strlen (buffer));

    snprint_fixed (buffer, sizeof (buffer), header.komi);
    write_file (sgf_fd, buffer, rb->strlen (buffer));

    write_char (sgf_fd, ']');

    output_header_helper (PROP_RULESET);
    output_header_helper (PROP_RESULT);

    output_header_helper (PROP_BLACK_NAME);
    output_header_helper (PROP_WHITE_NAME);
    output_header_helper (PROP_BLACK_RANK);
    output_header_helper (PROP_WHITE_RANK);
    output_header_helper (PROP_BLACK_TEAM);
    output_header_helper (PROP_WHITE_TEAM);

    output_header_helper (PROP_EVENT);
    output_header_helper (PROP_PLACE);
    output_header_helper (PROP_DATE);

    if (output_header_helper (PROP_OVERTIME) || header.time_limit != 0)
    {
        rb->snprintf (buffer, sizeof (buffer), "%s[%d]",
                      prop_names[PROP_TIME_LIMIT], header.time_limit);
        write_file (sgf_fd, buffer, rb->strlen (buffer));
    }

    write_char (sgf_fd, '\n');
    write_char (sgf_fd, '\n');
}