Graphviz  2.41.20170921.2350
gvcontext.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  A gvcontext is a single instance of a GVC_t data structure providing
16  for a set of plugins for processing one graph at a time, and a job
17  description provividing for a sequence of graph jobs.
18 
19  Sometime in the future it may become the basis for a thread.
20  */
21 
22 #include "config.h"
23 
24 #include <stdlib.h>
25 
26 #include "builddate.h"
27 #include "types.h"
28 #include "gvplugin.h"
29 #include "gvcjob.h"
30 #include "gvcint.h"
31 #include "gvcproc.h"
32 #include "gvc.h"
33 
34 /* from common/utils.c */
35 extern void *zmalloc(size_t);
36 
37 /* from common/textspan.c */
38 extern void textfont_dict_close(GVC_t *gvc);
39 
40 /* from common/emit.c */
41 extern void emit_once_reset(void);
42 
43 /* from common/globals.c */
44 extern int graphviz_errors;
45 
46 static char *LibInfo[] = {
47  "graphviz", /* Program */
48  PACKAGE_VERSION, /* Version */
49  BUILDDATE /* Build Date */
50 };
51 
52 GVC_t *gvNEWcontext(const lt_symlist_t *builtins, int demand_loading)
53 {
54  GVC_t *gvc = zmalloc(sizeof(GVC_t));
55 
56  if (gvc) {
57  gvc->common.info = LibInfo;
58  gvc->common.errorfn = agerrorf;
59  gvc->common.builtins = builtins;
60  gvc->common.demand_loading = demand_loading;
61  }
62  return gvc;
63 }
64 
66 {
67  if (gvc->active_jobs)
69 }
70 
71 
73 {
74  GVG_t *gvg, *gvg_next;
75  gvplugin_package_t *package, *package_next;
76  gvplugin_available_t *api, *api_next;
77 
78 #define ELEM(x) +1
79  /* See gvcext.h for APIS and gvcint.h for an example usage of "+1"
80  to get the number of APIs. */
81  unsigned int num_apis = APIS, i;
82 #undef ELEM
83 
85  gvg_next = gvc->gvgs;
86  while ((gvg = gvg_next)) {
87  gvg_next = gvg->next;
88  free(gvg);
89  }
90  package_next = gvc->packages;
91  while ((package = package_next)) {
92  package_next = package->next;
93  free(package->path);
94  free(package->name);
95  free(package);
96  }
97  gvjobs_delete(gvc);
98  if (gvc->config_path)
99  free(gvc->config_path);
100  if (gvc->input_filenames)
101  free(gvc->input_filenames);
102  textfont_dict_close(gvc);
103  for (i = 0; i != num_apis; ++i) {
104  for (api = gvc->apis[i]; api != NULL; api = api_next) {
105  api_next = api->next;
106  free(api);
107  }
108  }
109  free(gvc);
110  return (graphviz_errors + agerrors());
111 }
112 
114 {
115  GVC_t *gvc = zmalloc(sizeof(GVC_t));
116 
117  gvc->common = gvc0->common;
118  memcpy (&gvc->apis, &gvc0->apis, sizeof(gvc->apis));
119  memcpy (&gvc->api, &gvc0->api, sizeof(gvc->api));
120  gvc->packages = gvc0->packages;
121 
122  return gvc;
123 }
124 
126 {
127  gvjobs_delete(gvc);
128  free(gvc);
129 }
130 
void * zmalloc(size_t nbytes)
Definition: memory.c:20
gvplugin_package_t * next
Definition: gvcint.h:44
#define APIS
Definition: gvcext.h:28
gvplugin_available_t * next
Definition: gvcint.h:50
void gvFreeCloneGVC(GVC_t *)
Definition: gvcontext.c:125
EXTERN int graphviz_errors
Definition: globals.h:69
int demand_loading
Definition: gvcommon.h:34
char ** input_filenames
Definition: gvcint.h:77
gvplugin_available_t * api[APIS]
Definition: gvcint.h:87
GVC_t * gvCloneGVC(GVC_t *)
Definition: gvcontext.c:113
const lt_symlist_t * builtins
Definition: gvcommon.h:33
void gvFinalize(GVC_t *gvc)
Definition: gvcontext.c:65
GVG_t * next
Definition: gvcint.h:61
void textfont_dict_close(GVC_t *gvc)
Definition: textspan.c:286
gvplugin_package_t * packages
Definition: gvcint.h:89
Definition: gvcint.h:70
GVJ_t * active_jobs
Definition: gvcint.h:112
char ** info
Definition: gvcommon.h:22
GVG_t * gvgs
Definition: gvcint.h:80
Definition: gvcint.h:59
void(* errorfn)(const char *fmt,...)
Definition: gvcommon.h:26
#define NULL
Definition: logic.h:39
GVC_t * gvc
Definition: htmlparse.c:87
void emit_once_reset(void)
Definition: emit.c:3632
int gvFreeContext(GVC_t *gvc)
Definition: gvcontext.c:72
GVCOMMON_t common
Definition: gvcint.h:71
gvplugin_available_t * apis[APIS]
Definition: gvcint.h:86
void gvrender_end_job(GVJ_t *job)
Definition: gvrender.c:123
int agerrors()
Definition: agerror.c:170
GVC_t * gvNEWcontext(const lt_symlist_t *builtins, int demand_loading)
Definition: gvcontext.c:52
void gvjobs_delete(GVC_t *gvc)
Definition: gvjobs.c:135
char * config_path
Definition: gvcint.h:73
void agerrorf(const char *fmt,...)
Definition: agerror.c:152