Graphviz  2.35.20130930.0449
gvloadimage.c
Go to the documentation of this file.
1 /* $Id$ $Revision$ */
2 /* vim:set shiftwidth=4 ts=8: */
3 
4 /*************************************************************************
5  * Copyright (c) 2011 AT&T Intellectual Property
6  * All rights reserved. This program and the accompanying materials
7  * are made available under the terms of the Eclipse Public License v1.0
8  * which accompanies this distribution, and is available at
9  * http://www.eclipse.org/legal/epl-v10.html
10  *
11  * Contributors: See CVS logs. Details at http://www.graphviz.org/
12  *************************************************************************/
13 
14 /*
15  * graphics code generator wrapper
16  *
17  * This library forms the socket for run-time loadable loadimage plugins.
18  */
19 
20 #ifdef HAVE_CONFIG_H
21 #include "config.h"
22 #endif
23 
24 #include <string.h>
25 
26 #include "const.h"
27 #include "gvplugin_loadimage.h"
28 #include "gvcint.h"
29 #include "gvcproc.h"
30 
31 /* for agerr() */
32 #if WITH_CGRAPH
33 #include "cgraph.h"
34 #else
35 #include "graph.h"
36 #endif
37 
38 static int gvloadimage_select(GVJ_t * job, char *str)
39 {
40  gvplugin_available_t *plugin;
41  gvplugin_installed_t *typeptr;
42 
43  plugin = gvplugin_load(job->gvc, API_loadimage, str);
44  if (plugin) {
45  typeptr = plugin->typeptr;
46  job->loadimage.engine = (gvloadimage_engine_t *) (typeptr->engine);
47  job->loadimage.id = typeptr->id;
48  return GVRENDER_PLUGIN;
49  }
50  return NO_SUPPORT;
51 }
52 
53 void gvloadimage(GVJ_t * job, usershape_t *us, boxf b, boolean filled, const char *target)
54 {
56  char type[SMALLBUF];
57 
58  strcpy(type, us->stringtype);
59  strcat(type, ":");
60  strcat(type, target);
61 
62  if (gvloadimage_select(job, type) == NO_SUPPORT)
63  agerr (AGWARN, "No loadimage plugin for \"%s\"\n", type);
64 
65  if ((gvli = job->loadimage.engine) && gvli->loadimage)
66  gvli->loadimage(job, us, b, filled);
67 }