Front Range PHP NoSQL Databases
View more presentations from Jon Meredith.
The place where I put things I'm sure I'll forget.
svn co http://svn.php.net/repository --depth empty phpdoc
svn co http://svn.php.net/repository/phpdoc/en/trunk --depth infinity phpdoc/en
svn co http://svn.php.net/repository/phpdoc/doc-base/trunk --depth infinity phpdoc/doc-base
sudo port install php5-sqlite +debug
sudo pear install doc.php.net/phd-beta
/path/to/svn/phpdoc/php -d debug_mode=1 -d extension_dir=modules/ -d extension=myext.so /Users/jmeredith/src/php/phpdoc/doc-base/scripts/docgen/docgen.php --output tmp --extension myext
cp -rp tmp /Users/jmeredith/src/php/phpdoc/en/reference/myext
&reference.magneto.book;
phd -d /Users/jmeredith/src/php/phpdoc/doc-base/.manual.book.myext.xml
Erlang R13B03 (erts-5.7.4) [source] [64-bit] [smp:2:2] [rq:2] [async-threads:0] [kernel-poll:false]
Eshell V5.7.4 (abort with ^G)
1> sniffer:start().
ok
2> B= <<"abc">>.
<<"abc">>
3> process_info(self(), binary).
{binary,[{4303709336,3,3}]}
4> sniffer:get_binary(4303709336).
<<"abc">>
// sniffer.c
#include
#include
#include "erl_nif.h"
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "sys.h"
#include "erl_vm.h"
#include "global.h"
static int
load(ErlNifEnv* env, void** priv, ERL_NIF_TERM load_info)
{
return 0;
}
static int
reload(ErlNifEnv* env, void** priv, ERL_NIF_TERM load_info)
{
return 0;
}
static int
upgrade(ErlNifEnv* env, void** priv, void** old_priv,
ERL_NIF_TERM load_info)
{
return 0;
}
static void
unload(ErlNifEnv* env, void* priv)
{
return;
}
static ERL_NIF_TERM
get_binary(ErlNifEnv* env, ERL_NIF_TERM a1)
{
unsigned long mem_loc;
if (!enif_get_ulong(env, a1, &mem_loc))
{
return enif_make_badarg(env);
}
else
{
Binary* bin_ptr = (Binary*) mem_loc;
ErlNifBinary nif_bin;
enif_alloc_binary(env, bin_ptr->orig_size, &nif_bin);
memcpy(nif_bin.data, bin_ptr->orig_bytes, bin_ptr->orig_size);
return enif_make_binary(env, &nif_bin);
}
}
static ErlNifFunc sniffer_funcs[] =
{
{"get_binary", 1, get_binary}
};
ERL_NIF_INIT(sniffer, sniffer_funcs, load, reload, upgrade, unload)
%% sniffer.erl
-module(sniffer).
-export([start/0, get_binary/1]).
start() ->
erlang:load_nif("sniffer", 0).
get_binary(_Val) ->
nif_error(?LINE).
nif_error(Line) ->
exit({nif_not_loaded,module,?MODULE,line,Line}).
# Makefile
ERL_TOP=/Users/jmeredith/git/erlang0d
include $(ERL_TOP)/make/target.mk
INCLUDES = \
-I$(ERL_TOP)/erts/$(TARGET) \
-I$(ERL_TOP)/erts/emulator/$(TARGET) \
-I$(ERL_TOP)/erts/emulator/$(TARGET)/opt/smp \
-I$(ERL_TOP)/erts/emulator/beam/ \
-I$(ERL_TOP)/erts/emulator/sys/unix \
-I$(ERL_TOP)/erts/include/$(TARGET) \
-I$(ERL_TOP)/erts/include/internal \
-no-cpp-precomp -DHAVE_CONFIG_H
# OS X Snow Leopard flags.
GCCFLAGS = -m64 -O3 -fPIC -bundle -flat_namespace -undefined suppress -fno-common -Wall
# Linux Flags
#GCCFLAGS = -O3 -fPIC -shared -fno-common -Wall
CFLAGS = $(GCCFLAGS) $(INCLUDES)
LDFLAGS = $(GCCFLAGS) $(LIBS)
OBJECTS = sniffer.o
DRIVER = sniffer.so
BEAM = sniffer.beam
all: $(DRIVER) $(BEAM)
clean:
rm -f *.o *.beam $(DRIVER)
$(DRIVER): $(OBJECTS)
gcc -o $@ $^ $(LDFLAGS)
$(BEAM): sniffer.erl
erlc $^
jons-macpro:protobuf-2.1.0 jmeredith$ cat BUILDIT
ARCH='-arch i386 -arch x86_64'
./configure --prefix=/Users/jmeredith/Applications/protobuf CFLAGS="$ARCH" CXXFLAGS="$ARCH" --disable-dependency-tracking && \
make && \
make install
jons-macpro:protobuf-c-0.11 jmeredith$ cat BUILDIT
## Make sure protoc is in your path or this will die
ARCH="-arch i386 -arch x86_64"
./configure --prefix=/Users/jmeredith/Applications/protobuf-c \
CXXFLAGS="-I/Users/jmeredith/Applications/protobuf/include $ARCH" \
CFLAGS="$ARCH" \
LDFLAGS="-L/Users/jmeredith/Applications/protobuf/lib" \
--disable-dependency-tracking && \
make && \
make install
dnl # protobuf-c
if test "$PHP_PROTOBUFC" != "no"; then
PHP_ADD_INCLUDE($PHP_PROTOBUFC/include)
PHP_ADD_LIBRARY_WITH_PATH(protobuf-c, $PHP_PROTOBUFC/lib, MAGNETO_SHARED_LIBADD)
fi
phpize
CFLAGS='-arch i386 -arch x86_64' ./configure --enable-yourextension --with-protobufc=/path/to/pb-c && \
make && \
sudo make install
<configuration>
<system.net>
<defaultProxy>
<proxy proxyaddress="http://localhost:8888" />
</defaultProxy>
</system.net>
</configuration>