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#include "config.h"
21
22#include <string.h>
23
24#include "const.h"
25#include "gvplugin_loadimage.h"
26#include "gvcint.h"
27#include "gvcproc.h"
28
29/* for agerr() */
30#include "cgraph.h"
31
32static int gvloadimage_select(GVJ_t * job, char *str)
33{
34 gvplugin_available_t *plugin;
35 gvplugin_installed_t *typeptr;
36
37 plugin = gvplugin_load(job->gvc, API_loadimage, str);
38 if (plugin) {
39 typeptr = plugin->typeptr;
40 job->loadimage.engine = (gvloadimage_engine_t *) (typeptr->engine);
41 job->loadimage.id = typeptr->id;
42 return GVRENDER_PLUGIN;
43 }
44 return NO_SUPPORT;
45}
46
47void gvloadimage(GVJ_t * job, usershape_t *us, boxf b, boolean filled, const char *target)
48{
49 gvloadimage_engine_t *gvli;
50 char type[SMALLBUF];
51
52 assert(job);
53 assert(us);
54 assert(us->name);
55 assert(us->name[0]);
56
57 strcpy(type, us->stringtype);
58 strcat(type, ":");
59 strcat(type, target);
60
61 if (gvloadimage_select(job, type) == NO_SUPPORT)
62 agerr (AGWARN, "No loadimage plugin for \"%s\"\n", type);
63
64 if ((gvli = job->loadimage.engine) && gvli->loadimage)
65 gvli->loadimage(job, us, b, filled);
66}
67