Page 2 of 2
					
				
				Posted: Fri May 20, 2005 5:34 am
				by Hatonastick
				PS this is not the problem:
#define PBINT extern int _stdcall
#define PBLONG extern long32 _stdcall
#define PBSTRING extern char _stdcall *
#define PBFLOAT extern float _stdcall
I had to reverse the order of "extern value" and "_stdcall" with the LccWin example for Pelles C to handle it as well.  Under Lcc it is apparently: "extern _stdcall int".
I think I need more sleep.  :roll:
			 
			
					
				
				Posted: Fri May 20, 2005 5:38 am
				by Hatonastick
				The PureCrypt.Desc file:
Code: Select all
;
; Langage used to code the library: ASM or C
C
;
; Number of windows DLLs our library needs.
; This is used to tell the PureBasic compiler /
; linker which libraries are needed to link with.
1
crtmt 
;
; Library type (Can be OBJ or LIB).
LIB
;
; Number of PureBasic libraries needed by your library.
; (additional PureBasic libraries that are needed for linking).
0
;
; Help directory name.
Extension1
;
; Library functions (FunctionName, Arg1, Arg2, ...);
; First the function name. Its the name of the C function
; that should be exported to PB, without the "PB_" Prefix
; used in C. After function name a comma and a list of
; arguments seperated by comma aswell. in parentheses
; a argument description that is showed by the PureBasic IDE
; as quick help. After the parentheses a general description
; can follow.
;
; Translation table for some arguments:
; ANSI C         | PureBasic
; --------------------------
; int *          |  Long
; byte *         |  Long
; int  (32 bits) |  Long
; char *         |  Long / String
; long (32 bits) |  Long
; float          |  Float
; double         |    -  (must be casted to float in C for now)
; char           |  Byte
; void           |  None
; short(16 bits) |  Word
;
; Return value:
; Type of return value and flags for:
; 'InitFunction' (a function which is called automatically
; at the start of a PureBasic program),
; 'EndFunction' (called at the end, for cleaning)
; and 'DebuggerCheck' (a debugger handler function for this command.)
;Long | DebuggerCheck
SHA1Hash, Long, Long, Long ([in] *buffer, [in] length, [out] *result) - Returns 20 byte hash.
Long | DebuggerCheck
The purebasic test program:
Code: Select all
; Attempt to use SHA1Hash.
InBuffer$  = "foo"
Length     = Len(InBuffer$)
OutBuffer$ = Space(21)
Debug SHA1Hash(@InBuffer$, Length, @OutBuffer$)
Debug OutBuffer$
I've officially run out of ideas.  

 
			 
			
					
				
				Posted: Fri May 20, 2005 8:06 am
				by traumatic
				Ok, no more unresolved external symbols here.
It's "crtmt2" you need, not "crtmt". I guessed wrong there.
You'll still get some fun when you turn off PB's debugger because you wrote:
Code: Select all
extern char *PB_DEBUGGER_ErrorDescription;
extern HWND    PB_DEBUGGER_Window;
extern int    PB_DEBUGGER_Control;
These aren't defined without the debugger.
Better split the _DEBUG functions into their own .obj.
(Smaller size and less hassle).
Have fun! 

 
			 
			
					
				
				Posted: Fri May 20, 2005 8:47 am
				by Hatonastick
				Ok it didn't work, then it worked.  I suspect rather strongly some sort of minor bug with Pelles C: I changed a number of options, compiled, failed, changed them all back, recompiled and it worked.  Almost as if the object files weren't being updated properly. 
Anyway I thank you all for your help!  You've help prevent my being interned within a Mental Asylum. 

  It works. 
However I have one last request: I still need advice/help on the best way to use PB_memoryBase to pass data from my library functions to PureBASIC.  A small example in C on how to do this would be greatly appreciated.  Once I have that worked out, I should be pretty much ok.
 
			 
			
					
				
				Posted: Fri May 20, 2005 9:01 am
				by traumatic
				Nah, no bug in PellesC...
...maybe you changed this flag?
options -> compiler -> calling convention -> __cdecl
			 
			
					
				
				Posted: Fri May 20, 2005 9:18 am
				by Hatonastick
				Yup that was it...  Just realised.  

  *sigh*  Thanks again.
 
			 
			
					
				
				Posted: Fri May 20, 2005 9:39 am
				by traumatic
				np, glad it works!  

 
			 
			
					
				
				Posted: Sat Mar 25, 2006 10:08 am
				by Seldon
				Does someone have this working LIB for SHA1 ?? Thank you in advance.
			 
			
					
				
				Posted: Thu Dec 14, 2006 10:11 pm
				by DoubleDutch
				Any news on this lib?