Example #1
0
/**
 * gva_mame_verify_samples:
 * @name: the name of a sample set
 * @error: return location for a #GError, or %NULL
 *
 * Verifies the contents of the sample set @name and returns the status,
 * which may be "good", "bad", "best available", "not found", or "not
 * supported".  If an error occurs, it returns %NULL and sets @error.
 *
 * Returns: verification status, or %NULL
 **/
gchar *
gva_mame_verify_samples (const gchar *name,
                         GError **error)
{
        gchar *arguments;
        gchar **stdout_lines;
        gchar **stderr_lines;
        gchar *status = NULL;
        gint exit_status;
        gint ii;

        g_return_val_if_fail (name != NULL, NULL);

        /* Execute the command "${mame} -verifysamples %{name}". */
        arguments = g_strdup_printf ("-verifysamples %s", name);
        exit_status = gva_mame_command (
                arguments, &stdout_lines, &stderr_lines, error);
        g_free (arguments);

        if (exit_status < 0)
                return NULL;

        /* First try to extract a status from standard output. */
        for (ii = 0; status == NULL && stdout_lines[ii] != NULL; ii++)
                gva_mame_verify_parse (stdout_lines[ii], NULL, &status);

        /* If that fails, try to extract a status from standard error. */
        for (ii = 0; status == NULL && stderr_lines[ii] != NULL; ii++)
                gva_mame_verify_parse (stderr_lines[ii], NULL, &status);

        g_strfreev (stdout_lines);
        g_strfreev (stderr_lines);

        return status;
}
Example #2
0
static void
audit_read (GvaProcess *process,
            GvaAuditData *data)
{
    gchar *line;
    gchar *name;
    gchar *status;
    GString *string;
    gpointer value;

    line = g_strchomp (gva_process_stdout_read_line (process));

    value = GUINT_TO_POINTER (data->output->len);
    g_ptr_array_add (data->output, g_strdup (line));

    if (!gva_mame_verify_parse (line, &name, &status))
        goto exit;

    g_hash_table_insert (data->output_index, g_strdup (name), value);

    /* Build a quoted, comma-separated list of games. */
    string = g_hash_table_lookup (data->status_index, status);
    if (string != NULL)
        g_string_append_printf (string, ", \"%s\"", name);
    else
    {
        string = g_string_sized_new (1024);
        g_string_printf (string, "\"%s\"", name);

        g_hash_table_insert (
            data->status_index,
            g_strdup (status), string);
    }

    gva_process_inc_progress (process);

    g_free (name);
    g_free (status);

exit:
    g_free (line);
}