亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? remove.c

?? 《Linux應(yīng)用開發(fā)技術(shù)詳解》附書光盤中的例程。
?? C
?? 第 1 頁 / 共 3 頁
字號:
/* remove.c -- core functions for removing files and directories
   Copyright (C) 88, 90, 91, 1994-2002 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.  */

/* Extracted from rm.c and librarified, then rewritten by Jim Meyering.  */

#ifdef _AIX
 #pragma alloca
#endif

#include <config.h>
#include <stdio.h>
#include <sys/types.h>
#include <assert.h>

#include "save-cwd.h"
#include "system.h"
#include "dirname.h"
#include "error.h"
#include "file-type.h"
#include "hash.h"
#include "hash-pjw.h"
#include "obstack.h"
#include "quote.h"
#include "remove.h"

/* Avoid shadowing warnings because these are functions declared
   in dirname.h as well as locals used below.  */
#define dir_name rm_dir_name
#define dir_len rm_dir_len

#define obstack_chunk_alloc malloc
#define obstack_chunk_free free

#ifndef PARAMS
# if defined (__GNUC__) || __STDC__
#  define PARAMS(args) args
# else
#  define PARAMS(args) ()
# endif
#endif

/* FIXME: if possible, use autoconf...  */
#ifdef __GLIBC__
# define ROOT_CAN_UNLINK_DIRS 0
#else
# define ROOT_CAN_UNLINK_DIRS 1
#endif

enum Ternary
  {
    T_UNKNOWN = 2,
    T_NO,
    T_YES
  };
typedef enum Ternary Ternary;

/* The prompt function may be called twice a given directory.
   The first time, we ask whether to descend into it, and the
   second time, we ask whether to remove it.  */
enum Prompt_action
  {
    PA_DESCEND_INTO_DIR = 2,
    PA_REMOVE_DIR
  };

/* On systems with an lstat function that accepts the empty string,
   arrange to make lstat calls go through the wrapper function.  */
#if HAVE_LSTAT_EMPTY_STRING_BUG
int rpl_lstat PARAMS((const char *, struct stat *));
# define lstat(Name, Stat_buf) rpl_lstat(Name, Stat_buf)
#endif

#ifdef D_INO_IN_DIRENT
# define D_INO(dp) ((dp)->d_ino)
# define ENABLE_CYCLE_CHECK
#else
/* Some systems don't have inodes, so fake them to avoid lots of ifdefs.  */
# define D_INO(dp) 1
#endif

#if !defined S_ISLNK
# define S_ISLNK(Mode) 0
#endif

/* Initial capacity of per-directory hash table of entries that have
   been processed but not been deleted.  */
#define HT_UNREMOVABLE_INITIAL_CAPACITY 13

/* An entry in the active directory stack.
   Each entry corresponds to an `active' directory.  */
struct AD_ent
{
  /* For a given active directory, this is the set of names of
     entries in that directory that could/should not be removed.
     For example, `.' and `..', as well as files/dirs for which
     unlink/rmdir failed e.g., due to access restrictions.  */
  Hash_table *unremovable;

  /* Record the status for a given active directory; we need to know
     whether an entry was not removed, either because of an error or
     because the user declined.  */
  enum RM_status status;

  union
  {
    /* The directory's dev/ino.  Used to ensure that `chdir some-subdir', then
       `chdir ..' takes us back to the same directory from which we started).
       (valid for all but the bottommost entry on the stack.  */
    struct dev_ino a;

    /* Enough information to restore the initial working directory.
       (valid only for the bottommost entry on the stack)  */
    struct saved_cwd saved_cwd;
  } u;
};

int euidaccess ();
int yesno ();

extern char *program_name;

/* The name of the directory (starting with and relative to a command
   line argument) being processed.  When a subdirectory is entered, a new
   component is appended (pushed).  When RM chdir's out of a directory,
   the top component is removed (popped).  This is used to form a full
   file name when necessary.  */
static struct obstack dir_stack;

/* Stack of lengths of directory names (including trailing slash)
   appended to dir_stack.  We have to have a separate stack of lengths
   (rather than just popping back to previous slash) because the first
   element pushed onto the dir stack may contain slashes.  */
static struct obstack len_stack;

/* Stack of active directory entries.
   The first `active' directory is the initial working directory.
   Additional active dirs are pushed onto the stack as rm `chdir's
   into each nonempty directory it must remove.  When rm has finished
   removing the hierarchy under a directory, it pops the active dir stack.  */
