File: cm_main.c

package info (click to toggle)
jbofihe 0.38-5
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k, lenny
  • size: 1,576 kB
  • ctags: 2,420
  • sloc: ansic: 18,597; yacc: 1,865; perl: 1,190; makefile: 269; lex: 152; sh: 60
file content (103 lines) | stat: -rw-r--r-- 2,611 bytes parent folder | download | duplicates (4)
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
/***************************************
  $Header: /cvs/src/jbofihe/cm_main.c,v 1.7 2001/07/31 21:18:11 richard Exp $

  Main routine for mini-translater
  ***************************************/

/* Copyright 1998-2001 Richard P. Curnow */
/* Help options added by Bjrn Gohla */
/*
 * 
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of version 2 of the GNU General Public License as
 * published by the Free Software Foundation.
 * 
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
 * 
*/

#include "cm.h"
#include "version.h"

extern FILE *yyin;
extern int yylex(void);

int
yywrap(void)
{
  return 1;
}

int
main (int argc, char **argv)
{
  char *filename = NULL;
  FILE *in = NULL;
  
  ofmt = OF_TEXT;
  width = 80;

  while (++argv,--argc) {
    if (!strcmp(*argv, "-l")) {
      ofmt = OF_LATEX;
    } else if (!strcmp(*argv, "-b")) {
      ofmt = OF_TEXTBLK;
#ifdef PLIST
    } else if (!strcmp(*argv, "-p")) {
      ofmt = OF_PLIST;
#endif 
    } else if (!strcmp(*argv, "-w")) {
      ++argv, --argc;
      width = atoi(*argv);
    } else if (!strcmp(*argv, "-v")) {
      fprintf(stderr, "cmafihe version %s\n", version_string);
      exit(0);
    } else if ( !strcmp(*argv, "-h") || !strcmp(*argv, "--help") ) {
      fprintf(stderr, "cmafihe, gloss lojban text without verifying\n"
                      "usage: cmafihe [-b [-w WIDTH] | -p | -l | -v] [FILENAME]\n"
                      "no options : output inline ascii\n"
                      "-b         : output blocked ascii with optional WIDTH, default %i\n"
                      "-l         : output blocked latex code\n"
#ifdef PLIST
                      "-p         : output GNUStep property list with vocabulary\n"
#endif
                      "-v         : version\n", width);
      exit(0);
    } else {
      filename = *argv;
    }
  }

  if (filename) {
    in = fopen(filename, "rb");
    if (!in) {
      fprintf(stderr, "Could not open %s for input\n", filename);
      exit(1);
    }
  }

  if (in) {
    yyin = in;
  }
  
  yylex();

  if (in) {
    fclose(in);
  }

  do_trans();

  start_output();
  do_output();
  end_output();
  output_newline();
  return 0;
}