Graphviz 12.0.1~dev.20240716.0800
Loading...
Searching...
No Matches
actions.c File Reference
#include <ast/ast.h>
#include <ast/error.h>
#include <cgraph/agxbuf.h>
#include <cgraph/alloc.h>
#include <cgraph/gv_ctype.h>
#include <cgraph/strcasecmp.h>
#include <cgraph/unreachable.h>
#include <cgraph/unused.h>
#include <gvpr/actions.h>
#include <gvpr/compile.h>
#include <limits.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include "../common/colxlate.c"
#include <sys/param.h>
#include <sys/times.h>
#include <sys/types.h>
Include dependency graph for actions.c:

Go to the source code of this file.

Data Structures

struct  edgepair_t
 

Macros

#define KINDS(p)    ((AGTYPE(p) == AGRAPH) ? "graph" : (AGTYPE(p) == AGNODE) ? "node" : "edge")
 
#define CCMARKED(n)   (((nData(n))->iu.integer) & 2)
 
#define CCMARK(n)   (((nData(n))->iu.integer) |= 2)
 
#define CCUNMARK(n)   (((nData(n))->iu.integer) &= ~2)
 
#define COLORPROCS_API   static UNUSED
 
#define HZ   60
 
#define GET_TIME(S)   times(&(S))
 
#define DIFF_IN_SECS(S, T)    ((S.tms_utime + S.tms_stime - T.tms_utime - T.tms_stime) / (double)HZ)
 

Typedefs

typedef struct tms mytime_t
 

Functions

static int iofread (void *chan, char *buf, int bufsize)
 
static int ioputstr (void *chan, const char *str)
 
static int ioflush (void *chan)
 
Agraph_tsameG (void *p1, void *p2, char *fn, char *msg)
 
int indexOf (char *s1, char *s2)
 
long rindexOf (char *s1, char *s2)
 
size_t match (char *str, char *pat)
 
int copyAttr (Agobj_t *src, Agobj_t *tgt)
 
Agobj_tcopy (Agraph_t *g, Agobj_t *obj)
 
static Agedge_tmapEdge (Dt_t *emap, Agedge_t *e)
 
static Agraph_tcloneSubg (Agraph_t *tgt, Agraph_t *g, Dt_t *emap)
 
static int cmppair (void *k1, void *k2)
 
static void cloneGraph (Agraph_t *tgt, Agraph_t *src)
 
Agraph_tcloneG (Agraph_t *g, char *name)
 
Agobj_tcloneO (Agraph_t *g, Agobj_t *obj)
 
static void cc_dfs (Agraph_t *g, Agraph_t *comp, Agnode_t *n)
 
Agraph_tcompOf (Agraph_t *g, Agnode_t *n)
 
Agedge_tisEdge (Agraph_t *g, Agnode_t *t, Agnode_t *h, char *key)
 
Agnode_taddNode (Agraph_t *gp, Agnode_t *np, int doAdd)
 
Agedge_taddEdge (Agraph_t *gp, Agedge_t *ep, int doAdd)
 
int lockGraph (Agraph_t *g, int v)
 
int deleteObj (Agraph_t *g, Agobj_t *obj)
 
int sfioWrite (Agraph_t *g, FILE *fp)
 
int writeFile (Agraph_t *g, char *f)
 
Agraph_treadFile (char *f)
 
int fwriteFile (Expr_t *ex, Agraph_t *g, long long fd)
 
Agraph_tfreadFile (Expr_t *ex, long long fd)
 
int openFile (Expr_t *ex, const char *fname, const char *mode)
 
int closeFile (Expr_t *ex, long long fd)
 
char * readLine (Expr_t *ex, long long fd)
 
int compare (Agobj_t *l, Agobj_t *r)
 
char * toLower (Expr_t *pgm, char *src)
 
char * toUpper (Expr_t *pgm, char *src)
 
char * toHtml (Agraph_t *g, char *arg)
 
char * canon (Expr_t *pgm, char *arg)
 
char * colorx (Expr_t *ex, char *incolor, char *fmt)
 
void gvstart_timer (void)
 
double gvelapsed_sec (void)
 

Variables

