actually loading and running some libgit2 code

This commit is contained in:
Scott Chacon
2010-05-24 17:09:32 -07:00
parent 89c86150c8
commit d76f1e87f2
4 changed files with 19 additions and 9 deletions

3
.gitignore vendored Normal file
View File

@@ -0,0 +1,3 @@
*.beam
*.so
*.o

View File

@@ -4,6 +4,8 @@ INCLUDES = -I$(OTPROOT)/erts/emulator/beam/
# OS X flags.
GCCFLAGS = -O3 -fPIC -bundle -flat_namespace -undefined suppress -fno-common -Wall -m32
LIBS = -lz -lgit2
# Linux Flags
#GCCFLAGS = -O3 -fPIC -shared -fno-common -Wall

10
geef.c
View File

@@ -1,4 +1,8 @@
#include "erl_nif.h"
#include <stdio.h>
#include <git/common.h>
#include <git/oid.h>
static int
load(ErlNifEnv* env, void** priv, ERL_NIF_TERM load_info)
@@ -28,6 +32,12 @@ unload(ErlNifEnv* env, void* priv)
static ERL_NIF_TERM
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;
if(!enif_get_ulong(env, a1, &val)) {
return enif_make_badarg(env);

13
test
View File

@@ -3,18 +3,13 @@
%%! debug verbose -noshell
main([Object]) ->
try
geef:start(),
Test = geef:object_exists(4),
io:format("factorial ~s:~w~n", [Object, Test])
catch
_:_ ->
usage()
end;
geef:start(),
Test = geef:object_exists(4),
io:format("exists ~s:~w~n", [Object, Test]);
main(_) ->
usage().
usage() ->
io:format("usage: factorial integer\n"),
io:format("usage: ./test SHA\n"),
halt(1).