Graphviz  2.39.20141219.0545
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 #include "cgraph.h"
33 
34 static int gvloadimage_select(GVJ_t * job, char *str)
35 {
36  gvplugin_available_t *plugin;
37  gvplugin_installed_t *typeptr;
38 
39  plugin = gvplugin_load(job->gvc, API_loadimage, str);
40  if (plugin) {
41  typeptr = plugin->typeptr;
42  job->loadimage.engine = (gvloadimage_engine_t *) (typeptr->engine);
43  job->loadimage.id = typeptr->id;
44  return GVRENDER_PLUGIN;
45  }
46  return NO_SUPPORT;
47 }
48 
49 void gvloadimage(GVJ_t * job, usershape_t *us, boxf b, boolean filled, const char *target)
50 {
52  char type[SMALLBUF];
53 
54  assert(job);
55  assert(us);
56  assert(us->name);
57  assert(us->name[0]);
58 
59  strcpy(type, us->stringtype);
60  strcat(type, ":");
61  strcat(type, target);
62 
63  if (gvloadimage_select(job, type) == NO_SUPPORT)
64  agerr (AGWARN, "No loadimage plugin for \"%s\"\n", type);
65 
66  if ((gvli = job->loadimage.engine) && gvli->loadimage)
67  gvli->loadimage(job, us, b, filled);
68 }
#define SMALLBUF
Definition: const.h:17
char * stringtype
Definition: usershape.h:47
#define assert(x)
Definition: cghdr.h:48
#define GVRENDER_PLUGIN
Definition: const.h:150
gvplugin_active_loadimage_t loadimage
Definition: gvcjob.h:296
int agerr(agerrlevel_t level, const char *fmt,...)
Definition: agerror.c:142
gvplugin_available_t * gvplugin_load(GVC_t *gvc, api_t api, const char *type)
Definition: gvplugin.c:250
Definition: gvcjob.h:271
#define NO_SUPPORT
Definition: const.h:151
Definition: cgraph.h:389
gvloadimage_engine_t * engine
Definition: gvcjob.h:145
GVC_t * gvc
Definition: gvcjob.h:272
void(* loadimage)(GVJ_t *job, usershape_t *us, boxf b, boolean filled)
void gvloadimage(GVJ_t *job, usershape_t *us, boxf b, boolean filled, const char *target)
Definition: gvloadimage.c:49
agxbuf * str
Definition: htmlparse.c:85
gvplugin_installed_t * typeptr
Definition: gvcint.h:55
const char * name
Definition: usershape.h:41
Definition: geom.h:37