Problem beim Übersetzen von C-Header

Anfängerfragen zum Programmieren mit PureBasic.
Benutzeravatar
uweb
Beiträge: 461
Registriert: 13.07.2005 08:39

Problem beim Übersetzen von C-Header

Beitrag von uweb »

Hallo ich versuche gerade einen C-Quellcode nach PB zu übersetzen und brauche schon beim ersten Header eure Hilfe.
Durch den Header Converter stehe ich zwar nicht mehr bei Null - aber immer noch auf dem Schlauch.

>>> 1.

Code: Alles auswählen

typedef struct _DOKAN_FILE_INFO {

	ULONG64	Context;      // FileSystem can use this variable
	ULONG64	DokanContext; // Don't touch this
	ULONG	ProcessId;    // process id for the thread that originally requested a given I/O operation
	BOOL	IsDirectory;  // requesting a directory file

} DOKAN_FILE_INFO, *PDOKAN_FILE_INFO;
wurdo so konvertiert :

Code: Alles auswählen

Structure DOKAN_FILE_INFO
  Context.ULONG64
  DokanContext.ULONG64
  ProcessId.ULONG 
  IsDirectory.BOOL
EndStructure
Ist das schon komplett?
Ich habe nur Infos zu "typedef struct {...} NAME;" gefunden.


>>>2.

Code: Alles auswählen

typedef int (WINAPI *PFillFindData) (PWIN32_FIND_DATAW, PDOKAN_FILE_INFO);
wurde gar nicht konvertiert.


>>>3.

Code: Alles auswählen

