Jelajahi Sumber

* PChar -> PAnsiChar

Michaël Van Canneyt 2 tahun lalu
induk
melakukan
07450440b1

+ 6 - 6
packages/users/examples/testpass.pp

@@ -7,7 +7,7 @@ Program TestPass;
 uses {$ifdef linux}shadow, {$endif} pwd  ,crypth ;
 
 Var
-  strUserName, Password : String;
+  strUserName, Password : AnsiString;
   sEntry : PPasswordFileEntry;
   pEntry : PPasswd;
 
@@ -17,9 +17,9 @@ Const
   Err_WrongPass = 2;
   NoUser = '*NO USER*';
 
-Function UserEncPass(User: String): String;
+Function UserEncPass(User: AnsiString): AnsiString;
 Var
-  A : Array[0..255] of char;
+  A : Array[0..255] of AnsiChar;
 Begin
   A := strUserName;
   {$IFDEF DEBUG}
@@ -44,10 +44,10 @@ Begin
   if pEntry <> nil then UserEncPass := pEntry^.pw_passwd
 End;
 
-Function CheckPass(User, Pass: String): Integer;
+Function CheckPass(User, Pass: AnsiString): Integer;
 Var
-  EncPass, ResultPass, SSalt : String;
-  PCPass, PCSalt, PCResult : Array[0..255] of Char;
+  EncPass, ResultPass, SSalt : AnsiString;
+  PCPass, PCSalt, PCResult : Array[0..255] of AnsiChar;
   I : Integer;
 Begin
   EncPass := UserEncPass(User);

+ 3 - 3
packages/users/examples/testpass2.pp

@@ -4,7 +4,7 @@ Uses pwd,grp,baseunix,sysutils;
 
 {$mode objfpc}{$h+}
 
-Procedure printpchar(fieldname:String;p:pchar);
+Procedure printpchar(fieldname:ansistring;p:PAnsiChar);
 
 Begin
   If assigned(p) Then
@@ -15,10 +15,10 @@ Begin
     End;
 End;
 
-Procedure printpchar(fieldname,p:string);
+Procedure printpchar(fieldname,p:ansistring);
 
 Begin
-  printpchar(fieldname,pchar(p));
+  printpchar(fieldname,PAnsiChar(p));
 End;
 
 Var p : PPasswd;

+ 1 - 1
packages/users/src/crypth.pp

@@ -8,7 +8,7 @@ uses BaseUnix,initc;
 
 Const libname ={$ifdef Linux}'crypt'{$else}clib{$endif};
 
-function crypt(key,salt:pchar):pchar;cdecl; external libname name 'crypt';
+function crypt(key,salt:PAnsiChar):PAnsiChar;cdecl; external libname name 'crypt';
 
 implementation
 end.

+ 11 - 11
packages/users/src/grp.pp

@@ -19,41 +19,41 @@ Type
      PGroup = ^TGroup;
      PPGroup = ^PGroup;
      TGroup = record
-          gr_name   : pchar;                { group name  }
-          gr_passwd : pchar;		     { group password  }	
+          gr_name   : PAnsiChar;                { group name  }
+          gr_passwd : PAnsiChar;		     { group password  }	
           gr_gid    : gid_t;		     { group id  }
-          gr_mem    : ppchar;		     { group members  }
+          gr_mem    : PPAnsiChar;		     { group members  }
        end;
 
 
 procedure fpendgrent; cdecl;external External_library name 'endgrent';
 function  fpgetgrent:pgroup; cdecl;external External_library name 'getgrent';
 function  fpgetgrgid (id:gid_t):pgroup; cdecl;external External_library name 'getgrgid';
-function  fpgetgrnam (name:pchar):pgroup; cdecl;external External_library name 'getgrnam';
+function  fpgetgrnam (name:PAnsiChar):pgroup; cdecl;external External_library name 'getgrnam';
 {$ifdef BSD}
-function  fpgroup_from_gid (gid:gid_t; nogrup:cint):pchar; cdecl;external External_library name 'group_from_gid';
+function  fpgroup_from_gid (gid:gid_t; nogrup:cint):PAnsiChar; cdecl;external External_library name 'group_from_gid';
 {$endif}
 
 function  fpsetgrent:cint;cdecl;external External_library name 'setgrent';
 
