Graphviz  2.41.20171026.1811
gv_java_init.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 #include <stdio.h>
15 #include <stdlib.h>
16 #include "gvc.h"
17 #include "gvplugin.h"
18 #include "gvcjob.h"
19 #include "gvcint.h"
20 
21 typedef struct {
22  char* data;
23  int sz; /* buffer size */
24  int len; /* length of array */
25 } BA;
26 
27 static size_t gv_string_writer(GVJ_t *job, const char *s, size_t len)
28 {
29  BA* bap = (BA*)(job->output_file);
30 /* fprintf (stderr, "newlen %ld data %p sz %d len %d\n", len, bap->data,bap->sz, bap->len); */
31  int newlen = bap->len + len;
32  if (newlen > bap->sz) {
33  bap->sz *= 2;
34  if (newlen > bap->sz)
35  bap->sz = 2*newlen;
36  bap->data = (char*)realloc(bap->data, bap->sz);
37  }
38  memcpy (bap->data+bap->len, s, len);
39  bap->len = newlen;
40  return len;
41 }
42 
44 {
45  gvc->write_fn = gv_string_writer;
46 }
47 
48 static size_t gv_channel_writer(GVJ_t *job, const char *s, size_t len)
49 {
50  return len;
51 }
52 
54 {
55  gvc->write_fn = gv_channel_writer;
56 }
57 
void gv_writer_reset(GVC_t *gvc)
Definition: gv_dummy_init.c:5
Definition: gvcjob.h:271
void gv_string_writer_init(GVC_t *gvc)
Definition: gv_dummy_init.c:3
char * data
Definition: gv.cpp:876
Definition: gvcint.h:70
Definition: grammar.c:79
#define NULL
Definition: logic.h:39
GVC_t * gvc
Definition: htmlparse.c:87
int len
Definition: gv.cpp:878
Definition: gv.cpp:875
void gv_channel_writer_init(GVC_t *gvc)
Definition: gv_dummy_init.c:4
FILE * output_file
Definition: gvcjob.h:286
Definition: legal.c:60
int sz
Definition: gv.cpp:877
size_t(* write_fn)(GVJ_t *job, const char *s, size_t len)
Definition: gvcint.h:92