Initial snark14m import
[snark14.git] / src / snark / recon.c
1 /*
2  ***********************************************************
3  $SNARK_Header: S N A R K  1 4 - A PICTURE RECONSTRUCTION PROGRAM $
4  $HeadURL: svn://dig.cs.gc.cuny.edu/snark/trunk/src/snark/recon.c $
5  $LastChangedRevision: 94 $
6  $Date: 2014-07-02 18:53:30 -0400 (Wed, 02 Jul 2014) $
7  $Author: agulati $
8  ***********************************************************
9
10  Previously part of :*/
11
12 /*--------------------------------------------------------------------------
13  Super Snark V 1.0
14  Written by Jingsheng Zheng... November 1992
15
16  Modified by Jolyon Browne... June 1993
17  ----------------------------------------------------------------------------*/
18
19 #include <string.h>
20 #include <strings.h>
21 #include <stdlib.h>
22
23 #include "experimenter.h"
24 #include "errorc.h"
25 #include "recon.h"
26
27 /*--------------------------------------------------------------------------
28
29  This function echos the information stored in the file specified on
30  line 4 of the SuperSNARK input sequence. This information is sent to the
31  SNARK input stream.
32
33  INPUTS:
34  rec_flname - file containing information about the algorithms to be
35  executed. This is the file specified on line 4 of the
36  SuperSNARK input sequence.
37  exp_num - experiment number.
38  run_num - run number
39
40  OUTPUTS:
41  none
42  ----------------------------------------------------------------------------*/
43
44 void recon(char* rec_flname, int exp_num, int run_num)
45 {
46         char string[MAXLINESIZE];
47         FILE *recfl;
48
49         if ((recfl = fopen(rec_flname, "r")) == NULL)
50         {
51                 errorc("error in opening file", rec_flname);
52         }
53
54         while ((fgets(string, sizeof(string), recfl)) != NULL)
55         {
56                 while (isSkip(string)) //it's a comment line,
57                 {                    //echo it to output and read next line
58                         if (isComment(string))
59                                 fprintf(pstream, "%s", string);
60                         if (fgets(string, sizeof(string), recfl) == NULL)
61                                 break;
62                 }
63                 if (strncasecmp(string, "exec", 4) == 0)
64                 {
65                         fprintf(pstream, "%s", string);
66                         if ((fgets(string, sizeof(string), recfl)) != NULL)
67                         {
68                                 while (isSkip(string)) //it's a comment line,
69                                 {                    //echo it to output and read next line
70                                         if (isComment(string))
71                                                 fprintf(pstream, "%s", string);
72                                         if (fgets(string, sizeof(string), recfl) == NULL)
73                                                 break;
74                                 }
75                                 string[strlen(string) - 1] = '\0';
76                         }
77                         fprintf(pstream, "%s experiment= %d run= %d\n", string, exp_num, run_num);
78                 }
79                 else
80                 {
81                         fprintf(pstream, "%s", string);
82                 }
83         }
84
85         fclose(recfl);
86 }