-function  fpgetgrgid_r (id:gid_t; grp:Pgroup; buffer:pchar; buffersize:size_t; grresult:PPgroup):cint;cdecl;external External_library name 'getgrgid_r';
+function  fpgetgrgid_r (id:gid_t; grp:Pgroup; buffer:PAnsiChar; buffersize:size_t; grresult:PPgroup):cint;cdecl;external External_library name 'getgrgid_r';
 
-function  fpgetgrnam_r (nam:pchar; grp:Pgroup; buffer:pchar; buffersize:size_t; grresult:PPgroup):cint;cdecl;external External_library name 'getgrnam_r';
+function  fpgetgrnam_r (nam:PAnsiChar; grp:Pgroup; buffer:PAnsiChar; buffersize:size_t; grresult:PPgroup):cint;cdecl;external External_library name 'getgrnam_r';
 {$ifndef Darwin}
-function  fpgetgrent_r (grp:Pgroup; buffer:pchar; buffersize:size_t; grresult:PPgroup):cint;cdecl;external External_library name 'getgrent_r';
+function  fpgetgrent_r (grp:Pgroup; buffer:PAnsiChar; buffersize:size_t; grresult:PPgroup):cint;cdecl;external External_library name 'getgrent_r';
 {$endif}
 
 function  fpsetgroupent (stayopen:cint):cint;cdecl;external External_library name 'setgroupent';
 
 {$ifdef Darwin}
-procedure fpsetgrfile(name:pchar); cdecl; external external_library name 'setgrfile';
+procedure fpsetgrfile(name:PAnsiChar); cdecl; external external_library name 'setgrfile';
 {$endif}
 
 // FreeBSD has these, Linux too if USE_BSD is defined. Darwin too.
 // Darwin uses ints instead of gid's though, except for setgroups.
 function  fpsetgroups(n:size_t;groups:pgid):cint; cdecl; external External_Library name 'setgroups';
-function  fpgetgrouplist(user:pchar;group:tgid;groups:pgid;ngroups:pcint):cint; cdecl; external External_Library name 'getgrouplist';
-function  fpinitgroups(user:pchar;group:tgid):cint;cdecl; external External_Library name 'initgroups';
+function  fpgetgrouplist(user:PAnsiChar;group:tgid;groups:pgid;ngroups:pcint):cint; cdecl; external External_Library name 'getgrouplist';
+function  fpinitgroups(user:PAnsiChar;group:tgid):cint;cdecl; external External_Library name 'initgroups';
 
 implementation
 

+ 10 - 10
packages/users/src/pwd.pp

@@ -72,17 +72,17 @@ type
      PPasswd  = ^TPasswd;
      PPPasswd = ^PPasswd;
      Passwd   = record
-            pw_name    : pchar;        { user name  }
-            pw_passwd  : pchar;	{ encrypted password  }
+            pw_name    : PAnsiChar;        { user name  }
+            pw_passwd  : PAnsiChar;	{ encrypted password  }
             pw_uid     : Tuid;		{ user uid  }
             pw_gid     : Tgid;		{ user gid  }
             {$ifdef bsd}
             pw_change  : Ttime platform;         { password change time  }
-            pw_class   : pchar platform;        { user access class  }
+            pw_class   : PAnsiChar platform;        { user access class  }
             {$endif}
-            pw_gecos   : pchar;        { Honeywell login info  }
-            pw_dir     : pchar;        { home directory  }
-            pw_shell   : pchar;        { default shell  }
+            pw_gecos   : PAnsiChar;        { Honeywell login info  }
+            pw_dir     : PAnsiChar;        { home directory  }
+            pw_shell   : PAnsiChar;        { default shell  }
             {$ifdef bsd}
             pw_expire  : Ttime platform;         { account expiration  }
             {$ifdef FreeBSD}
@@ -113,17 +113,17 @@ const
         _PWF_HESIOD 	 = $3000;       
 {$endif}
 
