八亿电脑网
游戏盒子
当前位置: 首页 > 八亿电脑 > 电脑知识 >

linux系统中whereis的用法详解(2)

时间:2015-03-01 21:23来源:网络 作者:win8e 点击:
游戏盒子

* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. 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.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
*This productincludes software developed by the University of
*California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
*
* 1999-02-22 Arkadiusz MiśkIEwicz <misIEk@pld.ORG.PL>
* - added Native Language Support
* 2011-08-12 Davidlohr Bueso <dave@gnu.org>
* - added $PATH lookup
*
* Copyright (C) 2013 Karel Zak <kzak@redhat.com>
* 2013 Sami Kerola <kerolasa@iki.fi>
*/

#include <sys/param.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <dirent.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <assert.h>

#include "xalloc.h"
#include "nls.h"
#include "c.h"
#include "closestream.h"
#include "canonicalize.h"

#include "debug.h"

UL_DEBUG_DEFINE_MASK(whereis);
UL_DEBUG_DEFINE_MASKNAMES(whereis) = UL_DEBUG_EMPTY_MASKNAMES;

#define WHEREIS_DEBUG_INIT(1 << 1)
#define WHEREIS_DEBUG_PATH(1 << 2)
#define WHEREIS_DEBUG_ENV(1 << 3)
#define WHEREIS_DEBUG_ARGV(1 << 4)
#define WHEREIS_DEBUG_SEARCH(1 << 5)
#define WHEREIS_DEBUG_STATIC(1 << 6)
#define WHEREIS_DEBUG_LIST(1 << 7)
#define WHEREIS_DEBUG_ALL0xFFFF

#define DBG(m, x) __UL_DBG(whereis, WHEREIS_DEBUG_, m, x)
#define ON_DBG(m, x) __UL_DBG_CALL(whereis, WHEREIS_DEBUG_, m, x)

static char uflag = 0;

/* supported types */
enum {
BIN_DIR = (1 << 1),
MAN_DIR = (1 << 2),
SRC_DIR = (1 << 3),

ALL_DIRS = BIN_DIR | MAN_DIR | SRC_DIR
};

/* directorIEs */
struct wh_dirlist {
inttype;
dev_tst_dev;
ino_tst_ino;
char*path;

struct wh_dirlist *next;
};

static const char *bindirs[] = {
"/usr/bin",
"/usr/sbin",
"/usr/lib",
"/usr/lib64",
"/bin",
"/sbin",
"/etc",
"/usr/etc",
"/lib",
"/lib64",
"/usr/games",
"/usr/games/bin",
"/usr/games/lib",
"/usr/emacs/etc",
"/usr/lib/emacs/*/etc",
"/usr/TeX/bin",
"/usr/tex/bin",
"/usr/intervIEws/bin/LINUX",

"/usr/X11R6/bin",
"/usr/X386/bin",
"/usr/bin/X11",
"/usr/X11/bin",
"/usr/X11R5/bin",

"/usr/local/bin",
"/usr/local/sbin",
"/usr/local/etc",
"/usr/local/lib",
"/usr/local/games",
"/usr/local/games/bin",
"/usr/local/emacs/etc",
"/usr/local/TeX/bin",
"/usr/local/tex/bin",
"/usr/local/bin/X11",

"/usr/contrib",
"/usr/hosts",
"/usr/include",

"/usr/g++-include",

"/usr/ucb",
"/usr/old",
"/usr/new",
"/usr/local",
"/usr/libexec",
"/usr/share",

"/opt/*/bin",
NULL
};

static const char *mandirs[] = {
"/usr/man/*",
"/usr/share/man/*",
"/usr/X386/man/*",
本篇文章标签: 教程 Win10 win7 软件 Win8
发表评论