static Agiodisc_t gprIoDisc = {iofread, ioputstr, ioflush}
 
static Dtdisc_t edgepair
 
static mytime_t T
 

Macro Definition Documentation

◆ CCMARK

#define CCMARK (   n)    (((nData(n))->iu.integer) |= 2)

Definition at line 402 of file actions.c.

◆ CCMARKED

#define CCMARKED (   n)    (((nData(n))->iu.integer) & 2)

Definition at line 401 of file actions.c.

◆ CCUNMARK

#define CCUNMARK (   n)    (((nData(n))->iu.integer) &= ~2)

Definition at line 403 of file actions.c.

◆ COLORPROCS_API

#define COLORPROCS_API   static UNUSED

Definition at line 783 of file actions.c.

◆ DIFF_IN_SECS

#define DIFF_IN_SECS (   S,
  T 
)     ((S.tms_utime + S.tms_stime - T.tms_utime - T.tms_stime) / (double)HZ)

Definition at line 853 of file actions.c.

◆ GET_TIME

#define GET_TIME (   S)    times(&(S))

Definition at line 852 of file actions.c.

◆ HZ

#define HZ   60

Definition at line 849 of file actions.c.

◆ KINDS

#define KINDS (   p)     ((AGTYPE(p) == AGRAPH) ? "graph" : (AGTYPE(p) == AGNODE) ? "node" : "edge")

Definition at line 33 of file actions.c.

Typedef Documentation

◆ mytime_t

typedef struct tms mytime_t

Definition at line 851 of file actions.c.

Function Documentation

◆ addEdge()

Agedge_t * addEdge ( Agraph_t gp,
Agedge_t ep,
int  doAdd 
)

Definition at line 475 of file actions.c.

References agsubedge(), and sameG().

Here is the call graph for this function:

◆ addNode()

Agnode_t * addNode ( Agraph_t gp,
Agnode_t np,
int  doAdd 
)

Definition at line 465 of file actions.c.

References agsubnode(), and sameG().

Here is the call graph for this function:

◆ canon()

char * canon ( Expr_t pgm,
char *  arg 
)

Definition at line 761 of file actions.c.

References agcanonStr(), and exstring().

Here is the call graph for this function:

◆ cc_dfs()

static void cc_dfs ( Agraph_t g,
Agraph_t comp,
Agnode_t n 
)
static

Definition at line 405 of file actions.c.

References agfstedge(), aghead, AGID, agidnode(), agnxtedge(), agtail, cc_dfs(), CCMARK, and CCMARKED.

Referenced by cc_dfs(), and compOf().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cloneG()

Agraph_t * cloneG ( Agraph_t g,
char *  name 
)

Definition at line 332 of file actions.c.

References agnameof(), cloneGraph(), copyAttr(), Agraph_s::desc, and openG().

Referenced by getval().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cloneGraph()

static void cloneGraph ( Agraph_t tgt,
Agraph_t src 
)
static

Definition at line 284 of file actions.c.

References agfstnode(), agfstout(), agfstsubg(), aghead, AGMKOUT, agnameof(), agnedges(), agnxtnode(), agnxtout(), agnxtsubg(), agtail, cloneSubg(), copy(), dtclose(), dtinsert, dtopen(), Dtoset, edgepair, exerror(), free(), edgepair_t::key, malloc(), OBJ, and edgepair_t::val.

Referenced by cloneG(), and cloneO().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cloneO()

Agobj_t * cloneO ( Agraph_t g,
Agobj_t obj 
)

Definition at line 353 of file actions.c.

References aghead, AGINEDGE, AGMKOUT, agnameof(), AGNODE, AGOUTEDGE, AGRAPH, agtail, AGTYPE, cloneGraph(), cloneO(), copyAttr(), exerror(), kind, OBJ, openEdge(), openG(), openNode(), openSubg(), and UNREACHABLE.

Referenced by addOutputGraph(), cloneO(), getval(), and gvpr_core().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cloneSubg()

static Agraph_t * cloneSubg ( Agraph_t tgt,
Agraph_t g,
Dt_t emap 
)
static

Definition at line 215 of file actions.c.