-function  fpgetpwnam (name:pchar):PPasswd; cdecl;external External_library name 'getpwnam';
+function  fpgetpwnam (name:PAnsiChar):PPasswd; cdecl;external External_library name 'getpwnam';
 function  fpgetpwuid (id:tuid):PPasswd;cdecl;external External_library name 'getpwuid';
 
 procedure fpendpwent;cdecl;external External_library name 'endpwent';
 function  fpgetpwent:ppasswd;cdecl;external External_library name 'getpwent';
 procedure fpsetpwent;cdecl;external External_library name 'setpwent';
 
-function  fpgetpwnam_r (namepara1:pchar; pwd:Ppasswd; buffer:pchar; bufsize:size_t; pwresult:PPpasswd):cint;cdecl;external External_library name 'getpwnam_r';
-function  fpgetpwuid_r (uid:uid_t; pwd:Ppasswd; buffer:pchar; buffersize:size_t; pwresult:PPpasswd):cint;cdecl;external External_library name 'getpwuid_r';
+function  fpgetpwnam_r (namepara1:PAnsiChar; pwd:Ppasswd; buffer:PAnsiChar; bufsize:size_t; pwresult:PPpasswd):cint;cdecl;external External_library name 'getpwnam_r';
+function  fpgetpwuid_r (uid:uid_t; pwd:Ppasswd; buffer:PAnsiChar; buffersize:size_t; pwresult:PPpasswd):cint;cdecl;external External_library name 'getpwuid_r';
 {$ifndef Darwin}
-function  fpgetpwent_r (pwd:Ppasswd; buffer:pchar; buffersize:size_t; pwresult:PPpasswd):cint;cdecl;external External_library name 'getpwent_r';
+function  fpgetpwent_r (pwd:Ppasswd; buffer:PAnsiChar; buffersize:size_t; pwresult:PPpasswd):cint;cdecl;external External_library name 'getpwent_r';
 {$endif}
 
 implementation

+ 4 - 4
packages/users/src/shadow.pp

@@ -35,8 +35,8 @@ type
 
    Pspwd = ^spwd;
    spwd = record
-        sp_namp : pchar;
-        sp_pwdp : pchar;
+        sp_namp : PAnsiChar;
+        sp_pwdp : PAnsiChar;
         sp_lstchg : longint;
         sp_min : longint;
         sp_max : longint;
@@ -51,8 +51,8 @@ type
 procedure setspent;cdecl;external External_library name 'setspent';
 procedure endspent;cdecl;external External_library name 'endspent';
 function getspent:Pspwd;cdecl;external External_library name 'getspent';
-function getspnam(__name:Pchar):Pspwd;cdecl;external External_library name 'getspnam';
-function sgetspent(__string:Pchar):Pspwd;cdecl;external External_library name 'sgetspent';
+function getspnam(__name:PAnsiChar):Pspwd;cdecl;external External_library name 'getspnam';
+function sgetspent(__string:PAnsiChar):Pspwd;cdecl;external External_library name 'sgetspent';
 function fgetspent(__stream:PFILE):Pspwd;cdecl;external External_library name 'fgetspent';
 function putspent(__p:Pspwd; __stream:PFILE):longint;cdecl;external External_library name 'putspent';
 function lckpwdf:longint;cdecl;external External_library name 'lckpwdf';

+ 40 - 40
packages/users/src/users.pp

@@ -13,42 +13,42 @@ Type
 
 { User functions }
 
-Function  getpwnam(Const UserName: String) : PPasswordRecord;
-Procedure GetUserData(Const UserName : String; Var Data : TPasswordRecord); overload;
+Function  getpwnam(Const UserName: AnsiString) : PPasswordRecord;
+Procedure GetUserData(Const UserName : AnsiString; Var Data : TPasswordRecord); overload;
 Procedure GetUserData(Uid : TUID; Var Data : TPasswordRecord); overload;
-function  GetUserName(UID : TUID) : String;
-function  GetUserId(Const UserName : String) : TUID;
-function  GetUserGid(Const UserName : String) : TGID;
-function  GetUserDir(Const UserName : String): String;
-function  GetUserDescription(Const UserName : String): String;
+function  GetUserName(UID : TUID) : AnsiString;
+function  GetUserId(Const UserName : AnsiString) : TUID;
+function  GetUserGid(Const UserName : AnsiString) : TGID;
+function  GetUserDir(Const UserName : AnsiString): AnsiString;
+function  GetUserDescription(Const UserName : AnsiString): AnsiString;
 Procedure GetUserList(List : Tstrings);overload;
 Procedure GetUserList(List : TStrings; WithIDs : Boolean);overload;
 
 { Group functions }
 
