File: vflpp.c

package info (click to toggle)
vflib3 3.6.14.dfsg-3+nmu3
  • links: PTS
  • area: main
  • in suites: stretch
  • size: 11,536 kB
  • ctags: 3,710
  • sloc: ansic: 35,811; sh: 10,357; asm: 3,290; makefile: 962; lisp: 123; perl: 109; awk: 43
file content (91 lines) | stat: -rw-r--r-- 2,212 bytes parent folder | download | duplicates (6)
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
/*
 * vflpp.c - prettyprint a vflibcap file
 * by Hirotsugu Kakugawa
 *
 *   22 Jul 1998  First implementation
 */
/*
 * Copyright (C) 1998  Hirotsugu Kakugawa. 
 * All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2, or (at your option)
 * any later version.
 * 
 * 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., 675 Mass Ave, Cambridge, MA 02139, USA.  
 */


#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#if HAVE_STDARG_H
#include <stdarg.h>
#else
#include <varargs.h>
#endif

#include "VFlib-3_6.h"
#include "VFsys.h"
#include "vflibcap.h"
#include "sexp.h"

#define PROG_NAME  "vflpp"

void  usage(void);


int
main(int argc, char **argv)
{
  FILE   *fp_in;
  int    need_close;
  SEXP   s;

  /* get input stream */
  need_close = 0;
  if (argc >= 2){
    if ((fp_in = fopen(argv[1], FOPEN_RD_MODE_TEXT)) == NULL){
      fprintf(stderr, "Cannot open: %s\n", argv[1]);
      exit(1);
    }
    need_close = 1;
  } else {
    fp_in = stdin;
  }

  /* prettyprint */
  while ((s = vf_sexp_read(fp_in)) != NULL){
    if (   vf_sexp_listp(s)
	&& (vf_sexp_length(s) >= 2)
	&& (vf_sexp_stringp(vf_sexp_car(s)))
	&& (vf_sexp_stringp(vf_sexp_cadr(s)))
	&& (   (strcmp(vf_sexp_get_cstring(vf_sexp_car(s)), 
		       VF_CAPE_VFLIBCAP_CLASS_DEFAULT_DEFINITION) == 0)
	    || (strcmp(vf_sexp_get_cstring(vf_sexp_car(s)), 
		       VF_CAPE_VFLIBCAP_FONT_ENTRY_DEFINITION) == 0)
	    || (strcmp(vf_sexp_get_cstring(vf_sexp_car(s)), 
		       VF_CAPE_VFLIBCAP_MACRO_DEFINITION) == 0))){
      vf_sexp_pp_entry(s);
    } else {
      vf_sexp_pp(s);
    }
    printf("\n");
    vf_sexp_free1(&s);
  }

  /* close input stream */
  if (need_close == 1){
    fclose(fp_in);
  }

  return 0;
}