LibraryMaker Desc file.

Just starting out? Need help? Post your questions and find answers here.
Hatonastick
Enthusiast
Enthusiast
Posts: 149
Joined: Wed Apr 27, 2005 11:50 am
Location: Adelaide, Australia
Contact:

Post 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:
Hatonastick
Enthusiast
Enthusiast
Posts: 149
Joined: Wed Apr 27, 2005 11:50 am
Location: Adelaide, Australia
Contact:

Post 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. :(
traumatic
PureBasic Expert
PureBasic Expert
Posts: 1661
Joined: Sun Apr 27, 2003 4:41 pm
Location: Germany
Contact:

Post 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! :)
Good programmers don't comment their code. It was hard to write, should be hard to read.
Hatonastick
Enthusiast
Enthusiast
Posts: 149
Joined: Wed Apr 27, 2005 11:50 am
Location: Adelaide, Australia
Contact:

Post 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.
Last edited by Hatonastick on Fri May 20, 2005 9:17 am, edited 1 time in total.
traumatic
PureBasic Expert
PureBasic Expert
Posts: 1661
Joined: Sun Apr 27, 2003 4:41 pm
Location: Germany
Contact:

Post by traumatic »

Nah, no bug in PellesC...
...maybe you changed this flag?

options -> compiler -> calling convention -> __cdecl
Good programmers don't comment their code. It was hard to write, should be hard to read.
Hatonastick
Enthusiast
Enthusiast
Posts: 149
Joined: Wed Apr 27, 2005 11:50 am
Location: Adelaide, Australia
Contact:

Post by Hatonastick »

Yup that was it... Just realised. :oops: *sigh* Thanks again.
traumatic
PureBasic Expert
PureBasic Expert
Posts: 1661
Joined: Sun Apr 27, 2003 4:41 pm
Location: Germany
Contact:

Post by traumatic »

np, glad it works! :)
Good programmers don't comment their code. It was hard to write, should be hard to read.
Seldon
Enthusiast
Enthusiast
Posts: 405
Joined: Fri Aug 22, 2003 7:12 am
Location: Italia

Post by Seldon »

Does someone have this working LIB for SHA1 ?? Thank you in advance.
User avatar
DoubleDutch
Addict
Addict
Posts: 3220
Joined: Thu Aug 07, 2003 7:01 pm
Location: United Kingdom
Contact:

Post by DoubleDutch »

Any news on this lib?
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
Post Reply