-Function  getgrnam(Const GroupName: String) : PGroup;
-Procedure GetGroupData(Const GroupName : String; Var Data : TGroup); overload;
+Function  getgrnam(Const GroupName: AnsiString) : PGroup;
+Procedure GetGroupData(Const GroupName : AnsiString; Var Data : TGroup); overload;
 Procedure GetGroupData(Gid : TGID; Var Data : TGroup); overload;
-function  GetGroupName(GID : TGID) : String;
-function  GetGroupId(Const GroupName : String) : TGID;
+function  GetGroupName(GID : TGID) : AnsiString;
+function  GetGroupId(Const GroupName : AnsiString) : TGID;
 Procedure GetGroupList(List : Tstrings);overload;
 Procedure GetGroupList(List : TStrings; WithIDs : Boolean);overload;
 Procedure GetGroupMembers(GID : TGID;List : TStrings);overload;
-Procedure GetGroupMembers(Const GroupName : String;List : TStrings);overload;
+Procedure GetGroupMembers(Const GroupName : AnsiString;List : TStrings);overload;
 
 { Shadow password functions }
 
 {$ifdef Linux}
-function getspnam(UserName : String): PPasswordFileEntry;
-function sgetspent(Line : String): PPasswordFileEntry;
+function getspnam(UserName : AnsiString): PPasswordFileEntry;
+function sgetspent(Line : AnsiString): PPasswordFileEntry;
 
-Procedure GetUserShadowData(Const UserName : String; Var Data : TPasswordFileEntry);overload;
+Procedure GetUserShadowData(Const UserName : AnsiString; Var Data : TPasswordFileEntry);overload;
 Procedure GetUserShadowData(UID : TUID; Var Data : TPasswordFileEntry);overload;
 {$endif}
 
 { Extra functions }
 
-Function GetUserGroup(Const UserName : String) : String;
+Function GetUserGroup(Const UserName : AnsiString) : AnsiString;
 
 Implementation
 
@@ -61,18 +61,18 @@ EnoSuchGroupID = 'Unknown group ID: %d';
 ENoShadowEntry = 'No shadow file entry for "%s"';
 EShadowNotPermitted = 'Not enough permissions to access shadow password file';
 
-Function getpwnam(Const UserName: String) : PPasswordRecord;
+Function getpwnam(Const UserName: AnsiString) : PPasswordRecord;
 
 begin
-  Result:=pwd.fpgetpwnam(Pchar(UserName));
+  Result:=pwd.fpgetpwnam(PAnsiChar(UserName));
 end;
 
-Procedure GetUserData(Const UserName : String; Var Data : TPasswordRecord);
+Procedure GetUserData(Const UserName : AnsiString; Var Data : TPasswordRecord);
 
 Var P : PPasswordRecord;
 
 begin
-  P:=fpGetpwnam(pchar(UserName));
+  P:=fpGetpwnam(PAnsiChar(UserName));
   If P<>Nil then
     Data:=P^
   else
@@ -91,7 +91,7 @@ begin
     Raise EUserLookupError.CreateFmt(ENoSuchUserID,[Uid]);
 end;
 
-function GetUserName(UID : TUID) : String;
+function GetUserName(UID : TUID) : AnsiString;
 
 Var
   UserData : TPasswordRecord;
@@ -101,7 +101,7 @@ begin
   Result:=UserData.pw_Name;
 end;
 
-function  GetUserId(Const UserName : String) : TUID;
+function  GetUserId(Const UserName : AnsiString) : TUID;
 
 Var
   UserData : TPasswordRecord;
@@ -111,7 +111,7 @@ begin
   Result:=UserData.pw_uid;
 end;
 
-function  GetUserGId(Const UserName : String) : TGID;
+function  GetUserGId(Const UserName : AnsiString) : TGID;
 
 Var
   UserData : TPasswordRecord;
