gvloadimage.c 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /*************************************************************************
  2. * Copyright (c) 2011 AT&T Intellectual Property
  3. * All rights reserved. This program and the accompanying materials
  4. * are made available under the terms of the Eclipse Public License v1.0
  5. * which accompanies this distribution, and is available at
  6. * https://www.eclipse.org/legal/epl-v10.html
  7. *
  8. * Contributors: Details at https://graphviz.org
  9. *************************************************************************/
  10. /*
  11. * graphics code generator wrapper
  12. *
  13. * This library forms the socket for run-time loadable loadimage plugins.
  14. */
  15. #include "config.h"
  16. #include <common/const.h>
  17. #include <gvc/gvplugin_loadimage.h>
  18. #include <gvc/gvcint.h>
  19. #include <gvc/gvcproc.h>
  20. /* for agerr() */
  21. #include <cgraph/cgraph.h>
  22. #include <stdbool.h>
  23. #include <stddef.h>
  24. #include <util/agxbuf.h>
  25. static int gvloadimage_select(GVJ_t * job, char *str)
  26. {
  27. gvplugin_available_t *plugin;
  28. gvplugin_installed_t *typeptr;
  29. plugin = gvplugin_load(job->gvc, API_loadimage, str, NULL);
  30. if (plugin) {
  31. typeptr = plugin->typeptr;
  32. job->loadimage.engine = typeptr->engine;
  33. job->loadimage.id = typeptr->id;
  34. return GVRENDER_PLUGIN;
  35. }
  36. return NO_SUPPORT;
  37. }
  38. void gvloadimage(GVJ_t * job, usershape_t *us, boxf b, bool filled, const char *target)
  39. {
  40. gvloadimage_engine_t *gvli;
  41. agxbuf type_buf = {0};
  42. assert(job);
  43. assert(us);
  44. assert(us->name);
  45. assert(us->name[0]);
  46. agxbprint(&type_buf, "%s:%s", us->stringtype, target);
  47. char *type = agxbuse(&type_buf);
  48. if (gvloadimage_select(job, type) == NO_SUPPORT)
  49. agwarningf("No loadimage plugin for \"%s\"\n", type);
  50. if ((gvli = job->loadimage.engine) && gvli->loadimage)
  51. gvli->loadimage(job, us, b, filled);
  52. agxbfree(&type_buf);
  53. }