src/commands/simple/ls.c File Reference

#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <stddef.h>
#include <stdlib.h>
#include <unistd.h>
#include <dirent.h>
#include <time.h>
#include <pwd.h>
#include <grp.h>
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
#include <termios.h>
#include <sys/ioctl.h>

Go to the source code of this file.

Classes

struct  idname
struct  file

Defines

#define ifmt(mode)   l_ifmt[((mode) >> 12) & 0xF]
#define nil   0
#define major(dev)   ((int) (((dev) >> 8) & 0xFF))
#define minor(dev)   ((int) (((dev) >> 0) & 0xFF))
#define SUPER_ID   uid
#define status   stat
#define BLOCK   512
#define ST_BLOCKS   1
#define NSEP   3
#define MAXCOLS   128
#define NNAMES   (1 << (sizeof(int) + sizeof(char *)))
#define uidname(uid)   idname((uid), PASSWD)
#define gidname(gid)   idname((gid), GROUP)
#define delpath(didx)   (path[pidx= didx]= 0)
#define L_INODE   0x0001
#define L_BLOCKS   0x0002
#define L_EXTRA   0x0004
#define L_MODE   0x0008
#define L_LONG   0x0010
#define L_GROUP   0x0020
#define L_BYTIME   0x0040
#define L_ATIME   0x0080
#define L_CTIME   0x0100
#define L_MARK   0x0200
#define L_MARKDIR   0x0400
#define L_TYPE   0x0800
#define L_LONGTIME   0x1000
#define L_DIR   0x2000
#define L_KMG   0x4000
#define PAST   (26*7*24*3600L)
#define FUTURE   ( 1*7*24*3600L)
#define K   1024L
#define T   1000L
#define nblocks(f)   ((f)->blocks)
#define nblk2k(nb)   (((nb) + (1024 / BLOCK - 1)) / (1024 / BLOCK))
#define spaces(n)   (nsp= (n))
#define terpri()   (nsp= 0, putchar('\n'))

Enumerations

enum  whatmap { PASSWD, GROUP }
enum  {
  W_COL, W_INO, W_BLK, W_NLINK,
  W_UID, W_GID, W_SIZE, W_NAME,
  MAXFLDS
}
enum  depth { SURFACE, SURFACE1, SUBMERGED }
enum  state { BOTTOM, SINKING, FLOATING }

Functions

void heaperr (void)
void * allocate (size_t n)
void * reallocate (void *a, size_t n)
void setflags (char *flgs)
int present (int f)
void report (char *f)
char * idname (unsigned id, enum whatmap map)
void addpath (int *didx, char *name)
void setstat (struct file *f, struct stat *stp)
char * permissions (struct file *f)
void numeral (int i, char **pp)
char * cxsize (struct file *f)
int namecmp (struct file *f1, struct file *f2)
int mtimecmp (struct file *f1, struct file *f2)
int atimecmp (struct file *f1, struct file *f2)
int ctimecmp (struct file *f1, struct file *f2)
int typecmp (struct file *f1, struct file *f2)
int revcmp (struct file *f1, struct file *f2)
struct filenewfile (char *name)
void pushfile (struct file **flist, struct file *new)
void delfile (struct file *old)
struct filepopfile (struct file **flist)
int dotflag (char *name)
int adddir (struct file **aflist, char *name)
off_t countblocks (struct file *flist)
void printname (char *name)
int mark (struct file *f, int doit)
void maxise (unsigned char *aw, int w)
int numwidth (unsigned long n)
int numxwidth (unsigned long n)
void print1 (struct file *f, int col, int doit)
int countfiles (struct file *flist)
void columnise (struct file *flist, int nplin)
int print (struct file *flist, int nplin, int doit)
void listfiles (struct file *flist, enum depth depth, enum state state)
int main (int argc, char **argv)

Variables

char l_ifmt [] = "0pcCd?bB-?l?s???"
int ncols = 79
char * arg0
int uid
int gid
int ex = 0
int istty
char allowed [] = "acdfghilnpqrstu1ACDFLMRTX"
char flags [sizeof(allowed)]
char arg0flag [] = "cdfmrtx"
struct idnameuids [NNAMES]
struct idnamegids [NNAMES]
char * path
int plen = 0
int pidx = 0
int field = 0
unsigned char fieldwidth [MAXCOLS][MAXFLDS]
struct filefilecol [MAXCOLS]
int nfiles
int nlines