@@ -121,7 +121,7 @@ begin
   Result:=UserData.pw_gid;
 end;
 
-function GetUserDir(Const UserName : String): String;
+function GetUserDir(Const UserName : AnsiString): AnsiString;
 
 Var
   UserData : TPasswordRecord;
@@ -131,7 +131,7 @@ begin
   Result:=UserData.pw_dir;
 end;
 
-function  GetUserDescription(Const UserName : String): String;
+function  GetUserDescription(Const UserName : AnsiString): AnsiString;
 
 Var
   UserData : TPasswordRecord;
@@ -176,18 +176,18 @@ end;
   ---------------------------------------------------------------------}
 
 
-Function  getgrnam(Const GroupName: String) : PGroup;
+Function  getgrnam(Const GroupName: AnsiString) : PGroup;
 
 begin
-  Result:=grp.fpgetgrnam(Pchar(GroupName));
+  Result:=grp.fpgetgrnam(PAnsiChar(GroupName));
 end;
 
-Procedure GetGroupData(Const GroupName : String; Var Data : TGroup); overload;
+Procedure GetGroupData(Const GroupName : AnsiString; Var Data : TGroup); overload;
 
 Var P : PGroup;
 
 begin
-  P:=fpGetgrnam(pchar(GroupName));
+  P:=fpGetgrnam(PAnsiChar(GroupName));
   If P<>Nil then
     Data:=P^
   else
@@ -206,7 +206,7 @@ begin
     Raise EGroupLookupError.CreateFmt(ENoSuchGroupID,[Gid]);
 end;
 
-function GetGroupName(GID : TGID) : String;
+function GetGroupName(GID : TGID) : AnsiString;
 
 Var
   G : TGroup;
@@ -216,7 +216,7 @@ begin
   Result:=G.gr_name;
 end;
 
-function  GetGroupId(Const GroupName : String) : TGID;
+function  GetGroupId(Const GroupName : AnsiString) : TGID;
 
 Var
   G : TGroup;
@@ -256,14 +256,14 @@ begin
   end;
 end;
 
-Function PCharListToStrings(P : PPChar; List : TStrings) : Integer;
+Function PCharListToStrings(P : PPAnsiChar; List : TStrings) : Integer;
 
 begin
   List.Clear;
   While P^<>Nil do
     begin
     List.Add(StrPas(P^));
-    P:=PPChar(PChar(P)+SizeOf(PChar));
+    P:=PPAnsiChar(PAnsiChar(P)+SizeOf(PAnsiChar));
     end;
   Result:=List.Count;
 end;
@@ -279,7 +279,7 @@ begin
   PCharListToStrings(G.gr_mem,List);
 end;
 
-Procedure GetGroupMembers(Const GroupName : String;List : TStrings);
+Procedure GetGroupMembers(Const GroupName : AnsiString;List : TStrings);
 
 Var
   G : TGroup;
@@ -291,19 +291,19 @@ end;
 
 { Shadow password functions }
 {$ifdef linux}
-function getspnam(UserName : String): PPasswordFileEntry;
+function getspnam(UserName : AnsiString): PPasswordFileEntry;
 
 begin
-  result:=shadow.getspnam(Pchar(UserName));
+  result:=shadow.getspnam(PAnsiChar(UserName));
 end;
 
-function sgetspent(Line : String): PPasswordFileEntry;
+function sgetspent(Line : AnsiString): PPasswordFileEntry;
 
 begin
-  Result:=shadow.sgetspent(Pchar(Line));
+  Result:=shadow.sgetspent(PAnsiChar(Line));
 end;
 
-Procedure GetUserShadowData(Const UserName : String; Var Data : TPasswordFileEntry);
+Procedure GetUserShadowData(Const UserName : AnsiString; Var Data : TPasswordFileEntry);
 
 Var
   P : PPasswordFileEntry;
@@ -328,7 +328,7 @@ end;
 {$endif}
 { Extra functions }
 
-Function GetUserGroup(Const UserName : String) : String;
+Function GetUserGroup(Const UserName : AnsiString) : AnsiString;
 
 begin
   GetGroupName(GetUserGid(UserName));