References agfstnode(), agfstout(), agfstsubg(), aghead, AGMKOUT, agnameof(), agnode(), agnxtnode(), agnxtout(), agnxtsubg(), agsubedge(), agsubnode(), agtail, cloneSubg(), copy(), exerror(), mapEdge(), and OBJ.

Referenced by cloneGraph(), and cloneSubg().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ closeFile()

int closeFile ( Expr_t ex,
long long  fd 
)

Definition at line 639 of file actions.c.

References elementsof, exerror(), and Expr_s::file.

Referenced by getval().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cmppair()

static int cmppair ( void *  k1,
void *  k2 
)
static

Definition at line 263 of file actions.c.

◆ colorx()

char * colorx ( Expr_t ex,
char *  incolor,
char *  fmt 
)

Definition at line 790 of file actions.c.

References agxbfree(), agxbprint(), agxbuse(), alpha, color(), COLOR_OK, colorxlate(), exstring(), HSVA_DOUBLE, RGBA_BYTE, type, and agxbuf::u.

Referenced by getval().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ compare()

int compare ( Agobj_t l,
Agobj_t r 
)

Definition at line 687 of file actions.c.

References AGID, AGTYPE, and NULL.

Referenced by binary(), and SWIG_MangledTypeQueryModule().

Here is the caller graph for this function:

◆ compOf()

Agraph_t * compOf ( Agraph_t g,
Agnode_t n 
)

Definition at line 424 of file actions.c.

References agfstnode(), AGID, agidnode(), agnxtnode(), cc_dfs(), CCUNMARK, cg(), id, and openSubg().

Referenced by getval().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ copy()

Agobj_t * copy ( Agraph_t g,
Agobj_t obj 
)

Definition at line 156 of file actions.c.

References aghead, AGINEDGE, AGMKOUT, agnameof(), AGNODE, AGOUTEDGE, AGRAPH, agtail, AGTYPE, copyAttr(), exerror(), kind, openEdge(), openG(), openNode(), openSubg(), and UNREACHABLE.

Referenced by cloneGraph(), cloneSubg(), getval(), gv_strdup(), gv_strndup(), prformat(), push(), and SWIG_Guile_NewMemberObj().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ copyAttr()

int copyAttr ( Agobj_t src,
Agobj_t tgt 
)

Definition at line 122 of file actions.c.

References agattr(), agattrsym(), aghtmlstr(), agnxtattr(), agraphof(), agstrdup_html(), agstrfree(), AGTYPE, agxget(), agxset(), Agsym_s::defval, and Agsym_s::name.

Referenced by cloneG(), cloneO(), and copy().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ deleteObj()

int deleteObj ( Agraph_t g,
Agobj_t obj 
)

Definition at line 519 of file actions.c.

References agclose(), agdelete(), agnameof(), AGRAPH, agraphof(), agroot(), AGTYPE, error(), ERROR_WARNING, and gData.

Referenced by getval().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ freadFile()

Agraph_t * freadFile ( Expr_t ex,
long long  fd 
)

Definition at line 611 of file actions.c.

References elementsof, exerror(), Expr_s::file, and readG().

Referenced by getval().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ fwriteFile()

int fwriteFile ( Expr_t ex,
Agraph_t g,
long long  fd 
)

Definition at line 601 of file actions.c.

References elementsof, exerror(), Expr_s::file, and sfioWrite().

Referenced by getval().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gvelapsed_sec()

double gvelapsed_sec ( void  )

Definition at line 870 of file actions.c.

References DIFF_IN_SECS, GET_TIME, S, and T.

Referenced by gvpr_core().

Here is the caller graph for this function:

◆ gvstart_timer()

void gvstart_timer ( void  )

Definition at line 868 of file actions.c.

References GET_TIME, and T.

Referenced by gvpr_core().

Here is the caller graph for this function:

◆ indexOf()

int indexOf ( char *  s1,
char *  s2 
)

Definition at line 72 of file actions.c.

References NULL, and s1().

Referenced by getval().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ioflush()

static int ioflush ( void *  chan)
static

Definition at line 44 of file actions.c.

◆ iofread()

static int iofread ( void *  chan,
char *  buf,
int  bufsize 
)
static

Definition at line 36 of file actions.c.

References read().

Here is the call graph for this function:

