Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include <stdio.h>
00024 #include <sys/types.h>
00025 #include <sys/stat.h>
00026 #include <unistd.h>
00027 #include <stdlib.h>
00028 #include <fcntl.h>
00029 #include <time.h>
00030 #include <errno.h>
00031 #include <math.h>
00032
00033 #include "../type.h"
00034 #include "../graph.h"
00035
00036 #include "opt.h"
00037
00038 int main(int argc, char **argv)
00039 {
00040 dglGraph_s graph;
00041 int nret, fd;
00042
00043
00044
00045 char *pszGraph;
00046 char *pszGraphOut;
00047
00048 GNO_BEGIN
00049 GNO_OPTION("g", "graph", NULL, &pszGraph, "Input Graph file")
00050 GNO_OPTION("o", "graphout", NULL, &pszGraphOut, "Output Graph file")
00051 GNO_END if (GNO_PARSE(argc, argv) < 0)
00052 {
00053 return 1;
00054 }
00055
00056
00057
00058
00059 printf("Graph read:\n");
00060 if ((fd = open(pszGraph, O_RDONLY)) < 0) {
00061 perror("open");
00062 return 1;
00063 }
00064 nret = dglRead(&graph, fd);
00065 if (nret < 0) {
00066 fprintf(stderr, "dglRead error: %s\n", dglStrerror(&graph));
00067 return 1;
00068 }
00069 close(fd);
00070 printf("Done.\n");
00071
00072
00073 printf("Graph unflatten:\n");
00074 nret = dglUnflatten(&graph);
00075 if (nret < 0) {
00076 fprintf(stderr, "dglUnflatten error: %s\n", dglStrerror(&graph));
00077 return 1;
00078 }
00079 printf("Done.\n");
00080
00081
00082 printf("Graph flatten:\n");
00083 nret = dglFlatten(&graph);
00084 printf("Done.\n");
00085
00086
00087 if (pszGraphOut) {
00088 printf("Graph write:\n");
00089 if ((fd = open(pszGraphOut, O_WRONLY | O_CREAT | O_TRUNC, 0666)) < 0) {
00090 perror("open");
00091 return 1;
00092 }
00093 dglWrite(&graph, fd);
00094 if (nret < 0) {
00095 fprintf(stderr, "dglWrite error: %s\n", dglStrerror(&graph));
00096 return 1;
00097 }
00098 close(fd);
00099 printf("Done.\n");
00100 }
00101
00102 dglRelease(&graph);
00103 return 0;
00104 }