~ubuntu-branches/ubuntu/vivid/psicode/vivid

« back to all changes in this revision

Viewing changes to src/lib/libciomr/psi_start.c

  • Committer: Bazaar Package Importer
  • Author(s): Michael Banck
  • Date: 2008-06-07 16:49:57 UTC
  • mfrom: (2.1.2 hardy)
  • Revision ID: james.westby@ubuntu.com-20080607164957-8pifvb133yjlkagn
Tags: 3.3.0-3
* debian/rules (DEB_MAKE_CHECK_TARGET): Do not abort test suite on
  failures.
* debian/rules (DEB_CONFIGURE_EXTRA_FLAGS): Set ${bindir} to /usr/lib/psi.
* debian/rules (install/psi3): Move psi3 file to /usr/bin.
* debian/patches/07_464867_move_executables.dpatch: New patch, add
  /usr/lib/psi to the $PATH, so that the moved executables are found.
  (closes: #464867)
* debian/patches/00list: Adjusted.

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
** psi_start()
26
26
**
27
27
** This function initializes the input, output files, file prefix, etc.,
28
 
** by checking command line arguments and environmental variables. It also initializes
29
 
** Input Parsing library.
 
28
** by checking command line arguments and environmental variables. It also 
 
29
** initializes the Input Parsing library.
30
30
**
31
31
** Arguments: 
32
32
**  \param argc       = number of command-line arguments passed
129
129
  /* default prefix is not assigned here yet because need to check input file first */
130
130
 
131
131
  /* open input and output files */
132
 
  infile = fopen(ifname, "r");
 
132
  if(ifname[0]=='-' && ifname[1]=='\x0')
 
133
    infile=stdin;
 
134
  else
 
135
    infile = fopen(ifname, "r");
133
136
  if (infile == NULL) {
134
137
    fprintf(stderr, "Error: could not open input file %s\n",ifname);
135
138
    return(PSI_RETURN_FAILURE);
136
139
  }
137
140
  if (overwrite_output)
138
 
    outfile = fopen(ofname, "w");
 
141
    {
 
142
      if(ofname[0]=='-' && ofname[1]=='\x0')
 
143
        outfile=stdout;
 
144
      else
 
145
        outfile = fopen(ofname, "w");
 
146
    }
139
147
  else
140
 
    outfile = fopen(ofname, "a");
 
148
    {
 
149
      if(ofname[0]=='-' && ofname[1]=='\x0')
 
150
        outfile=stdout;
 
151
      else
 
152
        outfile = fopen(ofname, "a");
 
153
    }
141
154
  if (outfile == NULL) {
142
155
    fprintf(stderr, "Error: could not open output file %s\n",ofname);
143
156
    return(PSI_RETURN_FAILURE);
154
167
    userhome = getenv("HOME");
155
168
    cfname = (char *) malloc((10+strlen(userhome))*sizeof(char));
156
169
    sprintf(cfname, "%s%s", userhome, "/.psirc");
 
170
    psirc = fopen(cfname, "r");
 
171
    free(cfname);
157
172
  }
158
 
  psirc = fopen(cfname, "r");
 
173
  else psirc = fopen(cfname, "r");
159
174
  if(psirc != NULL) {
160
175
    ip_append(psirc, stderr);
161
176
    fclose(psirc);
182
197
#if HAVE_PUTENV
183
198
  tmpstr1 = (char *) malloc(11+strlen(ifname));
184
199
  sprintf(tmpstr1, "PSI_INPUT=%s", ifname);
185
 
  putenv(tmpstr1);
 
200
  putenv(tmpstr1);  /* note potential memory leak */
186
201
#elif HAVE_SETENV
187
202
  setenv("PSI_OUTPUT",ifname,1);
188
203
#else
194
209
#if HAVE_PUTENV
195
210
  tmpstr1 = (char *) malloc(12+strlen(ofname));
196
211
  sprintf(tmpstr1, "PSI_OUTPUT=%s", ofname);
197
 
  putenv(tmpstr1);
 
212
  putenv(tmpstr1); /* note potential memory leak */
198
213
#elif HAVE_SETENV
199
214
  setenv("PSI_OUTPUT",ofname,1);
200
215
#else
206
221
#if HAVE_PUTENV
207
222
  tmpstr1 = (char *) malloc(12+strlen(fprefix));
208
223
  sprintf(tmpstr1, "PSI_PREFIX=%s", fprefix);
209
 
  putenv(tmpstr1);
 
224
  putenv(tmpstr1); /* note potential memory leak */
210
225
#elif HAVE_SETENV
211
226
  setenv("PSI_PREFIX",fprefix,1);
212
227
#else
252
267
}
253
268
 
254
269
/*!
255
 
** psi_ifname()
 
270
** psi_fprefix()
256
271
**
257
272
** This function returns the PSI file prefix
258
273
**