DataMuseum.dkPresents historical artifacts from the history of: Rational R1000/400 Tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about Rational R1000/400 Tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - downloadIndex: ┃ T l ┃
Length: 6288 (0x1890) Types: TextFile Names: »ls_f.c«
└─⟦8ee07855d⟧ Bits:30000545 8mm tape, Rational 1000, DTIA 2_1_6 └─ ⟦0c25cb74a⟧ »DATA« └─⟦038380b96⟧ └─⟦d0624311f⟧ Bits:30000529 8mm tape, Rational 1000, DTIA 2_1_7 └─ ⟦f494b5154⟧ »DATA« └─⟦038380b96⟧ └─ ⟦this⟧ »ls_f.c« └─⟦8ee07855d⟧ Bits:30000545 8mm tape, Rational 1000, DTIA 2_1_6 └─ ⟦0c25cb74a⟧ »DATA« └─⟦0732ea0cf⟧ └─⟦d0624311f⟧ Bits:30000529 8mm tape, Rational 1000, DTIA 2_1_7 └─ ⟦f494b5154⟧ »DATA« └─⟦0732ea0cf⟧ └─ ⟦this⟧ »../../dtia/release_apollo_2.1/ls_f.c« └─⟦8ee07855d⟧ Bits:30000545 8mm tape, Rational 1000, DTIA 2_1_6 └─ ⟦0c25cb74a⟧ »DATA« └─⟦25fab149a⟧ └─⟦d0624311f⟧ Bits:30000529 8mm tape, Rational 1000, DTIA 2_1_7 └─ ⟦f494b5154⟧ »DATA« └─⟦25fab149a⟧ └─ ⟦this⟧ »../../dtia/release_sun_2.1/ls_f.c« └─⟦8ee07855d⟧ Bits:30000545 8mm tape, Rational 1000, DTIA 2_1_6 └─ ⟦0c25cb74a⟧ »DATA« └─⟦be254d495⟧ └─⟦d0624311f⟧ Bits:30000529 8mm tape, Rational 1000, DTIA 2_1_7 └─ ⟦f494b5154⟧ »DATA« └─⟦be254d495⟧ └─ ⟦this⟧ »../../dtia/release_aix_2.1/ls_f.c« └─⟦8ee07855d⟧ Bits:30000545 8mm tape, Rational 1000, DTIA 2_1_6 └─ ⟦0c25cb74a⟧ »DATA« └─⟦c67979795⟧ └─⟦d0624311f⟧ Bits:30000529 8mm tape, Rational 1000, DTIA 2_1_7 └─ ⟦f494b5154⟧ »DATA« └─⟦c67979795⟧ └─ ⟦this⟧ »../../dtia/release_hp_2.1/ls_f.c«
#ifndef lint #ifndef DEBUG static char SCCS_id[] = "@(#)ls_f.c 2.1 90/08/02 19:04:54 Copyright(c) 1990 by Rational."; #else static char SCCS_id[] = "@(#)ls_f.c DEBUG 2.1 90/08/02 19:04:54 Copyright(c) 1990 by Rational."; #endif #endif #define LS_F #include "talk.h" #undef LS_F #define UNREADABLE " unredeable" #define STATFAILED " stat failed" #define UNACCESSIBLE " unaccessible" typedef int (*PFRE)(); static PFRE fct_write; extern int errno; static int error_number = E_OK; static char type(t) unsigned short t; { if (t&S_IFDIR) return 'd'; else if (t&S_IFCHR) return 'c'; else if (t&S_IFBLK) return 'b'; else if (t&S_IFREG) return '-'; else if (t&S_IFLNK) return 'l'; else if (t&S_IFSOCK) return 's'; else if (t&S_IFIFO) return 'p'; else return '?'; } static char *mode(m) unsigned short m; { static char m_value[10]; int su_mode =04000; int read_mode =0400; int write_mode =0200; int exec_mode =0100; /* Owner modes */ m_value[0]=(m&read_mode)?'r':'-'; m_value[1]=(m&write_mode)?'w':'-'; m_value[2]=(m&exec_mode)?((m&su_mode)?'s':'x'): ((m&su_mode)?'S':'-'); /* Group modes */ su_mode>>=1; read_mode>>=3; write_mode>>=3; exec_mode>>=3; m_value[3]=(m&read_mode)?'r':'-'; m_value[4]=(m&write_mode)?'w':'-'; m_value[5]=(m&exec_mode)?((m&su_mode)?'s':'x'): ((m&su_mode)?'S':'-'); /* Other modes */ su_mode>>=1; read_mode>>=3; write_mode>>=3; exec_mode>>=3; m_value[6]=(m&read_mode)?'r':'-'; m_value[7]=(m&write_mode)?'w':'-'; m_value[8]=(m&exec_mode)?((m&su_mode)?'t':'x'): ((m&su_mode)?'T':'-'); /* The end */ m_value[9]='\0'; return m_value; } static char *owner(u) int u; { static struct passwd password,*p_password; if ((p_password=getpwuid(u))==NULL) return "?"; else { password= *p_password; return password.pw_name; } } static char *group(g) int g; { static struct group grp,*p_grp; if ((p_grp=getgrgid(g))==NULL) return "?"; else { grp= *p_grp; return grp.gr_name; } } #define LEFT 0 #define RIGHT 1 #define MAXLINE 100 static char line[MAXLINE+1]; static int lg_line=0; #define FREEZON (line+lg_line) #define NBFREE (MAXLINE-lg_line) #define CONCAT(ss,ll) if(ll<=NBFREE){bcopy(ss,FREEZON,ll);lg_line+=ll;} \ else{bcopy(ss,FREEZON,NBFREE);lg_line=MAXLINE;} static void empty() { lg_line=0; } static void concat(string,adjustment,size) char *string; int adjustment,size; { int lg_string=strlen(string); int size_padding; if (size== -1) size=strlen(string); size_padding=size-lg_string; if (size_padding<0) size_padding=0; if (lg_string>size) { string[size]='\0'; lg_string=size; } switch (adjustment) { case LEFT: CONCAT(string,lg_string); while (size_padding--) CONCAT(" ",1); break; case RIGHT: while (size_padding--) CONCAT(" ",1); CONCAT(string,lg_string); break; } } static void my_itoa(i,s,l) int i; char *s; int l; { int index=l-2; s[l-1]='\0'; while (1) { if (index<0) break; s[index]='0'+(i % 10); index--; i /= 10; if (i==0) break; } if (index>=0) bcopy(s+index+1,s,l-index-1); } static void print_line() { line[lg_line]='\0'; (*fct_write)(line); empty(); } static void print(level,type,mode,nb_links,owner,group,size,path) int level; char type,*mode; short nb_links; char *owner,*group; off_t size; char *path; { char buffer[9]; char *p; p=rindex(path,'/'); if ((p?p+1:path)[0]=='.') return; while (level--) concat(" ",LEFT,1); empty(); concat(&type,LEFT,1); concat(mode,LEFT,9); concat(" ",LEFT,2); my_itoa(nb_links,buffer,3); concat(buffer,RIGHT,2); concat(" ",LEFT,2); concat(owner,LEFT,8); concat(" ",LEFT,2); concat(group,LEFT,8); concat(" ",LEFT,2); my_itoa((int)size,buffer,9); concat(buffer,RIGHT,8); concat(" ",LEFT,2); concat((p)?p+1:path,LEFT,20); print_line(); } static int print_dir(arg,root,level,level_max) char *arg,*root; int level,level_max; { static char pathname[MAXPATHLEN]; static int to_be_removed; #define FULL_PATH (to_be_removed=(arg[0]=='/')? \ 0:(rindex(root,'/')-root+1), \ (getwd(pathname)+to_be_removed) \ ) int i; int ret_stat; struct stat infos; DIR *dirp; #ifdef APOLLO struct direct *dp; #else struct dirent *dp; #endif if ((level>=level_max)&&(level_max>0)) return; empty(); if (strcmp(root,getwd(pathname))) print_line(); concat(FULL_PATH,LEFT,-1); if ((dirp=opendir("."))==NULL) { concat(UNREADABLE,LEFT,-1); print_line(); return; } else { concat(":",LEFT,1); print_line(); } for (i=1;i<3;i++) { for (dp=readdir(dirp);dp!=NULL;dp=readdir(dirp)) { if (dp->d_name[0]=='.') continue; ret_stat=stat(dp->d_name,&infos); switch (i) { case 1: if (ret_stat!= -1) print( level, type(infos.st_mode), mode(infos.st_mode), infos.st_nlink, owner(infos.st_uid), group(infos.st_gid), infos.st_size, dp->d_name ); else { concat(dp->d_name,LEFT,-1); concat(STATFAILED,LEFT,-1); print_line(); } break; case 2: if ( ((level+1<level_max)||(level_max<=0)) && (type(infos.st_mode)=='d') ) { if (chdir(dp->d_name)== -1) { empty(); print_line(); empty(); concat(FULL_PATH,LEFT,-1); concat("/",LEFT,1); concat(dp->d_name,LEFT,-1); concat(UNACCESSIBLE,LEFT,-1); print_line(); continue; } print_dir(arg,root, level+1, level_max); chdir(".."); } break; } } switch (i) { case 1: rewinddir(dirp); break; case 2: closedir(dirp); break; } } } static int print_dirs(path,level) char *path; int level; { static char pathname[MAXPATHLEN]; if (chdir(path)== -1) { empty(); concat(path,LEFT,-1); concat(UNACCESSIBLE,LEFT,-1); print_line(); return -1; } print_dir(path,getwd(pathname),0,level); return 0; } static int error; static int level; int ls_f_from_remote_directory_in(directory) char *directory; { error_number = E_OK; error=0; level=0; put_unix_name(directory); return E_OK; } int ls_f_level_in(l) int l; { level = l; return E_OK; } int ls_f_end(f) PFRE f; { int error; char *directory; fct_write = f; get_unix_name(&directory); error = print_dirs(directory,level); chdir(get_user_home()); return (error == -1) ? error_number : E_OK; }