Partial fix for https://gitlab.com/graphviz/graphviz/-/issues/2178.
#include "config.h"
#include <cgraph/cgraph.h>
+#include <cgraph/exit.h>
#include <gvc/gvc.h>
#include <gvc/gvio.h>
gvRenderJobs(Gvc, G);
/* Note that we don't call gvFinalize() so that we don't start event-driven
* devices like -Tgtk or -Txlib */
- exit (gvFreeContext(Gvc));
+ graphviz_exit(gvFreeContext(Gvc));
}
#ifndef NO_FPERR
{
fprintf(stderr, "caught SIGFPE %d\n", s);
/* signal (s, SIG_DFL); raise (s); */
- exit(1);
+ graphviz_exit(1);
}
#endif
#endif
#include <sys/types.h>
#include <sys/stat.h>
+#include <cgraph/exit.h>
+
static char *shellpath;
static char *buildpath (char *);
if (!shellpath || !(path = buildpath ("lefty"))) {
if (!GetModuleFileName (hInstance, cmd, 256) ||
!(s = strrchr (cmd, '\\')))
- exit (1);
+ graphviz_exit(1);
*s = 0;
shellpath = &cmd[0];
if (!(path = buildpath ("lefty")))
- exit (1);
+ graphviz_exit(1);
}
argv = CommandLineToArgvW(lpCmdLine, &argc);
if (argc == 1 && strcmp(argv[0], "-?") == 0) {
fprintf(stderr, "usage: dotty [-V] [-lm (sync|async)] [-el (0|1)] <filename>\n");
- exit(0);
+ graphviz_exit(0);
}
if (lpCmdLine[0] == 0)
snprintf(cmd, sizeof(cmd), "%s -e \"load('dotty.lefty');%sdotty.init();"
&si, // Pointer to STARTUPINFO structure.
&pi // Pointer to PROCESS_INFORMATION structure.
);
- exit (0);
+ graphviz_exit(0);
}
#define PATHDEL '\\'
#include <cgraph/cgraph.h>
#include <cgraph/agxbuf.h>
+#include <cgraph/exit.h>
#include <cgraph/unreachable.h>
#include <ingraphs/ingraphs.h>
#include <common/pointset.h>
fp = fopen(name, "w");
if (!fp) {
fprintf(stderr, "%s: could not open file %s for writing\n", cmd, name);
- exit(EXIT_FAILURE);
+ graphviz_exit(EXIT_FAILURE);
}
return fp;
}
fprintf(stderr, " parallel but is on the opposite ends of the shared point (around 180 degree).\n");
fprintf(stderr, " -v : verbose\n");
fprintf(stderr, " -o fname : write output to file fname (stdout)\n");
- exit(eval);
+ graphviz_exit(eval);
}
/* checkG:
{
fprintf(stderr, "Usage: %s <options> graphfile\n", cmd);
fputs (usestr, stderr);
- exit(eval);
+ graphviz_exit(eval);
}
static FILE *openFile(const char *name, const char* cmd)
fp = fopen(name, "w");
if (!fp) {
fprintf(stderr, "%s: could not open file %s for writing\n", cmd, name);
- exit(-1);
+ graphviz_exit(-1);
}
return fp;
}
{
fprintf(stderr, "Usage: %s <options> graphfile\n", cmd);
fputs (usestr, stderr);
- exit(eval);
+ graphviz_exit(eval);
}
static FILE *openFile(const char *name, const char* cmd)
fp = fopen(name, "w");
if (!fp) {
fprintf(stderr, "%s: could not open file %s for writing\n", cmd, name);
- exit(-1);
+ graphviz_exit(-1);
}
return (fp);
}
/* Lefteris Koutsofios - AT&T Labs Research */
+#include <cgraph/exit.h>
#include "common.h"
#include "g.h"
#include "mem.h"
fn = "closeview";
if (!wo || !(fo = Tfinds (wo, fn)) || Tgettype (fo) != T_CODE)
if (!(fo = Tfinds (root, fn)) || Tgettype (fo) != T_CODE)
- exit (0);
+ graphviz_exit(0);
fm = Mpushmark (fo);
to = Ttable (2);
Mpushmark (to);
#define LEFTYVERSION "10 Mar 2005"
#include "builddate.h"
+#include <cgraph/exit.h>
#include "common.h"
#include "g.h"
#include "code.h"
term ();
#endif
printusage ();
- exit (0);
+ graphviz_exit(0);
}
#endif
{
fprintf (stderr, "Usage: lefty [options] [file]\n");
fputs (usestr, stderr);
- exit (eval);
+ graphviz_exit(eval);
}
static void processstr (char *buf) {
fclose(fp);
if ((fp = fopen (argv[0], "r")) == NULL) {
fprintf (stderr, "cannot open input file: %s\n", argv[0]);
- exit(2);
+ graphviz_exit(2);
}
}
argv++, argc--;
*************************************************************************/
+#include <cgraph/exit.h>
#include "common.h"
#include "g.h"
#include "gcommon.h"
widget = findwidget((unsigned long) w, G_VIEWWIDGET);
if (!widget)
- exit(0);
+ graphviz_exit(0);
gev.type = 0, gev.code = 0, gev.data = 0;
gev.wi = widget - &Gwidgets[0];
if (WVU->func)
(*WVU->func) (&gev);
else
- exit(0);
+ graphviz_exit(0);
}
/* Lefteris Koutsofios - AT&T Labs Research */
#include <stdbool.h>
+
+#include <cgraph/exit.h>
#include "common.h"
#include "g.h"
#include "gcommon.h"
switch (waitflag) {
case TRUE:
if (!GetMessage(&msg, (HWND) NULL, (UINT) NULL, (UINT) NULL))
- exit (msg.wParam);
+ graphviz_exit(msg.wParam);
TranslateMessage(&msg);
DispatchMessage(&msg);
if (mode == G_ONEEVENT)
case FALSE:
while (PeekMessage(&msg, (HWND) 0, (UINT) 0, (UINT) 0, PM_REMOVE)) {
if (msg.message == WM_QUIT)
- exit (msg.wParam);
+ graphviz_exit(msg.wParam);
TranslateMessage(&msg);
DispatchMessage(&msg);
if (mode == G_ONEEVENT)
break;
case WM_CLOSE:
if (!widget)
- exit (0);
+ graphviz_exit(0);
if (WVU->closing)
DestroyWindow (hwnd);
if (Gnocallbacks)
- exit (0);
+ graphviz_exit(0);
gev.type = 0, gev.code = 0, gev.data = 0;
gev.wi = widget - &Gwidgets[0];
if (WVU->func)
(*WVU->func) (&gev);
else
- exit (0);
+ graphviz_exit(0);
break;
case WM_PALETTECHANGED:
palettechanged = (HWND) wparam;
/* Lefteris Koutsofios - AT&T Labs Research */
+#include <cgraph/exit.h>
#include "common.h"
#include "g.h"
#include "gcommon.h"
widget = findwidget ((unsigned long) w, G_VIEWWIDGET);
if (!widget)
- exit (0);
+ graphviz_exit(0);
gev.type = 0, gev.code = 0, gev.data = 0;
gev.wi = widget - &Gwidgets[0];
if (WVU->func)
(*WVU->func) (&gev);
else
- exit (0);
+ graphviz_exit(0);
}
#include <sys/types.h>
#include <sys/stat.h>
+#include <cgraph/exit.h>
+
static char *shellpath;
static char *buildpath (char *);
if (!shellpath || !(path = buildpath ("lefty"))) {
if (!GetModuleFileName (hInstance, cmd, 256) ||
!(s = strrchr (cmd, '\\')))
- exit (1);
+ graphviz_exit(1);
*s = 0;
shellpath = &cmd[0];
if (!(path = buildpath ("lefty")))
- exit (1);
+ graphviz_exit(1);
}
argv = CommandLineToArgvW(pCmdLine, &argc);
if (argc == 1 && wcscmp(argv[0], L"-?") == 0) {
fprintf(stderr, "usage: lneato [-V] [-lm (sync|async)] [-el (0|1)] <filename>\n");
- exit(0);
+ graphviz_exit(0);
}
if (pCmdLine[0] == 0)
snprintf(cmd, sizeof(cmd), "%s -e \"load('dotty.lefty');"
pCmdLine);
handle = WinExec (cmd, SW_SHOW);
- exit (0);
+ graphviz_exit(0);
}
#define PATHDEL '\\'
#include "gui.h"
#include "viewport.h"
#include "gltemplate.h"
+#include <cgraph/exit.h>
#include <glcomp/glutils.h>
#include "glexpose.h"
#include "glmotion.h"
GDK_GL_MODE_DEPTH);
if (glconfig == NULL) {
g_print("*** No appropriate OpenGL-capable visual found.\n");
- exit(1);
+ graphviz_exit(1);
}
}
* Contributors: Details at https://graphviz.org
*************************************************************************/
+#include <cgraph/exit.h>
+
#include "glutrender.h"
#include "viewport.h"
#include "arcball.h"
static void cb_keyboard(unsigned char key, int x, int y)
{
if (key==27) /*ESC*/
- exit (1);
+ graphviz_exit(1);
if(key=='3')
switch2D3D(NULL, 0, 0,glMouseLeftButton);
if(key=='c')
else
{
printf("smyrna cannot initialize requested screen resolution and rate!\n");
- exit(-1);
+ graphviz_exit(-1);
}
#include "support.h"
#include "menucallbacks.h"
#include "gltemplate.h"
+#include <cgraph/exit.h>
#include <common/memory.h>
#include "gvprpipe.h"
#include "frmobjectui.h"
static void usage(int v)
{
fputs(useString, stdout);
- exit(v);
+ graphviz_exit(v);
}
static char *Info[] = {
case 'V':
fprintf(stderr, "%s version %s (%s)\n",
Info[0], Info[1], Info[2]);
- exit (0);
+ graphviz_exit(0);
break;
case '?':
if (optopt == '\0')
#include "arcball.h"
#include "hotkeymap.h"
#include "topviewfuncs.h"
+#include <cgraph/exit.h>
#include <cgraph/strcasecmp.h>
fprintf(stderr,
"default attributes template graph file \"%s\" not found\n",
view->template_file);
- exit(-1);
+ graphviz_exit(-1);
}
view->systemGraphs.def_attrs = agread(input_file, NULL);
fclose (input_file);
fprintf(stderr,
"could not load default attributes template graph file \"%s\"\n",
view->template_file);
- exit(-1);
+ graphviz_exit(-1);
}
if (!path)
path = smyrnaPath("attr_widgets.dot");
input_file2 = fopen(path, "rb");
if (!input_file2) {
fprintf(stderr, "default attributes template graph file \"%s\" not found\n",smyrnaPath("attr_widgets.dot"));
- exit(-1);
+ graphviz_exit(-1);
}
view->systemGraphs.attrs_widgets = agread(input_file2, NULL);
fclose (input_file2);
if (!(view->systemGraphs.attrs_widgets )) {
fprintf(stderr,"could not load default attribute widgets graph file \"%s\"\n",smyrnaPath("attr_widgets.dot"));
- exit(-1);
+ graphviz_exit(-1);
}
//init graphs
view->g = NULL; //no graph, gl screen should check it
#include <stdlib.h>
#include <cgraph/cgraph.h>
+#include <cgraph/exit.h>
+
typedef struct {
Agrec_t h;
int mark;
static void usage(int v)
{
fprintf(stderr, useString, cmd);
- exit(v);
+ graphviz_exit(v);
}
static FILE *openFile(const char *name, const char *mode)
modestr = "writing";
fprintf(stderr, "%s: could not open file %s for %s\n",
cmd, name, modestr);
- exit(-1);
+ graphviz_exit(-1);
}
return (fp);
}
if (Verbose)
fprintf(stderr, "Graph \"%s\" is undirected\n", graphName(g));
}
- exit(rv);
+ graphviz_exit(rv);
} else
- exit(-1);
+ graphviz_exit(-1);
}
#include <stdlib.h>
#include <cgraph/cgraph.h>
+#include <cgraph/exit.h>
typedef struct {
Agrec_t h;
if (!outf) {
fprintf(stderr, "Could not open %s for writing\n", name);
perror("bcomps");
- exit(1);
+ graphviz_exit(1);
}
agwrite(g, outf);
fclose(outf);
static void usage(int v)
{
printf("%s",useString);
- exit(v);
+ graphviz_exit(v);
}
static void split(char *name)
#include <cgraph/cgraph.h>
#include <cgraph/likely.h>
#include <cgraph/unreachable.h>
+#include <cgraph/exit.h>
static void *xmalloc(size_t size) {
void *p = malloc(size);
if (UNLIKELY(size > 0 && p == NULL)) {
fprintf(stderr, "ccomps: out of memory\n");
- exit(EXIT_FAILURE);
+ graphviz_exit(EXIT_FAILURE);
}
return p;
}
void *p = calloc(count, size);
if (UNLIKELY(count > 0 && size > 0 && p == NULL)) {
fprintf(stderr, "ccomps: out of memory\n");
- exit(EXIT_FAILURE);
+ graphviz_exit(EXIT_FAILURE);
}
return p;
}
void *p = realloc(ptr, size);
if (UNLIKELY(size > 0 && p == NULL)) {
fprintf(stderr, "ccomps: out of memory\n");
- exit(EXIT_FAILURE);
+ graphviz_exit(EXIT_FAILURE);
}
return p;
}
static void usage(int v)
{
printf("%s",useString);
- exit(v);
+ graphviz_exit(v);
}
static void split(char *name)
#include <stdlib.h>
#include "convert.h"
+#include <cgraph/exit.h>
#include <ingraphs/ingraphs.h>
typedef enum { Unset, ToGV, ToGXL } mode;
if (!fp) {
fprintf(stderr, "%s: could not open file %s for writing\n", CmdName, name);
perror(name);
- exit(1);
+ graphviz_exit(1);
}
return fp;
}
static void usage(int v)
{
fprintf(stderr, use, CmdName);
- exit(v);
+ graphviz_exit(v);
}
static char *cmdName(char *path)
else {
fprintf(stderr, "%s: option -%c unrecognized\n", CmdName,
optopt);
- exit(1);
+ graphviz_exit(1);
}
break;
default:
fprintf(stderr, "cvtgxl: unexpected error\n");
- exit(EXIT_FAILURE);
+ graphviz_exit(EXIT_FAILURE);
}
}
#else
fputs("cvtgxl: not configured for conversion from GXL to GV\n",
stderr);
- exit(1);
+ graphviz_exit(1);
#endif
}
- exit(0);
+ graphviz_exit(0);
}
#include <stdlib.h>
#include <math.h>
#include <cgraph/cgraph.h>
+#include <cgraph/exit.h>
#include <ingraphs/ingraphs.h>
#include <getopt.h>
static void usage(int v)
{
printf("%s",useString);
- exit(v);
+ graphviz_exit(v);
}
static void init(int argc, char *argv[])
}
free(Nodes);
free(Files);
- exit(code);
+ graphviz_exit(code);
}
#include <cgraph/cgraph.h>
#include <cgraph/cghdr.h>
+#include <cgraph/exit.h>
+
typedef struct {
Agrec_t h;
int dfs_mark;
static void usage(int v)
{
printf("%s",useString);
- exit(v);
+ graphviz_exit(v);
}
static void init(int argc, char *argv[])
break;
default:
fprintf(stderr, "gc: unexpected error\n");
- exit(EXIT_FAILURE);
+ graphviz_exit(EXIT_FAILURE);
}
}
argv += optind;
blk_t *bp = NEW(blk_t);
if (bp == 0) {
fprintf(stderr, "gc: Out of memory\n");
- exit(1);
+ graphviz_exit(1);
}
bp->prev = Stk.curblk;
bp->next = NULL;
bp->data = N_NEW(BIGBUF, Agnode_t *);
if (bp->data == 0) {
fprintf(stderr, "gc: Out of memory\n");
- exit(1);
+ graphviz_exit(1);
}
bp->endp = bp->data + BIGBUF;
Stk.curblk->next = bp;
#include <getopt.h>
+#include <cgraph/exit.h>
+
#define N_NEW(n,t) calloc((n),sizeof(t))
static int Verbose;
fprintf(stderr, "%s: could not open file %s for writing\n",
CmdName, name);
perror(name);
- exit(1);
+ graphviz_exit(1);
}
return fp;
}
static void usage(int v)
{
printf(useString, CmdName);
- exit(v);
+ graphviz_exit(v);
}
static char *cmdName(char *path)
fflush(outFile);
}
}
- exit(rv);
+ graphviz_exit(rv);
}
#include "convert.h"
#include <cgraph/agxbuf.h>
+#include <cgraph/exit.h>
#include <getopt.h>
#ifdef HAVE_EXPAT
#include <expat.h>
slist *sp = *stk;
if (!sp) {
fprintf(stderr, "PANIC: graphml2gv: empty element stack\n");
- exit(1);
+ graphviz_exit(1);
}
*stk = sp->next;
free(sp);
{
if (!stk) {
fprintf(stderr, "PANIC: graphml2gv: empty element stack\n");
- exit(1);
+ graphviz_exit(1);
}
return stk->buf;
}
if (GSP == STACK_DEPTH) {
fprintf(stderr, "graphml2gv: Too many (> %d) nestings of subgraphs\n",
STACK_DEPTH);
- exit(1);
+ graphviz_exit(1);
} else if (GSP == 0)
root = g;
G = Gstack[GSP++] = g;
Agraph_t *g;
if (GSP == 0) {
fprintf(stderr, "graphml2gv: Gstack underflow in graph parser\n");
- exit(1);
+ graphviz_exit(1);
}
g = Gstack[--GSP];
if (GSP > 0)
if (!fp) {
fprintf(stderr, "%s: could not open file %s for writing\n", CmdName, name);
perror(name);
- exit(1);
+ graphviz_exit(1);
}
return fp;
}
static void usage(int v)
{
fprintf(stderr, use, CmdName);
- exit(v);
+ graphviz_exit(v);
}
static char *cmdName(char *path)
fflush(outFile);
}
}
- exit(rv);
+ graphviz_exit(rv);
#else
fputs("cvtgxl: not configured for conversion from GXL to GV\n", stderr);
- exit(1);
+ graphviz_exit(1);
#endif
}
#include <getopt.h>
#include <cgraph/cgraph.h>
+#include <cgraph/exit.h>
#include <common/types.h>
#include <common/utils.h>
#include <ctype.h>
s = readPoint (s, xp, yp);
if (s == NULL) {
fprintf (stderr, "Illegal spline end: %s\n", s0);
- exit (1);
+ graphviz_exit(1);
}
*fp = 1;
return s;
fprintf(stderr, "%s: could not open file %s for writing\n",
CmdName, name);
perror(name);
- exit(1);
+ graphviz_exit(1);
}
return fp;
}
static void usage(int v)
{
printf(useString, CmdName);
- exit(v);
+ graphviz_exit(v);
}
static char *cmdName(char *cmd)
gv_to_gml(G, outFile);
fflush(outFile);
}
- exit(rv);
+ graphviz_exit(rv);
}
#include <assert.h>
#include <cgraph/cgraph.h>
+#include <cgraph/exit.h>
#include <stdlib.h>
typedef struct Agnodeinfo_t {
Agrec_t h;
static void usage(int v)
{
printf("%s",useString);
- exit(v);
+ graphviz_exit(v);
}
static void init(int argc, char *argv[])
break;
default:
fprintf(stderr, "gvcolor: unexpected error\n");
- exit(EXIT_FAILURE);
+ graphviz_exit(EXIT_FAILURE);
}
}
argv += optind;
if (agattr(g, AGNODE, "pos", 0) == NULL) {
fprintf(stderr,
"graph must be run through 'dot' before 'gvcolor'\n");
- exit(1);
+ graphviz_exit(1);
}
aginit(g, AGNODE, "nodeinfo", sizeof(Agnodeinfo_t), TRUE);
if (agattr(g, AGNODE, "style", 0) == NULL)
agclose(g);
}
- exit(0);
+ graphviz_exit(0);
}
#include <getopt.h>
#include "graph_generator.h"
+#include <cgraph/exit.h>
+
typedef enum { unknown, grid, circle, complete, completeb,
path, tree, torus, cylinder, mobius, randomg, randomt, ball,
sierpinski, hypercube, star, wheel, trimesh
fp = fopen(name, "w");
if (!fp) {
fprintf(stderr, "%s: could not open file %s for writing\n", cmd, name);
- exit(1);
+ graphviz_exit(1);
}
return fp;
}
static void usage(int v)
{
fprintf(v ? stderr : stdout, Usage, cmd);
- exit(v);
+ graphviz_exit(v);
}
static void errexit(int opt) {
}
fprintf(opts.outfile, "}\n");
- exit(0);
+ graphviz_exit(0);
}
#include <assert.h>
#include <gvc/gvc.h>
+#include <cgraph/exit.h>
#include <common/render.h>
#include <neatogen/neatoprocs.h>
#include <ingraphs/ingraphs.h>
static void usage(int v)
{
printf("%s",useString);
- exit(v);
+ graphviz_exit(v);
}
static FILE *openFile(const char *name)
fp = fopen(name, "w");
if (!fp) {
fprintf(stderr, "gvpack: could not open file %s for writing\n", name);
- exit(1);
+ graphviz_exit(1);
}
return (fp);
}
if (d != 2) {
fprintf(stderr, "Error: graph %s has dim = %d (!= 2)\n", agnameof(g),
d);
- exit(1);
+ graphviz_exit(1);
}
Ndim = GD_ndim(g) = 2;
init_node_edge(g);
else if (ret > 0)
fprintf(stderr, "gvpack does not support backgrounds as found in graph %s\n",
agnameof(g));
- exit(1);
+ graphviz_exit(1);
}
if (Concentrate) { /* check for edges without pos info */
for (n = agfstnode(g); n; n = agnxtnode(g, n)) {
else if (kind.directed != g->desc.directed) {
fprintf(stderr,
"Error: all graphs must be directed or undirected\n");
- exit(1);
+ graphviz_exit(1);
} else if (!agisstrict(g))
kind = g->desc;
init_graph(g, doPack, gvc);
gvc = gvContextPlugins(lt_preloaded_symbols, DEMAND_LOADING);
gs = readGraphs(&cnt, gvc);
if (cnt == 0)
- exit(0);
+ graphviz_exit(0);
/* pack graphs */
if (doPack) {
if (packGraphs(cnt, gs, 0, &pinfo)) {
fprintf(stderr, "gvpack: packing of graphs failed.\n");
- exit(1);
+ graphviz_exit(1);
}
}
attach_attrs(g);
}
agwrite(g, outfp);
- exit(0);
+ graphviz_exit(0);
}
#include <assert.h>
#include "convert.h"
#include <cgraph/agxbuf.h>
+#include <cgraph/exit.h>
#ifdef HAVE_EXPAT
#include <expat.h>
#include <ctype.h>
char *rv = calloc(nmemb, size);
if (rv == NULL) {
fprintf(stderr, "out of memory\n");
- exit(EXIT_FAILURE);
+ graphviz_exit(EXIT_FAILURE);
}
return rv;
}
slist *sp = *stk;
if (!sp) {
fprintf(stderr, "PANIC: gxl2gv: empty element stack\n");
- exit(1);
+ graphviz_exit(1);
}
*stk = sp->next;
free(sp);
{
if (!stk) {
fprintf(stderr, "PANIC: gxl2gv: empty element stack\n");
- exit(1);
+ graphviz_exit(1);
}
return stk->buf;
}
if (GSP == STACK_DEPTH) {
fprintf(stderr, "gxl2gv: Too many (> %d) nestings of subgraphs\n",
STACK_DEPTH);
- exit(1);
+ graphviz_exit(1);
} else if (GSP == 0)
root = g;
G = Gstack[GSP++] = g;
Agraph_t *g;
if (GSP == 0) {
fprintf(stderr, "gxl2gv: Gstack underflow in graph parser\n");
- exit(1);
+ graphviz_exit(1);
}
g = Gstack[--GSP];
if (GSP > 0)
if (udata == NULL) {
fprintf(stderr, "out of memory\n");
- exit(1);
+ graphviz_exit(1);
}
XML_SetUserData(parser, udata);
"%s at line %lu\n",
XML_ErrorString(XML_GetErrorCode(parser)),
XML_GetCurrentLineNumber(parser));
- exit(1);
+ graphviz_exit(1);
}
} while (!done);
XML_ParserFree(parser);
static void usage(int eval)
{
fprintf(stderr, useString, cmd);
- exit(eval);
+ graphviz_exit(eval);
}
static FILE *openF(char *fname, char *mode)
if (!f) {
fprintf(stderr, "Could not open %s for %s\n", fname,
((*mode == 'r') ? "reading" : "writing"));
- exit(1);
+ graphviz_exit(1);
}
return f;
}
if (!A) {
fprintf(stderr, "cannot import from file %s\n", pv.infile);
- exit(1);
+ graphviz_exit(1);
}
if (pv.undirected) {
#include "config.h"
#include <cgraph/cgraph.h>
+#include <cgraph/exit.h>
#include <ingraphs/ingraphs.h>
#include <stdbool.h>
#include <stdio.h>
static void usage(int v)
{
printf("%s",useString);
- exit(v);
+ graphviz_exit(v);
}
static void init(int argc, char *argv[])
break;
default:
fprintf(stderr, "nop: unexpected error\n");
- exit(EXIT_FAILURE);
+ graphviz_exit(EXIT_FAILURE);
}
}
argv += optind;
#include <unistd.h>
#endif
#include <cgraph/cgraph.h>
+#include <cgraph/exit.h>
#include <ingraphs/ingraphs.h>
#include <getopt.h>
fp = fopen(name, "w");
if (!fp) {
fprintf(stderr, "gvpack: could not open file %s for writing\n", name);
- exit(1);
+ graphviz_exit(1);
}
return (fp);
}
static void usage(int v)
{
printf(useString, CmdName);
- exit(v);
+ graphviz_exit(v);
}
static void scanArgs(int argc, char **argv)
#include "config.h"
#include <cgraph/cgraph.h>
+#include <cgraph/exit.h>
#include <common/arith.h>
#include <common/types.h>
#include <common/utils.h>
blk_t *bp = NEW(blk_t);
if (bp == 0) {
fprintf(stderr, "%s: Out of memory\n", CmdName);
- exit(1);
+ graphviz_exit(1);
}
bp->prev = sp->Stk.curblk;
bp->next = NULL;
bp->data = N_NEW(BIGBUF, Agedge_t *);
if (bp->data == 0) {
fprintf(stderr, "%s: Out of memory\n", CmdName);
- exit(1);
+ graphviz_exit(1);
}
bp->endp = bp->data + BIGBUF;
sp->Stk.curblk->next = bp;
static void usage(int v)
{
printf(useString, CmdName);
- exit(v);
+ graphviz_exit(v);
}
static void init(int argc, char *argv[])
#include <unistd.h>
#endif
#include <cgraph/cgraph.h>
+#include <cgraph/exit.h>
#include <ingraphs/ingraphs.h>
#include <getopt.h>
static void usage(int v)
{
fprintf(stderr, useString, cmd);
- exit(v);
+ graphviz_exit(v);
}
static FILE *openFile(const char *name)
fp = fopen(name, "w");
if (!fp) {
fprintf(stderr, "%s: could not open file %s for writing\n", cmd, name);
- exit(-1);
+ graphviz_exit(-1);
}
return fp;
}
#include <gd.h>
#include <stdbool.h>
+#include <cgraph/exit.h>
+
static char *pstopng="gs -dNOPAUSE -sDEVICE=pngalpha -sOutputFile=- -q -";
static gdImagePtr imageLoad (char *filename)
ext = strrchr(filename, '.');
if (!ext) {
fprintf(stderr, "Filename \"%s\" has no file extension.\n", filename);
- exit(EX_USAGE);
+ graphviz_exit(EX_USAGE);
}
rc = stat(filename, &statbuf);
if (rc) {
fprintf(stderr, "Failed to stat \"%s\"\n", filename);
- exit(EX_NOINPUT);
+ graphviz_exit(EX_NOINPUT);
}
if (strcasecmp(ext, ".ps") == 0) {
ext = ".png";
free(tmp);
if (!f) {
fprintf(stderr, "Failed to open converted \"%s%s\"\n", filename, ext);
- exit(EX_NOINPUT);
+ graphviz_exit(EX_NOINPUT);
}
}
else {
f = fopen(filename, "rb");
if (!f) {
fprintf(stderr, "Failed to open \"%s\"\n", filename);
- exit(EX_NOINPUT);
+ graphviz_exit(EX_NOINPUT);
}
}
im = 0;
im = gdImageCreateFromPng(f);
#else
fprintf(stderr, "PNG support is not available\n");
- exit(EX_UNAVAILABLE);
+ graphviz_exit(EX_UNAVAILABLE);
#endif
}
else if (strcasecmp(ext, ".gif") == 0) {
im = gdImageCreateFromGif(f);
#else
fprintf(stderr, "GIF support is not available\n");
- exit(EX_UNAVAILABLE);
+ graphviz_exit(EX_UNAVAILABLE);
#endif
}
else if (strcasecmp(ext, ".jpg") == 0) {
im = gdImageCreateFromJpeg(f);
#else
fprintf(stderr, "JPEG support is not available\n");
- exit(EX_UNAVAILABLE);
+ graphviz_exit(EX_UNAVAILABLE);
#endif
}
fclose(f);
if (!im) {
fprintf(stderr, "Loading image from file \"%s\" failed!\n", filename);
- exit(EX_DATAERR);
+ graphviz_exit(EX_DATAERR);
}
return im;
}
if (argc == 2 && strcmp(argv[1], "-?") == 0) {
fprintf(stderr, "Usage: diffimg image1 image2 [outimage]\n");
- exit(0);
+ graphviz_exit(0);
}
if (argc < 3) {
fprintf(stderr, "Usage: diffimg image1 image2 [outimage]\n");
- exit(EX_USAGE);
+ graphviz_exit(EX_USAGE);
}
A = imageLoad(argv[1]);
B = imageLoad(argv[2]);
#include <getopt.h>
#include "cgraph.h"
+#include "exit.h"
#include "ingraphs.h"
#include "generic_list.h"
case 'h':
{
help_message(progname);
- exit(EXIT_SUCCESS);
+ graphviz_exit(EXIT_SUCCESS);
break;
}
case 'v':
case '?':
if (optopt == '?') {
help_message(progname);
- exit(EXIT_SUCCESS);
+ graphviz_exit(EXIT_SUCCESS);
} else if (isprint(optopt)) {
fprintf(stderr, "Unknown option `-%c'.\n", optopt);
} else {
fprintf(stderr, "Unknown option character `\\x%X'.\n",
optopt);
}
- exit(EXIT_FAILURE);
+ graphviz_exit(EXIT_FAILURE);
break;
default:
help_message(progname);
- exit(EXIT_FAILURE);
+ graphviz_exit(EXIT_FAILURE);
break;
}
}
if (agisdirected(graph) == 0) {
fprintf(stderr,
"*** Error: Graph is undirected! Pruning works only with directed graphs!\n");
- exit(EXIT_FAILURE);
+ graphviz_exit(EXIT_FAILURE);
}
/* attach node data for marking to all nodes */
if (attr == NULL) {
fprintf(stderr, "Couldn't create attribute: %s\n",
((strattr_t *) attr_list->data[j])->n);
- exit(EXIT_FAILURE);
+ graphviz_exit(EXIT_FAILURE);
}
agxset(node, attr,
((strattr_t *) attr_list->data[j])->v);
}
free(attr_list);
free(node_list);
- exit(EXIT_SUCCESS);
+ graphviz_exit(EXIT_SUCCESS);
}
int remove_child(Agraph_t * graph, Agnode_t * node)
sp = malloc(sizeof(strattr_t));
if (sp == NULL) {
perror("[addattr()->malloc()]");
- exit(EXIT_FAILURE);
+ graphviz_exit(EXIT_FAILURE);
}
/* Split argument spec. at first '=' */
p = strchr(a, '=');
if (p == NULL) {
fprintf(stderr, "Invalid argument specification: %s\n", a);
- exit(EXIT_FAILURE);
+ graphviz_exit(EXIT_FAILURE);
}
*(p++) = '\0';
sp->n = strdup(a);
if (sp->n == NULL) {
perror("[addattr()->strdup()]");
- exit(EXIT_FAILURE);
+ graphviz_exit(EXIT_FAILURE);
}
/* pointer to argument value */
sp->v = strdup(p);
if (sp->v == NULL) {
perror("[addattr()->strdup()]");
- exit(EXIT_FAILURE);
+ graphviz_exit(EXIT_FAILURE);
}
return add_to_generic_list(l, (gl_data) sp);
sp = strdup(n);
if (sp == NULL) {
perror("[addnode()->strdup()]");
- exit(EXIT_FAILURE);
+ graphviz_exit(EXIT_FAILURE);
}
return add_to_generic_list(l, (gl_data) sp);
#include <unistd.h>
#endif
#include "cgraph.h"
+#include "exit.h"
#include "ingraphs.h"
#include <getopt.h>
fp = fopen(name, "w");
if (!fp) {
fprintf(stderr, "gvpack: could not open file %s for writing\n", name);
- exit(1);
+ graphviz_exit(1);
}
return (fp);
}
static void usage(int v)
{
printf(useString, CmdName);
- exit(v);
+ graphviz_exit(v);
}
static void scanArgs(int argc, char **argv)
#include <ast/ast.h>
#include <ast/error.h>
+#include <cgraph/exit.h>
#include <stddef.h>
#include <string.h>
#include <errno.h>
sfprintf(sfstderr, "\n%s", strerror(errno));
sfprintf(sfstderr, "\n");
if (level >= ERROR_FATAL)
- exit(level - ERROR_FATAL + 1);
+ graphviz_exit(level - ERROR_FATAL + 1);
}
void error(int level, const char *s, ...)
#include <assert.h>
#include <cgraph/sprint.h>
+#include <cgraph/exit.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
if (s == NULL) {
fprintf(stderr, "gv_sprint failed\n");
- exit(EXIT_FAILURE);
+ graphviz_exit(EXIT_FAILURE);
}
return s;
#include <gvc/gvc.h>
#include <xdot/xdot.h>
#include <cgraph/agxbuf.h>
+#include <cgraph/exit.h>
#include <cgraph/strcasecmp.h>
#include <stdbool.h>
#include <stddef.h>
fputs(configItems, outs);
if (GvExitOnUsage && (exval >= 0))
- exit(exval);
+ graphviz_exit(exval);
return (exval+1);
}
/* must happen before trying to select any plugins */
if (gvc->common.config) {
gvconfig(gvc, gvc->common.config);
- exit (0);
+ graphviz_exit(0);
}
/* feed the globals */
/* Q: Should 'dot -c' be suggested generally or only when val = "dot"? */
fprintf(stderr, " No formats found.\nPerhaps \"dot -c\" needs to be run (with installer's privileges) to register the plugins?\n");
}
- if (GvExitOnUsage) exit(1);
+ if (GvExitOnUsage) graphviz_exit(1);
return(2);
}
break;
fprintf(stderr, " No layouts found.\nPerhaps \"dot -c\" needs to be run (with installer's privileges) to register the plugins?\n");
}
}
- if (GvExitOnUsage) exit(1);
+ if (GvExitOnUsage) graphviz_exit(1);
return(2);
}
Kflag = 1;
fprintf(stderr, "%s - %s version %s (%s)\n",
gvc->common.cmdname, gvc->common.info[0],
gvc->common.info[1], gvc->common.info[2]);
- if (GvExitOnUsage) exit(0);
+ if (GvExitOnUsage) graphviz_exit(0);
return (1);
break;
case 'l':
}
}
- if (GvExitOnUsage) exit(1);
+ if (GvExitOnUsage) graphviz_exit(1);
return(2);
}
}
#include "config.h"
+#include <cgraph/exit.h>
#include <cgraph/likely.h>
#include <stdio.h>
#include <stdlib.h>
void *p = realloc(ptr, size * elt);
if (UNLIKELY(p == NULL && size)) {
fprintf(stderr, "out of memory\n");
- exit(EXIT_FAILURE);
+ graphviz_exit(EXIT_FAILURE);
}
if (osize < size)
memset((char *) p + (osize * elt), '\0', (size - osize) * elt);
char *rv = calloc(nmemb, size);
if (UNLIKELY(nmemb > 0 && size > 0 && rv == NULL)) {
fprintf(stderr, "out of memory\n");
- exit(EXIT_FAILURE);
+ graphviz_exit(EXIT_FAILURE);
}
return rv;
}
rv = malloc(nbytes);
if (UNLIKELY(rv == NULL)) {
fprintf(stderr, "out of memory\n");
- exit(EXIT_FAILURE);
+ graphviz_exit(EXIT_FAILURE);
}
return rv;
}
void *p = realloc(ptr, size);
if (UNLIKELY(p == NULL && size)) {
fprintf(stderr, "out of memory\n");
- exit(EXIT_FAILURE);
+ graphviz_exit(EXIT_FAILURE);
}
return p;
}
+#include <cgraph/exit.h>
#include <cgraph/unreachable.h>
#include <common/types.h>
#include <common/utils.h>
// TODO: a better strategy than aborting on malformed data
if (is_invalid) {
fprintf(stderr, "Error during conversion to \"UTF-8\". Quiting.\n");
- exit(EXIT_FAILURE);
+ graphviz_exit(EXIT_FAILURE);
}
// Decode the character. Refer again to the above table to understand this
#include <assert.h>
#include <cgraph/cgraph.h>
+#include <cgraph/exit.h>
#include <dotgen/dot.h>
#include <limits.h>
#include <stdbool.h>
assert(t >= 0);
if (INT_MAX / t < ED_weight(e)) {
agerr(AGERR, "overflow when calculating virtual weight of edge\n");
- exit(EXIT_FAILURE);
+ graphviz_exit(EXIT_FAILURE);
}
ED_weight(e) *= t;
int tmp; /* temp var index */ \
Exccdisc_t* ccdisc; /* excc() discipline */
+#include <cgraph/exit.h>
#include <expr/exlib.h>
#include <stddef.h>
#include <stdio.h>
sfprintf(cc->ccdisc->text, "%s", expr->data.variable.symbol->name);
return;
case EXIT:
- sfprintf(cc->ccdisc->text, "exit(");
+ sfprintf(cc->ccdisc->text, "exit(");
gen(cc, x);
sfprintf(cc->ccdisc->text, ");\n");
return;
*/
#include <assert.h>
+#include <cgraph/exit.h>
#include <expr/exlib.h>
#include <stdarg.h>
#include <stdio.h>
free(s);
}
else if (expr.program->disc->flags & EX_FATAL)
- exit(1);
+ graphviz_exit(1);
}
void
#define _BLD_sfio 1
#endif
+#include <cgraph/exit.h>
#include <expr/exlib.h>
#include <expr/exop.h>
#include <inttypes.h>
if (ex->disc->exitf)
(*ex->disc->exitf) (ex, env, (int)v.integer);
else
- exit((int)v.integer);
+ graphviz_exit((int)v.integer);
/*NOTREACHED*/
v.integer = -1;
return v;
Sfio_t *buffer = sfstropen();
if (buffer == NULL) {
fprintf(stderr, "out of memory\n");
- exit(EXIT_FAILURE);
+ graphviz_exit(EXIT_FAILURE);
}
print(ex, expr, env, buffer);
v.string = exstash(buffer, ex->ve);
#define FDP_PRIVATE
+#include <cgraph/exit.h>
#include <fdpgen/dbg.h>
#include <neatogen/neatoprocs.h>
#include <fdpgen/fdp.h>
fp = fopen(fname, "w");
if (!fp) {
fprintf(stderr, "Couldn not open %s \n", fname);
- exit(1);
+ graphviz_exit(1);
}
outputGraph(g, fp, expMode);
fclose(fp);
#define _GNU_SOURCE 1
#endif
+#include <cgraph/exit.h>
#include <gvc/gvconfig.h>
#include <ctype.h>
f = fopen(config_path,"w");
if (!f) {
agerr(AGERR,"failed to open %s for write.\n", config_path);
- exit(1);
+ graphviz_exit(1);
}
fprintf(f, "# This file was generated by \"dot -c\" at time of install.\n\n");
#endif /* HAVE_LIBZ */
#include <assert.h>
+#include <cgraph/exit.h>
#include <common/const.h>
#include <common/memory.h>
#include <gvc/gvplugin_device.h>
job->output_data = realloc(job->output_data, job->output_data_allocated);
if (!job->output_data) {
(job->common->errorfn) ("memory allocation failure\n");
- exit(1);
+ graphviz_exit(1);
}
}
memcpy(job->output_data + job->output_data_position, s, len);
df = realloc(df, dfallocated);
if (! df) {
(job->common->errorfn) ("memory allocation failure\n");
- exit(1);
+ graphviz_exit(1);
}
}
int r = deflate(z, Z_NO_FLUSH);
if (r != Z_OK) {
(job->common->errorfn) ("deflation problem %d\n", r);
- exit(1);
+ graphviz_exit(1);
}
if ((olen = z->next_out - df)) {
ret = gvwrite_no_z(job, df, olen);
if (ret != olen) {
(job->common->errorfn) ("gvwrite_no_z problem %d\n", ret);
- exit(1);
+ graphviz_exit(1);
}
}
}
#else
NOTUSED(olen);
(job->common->errorfn) ("No libz support.\n");
- exit(1);
+ graphviz_exit(1);
#endif
}
else { /* uncompressed write */
ret = gvwrite_no_z (job, s, len);
if (ret != len) {
(job->common->errorfn) ("gvwrite_no_z problem %d\n", len);
- exit(1);
+ graphviz_exit(1);
}
}
return len;
}
if (ret != Z_STREAM_END) {
(job->common->errorfn) ("deflation finish problem %d cnt=%d\n", ret, cnt);
- exit(1);
+ graphviz_exit(1);
}
gvwrite_no_z(job, df, z->next_out - df);
ret = deflateEnd(z);
if (ret != Z_OK) {
(job->common->errorfn) ("deflation end problem %d\n", ret);
- exit(1);
+ graphviz_exit(1);
}
out[0] = (unsigned char)crc;
out[1] = (unsigned char)(crc >> 8);
gvwrite_no_z(job, out, sizeof(out));
#else
(job->common->errorfn) ("No libz support\n");
- exit(1);
+ graphviz_exit(1);
#endif
}
#include <gvpr/compile.h>
#include <assert.h>
#include <cgraph/cgraph.h>
+#include <cgraph/exit.h>
#include <cgraph/itos.h>
#include <ast/error.h>
#include <gvpr/actions.h>
int bytes = vsnprintf(NULL, 0, "<unknown (%d)>", op);
if (bytes < 0) {
fprintf(stderr, "%s: vsnprintf failure\n", __func__);
- exit(EXIT_FAILURE);
+ graphviz_exit(EXIT_FAILURE);
}
// construct a managed buffer to store this name
#include <gvpr/gprstate.h>
#include <cgraph/agxbuf.h>
#include <cgraph/cgraph.h>
+#include <cgraph/exit.h>
#include <common/globals.h>
#include <ingraphs/ingraphs.h>
#include <gvpr/compile.h>
if (level >= ERROR_ERROR) {
Gpr_t *state = (Gpr_t*)(discipline->user);
if (state->flags & GV_USE_EXIT)
- exit(1);
+ graphviz_exit(1);
else if (state->flags & GV_USE_JUMP)
longjmp (jbuf, 1);
}
#include <string.h>
#include <unistd.h>
+#include <cgraph/exit.h>
#include <common/memory.h>
#include <gvc/gvc.h>
#include <labels/xlabels.h>
if (!(gp = agread(opts->inf))) {
fprintf(stderr, "%s: %s not a dot file\n", progname,
opts->infname);
- exit(1);
+ graphviz_exit(1);
}
fclose(opts->inf);
fprintf(stderr, "laying out %s\n", opts->lay);
if (gvLayout(opts->gvc, gp, opts->lay)) {
fprintf(stderr, "%s: layout %s failed\n", progname, opts->lay);
- exit(1);
+ graphviz_exit(1);
}
fprintf(stderr, "attach labels\n");
modestr = "writing";
fprintf(stderr, "%s: could not open file %s for %s -- %s\n",
progname, name, modestr, strerror(errno));
- exit(1);
+ graphviz_exit(1);
}
return (fp);
}
else {
fprintf(stderr, "%s: unknown layout %s\n", progname,
optarg);
- exit(1);
+ graphviz_exit(1);
}
break;
case 'T':
else {
fprintf(stderr, "%s: unknown format %s\n", progname,
optarg);
- exit(1);
+ graphviz_exit(1);
}
break;
case 'v':
break;
default:
usage(progname);
- exit(1);
+ graphviz_exit(1);
}
}
*************************************************************************/
#include <math.h>
+#include <cgraph/exit.h>
#include <neatogen/neato.h>
#include <pathplan/pathutil.h>
#ifdef RECORD_INTERSECTS
if (input->ninters >= MAXINTS) {
agerr(AGERR, "using too many intersections\n");
- exit(1);
+ graphviz_exit(1);
}
ilist[input->ninters].firstv = l;
#include <ortho/maze.h>
#include <ortho/fPQ.h>
#include <ortho/ortho.h>
+#include <cgraph/exit.h>
#include <common/memory.h>
#include <common/geomprocs.h>
#include <common/globals.h>
}
else {
agerr (AGERR, "Node not adjacent to cell -- Aborting\n");
- exit(EXIT_FAILURE);
+ graphviz_exit(EXIT_FAILURE);
}
return p;
}
#include <stdbool.h>
#include <stdlib.h>
+#include <cgraph/exit.h>
#include <common/types.h>
#include <common/memory.h>
#include <common/globals.h>
} else {
fprintf(stderr,"ideal_dist_scheme value wrong");
assert(0);
- exit(1);
+ graphviz_exit(1);
}
/*
} else {
fprintf(stderr,"ideal_dist_scheme value wrong");
assert(0);
- exit(1);
+ graphviz_exit(1);
}
jw[nz] = ja[l];
nedges = agnedges (g);
if (format != FORMAT_CSR && format != FORMAT_COORD) {
fprintf (stderr, "Format %d not supported\n", format);
- exit (1);
+ graphviz_exit(1);
}
/* Assign node ids */
fprintf(stderr,"{%d,%d}=%f,",94,list[j],dist[list[j]]);
}
fprintf(stderr,"\n");
- exit(1);
+ graphviz_exit(1);
*/
*/
#ifndef STANDALONE
#include "cgraph.h"
+#include "exit.h"
#include "globals.h"
#include "logic.h"
#include "arith.h"
#endif
#include <errno.h>
+#include <cgraph/exit.h>
#include <gvc/gvplugin_device.h>
#include <cairo.h>
window = (window_t *)job->window;
if (cmev->format == 32
&& (Atom) cmev->data.l[0] == window->wm_delete_window_atom)
- exit(0);
+ graphviz_exit(0);
}
static bool handle_keypress(GVJ_t *job, XKeyEvent *kev)
#include <fcntl.h>
#endif
+#include <cgraph/exit.h>
#include <gvc/gvplugin_device.h>
#include <cairo.h>
window = job->window;
if (cmev->format == 32
&& (Atom) cmev->data.l[0] == window->wm_delete_window_atom)
- exit(0);
+ graphviz_exit(0);
}
static bool handle_keypress(GVJ_t *job, XKeyEvent *kev)
#include <sys/stat.h>
#include <fcntl.h>
+#include <cgraph/exit.h>
+
static int openF(char *fname)
{
int fd = open(fname, O_RDONLY);
if (fd < 0) {
fprintf(stderr, "Could not open %s for reading: %s\n\n", fname,
strerror(errno));
- exit(1);
+ graphviz_exit(1);
}
return fd;
}
if (argc != 3) {
fprintf(stderr, "Usage: %s <file1> <file2>\n", argv[0]);
- exit(1);
+ graphviz_exit(1);
}
f1 = openF(argv[1]);
} else
xval = 0;
- exit(xval);
+ graphviz_exit(xval);
}
#include <stdio.h>
#include <stdlib.h>
+#include <cgraph/exit.h>
+
void find_intersection(struct vertex *l, struct vertex *m,
struct intersection ilist[], struct data *input);
static int gt(const void *a, const void *b);
if ((tempa = templ->active) == NULL) {
fprintf(stderr,
"\n***ERROR***\n trying to delete a non line\n");
- exit(1);
+ graphviz_exit(1);
}
if (all.number == 1)
all.final = all.first = NULL; /* delete the line */
*************************************************************************/
#include <cgraph/unreachable.h>
+#include <cgraph/exit.h>
#include <math.h>
#include <stdio.h>
#include "simple.h"
if (input->ninters >= MAXINTS) {
fprintf(stderr, "\n**ERROR**\n using too many intersections\n");
- exit(1);
+ graphviz_exit(1);
}
ilist[input->ninters].firstv = l;