static struct obstack Active_dir;

static void
hash_freer (void *x)
{
  free (x);
}

static bool
hash_compare_strings (void const *x, void const *y)
{
  return STREQ (x, y) ? true : false;
}

static inline void
push_dir (const char *dir_name)
{
  size_t len;

  len = strlen (dir_name);

  /* Append the string onto the stack.  */
  obstack_grow (&dir_stack, dir_name, len);

  /* Append a trailing slash.  */
  obstack_1grow (&dir_stack, '/');

  /* Add one for the slash.  */
  ++len;

  /* Push the length (including slash) onto its stack.  */
  obstack_grow (&len_stack, &len, sizeof (len));
}

/* Return the entry name of the directory on the top of the stack
   in malloc'd storage.  */
static inline char *
top_dir (void)
{
  int n_lengths = obstack_object_size (&len_stack) / sizeof (size_t);
  size_t *length = (size_t *) obstack_base (&len_stack);
  size_t top_len = length[n_lengths - 1];
  char const *p = obstack_next_free (&dir_stack) - top_len;
  char *q = xmalloc (top_len);
  memcpy (q, p, top_len - 1);
  q[top_len - 1] = 0;
  return q;
}

static inline void
pop_dir (void)
{
  int n_lengths = obstack_object_size (&len_stack) / sizeof (size_t);
  size_t *length = (size_t *) obstack_base (&len_stack);
  size_t top_len;

  assert (n_lengths > 0);
  top_len = length[n_lengths - 1];
  assert (top_len >= 2);

  /* Pop off the specified length of pathname.  */
  assert (obstack_object_size (&dir_stack) >= top_len);
  obstack_blank (&dir_stack, -top_len);

  /* Pop the length stack, too.  */
  assert (obstack_object_size (&len_stack) >= sizeof (size_t));
  obstack_blank (&len_stack, (int) -(sizeof (size_t)));
}

/* Copy the SRC_LEN bytes of data beginning at SRC into the DST_LEN-byte
   buffer, DST, so that the last source byte is at the end of the destination
   buffer.  If SRC_LEN is longer than DST_LEN, then set *TRUNCATED to non-zero.
   Set *RESULT to point to the beginning of (the portion of) the source data
   in DST.  Return the number of bytes remaining in the destination buffer.  */

static size_t
right_justify (char *dst, size_t dst_len, const char *src, size_t src_len,
	       char **result, int *truncated)
{
  const char *sp;
  char *dp;

  if (src_len <= dst_len)
    {
      sp = src;
      dp = dst + (dst_len - src_len);
      *truncated = 0;
    }
  else
    {
      sp = src + (src_len - dst_len);
      dp = dst;
      src_len = dst_len;
      *truncated = 1;
    }

  *result = memcpy (dp, sp, src_len);
  return dst_len - src_len;
}

/* Using the global directory name obstack, create the full path to FILENAME.
   Return it in sometimes-realloc'd space that should not be freed by the
   caller.  Realloc as necessary.  If realloc fails, use a static buffer
   and put as long a suffix in that buffer as possible.  */

static char *
full_filename (const char *filename)
{
  static char *buf = NULL;
  static size_t n_allocated = 0;

  int dir_len = obstack_object_size (&dir_stack);
  char *dir_name = (char *) obstack_base (&dir_stack);
  size_t n_bytes_needed;
  size_t filename_len;

  filename_len = strlen (filename);
  n_bytes_needed = dir_len + filename_len + 1;

  if (n_bytes_needed > n_allocated)
    {
      /* This code requires that realloc accept NULL as the first arg.
         This function must not use xrealloc.  Otherwise, an out-of-memory
	 error involving a file name to be expanded here wouldn't ever
	 be issued.  Use realloc and fall back on using a static buffer
	 if memory allocation fails.  */
      buf = realloc (buf, n_bytes_needed);
      n_allocated = n_bytes_needed;

      if (buf == NULL)
	{
#define SBUF_SIZE 512
#define ELLIPSES_PREFIX "[...]"
	  static char static_buf[SBUF_SIZE];
	  int truncated;
	  size_t len;
	  char *p;

	  len = right_justify (static_buf, SBUF_SIZE, filename,
			       filename_len + 1, &p, &truncated);
	  right_justify (static_buf, len, dir_name, dir_len, &p, &truncated);
	  if (truncated)
	    {
	      memcpy (static_buf, ELLIPSES_PREFIX,
		      sizeof (ELLIPSES_PREFIX) - 1);
	    }
	  return p;
	}
    }

  /* Copy directory part, including trailing slash, and then
     append the filename part, including a trailing zero byte.  */
  memcpy (mempcpy (buf, dir_name, dir_len), filename, filename_len + 1);

  assert (strlen (buf) + 1 == n_bytes_needed);

  return buf;
}

