actually loading and running some libgit2 code
This commit is contained in:
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
*.beam
|
||||||
|
*.so
|
||||||
|
*.o
|
||||||
2
Makefile
2
Makefile
@@ -4,6 +4,8 @@ INCLUDES = -I$(OTPROOT)/erts/emulator/beam/
|
|||||||
# OS X flags.
|
# OS X flags.
|
||||||
GCCFLAGS = -O3 -fPIC -bundle -flat_namespace -undefined suppress -fno-common -Wall -m32
|
GCCFLAGS = -O3 -fPIC -bundle -flat_namespace -undefined suppress -fno-common -Wall -m32
|
||||||
|
|
||||||
|
LIBS = -lz -lgit2
|
||||||
|
|
||||||
# Linux Flags
|
# Linux Flags
|
||||||
#GCCFLAGS = -O3 -fPIC -shared -fno-common -Wall
|
#GCCFLAGS = -O3 -fPIC -shared -fno-common -Wall
|
||||||
|
|
||||||
|
|||||||
10
geef.c
10
geef.c
@@ -1,4 +1,8 @@
|
|||||||
#include "erl_nif.h"
|
#include "erl_nif.h"
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <git/common.h>
|
||||||
|
#include <git/oid.h>
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
load(ErlNifEnv* env, void** priv, ERL_NIF_TERM load_info)
|
load(ErlNifEnv* env, void** priv, ERL_NIF_TERM load_info)
|
||||||
@@ -28,6 +32,12 @@ unload(ErlNifEnv* env, void* priv)
|
|||||||
static ERL_NIF_TERM
|
static ERL_NIF_TERM
|
||||||
object_exists(ErlNifEnv* env, ERL_NIF_TERM a1)
|
object_exists(ErlNifEnv* env, ERL_NIF_TERM a1)
|
||||||
{
|
{
|
||||||
|
git_oid oid;
|
||||||
|
static char *sha = "ce08fe4884650f067bd5703b6a59a8b3b3c99a09";
|
||||||
|
printf("sha: %s\n", sha);
|
||||||
|
git_oid_mkstr(&oid, sha);
|
||||||
|
//printf("raw: %s", (&oid)->id);
|
||||||
|
|
||||||
unsigned long val;
|
unsigned long val;
|
||||||
if(!enif_get_ulong(env, a1, &val)) {
|
if(!enif_get_ulong(env, a1, &val)) {
|
||||||
return enif_make_badarg(env);
|
return enif_make_badarg(env);
|
||||||
|
|||||||
9
test
9
test
@@ -3,18 +3,13 @@
|
|||||||
%%! debug verbose -noshell
|
%%! debug verbose -noshell
|
||||||
|
|
||||||
main([Object]) ->
|
main([Object]) ->
|
||||||
try
|
|
||||||
geef:start(),
|
geef:start(),
|
||||||
Test = geef:object_exists(4),
|
Test = geef:object_exists(4),
|
||||||
io:format("factorial ~s:~w~n", [Object, Test])
|
io:format("exists ~s:~w~n", [Object, Test]);
|
||||||
catch
|
|
||||||
_:_ ->
|
|
||||||
usage()
|
|
||||||
end;
|
|
||||||
main(_) ->
|
main(_) ->
|
||||||
usage().
|
usage().
|
||||||
|
|
||||||
usage() ->
|
usage() ->
|
||||||
io:format("usage: factorial integer\n"),
|
io:format("usage: ./test SHA\n"),
|
||||||
halt(1).
|
halt(1).
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user