Initial data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 72d218235f
commit f23f22d71c
199087 changed files with 3378941 additions and 0 deletions

View file

@ -0,0 +1,2 @@
:- module(plffi, [strdup/2]).
:- use_foreign_library(plffi).

View file

@ -0,0 +1,20 @@
#include <string.h>
#include <stdio.h>
#include <SWI-Prolog.h>
static foreign_t pl_strdup(term_t string0, term_t string1)
{
char *input_string, *output_string;
if (PL_get_atom_chars(string0, &input_string))
{
output_string = strdup(input_string);
return PL_unify_atom_chars(string1, output_string);
}
PL_fail;
}
install_t install_plffi()
{
PL_register_foreign("strdup", 2, pl_strdup, 0);
}

View file

@ -0,0 +1 @@
$ swipl-ld -o plffi -shared plffi.c

View file

@ -0,0 +1,15 @@
?- [plffi].
% plffi compiled into plffi 0.04 sec, 1,477 clauses
true.
?- strdup('Booger!', X).
X = 'Booger!'.
?- strdup(booger, X).
X = booger.
?- strdup(booger, booger).
true.
?- X = booger, strdup(booger, X).
X = booger.