aboutsummaryrefslogtreecommitdiff
path: root/process_args.c
blob: 5c4655a41c8e484ee08e152aa8e4dcc35629d70b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include "process_args.h"
#include <stdio.h>
#include <stdlib.h>

FILE *lrs_ifp;
FILE *lrs_ofp;

void
lrs_overflow (int ignored) {
  fprintf (stderr, "lrs_overflow called. exiting\n");
  exit(1);
}

void process_args(int argc, char **argv,char *docstring){
  if (argc > 1 && argv[1][0]=='-' && argv[1][1]=='h') {
    fprintf(stderr,docstring);  
    fprintf(stderr,"\n\nusage: %s [infile] [outfile]\n",argv[0]);
    exit(1); 	
  }

  if (argc > 1){
    freopen(argv[1],"r",stdin);
  }
  
  if (argc > 2){
    freopen(argv[2],"w",stdout);
  }

  lrs_ifp = stdin;
  lrs_ofp = stdout;
}