From: ellson Date: Tue, 18 Oct 2005 18:54:05 +0000 (+0000) Subject: use exit status codes, X-Git-Tag: LAST_LIBGRAPH~32^2~7212 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=49178f3ed4abe4b54b1ac333905517549e8d2ee3;p=graphviz use exit status codes, --- diff --git a/contrib/diffimg/Makefile b/contrib/diffimg/Makefile index 23d972d4d..7f00ec2ac 100644 --- a/contrib/diffimg/Makefile +++ b/contrib/diffimg/Makefile @@ -10,9 +10,9 @@ GRAPH = "digraph G { hello -> world }" test: diffimg echo $(GRAPH) | dot -Tpng:cg >hello1.png echo $(GRAPH) | dot -Tpng:cg >hello2.png - ./diffimg hello1.png hello2.png >test1.png + if `./diffimg hello1.png hello2.png >test1.png`;then echo same;else echo different;fi echo $(GRAPH) | dot -Grankdir=LR -Tpng:cg >hello2.png - ./diffimg hello1.png hello2.png >test2.png + if `./diffimg hello1.png hello2.png >test2.png`;then echo same;else echo different;fi dist: clean mkdir diffimg-$(VERSION) diff --git a/contrib/diffimg/diffimg.c b/contrib/diffimg/diffimg.c index 06eddf553..74808b038 100644 --- a/contrib/diffimg/diffimg.c +++ b/contrib/diffimg/diffimg.c @@ -32,6 +32,7 @@ #include #include #include +#include #include #define NOT(v) (!(v)) @@ -54,12 +55,12 @@ static gdImagePtr imageLoad (char *filename) ext = strrchr(filename, '.'); if (!ext) { fprintf(stderr, "Filename \"%s\" has no file extension.\n", filename); - exit(-1); + exit(EX_USAGE); } rc = stat(filename, &statbuf); if (rc) { fprintf(stderr, "Failed to stat \"%s\"\n", filename); - exit(-1); + exit(EX_NOINPUT); } if (strcasecmp(ext, ".ps") == 0) { ext = ".png"; @@ -80,14 +81,14 @@ static gdImagePtr imageLoad (char *filename) free(tmp); if (!f) { fprintf(stderr, "Failed to open converted \"%s%s\"\n", filename, ext); - exit(-1); + exit(EX_NOINPUT); } } else { f = fopen(filename, "rb"); if (!f) { fprintf(stderr, "Failed to open \"%s\"\n", filename); - exit(-1); + exit(EX_NOINPUT); } } im = 0; @@ -100,7 +101,7 @@ static gdImagePtr imageLoad (char *filename) fclose(f); if (!im) { fprintf(stderr, "Loading image from file \"%s\" failed!\n", filename); - exit(-1); + exit(EX_DATAERR); } return im; } @@ -134,7 +135,7 @@ int main(int argc, char **argv) if (argc < 3) { fprintf(stderr, "Usage: diffimg image1 image2 [outimage]\n"); - exit(-1); + exit(EX_USAGE); } A = imageLoad(argv[1]); B = imageLoad(argv[2]); @@ -142,7 +143,7 @@ int main(int argc, char **argv) minSX = (gdImageSX(A) < gdImageSX(B)) ? gdImageSX(A) : gdImageSX(B); minSY = (gdImageSY(A) < gdImageSY(B)) ? gdImageSY(A) : gdImageSY(B); maxSX = (gdImageSX(A) > gdImageSX(B)) ? gdImageSX(A) : gdImageSX(B); - maxSY = (gdImageSX(A) > gdImageSX(B)) ? gdImageSX(A) : gdImageSX(B); + maxSY = (gdImageSY(A) > gdImageSY(B)) ? gdImageSY(A) : gdImageSY(B); C = gdImageCreatePalette (maxSX, maxSY); @@ -165,6 +166,6 @@ int main(int argc, char **argv) gdImageDestroy(B); gdImageDestroy(C); - return (rc ? 0 : 1); + return (rc ? EXIT_FAILURE : EXIT_SUCCESS); }