dot.c 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /**
  2. * @file
  3. * @brief main rendering program for various layouts of graphs and output formats
  4. */
  5. /*************************************************************************
  6. * Copyright (c) 2011 AT&T Intellectual Property
  7. * All rights reserved. This program and the accompanying materials
  8. * are made available under the terms of the Eclipse Public License v1.0
  9. * which accompanies this distribution, and is available at
  10. * https://www.eclipse.org/legal/epl-v10.html
  11. *
  12. * Contributors: Details at https://graphviz.org
  13. *************************************************************************/
  14. /*
  15. * Written by Stephen North and Eleftherios Koutsofios.
  16. */
  17. #include "config.h"
  18. #include <cgraph/cgraph.h>
  19. #include <gvc/gvc.h>
  20. #include <gvc/gvio.h>
  21. #include <util/exit.h>
  22. #include <common/globals.h>
  23. #include <stdbool.h>
  24. #include <stdlib.h>
  25. #include <time.h>
  26. static GVC_t *Gvc;
  27. static graph_t * G;
  28. #ifndef _WIN32
  29. #ifndef NO_FPERR
  30. static void fperr(int s)
  31. {
  32. fprintf(stderr, "caught SIGFPE %d\n", s);
  33. /* signal (s, SIG_DFL); raise (s); */
  34. graphviz_exit(1);
  35. }
  36. #endif
  37. #endif
  38. int main(int argc, char **argv)
  39. {
  40. graph_t *prev = NULL;
  41. int r, rc = 0;
  42. Gvc = gvContextPlugins(lt_preloaded_symbols, DEMAND_LOADING);
  43. GvExitOnUsage = 1;
  44. gvParseArgs(Gvc, argc, argv);
  45. #ifndef _WIN32
  46. signal(SIGUSR1, gvToggle);
  47. #ifndef NO_FPERR
  48. signal(SIGFPE, fperr);
  49. #endif
  50. #endif
  51. if ((G = gvPluginsGraph(Gvc))) {
  52. gvLayoutJobs(Gvc, G); /* take layout engine from command line */
  53. gvRenderJobs(Gvc, G);
  54. }
  55. else {
  56. while ((G = gvNextInputGraph(Gvc))) {
  57. if (prev) {
  58. gvFreeLayout(Gvc, prev);
  59. agclose(prev);
  60. }
  61. gvLayoutJobs(Gvc, G); /* take layout engine from command line */
  62. gvRenderJobs(Gvc, G);
  63. r = agreseterrors();
  64. rc = MAX(rc,r);
  65. prev = G;
  66. }
  67. }
  68. gvFinalize(Gvc);
  69. r = gvFreeContext(Gvc);
  70. graphviz_exit(MAX(rc,r));
  71. }
  72. /**
  73. * @dir .
  74. * @brief main rendering program for various layouts of graphs and output formats
  75. */
  76. /**
  77. * @mainpage
  78. *
  79. * %Hierarchy:\n
  80. * -# Applications
  81. * - @ref cmd/dot – main rendering application for various layouts of graphs and output formats
  82. * - @ref cmd – directory of applications
  83. * - @ref dot.demo "dot.demo" – demo programs
  84. * -# @ref plugin – Plugins of graph layout engines and output formats
  85. * -# Core libraries
  86. * -# @ref engines
  87. * -# @ref common_render – rendering for layout engines
  88. * -# @ref common_utils – low level utilities for layout engines
  89. * -# @ref lib – miscellaneous libraries
  90. * -# @ref cgraph – abstract graph C library
  91. * -# @ref cgraph_app – uncoupled application specific functions
  92. * -# @ref cgraph_core – highly cohesive core
  93. * -# Low level utility libraries
  94. * - @ref cgraph_utils – low level cgraph utilities
  95. * - @ref lib/cdt – Container Data Types library
  96. */