资源简介
bash4.4源代码,学习了解bash原理,及系统级别开发的绝佳参考
代码片段和文件信息
/* alias.c -- Not a full alias but just the kind that we use in the
shell. Csh style alias is somewhere else (‘over there in a box‘). */
/* Copyright (C) 1987-2015 Free Software Foundation Inc.
This file is part of GNU Bash the Bourne Again SHell.
Bash 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 3 of the License or
(at your option) any later version.
Bash 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 Bash. If not see .
*/
#include “config.h“
#if defined (ALIAS)
#if defined (HAVE_UNISTD_H)
# ifdef _MINIX
# include
# endif
# include
#endif
#include
#include “chartypes.h“
#include “bashansi.h“
#include “command.h“
#include “general.h“
#include “externs.h“
#include “alias.h“
#if defined (PROGRAMMABLE_COMPLETION)
# include “pcomplete.h“
#endif
#if defined (HAVE_MBSTR_H) && defined (HAVE_MBSCHR)
# include /* mbschr */
#endif
#define ALIAS_HASH_BUCKETS 64 /* must be power of two */
typedef int sh_alias_map_func_t __P((alias_t *));
static void free_alias_data __P((PTR_T));
static alias_t **map_over_aliases __P((sh_alias_map_func_t *));
static void sort_aliases __P((alias_t **));
static int qsort_alias_compare __P((alias_t ** alias_t **));
#if defined (READLINE)
static int skipquotes __P((char * int));
static int skipws __P((char * int));
static int rd_token __P((char * int));
#endif
/* Non-zero means expand all words on the line. Otherwise expand
after first expansion if the expansion ends in a space. */
int alias_expand_all = 0;
/* The list of aliases that we have. */
HASH_TABLE *aliases = (HASH_TABLE *)NULL;
void
initialize_aliases ()
{
if (aliases == 0)
aliases = hash_create (ALIAS_HASH_BUCKETS);
}
/* Scan the list of aliases looking for one with NAME. Return NULL
if the alias doesn‘t exist else a pointer to the alias_t. */
alias_t *
find_alias (name)
char *name;
{
BUCKET_CONTENTS *al;
if (aliases == 0)
return ((alias_t *)NULL);
al = hash_search (name aliases 0);
return (al ? (alias_t *)al->data : (alias_t *)NULL);
}
/* Return the value of the alias for NAME or NULL if there is none. */
char *
get_alias_value (name)
char *name;
{
alias_t *alias;
if (aliases == 0)
return ((char *)NULL);
alias = find_alias (name);
return (alias ? alias->value : (char *)NULL);
}
/* Make a new alias from NAME and VALUE. If NAME can be found
then replace its value. */
void
add_alias (name value)
char *name *value;
{
BUCKET_CONTENTS *elt;
alias_t *temp;
int n;
if (aliases == 0
相关资源
- SSH投票管理平台项目源码
- 驾校网站源码共享
- 最新源码免杀过360云鉴定与IP拦截源码
- 20几套CPA网站源码
-
.net使用dsofr
amer打开officeV2.3源码、、 - 内部vs2010版本人事管理系统全源码
- Spring5 源码分析(第 2 版)-某Tom老师
- 淘淘商城源码
- MWC2.4飞控源码
- QQ空间高仿源码
- 基于51单片机串口温湿度采集和传输仿
- 基于STM32的示波器源码
- 50个基础css页面布局样式
- 6款H5小游戏源码包含有五子棋 3d魔方
- 唯美表白网页源码
- 圣剑英雄传2源码+资源
- Delphi毕业设计银行助学贷款管理系统
- 《as大型网页游戏开发》
- 王金明:《Verilog HDL程序设计教程》及
- stm32f103c8t6单片机 FreeRTOS源码
- 采用HC-SR04实现的超声波测距FPGA源码
- 数学建模10大算法详解_程序源码打包
- 国外开源Wince全能播放器TCPMP源码
- API接口开发 dome源码 加密 鉴权验证
- JFreeChar图表生成柱状图和饼状图源码
- 滴水逆向中级课件源码
- 高校补考管理系统源码附数据库
- Lab Windows_CVI逐步深入与开发书pdf文档
- 后台管理端代码.rar
- 医药系统管理项目源码
评论
共有 条评论