Define Documentation

#define BLOCK   512

Definition at line 58 of file ls.c.

#define delpath ( didx   )     (path[pidx= didx]= 0)

Definition at line 228 of file ls.c.

#define FUTURE   ( 1*7*24*3600L)

Definition at line 286 of file ls.c.

#define gidname ( gid   )     idname((gid), GROUP)

Definition at line 191 of file ls.c.

#define ifmt ( mode   )     l_ifmt[((mode) >> 12) & 0xF]

Definition at line 17 of file ls.c.

#define K   1024L

Definition at line 389 of file ls.c.

#define L_ATIME   0x0080

Definition at line 240 of file ls.c.

#define L_BLOCKS   0x0002

Definition at line 234 of file ls.c.

#define L_BYTIME   0x0040

Definition at line 239 of file ls.c.

#define L_CTIME   0x0100

Definition at line 241 of file ls.c.

#define L_DIR   0x2000

Definition at line 246 of file ls.c.

#define L_EXTRA   0x0004

Definition at line 235 of file ls.c.

#define L_GROUP   0x0020

Definition at line 238 of file ls.c.

#define L_INODE   0x0001

Definition at line 233 of file ls.c.

#define L_KMG   0x4000

Definition at line 247 of file ls.c.

#define L_LONG   0x0010

Definition at line 237 of file ls.c.

#define L_LONGTIME   0x1000

Definition at line 245 of file ls.c.

#define L_MARK   0x0200

Definition at line 242 of file ls.c.

#define L_MARKDIR   0x0400

Definition at line 243 of file ls.c.

#define L_MODE   0x0008

Definition at line 236 of file ls.c.

#define L_TYPE   0x0800

Definition at line 244 of file ls.c.

#define major ( dev   )     ((int) (((dev) >> 8) & 0xFF))

Definition at line 38 of file ls.c.

#define MAXCOLS   128

Definition at line 74 of file ls.c.

#define minor ( dev   )     ((int) (((dev) >> 0) & 0xFF))

Definition at line 39 of file ls.c.

#define nblk2k ( nb   )     (((nb) + (1024 / BLOCK - 1)) / (1024 / BLOCK))

Definition at line 442 of file ls.c.

#define nblocks ( f   )     ((f)->blocks)

Definition at line 435 of file ls.c.

#define nil   0

Definition at line 19 of file ls.c.

#define NNAMES   (1 << (sizeof(int) + sizeof(char *)))

Definition at line 140 of file ls.c.

#define NSEP   3

Definition at line 72 of file ls.c.

#define PAST   (26*7*24*3600L)

Definition at line 284 of file ls.c.

#define spaces ( n   )     (nsp= (n))

Definition at line 718 of file ls.c.

#define ST_BLOCKS   1

Definition at line 63 of file ls.c.

#define status   stat

Definition at line 51 of file ls.c.

#define SUPER_ID   uid

Definition at line 43 of file ls.c.

#define T   1000L

Definition at line 390 of file ls.c.

 
#define terpri (  )     (nsp= 0, putchar('\n'))

Definition at line 719 of file ls.c.

#define uidname ( uid   )     idname((uid), PASSWD)

Definition at line 190 of file ls.c.


Enumeration Type Documentation

anonymous enum

Enumerator:
W_COL 
W_INO 
W_BLK 
W_NLINK 
W_UID 
W_GID 
W_SIZE 
W_NAME 
MAXFLDS 

Definition at line 684 of file ls.c.

enum depth

Enumerator:
SURFACE 
SURFACE1 
SUBMERGED 

Definition at line 958 of file ls.c.

enum state

Enumerator:
BOTTOM 
SINKING 
FLOATING 

Definition at line 959 of file ls.c.

enum whatmap

Enumerator:
PASSWD 
GROUP 

Definition at line 141 of file ls.c.


Function Documentation

int adddir ( struct file **  aflist,
char *  name 
)

Definition at line 595 of file ls.c.

void addpath ( int *  didx,
char *  name 
)

Definition at line 200 of file ls.c.

void* allocate ( size_t  n  ) 

Definition at line 89 of file ls.c.

int atimecmp ( struct file f1,
struct file f2 
)

Definition at line 496 of file ls.c.

void columnise ( struct file flist,
int  nplin 
)