static size_t
AD_stack_height (void)
{
  return obstack_object_size (&Active_dir) / sizeof (struct AD_ent);
}

static struct AD_ent *
AD_stack_top (void)
{
  return (struct AD_ent *)
    ((char *) obstack_next_free (&Active_dir) - sizeof (struct AD_ent));
}

static void
AD_stack_pop (void)
{
  /* operate on Active_dir.  pop and free top entry */
  struct AD_ent *top = AD_stack_top ();
  if (top->unremovable)
    hash_free (top->unremovable);
  obstack_blank (&Active_dir, -sizeof (struct AD_ent));
  pop_dir ();
}

/* chdir `up' one level.
   Whenever using chdir '..', verify that the post-chdir
   dev/ino numbers for `.' match the saved ones.
   Return the name (in malloc'd storage) of the
   directory (usually now empty) from which we're coming.  */
static char *
AD_pop_and_chdir (void)
{
  /* Get the name of the current directory from the top of the stack.  */
  char *dir = top_dir ();
  enum RM_status old_status = AD_stack_top()->status;
  struct stat sb;
  struct AD_ent *top;

  AD_stack_pop ();

  /* Propagate any failure to parent.  */
  UPDATE_STATUS (AD_stack_top()->status, old_status);

  assert (AD_stack_height ());

  top = AD_stack_top ();
  if (1 < AD_stack_height ())
    {
      /* We can give a better diagnostic here, since the target is relative. */
      if (chdir (".."))
	{
	  error (EXIT_FAILURE, errno,
		 _("cannot chdir from %s to .."),
		 quote (full_filename (".")));
	}
    }
  else
    {
      if (restore_cwd (&top->u.saved_cwd, NULL, NULL))

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产精品乱码人人做人人爱| 蜜桃视频一区二区| 午夜免费久久看| 欧美精品一二三区| 国产片一区二区| 天天综合网天天综合色| 国产成人av资源| 欧美精品777| 亚洲日本一区二区| 国产精品一二三四区| 7777精品伊人久久久大香线蕉完整版 | 精品va天堂亚洲国产| 亚洲区小说区图片区qvod| 蜜桃视频在线观看一区二区| 91亚洲大成网污www| 欧美精品一区男女天堂| 天天综合日日夜夜精品| 色婷婷国产精品久久包臀| 久久综合久久鬼色| 欧美日韩精品欧美日韩精品一综合| 久久精品视频在线看| 奇米影视一区二区三区| 欧美在线一二三四区| 国产精品午夜在线观看| 国产黄色91视频| 久久综合av免费| 黑人巨大精品欧美一区| 日韩欧美亚洲另类制服综合在线| 亚洲mv大片欧洲mv大片精品| 在线观看成人小视频| 亚洲国产综合人成综合网站| 色综合久久久网| 亚洲免费av在线| 91成人网在线| 亚洲一区二区在线播放相泽| 色国产综合视频| 一区二区三区欧美在线观看| 欧美综合欧美视频| 亚洲一区二区三区四区五区黄 | 中文字幕乱码日本亚洲一区二区| 精品一区二区三区香蕉蜜桃| 国产精品久久福利| 亚洲精选一二三| 亚洲精品在线观看网站| 亚洲一二三四久久| 欧美国产成人在线| 成人激情电影免费在线观看| 日日摸夜夜添夜夜添国产精品| 国产亲近乱来精品视频| 日韩一区二区三区四区五区六区| 成人黄色免费短视频| 免费观看91视频大全| 一区二区三区四区五区视频在线观看 | 国产精品久久精品日日| 91精品国产乱码| 91精品福利视频| 成人精品视频网站| 国内精品免费**视频| 日本亚洲一区二区| 亚洲国产日韩一级| 亚洲天堂av老司机| 中文字幕av在线一区二区三区| 欧美一级夜夜爽| 欧美日韩午夜在线| 欧美性猛交一区二区三区精品| 成人18视频日本| 国产精品正在播放| 国产精品伊人色| 韩国v欧美v日本v亚洲v| 久久av资源网| 毛片不卡一区二区| 日本免费新一区视频| 亚洲成va人在线观看| 亚洲一二三四区不卡| 亚洲第四色夜色| 亚洲午夜成aⅴ人片| 亚洲一区二区精品视频| 一区二区三区四区在线播放| 亚洲精品国产一区二区精华液 | 中文字幕制服丝袜成人av | 91麻豆精品国产| 欧美精品日日鲁夜夜添| 欧美色图免费看| 欧美挠脚心视频网站| 欧美午夜片在线看| 欧美日韩精品一区二区三区蜜桃| 欧美日韩国产小视频| 欧美福利一区二区| 欧美一二三四区在线| 精品免费99久久| 国产亚洲成av人在线观看导航| 国产日本欧美一区二区| 国产精品每日更新在线播放网址 | 欧美日韩在线电影| 欧美性欧美巨大黑白大战| 欧美高清dvd| 久久亚洲私人国产精品va媚药| 26uuu国产在线精品一区二区| 久久精品亚洲精品国产欧美| 国产精品免费免费| 一区二区成人在线视频| 水蜜桃久久夜色精品一区的特点| 免费亚洲电影在线| 国产成人精品影视| 色综合色狠狠天天综合色| 欧美日韩久久一区| 欧美大片免费久久精品三p| 国产人成亚洲第一网站在线播放| 国产精品成人一区二区三区夜夜夜 | 国产精选一区二区三区| 99re这里只有精品视频首页| 在线观看网站黄不卡| 日韩精品中午字幕| 国产精品成人免费| 日本不卡视频在线观看| 成人黄色777网| 欧美精品丝袜中出| 国产欧美日本一区二区三区| 亚洲线精品一区二区三区八戒| 精品一区二区三区在线播放视频| www.成人在线| 欧美一级国产精品| |精品福利一区二区三区| 日韩电影一区二区三区四区| 国产91精品免费| 3atv在线一区二区三区| 中日韩av电影| 久久精品99国产国产精| 色综合久久久网| 久久亚洲捆绑美女| 婷婷综合在线观看| av一区二区三区四区| 精品国产伦一区二区三区观看方式| 亚洲欧美在线aaa| 麻豆高清免费国产一区| 在线免费亚洲电影| 久久老女人爱爱| 日韩综合在线视频| 99国产精品久| 国产午夜亚洲精品午夜鲁丝片| 午夜精品视频一区| 91麻豆自制传媒国产之光| 日韩欧美不卡在线观看视频| 亚洲激情网站免费观看| 波多野结衣精品在线| 欧美精品一区二区久久久| 亚洲成人手机在线| 色吧成人激情小说| 国产精品乱码人人做人人爱| 狠狠狠色丁香婷婷综合激情| 91精品国产免费| 图片区小说区区亚洲影院| 欧洲生活片亚洲生活在线观看| 国产欧美精品国产国产专区| 精品影视av免费| 日韩一区二区电影在线| 日本中文一区二区三区| 欧美丰满美乳xxx高潮www| 亚洲曰韩产成在线| 在线精品视频小说1| 亚洲黄色小视频| 色噜噜狠狠成人网p站| 1024国产精品| 色综合网站在线| 亚洲激情图片qvod| 色先锋久久av资源部| 亚洲一线二线三线视频| 色网站国产精品| 亚洲主播在线观看| 欧美日韩精品一区二区三区蜜桃 | 麻豆精品久久精品色综合| 91精品国产免费| 久久国产精品免费| 欧美精品一区二区三区蜜臀 | 蜜臀久久99精品久久久久宅男| 4438x亚洲最大成人网| 热久久一区二区| 欧美tickling网站挠脚心| 国内久久精品视频| 国产午夜精品一区二区三区嫩草| 国产精品一区二区91| 国产精品伦一区| 色综合久久99| 午夜精品爽啪视频| 精品国产91久久久久久久妲己| 国产盗摄视频一区二区三区| 亚洲国产成人私人影院tom| 成人免费视频app| 亚洲精品日韩一| 欧美一级二级在线观看| 国产最新精品精品你懂的| 中文字幕乱码一区二区免费| 日本精品裸体写真集在线观看| 亚洲丶国产丶欧美一区二区三区| 欧美一区二区视频在线观看| 久久aⅴ国产欧美74aaa| 中文字幕在线一区二区三区| 欧美午夜一区二区三区免费大片| 美女任你摸久久| 国产精品高潮久久久久无|