Plug-In Approach ...
Posted: Mon Apr 02, 2012 5:59 pm
Hi board,
I found a small Plug-In-source-code on my hard drive, which I hacked together sometime last year (or so).
Used it in one of my Apps, and am going to use it again...
Have fun. It's not documented, but you will get the point, the second you read it.
Tested on Mac OS X 10.6 and 10.7. Works great
If you add functions, or improve something, please answer here.
Don't forget to edit the path to lib.so, as there is no check in the Demo!
First part, save as lib.pb and compile to lib.so.
Demo, compiles to testlib.app
I found a small Plug-In-source-code on my hard drive, which I hacked together sometime last year (or so).
Used it in one of my Apps, and am going to use it again...
Have fun. It's not documented, but you will get the point, the second you read it.
Tested on Mac OS X 10.6 and 10.7. Works great

If you add functions, or improve something, please answer here.
Don't forget to edit the path to lib.so, as there is no check in the Demo!
First part, save as lib.pb and compile to lib.so.
Code: Select all
; Small static-library, tested on Mac OS X 10.7
; (c) 2012, Jamirokwai / quadWorks
; Use at your own risk, change it, give back. If you use and like, please give credit.
Global *Dest
Global *Source
ProcedureCDLL.s DoMagic(Text.s,Count.i)
Temp.s = Text
For i = 0 To Count
Temp + " - " + Text
Next i
ProcedureReturn
EndProcedure
ProcedureCDLL.i GetIcon()
ProcedureReturn ?Icon
EndProcedure
ProcedureCDLL.s GetName()
Text$ = PeekS(?Name)
ProcedureReturn Text$
EndProcedure
ProcedureCDLL.s GetCopyright()
Text$ = PeekS(?Copy)
ProcedureReturn Text$
EndProcedure
ProcedureCDLL.s GetDesc()
Text$ = PeekS(?Desc)
ProcedureReturn Text$
EndProcedure
ProcedureCDLL.s GetCreator()
Text$ = PeekS(?Crea)
ProcedureReturn Text$
EndProcedure
ProcedureCDLL.s GetVersion()
Text$ = PeekS(?Vers)
ProcedureReturn Text$
EndProcedure
ProcedureCDLL Init()
*Dest = AllocateMemory(1024)
*Source = AllocateMemory(1024)
EndProcedure
ProcedureCDLL DeInit()
If *Dest
FreeMemory(*Dest)
EndIf
If *Source
FreeMemory(*Source)
EndIf
EndProcedure
DataSection
Name: Data.s "Test-Plug-In"
Vers: Data.s "1.0.0"
Desc: Data.s "Just a Test-Plug-In"
Copy: Data.s "(c,p) 2010-2012 quadWorks"
Crea: Data.s "quadWorks"
Icon:
; size : 329 bytes - made with Bin2Data
Data.q $0A1A0A0D474E5089,$524448490D000000,$1000000010000000,$0F2D280000000308,$4D41670400000053
Data.q $DAB2DC04D9000041,$544C507E00000002,$F8F0F8F8FFFFFF45,$F0F0E8F0F0F0F0F0,$E0D8F0E8E0F0E8E8
Data.q $C8F0D8D0F8D8D0F0,$F0D0C0F0D0C8F0D8,$C0B0F0C8B8F0C8C0,$98F0B8A0F8B8A0F0,$F8A888F8B098F8B8
Data.q $9878F8A078F8A080,$68F89870787878F8,$F88858F89060F890,$3840F88048F88050,$28F86830F8703838
Data.q $F86020F86028F868,$5010F85818F86018,$A5F84808F85008F8,$49760000002EAD7F,$518F949C78544144
Data.q $1825EF840830800B,$0F658311C0C462C1,$EA0832D83FFFFDD2,$2B44F453F07D0EA9,$2B033E543C14350F
Data.q $55621A60E8B00CC8,$E66CDD509F40D318,$43BD0B039B4965C8,$E840AF413D7349B1,$4C210884D74B415E
Data.q $F7310D99041D1958,$65F847DBE59F72E5,$0000719E576FDFDD,$0C9B0C0003FFFF00,$0000007E4B7209FD
Data.q $6042AE444E454900
Data.b $82
EndDataSection
Code: Select all
; Small static-library-demo, tested on Mac OS X 10.7
; (c) 2012, Jamirokwai / quadWorks
; Use at your own risk, change it, give back. If you use and like, please give credit.
Structure PlugIn_Struct
Handle.l ; Handle, for function
Init.l ; DLL init
Exit.l ; DLL Clean up
GetIcon.l ; Get Icon (PNG, BMP, JPG, etc.)
GetName.l ; Name of Plug-In
GetVersion.l ; Version of Plugin
GetCopyright.l ; Copyright
GetDesc.l ; Description
GetCreator.l ; Name of Creator
DoMagic.l ; Function to call
EndStructure
Global PlugIn.PlugIn_Struct
Procedure OpenPlugin(FileName$)
With PlugIn
\Handle = OpenLibrary(#PB_Any, FileName$)
\Init = GetFunction(\Handle,"Init")
\Exit = GetFunction(\Handle,"DeInit")
\GetIcon = GetFunction(\Handle,"GetIcon")
\GetName = GetFunction(\Handle,"GetName")
\GetCopyright = GetFunction(\Handle,"GetCopyright")
\GetDesc = GetFunction(\Handle,"GetDesc")
\GetCreator = GetFunction(\Handle,"GetCreator")
\GetVersion = GetFunction(\Handle,"GetVersion")
EndWith
EndProcedure
Procedure.s GetName()
ProcedureReturn PeekS(CallCFunctionFast(PlugIn\GetName))
EndProcedure
Procedure.s GetCopyright()
ProcedureReturn PeekS(CallCFunctionFast(PlugIn\GetCopyright))
EndProcedure
Procedure.s GetDesc()
ProcedureReturn PeekS(CallCFunctionFast(PlugIn\GetDesc))
EndProcedure
Procedure.s GetVersion()
ProcedureReturn PeekS(CallCFunctionFast(PlugIn\GetVersion))
EndProcedure
Procedure.s GetCreator()
ProcedureReturn PeekS(CallCFunctionFast(PlugIn\GetCreator))
EndProcedure
UsePNGImageDecoder()
UsePNGImageEncoder()
OpenPlugin("lib.so") ; Check, if Handle is <> 0! and set correct folder
CallCFunctionFast(PlugIn\Init)
*Ziel = CallCFunctionFast(PlugIn\GetIcon)
CatchImage(0,*Ziel)
SaveImage(0,"output.png",#PB_ImagePlugin_PNG)
Debug GetName()
Debug GetCreator()
Debug GetDesc()
Debug GetCopyright()
Debug GetVersion()
CallCFunctionFast(PlugIn\Exit)