| 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 |
/* |
| 12 |
* graphics code generator wrapper |
| 13 |
* |
| 14 |
* This library forms the socket for run-time loadable loadimage plugins. |
| 15 |
*/ |
| 16 |
|
| 17 |
#include "config.h" |
| 18 |
#include <common/const.h> |
| 19 |
#include <gvc/gvplugin_loadimage.h> |
| 20 |
#include <gvc/gvcint.h> |
| 21 |
#include <gvc/gvcproc.h> |
| 22 |
|
| 23 |
/* for agerr() */ |
| 24 |
#include <cgraph/cgraph.h> |
| 25 |
#include <stdbool.h> |
| 26 |
#include <stddef.h> |
| 27 |
#include <util/agxbuf.h> |
| 28 |
|
| 29 |
static int gvloadimage_select(GVJ_t * job, char *str) |
| 30 |
{ |
| 31 |
gvplugin_available_t *plugin; |
| 32 |
gvplugin_installed_t *typeptr; |
| 33 |
|
| 34 |
plugin = gvplugin_load(job->gvc, API_loadimage, str, NULL); |
| 35 |
if (plugin) { |
| 36 |
typeptr = plugin->typeptr; |
| 37 |
job->loadimage.engine = typeptr->engine; |
| 38 |
job->loadimage.id = typeptr->id; |
| 39 |
return GVRENDER_PLUGIN; |
| 40 |
} |
| 41 |
return NO_SUPPORT; |
| 42 |
} |
| 43 |
|
| 44 |
void gvloadimage(GVJ_t * job, usershape_t *us, boxf b, bool filled, const char *target) |
| 45 |
{ |
| 46 |
gvloadimage_engine_t *gvli; |
| 47 |
agxbuf type_buf = {0}; |
| 48 |
|
| 49 |
assert(job); |
| 50 |
assert(us); |
| 51 |
assert(us->name); |
| 52 |
assert(us->name[0]); |
| 53 |
|
| 54 |
agxbprint(&type_buf, "%s:%s", us->stringtype, target); |
| 55 |
char *type = agxbuse(&type_buf); |
| 56 |
|
| 57 |
if (gvloadimage_select(job, type) == NO_SUPPORT) |
| 58 |
agwarningf("No loadimage plugin for \"%s\"\n", type); |
| 59 |
|
| 60 |
if ((gvli = job->loadimage.engine) && gvli->loadimage) |
| 61 |
gvli->loadimage(job, us, b, filled); |
| 62 |
|
| 63 |
agxbfree(&type_buf); |
| 64 |
} |