Graphviz  2.29.20120524.0446
lib/gvc/gvloadimage.c
Go to the documentation of this file.
00001 /* $Id$ $Revision$ */
00002 /* vim:set shiftwidth=4 ts=8: */
00003 
00004 /*************************************************************************
00005  * Copyright (c) 2011 AT&T Intellectual Property 
00006  * All rights reserved. This program and the accompanying materials
00007  * are made available under the terms of the Eclipse Public License v1.0
00008  * which accompanies this distribution, and is available at
00009  * http://www.eclipse.org/legal/epl-v10.html
00010  *
00011  * Contributors: See CVS logs. Details at http://www.graphviz.org/
00012  *************************************************************************/
00013 
00014 /*
00015  *  graphics code generator wrapper
00016  *
00017  *  This library forms the socket for run-time loadable loadimage plugins.  
00018  */
00019 
00020 #ifdef HAVE_CONFIG_H
00021 #include "config.h"
00022 #endif
00023 
00024 #include <string.h>
00025 
00026 #include "const.h"
00027 #include "gvplugin_loadimage.h"
00028 #include "gvcint.h"
00029 #include "gvcproc.h"
00030 
00031 /* for agerr() */
00032 #if WITH_CGRAPH
00033 #include "cgraph.h"
00034 #else
00035 #include "graph.h"
00036 #endif
00037 
00038 static int gvloadimage_select(GVJ_t * job, char *str)
00039 {
00040     gvplugin_available_t *plugin;
00041     gvplugin_installed_t *typeptr;
00042 
00043     plugin = gvplugin_load(job->gvc, API_loadimage, str);
00044     if (plugin) {
00045         typeptr = plugin->typeptr;
00046         job->loadimage.engine = (gvloadimage_engine_t *) (typeptr->engine);
00047         job->loadimage.id = typeptr->id;
00048         return GVRENDER_PLUGIN;
00049     }
00050     return NO_SUPPORT;
00051 }
00052 
00053 void gvloadimage(GVJ_t * job, usershape_t *us, boxf b, boolean filled, const char *target)
00054 {
00055     gvloadimage_engine_t *gvli;
00056     char type[SMALLBUF];
00057 
00058     strcpy(type, us->stringtype);
00059     strcat(type, ":");
00060     strcat(type, target);
00061 
00062     if (gvloadimage_select(job, type) == NO_SUPPORT)
00063             agerr (AGWARN, "No loadimage plugin for \"%s\"\n", type);
00064 
00065     if ((gvli = job->loadimage.engine) && gvli->loadimage)
00066         gvli->loadimage(job, us, b, filled);
00067 }