62char *option[N_OPTIONS] = {
71 "Usage: convert_to_bdd [<database_file>] [<output_file>]\n"
72 " [-pipe=[input][,output]]\n"
73 " [-goodElements=<list_of_base_IDs>]\n"
74 " [-badElements=<list_of_base_IDs>]\n"
76 " [-failedSubTrees=<list_of_sub_tree_IDs>]\n"
78 " -pipe=<input>,<output> Enable piping for input and/or output.\n"
79 " -goodElements=<base_IDs> Comma-separated list of base elements with fault probability 0.\n"
80 " -badElements=<base_IDs> Comma-separated list of base elements with fault probability 1.\n"
81 " -failedSubTrees=<sub_tree_IDs> Comma-separated list of sub-trees to compute.\n"
82 " -verbose Enable verbose output for detailed processing information.\n\n";
87 double probability, ps, pes, MIF, DIF;
89 char *guidance, *description;
97 double probability, p1, p0, ps, pes;
99 char *description, *guidance, *label;
108 char *description, *tree_name, *typeDesc;
117ITE *bdd_ite_cal(
ITE *ite1,
ITE *ite2,
short type);
118ITE *bdd_base_ite_cal(
BASE *base,
ITE *ite,
short type);
119ITE *bdd_base_base_cal(
BASE *base1,
BASE *base2,
short type);
120void load_data_base(
char *filename);
121void print_sub_tree(
ITE *ite);
122short is_base(
ITE *ite);
123void free_cal_ite(
ITE *ite);
124void locate_tree_id();
125double compute_ps(
ITE *ite);
126void SetupOutputFile(
char *outputFile,
SDDS_DATASET *outData);
129#define STACKSIZE 2000
130long treeStack1[STACKSIZE];
131long treeStackptr1 = 0;
132long treeStack[STACKSIZE];
133long treeStackptr = 0;
135long push_node(
long ID);
137void push_sub_tree(
ITE *ite);
138void push_sub_tree1(
ITE *ite);
139double compute_ps(
ITE *ite);
140void compute_sub_tree_ps(
ITE *ite,
SDDS_DATASET *outData,
long treeIndex);
141long push_node1(
long ID);
145static BASE **base = NULL;
146static long bases = 0;
148static long sub_trees = 0;
149static ITE **ite = NULL;
152static ITE **ite_ptr = NULL;
153static long ite_ptrs = 0;
154static long verbose = 0;
156int main(
int argc,
char **argv) {
159 long i, j, alldone = 0, ready, tree_ID;
160 char *inputFile = NULL, *outputFile = NULL;
162 char **badBase = NULL, **goodBase = NULL, **failedTree = NULL;
163 long badBases = 0, goodBases = 0, failedTrees = 0, i_arg, tmpfile_used = 0, compute = 0;
164 unsigned long pipeFlags = 0;
166 argc =
scanargs(&s_arg, argc, argv);
168 fprintf(stderr,
"Error: Insufficient arguments provided.\n\n%s", USAGE);
172 for (i_arg = 1; i_arg < argc; i_arg++) {
173 if (s_arg[i_arg].arg_type == OPTION) {
175 switch (
match_string(s_arg[i_arg].list[0], option, N_OPTIONS, 0)) {
176 case CLO_GOOD_ELEMENTS:
177 goodBases = s_arg[i_arg].n_items - 1;
178 goodBase = malloc(
sizeof(*goodBase) * goodBases);
180 fprintf(stderr,
"Error: Memory allocation failed for goodBase.\n");
183 for (i = 0; i < goodBases; i++)
184 goodBase[i] = s_arg[i_arg].list[i + 1];
186 case CLO_BAD_ELEMENTS:
187 badBases = s_arg[i_arg].n_items - 1;
188 badBase = malloc(
sizeof(*badBase) * badBases);
190 fprintf(stderr,
"Error: Memory allocation failed for badBase.\n");
193 for (i = 0; i < badBases; i++)
194 badBase[i] = s_arg[i_arg].list[i + 1];
196 case CLO_FAILED_SUB_TREES:
197 failedTrees = s_arg[i_arg].n_items - 1;
198 failedTree = malloc(
sizeof(*failedTree) * failedTrees);
200 fprintf(stderr,
"Error: Memory allocation failed for failedTree.\n");
203 for (i = 0; i < failedTrees; i++)
204 failedTree[i] = s_arg[i_arg].list[i + 1];
207 if (!
processPipeOption(s_arg[i_arg].list + 1, s_arg[i_arg].n_items - 1, &pipeFlags)) {
208 fprintf(stderr,
"Error: Invalid -pipe syntax.\n");
216 fprintf(stderr,
"Unknown option: %s\n", s_arg[i_arg].list[0]);
221 inputFile = s_arg[i_arg].list[0];
222 else if (!outputFile)
223 outputFile = s_arg[i_arg].list[0];
225 fprintf(stderr,
"Error: Too many filenames provided (%s).\n", s_arg[i_arg].list[0]);
231 processFilenames(
"convert_to_bdd", &inputFile, &outputFile, pipeFlags, 1, &tmpfile_used);
233 load_data_base(inputFile);
237 for (i = 0; i < goodBases; i++) {
238 for (j = 0; j < bases; j++) {
239 if (strcmp(goodBase[i], base[j]->label) == 0) {
240 base[j]->probability = 0.0;
249 for (i = 0; i < badBases; i++) {
250 for (j = 0; j < bases; j++) {
251 if (strcmp(badBase[i], base[j]->label) == 0) {
252 base[j]->probability = 1.0;
260 SetupOutputFile(outputFile, &outData);
262 for (i = 0; i < sub_trees; i++) {
264 if (sub_tree[i].all_base) {
266 fprintf(stdout,
"\nSub-tree Name: %s, ID: %d, ITE Structure:\n", sub_tree[i].tree_name, sub_tree[i].ID);
267 print_sub_tree(sub_tree[i].CAL_ITE);
270 for (j = 0; j < failedTrees; j++) {
271 if (strcmp(sub_tree[i].tree_name, failedTree[j]) == 0) {
280 compute_sub_tree_ps(sub_tree[i].CAL_ITE, &outData, i);
286 for (i = 0; i < sub_trees; i++) {
287 if (sub_tree[i].calculated)
292 for (j = 0; j < sub_tree[i].ites; j++) {
293 tree_ID = sub_tree[i].tree_ID[j];
294 if (tree_ID >= 0 && sub_tree[tree_ID].calculated == 0) {
300 if (sub_tree[i].ites == 1)
301 sub_tree[i].CAL_ITE = sub_tree[i].ite_ptr[0];
303 if (sub_tree[i].ite_ptr[0]->base && is_base(sub_tree[i].ite_ptr[0]))
304 ite1 = sub_tree[i].ite_ptr[0];
306 ite1 = sub_tree[sub_tree[i].tree_ID[0]].CAL_ITE;
308 if (sub_tree[i].ite_ptr[1]->base && is_base(sub_tree[i].ite_ptr[1]))
309 ite2 = sub_tree[i].ite_ptr[1];
311 ite2 = sub_tree[sub_tree[i].tree_ID[1]].CAL_ITE;
313 sub_tree[i].CAL_ITE = bdd_ite_cal(ite1, ite2, sub_tree[i].type);
315 for (j = 2; j < sub_tree[i].ites; j++) {
316 if (sub_tree[i].ite_ptr[j]->base && is_base(sub_tree[i].ite_ptr[j]))
317 ite1 = sub_tree[i].ite_ptr[j];
319 ite1 = sub_tree[sub_tree[i].tree_ID[j]].CAL_ITE;
321 sub_tree[i].CAL_ITE = bdd_ite_cal(sub_tree[i].CAL_ITE, ite1, sub_tree[i].type);
325 fprintf(stdout,
"\nSub-tree Name: %s, ID: %d, ITE Structure:\n", sub_tree[i].tree_name, sub_tree[i].ID);
326 print_sub_tree(sub_tree[i].CAL_ITE);
331 for (j = 0; j < failedTrees; j++) {
332 if (strcmp(sub_tree[i].tree_name, failedTree[j]) == 0) {
341 compute_sub_tree_ps(sub_tree[i].CAL_ITE, &outData, i);
343 sub_tree[i].calculated = 1;
358 for (i = 0; i < bases; i++) {
359 free(base[i]->guidance);
360 free(base[i]->label);
361 free(base[i]->description);
366 for (i = 0; i < ites; i++) {
368 free((
ITE *)(ite[i]->left));
370 free((
ITE *)(ite[i]->right));
371 free(ite[i]->description);
372 free(ite[i]->guidance);
378 for (i = 0; i < sub_trees; i++) {
379 free(sub_tree[i].description);
380 free(sub_tree[i].tree_name);
381 free(sub_tree[i].typeDesc);
382 free(sub_tree[i].ite_ptr);
383 free(sub_tree[i].tree_ID);
387 for (i = 0; i < ite_ptrs; i++) {
388 if (ite_ptr[i]->guidance)
389 free(ite_ptr[i]->guidance);
390 if (ite_ptr[i]->description)
391 free(ite_ptr[i]->description);
392 if (ite_ptr[i]->label)
393 free(ite_ptr[i]->label);
402short is_base(
ITE *ite) {
403 return (ite->left == NULL && ite->right == NULL) || ite->is_base;
406ITE *bdd_base_base_cal(
BASE *base1,
BASE *base2,
short type) {
407 ITE *tmp = calloc(1,
sizeof(*tmp));
408 BASE *base_s, *base_b;
411 fprintf(stderr,
"Error: Memory allocation failed in bdd_base_base_cal.\n");
415 tmp->left = tmp->right = NULL;
418 ite_ptr =
SDDS_Realloc(ite_ptr,
sizeof(*ite_ptr) * (ite_ptrs + 1));
420 fprintf(stderr,
"Error: Memory reallocation failed in bdd_base_base_cal.\n");
423 ite_ptr[ite_ptrs++] = tmp;
425 if (base1->id == base2->id) {
432 if (base1->id < base2->id) {
443 tmp->left = calloc(1,
sizeof(
ITE));
445 fprintf(stderr,
"Error: Memory allocation failed for tmp->left in bdd_base_base_cal.\n");
448 ((
ITE *)tmp->left)->base = base_b;
449 ((
ITE *)tmp->left)->left = ((
ITE *)tmp->left)->right = NULL;
453 ite_ptr =
SDDS_Realloc(ite_ptr,
sizeof(*ite_ptr) * (ite_ptrs + 1));
455 fprintf(stderr,
"Error: Memory reallocation failed for tmp->left in bdd_base_base_cal.\n");
458 ite_ptr[ite_ptrs++] = (
ITE *)tmp->left;
463 tmp->right = calloc(1,
sizeof(
ITE));
465 fprintf(stderr,
"Error: Memory allocation failed for tmp->right in bdd_base_base_cal.\n");
468 ((
ITE *)tmp->right)->base = base_b;
469 ((
ITE *)tmp->right)->left = ((
ITE *)tmp->right)->right = NULL;
471 ite_ptr =
SDDS_Realloc(ite_ptr,
sizeof(*ite_ptr) * (ite_ptrs + 1));
473 fprintf(stderr,
"Error: Memory reallocation failed for tmp->right in bdd_base_base_cal.\n");
476 ite_ptr[ite_ptrs++] = (
ITE *)tmp->right;
482ITE *bdd_base_ite_cal(
BASE *base,
ITE *ite,
short type) {
483 ITE *tmp = calloc(1,
sizeof(*tmp));
485 BASE *base1 = ite->base;
488 fprintf(stderr,
"Error: Memory allocation failed in bdd_base_ite_cal.\n");
492 ite_ptr =
SDDS_Realloc(ite_ptr,
sizeof(*ite_ptr) * (ite_ptrs + 1));
494 fprintf(stderr,
"Error: Memory reallocation failed in bdd_base_ite_cal.\n");
497 ite_ptr[ite_ptrs++] = tmp;
499 left = (
ITE *)ite->left;
500 right = (
ITE *)ite->right;
502 if (base->id < base1->id) {
513 }
else if (base->id > base1->id) {
514 tmp->base = ite->base;
517 tmp->left = calloc(1,
sizeof(
ITE));
519 fprintf(stderr,
"Error: Memory allocation failed for tmp->left in bdd_base_ite_cal.\n");
522 ((
ITE *)tmp->left)->base = base;
523 ((
ITE *)tmp->left)->left = ((
ITE *)tmp->left)->right = NULL;
525 ite_ptr =
SDDS_Realloc(ite_ptr,
sizeof(*ite_ptr) * (ite_ptrs + 1));
527 fprintf(stderr,
"Error: Memory reallocation failed for tmp->left in bdd_base_ite_cal.\n");
530 ite_ptr[ite_ptrs++] = (
ITE *)tmp->left;
535 tmp->left = bdd_base_ite_cal(base, (
ITE *)ite->left, type);
542 tmp->right = calloc(1,
sizeof(
ITE));
544 fprintf(stderr,
"Error: Memory allocation failed for tmp->right in bdd_base_ite_cal.\n");
547 ((
ITE *)tmp->right)->base = base;
548 ((
ITE *)tmp->right)->left = ((
ITE *)tmp->right)->right = NULL;
550 ite_ptr =
SDDS_Realloc(ite_ptr,
sizeof(*ite_ptr) * (ite_ptrs + 1));
552 fprintf(stderr,
"Error: Memory reallocation failed for tmp->right in bdd_base_ite_cal.\n");
555 ite_ptr[ite_ptrs++] = (
ITE *)tmp->right;
558 tmp->right = bdd_base_ite_cal(base, (
ITE *)ite->right, type);
574ITE *bdd_ite_cal(
ITE *ite1,
ITE *ite2,
short type) {
575 ITE *ite = calloc(1,
sizeof(*ite));
577 BASE *base1 = NULL, *base2 = NULL;
580 fprintf(stderr,
"Error: Memory allocation failed in bdd_ite_cal.\n");
584 if (!ite1 || !ite2) {
585 fprintf(stderr,
"Error: Null pointer provided to bdd_ite_cal().\n");
589 if (is_base(ite1) && is_base(ite2))
590 return bdd_base_base_cal(ite1->base, ite2->base, type);
593 return bdd_base_ite_cal(ite1->base, ite2, type);
595 return bdd_base_ite_cal(ite2->base, ite1, type);
600 ite_ptr =
SDDS_Realloc(ite_ptr,
sizeof(*ite_ptr) * (ite_ptrs + 1));
602 fprintf(stderr,
"Error: Memory reallocation failed in bdd_ite_cal.\n");
605 ite_ptr[ite_ptrs++] = ite;
607 if (base1->id == base2->id) {
608 ite->base = ite1->base;
609 if (ite1->left && ite2->left)
610 ite->left = bdd_ite_cal((
ITE *)ite1->left, (
ITE *)ite2->left, type);
616 ite->left = ite1->left ? ite1->left : ite2->left;
620 if (ite1->right && ite2->right)
621 ite->right = bdd_ite_cal((
ITE *)ite1->right, (
ITE *)ite2->right, type);
627 ite->right = ite1->right ? ite1->right : ite2->right;
631 if (base1->id < base2->id) {
638 ite->base = ite_l->base;
641 ite->left = bdd_ite_cal(ite_l->left, ite_r, type);
650 ite->right = bdd_ite_cal(ite_l->right, ite_r, type);
662void load_data_base(
char *filename) {
663 int32_t i, rows, pages, j, allbase, index;
666 char **guid = NULL, **desc = NULL, **label = NULL;
680 sub_tree =
SDDS_Realloc(sub_tree,
sizeof(*sub_tree) * (pages + 1));
682 fprintf(stderr,
"Error: Memory reallocation failed for sub_tree.\n");
686 sub_tree[pages].ites = rows;
687 sub_tree[pages].ite_ptr = malloc(
sizeof(
ITE *) * rows);
688 if (!sub_tree[pages].ite_ptr) {
689 fprintf(stderr,
"Error: Memory allocation failed for sub_tree[%" PRId32
"].ite_ptr.\n", pages);
693 sub_tree[pages].calculated = 0;
710 for (i = 0; i < rows; i++) {
715 for (j = 0; j < bases; j++) {
716 if (
id[i] == base[j]->
id) {
726 fprintf(stderr,
"Error: Memory reallocation failed for base.\n");
729 base[bases] = calloc(1,
sizeof(**base));
731 fprintf(stderr,
"Error: Memory allocation failed for base[%ld].\n", bases);
734 base[bases]->id =
id[i];
735 base[bases]->probability = prob[i];
743 sub_tree[pages].ite_ptr[i] = calloc(1,
sizeof(
ITE));
744 if (!sub_tree[pages].ite_ptr[i]) {
745 fprintf(stderr,
"Error: Memory allocation failed for sub_tree[%" PRId32
"].ite_ptr[%d].\n", pages, i);
749 sub_tree[pages].ite_ptr[i]->base = base[index];
750 sub_tree[pages].ite_ptr[i]->left = sub_tree[pages].ite_ptr[i]->right = NULL;
751 sub_tree[pages].ite_ptr[i]->ID =
id[i];
752 sub_tree[pages].ite_ptr[i]->probability = prob[i];
753 sub_tree[pages].ite_ptr[i]->is_base = 1;
759 ite_ptr =
SDDS_Realloc(ite_ptr,
sizeof(*ite_ptr) * (ite_ptrs + 1));
761 fprintf(stderr,
"Error: Memory reallocation failed for ite_ptr in load_data_base.\n");
764 ite_ptr[ite_ptrs++] = sub_tree[pages].ite_ptr[i];
769 for (j = 0; j < ites; j++) {
770 if (
id[i] == ite[j]->ID) {
780 fprintf(stderr,
"Error: Memory reallocation failed for ite.\n");
783 ite[ites] = calloc(1,
sizeof(
ITE));
785 fprintf(stderr,
"Error: Memory allocation failed for ite[%ld].\n", ites);
788 ite[ites]->ID =
id[i];
789 ite[ites]->base = NULL;
790 ite[ites]->probability = prob[i];
791 ite[ites]->is_base = 0;
799 sub_tree[pages].ite_ptr[i] = ite[index];
804 sub_tree[pages].ites = rows;
805 sub_tree[pages].all_base = allbase;
810 sub_tree[pages].CAL_ITE = sub_tree[pages].ite_ptr[0];
812 sub_tree[pages].CAL_ITE = bdd_ite_cal(sub_tree[pages].ite_ptr[0], sub_tree[pages].ite_ptr[1], sub_tree[pages].type);
813 for (j = 2; j < rows; j++) {
814 sub_tree[pages].CAL_ITE = bdd_ite_cal(sub_tree[pages].CAL_ITE, sub_tree[pages].ite_ptr[j], sub_tree[pages].type);
817 sub_tree[pages].calculated = 1;
834 fprintf(stdout,
"Total Bases: %ld, Total ITEs: %ld\n", bases, ites);
842long push_node(
long ID) {
843 if (treeStackptr >= STACKSIZE) {
844 fprintf(stderr,
"Error: Stack overflow.\n");
847 treeStack[treeStackptr++] = ID;
852 if (treeStackptr < 1) {
853 fprintf(stderr,
"Error: Too few items on stack.\n");
856 return treeStack[--treeStackptr];
859void print_sub_tree(
ITE *ite) {
863 push_node(ite->base->id);
864 fprintf(stdout,
"%ld\n", pop_node());
865 left = (
ITE *)ite->left;
866 right = (
ITE *)ite->right;
870 push_node(left->base->id);
871 fprintf(stdout,
"%ld ", pop_node());
875 push_node(right->base->id);
876 fprintf(stdout,
"%ld \n", pop_node());
878 print_sub_tree(left);
880 print_sub_tree(right);
883void free_cal_ite(
ITE *ite) {
887 left = (
ITE *)(ite->left);
888 right = (
ITE *)(ite->right);
889 if (!left && !right) {
901 if (is_base(right)) {
909void locate_tree_id() {
911 for (i = 0; i < sub_trees; i++) {
912 sub_tree[i].tree_ID = malloc(
sizeof(
long) * sub_tree[i].ites);
913 if (!sub_tree[i].tree_ID) {
914 fprintf(stderr,
"Error: Memory allocation failed for sub_tree[%ld].tree_ID.\n", i);
917 for (j = 0; j < sub_tree[i].ites; j++) {
918 sub_tree[i].tree_ID[j] = -1;
919 if (!(sub_tree[i].ite_ptr[j]->base)) {
920 for (k = 0; k < sub_trees; k++) {
921 if (sub_tree[i].ite_ptr[j]->ID == sub_tree[k].ID) {
922 sub_tree[i].tree_ID[j] = k;
926 if (sub_tree[i].tree_ID[j] < 0) {
927 fprintf(stderr,
"Error: No tree_ID found for ITE %ld of tree %ld (%s).\n",
928 j, i, sub_tree[i].tree_name);
936void push_sub_tree(
ITE *ite) {
938 push_node((
long)ite);
944 push_node((
long)left);
948 push_node((
long)right);
952 push_sub_tree(right);
955double compute_ps(
ITE *ite) {
956 ITE *left, *right, *c_ite = NULL;
957 long left_adr, right_adr;
960 while (treeStackptr1 > 0) {
961 right_adr = pop_node1();
962 left_adr = pop_node1();
963 c_ite = (
ITE *)pop_node1();
964 p = c_ite->base->probability;
968 left = (
ITE *)left_adr;
969 c_ite->p1 = left->ps;
971 if (right_adr == 0) {
974 right = (
ITE *)right_adr;
975 c_ite->p0 = right->ps;
977 c_ite->ps = p * c_ite->p1 + (1.0 - p) * c_ite->p0;
982void compute_sub_tree_ps(
ITE *ite,
SDDS_DATASET *outData,
long treeIndex) {
985 long t_bases = 0, i, index;
986 BASE **t_base = NULL, *base1;
990 PS = compute_ps(ite);
993 while (treeStackptr > 0) {
994 this_adr = pop_node();
995 if (this_adr != 1 && this_adr != 0) {
996 t_ite = (
ITE *)this_adr;
1000 t_base =
SDDS_Realloc(t_base,
sizeof(*t_base) * (t_bases + 1));
1002 fprintf(stderr,
"Error: Memory reallocation failed for t_base in compute_sub_tree_ps.\n");
1005 t_base[t_bases] = base1;
1008 for (i = 0; i < t_bases; i++) {
1009 if (base1->id == t_base[i]->id) {
1015 t_base =
SDDS_Realloc(t_base,
sizeof(*t_base) * (t_bases + 1));
1017 fprintf(stderr,
"Error: Memory reallocation failed for t_base in compute_sub_tree_ps.\n");
1020 t_base[t_bases] = base1;
1027 prob = base1->probability;
1030 base1->probability = 1.0;
1031 base1->ps = compute_ps(ite);
1034 base1->probability = 0.0;
1035 base1->pes = compute_ps(ite);
1038 base1->probability = prob;
1040 base1->MIF = base1->ps - base1->pes;
1041 base1->DIF = prob + prob * (1.0 - prob) * base1->MIF / PS;
1044 fprintf(stdout,
"Base %ld: prob=%.6f, ps=%.6f, pes=%.6f, MIF=%.6f, DIF=%.6f\n",
1045 base1->id, base1->probability, base1->ps, base1->pes, base1->MIF, base1->DIF);
1050 SDDS_PrintErrors(stdout, SDDS_VERBOSE_PrintErrors | SDDS_EXIT_PrintErrors);
1053 "TreeName", sub_tree[treeIndex].tree_name,
1054 "Description", sub_tree[treeIndex].description,
1055 "LogicalType", sub_tree[treeIndex].type,
1056 "LogicalTypeDesc", sub_tree[treeIndex].typeDesc,
1057 "ID", sub_tree[treeIndex].ID, NULL))
1058 SDDS_PrintErrors(stderr, SDDS_EXIT_PrintErrors | SDDS_VERBOSE_PrintErrors);
1060 for (i = 0; i < t_bases; i++) {
1062 "BaseID", t_base[i]->
id,
1063 "Label", t_base[i]->label,
1064 "Probability", t_base[i]->probability,
1065 "DIF", t_base[i]->DIF,
1066 "MIF", t_base[i]->MIF,
1067 "PS", t_base[i]->ps,
1068 "PES", t_base[i]->pes,
1069 "Description", t_base[i]->description,
1070 "Guidance", t_base[i]->guidance, NULL))
1071 SDDS_PrintErrors(stderr, SDDS_VERBOSE_PrintErrors | SDDS_EXIT_PrintErrors);
1075 SDDS_PrintErrors(stderr, SDDS_VERBOSE_PrintErrors | SDDS_EXIT_PrintErrors);
1081long push_node1(
long ID) {
1082 if (treeStackptr1 >= STACKSIZE) {
1083 fprintf(stderr,
"Error: Stack overflow in push_node1.\n");
1086 treeStack1[treeStackptr1++] = ID;
1090long pop_node1(
void) {
1091 if (treeStackptr1 < 1) {
1092 fprintf(stderr,
"Error: Too few items on stack in pop_node1.\n");
1095 return treeStack1[--treeStackptr1];
1098void push_sub_tree1(
ITE *ite) {
1100 push_node1((
long)ite);
1106 push_node1((
long)left);
1110 push_node1((
long)right);
1112 push_sub_tree1(left);
1114 push_sub_tree1(right);
1117void SetupOutputFile(
char *outputFile,
SDDS_DATASET *outData) {
1119 SDDS_PrintErrors(stdout, SDDS_VERBOSE_PrintErrors | SDDS_EXIT_PrintErrors);
1135 SDDS_PrintErrors(stdout, SDDS_VERBOSE_PrintErrors | SDDS_EXIT_PrintErrors);
1138 SDDS_PrintErrors(stdout, SDDS_VERBOSE_PrintErrors | SDDS_EXIT_PrintErrors);
SDDS (Self Describing Data Set) Data Types Definitions and Function Prototypes.
int32_t SDDS_SetRowValues(SDDS_DATASET *SDDS_dataset, int32_t mode, int64_t row,...)
int32_t SDDS_StartPage(SDDS_DATASET *SDDS_dataset, int64_t expected_n_rows)
int32_t SDDS_SetParameters(SDDS_DATASET *SDDS_dataset, int32_t mode,...)
int32_t SDDS_InitializeOutput(SDDS_DATASET *SDDS_dataset, int32_t data_mode, int32_t lines_per_row, const char *description, const char *contents, const char *filename)
Initializes the SDDS output dataset.
int32_t SDDS_DefineSimpleColumn(SDDS_DATASET *SDDS_dataset, const char *name, const char *unit, int32_t type)
Defines a simple data column within the SDDS dataset.
int32_t SDDS_DefineSimpleParameter(SDDS_DATASET *SDDS_dataset, const char *name, const char *unit, int32_t type)
Defines a simple data parameter within the SDDS dataset.
int32_t SDDS_WritePage(SDDS_DATASET *SDDS_dataset)
Writes the current data table to the output file.
int32_t SDDS_WriteLayout(SDDS_DATASET *SDDS_dataset)
Writes the SDDS layout header to the output file.
int32_t SDDS_FreeStringArray(char **string, int64_t strings)
Frees an array of strings by deallocating each individual string.
void SDDS_PrintErrors(FILE *fp, int32_t mode)
Prints recorded error messages to a specified file stream.
int32_t SDDS_CopyString(char **target, const char *source)
Copies a source string to a target string with memory allocation.
void * SDDS_Realloc(void *old_ptr, size_t new_size)
Reallocates memory to a new size.
#define SDDS_STRING
Identifier for the string data type.
#define SDDS_LONG
Identifier for the signed 32-bit integer data type.
#define SDDS_SHORT
Identifier for the signed short integer data type.
#define SDDS_DOUBLE
Identifier for the double data type.
char * delete_chars(char *s, char *t)
Removes all occurrences of characters found in string t from string s.
long match_string(char *string, char **option, long n_options, long mode)
Matches a given string against an array of option strings based on specified modes.
int scanargs(SCANNED_ARG **scanned, int argc, char **argv)
long processPipeOption(char **item, long items, unsigned long *flags)
void processFilenames(char *programName, char **input, char **output, unsigned long pipeFlags, long noWarnings, long *tmpOutputUsed)
void free_scanargs(SCANNED_ARG **scanned, int argc)