| 1 |
/** |
| 2 |
* @file |
| 3 |
* @brief graph pattern scanning and processing language API, main function @ref gvpr |
| 4 |
* @ingroup public_apis |
| 5 |
*/ |
| 6 |
/************************************************************************* |
| 7 |
* Copyright (c) 2011 AT&T Intellectual Property |
| 8 |
* All rights reserved. This program and the accompanying materials |
| 9 |
* are made available under the terms of the Eclipse Public License v1.0 |
| 10 |
* which accompanies this distribution, and is available at |
| 11 |
* https://www.eclipse.org/legal/epl-v10.html |
| 12 |
* |
| 13 |
* Contributors: Details at https://graphviz.org |
| 14 |
*************************************************************************/ |
| 15 |
|
| 16 |
#pragma once |
| 17 |
|
| 18 |
#include <stddef.h> |
| 19 |
|
| 20 |
#ifdef __cplusplus |
| 21 |
extern "C" { |
| 22 |
#endif |
| 23 |
|
| 24 |
#ifdef GVDLL |
| 25 |
#ifdef EXPORT_GVPR |
| 26 |
#define GVPR_API __declspec(dllexport) |
| 27 |
#else |
| 28 |
#define GVPR_API __declspec(dllimport) |
| 29 |
#endif |
| 30 |
#endif |
| 31 |
|
| 32 |
#ifndef GVPR_API |
| 33 |
#define GVPR_API /* nothing */ |
| 34 |
#endif |
| 35 |
|
| 36 |
#include "cgraph.h" |
| 37 |
#ifdef _MSC_VER |
| 38 |
#include <BaseTsd.h> |
| 39 |
typedef SSIZE_T ssize_t; |
| 40 |
#endif |
| 41 |
|
| 42 |
/* Bits for flags variable in gvprstate_t. |
| 43 |
* Included here so that calling programs can use the first |
| 44 |
* two in gvpropts.flags |
| 45 |
*/ |
| 46 |
/* If set, gvpr calls exit() on errors */ |
| 47 |
#define GV_USE_EXIT 1 |
| 48 |
/* If set, gvpr stores output graphs in gvpropts */ |
| 49 |
#define GV_USE_OUTGRAPH 2 |
| 50 |
/* Use longjmp to return to top-level call in gvpr */ |
| 51 |
#define GV_USE_JUMP 4 |
| 52 |
/* $tvnext has been set but not used */ |
| 53 |
#define GV_NEXT_SET 8 |
| 54 |
|
| 55 |
|
| 56 |
typedef ssize_t (*gvprwr) (void*, const char *buf, size_t nbyte, void*); |
| 57 |
typedef int (*gvpruserfn) (char *); |
| 58 |
typedef struct { |
| 59 |
char* name; |
| 60 |
gvpruserfn fn; |
| 61 |
} gvprbinding; |
| 62 |
|
| 63 |
typedef struct { |
| 64 |
Agraph_t** ingraphs; /* NULL-terminated array of input graphs */ |
| 65 |
size_t n_outgraphs; ///< if GV_USE_OUTGRAPH set, output graphs |
| 66 |
Agraph_t** outgraphs; |
| 67 |
gvprwr out; /* write function for stdout */ |
| 68 |
gvprwr err; /* write function for stderr */ |
| 69 |
int flags; |
| 70 |
gvprbinding* bindings; /* array of bindings, terminated with {NULL,NULL} */ |
| 71 |
} gvpropts; |
| 72 |
|
| 73 |
/// @param opts Options affecting gvpr behavior. Pass `NULL` for defaults. |
| 74 |
GVPR_API extern int gvpr (int argc, char *argv[], gvpropts* opts); |
| 75 |
|
| 76 |
#ifdef __cplusplus |
| 77 |
} |
| 78 |
#endif |