5748431 [rkeene@sledge /home/rkeene/devel/mooselinux-0.0.19/src]$ cat -n ls.c
 1 //#define __USE_BSD
 2 #include <stdio.h>
 3 #include <unistd.h>
 4 #include <stdlib.h>
 5 #include <sys/types.h>
 6 #include <sys/stat.h>
 7 #include <fcntl.h>
 8 #include <dirent.h>
 9 #include "version.h"
10 #include "ls.h"
11 
12 
13 int ls_main (int argc, char **argv) {
14     DIR *dirtype;
15     struct dirent *dinfo;
16     char pwd[256];
17 
18     if (argc==1) {
19         strcpy(pwd,".");
20     } else {
21         strcpy(pwd,argv[1]);
22     }
23 
24     if ((dirtype=opendir(pwd))==NULL) return(-1);
25     while (1) {
26         if ((dinfo=readdir(dirtype))==NULL) break;
27         printf("%s\n",dinfo->d_name);
28     }
29     closedir(dirtype);
30     return(0);
31 }
5748432 [rkeene@sledge /home/rkeene/devel/mooselinux-0.0.19/src]$

Click here to go back to the directory listing.
Click here to download this file.
last modified: 2000-04-29 03:22:22