UNIX Free Pascal


. - 10


uses linux,strings,sysutils;

 

{$linklib c}

 

type

plong=^longint;

 

function ctime(r:plong):pchar;cdecl;external;

 

function getall(w:string;uid:integer):string;

{const w='/etc/passwd';}

var ts,nam1,namb1:string;

tx:text;

d:integer;

begin

assign(tx,w);

reset(tx);

while not EOF (tx) do

begin

readln(tx,ts);

d:=pos(':',ts);

nam1:=copy(ts,1,d-1);

delete(ts,1,d+2);

d:=pos(':',ts);

{delete(ts,1,d);}

namb1:=copy(ts,1,d-1);

val(namb1,d);

{writeln(' = ',nam1,', =',namb1);}

if d=uid then

break;

end;

close(tx);

getall:=nam1;

end;

 

 

 

 

function getname(uid:integer):string;

begin

getname:=getall('/etc/passwd',uid);

end;

 

 

function getgroup(gid:integer):string;

begin

getgroup:=getall('/etc/group',gid);

end;

 

 

function gettype(mode:integer):char;

begin

if S_ISREG(mode) then

gettype:='-'

else

if S_ISDIR(mode) then

gettype:='d'

else

if S_ISCHR(mode) then

gettype:='c'

else

if S_ISBLK(mode) then

gettype:='b'

else

if S_ISFIFO(mode) then

gettype:='p'

else

gettype:='l';

end;

 

function getrights(mode:integer):string;

const

sympr:array [0..7] of string=(

'---', {0}

'--x', {1}

'-w-', {2}

'-wx', {3}

'r--', {4}

'r-x', {5}

'rw-', {6}

'rwx' {7}

);

specsympr:array [0..7] of string=(

'---', {0}

'--t', {1}

'-s-', {2}

'-st', {3}




- -  - -  - -