Definition at line 900 of file ls.c.

off_t countblocks ( struct file flist  ) 

Definition at line 620 of file ls.c.

int countfiles ( struct file flist  ) 

Definition at line 887 of file ls.c.

int ctimecmp ( struct file f1,
struct file f2 
)

Definition at line 501 of file ls.c.

char* cxsize ( struct file f  ) 

Definition at line 392 of file ls.c.

void delfile ( struct file old  ) 

Definition at line 566 of file ls.c.

int dotflag ( char *  name  ) 

Definition at line 583 of file ls.c.

void heaperr ( void   ) 

Definition at line 83 of file ls.c.

char* idname ( unsigned  id,
enum whatmap  map 
)

Definition at line 149 of file ls.c.

void listfiles ( struct file flist,
enum depth  depth,
enum state  state 
)

Definition at line 961 of file ls.c.

int main ( int argc  ,
char **  argv 
)

Definition at line 1059 of file ls.c.

int mark ( struct file f,
int  doit 
)

Definition at line 652 of file ls.c.

void maxise ( unsigned char *  aw,
int  w 
)

Definition at line 688 of file ls.c.

int mtimecmp ( struct file f1,
struct file f2 
)

Definition at line 491 of file ls.c.

int namecmp ( struct file f1,
struct file f2 
)

Definition at line 486 of file ls.c.

struct file* newfile ( char *  name  )  [read]

Definition at line 549 of file ls.c.

void numeral ( int  i,
char **  pp 
)

Definition at line 380 of file ls.c.

int numwidth ( unsigned long  n  ) 

Definition at line 697 of file ls.c.

int numxwidth ( unsigned long  n  ) 

Definition at line 707 of file ls.c.

char* permissions ( struct file f  ) 

Definition at line 326 of file ls.c.

struct file* popfile ( struct file **  flist  )  [read]

Definition at line 573 of file ls.c.

int present ( int  f  ) 

Definition at line 125 of file ls.c.

int print ( struct file flist,
int  nplin,
int  doit 
)

Definition at line 918 of file ls.c.

void print1 ( struct file f,
int  col,
int  doit 
)

Definition at line 721 of file ls.c.

void printname ( char *  name  ) 

Definition at line 639 of file ls.c.

void pushfile ( struct file **  flist,
struct file new 
)

Definition at line 559 of file ls.c.

void* reallocate ( void *  a,
size_t  n 
)

Definition at line 98 of file ls.c.

void report ( char *  f  ) 

Definition at line 130 of file ls.c.

int revcmp ( struct file f1,
struct file f2 
)

Definition at line 511 of file ls.c.

void setflags ( char *  flgs  ) 

Definition at line 109 of file ls.c.

void setstat ( struct file f,
struct stat stp 
)

Definition at line 267 of file ls.c.

int typecmp ( struct file f1,
struct file f2 
)

Definition at line 506 of file ls.c.


Variable Documentation

char allowed[] = "acdfghilnpqrstu1ACDFLMRTX"

Definition at line 104 of file ls.c.

char* arg0

Definition at line 76 of file ls.c.

char arg0flag[] = "cdfmrtx"

Definition at line 107 of file ls.c.

int ex = 0

Definition at line 78 of file ls.c.

int field = 0

Definition at line 230 of file ls.c.

unsigned char fieldwidth[MAXCOLS][MAXFLDS]

Definition at line 686 of file ls.c.

struct file* filecol[MAXCOLS]

Definition at line 897 of file ls.c.

char flags[sizeof(allowed)]

Definition at line 105 of file ls.c.

int gid

Definition at line 77 of file ls.c.

struct idname * gids[NNAMES]

int istty

Definition at line 79 of file ls.c.

char l_ifmt[] = "0pcCd?bB-?l?s???"

Definition at line 15 of file ls.c.

int ncols = 79

Definition at line 70 of file ls.c.

int nfiles

Definition at line 898 of file ls.c.

int nlines

Definition at line 898 of file ls.c.

char* path

Definition at line 197 of file ls.c.

int pidx = 0

Definition at line 198 of file ls.c.

int plen = 0

Definition at line 198 of file ls.c.

int uid

Definition at line 77 of file ls.c.

struct idname * uids[NNAMES]


Generated on Tue Mar 9 04:36:41 2010 for Minix by  doxygen 1.5.8