Graphviz  2.39.20141222.0545
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 #ifdef HAVE_CONFIG_H
23 #include "config.h"
24 #endif
25 
26 #include <stdlib.h>
27 
28 #include "builddate.h"
29 #include "types.h"
30 #include "gvplugin.h"
31 #include "gvcjob.h"
32 #include "gvcint.h"
33 #include "gvcproc.h"
34 #include "gvc.h"
35 
36 /* from common/utils.c */
37 extern void *zmalloc(size_t);
38 
39 /* from common/textspan.c */
40 extern void textfont_dict_close(GVC_t *gvc);
41 
42 /* from common/emit.c */
43 extern void emit_once_reset(void);
44 
45 /* from common/globals.c */
46 extern int graphviz_errors;
47 
48 static char *LibInfo[] = {
49  "graphviz", /* Program */
50  PACKAGE_VERSION, /* Version */
51  BUILDDATE /* Build Date */
52 };
53 
54 GVC_t *gvNEWcontext(const lt_symlist_t *builtins, int demand_loading)
55 {
56  GVC_t *gvc = zmalloc(sizeof(GVC_t));
57 
58  if (gvc) {
59  gvc->common.info = LibInfo;
60  gvc->common.errorfn = agerrorf;
61  gvc->common.builtins = builtins;
62  gvc->common.demand_loading = demand_loading;
63  }
64  return gvc;
65 }
66 
68 {
69  if (gvc->active_jobs)
71 }
72 
73 
75 {
76  GVG_t *gvg, *gvg_next;
77  gvplugin_package_t *package, *package_next;
78 
80  gvg_next = gvc->gvgs;
81  while ((gvg = gvg_next)) {
82  gvg_next = gvg->next;
83  free(gvg);
84  }
85  package_next = gvc->packages;
86  while ((package = package_next)) {
87  package_next = package->next;
88  free(package->path);
89  free(package->name);
90  free(package);
91  }
92  gvjobs_delete(gvc);
93  if (gvc->config_path)
94  free(gvc->config_path);
95  if (gvc->input_filenames)
96  free(gvc->input_filenames);
98  free(gvc);
99  return (graphviz_errors + agerrors());
100 }
gvplugin_package_t * next
Definition: gvcint.h:44
void * zmalloc(size_t)
Definition: memory.c:22
int gvFreeContext(GVC_t *gvc)
Definition: gvcontext.c:74
void gvFinalize(GVC_t *gvc)
Definition: gvcontext.c:67
int demand_loading
Definition: gvcommon.h:34
char ** input_filenames
Definition: gvcint.h:77
const lt_symlist_t * builtins
Definition: gvcommon.h:33
GVG_t * next
Definition: gvcint.h:61
void free()
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
void textfont_dict_close(GVC_t *gvc)
Definition: textspan.c:286
GVC_t * gvc
Definition: htmlparse.c:87
GVC_t * gvNEWcontext(const lt_symlist_t *builtins, int demand_loading)
Definition: gvcontext.c:54
GVCOMMON_t common
Definition: gvcint.h:71
void gvrender_end_job(GVJ_t *job)
Definition: gvrender.c:125
int agerrors()
Definition: agerror.c:166
void gvjobs_delete(GVC_t *gvc)
Definition: gvjobs.c:137
char * config_path
Definition: gvcint.h:73
int graphviz_errors
Definition: globals.h:78
void emit_once_reset(void)
Definition: emit.c:3543
void agerrorf(const char *fmt,...)
Definition: agerror.c:150