1
/*
2
 * Copyright © 2008 Chris Wilson <chris@chris-wilson.co.uk>
3
 *
4
 * This library is free software; you can redistribute it and/or
5
 * modify it either under the terms of the GNU Lesser General Public
6
 * License version 2.1 as published by the Free Software Foundation
7
 * (the "LGPL") or, at your option, under the terms of the Mozilla
8
 * Public License Version 1.1 (the "MPL"). If you do not alter this
9
 * notice, a recipient may use your version of this file under either
10
 * the MPL or the LGPL.
11
 *
12
 * You should have received a copy of the LGPL along with this library
13
 * in the file COPYING-LGPL-2.1; if not, write to the Free Software
14
 * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
15
 * You should have received a copy of the MPL along with this library
16
 * in the file COPYING-MPL-1.1
17
 *
18
 * The contents of this file are subject to the Mozilla Public License
19
 * Version 1.1 (the "License"); you may not use this file except in
20
 * compliance with the License. You may obtain a copy of the License at
21
 * http://www.mozilla.org/MPL/
22
 *
23
 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
24
 * OF ANY KIND, either express or implied. See the LGPL or the MPL for
25
 * the specific language governing rights and limitations.
26
 *
27
 * The Original Code is the cairo graphics library.
28
 *
29
 * The Initial Developer of the Original Code is Chris Wilson.
30
 *
31
 * Contributor(s):
32
 *      Chris Wilson <chris@chris-wilson.co.uk>
33
 */
34

            
35
#include "config.h"
36

            
37
#include "cairo.h"
38
#include "cairo-script-interpreter.h"
39

            
40
#include <stdio.h>
41
#include <stdlib.h>
42

            
43
static cairo_surface_t *
44
_surface_create (void *closure,
45
		 cairo_content_t content,
46
		 double width, double height,
47
		 long uid)
48
{
49
    return cairo_image_surface_create (CAIRO_FORMAT_ARGB32, width, height);
50
}
51

            
52
int
53
main (int argc, char **argv)
54
{
55
    const cairo_script_interpreter_hooks_t hooks = {
56
	.surface_create = _surface_create
57
    };
58
    cairo_script_interpreter_t *csi;
59
    int i;
60

            
61
    for (i = 1; i < argc; i++) {
62
	int status, line;
63

            
64
	csi = cairo_script_interpreter_create ();
65
	cairo_script_interpreter_install_hooks (csi, &hooks);
66
	cairo_script_interpreter_run (csi, argv[i]);
67
	line = cairo_script_interpreter_get_line_number (csi);
68
	status = cairo_script_interpreter_destroy (csi);
69
	if (status) {
70
	    fprintf (stderr, "Error during replay of '%s', line %d: %d\n",
71
		     argv[i], line, status);
72
	    return 1;
73
	}
74
    }
75

            
76
    return 0;
77
}