26 Tcl_AppendResult(interp,
"wrong # args: should be \"", argv[0],
27 " option ?arg arg ...?\"",
NULL);
32 Tcl_AppendResult(interp,
"node \"", argv[0],
"\" not found",
NULL);
37 if (
streq(
"addedge", argv[1])) {
38 if ((argc < 3) || (!(argc % 2))) {
39 Tcl_AppendResult(interp,
"wrong # args: should be \"", argv[0],
40 " addedge head ?attributename attributevalue? ?...?\"",
47 Tcl_AppendResult(interp,
"head node \"", argv[2],
"\" not found.",
53 Tcl_AppendResult(interp,
"nodes ", argv[0],
" and ", argv[2],
54 " are not in the same graph.",
NULL);
62 }
else if (
streq(
"delete", argv[1])) {
66 }
else if (
streq(
"findedge", argv[1])) {
68 Tcl_AppendResult(interp,
"wrong # args: should be \"", argv[0],
69 " findedge headnodename\"",
NULL);
73 Tcl_AppendResult(interp,
"head node \"", argv[2],
"\" not found.",
NULL);
77 Tcl_AppendResult(interp,
"edge \"", argv[0],
" - ",
obj2cmd(
head),
78 "\" not found.",
NULL);
84 }
else if (
streq(
"listattributes", argv[1])) {
88 }
else if (
streq(
"listedges", argv[1])) {
90 Tcl_AppendElement(interp,
obj2cmd(e));
94 }
else if (
streq(
"listinedges", argv[1])) {
96 Tcl_AppendElement(interp,
obj2cmd(e));
100 }
else if (
streq(
"listoutedges", argv[1])) {
102 Tcl_AppendElement(interp,
obj2cmd(e));
106 }
else if (
streq(
"queryattributes", argv[1])) {
107 for (i = 2; i < argc; i++) {
108 if (Tcl_SplitList(interp, argv[i], &argc2, (
const char ***)&argv2) !=
111 for (j = 0; j < argc2; j++) {
113 Tcl_AppendElement(interp,
agxget(n, a));
115 Tcl_AppendResult(interp,
"no attribute named \"", argv2[j],
"\"",
117 Tcl_Free((
char *)argv2);
121 Tcl_Free((
char *)argv2);
125 }
else if (
streq(
"queryattributevalues", argv[1])) {
126 for (i = 2; i < argc; i++) {
127 if (Tcl_SplitList(interp, argv[i], &argc2, (
const char ***)&argv2) !=
130 for (j = 0; j < argc2; j++) {
132 Tcl_AppendElement(interp, argv2[j]);
133 Tcl_AppendElement(interp,
agxget(n, a));
135 Tcl_AppendResult(interp,
"no attribute named \"", argv2[j],
"\"",
137 Tcl_Free((
char *)argv2);
141 Tcl_Free((
char *)argv2);
145 }
else if (
streq(
"setattributes", argv[1])) {
148 if (Tcl_SplitList(interp, argv[2], &argc2, (
const char ***)&argv2) !=
151 if ((argc2 == 0) || (argc2 % 2)) {
152 Tcl_AppendResult(interp,
"wrong # args: should be \"", argv[0],
153 "\" setattributes attributename attributevalue "
154 "?attributename attributevalue? ?...?",
156 Tcl_Free((
char *)argv2);
160 Tcl_Free((
char *)argv2);
162 if ((argc < 4) || (argc % 2)) {
163 Tcl_AppendResult(interp,
"wrong # args: should be \"", argv[0],
164 "\" setattributes attributename attributevalue "
165 "?attributename attributevalue? ?...?",
173 }
else if (
streq(
"showname", argv[1])) {
174 Tcl_SetResult(interp,
agnameof(n), TCL_STATIC);
178 Tcl_AppendResult(interp,
"bad option \"", argv[1],
"\": must be one of:",
179 "\n\taddedge, listattributes, listedges, listinedges,",
180 "\n\tlistoutedges, queryattributes, queryattributevalues,",
181 "\n\tsetattributes, showname.",
NULL);
186int nodecmd(ClientData clientData, Tcl_Interp *interp,
int argc,
187 const char *argv[]) {
char * agxget(void *obj, Agsym_t *sym)
Agedge_t * agedge(Agraph_t *g, Agnode_t *t, Agnode_t *h, char *name, int createflag)
Agedge_t * agnxtin(Agraph_t *g, Agedge_t *e)
Agedge_t * agfstout(Agraph_t *g, Agnode_t *n)
#define agfindedge(g, t, h)
Agedge_t * agnxtedge(Agraph_t *g, Agedge_t *e, Agnode_t *n)
Agedge_t * agnxtout(Agraph_t *g, Agedge_t *e)
Agedge_t * agfstedge(Agraph_t *g, Agnode_t *n)
Agedge_t * agfstin(Agraph_t *g, Agnode_t *n)
#define agfindnodeattr(g, a)
Agraph_t * agraphof(void *obj)
char * agnameof(void *)
returns a string descriptor for the object.
Agraph_t * agroot(void *obj)
static bool streq(const char *a, const char *b)
are a and b equal?
static int nodecmd_internal(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[])
int nodecmd(ClientData clientData, Tcl_Interp *interp, int argc, const char *argv[])
void listNodeAttrs(Tcl_Interp *interp, Agraph_t *g)
void deleteNode(gctx_t *gctx, Agraph_t *g, Agnode_t *n)
char * obj2cmd(void *obj)
void setnodeattributes(Agraph_t *g, Agnode_t *n, char *argv[], int argc)
void setedgeattributes(Agraph_t *g, Agedge_t *e, char *argv[], int argc)
void tcldot_argv_free(int argc, char *argv[])
free the strings pointed to by argv
char ** tcldot_argv_dup(int argc, const char *argv[])
duplicate the strings pointed to by argv as non-const strings
Agnode_t * cmd2n(const char *cmd)