grp.pp 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. unit grp;
  2. interface
  3. uses
  4. initc,unixtype,baseunix,ctypes;
  5. {$IFDEF FPC}
  6. {$PACKRECORDS C}
  7. {$ENDIF}
  8. const
  9. External_library= clib; {Setup as you need}
  10. _PATH_GROUP = '/etc/group';
  11. Type
  12. PGroup = ^TGroup;
  13. PPGroup = ^PGroup;
  14. TGroup = record
  15. gr_name : pchar; { group name }
  16. gr_passwd : pchar; { group password }
  17. gr_gid : gid_t; { group id }
  18. gr_mem : ppchar; { group members }
  19. end;
  20. procedure fpendgrent; cdecl;external External_library name 'endgrent';
  21. function fpgetgrent:pgroup; cdecl;external External_library name 'getgrent';
  22. function fpgetgrgid (id:gid_t):pgroup; cdecl;external External_library name 'getgrgid';
  23. function fpgetgrnam (name:pchar):pgroup; cdecl;external External_library name 'getgrnam';
  24. {$ifdef BSD}
  25. function fpgroup_from_gid (gid:gid_t; nogrup:cint):pchar; cdecl;external External_library name 'group_from_gid';
  26. {$endif}
  27. function fpsetgrent:cint;cdecl;external External_library name 'setgrent';
  28. function fpgetgrgid_r (id:gid_t; grp:Pgroup; buffer:pchar; buffersize:size_t; grresult:PPgroup):cint;cdecl;external External_library name 'getgrgid_r';
  29. function fpgetgrnam_r (nam:pchar; grp:Pgroup; buffer:pchar; buffersize:size_t; grresult:PPgroup):cint;cdecl;external External_library name 'getgrnam_r';
  30. {$ifndef Darwin}
  31. function fpgetgrent_r (grp:Pgroup; buffer:pchar; buffersize:size_t; grresult:PPgroup):cint;cdecl;external External_library name 'getgrent_r';
  32. {$endif}
  33. function fpsetgroupent (stayopen:cint):cint;cdecl;external External_library name 'setgroupent';
  34. {$ifdef Darwin}
  35. procedure fpsetgrfile(name:pchar); cdecl; external external_library name 'setgrfile';
  36. {$endif}
  37. // FreeBSD has these, Linux too if USE_BSD is defined. Darwin too.
  38. // Darwin uses ints instead of gid's though, except for setgroups.
  39. function fpsetgroups(n:size_t;groups:pgid):cint; cdecl; external External_Library name 'setgroups';
  40. function fpgetgrouplist(user:pchar;group:tgid;groups:pgid;ngroups:pcint):cint; cdecl; external External_Library name 'getgrouplist';
  41. function fpinitgroups(user:pchar;group:tgid):cint;cdecl; external External_Library name 'initgroups';
  42. implementation
  43. end.