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.
|
||||
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
10
geef.c
@@ -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
13
test
@@ -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).
|
||||
|
||||
|
||||
Reference in New Issue
Block a user