Logo Search packages:      
Sourcecode: vflib3 version File versions  Download package

vflpp.c

/*
 * 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 <stdio.h>
#include <stdlib.h>
#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;
}

Generated by  Doxygen 1.6.0   Back to index