/* Copyright (c) 2004-2010, Dirk Krause All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above opyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the Dirk Krause nor the names of contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /** @file fig2vect.c Main program module for fig2vect. This program converts Fig file produced by XFig, jFig or WinFig to vector graphics formats. The program is intended for LaTeX users but may be useful to other users too. */ /* include files */ #include "dktools-version.h" #include "dkfig.h" $(trace-include) #ifndef VERSNUMB /** Version number. */ #define VERSNUMB "1.1.24" #endif /** System configuration directory (string constant). */ static char sysconfdir[] = { DK_SYSCONFDIR }; #ifndef PACKAGNAME /** Package name (definition). */ #define PACKAGENAME "dktools" #endif /** Package name (string constant). */ static char packagename[] = { PACKAGENAME }; /** Check whether or not to run silently or as a filter. If the option --silent is used the application runs silently. If no output file name (second command line argument) is specified the application runs as filter and can not print log messages to standard output. @param argc Number of command line arguments. @param argv Command line arguments array. @param rs Pointer to run-silently flag variable. @param rf Pointer to run-as-filter flag variable. */ static void silence_check DK_P4(int,argc,char **,argv,int *,rs,int *,rf) { int isrs = 0; int isrf = 0; int i; int filenames; char *fn1, *ptr, **lfdptr; $? "+ silence_check %d %s %s %s", argc, TR_PTR(argv), TR_PTR(rs), TR_PTR(rf) lfdptr = argv; lfdptr++; i = 1; filenames = 0; fn1 = NULL; while(i < argc) { ptr = *lfdptr; if(*ptr == '-') { ptr++; switch(*ptr) { case 's': isrs = 1; break; case 'l': case 'o': { ptr++; if(!(*ptr)) { lfdptr++; i++; } } break; } } else { filenames++; if(!fn1) fn1 = ptr; } lfdptr++; i++; } switch(filenames) { case 0: { isrf = 1; } break; case 1: { if(!dksf_is_directory(fn1)) { isrf = 1; } } break; } if(isrs) if(rs) *rs = isrs; if(isrf) if(rf) *rf = isrf; $? "- silence_check %d %d", isrs, isrf } /** Text to show for version number and license conditions. */ static char *version_text[] = { "", "fig2vect, version " VERSNUMB, "Copyright (C) 2004-2010 Dipl.-Ing. D. Krause", "http://dktools.sourceforge.net/fig2vect.html", "", "Redistribution and use in source and binary forms, with or without", "modification, are permitted provided that the following conditions are met:", "* Redistributions of source code must retain the above copyright notice, this", " list of conditions and the following disclaimer.", "* Redistributions in binary form must reproduce the above copyright notice,", " this list of conditions and the following disclaimer in the documentation", " and/or other materials provided with the distribution.", "* Neither the name of the Dirk Krause nor the names of other contributors may", " be used to endorse or promote products derived from this software without", " specific prior written permission.", "THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"", "AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE", "IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE", "ARE DISCLAIMED.", "IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY", "DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES", "(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;", "LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND", "ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT", "(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS", "SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.", NULL }; /** Print version number and license terms. */ static void print_version DK_P0() { char **xptr; $? "+ print_version" xptr = version_text; while(*xptr) { fputs(*(xptr++), stdout); fputc('\n', stdout); } fputc('\n', stdout); xptr = dklic_get(); fputs("Libraries used:\n\n", stdout); #if DK_HAVE_PNG_H fputs("libpng the official PNG reference library\n", stdout); fputs("\t http://www.libpng.org/pub/png/libpng.html\n", stdout); #endif #if DK_HAVE_JPEGLIB_H fputs("jpegsrc The Independent JPEG Group's free JPEG software\n", stdout); fputs("\t http://www.ijg.org/\n", stdout); #endif #if DK_HAVE_PNM_H || DK_HAVE_NETPBM_PNM_H fputs("netpbm The image conversion toolkit\n", stdout); fputs("\t http://netpbm.sourceforge.net/\n", stdout); #endif while(*xptr) { fputs(*(xptr++), stdout); fputc('\n', stdout); } fputc('\n', stdout); $? "- print_version" } /** Text to show as help text if the fig2vect.txt file is not found. */ static char *help_text[] = { "fig2vect - XFig to vector graphics converter", "", "fig2vect [-l ] [-o