概要 †
引数 †
実装 †
int main(int argc, char **argv)
{
struct file *flist= nil, **aflist= &flist;
enum depth depth;
- /usr/src/commands/simple/ls.cで定義。
- enum depth { SURFACE, SURFACE1, SUBMERGED };
char *lsflags;
struct winsize ws;
uid= geteuid();
gid= getegid();
- uid,gidはint。グローバル変数。
- 実効ユーザIDと実効グループIDを取得。
if ((arg0= strrchr(argv[0], '/')) == nil) arg0= argv[0]; else arg0++;
argv++;
if (strcmp(arg0, "ls") != 0) {
char *p= arg0+1;
while (*p != 0) {
if (strchr(arg0flag, *p) != nil) *p += 'A' - 'a';
p++;
}
setflags(arg0+1);
}
while (*argv != nil && (*argv)[0] == '-') {
if ((*argv)[1] == '-' && (*argv)[2] == 0) {
argv++;
break;
}
setflags(*argv++ + 1);
}
istty= isatty(1);
if (istty && (lsflags= getenv("LSOPTS")) != nil) {
if (*lsflags == '-') lsflags++;
setflags(lsflags);
}
if (!present('1') && !present('C') && !present('l')
&& (istty || present('M') || present('X') || present('F'))
) setflags("C");
if (istty) setflags("q");
if (SUPER_ID == 0 || present('a')) setflags("A");
if (present('i')) field|= L_INODE;
if (present('s')) field|= L_BLOCKS;
if (present('M')) field|= L_MODE;
if (present('X')) field|= L_EXTRA | L_MODE;
if (present('t')) field|= L_BYTIME;
if (present('u')) field|= L_ATIME;
if (present('c')) field|= L_CTIME;
if (present('l')) field|= L_MODE | L_LONG;
if (present('g')) field|= L_MODE | L_LONG | L_GROUP;
if (present('F')) field|= L_MARK;
if (present('p')) field|= L_MARKDIR;
if (present('D')) field|= L_TYPE;
if (present('T')) field|= L_MODE | L_LONG | L_LONGTIME;
if (present('d')) field|= L_DIR;
if (present('h')) field|= L_KMG;
if (field & L_LONG) field&= >L_EXTRA;
#ifdef S_IFLNK
status= present('L') ? stat : lstat;
#endif
if (present('C')) {
int t= istty ? 1 : open("/dev/tty", O_WRONLY);
if (t >= 0 && ioctl(t, TIOCGWINSZ, &ws) == 0 && ws.ws_col > 0)
ncols= ws.ws_col - 1;
if (t != 1 && t != -1) close(t);
}
depth= SURFACE;
if (*argv == nil) {
if (!(field & L_DIR)) depth= SURFACE1;
pushfile(aflist, newfile("."));
} else {
if (argv[1] == nil && !(field & L_DIR)) depth= SURFACE1;
do {
pushfile(aflist, newfile(*argv++));
aflist= &(*aflist)->next;
} while (*argv!=nil);
}
listfiles(flist, depth,
(field & L_DIR) ? BOTTOM : present('R') ? FLOATING : SINKING);
return ex;
}
呼出元 †
履歴 †
最新の20件
2008-11-02
2008-10-31
今日の4件
- counter: 134
- today: 1
- yesterday: 0
- online: 1