emergency commit
[cl-cudd.git] / distr / dddmp / dddmpDbg.c
blob88304f5af457f128488d62068c53d06ffb57a347
1 /**CFile**********************************************************************
3 FileName [dddmpDbg.c]
5 PackageName [dddmp]
7 Synopsis [Functions to display BDD files]
9 Description [Functions to display BDD files in binary format
12 Author [Gianpiero Cabodi and Stefano Quer]
14 Copyright [
15 Copyright (c) 2004 by Politecnico di Torino.
16 All Rights Reserved. This software is for educational purposes only.
17 Permission is given to academic institutions to use, copy, and modify
18 this software and its documentation provided that this introductory
19 message is not removed, that this software and its documentation is
20 used for the institutions' internal research and educational purposes,
21 and that no monies are exchanged. No guarantee is expressed or implied
22 by the distribution of this code.
23 Send bug-reports and/or questions to:
24 {gianpiero.cabodi,stefano.quer}@polito.it.
27 ******************************************************************************/
29 #include "dddmpInt.h"
31 /*---------------------------------------------------------------------------*/
32 /* Stucture declarations */
33 /*---------------------------------------------------------------------------*/
35 /*---------------------------------------------------------------------------*/
36 /* Type declarations */
37 /*---------------------------------------------------------------------------*/
39 /*---------------------------------------------------------------------------*/
40 /* Variable declarations */
41 /*---------------------------------------------------------------------------*/
43 /*---------------------------------------------------------------------------*/
44 /* Macro declarations */
45 /*---------------------------------------------------------------------------*/
48 /**AutomaticStart*************************************************************/
50 /*---------------------------------------------------------------------------*/
51 /* Static function prototypes */
52 /*---------------------------------------------------------------------------*/
55 /**AutomaticEnd***************************************************************/
58 /*---------------------------------------------------------------------------*/
59 /* Definition of exported functions */
60 /*---------------------------------------------------------------------------*/
63 /**Function********************************************************************
65 Synopsis [Display a binary dump file in a text file]
67 Description [Display a binary dump file in a text file]
69 SideEffects [None]
71 SeeAlso [Dddmp_cuddBddStore , Dddmp_cuddBddLoad ]
73 ******************************************************************************/
75 int
76 Dddmp_cuddBddDisplayBinary(
77 char *fileIn /* IN: name of binary file */,
78 char *fileOut /* IN: name of text file */
81 FILE *fp, *fpo;
82 int id, size;
83 struct binary_dd_code code;
84 char buf[1000];
85 int nnodes, i;
87 fp = fopen (fileIn, "rb");
88 if (fp == 0) {
89 return (0);
92 fpo = fopen (fileOut, "w");
93 if (fpo == 0) {
94 return (0);
97 while (fgets(buf, 999,fp)!=NULL) {
98 fprintf (fpo, "%s", buf);
99 if (strncmp(buf, ".nnodes", 7) == 0) {
100 sscanf (buf, "%*s %d", &nnodes);
102 if (strncmp(buf, ".rootids", 8) == 0) {
103 break;
107 for (i=1; i<=nnodes; i++) {
108 if (feof(fp)) {
109 return (0);
111 if (DddmpReadCode(fp,&code) == 0) {
112 return (0);
114 fprintf (fpo, "c : v %d | T %d | E %d\n",
115 (int)code.V, (int)code.T,
116 (code.Ecompl ? -(int)(code.E) : (int)(code.E)));
117 if (code.V == DDDMP_TERMINAL) {
118 continue;
120 if (code.V <= DDDMP_RELATIVE_ID) {
121 size = DddmpReadInt(fp,&id);
122 if (size == 0) {
123 return (0);
125 fprintf(fpo, "v(%d): %d\n", size, id);
127 if (code.T <= DDDMP_RELATIVE_ID) {
128 size = DddmpReadInt(fp,&id);
129 if (size == 0) {
130 return (0);
132 fprintf(fpo, "T(%d): %d\n", size, id);
134 if (code.E <= DDDMP_RELATIVE_ID) {
135 size = DddmpReadInt(fp,&id);
136 if (size == 0) {
137 return (0);
139 fprintf(fpo, "E(%d): %d\n", size, id);
144 fgets(buf, 999,fp);
145 if (strncmp(buf, ".end", 4) != 0) {
146 return (0);
149 fprintf(fpo, ".end");
151 fclose(fp);
152 fclose(fpo);
154 return (1);
158 /*---------------------------------------------------------------------------*/
159 /* Definition of internal functions */
160 /*---------------------------------------------------------------------------*/
162 /*---------------------------------------------------------------------------*/
163 /* Definition of static functions */
164 /*---------------------------------------------------------------------------*/