typedef struct _DOKAN_OPERATIONS {

	// When an error occurs, return negative value.
	// Usually you should return GetLastError() * -1.


	// CreateFile
	//   If file is a directory, CreateFile (not OpenDirectory) may be called.
	//   In this case, CreateFile should return 0 when that directory can be opened.
	//   You should set TRUE on DokanFileInfo->IsDirectory when file is a directory.
	//   When CreationDisposition is CREATE_ALWAYS or OPEN_ALWAYS and a file already exists,
	//   you should return ERROR_ALREADY_EXISTS(183) (not negative value)
	int (DOKAN_CALLBACK *CreateFile) (
		LPCWSTR,      // FileName
		DWORD,        // DesiredAccess
		DWORD,        // ShareMode
		DWORD,        // CreationDisposition
		DWORD,        // FlagsAndAttributes
		//HANDLE,       // TemplateFile
		PDOKAN_FILE_INFO);

	int (DOKAN_CALLBACK *OpenDirectory) (
		LPCWSTR,				// FileName
		PDOKAN_FILE_INFO);

	int (DOKAN_CALLBACK *CreateDirectory) (
		LPCWSTR,				// FileName
		PDOKAN_FILE_INFO);

	int (DOKAN_CALLBACK *Cleanup) (
		LPCWSTR,      // FileName
		PDOKAN_FILE_INFO);

	int (DOKAN_CALLBACK *CloseFile) (
		LPCWSTR,      // FileName
		PDOKAN_FILE_INFO);

	int (DOKAN_CALLBACK *ReadFile) (
		LPCWSTR,  // FileName
		LPVOID,   // Buffer
		DWORD,    // NumberOfBytesToRead
		LPDWORD,  // NumberOfBytesRead
		LONGLONG, // Offset
		PDOKAN_FILE_INFO);
	

	int (DOKAN_CALLBACK *WriteFile) (
		LPCWSTR,  // FileName
		LPCVOID,  // Buffer
		DWORD,    // NumberOfBytesToWrite
		LPDWORD,  // NumberOfBytesWritten
		LONGLONG, // Offset
		PDOKAN_FILE_INFO);


	int (DOKAN_CALLBACK *FlushFileBuffers) (
		LPCWSTR, // FileName
		PDOKAN_FILE_INFO);


	int (DOKAN_CALLBACK *GetFileInformation) (
		LPCWSTR,          // FileName
		LPBY_HANDLE_FILE_INFORMATION, // Buffer
		PDOKAN_FILE_INFO);
	

	int (DOKAN_CALLBACK *FindFiles) (
		LPCWSTR,			// PathName
		PFillFindData,		// call this function with PWIN32_FIND_DATAW
		PDOKAN_FILE_INFO);  //  (see PFillFindData definition)


	// You should implement either FindFires or FindFilesWithPattern
	int (DOKAN_CALLBACK *FindFilesWithPattern) (
		LPCWSTR,			// PathName
		LPCWSTR,			// SearchPattern
		PFillFindData,		// call this function with PWIN32_FIND_DATAW
		PDOKAN_FILE_INFO);


	int (DOKAN_CALLBACK *SetFileAttributes) (
		LPCWSTR, // FileName
		DWORD,   // FileAttributes
		PDOKAN_FILE_INFO);


	int (DOKAN_CALLBACK *SetFileTime) (
		LPCWSTR,		// FileName
		CONST FILETIME*, // CreationTime
		CONST FILETIME*, // LastAccessTime
		CONST FILETIME*, // LastWriteTime
		PDOKAN_FILE_INFO);

	int (DOKAN_CALLBACK *DeleteFile) (
		LPCWSTR, // FileName
		PDOKAN_FILE_INFO);


	int (DOKAN_CALLBACK *DeleteDirectory) ( 
		LPCWSTR, // FileName
		PDOKAN_FILE_INFO);


	int (DOKAN_CALLBACK *MoveFile) (
		LPCWSTR, // ExistingFileName
		LPCWSTR, // NewFileName
		BOOL,	// ReplaceExisiting
		PDOKAN_FILE_INFO);


	int (DOKAN_CALLBACK *SetEndOfFile) (
		LPCWSTR,  // FileName
		LONGLONG, // Length
		PDOKAN_FILE_INFO);


	int (DOKAN_CALLBACK *LockFile) (
		LPCWSTR, // FileName
		LONGLONG, // ByteOffset
		LONGLONG, // Length
		PDOKAN_FILE_INFO);


	int (DOKAN_CALLBACK *UnlockFile) (
		LPCWSTR, // FileName
		LONGLONG,// ByteOffset
		LONGLONG,// Length
		PDOKAN_FILE_INFO);


	// Neither GetDiskFreeSpace nor GetVolumeInformation
	// save the DokanFileContext->Context.
	// Before these methods are called, CreateFile may not be called.
	// (ditto CloseFile and Cleanup)

	// see Win32 API GetDiskFreeSpaceEx
	int (DOKAN_CALLBACK *GetDiskFreeSpace) (
		PULONGLONG, // FreeBytesAvailable
		PULONGLONG, // TotalNumberOfBytes
		PULONGLONG, // TotalNumberOfFreeBytes
		PDOKAN_FILE_INFO);


	// see Win32 API GetVolumeInformation
	int (DOKAN_CALLBACK *GetVolumeInformation) (
		LPWSTR, // VolumeNameBuffer
		DWORD,	// VolumeNameSize
		LPDWORD,// VolumeSerialNumber
		LPDWORD,// MaximumComponentLength
		LPDWORD,// FileSystemFlags
		LPWSTR,	// FileSystemNameBuffer
		DWORD,	// FileSystemNameSize
		PDOKAN_FILE_INFO);


	int (DOKAN_CALLBACK *Unmount) (
		PDOKAN_FILE_INFO);

} DOKAN_OPERATIONS, *PDOKAN_OPERATIONS;
ergab nur :

Code: Alles auswählen

Structure DOKAN_OPERATIONS
EndStructure
auch damit kann ich überhaupt nichts anfangen.

Eine Übersetzung wäre natürlich toll. Ich bin aber auch für jeden Tipp wie der C-Code zu interpretieren ist dankbar.
Benutzeravatar
ts-soft
Beiträge: 22292
Registriert: 08.09.2004 00:57
Computerausstattung: Mainboard: MSI 970A-G43
CPU: AMD FX-6300 Six-Core Processor
GraKa: GeForce GTX 750 Ti, 2 GB
Memory: 16 GB DDR3-1600 - Dual Channel
Wohnort: Berlin