◆ ioputstr()

static int ioputstr ( void *  chan,
const char *  str 
)
static

Definition at line 42 of file actions.c.

References str.

◆ isEdge()

Agedge_t * isEdge ( Agraph_t g,
Agnode_t t,
Agnode_t h,
char *  key 
)

Definition at line 446 of file actions.c.

References agedge(), agroot(), key, and sameG().

Referenced by getval(), and strdup_and_subst_obj0().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ lockGraph()

int lockGraph ( Agraph_t g,
int  v 
)

Definition at line 490 of file actions.c.

References agclose(), agroot(), error(), ERROR_WARNING, and gData.

Referenced by getval().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ mapEdge()

static Agedge_t * mapEdge ( Dt_t emap,
Agedge_t e 
)
static

Definition at line 204 of file actions.c.

References dtmatch, NULL, and edgepair_t::val.

Referenced by cloneSubg().

Here is the caller graph for this function:

◆ match()

size_t match ( char *  str,
char *  pat 
)

Definition at line 106 of file actions.c.

References SIZE_MAX, str, strgrpmatch(), and sub.

Referenced by getval(), strgrpmatch(), and svg_size().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ openFile()

int openFile ( Expr_t ex,
const char *  fname,
const char *  mode 
)

Definition at line 621 of file actions.c.

References elementsof, exerror(), Expr_s::file, and fname.

Here is the call graph for this function:

◆ readFile()

Agraph_t * readFile ( char *  f)

Definition at line 583 of file actions.c.

References exerror(), exwarn(), and readG().

Referenced by getval().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ readLine()

char * readLine ( Expr_t ex,
long long  fd 
)

Definition at line 664 of file actions.c.

References agxbfree(), agxbputc(), agxbuse(), elementsof, exerror(), exstring(), and Expr_s::file.

Referenced by getval().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ rindexOf()

long rindexOf ( char *  s1,
char *  s2 
)

Definition at line 80 of file actions.c.

References s1().

Referenced by getval().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sameG()

Agraph_t * sameG ( void *  p1,
void *  p2,
char *  fn,
char *  msg 
)

Definition at line 52 of file actions.c.

References agraphof(), agroot(), error(), ERROR_WARNING, KINDS, and OBJ.

Referenced by addEdge(), addNode(), isEdge(), and openEdge().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sfioWrite()

int sfioWrite ( Agraph_t g,
FILE *  fp 
)

Definition at line 548 of file actions.c.

References agwrite(), Agraph_s::clos, Agclos_s::disc, gprIoDisc, and Agdisc_s::io.

Referenced by fwriteFile(), getval(), gvpr_core(), and writeFile().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ toHtml()

char * toHtml ( Agraph_t g,
char *  arg 
)

Definition at line 756 of file actions.c.

References agstrdup_html().

Referenced by getval().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ toLower()

char * toLower ( Expr_t pgm,
char *  src 
)

Definition at line 718 of file actions.c.

References exstralloc(), gv_tolower(), len(), and NULL.

Referenced by getval().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ toUpper()

char * toUpper ( Expr_t pgm,
char *  src 
)

Definition at line 737 of file actions.c.

References exstralloc(), gv_toupper(), len(), and NULL.

Referenced by getval().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ writeFile()

int writeFile ( Agraph_t g,
char *  f 
)

Definition at line 562 of file actions.c.

References exerror(), exwarn(), and sfioWrite().

Referenced by getval().

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ edgepair

Dtdisc_t edgepair
static
Initial value:
= {
.key = offsetof(edgepair_t, key),
.size = sizeof(Agedge_t *),
.link = offsetof(edgepair_t, link),
.comparf = cmppair,
}
static int cmppair(void *k1, void *k2)
Definition actions.c:263
disc key
Definition exparse.y:214

Definition at line 274 of file actions.c.

Referenced by cloneGraph().

◆ gprIoDisc

Agiodisc_t gprIoDisc = {iofread, ioputstr, ioflush}
static

Definition at line 46 of file actions.c.

Referenced by sfioWrite().

◆ T

mytime_t T
static

Definition at line 866 of file actions.c.

Referenced by gvelapsed_sec(), and gvstart_timer().