home *** CD-ROM | disk | FTP | other *** search
/ Gold Fish 3 / goldfish_volume_3.bin / files / dev / misc / adoc / source / args.c < prev    next >
C/C++ Source or Header  |  1995-04-13  |  9KB  |  174 lines

  1. /*                                                               -*- C -*-
  2.  *  ARGS.C
  3.  *
  4.  *  (c)Copyright 1995 by Tobias Ferber,  All Rights Reserved
  5.  *
  6.  *  This file is part of ADOC.
  7.  *
  8.  *  ADOC is free software; you can redistribute it and/or modify
  9.  *  it under the terms of the GNU General Public License as published
  10.  *  by the Free Software Foundation; either version 1 of the License,
  11.  *  or (at your option) any later version.
  12.  *
  13.  *  ADOC is distributed in the hope that it will be useful,
  14.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  15.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16.  *  GNU General Public License for more details.
  17.  *
  18.  *  You should have received a copy of the GNU General Public License
  19.  *  along with this program; see the file COPYING.  If not, write to
  20.  *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  21.  */
  22.  
  23. /* $VER: $Id: args.c,v 1.14 1995/03/26 10:16:52 tf Exp $ */
  24.  
  25. #include <string.h>
  26. #include <stdio.h>
  27.  
  28. static char *howtouse[]= {
  29.  
  30.   "-",              "--stdin",                  "",            "read source code from stdin",
  31.   "-0",             "--no-output",              "",            "do not write any output (same as `-n')",
  32.   "-1",             "--autodoc",                "",            "create autodoc output (default)",
  33.   "-2",             "--texinfo",                "",            "create texinfo output",
  34.   "-2",             "--texi",                   "",            "",
  35.   "-b",             "--texi-funtable",          "",            "create a @table for each function",
  36.   "-B",             "--body-environment",       "<string>",    "put body text into a @<string> environment",
  37.  
  38. /*
  39.   "-Bexample",      "--example",                "",            "put body text into an @example environment",
  40.   "-Bsmallexample", "--small-example",          "",            "put body text into a @smallexample environment",
  41.   "-Bsmallexample", "--smallexample",           "",            "",
  42.   "-Bdisplay",      "--display",                "",            "put body text into a @display environment",
  43. */
  44.  
  45.   "-c",             "--flip-slashes",           "",            "convert \\* to /* and *\\ to */",
  46.   "-c",             "--convert",                "",            "",
  47.  
  48. #ifdef DEBUG
  49.   "-d",             "--debug",                  "<number>",    "set debug level to <number>",
  50. #endif
  51.  
  52.   "-D<macro>",      "",                         "<value>",     "define a texinfo header macro",
  53.   "-DPROJECT",      "--project",                "<string>",    "define a value for the PROJECT macro",
  54.   "-DEDITION",      "--edition",                "<string>",    "define a value for the EDITION macro",
  55.   "-DREVISION",     "--revision",               "<string>",    "define a value for the REVISION macro",
  56.   "-DCOPYRIGHT",    "--copyright",              "<string>",    "define a value for the COPYRIGHT macro",
  57.   "-DAUTHOR",       "--author",                 "<string>",    "define a value for the AUTHOR macro",
  58.   "-E",             "--error-file",             "<filename>",  "redirect error messages (default is stderr)",
  59.   "-f",             "--no-form-feeds",          "",            "no form feeds (^L) or @page between entries",
  60.   "-f",             "--no-ff",                  "",            "",
  61.   "-ff",            "--form-feeds",             "",            "begin a new page for each function",
  62.   "-g",             "--no-grouping",            "",            "no creation of @group ... @end group",
  63.   "-g",             "--no-groups",              "",            "",
  64.   "-gs",            "--group-sections",         "",            "put keyword sections into a @group",
  65.   "-H",             "--texi-header-file",       "<filename>",  "read texinfo header from file <filename>",
  66.   "-h",             "--help",                   "",            "print this short usage information and exit",
  67.   "-i",             "--internal",               "",            "process only internal docs (same as `-yi')",
  68.   "-I",             "--table-of-contents",      "",            "output table of contents before entries",
  69.   "-I",             "--toc",                    "",            "",
  70.   "-j",             "--reindent-bodytext",      "<number>",    "change the indentation of bodytext lines",
  71.   "-j",             "--reindent",               "",            "",
  72.   "-l",             "--line-length",            "<number>",    "set autodoc page width to <number> columns",
  73.   "-l",             "--page-width",             "",            "",
  74.   "-l",             "--width",                  "",            "",
  75.   "-l",             "--columns",                "",            "",
  76.   "-l",             "--cols",                   "",            "",
  77.   "-M<macro>",      "",                         "<value>",     "define a body text macro",
  78.   "-n",             "--dry-run",                "",            "do not write any output (same as `-0')",
  79.   "-n",             "--dryrun",                 "",            "",
  80.   "-o",             "--output-file",            "<filename>",  "set output filename (default is stdout)",
  81.   "-p",             "--preserve-order",         "",            "don't sort autodoc entries",
  82.   "-p",             "--no-sort",                "",            "",
  83.   "-pp",            "--sort-entries",           "",            "sort autodoc entries (default)",
  84.   "-q",             "--quiet",                  "",            "don't print information while processing",
  85.   "-q",             "--silent",                 "",            "",
  86.   "-q",             "--brief",                  "",            "",
  87.   "-t",             "--tabs-to-spaces",         "",            "turn tabs to spaces (same as `-T8')",
  88.   "-T",             "--tab-size",               "<number>",    "set tab step to <number> columns",
  89.   "-T",             "--tabsize",                "",            "",
  90.   "-U",             "",                         "<macro>",     "undefine a macro defined via `-D' or `-M'",
  91. /*
  92.   "-u",             "--unindent-bodytext",      "",            "remove indentation of body text lines",
  93.   "-u",             "--unindent",               "",            "",
  94. */
  95.   "-uu",            "--preserve-indent",        "",            "do not modify the body text indentation",
  96.   "-uu",            "--preserve-indentation",   "",            "",
  97.   "-v",             "--version",                "",            "print author and version information",
  98.   "-W",             "--no-warnings",            "",            "don't print any warnings",
  99.   "-Wkeywords",     "--check-keywords",         "",            "check section keywords while reading",
  100.   "-Wabsence",      "--check-presence",         "",            "look for missing section keywords",
  101.   "-Wall",          "--pedantic",               "",            "complain about almost everything",
  102.   "-x",             "--no-references",          "",            "print the SEE ALSO section as it is",
  103.   "-xoff",          "--no-xrefs",               "",            "",
  104.   "-xon",           "--parse-references",       "",            "try to create @xref{}s from SEE ALSO",
  105.   "-xitemize",      "--itemize-references",     "",            "put @xref{}s into an @itemize list",
  106.   "-y",             "--yank-type",              "<string>",    "process only comments of type <string>",
  107.   "-y",             "--input-type",             "",            "",
  108.   "-y",             "--comment-type",           "",            "",
  109.   "-Y",             "--indented-comments",      "",            "allow an indentation of autodoc comments",
  110.   "-Y",             "--allow-indentation",      "",            "",
  111.   "-z",             "--no-texi-header",         "",            "ommit writing texinfo header and title page",
  112.   "-Z",             "--no-texi-index",          "",            "ommit function index and table of contents",
  113.  
  114. #if 0
  115.  
  116.   /*
  117.    *  The following options are ignored for compatibility
  118.    *  with Bill Koester's original version `autodoc' which
  119.    *  is part of C=ommodore's Native Developer Kit (NDK).
  120.    */
  121.  
  122.   "-C",             "--slash-asterisk",         "",            "process autodocs starting with /*",
  123.   "-s",             "--semicolon",              "",            "process autodocs starting with a semicolon",
  124.   "-a",             "--asterisk",               "",            "process autodocs starting with an asterisk",
  125.   "-F",             "--tempfile",               "<filename>",  "ignored for compatibility",
  126.   "-r",             "--troff",                  "",            "ignored for compatibility",
  127.   "-w",             "--no-word-wrap",           "",            "ignored for compatibility",
  128.  
  129. #endif /*0*/
  130.  
  131.   (char *)0, (char *)0, (char *)0, (char *)0
  132. };
  133.  
  134. char *
  135. convert_args(s)
  136. char *s;
  137. {
  138.   char **t= howtouse;
  139.  
  140.   while(*t) {
  141.     if(!strcmp(s,t[1]))
  142.       break;
  143.     t= &t[4];
  144.   }
  145.  
  146.   return (*t) ? *t : s;
  147. }
  148.  
  149. void
  150. display_args(int which)
  151. {
  152.   char **t= howtouse;
  153.  
  154.   while(*t) {
  155.     if(t[3] && *t[3]) {
  156.  
  157.       if(which & 1)
  158.       {
  159.         printf("%-12s ",t[0]);
  160.  
  161.         if(which & 2)
  162.           printf("%s ",t[1][0] ? "or":"  ");
  163.       }
  164.  
  165.       if(which & 2)
  166.         printf("%-20s ",t[1][0] ? t[1] : ((which & 1) ? "": t[0]) );
  167.  
  168.       if(which & 3)
  169.         printf("%-13s %s\n",t[2],t[3]);
  170.     }
  171.     t= &t[4];
  172.   }
  173. }
  174.