gvpr.3 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. .TH LIBGVPR 3 "15 OCTOBER 2013"
  2. .SH NAME
  3. \fBlibgvpr\fR \- library for graph filtering
  4. .SH SYNOPSIS
  5. .ta .75i 1.5i 2.25i 3i 3.75i 4.5i 5.25i 6i
  6. .PP
  7. .nf
  8. \f5
  9. #include <graphviz/gvpr.h>
  10. /* If set, gvpr calls exit() on errors */
  11. #define GV_USE_EXIT 1
  12. /* If set, gvpr stores output graphs in gvpropts */
  13. #define GV_USE_OUTGRAPH 2
  14. typedef ssize_t (*gvprwr) (void*, const char *buf, size_t nbyte, void*);
  15. typedef struct {
  16. Agraph_t** ingraphs; /* NULL-terminated array of input graphs */
  17. int n_outgraphs; /* if GV_USE_OUTGRAPH set, output graphs */
  18. Agraph_t** outgraphs;
  19. gvprwr out; /* write function for stdout */
  20. gvprwr err; /* write function for stderr */
  21. int flags;
  22. } gvpropts;
  23. extern int gvpr (int argc, char *argv[], gvpropts* opts);
  24. \fP
  25. .fi
  26. .SH DESCRIPTION
  27. The \fBgvpr\fP library allows an application to perform general-purpose
  28. graph manipulation and filtering based on an awk-like language. (For a more
  29. complete description of this language, see gvpr(1).)
  30. .P
  31. The library has a single entry point: the \fIgvpr()\fP function. This provides a
  32. standard \fIargc/argv\fP interface, along with a structure to support
  33. in-core graphs, application print functions, along with additional options.
  34. .P
  35. When called, \fIgvpr()\fP processes any flags provided in the \fIargv\fP array, and compiles
  36. the \fBgvpr\fP program to be run (provided either via the \fI\-f\fP flag or as an item
  37. in \fIargv\fP). It then runs the program on each input graph. If \fIopt\->ingraphs\fP is
  38. non-NULL, this is taken as a NULL-terminated array of in-core graphs to be used as input.
  39. Otherwise, the unprocessed elements of \fIargv\fP are taken to be the names of files containing
  40. graphs to be processed. (If none remain, \fBgvpr\fP will read from stdin.)
  41. .P
  42. Normally, \fBgvpr\fP writes any output graph to stdout. However, if
  43. the flag \fIGV_USE_OUTGRAPH\fP is set in \fIopts\->flags\fP, the output graphs will be stored in
  44. an array pointed to be \fIopts\->outgraphs\fP and the count will be stored in \fIopts\->n_outgraphs\fP.
  45. In this case, the application must call \fIagclose()\fP on each output graph when it is done with
  46. it.
  47. .P
  48. The application can override the default write functions for stdout and stderr using the
  49. \fIout\fP and \fIerr\fP fields in \fIopts\fP. When called by \fBgvpr\fP, the second argument
  50. will point to a buffer of characters to be written, while the third argument provides the
  51. number of characters. The function should return the number of bytes actually written.
  52. .SH RETURN VALUES
  53. Normally, \fBgvpr\fP returns 0 on success and non-zero if an error occurs. Any relevant
  54. error message will have been written to stderr or the application's \fIopts\->err\fP function will
  55. have been called. If, however, \fIGV_USE_EXIT\fP is set in \fIopts\->flags\fP, \fBgvpr\fP will call
  56. exit(3) in case of an error.
  57. .SH SEE ALSO
  58. .BR gvpr (1),
  59. .BR awk (1),
  60. .BR cgraph (3)
  61. .SH AUTHORS
  62. Emden Gansner ([email protected]).