csi-exec.c 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. #include "config.h"
  35. #include "cairo.h"
  36. #include "cairo-script-interpreter.h"
  37. #include <stdio.h>
  38. #include <stdlib.h>
  39. static cairo_surface_t *
  40. _surface_create (void *closure,
  41. cairo_content_t content,
  42. double width, double height,
  43. long uid)
  44. {
  45. return cairo_image_surface_create (CAIRO_FORMAT_ARGB32, width, height);
  46. }
  47. int
  48. main (int argc, char **argv)
  49. {
  50. const cairo_script_interpreter_hooks_t hooks = {
  51. .surface_create = _surface_create
  52. };
  53. cairo_script_interpreter_t *csi;
  54. int i;
  55. for (i = 1; i < argc; i++) {
  56. int status, line;
  57. csi = cairo_script_interpreter_create ();
  58. cairo_script_interpreter_install_hooks (csi, &hooks);
  59. cairo_script_interpreter_run (csi, argv[i]);
  60. line = cairo_script_interpreter_get_line_number (csi);
  61. status = cairo_script_interpreter_destroy (csi);
  62. if (status) {
  63. fprintf (stderr, "Error during replay of '%s', line %d: %d\n",
  64. argv[i], line, status);
  65. return 1;
  66. }
  67. }
  68. return 0;
  69. }