Beitrag von ts-soft »

In etwa so:

Code: Alles auswählen

Structure DOKAN_FILE_INFO
  Context.q
  DokanContext.q
  ProcessId.l
  IsDirectory.l
EndStructure

Prototype protoCreateFile(lpCWStr.p-unicode, DesiredAccess.l, ShareMode.l, CreationDisposition.l, FlagsAndAttribute.l, *Handle.DOKAN_FILE_INFO)
Prototype protoOpenDirectory(lpCWStr.p-unicode, *Handle.DOKAN_FILE_INFO)
Prototype protoCreateDirectory(lpCWStr.p-unicode, *Handle.DOKAN_FILE_INFO)
; usw.

Structure DOKAN_OPERATIONS
  CreateFile.protoCreateFile
  OpenDirectory.protoOpenDirectory
  CreateDirectory.protoCreateDirectory
  ; usw.
EndStructure
Statt dem Pseudotyp p-unicode evtl. einen pointer nehmen, aber der
string wird als unicode-string erwartet.

Ob Prototype oder PrototypeC mußte nachsehen oder testen.

Für Richtigkeit wird keine Haftung übernommen :mrgreen:
PureBasic 5.73 LTS | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Nutella hat nur sehr wenig Vitamine. Deswegen muss man davon relativ viel essen.
Bild
Benutzeravatar
uweb
Beiträge: 461
Registriert: 13.07.2005 08:39

Beitrag von uweb »

Danke Thomas !
Das hätte ich alleine wohl nicht hinbekommen.
Ich werde mich heute abend gleich wieder dran machen.
Mir graut schon vor dem Rest. Da ich das Teil
(mirror.c - http://dokan-dev.net/en/docs/dokan-readme/)
mit der VC++ Express Edition und DevC++ nicht kompiliert bekomme
muß ich wohl erst den ganzen Code komplett übersetzen bevor ich irgend etwas testen kann.
Benutzeravatar
uweb
Beiträge: 461
Registriert: 13.07.2005 08:39

Beitrag von uweb »

So ganz langsam komme ich voran.

Code: Alles auswählen

typedef int (WINAPI *PFillFindData) (PWIN32_FIND_DATAW, PDOKAN_FILE_INFO);
ist mir aber immer noch nicht ganz klar.
Ich habe zwar mittlerweile herausgefunden, daß durch

Code: Alles auswählen

typedef Int(*Fzeiger)(double);
Fzeiger als Typ Zeiger auf eine Funktion mit Parameter double und Resultat int definiert wird.
Die Bedeutung von "WINAPI *PFillFindData" ist mir aber noch nicht klar.

edit

Im Moment habe ich es als

Code: Alles auswählen

Prototype protoPFillFindData( *Handle.PWIN32_FIND_DATAW, *Handle.DOKAN_FILE_INFO)
übersetzt. Ich werde aber das Gefühl nicht los, daß "WINAPI" oder "DOKAN_CALLBACK" Informationen sind die gebraucht werden.

Außer dem bin ich mir z.B. auch bei

Code: Alles auswählen

Int (DOKAN_CALLBACK *ReadFile) (
		LPCWSTR,  // FileName
		LPVOID,   // Buffer
		DWORD,    // NumberOfBytesToRead
		LPDWORD,  // NumberOfBytesRead
		LONGLONG, // Offset
		PDOKAN_FILE_INFO);
...
	Int (DOKAN_CALLBACK *GetFileInformation) (
		LPCWSTR,          // FileName
		LPBY_HANDLE_FILE_INFORMATION, // Buffer
		PDOKAN_FILE_INFO);
unsicher.
Ich habe das im Moment mal als

Code: Alles auswählen

Prototype protoReadFile(lpCWStr.p-unicode, *Buffer, NumberOfBytesToRead.l, *NumberOfBytesRead.l, Offset.d, *Handle.DOKAN_FILE_INFO)
...
Prototype protoGetFileInformation(lpCWStr.p-unicode, *Handle.DOKAN_FILE_INFO)
stehen.
Antworten