/* ================================================================== FILE: "/home/joze/pub/zimg/zimg/misc.c" LAST MODIFIED: "Sa, 27 Aug 2005 14:16:19 CEST (joze)" (C) 1999 - 2005 by Johannes Zellner johannes@zellner.org $Id: misc.c,v 1.69 2005/08/27 12:46:20 joze Exp $ --- Copyright (c) 1999 - 2005, Johannes Zellner 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 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 Johannes Zellner nor the names of contributors to this software 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 AUTHORS 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. ================================================================== */ #include "zimg_priv.h" static void shiftleft(char* buf); static char* copyright(void); static char* copyright(void) { static char cpy[0x80]; strcpy(cpy, "Copyright (c) 1999 - 2005 by Johannes Zellner "); return cpy; } void help(void) { (void) fprintf(stdout, "Usage: %s [OPTION]... [FILE ...]\n" "zimg displays ascii or binary data as" #ifdef GD_HAS_PNG " png" #endif #ifdef GD_HAS_GIF " gif" #endif #ifdef GD_JPEG_VERSION " or jpeg" #endif " image.\n\n" "Mandatory arguments to long options are mandatory for short options too.\n" "INPUT\n" " -r, --size=[x]\n" " dimension of the 2d data\n" " -M, --matrix input is in ASCII matrix format. Width and height\n" " taken as the number of columns and lines of the\n" " input file but can be overwritten by --size.\n" " -p, --pattern= marks a comment line for ascii input\n" " (default: '#')\n" " -n, --column[=] read column (ascii input). Multiple columns\n" " can be selected by using this option repeatedly\n" " This is limited to the 32 first cols\n" " If is omitted, all columns are selected\n" " -k, --skip[=] ascii input: skip \n" " binary input: skip \n" " if used w/o argument the default is restored\n" #ifdef HAVE_REGEX_H " --options=//\n" " apply if filename matches \n" #endif #ifdef HAVE_POPEN " --input-filter= use for reading input files\n" #endif "BINARY INPUT\n" " --swap swap bytes (overwritten by big/little endian)\n" " --big-endian binary input data is big endian\n" " --little-endian binary input data is little endian\n" " -f, --float\n" " -d, --double\n" " --char\n" " --short\n" " --int\n" " --long-int\n" " -c, --unsigned-char\n" " -s, --unsigned-short\n" " -i, --unsigned-int\n" " --unsigned-long-int\n" " --complex-float=(abs/length|phase|real|imaginary) [abs]\n" " --complex-double=(abs/length|phase|real|imaginary) [abs]\n" "OUTPUT\n" " -o, --output= filename for output, default is stdout; if more\n" " than one input file is given, must be a\n" " directory unless it is - for stdout\n" " --interlace write an interlaced image\n" #if defined(GD_HAS_PNG) && defined (GD_HAS_GIF) " -g, --gif write gif instead of png.\n" #endif #ifdef GD_JPEG_VERSION " -j, --jpeg[=] write jpeg, with the given quality\n" " (0 -- 100)\n" #endif " -P, --ppmorpgm write PPM or PGM file for color or\n" " gray palette image, respectively\n" " --ppm write portable pixmap (PPM) instead of png\n" " --pgm write portable graymap (PGM) instead of png; to be\n" " used only for --gray palette images\n" " -S, --scale=[,] image scaling\n" #if 0 " -B, --bin=[,] integer data binning\n" #endif " -C, --crop=[-x-]\n" " -A, --align=[x][,bordercolor]\n" #if 0 /* TODO: see also cmdln.c */ " -E, --extend=-x-\n" #endif "COLOR MAPPING\n" " --red\n" " --blue\n" " --grey, --gray (default is --colormap=1)\n" " -m, --colormap[=] use custom colormap file. The colormapfile must\n" " hold r g b triplets in the range from 0 to 0xff\n" " Empty lines and lines starting with a hash `#'\n" " mark are skipped\n" " -m --colormap[=r[,g[,b]]] use color formulae to create the colormap\n" " color formulae are documented on the man page\n" " -b, --cbox, --colorbox[=n] draw colorbox with levels\n" " --cbox-fmt= format for formatting the colorbox numbers\n" " --cbox-label=