save
This commit is contained in:
		
							
								
								
									
										83
									
								
								atbgit.pas
									
									
									
									
									
								
							
							
						
						
									
										83
									
								
								atbgit.pas
									
									
									
									
									
								
							| @@ -4,7 +4,7 @@ unit ATBGit; | |||||||
|  |  | ||||||
| interface | interface | ||||||
|  |  | ||||||
| uses SysUtils, fpjson, jsonparser; | uses CTypes, SysUtils, fpjson, jsonparser; | ||||||
|  |  | ||||||
|   // |   // | ||||||
|   // public interface |   // public interface | ||||||
| @@ -13,14 +13,74 @@ uses SysUtils, fpjson, jsonparser; | |||||||
|   function GetReposRootDirectory(): UTF8String; |   function GetReposRootDirectory(): UTF8String; | ||||||
|   function GetLocalRepositoryPath(const localrepo: UTF8String): UTF8String; |   function GetLocalRepositoryPath(const localrepo: UTF8String): UTF8String; | ||||||
|  |  | ||||||
|  |   function InitGitLibrary(): Integer; | ||||||
|  |   function ShutdownGitLibrary(): Integer; | ||||||
|  |   function CloneRepository(const url, localRepo: UTF8String): Integer; | ||||||
|  |   function CheckoutRepository(const url, localRepo, branchName: UTF8String): Integer; | ||||||
|  |   function CommitFile(const localRepoName, branchName, fName, commitMessage: UTF8String): Integer; | ||||||
|  |  | ||||||
|   // private c-interface |   // private c-interface | ||||||
|   procedure SetReposRootDirectoryInternal(const rootDir: PChar); stdcall; |   procedure SetReposRootDirectoryInternal(const rootDir: PChar); stdcall; | ||||||
|   function GetReposRootDirectoryInternal(): PChar; stdcall; |   function GetReposRootDirectoryInternal(): PChar; stdcall; | ||||||
|   function GetLocalRepositoryPathInternal(const localRepo: PChar): PChar; stdcall; |   function GetLocalRepositoryPathInternal(const localRepo: PChar): PChar; stdcall; | ||||||
|  |   function CloneRepositoryInternal(const url, localRepo: PChar): cint32; stdcall; | ||||||
|  |   function CheckoutRepositoryInternal(const url, localRepo, branchName: PChar): cint32; stdcall; | ||||||
|  |   function CommitFileInternal(const localRepoName, branchName, fName, commitMessage: PChar): cint32; stdcall; | ||||||
|  |   function PushRepositoryInternal(const localRepoName, branchName, user, password: PChar): cint32; stdcall; | ||||||
|  |   function PullRepositoryInternal(const localRepoName, remoteRepoName: PChar): cint32; stdcall; | ||||||
|  |  | ||||||
|  |   function InitGitLibraryInternal: cint32; stdcall; | ||||||
|  |   function ShutdownGitLibraryInternal: cint32; stdcall; | ||||||
|  |  | ||||||
| implementation | implementation | ||||||
|  |  | ||||||
|     const DLLName = 'CalculatorCInterface.dll'; |     const DLLName = 'CalculatorCInterface.dll'; | ||||||
|  |  | ||||||
|  |     function InitGitLibrary(): Integer; | ||||||
|  |     begin | ||||||
|  |         Result := InitGitLibraryInternal(); | ||||||
|  |     end; | ||||||
|  |  | ||||||
|  |     function ShutdownGitLibrary(): Integer; | ||||||
|  |     begin | ||||||
|  |         Result := ShutdownGitLibraryInternal(); | ||||||
|  |     end; | ||||||
|  |  | ||||||
|  |     function CloneRepository(const url, localRepo: UTF8String): Integer; | ||||||
|  |     begin | ||||||
|  |         Result := CloneRepositoryInternal(PChar(Utf8toAnsi(url)), | ||||||
|  |                                           PChar(Utf8toAnsi(localRepo))); | ||||||
|  |     end; | ||||||
|  |  | ||||||
|  |     function CheckoutRepository(const url, localRepo, branchName: UTF8String): Integer; | ||||||
|  |     begin | ||||||
|  |         Result := CheckoutRepositoryInternal(PChar(Utf8toAnsi(url)), | ||||||
|  |                                              PChar(Utf8toAnsi(localRepo)), | ||||||
|  |                                              PChar(Utf8toAnsi(branchName))); | ||||||
|  |     end; | ||||||
|  |  | ||||||
|  |     function CommitFile(const localRepoName, branchName, fName, commitMessage: UTF8String): Integer; | ||||||
|  |     begin | ||||||
|  |         Result := CommitFileInternal(PChar(Utf8toAnsi(localRepoName)), | ||||||
|  |                                      PChar(Utf8toAnsi(branchName)), | ||||||
|  |                                      PChar(Utf8toAnsi(fName)), | ||||||
|  |                                      PChar(Utf8toAnsi(commitMessage))); | ||||||
|  |     end; | ||||||
|  |  | ||||||
|  |     function PushRepository(const localRepoName, branchName, user, password: UTF8String): Integer; | ||||||
|  |     begin | ||||||
|  |         Result := PushRepositoryInternal(PChar(Utf8toAnsi(localRepoName)), | ||||||
|  |                                          PChar(Utf8toAnsi(branchName)), | ||||||
|  |                                          PChar(Utf8toAnsi(user)), | ||||||
|  |                                          PChar(Utf8toAnsi(password))); | ||||||
|  |     end; | ||||||
|  |  | ||||||
|  |     function PullRepository(const localRepoName, remoteRepoName: UTF8String): Integer; | ||||||
|  |     begin | ||||||
|  |         Result := PullRepositoryInternal(PChar(Utf8toAnsi(localRepoName)), | ||||||
|  |                                          PChar(Utf8toAnsi(remoteRepoName))); | ||||||
|  |     end; | ||||||
|  |  | ||||||
|     /// |     /// | ||||||
|     procedure SetReposRootDirectory(const rootDir: UTF8String); |     procedure SetReposRootDirectory(const rootDir: UTF8String); | ||||||
|     begin |     begin | ||||||
| @@ -59,5 +119,26 @@ implementation | |||||||
|     function GetLocalRepositoryPathInternal(const localRepo: PChar): PChar; stdcall; |     function GetLocalRepositoryPathInternal(const localRepo: PChar): PChar; stdcall; | ||||||
|         external DLLName; |         external DLLName; | ||||||
|  |  | ||||||
|  |     function InitGitLibraryInternal: cint32; stdcall; | ||||||
|  |         external DLLName; | ||||||
|  |  | ||||||
|  |     function ShutdownGitLibraryInternal: cint32; stdcall; | ||||||
|  |         external DLLName; | ||||||
|  |  | ||||||
|  |     function CloneRepositoryInternal(const url, localRepo: PChar): cint32; stdcall; | ||||||
|  |         external DLLName; | ||||||
|  |  | ||||||
|  |     function CheckoutRepositoryInternal(const url, localRepo, branchName: PChar): cint32; stdcall; | ||||||
|  |         external DLLName; | ||||||
|  |  | ||||||
|  |     function CommitFileInternal(const localRepoName, branchName, fName, commitMessage: PChar): cint32; stdcall; | ||||||
|  |         external DLLName; | ||||||
|  |  | ||||||
|  |     function PushRepositoryInternal(const localRepoName, branchName, user, password: PChar): cint32; stdcall; | ||||||
|  |         external DLLName; | ||||||
|  |  | ||||||
|  |     function PullRepositoryInternal(const localRepoName, remoteRepoName: PChar): cint32; stdcall; | ||||||
|  |         external DLLName; | ||||||
|  |  | ||||||
| end. | end. | ||||||
|  |  | ||||||
|   | |||||||
| @@ -25,10 +25,10 @@ procedure DeleteTariffCalculator(handle: TariffCalculatorHandle); stdcall; | |||||||
| //function GetFileSize(const localRepository: PChar; const fileId: PChar): cint32; stdcall; | //function GetFileSize(const localRepository: PChar; const fileId: PChar): cint32; stdcall; | ||||||
| //function GetFile(const localRepository: PChar; const fileId: PChar): PChar; stdcall; | //function GetFile(const localRepository: PChar; const fileId: PChar): PChar; stdcall; | ||||||
|  |  | ||||||
| function InitGitLibrary: cint32; stdcall; | //function InitGitLibrary: cint32; stdcall; | ||||||
| function ShutdownGitLibrary: cint32; stdcall; | //function ShutdownGitLibrary: cint32; stdcall; | ||||||
| function CloneRepository(var url; var local_path) : cint32; stdcall; | //function CloneRepository(var url; var local_path) : cint32; stdcall; | ||||||
| function CheckoutLocalBranch(var local_path; var branch_name) : cint32; stdcall; | //function CheckoutLocalBranch(var local_path; var branch_name) : cint32; stdcall; | ||||||
| function CommitFile(var local_path; var branch_name; | function CommitFile(var local_path; var branch_name; | ||||||
|                     var file_name; var comment) : cint32; stdcall; |                     var file_name; var comment) : cint32; stdcall; | ||||||
| function PushLocalRepository(var local_path; var branch_name; | function PushLocalRepository(var local_path; var branch_name; | ||||||
| @@ -86,10 +86,10 @@ procedure DeleteTariffCalculator(handle: TariffCalculatorHandle); stdcall; exter | |||||||
| //                         const json: PChar; | //                         const json: PChar; | ||||||
| //                         size: cint32): cbool; stdcall; external DLLName; | //                         size: cint32): cbool; stdcall; external DLLName; | ||||||
|  |  | ||||||
| function InitGitLibrary: cint32; stdcall; external DLLName; | //function InitGitLibrary: cint32; stdcall; external DLLName; | ||||||
| function ShutdownGitLibrary: cint32; stdcall; external DLLName; | //function ShutdownGitLibrary: cint32; stdcall; external DLLName; | ||||||
| function CloneRepository(var url; var local_path) : cint32; stdcall; external DLLName; | //function CloneRepository(var url; var local_path) : cint32; stdcall; external DLLName; | ||||||
| function CheckoutLocalBranch(var local_path; var branch_name) : cint32; stdcall; external DLLName; | //function CheckoutLocalBranch(var local_path; var branch_name) : cint32; stdcall; external DLLName; | ||||||
| function CommitFile(var local_path; var branch_name; | function CommitFile(var local_path; var branch_name; | ||||||
|                     var file_name; var comment) : cint32; stdcall; external DLLName; |                     var file_name; var comment) : cint32; stdcall; external DLLName; | ||||||
| function PushLocalRepository(var local_path; var branch_name; | function PushLocalRepository(var local_path; var branch_name; | ||||||
|   | |||||||
| @@ -4,7 +4,7 @@ unit ATBGit; | |||||||
|  |  | ||||||
| interface | interface | ||||||
|  |  | ||||||
| uses SysUtils, fpjson, jsonparser; | uses CTypes, SysUtils, fpjson, jsonparser; | ||||||
|  |  | ||||||
|   // |   // | ||||||
|   // public interface |   // public interface | ||||||
| @@ -13,14 +13,74 @@ uses SysUtils, fpjson, jsonparser; | |||||||
|   function GetReposRootDirectory(): UTF8String; |   function GetReposRootDirectory(): UTF8String; | ||||||
|   function GetLocalRepositoryPath(const localrepo: UTF8String): UTF8String; |   function GetLocalRepositoryPath(const localrepo: UTF8String): UTF8String; | ||||||
|  |  | ||||||
|  |   function InitGitLibrary(): Integer; | ||||||
|  |   function ShutdownGitLibrary(): Integer; | ||||||
|  |   function CloneRepository(const url, localRepo: UTF8String): Integer; | ||||||
|  |   function CheckoutRepository(const url, localRepo, branchName: UTF8String): Integer; | ||||||
|  |   function CommitFile(const localRepoName, branchName, fName, commitMessage: UTF8String): Integer; | ||||||
|  |  | ||||||
|   // private c-interface |   // private c-interface | ||||||
|   procedure SetReposRootDirectoryInternal(const rootDir: PChar); stdcall; |   procedure SetReposRootDirectoryInternal(const rootDir: PChar); stdcall; | ||||||
|   function GetReposRootDirectoryInternal(): PChar; stdcall; |   function GetReposRootDirectoryInternal(): PChar; stdcall; | ||||||
|   function GetLocalRepositoryPathInternal(const localRepo: PChar): PChar; stdcall; |   function GetLocalRepositoryPathInternal(const localRepo: PChar): PChar; stdcall; | ||||||
|  |   function CloneRepositoryInternal(const url, localRepo: PChar): cint32; stdcall; | ||||||
|  |   function CheckoutRepositoryInternal(const url, localRepo, branchName: PChar): cint32; stdcall; | ||||||
|  |   function CommitFileInternal(const localRepoName, branchName, fName, commitMessage: PChar): cint32; stdcall; | ||||||
|  |   function PushRepositoryInternal(const localRepoName, branchName, user, password: PChar): cint32; stdcall; | ||||||
|  |   function PullRepositoryInternal(const localRepoName, remoteRepoName: PChar): cint32; stdcall; | ||||||
|  |  | ||||||
|  |   function InitGitLibraryInternal: cint32; stdcall; | ||||||
|  |   function ShutdownGitLibraryInternal: cint32; stdcall; | ||||||
|  |  | ||||||
| implementation | implementation | ||||||
|  |  | ||||||
|     const DLLName = 'CalculatorCInterface.dll'; |     const DLLName = 'CalculatorCInterface.dll'; | ||||||
|  |  | ||||||
|  |     function InitGitLibrary(): Integer; | ||||||
|  |     begin | ||||||
|  |         Result := InitGitLibraryInternal(); | ||||||
|  |     end; | ||||||
|  |  | ||||||
|  |     function ShutdownGitLibrary(): Integer; | ||||||
|  |     begin | ||||||
|  |         Result := ShutdownGitLibraryInternal(); | ||||||
|  |     end; | ||||||
|  |  | ||||||
|  |     function CloneRepository(const url, localRepo: UTF8String): Integer; | ||||||
|  |     begin | ||||||
|  |         Result := CloneRepositoryInternal(PChar(Utf8toAnsi(url)), | ||||||
|  |                                           PChar(Utf8toAnsi(localRepo))); | ||||||
|  |     end; | ||||||
|  |  | ||||||
|  |     function CheckoutRepository(const url, localRepo, branchName: UTF8String): Integer; | ||||||
|  |     begin | ||||||
|  |         Result := CheckoutRepositoryInternal(PChar(Utf8toAnsi(url)), | ||||||
|  |                                              PChar(Utf8toAnsi(localRepo)), | ||||||
|  |                                              PChar(Utf8toAnsi(branchName))); | ||||||
|  |     end; | ||||||
|  |  | ||||||
|  |     function CommitFile(const localRepoName, branchName, fName, commitMessage: UTF8String): Integer; | ||||||
|  |     begin | ||||||
|  |         Result := CommitFileInternal(PChar(Utf8toAnsi(localRepoName)), | ||||||
|  |                                      PChar(Utf8toAnsi(branchName)), | ||||||
|  |                                      PChar(Utf8toAnsi(fName)), | ||||||
|  |                                      PChar(Utf8toAnsi(commitMessage))); | ||||||
|  |     end; | ||||||
|  |  | ||||||
|  |     function PushRepository(const localRepoName, branchName, user, password: UTF8String): Integer; | ||||||
|  |     begin | ||||||
|  |         Result := PushRepositoryInternal(PChar(Utf8toAnsi(localRepoName)), | ||||||
|  |                                          PChar(Utf8toAnsi(branchName)), | ||||||
|  |                                          PChar(Utf8toAnsi(user)), | ||||||
|  |                                          PChar(Utf8toAnsi(password))); | ||||||
|  |     end; | ||||||
|  |  | ||||||
|  |     function PullRepository(const localRepoName, remoteRepoName: UTF8String): Integer; | ||||||
|  |     begin | ||||||
|  |         Result := PullRepositoryInternal(PChar(Utf8toAnsi(localRepoName)), | ||||||
|  |                                          PChar(Utf8toAnsi(remoteRepoName))); | ||||||
|  |     end; | ||||||
|  |  | ||||||
|     /// |     /// | ||||||
|     procedure SetReposRootDirectory(const rootDir: UTF8String); |     procedure SetReposRootDirectory(const rootDir: UTF8String); | ||||||
|     begin |     begin | ||||||
| @@ -59,5 +119,26 @@ implementation | |||||||
|     function GetLocalRepositoryPathInternal(const localRepo: PChar): PChar; stdcall; |     function GetLocalRepositoryPathInternal(const localRepo: PChar): PChar; stdcall; | ||||||
|         external DLLName; |         external DLLName; | ||||||
|  |  | ||||||
|  |     function InitGitLibraryInternal: cint32; stdcall; | ||||||
|  |         external DLLName; | ||||||
|  |  | ||||||
|  |     function ShutdownGitLibraryInternal: cint32; stdcall; | ||||||
|  |         external DLLName; | ||||||
|  |  | ||||||
|  |     function CloneRepositoryInternal(const url, localRepo: PChar): cint32; stdcall; | ||||||
|  |         external DLLName; | ||||||
|  |  | ||||||
|  |     function CheckoutRepositoryInternal(const url, localRepo, branchName: PChar): cint32; stdcall; | ||||||
|  |         external DLLName; | ||||||
|  |  | ||||||
|  |     function CommitFileInternal(const localRepoName, branchName, fName, commitMessage: PChar): cint32; stdcall; | ||||||
|  |         external DLLName; | ||||||
|  |  | ||||||
|  |     function PushRepositoryInternal(const localRepoName, branchName, user, password: PChar): cint32; stdcall; | ||||||
|  |         external DLLName; | ||||||
|  |  | ||||||
|  |     function PullRepositoryInternal(const localRepoName, remoteRepoName: PChar): cint32; stdcall; | ||||||
|  |         external DLLName; | ||||||
|  |  | ||||||
| end. | end. | ||||||
|  |  | ||||||
|   | |||||||
| @@ -25,10 +25,10 @@ procedure DeleteTariffCalculator(handle: TariffCalculatorHandle); stdcall; | |||||||
| //function GetFileSize(const localRepository: PChar; const fileId: PChar): cint32; stdcall; | //function GetFileSize(const localRepository: PChar; const fileId: PChar): cint32; stdcall; | ||||||
| //function GetFile(const localRepository: PChar; const fileId: PChar): PChar; stdcall; | //function GetFile(const localRepository: PChar; const fileId: PChar): PChar; stdcall; | ||||||
|  |  | ||||||
| function InitGitLibrary: cint32; stdcall; | //function InitGitLibrary: cint32; stdcall; | ||||||
| function ShutdownGitLibrary: cint32; stdcall; | //function ShutdownGitLibrary: cint32; stdcall; | ||||||
| function CloneRepository(var url; var local_path) : cint32; stdcall; | //function CloneRepository(var url; var local_path) : cint32; stdcall; | ||||||
| function CheckoutLocalBranch(var local_path; var branch_name) : cint32; stdcall; | //function CheckoutLocalBranch(var local_path; var branch_name) : cint32; stdcall; | ||||||
| function CommitFile(var local_path; var branch_name; | function CommitFile(var local_path; var branch_name; | ||||||
|                     var file_name; var comment) : cint32; stdcall; |                     var file_name; var comment) : cint32; stdcall; | ||||||
| function PushLocalRepository(var local_path; var branch_name; | function PushLocalRepository(var local_path; var branch_name; | ||||||
| @@ -86,10 +86,10 @@ procedure DeleteTariffCalculator(handle: TariffCalculatorHandle); stdcall; exter | |||||||
| //                         const json: PChar; | //                         const json: PChar; | ||||||
| //                         size: cint32): cbool; stdcall; external DLLName; | //                         size: cint32): cbool; stdcall; external DLLName; | ||||||
|  |  | ||||||
| function InitGitLibrary: cint32; stdcall; external DLLName; | //function InitGitLibrary: cint32; stdcall; external DLLName; | ||||||
| function ShutdownGitLibrary: cint32; stdcall; external DLLName; | //function ShutdownGitLibrary: cint32; stdcall; external DLLName; | ||||||
| function CloneRepository(var url; var local_path) : cint32; stdcall; external DLLName; | //function CloneRepository(var url; var local_path) : cint32; stdcall; external DLLName; | ||||||
| function CheckoutLocalBranch(var local_path; var branch_name) : cint32; stdcall; external DLLName; | //function CheckoutLocalBranch(var local_path; var branch_name) : cint32; stdcall; external DLLName; | ||||||
| function CommitFile(var local_path; var branch_name; | function CommitFile(var local_path; var branch_name; | ||||||
|                     var file_name; var comment) : cint32; stdcall; external DLLName; |                     var file_name; var comment) : cint32; stdcall; external DLLName; | ||||||
| function PushLocalRepository(var local_path; var branch_name; | function PushLocalRepository(var local_path; var branch_name; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user