src/vflpp.c
/* [<][>][^][v][top][bottom][index][help] */
FUNCTIONS
This source file includes following functions.
- main
1 /*
2 * vflpp.c - prettyprint a vflibcap file
3 * by Hirotsugu Kakugawa
4 *
5 * 22 Jul 1998 First implementation
6 */
7 /*
8 * Copyright (C) 1998 Hirotsugu Kakugawa.
9 * All rights reserved.
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2, or (at your option)
14 * any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 */
25
26
27 #include <stdio.h>
28 #include <stdlib.h>
29 #include "VFlib-3_6.h"
30 #include "VFsys.h"
31 #include "vflibcap.h"
32 #include "sexp.h"
33
34 #define PROG_NAME "vflpp"
35
36 void usage(void);
37
38
39 int
40 main(int argc, char **argv)
/* [<][>][^][v][top][bottom][index][help] */
41 {
42 FILE *fp_in;
43 int need_close;
44 SEXP s;
45
46 /* get input stream */
47 need_close = 0;
48 if (argc >= 2){
49 if ((fp_in = fopen(argv[1], FOPEN_RD_MODE_TEXT)) == NULL){
50 fprintf(stderr, "Cannot open: %s\n", argv[1]);
51 exit(1);
52 }
53 need_close = 1;
54 } else {
55 fp_in = stdin;
56 }
57
58 /* prettyprint */
59 while ((s = vf_sexp_read(fp_in)) != NULL){
60 if ( vf_sexp_listp(s)
61 && (vf_sexp_length(s) >= 2)
62 && (vf_sexp_stringp(vf_sexp_car(s)))
63 && (vf_sexp_stringp(vf_sexp_cadr(s)))
64 && ( (strcmp(vf_sexp_get_cstring(vf_sexp_car(s)),
65 VF_CAPE_VFLIBCAP_CLASS_DEFAULT_DEFINITION) == 0)
66 || (strcmp(vf_sexp_get_cstring(vf_sexp_car(s)),
67 VF_CAPE_VFLIBCAP_FONT_ENTRY_DEFINITION) == 0)
68 || (strcmp(vf_sexp_get_cstring(vf_sexp_car(s)),
69 VF_CAPE_VFLIBCAP_MACRO_DEFINITION) == 0))){
70 vf_sexp_pp_entry(s);
71 } else {
72 vf_sexp_pp(s);
73 }
74 printf("\n");
75 vf_sexp_free1(&s);
76 }
77
78 /* close input stream */
79 if (need_close == 1){
80 fclose(fp_in);
81 }
82
83 return 0;
84 }