Data update
This commit is contained in:
parent
81fd053722
commit
52a6ef48dd
10248 changed files with 63654 additions and 6775 deletions
|
|
@ -0,0 +1,16 @@
|
|||
#include "crt.bi"
|
||||
|
||||
Extern "C"
|
||||
Function Query (Byval dato As zstring Ptr, Byval longitud As size_t Ptr) As Integer Export
|
||||
Dim As String message = "Here am I"
|
||||
Dim As size_t message_length = Len(message)
|
||||
|
||||
If *longitud < message_length Then
|
||||
Return 0
|
||||
Else
|
||||
memcpy(dato, Strptr(message), message_length)
|
||||
*longitud = message_length
|
||||
Return 1
|
||||
End If
|
||||
End Function
|
||||
End Extern
|
||||
|
|
@ -0,0 +1,53 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#else
|
||||
#include <dlfcn.h>
|
||||
#endif
|
||||
|
||||
typedef int (*QueryFunc)(char *, size_t *);
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
char Buffer[1024];
|
||||
size_t Size = sizeof(Buffer);
|
||||
|
||||
#ifdef _WIN32
|
||||
HMODULE hLib = LoadLibrary("libquery.dll");
|
||||
if (!hLib) {
|
||||
printf("failed to load library\n");
|
||||
return 1;
|
||||
}
|
||||
QueryFunc Query = (QueryFunc)GetProcAddress(hLib, "Query");
|
||||
#else
|
||||
void *hLib = dlopen("./libquery.so", RTLD_LAZY);
|
||||
if (!hLib) {
|
||||
printf("failed to load library\n");
|
||||
return 1;
|
||||
}
|
||||
QueryFunc Query = (QueryFunc)dlsym(hLib, "Query");
|
||||
#endif
|
||||
|
||||
if (!Query) {
|
||||
printf("failed to find Query function\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (0 == Query(Buffer, &Size)) {
|
||||
printf("failed to call Query\n");
|
||||
} else {
|
||||
char *Ptr = Buffer;
|
||||
while (Size-- > 0) putchar(*Ptr++);
|
||||
putchar('\n');
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
FreeLibrary(hLib);
|
||||
#else
|
||||
dlclose(hLib);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue