⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 info.c

📁 gcc-2.95.3 Linux下最常用的C编译器
💻 C
📖 第 1 页 / 共 2 页
字号:
/* info.c -- Display nodes of Info files in multiple windows.   $Id: info.c,v 1.1.1.3 1998/03/24 18:20:13 law Exp $   Copyright (C) 1993, 96, 97, 98 Free Software Foundation, Inc.   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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.   Written by Brian Fox (bfox@ai.mit.edu). */#include "info.h"#include "indices.h"#include "dribble.h"#include "getopt.h"#if defined (HANDLE_MAN_PAGES)#  include "man.h"#endif /* HANDLE_MAN_PAGES *//* The version numbers of this version of Info. */int info_major_version = 2;int info_minor_version = 18;/* basename (argv[0]) */static char *program_name = NULL;/* Non-zero means search all indices for APROPOS_SEARCH_STRING. */static int apropos_p = 0;/* Variable containing the string to search for when apropos_p is non-zero. */static char *apropos_search_string = (char *)NULL;/* Non-zero means search all indices for INDEX_SEARCH_STRING.  Unlike   apropos, this puts the user at the node, running info. */static int index_search_p = 0;/* Variable containing the string to search for when index_search_p is   non-zero. */ static char *index_search_string = (char *)NULL;/* Non-zero means print version info only. */static int print_version_p = 0;/* Non-zero means print a short description of the options. */static int print_help_p = 0;/* Array of the names of nodes that the user specified with "--node" on the   command line. */static char **user_nodenames = (char **)NULL;static int user_nodenames_index = 0;static int user_nodenames_slots = 0;/* String specifying the first file to load.  This string can only be set   by the user specifying "--file" on the command line. */static char *user_filename = (char *)NULL;/* String specifying the name of the file to dump nodes to.  This value is   filled if the user speficies "--output" on the command line. */static char *user_output_filename = (char *)NULL;/* Non-zero indicates that when "--output" is specified, all of the menu   items of the specified nodes (and their subnodes as well) should be   dumped in the order encountered.  This basically can print a book. */int dump_subnodes = 0;/* Structure describing the options that Info accepts.  We pass this structure   to getopt_long ().  If you add or otherwise change this structure, you must   also change the string which follows it. */#define APROPOS_OPTION 1#define DRIBBLE_OPTION 2#define RESTORE_OPTION 3#define IDXSRCH_OPTION 4static struct option long_options[] = {  { "apropos", 1, 0, APROPOS_OPTION },  { "directory", 1, 0, 'd' },  { "node", 1, 0, 'n' },  { "file", 1, 0, 'f' },  { "subnodes", 0, &dump_subnodes, 1 },  { "output", 1, 0, 'o' },  { "help", 0, &print_help_p, 1 },  { "version", 0, &print_version_p, 1 },  { "dribble", 1, 0, DRIBBLE_OPTION },  { "restore", 1, 0, RESTORE_OPTION },  { "index-search", 1, 0, IDXSRCH_OPTION },  {NULL, 0, NULL, 0}};/* String describing the shorthand versions of the long options found above. */static char *short_options = "d:n:f:o:s";/* When non-zero, the Info window system has been initialized. */int info_windows_initialized_p = 0;/* Some "forward" declarations. */static void info_short_help (), remember_info_program_name ();/* **************************************************************** *//*                                                                  *//*                Main Entry Point to the Info Program              *//*                                                                  *//* **************************************************************** */intmain (argc, argv)     int argc;     char **argv;{  int getopt_long_index;        /* Index returned by getopt_long (). */  NODE *initial_node;           /* First node loaded by Info. */  remember_info_program_name (argv[0]);#ifdef HAVE_SETLOCALE  /* Set locale via LC_ALL.  */  setlocale (LC_ALL, "");#endif  /* Set the text message domain.  */  bindtextdomain (PACKAGE, LOCALEDIR);  textdomain (PACKAGE);  while (1)    {      int option_character;      option_character = getopt_long        (argc, argv, short_options, long_options, &getopt_long_index);      /* getopt_long () returns EOF when there are no more long options. */      if (option_character == EOF)        break;      /* If this is a long option, then get the short version of it. */      if (option_character == 0 && long_options[getopt_long_index].flag == 0)        option_character = long_options[getopt_long_index].val;      /* Case on the option that we have received. */      switch (option_character)        {        case 0:          break;          /* User wants to add a directory. */        case 'd':          info_add_path (optarg, INFOPATH_PREPEND);          break;          /* User is specifying a particular node. */        case 'n':          add_pointer_to_array (optarg, user_nodenames_index, user_nodenames,                                user_nodenames_slots, 10, char *);          break;          /* User is specifying a particular Info file. */        case 'f':          if (user_filename)            free (user_filename);          user_filename = xstrdup (optarg);          break;          /* User is specifying the name of a file to output to. */        case 'o':          if (user_output_filename)            free (user_output_filename);          user_output_filename = xstrdup (optarg);          break;          /* User is specifying that she wishes to dump the subnodes of             the node that she is dumping. */        case 's':          dump_subnodes = 1;          break;          /* User has specified a string to search all indices for. */        case APROPOS_OPTION:          apropos_p = 1;          maybe_free (apropos_search_string);          apropos_search_string = xstrdup (optarg);          break;          /* User has specified a dribble file to receive keystrokes. */        case DRIBBLE_OPTION:          close_dribble_file ();          open_dribble_file (optarg);          break;          /* User has specified an alternate input stream. */        case RESTORE_OPTION:          info_set_input_from_file (optarg);          break;          /* User has specified a string to search all indices for. */        case IDXSRCH_OPTION:          index_search_p = 1;          maybe_free (index_search_string);          index_search_string = xstrdup (optarg);          break;        default:          fprintf (stderr, _("Try --help for more information."));          exit (1);        }    }  /* If the output device is not a terminal, and no output filename has been     specified, make user_output_filename be "-", so that the info is written     to stdout, and turn on the dumping of subnodes. */  if ((!isatty (fileno (stdout))) && (user_output_filename == (char *)NULL))    {      user_output_filename = xstrdup ("-");      dump_subnodes = 1;    }  /* If the user specified --version, then show the version and exit. */  if (print_version_p)    {      printf ("%s (GNU %s %s) %s\n", program_name, PACKAGE, VERSION,               version_string ());      printf (_("Copyright (C) %s Free Software Foundation, Inc.\n\There is NO warranty.  You may redistribute this software\n\under the terms of the GNU General Public License.\n\For more information about these matters, see the files named COPYING.\n"),		  "1998");      exit (0);    }  /* If the `--help' option was present, show the help and exit. */  if (print_help_p)    {      info_short_help ();      exit (0);    }    /* If the user hasn't specified a path for Info files, default it.     Lowest priority is our messy hardwired list in filesys.h.     Then comes the user's INFODIR from the Makefile.     Highest priority is the environment variable, if set.  */  if (!infopath)    {      char *path_from_env = getenv ("INFOPATH");      if (path_from_env)        {          unsigned len = strlen (path_from_env);          /* Trailing : on INFOPATH means insert the default path.  */          if (len && path_from_env[len - 1] == ':')            {              path_from_env[len - 1] = 0;              info_add_path (DEFAULT_INFOPATH, INFOPATH_PREPEND);            }#ifdef INFODIR /* from the Makefile */          info_add_path (INFODIR, INFOPATH_PREPEND);#endif          info_add_path (path_from_env, INFOPATH_PREPEND);        }      else        {          info_add_path (DEFAULT_INFOPATH, INFOPATH_PREPEND);#ifdef INFODIR /* from the Makefile */         info_add_path (INFODIR, INFOPATH_PREPEND);#endif        }    }  /* If the user specified a particular filename, add the path of that     file to the contents of INFOPATH. */  if (user_filename)    {      char *directory_name = xstrdup (user_filename);      char *temp = filename_non_directory (directory_name);      if (temp != directory_name)        {          *temp = 0;          info_add_path (directory_name, INFOPATH_PREPEND);        }      free (directory_name);    }  /* If the user wants to search every known index for a given string,     do that now, and report the results. */  if (apropos_p)    {      info_apropos (apropos_search_string);      exit (0);    }  /* Get the initial Info node.  It is either "(dir)Top", or what the user     specifed with values in user_filename and user_nodenames. */  initial_node = info_get_node (user_filename,                                user_nodenames ? user_nodenames[0] : NULL);  /* If we couldn't get the initial node, this user is in trouble. */  if (!initial_node)    {      if (info_recent_file_error)        info_error (info_recent_file_error);      else        info_error          (CANT_FIND_NODE, user_nodenames ? user_nodenames[0] : "Top");      exit (1);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -