#include <sys/types.h>
#include <sstream>
#include "t_erl_generator.h"
-using namespace std;
+using namespace std;
void hrl_header(std::ostream& out, std::string name);
void hrl_footer(std::ostream& out, std::string name);
-
/**
* UI for file generation by opening up the necessary file output
* streams.
*/
string t_erl_generator::erl_imports() {
return
- string("-include(\"thrift/protocol/tProtocol.hrl\").\n") +
- "-include(\"thrift/thrift.hrl\").";
+ string("-include(\"thrift.hrl\").\n") +
+ "-include(\"tApplicationException.hrl\").\n" +
+ "-include(\"protocol/tProtocol.hrl\").\n";
}
/**
indent_up();
out <<
- indent() << "?M 0(Iprot, readStructBegin)," << endl <<
+ indent() << "?R 0(Iprot, readStructBegin)," << endl <<
indent() << "Str = " << uncapitalize(type_name(tstruct)) << "_read_loop(Iprot, ";
// if (fields.size() > 0) { // cpiro: sensible default for non-empty structs
// }
out << ")," << endl <<
- indent() << "?M 0(Iprot, readStructEnd)," << endl <<
+ indent() << "?R 0(Iprot, readStructEnd)," << endl <<
indent() << "Str." << endl;
indent_down();
indent_up();
// Read beginning field marker
- indent(out) <<
- "{ Fname, Ftype, Fid } = ?M 0(Iprot, readFieldBegin)," << endl <<
- indent() << "Fid, Fname , % suppress unused warnings" << endl;
+ out <<
+ indent() << "{ _Fname, Ftype, Fid } = ?R 0(Iprot, readFieldBegin)," << endl <<
+ indent() << "Fid , % suppress unused warnings" << endl;
// Check for field STOP marker and break
indent(out) << "if" << endl;
indent_up();
generate_deserialize_field(out, *f_iter, "Val");
- out << indent() << "?M 0(Iprot, readFieldEnd)," << endl
+ out << indent() << "?R 0(Iprot, readFieldEnd)," << endl
<< indent() << uncapitalize(type_name(tstruct)) << "_read_loop(Iprot, "
<< "Str#" << uncapitalize(type_name(tstruct))
<< "{" << (*f_iter)->get_name()
// In the default case we skip the field
out <<
indent() << "true -> " << endl <<
- indent() << " ?M 1(Iprot, skip, Ftype)," << endl <<
- indent() << " ?M 0(Iprot, readFieldEnd)," << endl <<
+ indent() << " ?R 1(Iprot, skip, Ftype)," << endl <<
+ indent() << " ?R 0(Iprot, readFieldEnd)," << endl <<
indent() << " " << uncapitalize(type_name(tstruct)) << "_read_loop(Iprot, Str)" << endl;
indent_down();
indent(out) << "end." << endl;
indent(out) << fname << "(Str, Oprot) -> %xy" << endl;
indent_up();
- indent(out) <<
- "Str, % suppress unused warnings" << endl <<
- indent() << "?M 1(Oprot, writeStructBegin, \"" << name << "\")," << endl;
+ out <<
+ indent() << "Str, % suppress unused warnings" << endl <<
+ indent() << "?R 1(Oprot, writeStructBegin, \"" << name << "\")," << endl;
string prefix = string("Str#") + uncapitalize(type_name(tstruct)) + ".";
"if " << prefix << (*f_iter)->get_name() << " /= undefined ->" << endl;
indent_up();
indent(out) <<
- "?M 3(Oprot, writeFieldBegin, " <<
+ "?R 3(Oprot, writeFieldBegin, " <<
"\"" << (*f_iter)->get_name() << "\", " <<
type_to_enum((*f_iter)->get_type()) << ", " <<
(*f_iter)->get_key() << ")," << endl;
// Write field closer
indent(out) <<
- "?M 0(Oprot, writeFieldEnd);" << endl <<
+ "?R 0(Oprot, writeFieldEnd);" << endl <<
indent() << "true -> ok" << endl;
indent_down();
// Write the struct map
out <<
- indent() << "?M 0(Oprot, writeFieldStop)," << endl <<
- indent() << "?M 0(Oprot, writeStructEnd)," << endl <<
+ indent() << "?R 0(Oprot, writeFieldStop)," << endl <<
+ indent() << "?R 0(Oprot, writeStructEnd)," << endl <<
indent() << "ok." << endl;
indent_down();
f_service_file_ << "-include(\"" << uncapitalize(tservice->get_name()) << ".hrl\")." << endl << endl;
- f_service_file_ << "-export([" << export_lines_.str() << "]).";
+ f_service_file_ << "-export([" << export_lines_.str() << "])." << endl << endl ;
f_service_file_ << f_service_.str();
// Serialize the request header
f_service_ <<
- indent() << "Oprot = ?ATTR(oprot)," << endl <<
- indent() << "?M3(Oprot, writeMessageBegin, \"" << (*f_iter)->get_name() << "\", ?tMessageType_CALL, ?ATTR(seqid))," << endl <<
+ indent() << "Oprot = oop:get(This, oprot)," << endl <<
+ indent() << "Seqid = oop:get(This, seqid)," << endl <<
+ indent() << "?R3(Oprot, writeMessageBegin, \"" << (*f_iter)->get_name() << "\", ?tMessageType_CALL, Seqid)," << endl <<
indent() << "Args = #" << (*f_iter)->get_name() << "_args{";
bool first = true;
// Write to the stream
f_service_ <<
- indent() << "?M 0(Oprot, writeMessageEnd)," << endl <<
- indent() << "%% side-effect: not gonna happen " << endl <<
- indent() << "%% ?M0(?M0(Oprot, trans), flush)," << endl <<
+ indent() << "?R 0(Oprot, writeMessageEnd)," << endl <<
+ indent() << "Trans = ?R1(Oprot, get, trans), " << endl <<
+ indent() << "?R0(Trans, effectful_ flush)," << endl <<
indent() << "ok." << endl;
indent_down();
// TODO(cpiro): actually raise an Erlang exception?
f_service_ <<
- indent() << "Iprot = ?ATTR(iprot)," << endl <<
- indent() << "{ Fname, Mtype, Rseqid } = ?M0(Iprot, readMessageBegin)," << endl <<
- indent() << "Fname, Rseqid, % suppress unused warnings" << endl <<
+ indent() << "Iprot = oop:get(This, iprot)," << endl <<
+ indent() << "{ _Fname, Mtype, _Rseqid } = ?R0(Iprot, readMessageBegin)," << endl <<
indent() << "if" << endl <<
indent() << " Mtype == ?tMessageType_EXCEPTION ->" << endl <<
indent() << " X = tApplicationException:new()," << endl <<
- indent() << " ?M1(X, read, Iprot), " << endl <<
- indent() << " ?M 0(Iprot, readMessageEnd), " << endl <<
+ indent() << " tApplicationException:read(X, Iprot), %% cpiro rly treat exceptions different? " << endl <<
+ indent() << " ?R 0(Iprot, readMessageEnd), " << endl <<
indent() << " {error, X};" << endl <<
indent() << " true ->" << endl <<
indent() << " Result = " << resultname << "_read(Iprot)," << endl <<
- indent() << " ?M 0(Iprot, readMessageEnd)," << endl <<
+ indent() << " ?R 0(Iprot, readMessageEnd)," << endl <<
indent() << " if % time to figure out retval" << endl;
// indent() << " {ok, Success} % result.success casing? Success even for void?" << endl <<
// Careful, only return _result if not a void function
if ((*f_iter)->get_returntype()->is_void()) {
indent(f_service_) <<
- indent() << " Result, % suppress unused warnings " << endl <<
+ indent() << " Result," << endl <<
indent() << " true -> {ok, nil}" << endl <<
indent() << " end" << endl;
} else {
indent_up();
f_service_ <<
- indent() << "{ Name, Type, Seqid } = ?M0(Iprot, readMessageBegin)," << endl <<
- indent() << "Type, % suppress unused warnings" << endl;
+ indent() << "{ Name, _Type, Seqid } = ?R0(Iprot, readMessageBegin)," << endl;
// TODO(mcslee): validate message
indent(f_service_) << " %% TODO(cpiro): pass to super" << endl;
indent(f_service_) << " _ -> % unknown function" << endl <<
- indent() << " ?M 1(Iprot, skip, ?tType_STRUCT)," << endl <<
- indent() << " ?M 0(Iprot, readMessageEnd)," << endl <<
+ indent() << " ?R 1(Iprot, skip, ?tType_STRUCT)," << endl <<
+ indent() << " ?R 0(Iprot, readMessageEnd)," << endl <<
indent() << " X = tApplicationException:new(?tApplicationException_UNKNOWN_METHOD, \"Unknown function \" ++ Name)," << endl <<
- indent() << " ?M 3(Oprot, writeMessageBegin, Name, ?tMessageType_EXCEPTION, Seqid)," << endl <<
- indent() << " ?M1(X, write , Oprot)," << endl <<
- indent() << " ?M 0(Oprot, writeMessageEnd)," << endl <<
- indent() << " %% side-effect: not gonna happen " << endl <<
- indent() << " %% ?M0(?M0(Oprot, trans), flush)," << endl <<
+ indent() << " ?R 3(Oprot, writeMessageBegin, Name, ?tMessageType_EXCEPTION, Seqid)," << endl <<
+ indent() << " tApplicationException:write(X , Oprot)," << endl <<
+ indent() << " ?R 0(Oprot, writeMessageEnd)," << endl <<
+ indent() << " Trans = ?R1(Oprot, get, trans), " << endl <<
+ indent() << " ?R0(Trans, effectful_ flush)," << endl <<
indent() << " {error, X} % what's the retval in this case?" << endl <<
indent() << "end." << endl;
// indent() << "ok. % this one?" << endl << endl;
"(HandlerModule, Seqid, Iprot, Oprot) ->" << endl;
indent_up();
+ f_service_ <<
+ indent() << "Seqid, Oprot, % suppress unused warnings" << endl;
+
string argsname = tfunction->get_name() + "_args";
string resultname = tfunction->get_name() + "_result";
f_service_ <<
- indent() << "Args = " << argsname << "_read(Iprot)," << endl <<
- indent() << "Args, Seqid, Oprot, % suppress unused warnings" << endl <<
- indent() << "?M0(Iprot, readMessageEnd)," << endl;
+ indent() << "_Args = " << argsname << "_read(Iprot)," << endl <<
+ // indent() << "Args, Seqid, Oprot, % suppress unused warnings" << endl <<
+ // indent() << "Args % suppress unused warnings" << endl <<
+ indent() << "?R0(Iprot, readMessageEnd)," << endl;
t_struct* xs = tfunction->get_xceptions();
const std::vector<t_field*>& xceptions = xs->get_members();
} else {
f_service_ << ", ";
}
- f_service_ << "Args#" << tfunction->get_name() << "_args." << (*f_iter)->get_name();
+ f_service_ << "_ Args#" << tfunction->get_name() << "_args." << (*f_iter)->get_name();
}
f_service_ << ")," << endl;
indent(f_service_) << "% async" << endl;
} else {
f_service_ <<
- indent() << "?M 3(Oprot, writeMessageBegin, \"" << tfunction->get_name() << "\", ?tMessageType_REPLY, Seqid)," << endl <<
+ indent() << "?R 3(Oprot, writeMessageBegin, \"" << tfunction->get_name() << "\", ?tMessageType_REPLY, Seqid)," << endl <<
indent() << tfunction->get_name() << "_result_write(Result, Oprot)," << endl <<
- indent() << "?M 0(Oprot, writeMessageEnd)," << endl <<
- indent() << "%% side-effect: not gonna happen " << endl <<
- indent() << "%% ?M0(?M0(Oprot, trans), flush)," << endl;
+ indent() << "?R 0(Oprot, writeMessageEnd)," << endl <<
+ indent() << "Trans = ?R1(Oprot, get, trans), " << endl <<
+ indent() << "?R0(Trans, effectful_ flush)," << endl;
}
indent(f_service_) << "Result." << endl << endl;
} else if (type->is_base_type() || type->is_enum()) {
indent(out) <<
// name << " = iprot.";
- name << " = ?M 0(Iprot, ";
+ name << " = ?R 0(Iprot, ";
if (type->is_base_type()) {
t_base_type::t_base tbase = ((t_base_type*)type)->get_base();
string name = prefix + tfield->get_name();
indent(out) <<
- "?M 1(Oprot, ";
+ "?R 1(Oprot, ";
if (type->is_base_type()) {
t_base_type::t_base tbase = ((t_base_type*)type)->get_base();
string prefix) {
indent(out) << tstruct->get_program()->get_name() << "_types:" << uncapitalize(tstruct->get_name()) << "_write(" << prefix << ", Oprot), % generate_serialize_struct" << endl;
// indent(out) <<
- // "?M 1(" << prefix << ", write, Oprot), % generate_serialize_struct" << endl;
+ // "?R 1(" << prefix << ", write, Oprot), % generate_serialize_struct" << endl;
}
void t_erl_generator::generate_serialize_container(ostream &out,
string prefix) {
if (ttype->is_map()) {
indent(out) <<
- "?M 3(Oprot, writeMapBegin, " <<
+ "?R 3(Oprot, writeMapBegin, " <<
type_to_enum(((t_map*)ttype)->get_key_type()) << ", " <<
type_to_enum(((t_map*)ttype)->get_val_type()) << ", length(" <<
prefix << ")), % generate_serialize_container" << endl;
} else if (ttype->is_set()) {
indent(out) <<
- "?M 2(Oprot, writeSetBegin, " <<
+ "?R 2(Oprot, writeSetBegin, " <<
type_to_enum(((t_set*)ttype)->get_elem_type()) << ", length(" <<
prefix << ")), % generate_serialize_container" << endl;
} else if (ttype->is_list()) {
indent(out) <<
- "?M 2(Oprot, writeListBegin, " <<
+ "?R 2(Oprot, writeListBegin, " <<
type_to_enum(((t_list*)ttype)->get_elem_type()) << ", length(" <<
prefix << ")), % generate_serialize_container" << endl;
}
if (ttype->is_map()) {
indent(out) <<
- "?M 0(Oprot, writeMapEnd), % generate_serialize_container" << endl;
+ "?R 0(Oprot, writeMapEnd), % generate_serialize_container" << endl;
} else if (ttype->is_set()) {
indent(out) <<
- "?M 0(Oprot, writeSetEnd), % generate_serialize_container" << endl;
+ "?R 0(Oprot, writeSetEnd), % generate_serialize_container" << endl;
} else if (ttype->is_list()) {
indent(out) <<
- "?M 0(Oprot, writeListEnd), % generate_serialize_container" << endl;
+ "?R 0(Oprot, writeListEnd), % generate_serialize_container" << endl;
}
}
--- /dev/null
+MODULES = lib # release
+
+all clean:
+ @for dir in $(MODULES); do \
+ (cd $$dir; ${MAKE} $@); \
+ if [ "$$?" -ne "0" ]; then ERROR=$$?; echo "Error Code $$ERROR"; exit $$ERROR; fi; \
+ done
+
+docs:
+ (cd lib; ${MAKE} $@); \
+ if [ "$$?" -ne "0" ]; then ERROR=$$?; echo "Error Code $$ERROR"; exit $$ERROR; fi;
+
+install:
+ echo NO OP
--- /dev/null
+Much more information on these topics can be found at www.erlware.org
+
+
+Building the tree
+=================
+
+To build, type make, it should all work from there.
+
+NOTE** if your system has erlang installed in a directory other than /usr/local/lib/erlang
+then you must set the environment variable ERL_RUN_TOP to that directory. For example
+if you have erlang installed in /home/jdoe/erlang then you should
+export ERL_RUN_TOP=/home/jdoe/erlang
+
+
+Creating a new application
+==========================
+
+A new application can be created by using the appgen utility in otp/tools/utilities.
+This utility will create a basic OTP app framework under the otp/lib directory and
+an OTP release under the otp/release directory.
+
+usage: appgen <appname> <prefix>
+
+Appname is the name of the application that you would like to create. The prefix is
+usually the first letter of each word in the appname. This prefix is to avoid name
+clashes between applications included in a release (Erlang does not have packages).
+
+example usage: appgen my_app ma
+
+which results in
+
+otp/lib/my_app & otp/release/my_app_rel
+
+Running a release
+=================
+
+Your release should contain all that you need to run your application. If your application
+depends on any applications that are supplied outside of this build tree or OTP itself then
+they may be added to the <appname>_rel.rel.src file. If the extra applications are present
+in this build tree then they will be found by the make process and included in the final
+release.
+
+To run a release there are two options: "local" and installed. The local version can be found
+in the otp/release/<appname>_rel/local directory which is added by the make process. This
+should be used during development to run your release interactively via an Erlang shell.
+To run a release in local mode cd into the "local" directory and run <appname>_rel.sh.
+
+The second way to run a release is to install it and run it as a daemon. This is used for
+applications in a production setting. To do this you need to first run make & make install
+from the <appname>_rel directory. This will place a complete production ready versioned
+release in the /usr/local/lib/ directory under <appname>_rel. To run an installed release
+cd to /usr/local/lib/<appname>_rel/release/<rel_vsn> and run <appname>_rel.sh.
+
+In the case where you want to create a production ready release on one machine and then deploy it
+on multiple identical machines you may create a production tar archive. To do this run
+make & make tar from the otp/release/<appname>_rel/ directory. This will create a tar file conataining
+the release name and version number in the file name. This tar can be shipped to its destination and
+untarred. Within the untarred directory there is a shell script entitled install.sh. Running this
+script will install the release by default in /usr/local/lib/<appname>_rel. An optional argument
+can be provided that will direct the installation to a different directory.
+
+Example install.sh /opt/lib
+
+This will install the release in /opt/lib/<appname>_rel
+
+
+
+
--- /dev/null
+#!/bin/sh
+
+# erlwareSys: otp/build/beamver,v 1.1 2002/02/14 11:45:20 hal Exp $
+
+# usage: beamver <beam_file>
+#
+# if there's a usable -vsn() attribute, print it and exit with status 0
+# otherwise, print nothing and exit with status 1
+
+# From the Erlang shell:
+#
+# 5> code:which(acca_inets).
+# "/home/martin/work/otp/releases/<app>/../../acca/ebin/<app>.beam"
+#
+# 8> beam_lib:version(code:which(<app>)).
+# {ok,{<app>,['$Id: beamver,v 1.1.1.1 2003/06/13 21:43:21 mlogan Exp $ ']}}
+
+# TMPFILE looks like this:
+#
+# io:format("hello ~p~n",
+# beam_lib:version("/home/hal/work/otp/acca/ebin/acca_inets.beam")]).
+
+TMPFILE=/tmp/beamver.$$
+
+# exit with failure if we can't read the file
+test -f "$1" || exit 1
+BEAMFILE=\"$1\"
+
+cat > $TMPFILE <<_EOF
+io:format("~p~n",
+ [beam_lib:version($BEAMFILE)]).
+_EOF
+
+# beam_result is {ok,{Module_name, Beam_version} or {error,beam_lib,{Reason}}
+beam_result=`erl -noshell \
+ -s file eval $TMPFILE \
+ -s erlang halt`
+
+rm -f $TMPFILE
+
+# sed regexes:
+# remove brackets and anything outside them
+# remove quotes and anything outside them
+# remove apostrophes and anything outside them
+# remove leading and trailing spaces
+
+case $beam_result in
+\{ok*)
+ echo $beam_result | sed -e 's/.*\[\(.*\)].*/\1/' \
+ -e 's/.*\"\(.*\)\".*/\1/' \
+ -e "s/.*\'\(.*\)\'.*/\1/" \
+ -e 's/ *$//' -e 's/^ *//'
+ exit 0
+ ;;
+*)
+ exit 1
+ ;;
+esac
+
--- /dev/null
+EBIN=../ebin
+EMULATOR=beam
+
+ERLC_WFLAGS = -W
+ERLC = erlc $(ERLC_WFLAGS) $(ERLC_FLAGS)
+ERL = erl -boot start_clean
+ESRC = .
+
+$(EBIN)/%.beam: $(ESRC)/%.erl
+ $(ERLC) $(ERL_FLAGS) $(ERL_COMPILE_FLAGS) -o$(EBIN) $<
+
+.erl.beam:
+ $(ERLC) $(ERL_FLAGS) $(ERL_COMPILE_FLAGS) -o$(dir $@) $<
+
--- /dev/null
+# Colors to assist visual inspection of make output.
+
+# Colors
+LGRAY=$$'\e[0;37m'
+DGRAY=$$'\e[1;30m'
+LGREEN=$$'\e[1;32m'
+LBLUE=$$'\e[1;34m'
+LCYAN=$$'\e[1;36m'
+LPURPLE=$$'\e[1;35m'
+LRED=$$'\e[1;31m'
+NO_COLOR=$$'\e[0m'
+DEFAULT=$$'\e[0m'
+BLACK=$$'\e[0;30m'
+BLUE=$$'\e[0;34m'
+GREEN=$$'\e[0;32m'
+CYAN=$$'\e[0;36m'
+RED=$$'\e[0;31m'
+PURPLE=$$'\e[0;35m'
+BROWN=$$'\e[0;33m'
+YELLOW=$$'\e[1;33m'
+WHITE=$$'\e[1;37m'
+
+BOLD=$$'\e[1;37m'
+OFF=$$'\e[0m'
--- /dev/null
+EDOC_PATH=../../../tools/utilities
+
+#single place to include docs from.
+docs:
+ @mkdir -p ../doc
+ @echo -n $${MY_BLUE:-$(BLUE)}; \
+ $(EDOC_PATH)/edoc $(APP_NAME); \
+ if [ $$? -eq 0 ]; then \
+ echo $${MY_LRED:-$(LRED)}"$$d Doc Failed"; \
+ fi; \
+ echo -n $(OFF)$(NO_COLOR)
+
--- /dev/null
+
+application/activemessage
+application/andrew-inset
+application/applefile
+application/atomicmail
+application/dca-rft
+application/dec-dx
+application/mac-binhex40 hqx
+application/mac-compactpro cpt
+application/macwriteii
+application/msword doc
+application/news-message-id
+application/news-transmission
+application/octet-stream bin dms lha lzh exe class
+application/oda oda
+application/pdf pdf
+application/postscript ai eps ps
+application/powerpoint ppt
+application/remote-printing
+application/rtf rtf
+application/slate
+application/wita
+application/wordperfect5.1
+application/x-bcpio bcpio
+application/x-cdlink vcd
+application/x-compress Z
+application/x-cpio cpio
+application/x-csh csh
+application/x-director dcr dir dxr
+application/x-dvi dvi
+application/x-gtar gtar
+application/x-gzip gz
+application/x-hdf hdf
+application/x-httpd-cgi cgi
+application/x-koan skp skd skt skm
+application/x-latex latex
+application/x-mif mif
+application/x-netcdf nc cdf
+application/x-sh sh
+application/x-shar shar
+application/x-stuffit sit
+application/x-sv4cpio sv4cpio
+application/x-sv4crc sv4crc
+application/x-tar tar
+application/x-tcl tcl
+application/x-tex tex
+application/x-texinfo texinfo texi
+application/x-troff t tr roff
+application/x-troff-man man
+application/x-troff-me me
+application/x-troff-ms ms
+application/x-ustar ustar
+application/x-wais-source src
+application/zip zip
+audio/basic au snd
+audio/mpeg mpga mp2
+audio/x-aiff aif aiff aifc
+audio/x-pn-realaudio ram
+audio/x-pn-realaudio-plugin rpm
+audio/x-realaudio ra
+audio/x-wav wav
+chemical/x-pdb pdb xyz
+image/gif gif
+image/ief ief
+image/jpeg jpeg jpg jpe
+image/png png
+image/tiff tiff tif
+image/x-cmu-raster ras
+image/x-portable-anymap pnm
+image/x-portable-bitmap pbm
+image/x-portable-graymap pgm
+image/x-portable-pixmap ppm
+image/x-rgb rgb
+image/x-xbitmap xbm
+image/x-xpixmap xpm
+image/x-xwindowdump xwd
+message/external-body
+message/news
+message/partial
+message/rfc822
+multipart/alternative
+multipart/appledouble
+multipart/digest
+multipart/mixed
+multipart/parallel
+text/html html htm
+text/x-server-parsed-html shtml
+text/plain txt
+text/richtext rtx
+text/tab-separated-values tsv
+text/x-setext etx
+text/x-sgml sgml sgm
+video/mpeg mpeg mpg mpe
+video/quicktime qt mov
+video/x-msvideo avi
+video/x-sgi-movie movie
+x-conference/x-cooltalk ice
+x-world/x-vrml wrl vrml
--- /dev/null
+# +----------------------------------------------------------------------+
+# $Id: otp.mk,v 1.4 2004/07/01 14:57:10 tfee Exp $
+# +----------------------------------------------------------------------+
+
+# otp.mk
+# - to be included in all OTP Makefiles
+# installed to /usr/local/include/erlang/otp.mk
+
+# gmake looks in /usr/local/include - that's hard-coded
+# users of this file will use
+# include erlang/top.mk
+
+# most interface files will be installed to $ERL_RUN_TOP/app-vsn/include/*.hrl
+
+# group owner for library/include directories
+ERLANGDEV_GROUP=erlangdev
+
+# ERL_TOP is root of Erlang source tree
+# ERL_RUN_TOP is root of Erlang target tree (some Ericsson Makefiles use $ROOT)
+# ERLANG_OTP is target root for Erlang code
+# - see sasl/systools reference manual page; grep "TEST"
+
+# OS_TYPE is FreeBSD, NetBSD, OpenBSD, Linux, SCO_SV, SunOS.
+OS_TYPE=${shell uname}
+
+# MHOST is the host where this Makefile runs.
+MHOST=${shell hostname -s}
+ERL_COMPILE_FLAGS+=-W0
+
+# The location of the erlang runtime system.
+ifndef ERL_RUN_TOP
+ERL_RUN_TOP=/usr/local/lib/erlang
+endif
+
+
+# Edit to reflect local environment.
+# ifeq (${OS_TYPE},Linux)
+# ERL_RUN_TOP=/usr/local/lib/erlang
+# Note* ERL_RUN_TOP can be determined by starting an
+# erlang shell and typing code:root_dir().
+# ERL_TOP=a symbolic link to the actual source top, which changes from version to version
+# Note* ERL_TOP is the directory where the erlang
+# source files reside. Make sure to run ./configure there.
+# TARGET=i686-pc-linux-gnu
+# Note* Target can be found in $ERL_TOP/erts
+# endif
+
+# See above for directions.
+ifeq (${OS_TYPE},Linux)
+ERL_TOP=/opt/OTP_SRC
+TARGET=i686-pc-linux-gnu
+endif
+
+ERLANG_OTP=/usr/local/erlang/otp
+VAR_OTP=/var/otp
+
+
+# Aliases for common binaries
+# Note - CFLAGS is modified in erlang.conf
+
+
+################################
+# SunOS
+################################
+ifeq (${OS_TYPE},SunOS)
+
+ CC=gcc
+ CXX=g++
+ AR=/usr/ccs/bin/ar
+ ARFLAGS=-rv
+ CXXFLAGS+=${CFLAGS} -I/usr/include/g++
+ LD=/usr/ccs/bin/ld
+ RANLIB=/usr/ccs/bin/ranlib
+
+CFLAGS+=-Wall -pedantic -ansi -O
+CORE=*.core
+endif
+
+
+################################
+# FreeBSD
+################################
+ifeq (${OS_TYPE},FreeBSD)
+
+ ifdef LINUXBIN
+ COMPAT_LINUX=/compat/linux
+ CC=${COMPAT_LINUX}/usr/bin/gcc
+ CXX=${COMPAT_LINUX}/usr/bin/g++
+ AR=${COMPAT_LINUX}/usr/bin/ar
+ ARFLAGS=-rv
+ CXXFLAGS+=-fhandle-exceptions ${CFLAGS} -I${COMPAT_LINUX}/usr/include/g++
+ LD=${COMPAT_LINUX}/usr/bin/ld
+ RANLIB=${COMPAT_LINUX}/usr/bin/ranlib
+ BRANDELF=brandelf -t Linux
+ else
+ CC=gcc
+ CXX=g++
+ AR=/usr/bin/ar
+ ARFLAGS=-rv
+ CXXFLAGS+=-fhandle-exceptions ${CFLAGS} -I/usr/include/g++
+ LD=/usr/bin/ld
+ RANLIB=/usr/bin/ranlib
+ BRANDELF=@true
+
+ ifdef USES_PTHREADS
+ CFLAGS+=-D_THREAD_SAFE
+ LDFLAGS+=-lc_r
+
+ # -pthread flag for 3.0+
+ ifneq (${shell uname -r | cut -d. -f1},2)
+ CFLAGS+=-pthread
+ endif
+ endif
+ endif
+
+CFLAGS+=-Wall -pedantic -ansi -O -DFREEBSD
+CORE=*.core
+endif
+
+################################
+# OpenBSD
+################################
+ifeq (${OS_TYPE},OpenBSD)
+
+ CC=gcc
+ CXX=g++
+ AR=/usr/bin/ar
+ ARFLAGS=-rv
+ CXXFLAGS+=${CFLAGS} -I/usr/include/g++
+ LD=/usr/bin/ld
+ RANLIB=/usr/bin/ranlib
+
+ ifdef USES_PTHREADS
+ CFLAGS+=-D_THREAD_SAFE
+ LDFLAGS+=-lc_r
+
+ # -pthread flag for 3.0+
+ ifneq (${shell uname -r | cut -d. -f1},2)
+ CFLAGS+=-pthread
+ endif
+ endif
+
+CFLAGS+=-Wall -pedantic -ansi -O -DOPENBSD
+CORE=*.core
+endif
+
--- /dev/null
+# Comment by tfee 2004-07-01
+# ==========================
+# This file is a mod of the stock OTP one.
+# The change allows make to stop when a compile error occurs.
+# This file needs to go into two places:
+# /usr/local/include/erlang
+# /opt/OTP_SRC/make
+#
+# where OTP_SRC is a symbolic link to a peer directory containing
+# the otp source, e.g. otp_src_R9C-2.
+#
+# After installing OTP, running sudo make install in otp/build
+# will push this file out to the two places listed above.
+#
+# The mod involves setting the shell variable $short_circuit, which we
+# introduce - ie it is not in the stock file. This variable is tested
+# to affect execution flow and is also returned to affect the flow in
+# the calling script (this one). The latter step is necessary because
+# of the recursion involved.
+# =====================================================================
+
+
+# ``The contents of this file are subject to the Erlang Public License,
+# Version 1.1, (the "License"); you may not use this file except in
+# compliance with the License. You should have received a copy of the
+# Erlang Public License along with this software. If not, it can be
+# retrieved via the world wide web at http://www.erlang.org/.
+#
+# Software distributed under the License is distributed on an "AS IS"
+# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+# the License for the specific language governing rights and limitations
+# under the License.
+#
+# The Initial Developer of the Original Code is Ericsson Utvecklings AB.
+# Portions created by Ericsson are Copyright 1999, Ericsson Utvecklings
+# AB. All Rights Reserved.''
+#
+# $Id: otp_subdir.mk,v 1.5 2004/07/12 15:12:23 jeinhorn Exp $
+#
+#
+# Make include file for otp
+
+.PHONY: debug opt release docs release_docs tests release_tests \
+ clean depend
+
+#
+# Targets that don't affect documentation directories
+#
+debug opt release docs release_docs tests release_tests clean depend: prepare
+ @set -e ; \
+ app_pwd=`pwd` ; \
+ if test -f vsn.mk; then \
+ echo "=== Entering application" `basename $$app_pwd` ; \
+ fi ; \
+ case "$(MAKE)" in *clearmake*) tflag="-T";; *) tflag="";; esac; \
+ short_circuit=0 ; \
+ for d in $(SUB_DIRECTORIES); do \
+ if [[ $$short_circuit = 0 ]]; then \
+ if test -f $$d/SKIP ; then \
+ echo "=== Skipping subdir $$d, reason:" ; \
+ cat $$d/SKIP ; \
+ echo "===" ; \
+ else \
+ if test ! -d $$d ; then \
+ echo "=== Skipping subdir $$d, it is missing" ; \
+ else \
+ xflag="" ; \
+ if test -f $$d/ignore_config_record.inf; then \
+ xflag=$$tflag ; \
+ fi ; \
+ (cd $$d && $(MAKE) $$xflag $@) ; \
+ if [[ $$? != 0 ]]; then \
+ short_circuit=1 ; \
+ fi ; \
+ fi ; \
+ fi ; \
+ fi ; \
+ done ; \
+ if test -f vsn.mk; then \
+ echo "=== Leaving application" `basename $$app_pwd` ; \
+ fi ; \
+ exit $$short_circuit
+
+prepare:
+ echo
--- /dev/null
+# for testing erlang files directly. The set up for a
+# this type of test would be
+# files to test reside in lib/<app_name>/src and the test files which are
+# just plain erlang code reside in lib/<app_name>/test
+#
+# This color codes emitted while the tests run assume that you are using
+# a white-on-black display schema. If not, e.g. if you use a white
+# background, you will not be able to read the "WHITE" text.
+# You can override this by supplying your own "white" color,
+# which may in fact be black! You do this by defining an environment
+# variable named "MY_WHITE" and setting it to $'\e[0;30m' (which is
+# simply bash's way of specifying "Escape [ 0 ; 3 0 m").
+# Similarly, you can set your versions of the standard colors
+# found in colors.mk.
+
+test:
+ @TEST_MODULES=`ls *_test.erl`; \
+ trap "echo $(OFF)$(NO_COLOR); exit 1;" 1 2 3 6; \
+ for d in $$TEST_MODULES; do \
+ echo $${MY_GREEN:-$(GREEN)}"Testing File $$d" $${MY_WHITE:-$(WHITE)}; \
+ echo -n $${MY_BLUE:-$(BLUE)}; \
+ erl -name $(APP_NAME) $(TEST_LIBS) \
+ -s `basename $$d .erl` all -s init stop -noshell; \
+ if [ $$? -ne 0 ]; then \
+ echo $${MY_LRED:-$(LRED)}"$$d Test Failed"; \
+ fi; \
+ echo -n $(OFF)$(NO_COLOR); \
+ done
+
--- /dev/null
+include ../build/colors.mk
+
+MODULES=$(shell ls . | grep "[^(Makefile)]")
+
+all clean docs:
+ @for dir in $(MODULES); do \
+ (cd $$dir; if [ -e "SKIP" ]; then echo $${MY_LRED:-$(LRED)}"skipping \"make $@\" for $$dir"; else ${MAKE} $@; fi); \
+ if [ "$$?" -ne "0" ]; then ERROR=$$?; echo "Error Code $$ERROR"; exit $$ERROR; fi; \
+ echo -n $(OFF)$(NO_COLOR); \
+ done
--- /dev/null
+Thrift Software License
+Copyright (c) 2006- Facebook, Inc.
+
+Permission is hereby granted, free of charge, to any person or organization
+obtaining a copy of the software and accompanying documentation covered by
+this license (the "Software") to use, reproduce, display, distribute,
+execute, and transmit the Software, and to prepare derivative works of the
+Software, and to permit third-parties to whom the Software is furnished to
+do so, all subject to the following:
+
+The copyright notices in the Software and this entire statement, including
+the above license grant, this restriction and the following disclaimer,
+must be included in all copies of the Software, in whole or in part, and
+all derivative works of the Software, unless such copies or derivative
+works are solely in the form of machine-executable object code generated by
+a source language processor.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
+SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
+FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
--- /dev/null
+%%% Copyright (c) 2007- Facebook
+%%% Distributed under the Thrift Software License
+%%%
+%%% See accompanying file LICENSE or visit the Thrift site at:
+%%% http://developers.facebook.com/thrift/
+
--- /dev/null
+Thrift Software License
+Copyright (c) 2006- Facebook, Inc.
+
+Permission is hereby granted, free of charge, to any person or organization
+obtaining a copy of the software and accompanying documentation covered by
+this license (the "Software") to use, reproduce, display, distribute,
+execute, and transmit the Software, and to prepare derivative works of the
+Software, and to permit third-parties to whom the Software is furnished to
+do so, all subject to the following:
+
+The copyright notices in the Software and this entire statement, including
+the above license grant, this restriction and the following disclaimer,
+must be included in all copies of the Software, in whole or in part, and
+all derivative works of the Software, unless such copies or derivative
+works are solely in the form of machine-executable object code generated by
+a source language processor.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
+SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
+FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
--- /dev/null
+MODULES = \
+ src
+
+all clean docs:
+ for dir in $(MODULES); do \
+ (cd $$dir; ${MAKE} $@); \
+ done
--- /dev/null
+YMMV
+email cpiro@facebook.com
+--
+
+TO START A SERVER:
+
+$ cd lib/erl/lib/thrift/
+$ cd tutorial
+$ thrift -cpp -java -py -php -rb -perl -erl -xsd -r tutorial.thrift
+$ cd ..
+$ make
+$ ./server.sh
+> Pid = server:start().
+ ** GAZE IN AMAZEMENT **
+> server:stop(Pid).
+
+NOTES:
+
+get/set never means process dictionary
+
+tExecptions and t*Factorys are straight "new" -- e.g. TF = tTransportFactory:new()
+everything else is start_new (i.e. gen_server:start_link) -- this spawns a process and returns a pid
+
+notable change from the Ruby:
+in t*Server:new, the parameters now include a handler, i.e. the generated module name. For example if your interface is called calculator, then to spawn a TSimpleServer try: oop:start_new(tSimpleServer, [calculator, calculatorHandler, Transport, TF])
+
+tErlProcessor is a shim around the generated code (which is not actually a gen_server). Of course tErlProcessor isn't a gen_server either ... thrift_oop_server is a shim to make our "Thrift objects" gen_servers. Maybe we should remove some layers?
+
+Use tErlServer and tErlAcceptor. tSimpleServer and tServerSocket are incompatible by design ... the call trace is spastic across the process tree. tErlServer and tErlAcceptor follow the same model as iserve:
+ * the top level code spawns a tErlServer, which listens on a socket
+ * a tErlAcceptor is spawned and calls accept() on the listening socket
+ * when accept() finishes, the tErlAcceptor
+ * tells the tErlServer to spawn a new acceptor
+ * handles the requests by spawning a processor, a transport, and a protocol
+ * (the tricky part) when the socket closes, the protocol exits, so:
+ * the transport exits because it's the one caller of the protocol
+ * likewise, the processor exits because it's the caller of the transport
+ * the tErlAcceptor traps the protocol's exit and exits with an acceptor_done
+ * the tErlServer sees that the acceptor exited and does nothing since there is already another acceptor accept()ing on the listen socket
--- /dev/null
+tutorial client
+
+find TODO(cpiro)s
+make all methods effectful, remove the special casing (optionally, implement monads for Erlang)
+
+inheritance
+
+test suites
+
+undisgustify codegen
--- /dev/null
+%%% Copyright (c) 2007- Facebook
+%%% Distributed under the Thrift Software License
+%%%
+%%% See accompanying file LICENSE or visit the Thrift site at:
+%%% http://developers.facebook.com/thrift/
+
+-define(CLASS(Obj), element(1, Obj)).
+
+-define(DEFINE_ATTR(Attr), attr(This, get, Attr, _Value) -> This#?MODULE.Attr;
+ attr(This, set, Attr, Value) -> This#?MODULE{Attr=Value}
+).
+
+%%% static: use only if you're sure This is class ?MODULE and not a super/subclass
+-define(ATTR(Attr), This#?MODULE.Attr).
+
+%%% convenience for implementing inspect/1
+%%% e.g. -> "foo=5"
+-define(FORMAT_ATTR(Attr),
+ io_lib:write_atom(Attr) ++ "=" ++ io_lib:print(?ATTR(Attr))
+).
+
+
+-define(ATTR_DUMMY,
+ attr(dummy, dummy, dummy, dummy) ->
+ throw(dummy_attr_used)
+).
--- /dev/null
+%%% Copyright (c) 2007- Facebook
+%%% Distributed under the Thrift Software License
+%%%
+%%% See accompanying file LICENSE or visit the Thrift site at:
+%%% http://developers.facebook.com/thrift/
+
+-define(VERSION_MASK, 16#FFFF0000).
+-define(VERSION_1, 16#80010000).
+
+-record(tBinaryProtocol, {super}).
--- /dev/null
+%%% Copyright (c) 2007- Facebook
+%%% Distributed under the Thrift Software License
+%%%
+%%% See accompanying file LICENSE or visit the Thrift site at:
+%%% http://developers.facebook.com/thrift/
+
+-record(tBinaryProtocolFactory, {super}).
--- /dev/null
+%%% Copyright (c) 2007- Facebook
+%%% Distributed under the Thrift Software License
+%%%
+%%% See accompanying file LICENSE or visit the Thrift site at:
+%%% http://developers.facebook.com/thrift/
+
+-record(tProtocol, {trans}).
--- /dev/null
+%%% Copyright (c) 2007- Facebook
+%%% Distributed under the Thrift Software License
+%%%
+%%% See accompanying file LICENSE or visit the Thrift site at:
+%%% http://developers.facebook.com/thrift/
+
+-define(tProtocolException_UNKNOWN, 0).
+-define(tProtocolException_INVALID_DATA, 1).
+-define(tProtocolException_NEGATIVE_SIZE, 2).
+-define(tProtocolException_SIZE_LIMIT, 3).
+-define(tProtocolException_BAD_VERSION, 4).
+
+-record(tProtocolException, {super, type}).
+
+
--- /dev/null
+%%% Copyright (c) 2007- Facebook
+%%% Distributed under the Thrift Software License
+%%%
+%%% See accompanying file LICENSE or visit the Thrift site at:
+%%% http://developers.facebook.com/thrift/
+
+-record(tProtocolFactory, {}).
--- /dev/null
+%%% Copyright (c) 2007- Facebook
+%%% Distributed under the Thrift Software License
+%%%
+%%% See accompanying file LICENSE or visit the Thrift site at:
+%%% http://developers.facebook.com/thrift/
+
+-record(tErlServer, {super, acceptor, listenSocket, port}).
--- /dev/null
+%%% Copyright (c) 2007- Facebook
+%%% Distributed under the Thrift Software License
+%%%
+%%% See accompanying file LICENSE or visit the Thrift site at:
+%%% http://developers.facebook.com/thrift/
+
+-record(tServer, {handler, processor, serverTransport, transportFactory, protocolFactory}).
--- /dev/null
+%%% Copyright (c) 2007- Facebook
+%%% Distributed under the Thrift Software License
+%%%
+%%% See accompanying file LICENSE or visit the Thrift site at:
+%%% http://developers.facebook.com/thrift/
+
+-record(tSimpleServer, {super}).
+%%% Copyright (c) 2007- Facebook
+%%% Distributed under the Thrift Software License
+%%%
+%%% See accompanying file LICENSE or visit the Thrift site at:
+%%% http://developers.facebook.com/thrift/
+
% TApplicationException
-define(tApplicationException_UNKNOWN, 0).
-define(tApplicationException_UNKNOWN_METHOD, 1).
-define(tApplicationException_BAD_SEQUENCE_ID, 4).
-define(tApplicationException_MISSING_RESULT, 5).
--record(tApplicationException, {message, type=?tApplicationException_UNKNOWN }).
+-record(tApplicationException, {super, type }).
--- /dev/null
+%%% Copyright (c) 2007- Facebook
+%%% Distributed under the Thrift Software License
+%%%
+%%% See accompanying file LICENSE or visit the Thrift site at:
+%%% http://developers.facebook.com/thrift/
+
+-record(tErlProcessor, {super, generatedProcessor, handler}).
--- /dev/null
+%%% Copyright (c) 2007- Facebook
+%%% Distributed under the Thrift Software License
+%%%
+%%% See accompanying file LICENSE or visit the Thrift site at:
+%%% http://developers.facebook.com/thrift/
+
+-record(tException, {message}).
--- /dev/null
+%%% Copyright (c) 2007- Facebook
+%%% Distributed under the Thrift Software License
+%%%
+%%% See accompanying file LICENSE or visit the Thrift site at:
+%%% http://developers.facebook.com/thrift/
+
+-record(tProcessor, {}).
+
--- /dev/null
+%%% Copyright (c) 2007- Facebook
+%%% Distributed under the Thrift Software License
+%%%
+%%% See accompanying file LICENSE or visit the Thrift site at:
+%%% http://developers.facebook.com/thrift/
+
+% local (same process)
+-define(L0(Method), oop:call(This, Method, [])).
+-define(L1(Method, Arg1), oop:call(This, Method, [Arg1])).
+-define(L2(Method, Arg1, Arg2), oop:call(This, Method, [Arg1, Arg2])).
+-define(L3(Method, Arg1, Arg2, Arg3), oop:call(This, Method, [Arg1, Arg2, Arg3])).
+-define(L4(Method, Arg1, Arg2, Arg3, Arg4), oop:call(This, Method, [Arg1, Arg2, Arg3, Arg4])).
+-define(L5(Method, Arg1, Arg2, Arg3, Arg4, Arg5), oop:call(This, Method, [Arg1, Arg2, Arg3, Arg4, Arg5])).
+-define(L6(Method, Arg1, Arg2, Arg3, Arg4, Arg5, Arg6), oop:call(This, Method, [Arg1, Arg2, Arg3, Arg4, Arg5, Arg6])).
+
+% local (same process), but not This (e.g. t*Factory)
+-define(F0(Obj, Method), oop:call(Obj, Method, [])).
+-define(F1(Obj, Method, Arg1), oop:call(Obj, Method, [Arg1])).
+-define(F2(Obj, Method, Arg1, Arg2), oop:call(Obj, Method, [Arg1, Arg2])).
+-define(F3(Obj, Method, Arg1, Arg2, Arg3), oop:call(Obj, Method, [Arg1, Arg2, Arg3])).
+-define(F4(Obj, Method, Arg1, Arg2, Arg3, Arg4), oop:call(Obj, Method, [Arg1, Arg2, Arg3, Arg4])).
+-define(F5(Obj, Method, Arg1, Arg2, Arg3, Arg4, Arg5), oop:call(Obj, Method, [Arg1, Arg2, Arg3, Arg4, Arg5])).
+-define(F6(Obj, Method, Arg1, Arg2, Arg3, Arg4, Arg5, Arg6), oop:call(Obj, Method, [Arg1, Arg2, Arg3, Arg4, Arg5, Arg6])).
+
+% remote (different process)
+-define(RT0(ServerRef, Method, Timeout), gen_server:call(ServerRef, {Method, []}, Timeout)).
+-define(RT1(ServerRef, Method, Timeout, Arg1), gen_server:call(ServerRef, {Method, [Arg1]}, Timeout)).
+-define(RT2(ServerRef, Method, Timeout, Arg1, Arg2), gen_server:call(ServerRef, {Method, [Arg1, Arg2]}, Timeout)).
+-define(RT3(ServerRef, Method, Timeout, Arg1, Arg2, Arg3), gen_server:call(ServerRef, {Method, [Arg1, Arg2, Arg3]}, Timeout)).
+-define(RT4(ServerRef, Method, Timeout, Arg1, Arg2, Arg3, Arg4), gen_server:call(ServerRef, {Method, [Arg1, Arg2, Arg3, Arg4]}, Timeout)).
+-define(RT5(ServerRef, Method, Timeout, Arg1, Arg2, Arg3, Arg4, Arg5), gen_server:call(ServerRef, {Method, [Arg1, Arg2, Arg3, Arg4, Arg5]}, Timeout)).
+-define(RT6(ServerRef, Method, Timeout, Arg1, Arg2, Arg3, Arg4, Arg5, Arg6), gen_server:call(ServerRef, {Method, [Arg1, Arg2, Arg3, Arg4, Arg5, Arg6]}, Timeout)).
+
+% remote (different process), default timeout
+-define(DEFAULT_TIMEOUT, 5000).
+-define(R0(ServerRef, Method), ?RT0(ServerRef, Method, ?DEFAULT_TIMEOUT)).
+-define(R1(ServerRef, Method, Arg1), ?RT1(ServerRef, Method, ?DEFAULT_TIMEOUT, Arg1)).
+-define(R2(ServerRef, Method, Arg1, Arg2), ?RT2(ServerRef, Method, ?DEFAULT_TIMEOUT, Arg1, Arg2)).
+-define(R3(ServerRef, Method, Arg1, Arg2, Arg3), ?RT3(ServerRef, Method, ?DEFAULT_TIMEOUT, Arg1, Arg2, Arg3)).
+-define(R4(ServerRef, Method, Arg1, Arg2, Arg3, Arg4), ?RT4(ServerRef, Method, ?DEFAULT_TIMEOUT, Arg1, Arg2, Arg3, Arg4)).
+-define(R5(ServerRef, Method, Arg1, Arg2, Arg3, Arg4, Arg5), ?RT5(ServerRef, Method, ?DEFAULT_TIMEOUT, Arg1, Arg2, Arg3, Arg4, Arg5)).
+-define(R6(ServerRef, Method, Arg1, Arg2, Arg3, Arg4, Arg5, Arg6), ?RT6(ServerRef, Method, ?DEFAULT_TIMEOUT, Arg1, Arg2, Arg3, Arg4, Arg5, Arg6)).
+
+% remote (different process), cast
+-define(C0(ServerRef, Method), gen_server:cast(ServerRef, {Method, []})).
+-define(C1(ServerRef, Method, Arg1), gen_server:cast(ServerRef, {Method, [Arg1]})).
+-define(C2(ServerRef, Method, Arg1, Arg2), gen_server:cast(ServerRef, {Method, [Arg1, Arg2]})).
+-define(C3(ServerRef, Method, Arg1, Arg2, Arg3), gen_server:cast(ServerRef, {Method, [Arg1, Arg2, Arg3]})).
+-define(C4(ServerRef, Method, Arg1, Arg2, Arg3, Arg4), gen_server:cast(ServerRef, {Method, [Arg1, Arg2, Arg3, Arg4]})).
+-define(C5(ServerRef, Method, Arg1, Arg2, Arg3, Arg4, Arg5), gen_server:cast(ServerRef, {Method, [Arg1, Arg2, Arg3, Arg4, Arg5]})).
+-define(C6(ServerRef, Method, Arg1, Arg2, Arg3, Arg4, Arg5, Arg6), gen_server:cast(ServerRef, {Method, [Arg1, Arg2, Arg3, Arg4, Arg5, Arg6]})).
+
+% spawn new server
+%% -define(NEW(Class, Args), %%
+%% gen_server:start_link(thrift_oop_server, {Class, Args}, [])). %%
+%% moved to oop:start_new/2
+
+% old
+%% -define(M0(Obj, Method), oop:call(Obj, Method, [])). %%
+%% -define(M1(Obj, Method, Arg1), oop:call(Obj, Method, [Arg1])). %%
+%% -define(M2(Obj, Method, Arg1, Arg2), oop:call(Obj, Method, [Arg1, Arg2])). %%
+%% -define(M3(Obj, Method, Arg1, Arg2, Arg3), oop:call(Obj, Method, [Arg1, Arg2, Arg3])). %%
+%% -define(M4(Obj, Method, Arg1, Arg2, Arg3, Arg4), oop:call(Obj, Method, [Arg1, Arg2, Arg3, Arg4])). %%
+%% -define(M5(Obj, Method, Arg1, Arg2, Arg3, Arg4, Arg5), oop:call(Obj, Method, [Arg1, Arg2, Arg3, Arg4, Arg5])). %%
+%% -define(M6(Obj, Method, Arg1, Arg2, Arg3, Arg4, Arg5, Arg6), oop:call(Obj, Method, [Arg1, Arg2, Arg3, Arg4, Arg5, Arg6])). %%
+
+%%% implicit call: old
+
+%% -define(M0(Obj, Method), ((?CLASS(Obj)):Method(Obj))). %%
+%% -define(M1(Obj, Method, Arg1), ((?CLASS(Obj)):Method(Obj, Arg1))). %%
+%% -define(M2(Obj, Method, Arg1, Arg2), ((?CLASS(Obj)):Method(Obj, Arg1, Arg2))). %%
+%% -define(M3(Obj, Method, Arg1, Arg2, Arg3), ((?CLASS(Obj)):Method(Obj, Arg1, Arg2, Arg3))). %%
+%% -define(M4(Obj, Method, Arg1, Arg2, Arg3, Arg4), ((?CLASS(Obj)):Method(Obj, Arg1, Arg2, Arg3, Arg4))). %%
+%% -define(M5(Obj, Method, Arg1, Arg2, Arg3, Arg4, Arg5), ((?CLASS(Obj)):Method(Obj, Arg1, Arg2, Arg3, Arg4, Arg5))). %%
+%% -define(M6(Obj, Method, Arg1, Arg2, Arg3, Arg4, Arg5, Arg6), ((?CLASS(Obj)):Method(Obj, Arg1, Arg2, Arg3, Arg4, Arg5, Arg6))). %%
+
+%% TType
+-define(tType_STOP, 0).
+-define(tType_VOID, 1).
+-define(tType_BOOL, 2).
+-define(tType_BYTE, 3).
+-define(tType_DOUBLE, 4).
+-define(tType_I16, 6).
+-define(tType_I32, 8).
+-define(tType_I64, 10).
+-define(tType_STRING, 11).
+-define(tType_STRUCT, 12).
+-define(tType_MAP, 13).
+-define(tType_SET, 14).
+-define(tType_LIST, 15).
+
+% tmessagetype
+-define(tMessageType_CALL, 1).
+-define(tMessageType_REPLY, 2).
+-define(tMessageType_EXCEPTION, 3).
+
+% TProcessor
+% ?
+
+% -include("tApplicationException.hrl").
--- /dev/null
+%%% Copyright (c) 2007- Facebook
+%%% Distributed under the Thrift Software License
+%%%
+%%% See accompanying file LICENSE or visit the Thrift site at:
+%%% http://developers.facebook.com/thrift/
+
+-record(tBufferedTransport, {super, transport, wbuf}).
--- /dev/null
+%%% Copyright (c) 2007- Facebook
+%%% Distributed under the Thrift Software License
+%%%
+%%% See accompanying file LICENSE or visit the Thrift site at:
+%%% http://developers.facebook.com/thrift/
+
+-record(tBufferedTransportFactory, {super}).
--- /dev/null
+%%% Copyright (c) 2007- Facebook
+%%% Distributed under the Thrift Software License
+%%%
+%%% See accompanying file LICENSE or visit the Thrift site at:
+%%% http://developers.facebook.com/thrift/
+
+-record(tErlAcceptor, {super, serverPid, transportFactory, protocolFactory}).
--- /dev/null
+%%% Copyright (c) 2007- Facebook
+%%% Distributed under the Thrift Software License
+%%%
+%%% See accompanying file LICENSE or visit the Thrift site at:
+%%% http://developers.facebook.com/thrift/
+
+-record(tServerSocket, {super, port, handle}).
--- /dev/null
+%%% Copyright (c) 2007- Facebook
+%%% Distributed under the Thrift Software License
+%%%
+%%% See accompanying file LICENSE or visit the Thrift site at:
+%%% http://developers.facebook.com/thrift/
+
+-record(tServerTransport, {}).
--- /dev/null
+%%% Copyright (c) 2007- Facebook
+%%% Distributed under the Thrift Software License
+%%%
+%%% See accompanying file LICENSE or visit the Thrift site at:
+%%% http://developers.facebook.com/thrift/
+
+-record(tSocket, {super, host, port, handle}).
--- /dev/null
+%%% Copyright (c) 2007- Facebook
+%%% Distributed under the Thrift Software License
+%%%
+%%% See accompanying file LICENSE or visit the Thrift site at:
+%%% http://developers.facebook.com/thrift/
+
+-record(tTransport, {}).
--- /dev/null
+%%% Copyright (c) 2007- Facebook
+%%% Distributed under the Thrift Software License
+%%%
+%%% See accompanying file LICENSE or visit the Thrift site at:
+%%% http://developers.facebook.com/thrift/
+
+-define(tTransportException_UNKNOWN, 0).
+-define(tTransportException_NOT_OPEN, 1).
+-define(tTransportException_ALREADY_OPEN, 2).
+-define(tTransportException_TIMED_OUT, 3).
+-define(tTransportException_END_OF_FILE, 4).
+
+-record(tTransportException, {super, type}).
--- /dev/null
+%%% Copyright (c) 2007- Facebook
+%%% Distributed under the Thrift Software License
+%%%
+%%% See accompanying file LICENSE or visit the Thrift site at:
+%%% http://developers.facebook.com/thrift/
+
+-record(tTransportFactory, {}).
--- /dev/null
+#!/bin/sh
+echo "Compiling user/ and tutorial/gen-erl/..."
+mkdir ebin-user
+erlc -I include -I tutorial/gen-erl -o ebin-user user/*.erl tutorial/gen-erl/*.erl &&
+erl -pa ebin -pa ebin-user -s application start thrift # -s nh start
--- /dev/null
+# $Id: Makefile,v 1.3 2004/08/13 16:35:59 mlogan Exp $
+#
+include ../../../build/otp.mk
+include ../../../build/colors.mk
+include ../../../build/buildtargets.mk
+
+# ----------------------------------------------------
+# Application version
+# ----------------------------------------------------
+
+include ../vsn.mk
+APP_NAME=thrift
+PFX=thrift
+VSN=$(THRIFT_VSN)
+
+# ----------------------------------------------------
+# Install directory specification
+# WARNING: INSTALL_DIR the command to install a directory.
+# INSTALL_DST is the target directory
+# ----------------------------------------------------
+INSTALL_DST = $(ERLANG_OTP)/lib/$(APP_NAME)-$(VSN)
+
+# ----------------------------------------------------
+# Target Specs
+# ----------------------------------------------------
+
+
+MODULES = $(shell find -name \*.erl | sed s:^\\./:: | sed s/\\.erl//)
+MODULES_STRING_LIST = $(shell find -name \*.erl | sed s:^\\./:\": | sed s/\\.erl/\",/)
+
+HRL_FILES=
+INTERNAL_HRL_FILES= $(APP_NAME).hrl
+ERL_FILES= $(MODULES:%=%.erl)
+DOC_FILES=$(ERL_FILES)
+
+APP_FILE= $(APP_NAME).app
+APPUP_FILE= $(APP_NAME).appup
+
+APP_SRC= $(APP_FILE).src
+APPUP_SRC= $(APPUP_FILE).src
+
+APP_TARGET= $(EBIN)/$(APP_FILE)
+APPUP_TARGET= $(EBIN)/$(APPUP_FILE)
+
+BEAMS= $(MODULES:%=$(EBIN)/%.$(EMULATOR))
+TARGET_FILES= $(BEAMS) $(APP_TARGET) $(APPUP_TARGET)
+
+WEB_TARGET=/var/yaws/www/$(APP_NAME)
+
+# ----------------------------------------------------
+# FLAGS
+# ----------------------------------------------------
+
+ERL_FLAGS +=
+ERL_COMPILE_FLAGS += -I../include -I../../fslib/include -I../../system_status/include
+
+# ----------------------------------------------------
+# Targets
+# ----------------------------------------------------
+
+all debug opt: $(EBIN) $(TARGET_FILES)
+
+#$(EBIN)/rm_logger.beam: $(APP_NAME).hrl
+include ../../../build/docs.mk
+
+# Note: In the open-source build clean must not destroy the preloaded
+# beam files.
+clean:
+ rm -f $(TARGET_FILES)
+ rm -f core
+ rm -rf $(EBIN)
+ rm -rf *html
+
+$(EBIN):
+ mkdir $(EBIN)
+
+# ----------------------------------------------------
+# Special Build Targets
+# ----------------------------------------------------
+
+$(APP_TARGET): $(APP_SRC) ../vsn.mk $(BEAMS)
+ sed -e 's;%VSN%;$(VSN);' \
+ -e 's;%PFX%;$(PFX);' \
+ -e 's;%APP_NAME%;$(APP_NAME);' \
+ -e 's;%MODULES%;%MODULES%$(MODULES_STRING_LIST);' \
+ $< > $<".tmp"
+ sed -e 's/%MODULES%\(.*\),/\1/' \
+ $<".tmp" > $@
+ rm $<".tmp"
+
+
+$(APPUP_TARGET): $(APPUP_SRC) ../vsn.mk
+ sed -e 's;%VSN%;$(VSN);' $< > $@
+
+$(WEB_TARGET): ../markup/*
+ rm -rf $(WEB_TARGET)
+ mkdir $(WEB_TARGET)
+ cp -r ../markup/ $(WEB_TARGET)
+ cp -r ../skins/ $(WEB_TARGET)
+
+# ----------------------------------------------------
+# Install Target
+# ----------------------------------------------------
+
+install: all $(WEB_TARGET)
+# $(INSTALL_DIR) $(INSTALL_DST)/src
+# $(INSTALL_DATA) $(ERL_FILES) $(INSTALL_DST)/src
+# $(INSTALL_DATA) $(INTERNAL_HRL_FILES) $(INSTALL_DST)/src
+# $(INSTALL_DIR) $(INSTALL_DST)/include
+# $(INSTALL_DATA) $(HRL_FILES) $(INSTALL_DST)/include
+# $(INSTALL_DIR) $(INSTALL_DST)/ebin
+# $(INSTALL_DATA) $(TARGET_FILES) $(INSTALL_DST)/ebin
--- /dev/null
+%%% Copyright (c) 2007- Facebook
+%%% Distributed under the Thrift Software License
+%%%
+%%% See accompanying file LICENSE or visit the Thrift site at:
+%%% http://developers.facebook.com/thrift/
+
+-module(oop).
+
+-export([get/2, set/3, call/2, call/3, inspect/1, start_new/2]).
+-export([behaviour_info/1]).
+
+-include("oop.hrl").
+
+%%%
+%%% behavior definition
+%%%
+
+behaviour_info(callbacks) ->
+ [
+ {attr, 4},
+ {super, 0}
+ ];
+behaviour_info(_) ->
+ undefined.
+
+%%
+
+-define(TRIED, lists:reverse([TryModule|TriedRev])).
+
+%% no super attr defined
+-define(NOSUPEROBJ, exit({missing_attr_super, {inspect(Obj), ?TRIED}})).
+
+-define(NOMETHOD, exit({missing_method, {Method, inspect(Obj), tl(Args), ?TRIED}})).
+
+-define(NOATTR, exit({missing_attr, {hd(tl(Args)), inspect(FirstObj), ?TRIED}})).
+
+-define(NOATTR_SET, exit({missing_attr, {Field, inspect(Obj), ".." %% TODO: give a backtrace
+ }})).
+
+
+%%% get(Obj, Field) -> term()
+%%% looks up Field in Obj or its ancestor objects
+
+get(Obj, Field) ->
+ call(Obj, attr, [get, Field, get]).
+
+set(Obj, Field, Value) -> %% TODO: could be tail-recursive
+ Module = ?CLASS(Obj),
+ try
+ Module:attr(Obj, set, Field, Value)
+ catch
+ error:Kind when Kind == undef; Kind == function_clause ->
+ case get_superobject(Obj) of
+ { ok, Superobj } ->
+ Super1 = set(Superobj, Field, Value),
+ try
+ Module:attr(Obj, set, super, Super1)
+ catch %% TODO(cpiro): remove check
+ X -> exit({burnsauce, X})
+ end;
+ none ->
+ ?NOATTR_SET
+ end
+ end.
+
+
+%%% C++ <-> Erlang
+%%% classes modules
+%%% class b : public a a:super() -> b.
+%%%
+
+get_superobject(Obj) ->
+ try
+ {ok, (?CLASS(Obj)):attr(Obj, get, super, get)}
+ catch
+ error:Kind when Kind == undef; Kind == function_clause ->
+ none
+ end.
+
+call(Obj, Method, ArgsProper) ->
+ %% io:format("call called: Obj=~p Method=~p ArgsProper=~p~n", [oop:inspect(Obj), Method, ArgsProper]),
+ Args = [Obj|ArgsProper], %% prepend This to args
+ TryModule = ?CLASS(Obj),
+ call_loop(Obj, Method, Args, TryModule, [], Obj).
+
+call(Obj, Method) ->
+ call(Obj, Method, []).
+
+call_loop(Obj, Method, Args, TryModule, TriedRev, FirstObj) ->
+ try
+ %% io:format("call_loop~n ~p~n ~p~n ~p~n ~p~n ~n", [Obj, Method, Args, TryModule]),
+ apply(TryModule, Method, Args)
+ catch
+ error:Kind when Kind == undef; Kind == function_clause ->
+ case { TryModule:super(), Method } of
+ { none, attr } ->
+ ?NOATTR;
+
+ { none, _ } ->
+ ?NOMETHOD;
+
+ { Superclass, attr } ->
+ %% look for attrs in the "super object"
+
+ case get_superobject(Obj) of
+ {ok, Superobj} when (TryModule == ?CLASS(Obj)) ->
+ %% replace This with Superobj
+ NewArgs = [Superobj|tl(Args)],
+ call_loop(Superobj, Method, NewArgs,
+ Superclass, [TryModule|TriedRev], FirstObj);
+
+ {ok, _Superobj} -> % failed guard TODO(cpiro): removeme
+ exit(oh_noes);
+
+ none -> ?NOSUPEROBJ
+ end;
+
+ { SuperClass, _ } ->
+ call_loop(Obj, Method, Args,
+ SuperClass, [TryModule|TriedRev], FirstObj)
+ end
+ end.
+
+inspect(Obj) ->
+ DeepList = inspect_loop(Obj, "#<"),
+ lists:flatten(DeepList).
+
+inspect_loop(Obj, Str) ->
+ New =
+ atom_to_list(?CLASS(Obj)) ++
+ ": " ++
+ (?CLASS(Obj)):inspect(Obj),
+
+ case get_superobject(Obj) of
+ { ok, Superobj } ->
+ inspect_loop(Superobj, Str ++ New ++ " | ");
+ none ->
+ Str ++ New ++ ">"
+ end.
+
+%% TODO: voids take only ok as return?
+start_new(Class, Args) ->
+ case gen_server:start_link(thrift_oop_server, {Class, Args}, []) of
+ {ok, Pid} ->
+ Pid
+ end.
--- /dev/null
+%%% Copyright (c) 2007- Facebook
+%%% Distributed under the Thrift Software License
+%%%
+%%% See accompanying file LICENSE or visit the Thrift site at:
+%%% http://developers.facebook.com/thrift/
+
+-module(tBinaryProtocol).
+
+-include("oop.hrl").
+
+-include("thrift.hrl").
+-include("protocol/tProtocolException.hrl").
+-include("protocol/tBinaryProtocol.hrl").
+
+-behavior(oop).
+
+-export([attr/4, super/0, inspect/1]).
+
+-export([
+ new/1,
+
+ writeMessageBegin/4,
+ writeFieldBegin/4, writeFieldStop/1,
+ writeMapBegin/4,
+ writeListBegin/3,
+ writeSetBegin/3,
+
+ writeBool/2, writeByte/2, writeI16/2, writeI32/2,
+ writeI64/2, writeDouble/2, writeString/2,
+
+ readMessageBegin/1,
+ readFieldBegin/1,
+ readMapBegin/1,
+ readListBegin/1,
+ readSetBegin/1,
+
+ readBool/1, readByte/1, readI16/1, readI32/1,
+ readI64/1, readDouble/1, readString/1
+]).
+
+%%%
+%%% define attributes
+%%% 'super' is required unless ?MODULE is a base class
+%%%
+
+?DEFINE_ATTR(super).
+
+%%%
+%%% behavior callbacks
+%%%
+
+%%% super() -> SuperModule = atom()
+%%% | none
+
+super() ->
+ tProtocol.
+
+%%% inspect(This) -> string()
+
+inspect(_This) ->
+ "".
+
+%%%
+%%% class methods
+%%%
+
+new(Trans) ->
+ Super = (super()):new(Trans),
+ #?MODULE{super=Super}.
+
+%%%
+%%% instance methods
+%%%
+
+writeMessageBegin(This, Name, Type, Seqid) ->
+ ?L1(writeI32, ?VERSION_1 bor Type),
+ ?L1(writeString, Name),
+ ?L1(writeI32, Seqid),
+ ok.
+
+writeFieldBegin(This, _Name, Type, Id) ->
+ ?L1(writeByte, Type),
+ ?L1(writeI16, Id),
+ ok.
+
+writeFieldStop(This) ->
+ ?L1(writeByte, ?tType_STOP),
+ ok.
+
+writeMapBegin(This, Ktype, Vtype, Size) ->
+ ?L1(writeByte, Ktype),
+ ?L1(writeByte, Vtype),
+ ?L1(writeI32, Size),
+ ok.
+
+writeListBegin(This, Etype, Size) ->
+ ?L1(writeByte, Etype),
+ ?L1(writeI32, Size),
+ ok.
+
+writeSetBegin(This, Etype, Size) ->
+ ?L1(writeByte, Etype),
+ ?L1(writeI32, Size),
+ ok.
+
+%
+
+writeBool(This, Bool) ->
+ case Bool of
+ true -> ?L1(writeByte, 1);
+ false -> ?L1(writeByte, 0)
+ end.
+
+writeByte(This, Byte) ->
+ Trans = oop:get(This, trans),
+ ?R1(Trans, write, binary_to_list(<<Byte:8/big>>)).
+
+writeI16(This, I16) ->
+ Trans = oop:get(This, trans),
+ ?R1(Trans, write, binary_to_list(<<I16:16/big>>)).
+
+writeI32(This, I32) ->
+ Trans = oop:get(This, trans),
+ ?R1(Trans, write, binary_to_list(<<I32:32/big>>)).
+
+writeI64(This, I64) ->
+ Trans = oop:get(This, trans),
+ ?R1(Trans, write, binary_to_list(<<I64:64/big>>)).
+
+writeDouble(This, Double) ->
+ Trans = oop:get(This, trans),
+ ?R1(Trans, write, binary_to_list(<<Double:64/big>>)).
+
+writeString(This, Str) ->
+ Trans = oop:get(This, trans),
+ ?L1(writeI32, length(Str)),
+ ?R1(Trans, write, Str).
+
+%
+
+readMessageBegin(This) ->
+ Version = ?L0(readI32),
+ if
+ (Version band ?VERSION_MASK) /= ?VERSION_1 ->
+ throw(tProtocolException:new(?tProtocolException_BAD_VERSION,
+ "Missing version identifier"));
+ true -> ok
+ end,
+ Type = Version band 16#000000ff,
+ Name = ?L0(readString),
+ Seqid = ?L0(readI32),
+ { Name, Type, Seqid }.
+
+readFieldBegin(This) ->
+ Type = ?L0(readByte),
+ case Type of
+ ?tType_STOP ->
+ { nil, Type, 0 }; % WATCH
+ _ ->
+ Id = ?L0(readI16),
+ { nil, Type, Id }
+ end.
+
+readMapBegin(This) ->
+ Ktype = ?L0(readByte),
+ Vtype = ?L0(readByte),
+ Size = ?L0(readI32),
+ { Ktype, Vtype, Size }.
+
+readListBegin(This) ->
+ Etype = ?L0(readByte),
+ Size = ?L0(readI32),
+ { Etype, Size }.
+
+readSetBegin(This) ->
+ Etype = ?L0(readByte),
+ Size = ?L0(readI32),
+ { Etype, Size }.
+
+%
+
+readBool(This) ->
+ Byte = ?L0(readByte),
+ (Byte /= 0).
+
+readByte(This) ->
+ Trans = oop:get(This, trans),
+ <<Val:8/integer-signed-big, _/binary>> = ?R1(Trans, readAll, 1),
+ Val.
+
+readI16(This) ->
+ Trans = oop:get(This, trans),
+ <<Val:16/integer-signed-big, _/binary>> = ?R1(Trans, readAll, 2),
+ Val.
+
+readI32(This) ->
+ Trans = oop:get(This, trans),
+ <<Val:32/integer-signed-big, _/binary>> = ?R1(Trans, readAll, 4),
+ Val.
+
+readI64(This) ->
+ Trans = oop:get(This, trans),
+ <<Val:64/integer-signed-big, _/binary>> = ?R1(Trans, readAll, 8),
+ Val.
+
+readDouble(This) ->
+ Trans = oop:get(This, trans),
+ <<Val:64/float-signed-big, _/binary>> = ?R1(Trans, readAll, 8),
+ Val.
+
+readString(This) ->
+ Trans = oop:get(This, trans),
+ Sz = ?L0(readI32),
+ binary_to_list(?R1(Trans, readAll, Sz)).
--- /dev/null
+%%% Copyright (c) 2007- Facebook
+%%% Distributed under the Thrift Software License
+%%%
+%%% See accompanying file LICENSE or visit the Thrift site at:
+%%% http://developers.facebook.com/thrift/
+
+-module(tBinaryProtocolFactory).
+
+-include("oop.hrl").
+
+-include("thrift.hrl").
+-include("protocol/tBinaryProtocol.hrl").
+-include("protocol/tBinaryProtocolFactory.hrl").
+
+-behavior(oop).
+
+-export([attr/4, super/0, inspect/1]).
+
+-export([new/0, getProtocol/2]).
+
+%%%
+%%% define attributes
+%%% 'super' is required unless ?MODULE is a base class
+%%%
+
+?DEFINE_ATTR(super).
+
+%%%
+%%% behavior callbacks
+%%%
+
+%%% super() -> SuperModule = atom()
+%%% | none
+
+super() ->
+ tProtocolFactory.
+
+%%% inspect(This) -> string()
+
+inspect(_This) ->
+ "".
+
+%%%
+%%% class methods
+%%%
+
+new() ->
+ Super = (super()):new(),
+ #?MODULE{super=Super}.
+
+%%%
+%%% instance methods
+%%%
+
+getProtocol(_This, Trans) ->
+ oop:start_new(tBinaryProtocol, [Trans]).
+
--- /dev/null
+%%% Copyright (c) 2007- Facebook
+%%% Distributed under the Thrift Software License
+%%%
+%%% See accompanying file LICENSE or visit the Thrift site at:
+%%% http://developers.facebook.com/thrift/
+
+-module(tProtocol).
+
+-include("oop.hrl").
+
+-include("thrift.hrl").
+-include("protocol/tProtocol.hrl").
+
+-behavior(oop).
+
+-export([attr/4, super/0, inspect/1]).
+
+%% -export([interface/1]). %%
+
+-export([
+ new/1,
+ skip/2,
+
+ writeMessageBegin/4, writeMessageEnd/1,
+ writeStructBegin/2, writeStructEnd/1,
+ writeFieldBegin/4, writeFieldEnd/1, writeFieldStop/1,
+ writeMapBegin/4, writeMapEnd/1,
+ writeListBegin/3, writeListEnd/1,
+ writeSetBegin/3, writeSetEnd/1,
+
+ writeBool/2, writeByte/2, writeI16/2, writeI32/2,
+ writeI64/2, writeDouble/2, writeString/2,
+
+ readMessageBegin/1, readMessageEnd/1,
+ readStructBegin/1, readStructEnd/1,
+ readFieldBegin/1, readFieldEnd/1,
+ readMapBegin/1, readMapEnd/1,
+ readListBegin/1, readListEnd/1,
+ readSetBegin/1, readSetEnd/1,
+
+ readBool/1, readByte/1, readI16/1, readI32/1,
+ readI64/1, readDouble/1, readString/1
+]).
+
+%%%
+%%% server interface
+%%%
+
+%% %%% modules we can instantiate from the server %%
+%% interface(subclasses) -> %%
+%% [ %%
+%% tBinaryProtocol %%
+%% ]; %%
+%% %%
+%% %%% synchronous calls to pass %%
+%% interface(call) -> %%
+%% [ %%
+%% skip, %%
+%% %%
+%% writeMessageBegin, writeMessageEnd, %%
+%% writeStructBegin, writeStructEnd, %%
+%% writeFieldBegin, writeFieldEnd, writeFieldStop, %%
+%% writeMapBegin, writeMapEnd, %%
+%% writeListBegin, writeListEnd, %%
+%% writeSetBegin, writeSetEnd, %%
+%% %%
+%% writeBool, writeByte, writeI16, writeI32, %%
+%% writeI64, writeDouble, writeString, %%
+%% %%
+%% readMessageBegin, readMessageEnd, %%
+%% readStructBegin, readStructEnd, %%
+%% readFieldBegin, readFieldEnd, %%
+%% readMapBegin, readMapEnd, %%
+%% readListBegin, readListEnd, %%
+%% readSetBegin, readSetEnd, %%
+%% %%
+%% readBool, readByte, readI16, readI32, %%
+%% readI64, readDouble, readString %%
+%% ]; %%
+%% %%
+%% %%% asynchronous casts to pass %%
+%% interface(cast) -> %%
+%% []. %%
+
+%%%
+%%% define attributes
+%%% 'super' is required unless ?MODULE is a base class
+%%%
+
+?DEFINE_ATTR(trans).
+
+%%%
+%%% behavior callbacks
+%%%
+
+%%% super() -> SuperModule = atom()
+%%% | none
+
+super() ->
+ none.
+
+%%% inspect(This) -> string()
+
+inspect(This) ->
+ ?FORMAT_ATTR(trans).
+
+%%%
+%%% class methods
+%%%
+
+new(Trans) ->
+ #?MODULE{trans=Trans}.
+
+%%%
+%%% instance methods
+%%%
+
+writeMessageBegin(_This, _Name, _Type, _Seqid) -> ok.
+writeMessageEnd(_This) -> ok.
+writeStructBegin(_This, _Name) -> ok.
+writeStructEnd(_This) -> ok.
+writeFieldBegin(_This, _Name, _Type, _Id) -> ok.
+writeFieldEnd(_This) -> ok.
+writeFieldStop(_This) -> ok.
+writeMapBegin(_This, _Ktype, _Vtype, _Size) -> ok.
+writeMapEnd(_This) -> ok.
+writeListBegin(_This, _Etype, _Size) -> ok.
+writeListEnd(_This) -> ok.
+writeSetBegin(_This, _Etype, _Size) -> ok.
+writeSetEnd(_This) -> ok.
+
+writeBool(_This, _Value) -> ok.
+writeByte(_This, _Value) -> ok.
+writeI16(_This, _Value) -> ok.
+writeI32(_This, _Value) -> ok.
+writeI64(_This, _Value) -> ok.
+writeDouble(_This, _Value) -> ok.
+writeString(_This, _Value) -> ok.
+
+readMessageBegin(_This) -> ok.
+readMessageEnd(_This) -> ok.
+readStructBegin(_This) -> ok.
+readStructEnd(_This) -> ok.
+readFieldBegin(_This) -> ok.
+readFieldEnd(_This) -> ok.
+readMapBegin(_This) -> ok.
+readMapEnd(_This) -> ok.
+readListBegin(_This) -> ok.
+readListEnd(_This) -> ok.
+readSetBegin(_This) -> ok.
+readSetEnd(_This) -> ok.
+
+readBool(_This) -> ok.
+readByte(_This) -> ok.
+readI16(_This) -> ok.
+readI32(_This) -> ok.
+readI64(_This) -> ok.
+readDouble(_This) -> ok.
+readString(_This) -> ok.
+
+skip(This, Type) ->
+ case Type of
+ ?tType_STOP -> nil; % WATCH
+ ?tType_BOOL -> ?L0(readBool);
+ ?tType_BYTE -> ?L0(readByte);
+ ?tType_I16 -> ?L0(readI16);
+ ?tType_I32 -> ?L0(readI32);
+ ?tType_I64 -> ?L0(readI64);
+ ?tType_DOUBLE -> ?L0(readDouble);
+ ?tType_STRING -> ?L0(readString);
+
+ ?tType_STRUCT ->
+ ?L0(readStructBegin),
+ skip_struct_loop(This),
+
+ %% cpiro: this isn't here in the original tprotocol.rb, but i think it's a bug
+ ?L0(readStructEnd);
+
+ ?tType_MAP ->
+ {Ktype, Vtype, Size} = ?L0(readMapBegin),
+ skip_map_repeat(This, Ktype, Vtype, Size),
+ ?L0(readMapEnd);
+
+ ?tType_SET ->
+ {Etype, Size} = ?L0(readSetBegin),
+ skip_set_repeat(This, Etype, Size),
+ ?L0(readSetEnd);
+
+ ?tType_LIST ->
+ {Etype, Size} = ?L0(readListBegin),
+ skip_set_repeat(This, Etype, Size), % [sic] skipping same as for SET
+ ?L0(readListEnd)
+ end.
+
+skip_struct_loop(This) ->
+ { _Name, Type, _Id } = ?L0(readFieldBegin),
+ if
+ Type == ?tType_STOP ->
+ ok;
+
+ true ->
+ ?L1(skip, Type),
+ ?L0(readFieldEnd),
+
+ %% cpiro: this is here in original tprotocol.rb, but i think it's a bug
+ % ?L0(readStructEnd),
+ skip_struct_loop(This)
+ end.
+
+skip_map_repeat(This, Ktype, Vtype, Times) ->
+ ?L1(skip, Ktype),
+ ?L1(skip, Vtype),
+ skip_map_repeat(This, Ktype, Vtype, Times-1).
+
+skip_set_repeat(This, Etype, Times) ->
+ ?L1(skip, Etype),
+ skip_set_repeat(This, Etype, Times-1).
--- /dev/null
+%%% Copyright (c) 2007- Facebook
+%%% Distributed under the Thrift Software License
+%%%
+%%% See accompanying file LICENSE or visit the Thrift site at:
+%%% http://developers.facebook.com/thrift/
+
+-module(tProtocolException).
+
+-include("oop.hrl").
+
+-include("thrift.hrl").
+-include("protocol/tProtocolException.hrl").
+
+-behavior(oop).
+
+-export([attr/4, super/0, inspect/1]).
+
+-export([new/0, new/1, new/2]).
+
+%%%
+%%% define attributes
+%%% 'super' is required unless ?MODULE is a base class
+%%%
+
+?DEFINE_ATTR(super);
+?DEFINE_ATTR(type).
+
+%%%
+%%% behavior callbacks
+%%%
+
+%%% super() -> SuperModule = atom()
+%%% | none
+
+super() ->
+ tException.
+
+%%% inspect(This) -> string()
+
+inspect(This) ->
+ ?FORMAT_ATTR(type).
+
+%%%
+%%% class methods
+%%%
+
+new(Type, Message) ->
+ Super = (super()):new(Message),
+ #?MODULE{super=Super, type=Type}.
+
+new() ->
+ new(?tProtocolException_UNKNOWN, undefined).
+new(Type) ->
+ new(Type, undefined).
+
+%%%
+%%% instance methods
+%%%
--- /dev/null
+%%% Copyright (c) 2007- Facebook
+%%% Distributed under the Thrift Software License
+%%%
+%%% See accompanying file LICENSE or visit the Thrift site at:
+%%% http://developers.facebook.com/thrift/
+
+-module(tProtocolFactory).
+
+-include("oop.hrl").
+
+-include("thrift.hrl").
+-include("protocol/tProtocolFactory.hrl").
+
+-behavior(oop).
+
+-export([attr/4, super/0, inspect/1]).
+
+-export([new/0, getProtocol/2]).
+
+%%%
+%%% define attributes
+%%% 'super' is required unless ?MODULE is a base class
+%%%
+
+?ATTR_DUMMY.
+
+%%%
+%%% behavior callbacks
+%%%
+
+%%% super() -> SuperModule = atom()
+%%% | none
+
+super() ->
+ none.
+
+%%% inspect(This) -> string()
+
+inspect(_This) ->
+ "".
+
+%%%
+%%% class methods
+%%%
+
+new() ->
+ #?MODULE{}.
+
+%%%
+%%% instance methods
+%%%
+
+getProtocol(This, Trans) ->
+ nil.
--- /dev/null
+%%% Copyright (c) 2007- Facebook
+%%% Distributed under the Thrift Software License
+%%%
+%%% See accompanying file LICENSE or visit the Thrift site at:
+%%% http://developers.facebook.com/thrift/
+
+-module(tErlServer).
+
+-include("oop.hrl").
+
+-include("thrift.hrl").
+-include("transport/tTransportException.hrl").
+-include("server/tErlServer.hrl").
+
+-behavior(oop).
+
+-export([attr/4, super/0, inspect/1]).
+
+-export([new/6, new/5, new/4, effectful_serve/1, effectful_new_acceptor/1, catches/3]).
+
+%%%
+%%% define attributes
+%%% 'super' is required unless ?MODULE is a base class
+%%%
+
+?DEFINE_ATTR(super);
+?DEFINE_ATTR(acceptor);
+?DEFINE_ATTR(listenSocket);
+?DEFINE_ATTR(port).
+
+%%%
+%%% behavior callbacks
+%%%
+
+%%% super() -> SuperModule = atom()
+%%% | none
+
+super() ->
+ tServer.
+
+%%% inspect(This) -> string()
+
+inspect(This) ->
+ ?FORMAT_ATTR(acceptor) ++ ", " ++
+ ?FORMAT_ATTR(listenSocket) ++ ", " ++
+ ?FORMAT_ATTR(port).
+
+%%%
+%%% class methods
+%%%
+
+new(Port, Handler, Processor, ServerTransport, TransportFactory, ProtocolFactory) ->
+ Super = (super()):new(Handler, Processor, ServerTransport, TransportFactory, ProtocolFactory),
+ #?MODULE{super=Super, port=Port, listenSocket=nil, acceptor=nil}.
+
+new(Port, Handler, Processor, ServerTransport) ->
+ new(Port, Handler, Processor, ServerTransport, nil, nil).
+
+new(Port, Handler, Processor, ServerTransport, TransportFactory) ->
+ new(Port, Handler, Processor, ServerTransport, TransportFactory, nil).
+
+% listenSocket, acceptor, port
+
+effectful_serve(This) ->
+ Port = oop:get(This, port),
+
+ Options = [binary, {packet, 0}, {active, false}],
+
+ %% listen
+ case gen_tcp:listen(Port, Options) of
+ {ok, ListenSocket} ->
+
+ This1 = oop:set(This, listenSocket, ListenSocket),
+
+ %% spawn acceptor
+ {_Acceptor, This2} = effectful_new_acceptor(This1),
+
+ {ok, This2}
+ end.
+
+effectful_new_acceptor(This) ->
+ ListenSocket = oop:get(This, listenSocket),
+ Processor = oop:get(This, processor), %% cpiro: generated processor, not the "actual" processor
+ Handler = oop:get(This, handler),
+
+ TF = oop:get(This, transportFactory),
+ PF = oop:get(This, protocolFactory),
+
+ tErlAcceptor = oop:get(This, serverTransport), %% cpiro: only supported ServerTransport
+
+ ServerPid = self(),
+ Acceptor = oop:start_new(tErlAcceptor, [ServerPid, TF, PF]),
+ ?C3(Acceptor, accept, ListenSocket, Processor, Handler),
+
+ This1 = oop:set(This, acceptor, Acceptor),
+
+ {Acceptor, This1}.
+
+catches(This, Pid, acceptor_done) ->
+ ok.
+
+%% %% The current acceptor has died, wait a little and try again %%
+%% handle_info({'EXIT', Pid, _Abnormal}, #state{acceptor=Pid} = State) -> %%
+%% timer:sleep(2000), %%
+%% iserve_socket:start_link(self(), State#state.listen_socket, State#state.port), %%
+%% {noreply,State}; %%
+
+%% terminate(Reason, State) -> %%
+%% error_logger:info_msg( "Terminating error: ~p~n", [Reason]), % added %%
+%% gen_tcp:close(State#state.listen_socket), %%
+%% ok. %%
+%% %%
--- /dev/null
+%%% Copyright (c) 2007- Facebook
+%%% Distributed under the Thrift Software License
+%%%
+%%% See accompanying file LICENSE or visit the Thrift site at:
+%%% http://developers.facebook.com/thrift/
+
+-module(tServer).
+
+-include("oop.hrl").
+
+-include("thrift.hrl").
+-include("server/tServer.hrl").
+-include("transport/tTransportFactory.hrl").
+-include("protocol/tBinaryProtocolFactory.hrl").
+
+-behavior(oop).
+
+-export([attr/4, super/0, inspect/1]).
+
+-export([new/5, new/4, new/3, serve/1]).
+
+%%%
+%%% define attributes
+%%% 'super' is required unless ?MODULE is a base class
+%%%
+
+?DEFINE_ATTR(handler);
+?DEFINE_ATTR(processor);
+?DEFINE_ATTR(serverTransport);
+?DEFINE_ATTR(transportFactory);
+?DEFINE_ATTR(protocolFactory).
+
+%%%
+%%% behavior callbacks
+%%%
+
+%%% super() -> SuperModule = atom()
+%%% | none
+
+super() ->
+ none.
+
+%%% inspect(This) -> string()
+
+inspect(This) ->
+ ?FORMAT_ATTR(handler) ++ ", " ++
+ ?FORMAT_ATTR(processor) ++ ", " ++
+ ?FORMAT_ATTR(serverTransport) ++ ", " ++
+ ?FORMAT_ATTR(transportFactory) ++ ", " ++
+ ?FORMAT_ATTR(protocolFactory).
+
+%%%
+%%% class methods
+%%%
+
+new(Handler, Processor, ServerTransport, TransportFactory, ProtocolFactory) ->
+ #?MODULE{handler=Handler, processor=Processor, serverTransport=ServerTransport,
+
+ %% much ado about nothing but
+ %% subclasses pass nil too
+ transportFactory =
+ case TransportFactory of
+ nil -> tTransportFactory:new();
+ _ -> TransportFactory
+ end,
+
+ protocolFactory =
+ case ProtocolFactory of
+ nil -> tBinaryProtocolFactory:new();
+ _ -> ProtocolFactory
+ end
+}.
+
+new(Handler, Processor, ServerTransport) ->
+ new(Handler, Processor, ServerTransport, nil, nil).
+
+new(Handler, Processor, ServerTransport, TransportFactory) ->
+ new(Handler, Processor, ServerTransport, TransportFactory, nil).
+
+serve(_This) ->
+ ok.
--- /dev/null
+%%% Copyright (c) 2007- Facebook
+%%% Distributed under the Thrift Software License
+%%%
+%%% See accompanying file LICENSE or visit the Thrift site at:
+%%% http://developers.facebook.com/thrift/
+
+-module(tSimpleServer).
+
+-include("oop.hrl").
+
+-include("thrift.hrl").
+-include("transport/tTransportException.hrl").
+-include("server/tSimpleServer.hrl").
+
+-behavior(oop).
+
+-export([attr/4, super/0, inspect/1]).
+
+-export([new/5, new/4, new/3, serve/1]).
+
+%%%
+%%% define attributes
+%%% 'super' is required unless ?MODULE is a base class
+%%%
+
+?DEFINE_ATTR(super).
+
+%%%
+%%% behavior callbacks
+%%%
+
+%%% super() -> SuperModule = atom()
+%%% | none
+
+super() ->
+ tServer.
+
+%%% inspect(This) -> string()
+
+inspect(_This) ->
+ "".
+
+%%%
+%%% class methods
+%%%
+
+new(Handler, Processor, ServerTransport, TransportFactory, ProtocolFactory) ->
+ Super = (super()):new(Handler, Processor, ServerTransport, TransportFactory, ProtocolFactory),
+ #?MODULE{super=Super}.
+
+new(Handler, Processor, ServerTransport) ->
+ new(Handler, Processor, ServerTransport, nil, nil).
+
+new(Handler, Processor, ServerTransport, TransportFactory) ->
+ new(Handler, Processor, ServerTransport, TransportFactory, nil).
+
+%
+
+serve(This) ->
+ ST = oop:get(This, serverTransport),
+ ?R0(ST, effectful_listen),
+
+ serve_loop(This).
+
+serve_loop(This) ->
+ io:format("~nready.~n", []),
+
+ ST = oop:get(This, serverTransport),
+ Client = ?RT0(ST, accept, infinity),
+
+ TF = oop:get(This, transportFactory),
+ Trans = ?F1(TF, getTransport, Client), %% cpiro: OPAQUE!! Trans = Client
+
+ PF = oop:get(This, protocolFactory),
+ Prot = ?F1(PF, getProtocol, Trans), %% cpiro: OPAQUE!! Prot = start_new(tBinaryProtocol, [Trans])
+
+ io:format("client accept()ed~n", []),
+
+ serve_loop_loop(This, Prot), % giggle loop?
+
+ ?R0(Trans, effectful_close),
+
+ serve_loop(This).
+
+serve_loop_loop(This, Prot) ->
+ Next =
+ try
+ Handler = oop:get(This, handler),
+ Processor = oop:get(This, processor),
+ Val = apply(Processor, process, [Handler, Prot, Prot]), %% TODO(cpiro): make processor a gen_server instance
+ io:format("request processed: rv=~p~n", [Val]),
+ loop
+ catch
+ %% TODO(cpiro) case when is_record(...) to pick out our exception
+ %% records vs. normal erlang throws
+ E when is_record(E, tTransportException) ->
+ io:format("tTransportException (normal-ish?)~n", []),
+ close;
+ F ->
+ io:format("EXCEPTION: ~p~n", [F]),
+ close
+ end,
+ case Next of
+ loop -> serve_loop_loop(This, Prot);
+ close -> ok
+ end.
--- /dev/null
+%%% Copyright (c) 2007- Facebook
+%%% Distributed under the Thrift Software License
+%%%
+%%% See accompanying file LICENSE or visit the Thrift site at:
+%%% http://developers.facebook.com/thrift/
+
+-module(tApplicationException).
+
+-include("thrift.hrl").
+-include("tApplicationException.hrl").
+
+-include("oop.hrl").
+
+-behavior(oop).
+
+-export([attr/4, super/0, inspect/1]).
+
+-export([new/0, new/1, new/2, read/2, write/2]).
+
+%%%
+%%% define attributes
+%%% 'super' is required unless ?MODULE is a base class
+%%%
+
+?DEFINE_ATTR(super);
+?DEFINE_ATTR(type).
+
+%%%
+%%% behavior callbacks
+%%%
+
+%%% super() -> SuperModule = atom()
+%%% | none
+
+super() ->
+ tException.
+
+%%% inspect(This) -> string()
+
+inspect(This) ->
+ ?FORMAT_ATTR(type).
+
+%%%
+%%% class methods
+%%%
+
+new(Type, Message) ->
+ Super = (super()):new(Message),
+ #?MODULE{super=Super, type=Type}.
+
+new() -> new(?tApplicationException_UNKNOWN, undefined).
+new(Type) -> new(Type, undefined).
+
+%%%
+%%% instance methods
+%%%
+
+read(This, Iprot) ->
+ ?R0(Iprot, readStructBegin),
+ read_while_loop(This, Iprot),
+ ?R0(Iprot, readStructEnd),
+ ok.
+
+read_while_loop(This, Iprot) ->
+ {_Fname, Ftype, Fid} = ?R0(Iprot, readFieldBegin),
+
+ if
+ Ftype == ?tType_STOP ->
+ ok;
+
+ (Fid == 1) and (Ftype == ?tType_STRING) ->
+ Message1 = ?R0(Iprot, readString),
+ This1 = oop:set(This, message, Message1),
+ ?R0(Iprot, readFieldEnd),
+ read_while_loop(This1, Iprot);
+
+ Fid == 1 ->
+ ?R0(Iprot, skip),
+ ?R0(Iprot, readFieldEnd),
+ read_while_loop(This, Iprot);
+
+ (Fid == 2) and (Ftype == ?tType_I32) ->
+ Type1 = ?R0(Iprot, readI32),
+ This1 = oop:set(This, type, Type1),
+ ?R0(Iprot, readFieldEnd),
+ read_while_loop(This1, Iprot);
+
+ true ->
+ ?R0(Iprot, skip),
+ ?R0(Iprot, readFieldEnd),
+ read_while_loop(This, Iprot)
+ end.
+
+write(This, Oprot) ->
+ ?R1(Oprot, writeStructBegin, "tApplicationException"),
+ Message = oop:get(This, message),
+ Type = oop:get(This, type),
+
+ if Message /= undefined ->
+ ?R3(Oprot, writeFieldBegin, "message", ?tType_STRING, 1),
+ ?R1(Oprot, writeString, Message),
+ ?R0(Oprot, writeFieldEnd);
+ true -> ok
+ end,
+
+ if Type /= undefined ->
+ ?R3(Oprot, writeFieldBegin, "type", ?tType_I32, 2),
+ ?R1(Oprot, writeI32, Type),
+ ?R0(Oprot, writeFieldEnd);
+ true -> ok
+ end,
+
+ ?R0(Oprot, writeFieldStop),
+ ?R0(Oprot, writeStructEnd),
+ ok.
--- /dev/null
+%%% Copyright (c) 2007- Facebook
+%%% Distributed under the Thrift Software License
+%%%
+%%% See accompanying file LICENSE or visit the Thrift site at:
+%%% http://developers.facebook.com/thrift/
+
+-module(tErlProcessor).
+
+-include("oop.hrl").
+-include("tErlProcessor.hrl").
+
+-behavior(oop).
+
+-export([attr/4, super/0, inspect/1]).
+
+-export([new/2, process/3]).
+
+%%%
+%%% define attributes
+%%% 'super' is required unless ?MODULE is a base class
+%%%
+
+?DEFINE_ATTR(super);
+?DEFINE_ATTR(generatedProcessor);
+?DEFINE_ATTR(handler).
+
+%%%
+%%% behavior callbacks
+%%%
+
+%%% super() -> SuperModule = atom()
+%%% | none
+
+super() ->
+ tProcessor.
+
+%%% inspect(This) -> string()
+
+inspect(This) ->
+ ?FORMAT_ATTR(generatedProcessor) ++ ", " ++
+ ?FORMAT_ATTR(handler).
+
+%%%
+%%% class methods
+%%%
+
+new(GP, Handler) ->
+ Super = (super()):new(),
+ #?MODULE{super = Super, generatedProcessor = GP, handler = Handler}.
+
+%% processor is generated code
+%% handler is user code
+
+%%%
+%%% instance methods
+%%%
+
+process(This, Iprot, Oprot) ->
+ GP = oop:get(This, generatedProcessor),
+ Handler = oop:get(This, handler),
+
+ apply(GP, process, [Handler, Iprot, Oprot]).
--- /dev/null
+%%% Copyright (c) 2007- Facebook
+%%% Distributed under the Thrift Software License
+%%%
+%%% See accompanying file LICENSE or visit the Thrift site at:
+%%% http://developers.facebook.com/thrift/
+
+-module(tException).
+
+-include("oop.hrl").
+-include("tException.hrl").
+
+-behavior(oop).
+
+-export([attr/4, super/0, inspect/1]).
+
+-export([new/1]).
+
+%%%
+%%% define attributes
+%%% 'super' is required unless ?MODULE is a base class
+%%%
+
+?DEFINE_ATTR(message).
+
+%%%
+%%% behavior callbacks
+%%%
+
+%%% super() -> SuperModule = atom()
+%%% | none
+
+super() ->
+ none.
+
+%%% inspect(This) -> string()
+
+inspect(This) ->
+ ?FORMAT_ATTR(message).
+
+%%%
+%%% class methods
+%%%
+
+new(Message) ->
+ #?MODULE{message=Message}.
+
+%%%
+%%% instance methods
+%%%
+
--- /dev/null
+%%% Copyright (c) 2007- Facebook
+%%% Distributed under the Thrift Software License
+%%%
+%%% See accompanying file LICENSE or visit the Thrift site at:
+%%% http://developers.facebook.com/thrift/
+
+-module(tProcessor).
+
+-include("oop.hrl").
+-include("tProcessor.hrl").
+
+-behavior(oop).
+
+-export([attr/4, super/0, inspect/1]).
+
+-export([new/0]).
+
+%%%
+%%% define attributes
+%%% 'super' is required unless ?MODULE is a base class
+%%%
+
+?ATTR_DUMMY.
+
+%%%
+%%% behavior callbacks
+%%%
+
+%%% super() -> SuperModule = atom()
+%%% | none
+
+super() ->
+ none.
+
+%%% inspect(This) -> string()
+
+inspect(_This) ->
+ "".
+
+%%%
+%%% class methods
+%%%
+
+new() ->
+ #?MODULE{}.
+
+%%%
+%%% instance methods
+%%%
+
--- /dev/null
+%%% -*- mode:erlang -*-
+{application, %APP_NAME%,
+ [
+ % A quick description of the application.
+ {description, "Thrift bindings"},
+
+ % The version of the applicaton
+ {vsn, "%VSN%"},
+
+ % All modules used by the application.
+ {modules,
+ [
+ %MODULES%
+ ]},
+
+ % All of the registered names the application uses. This can be ignored.
+ {registered, []},
+
+ % Applications that are to be started prior to this one. This can be ignored
+ % leave it alone unless you understand it well and let the .rel files in
+ % your release handle this.
+ {applications,
+ [
+ kernel,
+ stdlib
+ ]},
+
+ % OTP application loader will load, but not start, included apps. Again
+ % this can be ignored as well. To load but not start an application it
+ % is easier to include it in the .rel file followed by the atom 'none'
+ {included_applications, []},
+
+ % configuration parameters similar to those in the config file specified
+ % on the command line. can be fetched with gas:get_env
+ {env, []},
+
+ % The Module and Args used to start this application.
+ {mod, {%APP_NAME%, []}}
+ ]
+}.
+
--- /dev/null
+{"%VSN%",[],[]}.
--- /dev/null
+%%% Copyright (c) 2007- Facebook
+%%% Distributed under the Thrift Software License
+%%%
+%%% See accompanying file LICENSE or visit the Thrift site at:
+%%% http://developers.facebook.com/thrift/
+
+%%%-------------------------------------------------------------------
+%%% @doc
+%%% @end
+%%%-------------------------------------------------------------------
+-module(thrift_oop_server).
+
+-behaviour(gen_server).
+%%--------------------------------------------------------------------
+%% Include files
+%%--------------------------------------------------------------------
+-include("oop.hrl").
+
+-include("thrift.hrl").
+
+%%--------------------------------------------------------------------
+%% External exports
+%%--------------------------------------------------------------------
+-export([
+ start_link/0,
+ stop/0
+ ]).
+
+%%--------------------------------------------------------------------
+%% gen_server callbacks
+%%--------------------------------------------------------------------
+-export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2, code_change/3]).
+
+%%--------------------------------------------------------------------
+%% record definitions
+%%--------------------------------------------------------------------
+
+%%--------------------------------------------------------------------
+%% macro definitions
+%%--------------------------------------------------------------------
+-define(SERVER, ?MODULE).
+
+%%====================================================================
+%% External functions
+%%====================================================================
+%%--------------------------------------------------------------------
+%% @doc Starts the server.
+%% @spec start_link() -> {ok, pid()} | {error, Reason}
+%% @end
+%%--------------------------------------------------------------------
+start_link() ->
+ gen_server:start_link({local, ?SERVER}, ?MODULE, [], []).
+
+%%--------------------------------------------------------------------
+%% @doc Stops the server.
+%% @spec stop() -> ok
+%% @end
+%%--------------------------------------------------------------------
+stop() ->
+ gen_server:cast(?SERVER, stop).
+
+%%====================================================================
+%% Server functions
+%%====================================================================
+
+%%--------------------------------------------------------------------
+%% Function: init/1
+%% Description: Initiates the server
+%% Returns: {ok, State} |
+%% {ok, State, Timeout} |
+%% ignore |
+%% {stop, Reason}
+%%--------------------------------------------------------------------
+
+unparenth(Args) ->
+ Args.
+
+init({Class, Args}) ->
+ process_flag(trap_exit, true),
+ if
+ true -> % lists:member(Class, Class:interface(subclasses)) ->
+ io:format("oop_server init: ~p := ~p:new(~p)~n", [self(), Class, unparenth(Args)]),
+ State = apply(Class, new, Args), % TODO(cpiro): try catch?
+ io:format(" =>~p~n", [oop:inspect(State)]),
+ {ok, State}
+
+ %% true -> %%
+ %% {stop, invalid_subclass} %%
+ end;
+init(_) ->
+ {stop, invalid_params}.
+
+%%--------------------------------------------------------------------
+%% Function: handle_call/3
+%% Description: Handling call messages
+%% Returns: {reply, Reply, State} |
+%% {reply, Reply, State, Timeout} |
+%% {noreply, State} |
+%% {noreply, State, Timeout} |
+%% {stop, Reason, Reply, State} | (terminate/2 is called)
+%% {stop, Reason, State} (terminate/2 is called)
+%%--------------------------------------------------------------------
+
+handle_call(Request, From, State) ->
+ handle_either(call, Request, From, State).
+
+%%--------------------------------------------------------------------
+%% Function: handle_cast/2
+%% Description: Handling cast messages
+%% Returns: {noreply, State} |
+%% {noreply, State, Timeout} |
+%% {stop, Reason, State} (terminate/2 is called)
+%%--------------------------------------------------------------------
+
+handle_cast(stop, State) ->
+ {stop, normal, State};
+
+handle_cast({Method, Args}, State) ->
+ handle_either(cast, {Method, Args}, undefined, State).
+
+-define(REPLY(Value, State),
+ case Type of
+ call -> {reply, Value, State};
+ cast -> {noreply, State}
+ end
+).
+
+handle_either(Type, Request, From, State) ->
+ %% io:format("~p: ~p~n", [?SERVER, oop:inspect(State)]),
+ %% io:format(" handle_call(Request=~p, From=~p, State)~n", [Request, From]),
+
+ case Request of
+ {get, [Field]} ->
+ Value = oop:get(State, Field),
+ ?REPLY(Value, State);
+
+ {set, [Field, Value]} ->
+ State1 = oop:set(State, Field, Value),
+ ?REPLY(Value, State1);
+
+ {Method, Args} ->
+ handle_method(Type, State, Method, Args);
+
+ _ ->
+ io:format(" ERROR: Request = ~p nomatch {Method, Args}~n", [Request]),
+ %% {stop, server_error, State}
+ {reply, server_error, State}
+ end.
+
+handle_method(Type, State, Method, Args) ->
+ %% is an effectful call?
+ Is_effectful = lists:prefix("effectful_", atom_to_list(Method)),
+ Call = oop:call(State, Method, Args),
+
+ %% TODO(cpiro): maybe add error handling here? = catch oop:call?
+
+ case {Is_effectful, Call} of
+ {true, {Retval, State1}} ->
+ ?REPLY(Retval, State1);
+
+ {true, _MalformedReturn} ->
+ %% TODO(cpiro): bad match -- remove when we're done converting
+ io:format(" ERROR: oop:call(effectful_*,..,..) malformed return value ~p~n",
+ [_MalformedReturn]),
+ %% {stop, server_error, State}
+ {noreply, State};
+
+ {false, Retval} ->
+ ?REPLY(Retval, State)
+ end.
+
+%%--------------------------------------------------------------------
+%% Function: handle_info/2
+%% Description: Handling all non call/cast messages
+%% Returns: {noreply, State} |
+%% {noreply, State, Timeout} |
+%% {stop, Reason, State} (terminate/2 is called)
+%%--------------------------------------------------------------------
+handle_info({'EXIT', Pid, Except} = All, State) ->
+ case catch oop:call(State, catches, [Pid, Except]) of
+ {'EXIT', MM} when element(1,MM) == missing_method ->
+ io:format("UNHANDLED ~p by ~p!~n", [All, self()]),
+ %% not caught
+ {stop, All, State};
+ _IsCaught ->
+ %% caught and handled
+ {noreply, State}
+ end;
+
+handle_info(Info, State) ->
+ io:format("~p infoED!: ~p~n", [self(), Info]),
+ {noreply, State}.
+
+%%--------------------------------------------------------------------
+%% Function: terminate/2
+%% Description: Shutdown the server
+%% Returns: any (ignored by gen_server)
+%%--------------------------------------------------------------------
+terminate(Reason, State) ->
+ io:format("~p terminated!: ~p~n", [self(), Reason]),
+ ok.
+
+%%--------------------------------------------------------------------
+%% Func: code_change/3
+%% Purpose: Convert process state when code is changed
+%% Returns: {ok, NewState}
+ %%--------------------------------------------------------------------
+code_change(OldVsn, State, Extra) ->
+ {ok, State}.
+
+%%====================================================================
+%%% Internal functions
+%%====================================================================
--- /dev/null
+%%% Copyright (c) 2007- Facebook
+%%% Distributed under the Thrift Software License
+%%%
+%%% See accompanying file LICENSE or visit the Thrift site at:
+%%% http://developers.facebook.com/thrift/
+
+-module(tBufferedTransport).
+
+-include("oop.hrl").
+
+-include("thrift.hrl").
+-include("transport/tBufferedTransport.hrl").
+
+-behavior(oop).
+
+-export([attr/4, super/0, inspect/1]).
+
+-export([new/1, isOpen/1, open/1, close/1, read/2, effectful_write/2, effectful_flush/1]).
+
+%%%
+%%% define attributes
+%%% 'super' is required unless ?MODULE is a base class
+%%%
+
+?DEFINE_ATTR(super);
+?DEFINE_ATTR(transport);
+?DEFINE_ATTR(wbuf).
+
+%%%
+%%% behavior callbacks
+%%%
+
+%%% super() -> SuperModule = atom()
+%%% | none
+
+super() ->
+ tTransport.
+
+%%% inspect(This) -> string()
+
+inspect(This) ->
+ ?FORMAT_ATTR(transport) ++
+ ?FORMAT_ATTR(wbuf).
+
+%%%
+%%% class methods
+%%%
+
+new(Transport) ->
+ Super = (super()):new(),
+ #?MODULE{super=Super, transport=Transport, wbuf=""}.
+
+%%%
+%%% instance methods
+%%%
+
+isOpen(This) ->
+ Transport = oop:get(This, transport),
+ ?R0(Transport, isOpen).
+
+open(This) ->
+ Transport = oop:get(This, transport),
+ ?R0(Transport, open).
+
+close(This) ->
+ Transport = oop:get(This, transport),
+ ?R0(Transport, close).
+
+read(This, Sz) ->
+ Transport = oop:get(This, transport),
+ ?R1(Transport, read, Sz).
+
+effectful_write(This, Buf) -> % be sure to rebind This to the retval
+ Wbuf = oop:get(This, wbuf),
+ This1 = oop:set(This, wbuf, Wbuf++Buf), % TODO: ++ efficiency?
+ {ok, This1}.
+
+effectful_flush(This) ->
+ Wbuf = oop:get(This, wbuf),
+ Transport = oop:get(This, transport),
+ ?R1(Transport, effectful_write, Wbuf),
+ ?R0(Transport, effectful_flush),
+ This1 = oop:set(This, wbuf, ""),
+ {ok, This1}.
--- /dev/null
+%%% Copyright (c) 2007- Facebook
+%%% Distributed under the Thrift Software License
+%%%
+%%% See accompanying file LICENSE or visit the Thrift site at:
+%%% http://developers.facebook.com/thrift/
+
+-module(tBufferedTransportFactory).
+
+-include("oop.hrl").
+-include("transport/tBufferedTransport.hrl").
+-include("transport/tBufferedTransportFactory.hrl").
+
+-behavior(oop).
+
+-export([attr/4, super/0, inspect/1]).
+
+-export([new/0, getTransport/2]).
+
+%%%
+%%% define attributes
+%%% 'super' is required unless ?MODULE is a base class
+%%%
+
+?ATTR_DUMMY.
+
+%%%
+%%% behavior callbacks
+%%%
+
+%%% super() -> SuperModule = atom()
+%%% | none
+
+super() ->
+ tTransportFactory.
+
+%%% inspect(This) -> string()
+
+inspect(_This) ->
+ "".
+
+%%%
+%%% class methods
+%%%
+
+new() ->
+ Super = (super()):new(),
+ #?MODULE{super=Super}.
+
+%%%
+%%% instance methods
+%%%
+
+getTransport(_This, Trans) ->
+ gen_server:start_link(tBufferedTransport, {new, [Trans]}).
--- /dev/null
+%%% Copyright (c) 2007- Facebook
+%%% Distributed under the Thrift Software License
+%%%
+%%% See accompanying file LICENSE or visit the Thrift site at:
+%%% http://developers.facebook.com/thrift/
+
+-module(tErlAcceptor).
+
+-include("oop.hrl").
+-include("thrift.hrl").
+-include("transport/tTransportException.hrl").
+-include("transport/tServerSocket.hrl").
+-include("transport/tErlAcceptor.hrl").
+
+-behavior(oop).
+
+-export([attr/4, super/0, inspect/1]).
+
+-export([new/3, accept/4]).
+
+%%%
+%%% define attributes
+%%% 'super' is required unless ?MODULE is a base class
+%%%
+
+?DEFINE_ATTR(super);
+?DEFINE_ATTR(serverPid);
+?DEFINE_ATTR(transportFactory);
+?DEFINE_ATTR(protocolFactory).
+
+%%%
+%%% behavior callbacks
+%%%
+
+%%% super() -> SuperModule = atom()
+%%% | none
+
+super() ->
+ tServerTransport.
+
+%%% inspect(This) -> string()
+
+inspect(This) ->
+ ?FORMAT_ATTR(serverPid) ++ ", " ++
+ ?FORMAT_ATTR(transportFactory) ++ ", " ++
+ ?FORMAT_ATTR(protocolFactory).
+
+%%%
+%%% class methods
+%%%
+
+new(ServerPid, TF, PF) ->
+ Super = (super()):new(),
+ #?MODULE{super = Super,
+ serverPid = ServerPid,
+ transportFactory = TF,
+ protocolFactory = PF
+ }.
+
+%%%
+%%% instance methods
+%%%
+
+accept(This, ListenSocket, GP, Handler) ->
+ io:format("acceptor started~n",[]),
+
+ ServerPid = oop:get(This, serverPid),
+
+ case catch gen_tcp:accept(ListenSocket) of
+ {ok, Socket} ->
+
+ ?C0(ServerPid, effectful_new_acceptor), %% cast to create new acceptor
+
+ %% start_new(tSocket, [])
+ Client = oop:start_new(tSocket, []),
+ ?R1(Client, effectful_setHandle, Socket), %% TODO(cpiro): should we just let this be a param to the constructor?
+
+ %% cpiro: OPAQUE!! Trans = Client
+ TF = oop:get(This, transportFactory),
+ Trans = ?F1(TF, getTransport, Client),
+
+ %% cpiro: OPAQUE!! Prot = start_new(tBinaryProtocol, [Trans])
+ PF = oop:get(This, protocolFactory),
+ Prot = ?F1(PF, getProtocol, Trans),
+
+ %% start_new(, ...)
+ Processor = oop:start_new(tErlProcessor, [GP, Handler]), %% TODO
+
+ receive_loop(This, Processor, Prot, Prot),
+
+ exit(acceptor_done); %% TODO(cpiro): grace?
+
+ Else ->
+ R = lists:flatten(
+ io_lib:format("accept() failed: ~p", [Else])),
+
+ exit(tTransportException:new(R))
+ end.
+
+receive_loop(This, Processor, Iprot, Oprot) ->
+ case catch ?R2(Processor, process, Iprot, Oprot) of
+ {'EXIT', X} ->
+ io:format("Acceptor: we gotta ~p~n", [X]);
+
+ Value ->
+ io:format("request processed: rv=~p~n", [Value]),
+ receive_loop(This, Processor, Iprot, Oprot)
+ end.
+
+%%%
+%%% error handlers
+%%%
+
+%% end
+
+%%% old codez
+
+%% effectful_listen(This) -> %%
+%% Port = oop:get(This, port), %%
+%% Options = [binary, {packet, 0}, {active, false}], % was [] %%
+%% %%
+%% case gen_tcp:listen(Port, Options) of %%
+%% {ok, ListenSocket} -> %%
+%% This1 = oop:set(This, handle, ListenSocket), %%
+%% {ok, This1} %%
+%% %%
+%% % {error, _} -> %%
+%% % TODO: no error handling in Ruby version? %%
+%% end. %%
+%% %%
+%% accept(This) -> %%
+%% case oop:get(This, handle) of %%
+%% nil -> %%
+%% nil; % cpiro: sic the Ruby code %%
+%% %%
+%% Handle -> %%
+%% case gen_tcp:accept(Handle) of %%
+%% {ok, Sock} -> %%
+%% Trans = oop:start_new(tSocket, []), %%
+%% ?R1(Trans, effectful_setHandle, Sock), %%
+%% Trans %%
+%% % {error, _} -> %%
+%% % TODO: no error handling in Ruby version? %%
+%% end %%
+%% end. %%
+%% %%
+%% effectful_close(This) -> %%
+%% case oop:get(This, handle) of %%
+%% nil -> %%
+%% {nil, This}; %%
+%% Handle -> %%
+%% case gen_tcp:close(Handle) of %%
+%% ok -> %%
+%% {ok, This} % cpiro: sic the Ruby version: don't set handle to nil %%
+%% % {error, _} -> %%
+%% % TODO: no error handling in Ruby version? %%
+%% end %%
+%% end. %%
+
+
+%%% teh iservez
+
+%% -module(iserve_socket). %%
+%% %%
+%% -export([start_link/3]). %%
+%% %%
+%% -export([init/1]). %%
+%% -include("iserve.hrl"). %%
+%% %%
+%% %TEST %%
+%% -export([handle_get/2]). %%
+%% %%
+%% -define(not_implemented_501, "HTTP/1.1 501 Not Implemented\r\n\r\n"). %%
+%% -define(forbidden_403, "HTTP/1.1 403 Forbidden\r\n\r\n"). %%
+%% -define(not_found_404, "HTTP/1.1 404 Not Found\r\n\r\n"). %%
+%% %%
+%% -record(c, {sock, %%
+%% port, %%
+%% peer_addr, %%
+%% peer_port %%
+%% }). %%
+%% %%
+%% -define(server_idle_timeout, 30*1000). %%
+%% %%
+%% start_link(ListenPid, ListenSocket, ListenPort) -> %%
+%% proc_lib:spawn_link(?MODULE, init, [{ListenPid, ListenSocket, ListenPort}]). %%
+%% %%
+
+
+%% init({Listen_pid, Listen_socket, ListenPort}) -> %%
+%% % error_logger:info_msg("Socket Started~n"), %%
+%% case catch gen_tcp:accept(Listen_socket) of %%
+%% {ok, Socket} -> %%
+%% %% Send the cast message to the listener process to create a new acceptor %%
+%% iserve_server:create(Listen_pid, self()), %%
+%% {ok, {Addr, Port}} = inet:peername(Socket), %%
+%% Conn = #c{sock = Socket, %%
+%% port = ListenPort, %%
+%% peer_addr = Addr, %%
+%% peer_port = Port}, %%
+%% request(Conn, #req{}); %% Jump to state 'request' %%
+%% Else -> %%
+%% error_logger:error_report([{application, iserve}, %%
+%% "Accept failed error", %%
+%% io_lib:format("~p",[Else])]), %%
+%% exit({error, accept_failed}) %%
+%% end. %%
+%% %%
+
+%% request(Conn, Req) -> %%
+%% case gen_tcp:recv(Conn#c.sock, 0, ?server_idle_timeout) of %%
+%% {ok, {http_request,Method,Path,Version}} -> %%
+%% headers(Conn, Req#req{vsn = Version, %%
+%% method = Method, %%
+%% uri = Path}, []); %%
+%% {error, {http_error, "\r\n"}} -> %%
+%% request(Conn, Req); %%
+%% {error, {http_error, "\n"}} -> %%
+%% request(Conn, Req); %%
+%% {tcp_closed, _Port} -> %%
+%% error_logger:info_msg("Closed connection: ~p ~p~n", [Conn#c.peer_addr, Conn#c.peer_port]), %%
+%% exit(normal); %%
+%% _Other -> %%
+%% exit(normal) %%
+%% end. %%
+
--- /dev/null
+%%% Copyright (c) 2007- Facebook
+%%% Distributed under the Thrift Software License
+%%%
+%%% See accompanying file LICENSE or visit the Thrift site at:
+%%% http://developers.facebook.com/thrift/
+
+-module(tServerSocket).
+
+-include("oop.hrl").
+-include("thrift.hrl").
+-include("transport/tServerSocket.hrl").
+
+-behavior(oop).
+
+-export([attr/4, super/0, inspect/1]).
+
+-export([new/1, effectful_listen/1, accept/1, effectful_close/1]).
+
+%%%
+%%% define attributes
+%%% 'super' is required unless ?MODULE is a base class
+%%%
+
+?DEFINE_ATTR(super);
+?DEFINE_ATTR(port);
+?DEFINE_ATTR(handle).
+
+%%%
+%%% behavior callbacks
+%%%
+
+%%% super() -> SuperModule = atom()
+%%% | none
+
+super() ->
+ tServerTransport.
+
+%%% inspect(This) -> string()
+
+inspect(This) ->
+ ?FORMAT_ATTR(port) ++ ", " ++
+ ?FORMAT_ATTR(handle).
+
+%%%
+%%% class methods
+%%%
+
+new(Port) ->
+ Super = (super()):new(),
+ #?MODULE{super = Super, port = Port, handle = nil}.
+
+%%%
+%%% instance methods
+%%%
+
+effectful_listen(This) ->
+ Port = oop:get(This, port),
+ Options = [binary, {packet, 0}, {active, false}], % was []
+
+ case gen_tcp:listen(Port, Options) of
+ {ok, ListenSocket} ->
+ This1 = oop:set(This, handle, ListenSocket),
+ {ok, This1}
+
+ % {error, _} ->
+ % TODO: no error handling in Ruby version?
+ end.
+
+accept(This) ->
+ case oop:get(This, handle) of
+ nil ->
+ nil; % cpiro: sic the Ruby code
+
+ Handle ->
+ case gen_tcp:accept(Handle) of
+ {ok, Sock} ->
+ Trans = oop:start_new(tSocket, []),
+ ?R1(Trans, effectful_setHandle, Sock),
+ Trans
+ % {error, _} ->
+ % TODO: no error handling in Ruby version?
+ end
+ end.
+
+effectful_close(This) ->
+ case oop:get(This, handle) of
+ nil ->
+ {nil, This};
+ Handle ->
+ case gen_tcp:close(Handle) of
+ ok ->
+ {ok, This} % cpiro: sic the Ruby version: don't set handle to nil
+ % {error, _} ->
+ % TODO: no error handling in Ruby version?
+ end
+ end.
--- /dev/null
+%%% Copyright (c) 2007- Facebook
+%%% Distributed under the Thrift Software License
+%%%
+%%% See accompanying file LICENSE or visit the Thrift site at:
+%%% http://developers.facebook.com/thrift/
+
+-module(tServerTransport).
+
+-include("oop.hrl").
+-include("transport/tServerTransport.hrl").
+
+-behavior(oop).
+
+-export([attr/4, super/0, inspect/1]).
+
+-export([new/0]).
+
+%%%
+%%% define attributes
+%%% 'super' is required unless ?MODULE is a base class
+%%%
+
+?ATTR_DUMMY.
+
+%%%
+%%% behavior callbacks
+%%%
+
+%%% super() -> SuperModule = atom()
+%%% | none
+
+super() ->
+ none.
+
+%%% inspect(This) -> string()
+
+inspect(_This) ->
+ "".
+
+%%%
+%%% class methods
+%%%
+
+new() ->
+ #?MODULE{}.
+
+%%%
+%%% instance methods
+%%%
+
+getTransport(_This, Trans) ->
+ Trans.
--- /dev/null
+%%% Copyright (c) 2007- Facebook
+%%% Distributed under the Thrift Software License
+%%%
+%%% See accompanying file LICENSE or visit the Thrift site at:
+%%% http://developers.facebook.com/thrift/
+
+-module(tSocket).
+
+-include("oop.hrl").
+
+-include("thrift.hrl").
+-include("transport/tTransportException.hrl").
+% -include("transport/tTransport.hrl").
+-include("transport/tSocket.hrl").
+
+-behavior(oop).
+
+-export([attr/4, super/0, inspect/1]).
+
+-export([new/0, new/1, new/2,
+ effectful_setHandle/2, effectful_open/1,
+ isOpen/1, write/2, read/2, effectful_close/1]).
+
+%%%
+%%% define attributes
+%%% 'super' is required unless ?MODULE is a base class
+%%%
+
+?DEFINE_ATTR(super);
+?DEFINE_ATTR(host);
+?DEFINE_ATTR(port);
+?DEFINE_ATTR(handle).
+
+%%%
+%%% behavior callbacks
+%%%
+
+%%% super() -> SuperModule = atom()
+%%% | none
+
+super() ->
+ tTransport.
+
+%%% inspect(This) -> string()
+
+inspect(This) ->
+ ?FORMAT_ATTR(host) ++ ", " ++
+ ?FORMAT_ATTR(port) ++ ", " ++
+ ?FORMAT_ATTR(handle).
+
+%%%
+%%% class methods
+%%%
+
+new(Host, Port) ->
+ Super = (super()):new(),
+ #?MODULE{super=Super, host=Host, port=Port, handle=nil}.
+
+new(Host) ->
+ new(Host, 9090).
+
+new() ->
+ new("localhost", 9090).
+
+%%%
+%%% instance methods
+%%%
+
+effectful_setHandle(This, Handle) ->
+ {ok, oop:set(This, handle, Handle)}.
+
+effectful_open(This) ->
+ Host = oop:get(This, host),
+ Port = oop:get(This, port),
+ Options = [],
+
+ case gen_tcp:connect(Host, Port, Options) of
+ {error, _} ->
+ exit(tTransportException:new(
+ ?tTransportException_NOT_OPEN,
+ "Could not connect to " ++ Host ++ ":" ++ Port)
+ );
+ {ok, Socket} ->
+ {ok, oop:set(This, handle, Socket)}
+ end.
+
+isOpen(This) ->
+ oop:get(This, handle) /= nil.
+
+write(This, Str) ->
+ Handle = oop:get(This, handle),
+ Val = gen_tcp:send(Handle, Str),
+
+ %% io:format("WRITE |~p|(~p)~n", [Str,Val]),
+
+ case Val of
+ {error, _} ->
+ throw(tTransportException:new(?tTransportException_NOT_OPEN, "in write"));
+ ok ->
+ ok
+ end.
+
+read(This, Sz) ->
+ Handle = oop:get(This, handle),
+ case gen_tcp:recv(Handle, Sz) of
+ {ok, []} ->
+ Host = oop:get(This, host),
+ Port = oop:get(This, port),
+ throw(tTransportException:new(?tTransportException_UNKNOWN, "TSocket: Could not read " ++ Sz ++ "bytes from " ++ Host ++ ":" ++ Port));
+ {ok, Data} ->
+ Data;
+ {error, Error} ->
+ io:format("in tSocket:read/2: gen_tcp:recv(~p, ~p) => {error, ~p}~n",
+ [Handle, Sz, Error]),
+ exit(tTransportException:new(?tTransportException_NOT_OPEN, "in tSocket:read/2: gen_tcp:recv"))
+ end.
+
+effectful_close(This) ->
+ case oop:get(This, handle) of
+ nil ->
+ {ok, This};
+ Handle ->
+ gen_tcp:close(Handle),
+ {ok, oop:set(This, handle, nil)}
+ end.
+
--- /dev/null
+%%% Copyright (c) 2007- Facebook
+%%% Distributed under the Thrift Software License
+%%%
+%%% See accompanying file LICENSE or visit the Thrift site at:
+%%% http://developers.facebook.com/thrift/
+
+-module(tTransport).
+
+-include("oop.hrl").
+
+-include("thrift.hrl").
+-include("transport/tTransport.hrl").
+
+-behavior(oop).
+
+-export([attr/4, super/0, inspect/1]).
+
+-export([new/0, isOpen/1, open/1, close/1, read/2, readAll/2, effectful_write/2, effectful_flush/1]).
+
+%%%
+%%% define attributes
+%%% 'super' is required unless ?MODULE is a base class
+%%%
+
+?ATTR_DUMMY.
+
+%%%
+%%% behavior callbacks
+%%%
+
+%%% super() -> SuperModule = atom()
+%%% | none
+
+super() ->
+ none.
+
+%%% inspect(This) -> string()
+
+inspect(_This) ->
+ "".
+
+%%%
+%%% class methods
+%%%
+
+new() ->
+ #?MODULE{}.
+
+%%%
+%%% instance methods
+%%%
+
+
+
+isOpen(_This) -> nil.
+open(_This) -> nil.
+close(_This) -> nil.
+read(_This, _Sz) -> nil.
+
+readAll(This, Sz) ->
+ readAll_loop(This, Sz, "", 0).
+
+readAll_loop(This, Sz, Buff, Have) ->
+ if
+ Have < Sz ->
+ Chunk = ?L1(read, Sz - Have),
+
+ %% man gen_tcp:
+ %% exactly Length bytes are returned, or an error;
+ %% possibly discarding less than Length bytes of data when
+ %% the socket gets closed from the other side.
+
+ %% io:format("READ |~p|~n", [Chunk]),
+
+ Have1 = Have + (Sz-Have), % length(Chunk)
+ Buff1 = Buff ++ Chunk, % TODO: ++ efficiency?
+ readAll_loop(This, Sz, Buff1, Have1);
+ true ->
+ Buff
+ end.
+
+effectful_write(This, _Buf) ->
+ {nil, This}.
+
+effectful_flush(This) ->
+ {nil, This}.
--- /dev/null
+%%% Copyright (c) 2007- Facebook
+%%% Distributed under the Thrift Software License
+%%%
+%%% See accompanying file LICENSE or visit the Thrift site at:
+%%% http://developers.facebook.com/thrift/
+
+-module(tTransportException).
+
+-include("oop.hrl").
+
+-include("thrift.hrl").
+-include("transport/tTransportException.hrl").
+
+-behavior(oop).
+
+-export([attr/4, super/0, inspect/1]).
+
+-export([new/0, new/1, new/2]).
+
+%%%
+%%% define attributes
+%%% 'super' is required unless ?MODULE is a base class
+%%%
+
+?DEFINE_ATTR(super);
+?DEFINE_ATTR(type).
+
+%%%
+%%% behavior callbacks
+%%%
+
+%%% super() -> SuperModule = atom()
+%%% | none
+
+super() ->
+ tException.
+
+%%% inspect(This) -> string()
+
+inspect(This) ->
+ ?FORMAT_ATTR(type).
+
+%%%
+%%% class methods
+%%%
+
+new(Type, Message) ->
+ Super = (super()):new(Message),
+ #?MODULE{super=Super, type=Type}.
+
+new() ->
+ new(?tTransportException_UNKNOWN, undefined).
+new(Type) ->
+ new(Type, undefined).
+
+%%%
+%%% instance methods
+%%%
--- /dev/null
+%%% Copyright (c) 2007- Facebook
+%%% Distributed under the Thrift Software License
+%%%
+%%% See accompanying file LICENSE or visit the Thrift site at:
+%%% http://developers.facebook.com/thrift/
+
+-module(tTransportFactory).
+
+-include("oop.hrl").
+-include("transport/tTransportFactory.hrl").
+
+-behavior(oop).
+
+-export([attr/4, super/0, inspect/1]).
+
+-export([new/0, getTransport/2]).
+
+%%%
+%%% define attributes
+%%% 'super' is required unless ?MODULE is a base class
+%%%
+
+?ATTR_DUMMY.
+
+%%%
+%%% behavior callbacks
+%%%
+
+%%% super() -> SuperModule = atom()
+%%% | none
+
+super() ->
+ none.
+
+%%% inspect(This) -> string()
+
+inspect(_This) ->
+ "".
+
+%%%
+%%% class methods
+%%%
+
+new() ->
+ #?MODULE{}.
+
+%%%
+%%% instance methods
+%%%
+
+getTransport(_This, Trans) ->
+ Trans.
--- /dev/null
+../../../../tutorial
\ No newline at end of file
--- /dev/null
+../../../../tutorial/erl
\ No newline at end of file
--- /dev/null
+THRIFT_VSN=0.1
--- /dev/null
+Tue Oct 24 12:28:44 CDT 2006
+
+Copyright (c) <2006> <Martin J. Logan, Erlware>
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software (OTP Base, fslib, G.A.S) and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+of the Software, and to permit persons to whom the Software is furnished to do
+so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
+INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
+PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
+OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
--- /dev/null
+include ../build/colors.mk
+
+MODULES=$(shell ls . | grep "[^(Makefile)]")
+
+all clean:
+ @for dir in $(MODULES); do \
+ (cd $$dir; if [ -e "SKIP" ]; then echo $${MY_LRED:-$(LRED)}"skipping \"make $@\" for $$dir"; else ${MAKE} $@; fi); \
+ if [ "$$?" -ne "0" ]; then ERROR=$$?; echo "Error Code $$ERROR"; exit $$ERROR; fi; \
+ echo -n $(OFF)$(NO_COLOR); \
+ done
--- /dev/null
+# ----------------------------------------------------
+# Make file for creating an otp release.
+# ----------------------------------------------------
+
+##
+# Basename of this release.
+##
+RELS=$(shell basename `pwd`)
+APP_NAME=$(shell echo $(RELS) | sed s/_rel$$//)
+
+include ../../build/otp.mk
+
+include ./vsn.mk
+
+#include $(ERL_TOP)/make/target.mk
+#include $(ERL_TOP)/make/$(TARGET)/otp.mk
+
+USR_LIBPATH=../../lib
+INSTALL_DIR=/usr/local/lib
+ABS_USER_LIBPATH=$(shell cd ../../lib;pwd)
+
+# ----------------------------------------------------
+# CREATE DIR STRUCTURE HERE
+# ----------------------------------------------------
+
+HTDOCS=$(wildcard $(ABS_USER_LIBPATH)/$(APP_NAME)/htdocs/*.html) \
+ $(wildcard $(ABS_USER_LIBPATH)/$(APP_NAME)/htdocs/*.htm) \
+ $(wildcard $(ABS_USER_LIBPATH)/$(APP_NAME)/htdocs/*.yaws)
+BUILD_FILES=fs_boot_smithe.beam fs_lists.beam fs_lib.beam
+
+LOCAL_DIR=local
+#LOCAL_DIR=$(shell cat $(RELS).rel.src |grep -m 1 '$(APP_NAME)' |awk -F '"' '{printf "%s-%s", $$2,$$4}')
+
+DIR_STRUCTURE= \
+ $(LOCAL_DIR) \
+ $(LOCAL_DIR)/log/$(REL_VSN) \
+ $(LOCAL_DIR)/var/$(REL_VSN) \
+ $(LOCAL_DIR)/var/$(REL_VSN)/www/conf \
+ $(LOCAL_DIR)/var/$(REL_VSN)/www/htdocs
+
+PRODUCTION_DIR_STRUCTURE= \
+ $(RELS) \
+ $(RELS)/release/$(REL_VSN) \
+ $(RELS)/stage \
+ $(RELS)/log/$(REL_VSN) \
+ $(RELS)/var/$(REL_VSN) \
+ $(RELS)/var/$(REL_VSN)/www \
+ $(RELS)/var/$(REL_VSN)/www/htdocs \
+ $(RELS)/var/$(REL_VSN)/www/conf
+
+# ----------------------------------------------------
+SCRIPT_AND_BOOT_FILES= \
+ $(RELS).script \
+ $(RELS).boot
+
+LOCAL_SCRIPT_AND_BOOT_FILES= \
+ $(LOCAL_DIR)/$(RELS).script \
+ $(LOCAL_DIR)/$(RELS).boot
+
+LOCAL_HTTP_CONF= \
+ $(LOCAL_DIR)/var/$(REL_VSN)/www/conf/yaws.conf \
+ $(LOCAL_DIR)/var/$(REL_VSN)/www/conf/mime.types
+
+PRODUCTION_HTTP_CONF= \
+ $(LOCAL_DIR)/var/$(REL_VSN)/www/conf/yaws.conf \
+ $(LOCAL_DIR)/var/$(REL_VSN)/www/conf/mime.types
+
+LOCAL_TARGET_FILES=$(LOCAL_HTTP_CONF) $(LOCAL_DIR)/$(RELS).config $(LOCAL_SCRIPT_AND_BOOT_FILES)
+
+LOCAL_TARGETS=$(LOCAL_DIR)/$(RELS).sh vsnit $(LOCAL_TARGET_FILES)
+
+PRODUCTION_TARGETS=$(RELS)/build/$(REL_VSN) \
+ $(RELS)/lib \
+ $(RELS)/stage/$(RELS).rel.src \
+ $(RELS)/stage/$(RELS).config.src \
+ $(RELS)/stage/yaws.conf.src \
+ $(RELS)/stage/$(RELS).sh.src \
+ $(RELS)/var/$(REL_VSN)/www/htdocs \
+ $(RELS)/install.sh \
+ $(RELS)/release/$(REL_VSN)/clean_release
+
+# ----------------------------------------------------
+# TARGETS
+# ----------------------------------------------------
+
+all debug opt instr script: $(DIR_STRUCTURE) $(LOCAL_TARGETS) $(PRODUCTION_DIR_STRUCTURE) $(PRODUCTION_TARGETS)
+ @echo $(HTDOCS)
+
+install: stage
+
+tar: $(RELS)-$(LOCATION)-$(REL_VSN).tgz
+
+$(DIR_STRUCTURE):
+ mkdir -p $@
+
+$(PRODUCTION_DIR_STRUCTURE):
+ mkdir -p $@
+
+clean:
+ $(RM) $(REL_SCRIPTS) $(TARGET_FILES)
+ $(RM) -r $(LOCAL_DIR) $(PRODN_DIR)
+ $(RM) $(RELS).rel
+ $(RM) -r $(RELS)
+ $(RM) $(RELS)*.tgz
+ $(RM) $(RELS).rel.src.tmp
+ $(RM) $(SCRIPT_AND_BOOT_FILES)
+
+docs:
+
+# ----------------------------------------------------
+# TARGETS FOR LOCAL MODE
+# ----------------------------------------------------
+
+# startup script for local mode
+$(LOCAL_DIR)/$(RELS).sh:
+ @echo '#!/bin/sh' > $@
+ @echo "cd $(CURDIR)/$(LOCAL_DIR)" >> $@
+ @echo "erl -name $${USER}_$(RELS) -boot $(RELS) -config $(RELS).config \$$@" >> $@
+ chmod +x $@
+ @echo
+ @echo "==== Start local node with \"sh $@\" ===="
+ @echo
+
+# Create the config file for local mode.
+$(LOCAL_DIR)/$(RELS).config: $(RELS).config.src
+ sed -e 's;%LOG_OTP%;$(CURDIR)/$(LOCAL_DIR)/log/$(REL_VSN);' \
+ -e 's;%VAR_OTP%;$(CURDIR)/$(LOCAL_DIR)/var/$(REL_VSN);' \
+ -e 's;%RELS%;$(RELS);g' \
+ -e 's;%HOME%;$(HOME);g' \
+ -e 's;%BROADCAST_ADDRESS%;$(BROADCAST_ADDRESS);g' \
+ -e 's;%CONTACT_NODE%;$(CONTACT_NODE);g' \
+ -e "s;%HOSTNAME%;`hostname --long`;" \
+ -e 's;%APP_NAME%;$(APP_NAME);' \
+ -e 's;%APP_VERSION%;$(APP_VERSION);g' \
+ $< > $@
+
+# Create the httpd conf file for local mode.
+$(LOCAL_DIR)/var/$(REL_VSN)/www/conf/yaws.conf: yaws.conf.src
+ sed -e 's;%VAR_OTP%;$(CURDIR)/$(LOCAL_DIR)/var/$(REL_VSN);' \
+ -e 's;%LOG_OTP%;$(CURDIR)/$(LOCAL_DIR)/log/$(REL_VSN);' \
+ -e 's;%HTDOC_ROOT%;$(ABS_USER_LIBPATH)/$(APP_NAME)/htdocs;' \
+ -e 's;%APP_NAME%;$(APP_NAME);' \
+ -e 's;%RELS%;$(RELS);' \
+ -e 's;%USER%;$(USER);' \
+ -e 's;%HTDOC_ROOT%;$(ABS_USER_LIBPATH);' \
+ -e 's;%MHOST%;$(MHOST);' \
+ $< > $@
+
+# Create the config file for local mode.
+vsnit: $(RELS).rel.src
+ sed -e 's;%REL_VSN%;$(REL_VSN);' \
+ $< > $<.tmp
+
+# Create and position script and boot files for local mode.
+$(LOCAL_SCRIPT_AND_BOOT_FILES):
+ @ erl -pz $(USR_LIBPATH)/fslib/ebin \
+ -noshell \
+ -s fs_lib s_apply fs_boot_smithe make_script_and_boot "[\"$(ERL_RUN_TOP)/*\", \"$(USR_LIBPATH)\"]. " \
+ \"$$(basename `pwd`)".rel.src.tmp\". " \
+ "[local]. " \
+ -s init stop
+ cp $(SCRIPT_AND_BOOT_FILES) $(LOCAL_DIR)/
+
+$(LOCAL_DIR)/var/$(REL_VSN)/www/conf/mime.types: ../../build/mime.types
+ cp $< $@
+
+# ----------------------------------------------------
+# TARGETS FOR PRODUCTION MODE
+# ----------------------------------------------------
+$(RELS)/lib:
+ # For some reason this will not happen if added to PRODUCTION_DIR_STRUCTURE
+ mkdir $@
+ @ erl -pz $(RELS)/build/$(REL_VSN) \
+ -noshell \
+ -s fs_lib s_apply fs_boot_smithe stage_from_relsrc "[\"$(USR_LIBPATH)\"]. " \
+ \"$$(basename `pwd`)".rel.src\". " \
+ \"$@\"". " \
+ -s init stop
+
+# Move the htdocs from the local apps to the production htdoc root directory.
+$(RELS)/var/$(REL_VSN)/www/htdocs/: $(HTDOCS)
+ @mkdir -p $(RELS)/var/$(REL_VSN)/www/htdocs; \
+ for x in $(HTDOCS);do \
+ cp $$x $@; \
+ done
+
+# startup script for production mode
+$(RELS)/stage/$(RELS).sh.src:
+ @echo '#!/bin/sh' > $@
+ @echo "cd %INSTALL_DIR%/$(RELS)/release/$(REL_VSN)" >> $@
+ @echo "erl -name $(RELS) -boot $(RELS) -config $(RELS).config -detached \$$@" >> $@
+ chmod +x $@
+
+$(RELS)/build/$(REL_VSN): $(USR_LIBPATH)/fslib/ebin
+ mkdir -p $(RELS)/build/$(REL_VSN)
+ cp $</fs_boot_smithe.beam $@
+ cp $</fs_lib.beam $@
+ cp $</fs_lists.beam $@
+
+$(RELS)/stage/$(RELS).rel.src: $(RELS).rel.src.tmp
+ cp $< $@
+
+$(RELS)/stage/$(RELS).config.src: $(RELS).config.src
+ cp $< $@
+
+$(RELS)/stage/yaws.conf.src: yaws.conf.src
+ cp $< $@
+
+$(RELS)/install.sh:
+ @echo '#!/bin/sh' > $@
+ @echo "" >> $@
+ @echo "if [ \$$# -eq 1 ];then" >> $@
+ @echo " INSTALL_DIR=\$$1;" >> $@
+ @echo "else" >> $@
+ @echo " INSTALL_DIR=$(INSTALL_DIR);" >> $@
+ @echo "fi" >> $@
+ @echo "" >> $@
+ @echo "function munge() {" >> $@
+ @echo " sed -e \"s;%LOG_OTP%;\$$INSTALL_DIR/$(RELS)/log/$(REL_VSN);g\" \\" >> $@
+ @echo " -e \"s;%VAR_OTP%;\$$INSTALL_DIR/$(RELS)/var/$(REL_VSN);g\" \\" >> $@
+ @echo " -e \"s;%RELS%;$(RELS);g\" \\" >> $@
+ @echo " -e \"s;%REL_VSN%;$(REL_VSN);g\" \\" >> $@
+ @echo " -e \"s;%USER%;$$USER;g\" \\" >> $@
+ @echo " -e \"s;%HTDOC_ROOT%;\$$INSTALL_DIR/$(RELS)/var/$(REL_VSN)/www/htdocs;g\" \\" >> $@
+ @echo " -e \"s;%MHOST%;\`hostname\`;g\" \\" >> $@
+ @echo " -e \"s;%BROADCAST_ADDRESS%;$(BROADCAST_ADDRESS);g\" \\" >> $@
+ @echo " -e \"s;%INSTALL_DIR%;\$$INSTALL_DIR;g\" \\" >> $@
+ @echo " -e \"s;%CONTACT_NODE%;$(CONTACT_NODE);g\" \\" >> $@
+ @echo " -e \"s;%HOSTNAME%;\`hostname --long\`;g\" \\" >> $@
+ @echo " -e \"s;%APP_NAME%;$(APP_NAME);g\" \\" >> $@
+ @echo " -e \"s;%APP_VERSION%;$(APP_VERSION);g\" \\" >> $@
+ @echo ' $$1 > $$2' >> $@
+ @echo "}" >> $@
+ @echo "" >> $@
+ @echo "munge stage/yaws.conf.src var/$(REL_VSN)/www/conf/yaws.conf;" >> $@
+ @echo "munge stage/$(RELS).config.src release/$(REL_VSN)/$(RELS).config;" >> $@
+ @echo "munge stage/$(RELS).sh.src release/$(REL_VSN)/$(RELS).sh;" >> $@
+ @echo "munge stage/$(RELS).rel.src release/$(REL_VSN)/$(RELS).rel;" >> $@
+ @echo "chmod +x release/$(REL_VSN)/$(RELS).sh;" >> $@
+ @echo "" >> $@
+ @echo "cd ..;" >> $@
+ @echo "find $(RELS) | cpio -o > \$$INSTALL_DIR/$(RELS).cpio;" >> $@
+ @echo "cd -;" >> $@
+ @echo "cd \$$INSTALL_DIR; " >> $@
+ @echo "echo -n \"Unpacked: \"" >> $@
+ @echo "cpio -uid < $(RELS).cpio;" >> $@
+ @echo "rm $(RELS).cpio;" >> $@
+ @echo "" >> $@
+ @echo "echo \"pwd is \`pwd\`\";" >> $@
+ @echo "cd $(RELS);" >> $@
+ @echo " erl -pz build/$(REL_VSN) \\" >> $@
+ @echo " -noshell \\" >> $@
+ @echo -n " -s fs_lib s_apply fs_boot_smithe make_script_and_boot \"[\\\"$(ERL_RUN_TOP)/*\\\", \\\"lib/\\\"]. \" " >> $@
+ @echo -n "\"\\\"stage/$$(basename `pwd`).rel.src\\\". \" " >> $@
+ @echo -n "\"[local]. \" " >> $@
+ @echo "-s init stop | egrep '*terminate*|ERROR'" >> $@
+ @echo "if [ \$$? -eq 0 ]; then" >> $@
+ @echo "echo \"============================================\";" >> $@
+ @echo "echo \"STAGE FAILURE \$$? - Silence the discord.\";" >> $@
+ @echo "echo \"============================================\";" >> $@
+ @echo "exit 1;" >> $@
+ @echo "fi" >> $@
+ @echo "" >> $@
+ @echo "mv $(RELS).rel $(RELS).script $(RELS).boot release/$(REL_VSN);" >> $@
+ @echo "" >> $@
+ @echo "rm -r stage;" >> $@
+ @echo "rm -r build;" >> $@
+ @echo "cd -;" >> $@
+ @echo "" >> $@
+ @echo "chgrp -R erts $(RELS); " >> $@
+ @echo "chmod -R 775 $(RELS); " >> $@
+ @echo "cd -" >> $@
+ @echo "" >> $@
+ @echo "rm -f /usr/local/bin/$(APP_NAME);" >> $@
+ @echo "ln -s \$$INSTALL_DIR/$(RELS)/release/$(REL_VSN)/$(RELS).sh /usr/local/bin/$(APP_NAME);" >> $@
+ @echo "chgrp -R erts /usr/local/bin/$(APP_NAME); " >> $@
+ @echo "chmod -R 775 /usr/local/bin/$(APP_NAME); " >> $@
+ @echo "rm \$$INSTALL_DIR/$(RELS)/install.sh;" >> $@
+ @echo "echo -n $$'\e[0;32m'" >> $@
+ @echo "echo \"$(APP_NAME) installation to \$$INSTALL_DIR complete.\"" >> $@
+ @echo "echo -n $$'\e[0m'" >> $@
+ chmod +x $@
+
+
+stage: $(RELS)
+ cd $(RELS); \
+ ./install.sh; \
+ cd -
+
+$(RELS)/var/$(REL_VSN)/www/conf/mime.types: ../../build/mime.types
+ cp $< $@
+
+$(RELS)-$(LOCATION)-$(REL_VSN).tgz: $(RELS)
+ tar -zcvf $@ $<
+
+$(RELS)/release/$(REL_VSN)/clean_release: ../../tools/utilities/clean_release
+ cp $< $@
+
--- /dev/null
+%%% -*- mode:erlang -*-
+%%% Parameter settings for apps on thrift
+%%% Warning - this config file *must* end with <dot><whitespace>
+
+%% write log files to sasl_dir
+[
+ {sasl,
+ [
+ {sasl_error_logger, {file, "/data/users/cpiro/thrift/trunk/lib/erl/release/thrift_rel/local/log/1.0/sasl_log"}}
+ ]},
+
+
+ {gas,
+ [
+ {mod_specs, [{elwrap, {fs_elwrap_h, start_link}}]},
+
+ % elwrap config.
+ {err_log, "/data/users/cpiro/thrift/trunk/lib/erl/release/thrift_rel/local/log/1.0/err_log"},
+ {err_log_wrap_info, {{err,5000000,10},{sasl,5000000,10}}},
+ {err_log_tty, true} % Log to the screen
+ ]},
+
+ {thrift,
+ [
+ ]}
+].
--- /dev/null
+#!/bin/sh
+cd /data/users/cpiro/thrift/trunk/lib/erl/release/thrift_rel/local
+erl -name cpiro_thrift_rel -boot thrift_rel -config thrift_rel.config $@
--- /dev/null
+
+application/activemessage
+application/andrew-inset
+application/applefile
+application/atomicmail
+application/dca-rft
+application/dec-dx
+application/mac-binhex40 hqx
+application/mac-compactpro cpt
+application/macwriteii
+application/msword doc
+application/news-message-id
+application/news-transmission
+application/octet-stream bin dms lha lzh exe class
+application/oda oda
+application/pdf pdf
+application/postscript ai eps ps
+application/powerpoint ppt
+application/remote-printing
+application/rtf rtf
+application/slate
+application/wita
+application/wordperfect5.1
+application/x-bcpio bcpio
+application/x-cdlink vcd
+application/x-compress Z
+application/x-cpio cpio
+application/x-csh csh
+application/x-director dcr dir dxr
+application/x-dvi dvi
+application/x-gtar gtar
+application/x-gzip gz
+application/x-hdf hdf
+application/x-httpd-cgi cgi
+application/x-koan skp skd skt skm
+application/x-latex latex
+application/x-mif mif
+application/x-netcdf nc cdf
+application/x-sh sh
+application/x-shar shar
+application/x-stuffit sit
+application/x-sv4cpio sv4cpio
+application/x-sv4crc sv4crc
+application/x-tar tar
+application/x-tcl tcl
+application/x-tex tex
+application/x-texinfo texinfo texi
+application/x-troff t tr roff
+application/x-troff-man man
+application/x-troff-me me
+application/x-troff-ms ms
+application/x-ustar ustar
+application/x-wais-source src
+application/zip zip
+audio/basic au snd
+audio/mpeg mpga mp2
+audio/x-aiff aif aiff aifc
+audio/x-pn-realaudio ram
+audio/x-pn-realaudio-plugin rpm
+audio/x-realaudio ra
+audio/x-wav wav
+chemical/x-pdb pdb xyz
+image/gif gif
+image/ief ief
+image/jpeg jpeg jpg jpe
+image/png png
+image/tiff tiff tif
+image/x-cmu-raster ras
+image/x-portable-anymap pnm
+image/x-portable-bitmap pbm
+image/x-portable-graymap pgm
+image/x-portable-pixmap ppm
+image/x-rgb rgb
+image/x-xbitmap xbm
+image/x-xpixmap xpm
+image/x-xwindowdump xwd
+message/external-body
+message/news
+message/partial
+message/rfc822
+multipart/alternative
+multipart/appledouble
+multipart/digest
+multipart/mixed
+multipart/parallel
+text/html html htm
+text/x-server-parsed-html shtml
+text/plain txt
+text/richtext rtx
+text/tab-separated-values tsv
+text/x-setext etx
+text/x-sgml sgml sgm
+video/mpeg mpeg mpg mpe
+video/quicktime qt mov
+video/x-msvideo avi
+video/x-sgi-movie movie
+x-conference/x-cooltalk ice
+x-world/x-vrml wrl vrml
--- /dev/null
+
+# conf for yaws
+
+
+# first we have a set of globals
+# That apply to all virtual servers
+
+
+# This is the directory where all logfiles for
+# all virtual servers will be written
+
+logdir = /var/log/yaws
+
+# This the path to a directory where additional
+# beam code can be placed. The daemon will add this
+# directory to its search path
+
+ebin_dir = /var/yaws/ebin
+
+
+# This is a directory where application specific .hrl
+# files can be placed. application specifig .yaws code can
+# then include these .hrl files
+
+include_dir = /var/yaws/include
+
+
+
+
+
+# This is a debug variable, possible values are http | traffic | false
+# It is also possible to set the trace (possibly to the tty) while
+# invoking yaws from the shell as in
+# yaws -i -T -x (see man yaws)
+
+trace = false
+
+
+
+
+
+# it is possible to have yaws start additional
+# application specific code at startup
+#
+# runmod = mymodule
+
+
+# By default yaws will copy the erlang error_log and
+# end write it to a wrap log called report.log (in the logdir)
+# this feature can be turned off. This would typically
+# be the case when yaws runs within another larger app
+
+copy_error_log = true
+
+
+# Logs are wrap logs
+
+log_wrap_size = 1000000
+
+
+# Possibly resolve all hostnames in logfiles so webalizer
+# can produce the nice geography piechart
+
+log_resolve_hostname = false
+
+
+
+# fail completely or not if yaws fails
+# to bind a listen socket
+fail_on_bind_err = true
+
+
+
+# If yaws is started as root, it can, once it has opened
+# all relevant sockets for listening, change the uid to a
+# user with lower accessrights than root
+
+# username = nobody
+
+
+# If HTTP auth is used, it is possible to have a specific
+# auth log.
+
+auth_log = true
+
+
+# When we're running multiple yaws systems on the same
+# host, we need to give each yaws system an individual
+# name. Yaws will write a number of runtime files under
+# /tmp/yaws/${id}
+# The default value is "default"
+
+
+# id = myname
+
+
+# earlier versions of Yaws picked the first virtual host
+# in a list of hosts with the same IP/PORT when the Host:
+# header doesn't match any name on any Host
+# This is often nice in testing environments but not
+# acceptable in real live hosting scenarios
+
+pick_first_virthost_on_nomatch = true
+
+
+# All unices are broken since it's not possible to bind to
+# a privileged port (< 1024) unless uid==0
+# There is a contrib in jungerl which makes it possible by means
+# of an external setuid root programm called fdsrv to listen to
+# to privileged port.
+# If we use this feature, it requires fdsrv to be properly installed.
+# Doesn't yet work with SSL.
+
+use_fdsrv = false
+
+
+
+
+# end then a set of virtual servers
+# First two virthosted servers on the same IP (0.0.0.0)
+# in this case, but an explicit IP can be given as well
+
+<server core.martinjlogan.com>
+ port = 80
+ listen = 0.0.0.0
+ docroot = /var/yaws/www
+ arg_rewrite_mod = pwr_arg_rewrite_mod
+ appmods = <pwr, pwr_main_controller_appmod>
+</server>
+
+<server localhost>
+ port = 80
+ listen = 0.0.0.0
+ docroot = /tmp
+ dir_listings = true
+ dav = true
+ <auth>
+ realm = foobar
+ dir = /
+ user = foo:bar
+ user = baz:bar
+ </auth>
+</server>
+
+
+
+# And then an ssl server
+
+<server core.martinjlogan.com>
+ port = 443
+ docroot = /tmp
+ listen = 0.0.0.0
+ dir_listings = true
+ <ssl>
+ keyfile = /usr/local/yaws/etc/yaws-key.pem
+ certfile = /usr/local/yaws/etc/yaws-cert.pem
+ </ssl>
+</server>
+
+
+
+
+
+
+
+
--- /dev/null
+%%% -*- mode:erlang -*-
+%%% Parameter settings for apps on %APP_NAME%
+%%% Warning - this config file *must* end with <dot><whitespace>
+
+%% write log files to sasl_dir
+[
+ {sasl,
+ [
+ {sasl_error_logger, {file, "%LOG_OTP%/sasl_log"}}
+ ]},
+
+
+ {gas,
+ [
+ {mod_specs, [{elwrap, {fs_elwrap_h, start_link}}]},
+
+ % elwrap config.
+ {err_log, "%LOG_OTP%/err_log"},
+ {err_log_wrap_info, {{err,5000000,10},{sasl,5000000,10}}},
+ {err_log_tty, true} % Log to the screen
+ ]},
+
+ {%APP_NAME%,
+ [
+ ]}
+].
--- /dev/null
+%%% -*- mode:erlang -*-
+{release,
+ {"thrift_rel", "%REL_VSN%"},
+ erts,
+ [
+ kernel,
+ stdlib,
+ sasl,
+ fslib,
+ gas,
+ thrift
+ ]
+}.
+
--- /dev/null
+%%% -*- mode:erlang -*-
+{release,
+ {"thrift_rel", "1.0"},
+ erts,
+ [
+ kernel,
+ stdlib,
+ sasl,
+ fslib,
+ gas,
+ thrift
+ ]
+}.
+
--- /dev/null
+REL_VSN=1.0
--- /dev/null
+
+# conf for yaws
+
+
+# first we have a set of globals
+# That apply to all virtual servers
+
+
+# This is the directory where all logfiles for
+# all virtual servers will be written
+
+logdir = /var/log/yaws
+
+# This the path to a directory where additional
+# beam code can be placed. The daemon will add this
+# directory to its search path
+
+ebin_dir = /var/yaws/ebin
+
+
+# This is a directory where application specific .hrl
+# files can be placed. application specifig .yaws code can
+# then include these .hrl files
+
+include_dir = /var/yaws/include
+
+
+
+
+
+# This is a debug variable, possible values are http | traffic | false
+# It is also possible to set the trace (possibly to the tty) while
+# invoking yaws from the shell as in
+# yaws -i -T -x (see man yaws)
+
+trace = false
+
+
+
+
+
+# it is possible to have yaws start additional
+# application specific code at startup
+#
+# runmod = mymodule
+
+
+# By default yaws will copy the erlang error_log and
+# end write it to a wrap log called report.log (in the logdir)
+# this feature can be turned off. This would typically
+# be the case when yaws runs within another larger app
+
+copy_error_log = true
+
+
+# Logs are wrap logs
+
+log_wrap_size = 1000000
+
+
+# Possibly resolve all hostnames in logfiles so webalizer
+# can produce the nice geography piechart
+
+log_resolve_hostname = false
+
+
+
+# fail completely or not if yaws fails
+# to bind a listen socket
+fail_on_bind_err = true
+
+
+
+# If yaws is started as root, it can, once it has opened
+# all relevant sockets for listening, change the uid to a
+# user with lower accessrights than root
+
+# username = nobody
+
+
+# If HTTP auth is used, it is possible to have a specific
+# auth log.
+
+auth_log = true
+
+
+# When we're running multiple yaws systems on the same
+# host, we need to give each yaws system an individual
+# name. Yaws will write a number of runtime files under
+# /tmp/yaws/${id}
+# The default value is "default"
+
+
+# id = myname
+
+
+# earlier versions of Yaws picked the first virtual host
+# in a list of hosts with the same IP/PORT when the Host:
+# header doesn't match any name on any Host
+# This is often nice in testing environments but not
+# acceptable in real live hosting scenarios
+
+pick_first_virthost_on_nomatch = true
+
+
+# All unices are broken since it's not possible to bind to
+# a privileged port (< 1024) unless uid==0
+# There is a contrib in jungerl which makes it possible by means
+# of an external setuid root programm called fdsrv to listen to
+# to privileged port.
+# If we use this feature, it requires fdsrv to be properly installed.
+# Doesn't yet work with SSL.
+
+use_fdsrv = false
+
+
+
+
+# end then a set of virtual servers
+# First two virthosted servers on the same IP (0.0.0.0)
+# in this case, but an explicit IP can be given as well
+
+<server core.martinjlogan.com>
+ port = 80
+ listen = 0.0.0.0
+ docroot = /var/yaws/www
+ arg_rewrite_mod = pwr_arg_rewrite_mod
+ appmods = <pwr, pwr_main_controller_appmod>
+</server>
+
+<server localhost>
+ port = 80
+ listen = 0.0.0.0
+ docroot = /tmp
+ dir_listings = true
+ dav = true
+ <auth>
+ realm = foobar
+ dir = /
+ user = foo:bar
+ user = baz:bar
+ </auth>
+</server>
+
+
+
+# And then an ssl server
+
+<server core.martinjlogan.com>
+ port = 443
+ docroot = /tmp
+ listen = 0.0.0.0
+ dir_listings = true
+ <ssl>
+ keyfile = /usr/local/yaws/etc/yaws-key.pem
+ certfile = /usr/local/yaws/etc/yaws-cert.pem
+ </ssl>
+</server>
+
+
+
+
+
+
+
+
+++ /dev/null
--module(tBinaryProtocol).
-
--include("thrift/thrift.hrl").
--include("thrift/protocol/tBinaryProtocol.hrl").
--include("thrift/protocol/tProtocolException.hrl").
-
--export([
- new/1,
- trans/1,
- skip/2,
-
- writeMessageBegin/4, writeMessageEnd/1,
- writeStructBegin/2, writeStructEnd/1,
- writeFieldBegin/4, writeFieldEnd/1, writeFieldStop/1,
- writeMapBegin/4, writeMapEnd/1,
- writeListBegin/3, writeListEnd/1,
- writeSetBegin/3, writeSetEnd/1,
-
- writeBool/2, writeByte/2, writeI16/2, writeI32/2,
- writeI64/2, writeDouble/2, writeString/2,
-
- readMessageBegin/1, readMessageEnd/1,
- readStructBegin/1, readStructEnd/1,
- readFieldBegin/1, readFieldEnd/1,
- readMapBegin/1, readMapEnd/1,
- readListBegin/1, readListEnd/1,
- readSetBegin/1, readSetEnd/1,
-
- readBool/1, readByte/1, readI16/1, readI32/1,
- readI64/1, readDouble/1, readString/1
-]).
-
-new(Trans) ->
- #tBinaryProtocol{trans=Trans}.
-
-trans(This) -> % accessor
- ?ATTR(trans).
-
-skip(This, Type) ->
- tProtocol:skip(This, Type).
-
-writeMessageBegin(This, Name, Type, Seqid) ->
- writeI32(This, ?VERSION_1 bor Type),
- writeString(This, Name),
- writeI32(This, Seqid).
-
-writeMessageEnd(This) ->
- This, % suppress unused warnings
- ok.
-
-writeStructBegin(This, Name) ->
- This, Name, % suppress unused warnings
- ok.
-
-writeStructEnd(This) ->
- This, % suppress unused warnings
- ok.
-
-writeFieldBegin(This, Name, Type, Id) ->
- Name,
- writeByte(This, Type),
- writeI16(This, Id).
-
-writeFieldEnd(This) ->
- This, % suppress unused warnings
- ok.
-
-writeFieldStop(This) ->
- writeByte(This, ?tType_STOP).
-
-writeMapBegin(This, Ktype, Vtype, Size) ->
- writeByte(This, Ktype),
- writeByte(This, Vtype),
- writeI32(This, Size).
-
-writeMapEnd(This) ->
- This, % suppress unused warnings
- ok.
-
-writeListBegin(This, Etype, Size) ->
- writeByte(This, Etype),
- writeI32(This, Size).
-
-writeListEnd(This) ->
- This, % suppress unused warnings
- ok.
-
-writeSetBegin(This, Etype, Size) ->
- writeByte(This, Etype),
- writeI32(This, Size).
-
-writeSetEnd(This) ->
- This, % suppress unused warnings
- ok.
-
-%
-
-writeBool(This, Bool) ->
- if Bool -> % true
- writeByte(This, 1);
- true -> % false
- writeByte(This, 0)
- end.
-
-writeByte(This, Byte) ->
- Trans = This#tBinaryProtocol.trans,
- ?M1(Trans, write, binary_to_list(<<Byte:8/big>>)).
-
-writeI16(This, I16) ->
- Trans = This#tBinaryProtocol.trans,
- ?M1(Trans, write, binary_to_list(<<I16:16/big>>)).
-
-writeI32(This, I32) ->
- Trans = This#tBinaryProtocol.trans,
- ?M1(Trans, write, binary_to_list(<<I32:32/big>>)).
-
-writeI64(This, I64) ->
- Trans = This#tBinaryProtocol.trans,
- ?M1(Trans, write, binary_to_list(<<I64:64/big>>)).
-
-writeDouble(This, Double) ->
- Trans = This#tBinaryProtocol.trans,
- ?M1(Trans, write, binary_to_list(<<Double:64/big>>)).
-
-writeString(This, Str) ->
- Trans = This#tBinaryProtocol.trans,
- writeI32(This, length(Str)),
- ?M1(Trans, write, Str).
-
-%
-
-readMessageBegin(This) ->
- Version = readI32(This),
- if
- (Version band ?VERSION_MASK) /= ?VERSION_1 ->
- throw(tProtocolException:new(?tProtocolException_BAD_VERSION,
- "Missing version identifier"));
- true -> ok
- end,
- Type = Version band 16#000000ff,
- Name = readString(This),
- Seqid = readI32(This),
- { Name, Type, Seqid }.
-
-readMessageEnd(This) ->
- This, % suppress unused warnings
- ok.
-
-readStructBegin(This) ->
- This, % suppress unused warnings
- ok.
-
-readStructEnd(This) ->
- This, % suppress unused warnings
- ok.
-
-readFieldBegin(This) ->
- Type = readByte(This),
- if Type == ?tType_STOP ->
- { nil, Type, 0 }; % WATCH
- true ->
- Id = readI16(This),
- { nil, Type, Id }
- end.
-
-readFieldEnd(This) ->
- This, % suppress unused warnings
- ok.
-
-readMapBegin(This) ->
- Ktype = readByte(This),
- Vtype = readByte(This),
- Size = readI32(This),
- { Ktype, Vtype, Size }.
-
-readMapEnd(This) ->
- This, % suppress unused warnings
- ok.
-
-readListBegin(This) ->
- Etype = readByte(This),
- Size = readI32(This),
- { Etype, Size }.
-
-readListEnd(This) ->
- This, % suppress unused warnings
- ok.
-
-readSetBegin(This) ->
- Etype = readByte(This),
- Size = readI32(This),
- { Etype, Size }.
-
-readSetEnd(This) ->
- This, % suppress unused warnings
- ok.
-
-% WATCH everything ... who knows what of this will work
-
-readBool(This) ->
- Byte = readByte(This),
- (Byte /= 0).
-
-readByte(This) ->
- Trans = This#tBinaryProtocol.trans,
- <<Val:8/integer-signed-big, _/binary>> = ?M1(Trans, readAll, 1),
- Val.
-
-readI16(This) ->
- Trans = This#tBinaryProtocol.trans,
- <<Val:16/integer-signed-big, _/binary>> = ?M1(Trans, readAll, 2),
- Val.
-
-readI32(This) ->
- Trans = This#tBinaryProtocol.trans,
- <<Val:32/integer-signed-big, _/binary>> = ?M1(Trans, readAll, 4),
- Val.
-
-readI64(This) ->
- Trans = This#tBinaryProtocol.trans,
- <<Val:64/integer-signed-big, _/binary>> = ?M1(Trans, readAll, 8),
- Val.
-
-readDouble(This) ->
- Trans = This#tBinaryProtocol.trans,
- <<Val:64/float-signed-big, _/binary>> = ?M1(Trans, readAll, 8),
- Val.
-
-readString(This) ->
- Trans = This#tBinaryProtocol.trans,
- Sz = readI32(This),
- binary_to_list(?M1(Trans, readAll, Sz)).
+++ /dev/null
--define(VERSION_MASK, 16#FFFF0000).
--define(VERSION_1, 16#80010000).
--record(tBinaryProtocol, {trans}).
-
+++ /dev/null
--module(tProtocol).
-
--include("thrift/thrift.hrl").
--include("thrift/protocol/tProtocol.hrl").
-
--export([new/1, skip/2]).
-
-skip_struct_loop(This) ->
- { Name, Type, Id } = ?M0(This, readFieldBegin),
- Name, Id, % suppress unused warnings
- if
- Type == ?tType_STOP ->
- ok;
- true ->
- skip(This, Type),
- ?M0(This, readFieldEnd),
-
- %% this is here in original tprotocol.rb, but i think it's a bug
- % ?M0(This, readStructEnd),
- skip_struct_loop(This)
- end.
-
-skip_map_repeat(This, Ktype, Vtype, Times) ->
- skip(This, Ktype),
- skip(This, Vtype),
- skip_map_repeat(This, Ktype, Vtype, Times-1).
-
-skip_set_repeat(This, Etype, Times) ->
- skip(This, Etype),
- skip_set_repeat(This, Etype, Times-1).
-
-new(Trans) ->
- #tProtocol{trans=Trans}.
-
-skip(This, Type) ->
- case Type of
- ?tType_STOP -> nil; % WATCH
- ?tType_BOOL -> ?M0(This, readBool);
- ?tType_BYTE -> ?M0(This, readByte);
- ?tType_I16 -> ?M0(This, readI16);
- ?tType_I32 -> ?M0(This, readI32);
- ?tType_I64 -> ?M0(This, readI64);
- ?tType_DOUBLE -> ?M0(This, readDouble);
- ?tType_STRING -> ?M0(This, readString);
-
- ?tType_STRUCT ->
- ?M0(This, readStructBegin),
- skip_struct_loop(This),
-
- %% this isn't here in the original tprotocol.rb, but i think it's a bug
- ?M0(This, readStructEnd);
-
- ?tType_MAP ->
- {Ktype, Vtype, Size} = ?M0(This, readMapBegin),
- skip_map_repeat(This, Ktype, Vtype, Size),
- ?M0(This, readMapEnd);
-
- ?tType_SET ->
- {Etype, Size} = ?M0(This, readSetBegin),
- skip_set_repeat(This, Etype, Size),
- ?M0(This, readSetEnd);
-
- ?tType_LIST ->
- {Etype, Size} = ?M0(This, readListBegin),
- skip_set_repeat(This, Etype, Size), % [sic] skipping same as for SET
- ?M0(This, readListEnd)
- end.
-
-
+++ /dev/null
--record(tProtocol, {trans}).
+++ /dev/null
--module(tProtocolException).
--include("tProtocolException.hrl").
--export([new/2, new/1, new/0]).
-
-new(Type, Message) ->
- #tProtocolException{type=Type, message=Message}.
-
-new(Type) -> new(Type, nil).
-new() -> new(?tProtocolException_UNKNOWN, nil).
+++ /dev/null
--record(tProtocolException, {message, type}).
-
--define(tProtocolException_UNKNOWN, 0).
--define(tProtocolException_INVALID_DATA, 1).
--define(tProtocolException_NEGATIVE_SIZE, 2).
--define(tProtocolException_SIZE_LIMIT, 3).
--define(tProtocolException_BAD_VERSION, 4).
-
+++ /dev/null
--module(tServer).
-
--include("thrift/thrift.hrl").
--include("thrift/protocol/tProtocol.hrl").
--include("thrift/protocol/tBinaryProtocol.hrl").
-% -include("thrift/transport/tTransport.hrl").
--include("tServer.hrl").
-
--export([new/3, serve/1]).
-
-% now processor is the module with process_*, not an object
-
-new(ProcessorModule, HandlerModule, ServerTransport) ->
- #tServer{processorModule=ProcessorModule,
- handlerModule=HandlerModule,
- serverTransport=ServerTransport}.
-
-serverTransport(This) ->
- This#tServer.serverTransport.
-
-serve(This) ->
- ST1 = ?M0(serverTransport(This), listen_MUTABLE),
- This1 = This#tServer{serverTransport=ST1},
- serve_loop(This1).
-
-processorModule(This) ->
- This#tServer.processorModule.
-
-handlerModule(This) ->
- This#tServer.handlerModule.
-
-serve_loop(This) ->
- io:format("~nready.~n", []),
- Client = ?M0(serverTransport(This), accept_MUTABLE),
- This1 = This#tServer{serverTransport=Client},
-
- Trans = Client, % factory
- Prot = tBinaryProtocol:new(Trans),
- serve_loop_loop(This1, Prot), % giggle loop?
- ?M0(Trans, close_MUTABLE), % don't "assign" ... discard
- serve_loop(This).
-
-serve_loop_loop(This, Prot) ->
- Next = try
- Val = (processorModule(This)):process(handlerModule(This), Prot, Prot),
- io:format("request processed: rv=~p~n", [Val]),
- loop
- catch
- %% TODO(cpiro) case when is_record(...) to pick out our exception
- %% records vs. normal erlang throws
- {tTransportException,_,_} ->
- io:format("tTransportException (normal-ish?)~n", []),
- close;
- E ->
- io:format("EXCEPTION: ~p~n", [E]),
- close
- end,
- case Next of
- loop -> serve_loop_loop(This, Prot);
- close -> ok
- end.
-
+++ /dev/null
--record(tServer, {processorModule, handlerModule, serverTransport}).
+++ /dev/null
--module(tApplicationException).
-
--include("thrift.hrl").
-% -include("tApplicationException.hrl").
-
--export([new/0, new/1, new/2, read/2, write/2]).
-
-new(Type, Message) ->
- #tApplicationException{type=Type, message=Message}.
-
-new() -> new(?tApplicationException_UNKNOWN, nil). % WATCH
-new(Type) -> new(Type, nil). % WATCH
-
-read(This, Iprot) ->
- ?M0(Iprot, readStructBegin),
- read_while_loop(This, Iprot),
- ?M0(Iprot, readStructEnd),
- This.
-
-read_while_loop(This, Iprot) ->
- {_, Ftype, Fid} = ?M0(Iprot, readFieldBegin), % field = {fname, ftype, fid}
-
- if
- Ftype == ?tType_STOP ->
- This;
- (Fid == 1) and (Ftype == ?tType_STRING) ->
- This1 = This#tApplicationException{message=?M0(Iprot, readString)},
- ?M0(Iprot, readFieldEnd),
- read_while_loop(This1, Iprot);
-
- Fid == 1 ->
- ?M0(Iprot, skip),
- ?M0(Iprot, readFieldEnd),
- read_while_loop(This, Iprot);
-
- (Fid == 2) and (Ftype == ?tType_I32) ->
- This1 = This#tApplicationException{type=?M0(Iprot, readI32)},
- ?M0(Iprot, readFieldEnd),
- read_while_loop(This1, Iprot);
-
- true ->
- ?M0(Iprot, skip),
- ?M0(Iprot, readFieldEnd),
- read_while_loop(This, Iprot)
- end.
-
-write(This, Oprot) ->
- ?M1(Oprot, writeStructBegin, "tApplicationException"),
- Message = This#tApplicationException.message,
- Type = This#tApplicationException.type,
- if Message /= undefined ->
- ?M3(Oprot, writeFieldBegin, "message", ?tType_STRING, 1),
- ?M1(Oprot, writeString, Message),
- ?M0(Oprot, writeFieldEnd);
- true -> ok
- end,
- if Type /= undefined ->
- ?M3(Oprot, writeFieldBegin, "type", ?tType_I32, 2),
- ?M1(Oprot, writeI32, Type),
- ?M0(Oprot, writeFieldEnd);
- true -> ok
- end,
- ?M0(Oprot, writeFieldStop),
- ?M0(Oprot, writeStructEnd).
+++ /dev/null
--module(tException).
--include("tException.hrl").
--export([new/0]).
-
-new() ->
- #tException{}.
-
+++ /dev/null
--record(tException, {message}).
+++ /dev/null
--define(CLASS(Obj), element(1,Obj)).
-
--define(M0(Obj, Method), ((?CLASS(Obj)):Method(Obj))).
--define(M1(Obj, Method, Arg1), ((?CLASS(Obj)):Method(Obj, Arg1))).
--define(M2(Obj, Method, Arg1, Arg2), ((?CLASS(Obj)):Method(Obj, Arg1, Arg2))).
--define(M3(Obj, Method, Arg1, Arg2, Arg3), ((?CLASS(Obj)):Method(Obj, Arg1, Arg2, Arg3))).
--define(M4(Obj, Method, Arg1, Arg2, Arg3, Arg4), ((?CLASS(Obj)):Method(Obj, Arg1, Arg2, Arg3, Arg4))).
--define(M5(Obj, Method, Arg1, Arg2, Arg3, Arg4, Arg5), ((?CLASS(Obj)):Method(Obj, Arg1, Arg2, Arg3, Arg4, Arg5))).
--define(M6(Obj, Method, Arg1, Arg2, Arg3, Arg4, Arg5, Arg6), ((?CLASS(Obj)):Method(Obj, Arg1, Arg2, Arg3, Arg4, Arg5, Arg6))).
-
--define(ATTR(X), This#?MODULE.X).
-
-%% TType
--define(tType_STOP, 0).
--define(tType_VOID, 1).
--define(tType_BOOL, 2).
--define(tType_BYTE, 3).
--define(tType_DOUBLE, 4).
--define(tType_I16, 6).
--define(tType_I32, 8).
--define(tType_I64, 10).
--define(tType_STRING, 11).
--define(tType_STRUCT, 12).
--define(tType_MAP, 13).
--define(tType_SET, 14).
--define(tType_LIST, 15).
-
-% tmessagetype
--define(tMessageType_CALL, 1).
--define(tMessageType_REPLY, 2).
--define(tMessageType_EXCEPTION, 3).
-
-% TProcessor
-% ?
-
--include("thrift/tApplicationException.hrl").
+++ /dev/null
--module(tBufferedTransport).
-
--include("thrift/thrift.hrl").
--include("thrift/transport/tBufferedTransport.hrl").
-
--export([new/1, isOpen/1, open/1, close/1, read/2, write_MUTABLE/2, flush_MUTABLE/1]).
-
-new(Transport) ->
- #tBufferedTransport{transport=Transport, wbuf=""}.
-
-transport(This) -> % local accessor
- This#tBufferedTransport.transport.
-
-isOpen(This) ->
- ?M0(transport(This), isOpen).
-
-open(This) ->
- ?M0(transport(This), open).
-
-close(This) ->
- ?M0(transport(This), close).
-
-read(This, Sz) ->
- ?M1(transport(This), read, Sz).
-
-write_MUTABLE(This, Buf) -> % be sure to rebind This to the retval
- Wbuf = This#tBufferedTransport.wbuf,
- This#tBufferedTransport{wbuf=Wbuf++Buf}. % TODO: ++ efficiency?
-
-flush_MUTABLE(This) -> % be sure to rebind This to the retval
- Wbuf = This#tBufferedTransport.wbuf,
- ?M1(transport(This), write, Wbuf),
- ?M0(transport(This), flush),
- This#tBufferedTransport{wbuf=""}. % TODO: ++ efficiency?
+++ /dev/null
--record(tBufferedTransport, {transport, wbuf}).
+++ /dev/null
--module(tServerSocket).
--include("tServerSocket.hrl").
-
--export([new/1, listen_MUTABLE/1, accept_MUTABLE/1, close/1]).
-
-new(Port) ->
- #tServerSocket{port=Port, handle=nil}.
-
-listen_MUTABLE(This) ->
- Port = This#tServerSocket.port,
- Options = [binary, {packet, 0}, {active, false}], % was []
-
- case gen_tcp:listen(Port, Options) of
- {ok, ListenSocket} ->
- This#tServerSocket{handle=ListenSocket}
- % {error, _} ->
- % TODO: no error handling in Ruby version?
- end.
-
-accept_MUTABLE(This) ->
- if
- This#tServerSocket.handle /= nil ->
- case gen_tcp:accept(This#tServerSocket.handle) of
- {ok, Socket} ->
- tSocket:setHandle_MUTABLE( tSocket:new(), Socket )
- % {error, _} ->
- % TODO: no error handling in Ruby version?
- end;
- true ->
- nil
- end.
-
-close(This) ->
- if
- This#tServerSocket.handle /= nil ->
- case gen_tcp:close(This#tServerSocket.handle) of
- ok ->
- ok
- % {error, _} ->
- % TODO: no error handling in Ruby version?
- end;
- true ->
- ok
- end.
+++ /dev/null
--record(tServerSocket, {port, handle}).
+++ /dev/null
--module(tSocket).
-
--include("thrift/thrift.hrl").
--include("thrift/transport/tTransportException.hrl").
-% -include("thrift/transport/tTransport.hrl").
--include("thrift/transport/tSocket.hrl").
-
--export([new/0, new/1, new/2, setHandle_MUTABLE/2, open_MUTABLE/1, isOpen/1, write/2, read/2, close_MUTABLE/1, readAll/2]).
-
-new(Host, Port) ->
- #tSocket{host=Host, port=Port, handle=nil}. % WATCH
-
-new() -> new("localhost", 9090).
-new(Host) -> new(Host, 9090).
-
-setHandle_MUTABLE(This, Handle) ->
- This#tSocket{handle=Handle}.
-
-open_MUTABLE(This) ->
- Host = This#tSocket.host,
- Port = This#tSocket.port,
- Options = [],
-
- case gen_tcp:connect(Host, Port, Options) of
- {error, _} ->
- throw(tTransportException:new(
- ?tTransportException_NOT_OPEN,
- "Could not connect to " ++ Host ++ ":" ++ Port)
- ),
- {error, This}; % cpiro not reached?
- {ok, Socket} ->
- {ok, This#tSocket{handle=Socket}}
- end.
-
-handle(This) ->
- This#tSocket.handle.
-
-isOpen(This) ->
- handle(This) /= nil.
-
-write(This, Str) ->
- Val = gen_tcp:send(handle(This), Str),
-
- %% io:format("WRITE |~p|(~p)~n", [Str,Val]),
-
- case Val of
- {error, _} ->
- throw(tTransportException:new(?tTransportException_NOT_OPEN, "in write"));
- ok ->
- ok
- end.
-
-read(This, Sz) ->
- case gen_tcp:recv(handle(This), Sz) of
- {ok, []} ->
- { Host, Port } = { This#tSocket.host, This#tSocket.port },
- throw(tTransportException:new(?tTransportException_UNKNOWN, "TSocket: Could not read " ++ Sz ++ "bytes from " ++ Host ++ ":" ++ Port));
- {ok, Data} ->
- Data;
- {error, Error} ->
- io:format("in tSocket:read/2: gen_tcp:recv(~p, ~p) => {error, ~p}~n",
- [handle(This), Sz, Error]),
- throw(tTransportException:new(?tTransportException_NOT_OPEN, "in tSocket:read/2: gen_tcp:recv"))
- end.
-
-close_MUTABLE(This) ->
- if
- This#tSocket.handle == nil ->
- This;
- true ->
- gen_tcp:close(handle(This)),
- This#tSocket{handle=nil}
- end.
-
-readAll(This, Sz) ->
- readAll_loop(This, Sz, "", 0).
-
-readAll_loop(This, Sz, Buff, Have) ->
- if
- Have < Sz ->
- Chunk = ?M1(This, read, Sz - Have),
-
- %% man gen_tcp:
- %% exactly Length bytes are returned, or an error;
- %% possibly discarding less than Length bytes of data when
- %% the socket gets closed from the other side.
-
- %% io:format("READ |~p|~n", [Chunk]),
-
- Have1 = Have + (Sz-Have), % length(Chunk)
- Buff1 = Buff ++ Chunk, % TODO: ++ efficiency?
- readAll_loop(This, Sz, Buff1, Have1);
- true ->
- Buff
- end.
-
+++ /dev/null
--record(tSocket, {host, port, handle}).
+++ /dev/null
--module(tTransport).
-
--include("thrift/transport/tTransportException.hrl").
-
+++ /dev/null
--module(tTransportException).
-
--include("thrift/thrift.hrl").
--include("thrift/transport/tTransportException.hrl").
-
--export([new/0, new/1, new/2, message/1]).
-
-new(Type, Message) ->
- #tTransportException{type = Type, message = Message}.
-
-new() -> new(?tTransportException_UNKNOWN, nil). % WATCH
-new(Type) -> new(Type, nil). % WATCH
-
-message(This) ->
- ?ATTR(message).
+++ /dev/null
--define(tTransportException_UNKNOWN, 0).
--define(tTransportException_NOT_OPEN, 1).
--define(tTransportException_ALREADY_OPEN, 2).
--define(tTransportException_TIMED_OUT, 3).
--define(tTransportException_END_OF_FILE, 4).
-
--record(tTransportException, {type, message}).
+++ /dev/null
-src-loose
\ No newline at end of file
--- /dev/null
+MODULES = \
+ src
+
+all clean docs:
+ for dir in $(MODULES); do \
+ (cd $$dir; ${MAKE} $@); \
+ done
--- /dev/null
+# $Id: Makefile,v 1.3 2004/08/13 16:35:59 mlogan Exp $
+#
+include ../../../build/otp.mk
+include ../../../build/colors.mk
+include ../../../build/buildtargets.mk
+
+# ----------------------------------------------------
+# Application version
+# ----------------------------------------------------
+
+include ../vsn.mk
+APP_NAME=%%APP_NAME%%
+PFX=%%PFX%%
+VSN=$(%%APP_NAME_UPPER_CASE%%_VSN)
+
+# ----------------------------------------------------
+# Install directory specification
+# WARNING: INSTALL_DIR the command to install a directory.
+# INSTALL_DST is the target directory
+# ----------------------------------------------------
+INSTALL_DST = $(ERLANG_OTP)/lib/$(APP_NAME)-$(VSN)
+
+# ----------------------------------------------------
+# Target Specs
+# ----------------------------------------------------
+
+
+MODULES = $(shell ls *.erl | sed s/.erl//)
+MODULES_COMMA = $(shell ls *.erl | sed s/\\.erl/,/)
+
+HRL_FILES=
+INTERNAL_HRL_FILES= $(APP_NAME).hrl
+ERL_FILES= $(MODULES:%=%.erl)
+DOC_FILES=$(ERL_FILES)
+
+APP_FILE= $(APP_NAME).app
+APPUP_FILE= $(APP_NAME).appup
+
+APP_SRC= $(APP_FILE).src
+APPUP_SRC= $(APPUP_FILE).src
+
+APP_TARGET= $(EBIN)/$(APP_FILE)
+APPUP_TARGET= $(EBIN)/$(APPUP_FILE)
+
+BEAMS= $(MODULES:%=$(EBIN)/%.$(EMULATOR))
+TARGET_FILES= $(BEAMS) $(APP_TARGET) $(APPUP_TARGET)
+
+WEB_TARGET=/var/yaws/www/$(APP_NAME)
+
+# ----------------------------------------------------
+# FLAGS
+# ----------------------------------------------------
+
+ERL_FLAGS +=
+ERL_COMPILE_FLAGS += -I../include -I../../fslib/include -I../../system_status/include
+
+# ----------------------------------------------------
+# Targets
+# ----------------------------------------------------
+
+all debug opt: $(EBIN) $(TARGET_FILES)
+
+#$(EBIN)/rm_logger.beam: $(APP_NAME).hrl
+include ../../../build/docs.mk
+
+# Note: In the open-source build clean must not destroy the preloaded
+# beam files.
+clean:
+ rm -f $(TARGET_FILES)
+ rm -f core
+ rm -rf $(EBIN)
+ rm -rf *html
+
+$(EBIN):
+ mkdir $(EBIN)
+
+# ----------------------------------------------------
+# Special Build Targets
+# ----------------------------------------------------
+
+$(APP_TARGET): $(APP_SRC) ../vsn.mk $(BEAMS)
+ sed -e 's;%VSN%;$(VSN);' \
+ -e 's;%PFX%;$(PFX);' \
+ -e 's;%APP_NAME%;$(APP_NAME);' \
+ -e 's;%MODULES%;%MODULES%$(MODULES_COMMA);' \
+ $< > $<".tmp"
+ sed -e 's/%MODULES%\(.*\),/\1/' \
+ $<".tmp" > $@
+ rm $<".tmp"
+
+
+$(APPUP_TARGET): $(APPUP_SRC) ../vsn.mk
+ sed -e 's;%VSN%;$(VSN);' $< > $@
+
+$(WEB_TARGET): ../markup/*
+ rm -rf $(WEB_TARGET)
+ mkdir $(WEB_TARGET)
+ cp -r ../markup/ $(WEB_TARGET)
+ cp -r ../skins/ $(WEB_TARGET)
+
+# ----------------------------------------------------
+# Install Target
+# ----------------------------------------------------
+
+install: all $(WEB_TARGET)
+# $(INSTALL_DIR) $(INSTALL_DST)/src
+# $(INSTALL_DATA) $(ERL_FILES) $(INSTALL_DST)/src
+# $(INSTALL_DATA) $(INTERNAL_HRL_FILES) $(INSTALL_DST)/src
+# $(INSTALL_DIR) $(INSTALL_DST)/include
+# $(INSTALL_DATA) $(HRL_FILES) $(INSTALL_DST)/include
+# $(INSTALL_DIR) $(INSTALL_DST)/ebin
+# $(INSTALL_DATA) $(TARGET_FILES) $(INSTALL_DST)/ebin
--- /dev/null
+%%%-------------------------------------------------------------------
+%%% @doc
+%%% @end
+%%%-------------------------------------------------------------------
+-module(%%PFX%%_server).
+
+-behaviour(gen_server).
+%%--------------------------------------------------------------------
+%% Include files
+%%--------------------------------------------------------------------
+-include("%%APP_NAME%%.hrl").
+
+%%--------------------------------------------------------------------
+%% External exports
+%%--------------------------------------------------------------------
+-export([
+ start_link/0,
+ stop/0
+ ]).
+
+%%--------------------------------------------------------------------
+%% gen_server callbacks
+%%--------------------------------------------------------------------
+-export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2, code_change/3]).
+
+%%--------------------------------------------------------------------
+%% record definitions
+%%--------------------------------------------------------------------
+-record(state, {}).
+
+%%--------------------------------------------------------------------
+%% macro definitions
+%%--------------------------------------------------------------------
+-define(SERVER, ?MODULE).
+
+%%====================================================================
+%% External functions
+%%====================================================================
+%%--------------------------------------------------------------------
+%% @doc Starts the server.
+%% @spec start_link() -> {ok, pid()} | {error, Reason}
+%% @end
+%%--------------------------------------------------------------------
+start_link() ->
+ gen_server:start_link({local, ?SERVER}, ?MODULE, [], []).
+
+%%--------------------------------------------------------------------
+%% @doc Stops the server.
+%% @spec stop() -> ok
+%% @end
+%%--------------------------------------------------------------------
+stop() ->
+ gen_server:cast(?SERVER, stop).
+
+%%====================================================================
+%% Server functions
+%%====================================================================
+
+%%--------------------------------------------------------------------
+%% Function: init/1
+%% Description: Initiates the server
+%% Returns: {ok, State} |
+%% {ok, State, Timeout} |
+%% ignore |
+%% {stop, Reason}
+%%--------------------------------------------------------------------
+init([]) ->
+ {ok, #state{}}.
+
+%%--------------------------------------------------------------------
+%% Function: handle_call/3
+%% Description: Handling call messages
+%% Returns: {reply, Reply, State} |
+%% {reply, Reply, State, Timeout} |
+%% {noreply, State} |
+%% {noreply, State, Timeout} |
+%% {stop, Reason, Reply, State} | (terminate/2 is called)
+%% {stop, Reason, State} (terminate/2 is called)
+%%--------------------------------------------------------------------
+handle_call(Request, From, State) ->
+ Reply = ok,
+ {reply, Reply, State}.
+
+%%--------------------------------------------------------------------
+%% Function: handle_cast/2
+%% Description: Handling cast messages
+%% Returns: {noreply, State} |
+%% {noreply, State, Timeout} |
+%% {stop, Reason, State} (terminate/2 is called)
+%%--------------------------------------------------------------------
+handle_cast(stop, State) ->
+ {stop, normal, State};
+handle_cast(Msg, State) ->
+ {noreply, State}.
+
+%%--------------------------------------------------------------------
+%% Function: handle_info/2
+%% Description: Handling all non call/cast messages
+%% Returns: {noreply, State} |
+%% {noreply, State, Timeout} |
+%% {stop, Reason, State} (terminate/2 is called)
+%%--------------------------------------------------------------------
+handle_info(Info, State) ->
+ {noreply, State}.
+
+%%--------------------------------------------------------------------
+%% Function: terminate/2
+%% Description: Shutdown the server
+%% Returns: any (ignored by gen_server)
+%%--------------------------------------------------------------------
+terminate(Reason, State) ->
+ ok.
+
+%%--------------------------------------------------------------------
+%% Func: code_change/3
+%% Purpose: Convert process state when code is changed
+%% Returns: {ok, NewState}
+%%--------------------------------------------------------------------
+code_change(OldVsn, State, Extra) ->
+ {ok, State}.
+
+%%====================================================================
+%%% Internal functions
+%%====================================================================
--- /dev/null
+%%%-------------------------------------------------------------------
+%%% @doc
+%%% @end
+%%%-------------------------------------------------------------------
+-module(%%PFX%%_sup).
+
+-behaviour(supervisor).
+%%--------------------------------------------------------------------
+%% Include files
+%%--------------------------------------------------------------------
+
+%%--------------------------------------------------------------------
+%% External exports
+%%--------------------------------------------------------------------
+-export([
+ start_link/1
+ ]).
+
+%%--------------------------------------------------------------------
+%% Internal exports
+%%--------------------------------------------------------------------
+-export([
+ init/1
+ ]).
+
+%%--------------------------------------------------------------------
+%% Macros
+%%--------------------------------------------------------------------
+-define(SERVER, ?MODULE).
+
+%%--------------------------------------------------------------------
+%% Records
+%%--------------------------------------------------------------------
+
+%%====================================================================
+%% External functions
+%%====================================================================
+%%--------------------------------------------------------------------
+%% @doc Starts the supervisor.
+%% @spec start_link(StartArgs) -> {ok, pid()} | Error
+%% @end
+%%--------------------------------------------------------------------
+start_link(StartArgs) ->
+ supervisor:start_link({local, ?SERVER}, ?MODULE, []).
+
+%%====================================================================
+%% Server functions
+%%====================================================================
+%%--------------------------------------------------------------------
+%% Func: init/1
+%% Returns: {ok, {SupFlags, [ChildSpec]}} |
+%% ignore |
+%% {error, Reason}
+%%--------------------------------------------------------------------
+init([]) ->
+ RestartStrategy = one_for_one,
+ MaxRestarts = 1000,
+ MaxTimeBetRestarts = 3600,
+
+ SupFlags = {RestartStrategy, MaxRestarts, MaxTimeBetRestarts},
+
+ ChildSpecs =
+ [
+ {%%PFX%%_server,
+ {%%PFX%%_server, start_link, []},
+ permanent,
+ 1000,
+ worker,
+ [%%PFX%%_server]}
+ ],
+ {ok,{SupFlags, ChildSpecs}}.
+%%====================================================================
+%% Internal functions
+%%====================================================================
--- /dev/null
+%%% -*- mode:erlang -*-
+{application, %APP_NAME%,
+ [
+ % A quick description of the application.
+ {description, "An Erlang Application."},
+
+ % The version of the applicaton
+ {vsn, "%VSN%"},
+
+ % All modules used by the application.
+ {modules,
+ [
+ %MODULES%
+ ]},
+
+ % All of the registered names the application uses. This can be ignored.
+ {registered, []},
+
+ % Applications that are to be started prior to this one. This can be ignored
+ % leave it alone unless you understand it well and let the .rel files in
+ % your release handle this.
+ {applications,
+ [
+ kernel,
+ stdlib
+ ]},
+
+ % OTP application loader will load, but not start, included apps. Again
+ % this can be ignored as well. To load but not start an application it
+ % is easier to include it in the .rel file followed by the atom 'none'
+ {included_applications, []},
+
+ % configuration parameters similar to those in the config file specified
+ % on the command line. can be fetched with gas:get_env
+ {env, []},
+
+ % The Module and Args used to start this application.
+ {mod, {%APP_NAME%, []}}
+ ]
+}.
+
--- /dev/null
+{"%VSN%",[],[]}.
--- /dev/null
+%%%-------------------------------------------------------------------
+%%% @doc
+%%% @end
+%%%-------------------------------------------------------------------
+-module(%%APP_NAME%%).
+
+-behaviour(application).
+%%--------------------------------------------------------------------
+%% Include files
+%%--------------------------------------------------------------------
+-include("%%APP_NAME%%.hrl").
+
+%%--------------------------------------------------------------------
+%% External exports
+%%--------------------------------------------------------------------
+-export([
+ start/2,
+ shutdown/0,
+ stop/1
+ ]).
+
+%%--------------------------------------------------------------------
+%% Macros
+%%--------------------------------------------------------------------
+
+%%--------------------------------------------------------------------
+%% Records
+%%--------------------------------------------------------------------
+
+%%====================================================================
+%% External functions
+%%====================================================================
+%%--------------------------------------------------------------------
+%% @doc The starting point for an erlang application.
+%% @spec start(Type, StartArgs) -> {ok, Pid} | {ok, Pid, State} | {error, Reason}
+%% @end
+%%--------------------------------------------------------------------
+start(Type, StartArgs) ->
+ case %%PFX%%_sup:start_link(StartArgs) of
+ {ok, Pid} ->
+ {ok, Pid};
+ Error ->
+ Error
+ end.
+
+%%--------------------------------------------------------------------
+%% @doc Called to shudown the %%APP_NAME%% application.
+%% @spec shutdown() -> ok
+%% @end
+%%--------------------------------------------------------------------
+shutdown() ->
+ application:stop(%%APP_NAME%%).
+
+%%====================================================================
+%% Internal functions
+%%====================================================================
+
+%%--------------------------------------------------------------------
+%% Called upon the termintion of an application.
+%%--------------------------------------------------------------------
+stop(State) ->
+ ok.
+
--- /dev/null
+%%APP_NAME_UPPER_CASE%%_VSN=1.0
--- /dev/null
+# ----------------------------------------------------
+# Make file for creating an otp release.
+# ----------------------------------------------------
+
+##
+# Basename of this release.
+##
+RELS=$(shell basename `pwd`)
+APP_NAME=$(shell echo $(RELS) | sed s/_rel$$//)
+
+include ../../build/otp.mk
+
+include ./vsn.mk
+
+#include $(ERL_TOP)/make/target.mk
+#include $(ERL_TOP)/make/$(TARGET)/otp.mk
+
+USR_LIBPATH=../../lib
+INSTALL_DIR=/usr/local/lib
+ABS_USER_LIBPATH=$(shell cd ../../lib;pwd)
+
+# ----------------------------------------------------
+# CREATE DIR STRUCTURE HERE
+# ----------------------------------------------------
+
+HTDOCS=$(wildcard $(ABS_USER_LIBPATH)/$(APP_NAME)/htdocs/*.html) \
+ $(wildcard $(ABS_USER_LIBPATH)/$(APP_NAME)/htdocs/*.htm) \
+ $(wildcard $(ABS_USER_LIBPATH)/$(APP_NAME)/htdocs/*.yaws)
+BUILD_FILES=fs_boot_smithe.beam fs_lists.beam fs_lib.beam
+
+LOCAL_DIR=local
+#LOCAL_DIR=$(shell cat $(RELS).rel.src |grep -m 1 '$(APP_NAME)' |awk -F '"' '{printf "%s-%s", $$2,$$4}')
+
+DIR_STRUCTURE= \
+ $(LOCAL_DIR) \
+ $(LOCAL_DIR)/log/$(REL_VSN) \
+ $(LOCAL_DIR)/var/$(REL_VSN) \
+ $(LOCAL_DIR)/var/$(REL_VSN)/www/conf \
+ $(LOCAL_DIR)/var/$(REL_VSN)/www/htdocs
+
+PRODUCTION_DIR_STRUCTURE= \
+ $(RELS) \
+ $(RELS)/release/$(REL_VSN) \
+ $(RELS)/stage \
+ $(RELS)/log/$(REL_VSN) \
+ $(RELS)/var/$(REL_VSN) \
+ $(RELS)/var/$(REL_VSN)/www \
+ $(RELS)/var/$(REL_VSN)/www/htdocs \
+ $(RELS)/var/$(REL_VSN)/www/conf
+
+# ----------------------------------------------------
+SCRIPT_AND_BOOT_FILES= \
+ $(RELS).script \
+ $(RELS).boot
+
+LOCAL_SCRIPT_AND_BOOT_FILES= \
+ $(LOCAL_DIR)/$(RELS).script \
+ $(LOCAL_DIR)/$(RELS).boot
+
+LOCAL_HTTP_CONF= \
+ $(LOCAL_DIR)/var/$(REL_VSN)/www/conf/yaws.conf \
+ $(LOCAL_DIR)/var/$(REL_VSN)/www/conf/mime.types
+
+PRODUCTION_HTTP_CONF= \
+ $(LOCAL_DIR)/var/$(REL_VSN)/www/conf/yaws.conf \
+ $(LOCAL_DIR)/var/$(REL_VSN)/www/conf/mime.types
+
+LOCAL_TARGET_FILES=$(LOCAL_HTTP_CONF) $(LOCAL_DIR)/$(RELS).config $(LOCAL_SCRIPT_AND_BOOT_FILES)
+
+LOCAL_TARGETS=$(LOCAL_DIR)/$(RELS).sh vsnit $(LOCAL_TARGET_FILES)
+
+PRODUCTION_TARGETS=$(RELS)/build/$(REL_VSN) \
+ $(RELS)/lib \
+ $(RELS)/stage/$(RELS).rel.src \
+ $(RELS)/stage/$(RELS).config.src \
+ $(RELS)/stage/yaws.conf.src \
+ $(RELS)/stage/$(RELS).sh.src \
+ $(RELS)/var/$(REL_VSN)/www/htdocs \
+ $(RELS)/install.sh \
+ $(RELS)/release/$(REL_VSN)/clean_release
+
+# ----------------------------------------------------
+# TARGETS
+# ----------------------------------------------------
+
+all debug opt instr script: $(DIR_STRUCTURE) $(LOCAL_TARGETS) $(PRODUCTION_DIR_STRUCTURE) $(PRODUCTION_TARGETS)
+ @echo $(HTDOCS)
+
+install: stage
+
+tar: $(RELS)-$(LOCATION)-$(REL_VSN).tgz
+
+$(DIR_STRUCTURE):
+ mkdir -p $@
+
+$(PRODUCTION_DIR_STRUCTURE):
+ mkdir -p $@
+
+clean:
+ $(RM) $(REL_SCRIPTS) $(TARGET_FILES)
+ $(RM) -r $(LOCAL_DIR) $(PRODN_DIR)
+ $(RM) $(RELS).rel
+ $(RM) -r $(RELS)
+ $(RM) $(RELS)*.tgz
+ $(RM) $(RELS).rel.src.tmp
+ $(RM) $(SCRIPT_AND_BOOT_FILES)
+
+docs:
+
+# ----------------------------------------------------
+# TARGETS FOR LOCAL MODE
+# ----------------------------------------------------
+
+# startup script for local mode
+$(LOCAL_DIR)/$(RELS).sh:
+ @echo '#!/bin/sh' > $@
+ @echo "cd $(CURDIR)/$(LOCAL_DIR)" >> $@
+ @echo "erl -name $${USER}_$(RELS) -boot $(RELS) -config $(RELS).config \$$@" >> $@
+ chmod +x $@
+ @echo
+ @echo "==== Start local node with \"sh $@\" ===="
+ @echo
+
+# Create the config file for local mode.
+$(LOCAL_DIR)/$(RELS).config: $(RELS).config.src
+ sed -e 's;%LOG_OTP%;$(CURDIR)/$(LOCAL_DIR)/log/$(REL_VSN);' \
+ -e 's;%VAR_OTP%;$(CURDIR)/$(LOCAL_DIR)/var/$(REL_VSN);' \
+ -e 's;%RELS%;$(RELS);g' \
+ -e 's;%HOME%;$(HOME);g' \
+ -e 's;%BROADCAST_ADDRESS%;$(BROADCAST_ADDRESS);g' \
+ -e 's;%CONTACT_NODE%;$(CONTACT_NODE);g' \
+ -e "s;%HOSTNAME%;`hostname --long`;" \
+ -e 's;%APP_NAME%;$(APP_NAME);' \
+ -e 's;%APP_VERSION%;$(APP_VERSION);g' \
+ $< > $@
+
+# Create the httpd conf file for local mode.
+$(LOCAL_DIR)/var/$(REL_VSN)/www/conf/yaws.conf: yaws.conf.src
+ sed -e 's;%VAR_OTP%;$(CURDIR)/$(LOCAL_DIR)/var/$(REL_VSN);' \
+ -e 's;%LOG_OTP%;$(CURDIR)/$(LOCAL_DIR)/log/$(REL_VSN);' \
+ -e 's;%HTDOC_ROOT%;$(ABS_USER_LIBPATH)/$(APP_NAME)/htdocs;' \
+ -e 's;%APP_NAME%;$(APP_NAME);' \
+ -e 's;%RELS%;$(RELS);' \
+ -e 's;%USER%;$(USER);' \
+ -e 's;%HTDOC_ROOT%;$(ABS_USER_LIBPATH);' \
+ -e 's;%MHOST%;$(MHOST);' \
+ $< > $@
+
+# Create the config file for local mode.
+vsnit: $(RELS).rel.src
+ sed -e 's;%REL_VSN%;$(REL_VSN);' \
+ $< > $<.tmp
+
+# Create and position script and boot files for local mode.
+$(LOCAL_SCRIPT_AND_BOOT_FILES):
+ @ erl -pz $(USR_LIBPATH)/fslib/ebin \
+ -noshell \
+ -s fs_lib s_apply fs_boot_smithe make_script_and_boot "[\"$(ERL_RUN_TOP)/*\", \"$(USR_LIBPATH)\"]. " \
+ \"$$(basename `pwd`)".rel.src.tmp\". " \
+ "[local]. " \
+ -s init stop
+ cp $(SCRIPT_AND_BOOT_FILES) $(LOCAL_DIR)/
+
+$(LOCAL_DIR)/var/$(REL_VSN)/www/conf/mime.types: ../../build/mime.types
+ cp $< $@
+
+# ----------------------------------------------------
+# TARGETS FOR PRODUCTION MODE
+# ----------------------------------------------------
+$(RELS)/lib:
+ # For some reason this will not happen if added to PRODUCTION_DIR_STRUCTURE
+ mkdir $@
+ @ erl -pz $(RELS)/build/$(REL_VSN) \
+ -noshell \
+ -s fs_lib s_apply fs_boot_smithe stage_from_relsrc "[\"$(USR_LIBPATH)\"]. " \
+ \"$$(basename `pwd`)".rel.src\". " \
+ \"$@\"". " \
+ -s init stop
+
+# Move the htdocs from the local apps to the production htdoc root directory.
+$(RELS)/var/$(REL_VSN)/www/htdocs/: $(HTDOCS)
+ @mkdir -p $(RELS)/var/$(REL_VSN)/www/htdocs; \
+ for x in $(HTDOCS);do \
+ cp $$x $@; \
+ done
+
+# startup script for production mode
+$(RELS)/stage/$(RELS).sh.src:
+ @echo '#!/bin/sh' > $@
+ @echo "cd %INSTALL_DIR%/$(RELS)/release/$(REL_VSN)" >> $@
+ @echo "erl -name $(RELS) -boot $(RELS) -config $(RELS).config -detached \$$@" >> $@
+ chmod +x $@
+
+$(RELS)/build/$(REL_VSN): $(USR_LIBPATH)/fslib/ebin
+ mkdir -p $(RELS)/build/$(REL_VSN)
+ cp $</fs_boot_smithe.beam $@
+ cp $</fs_lib.beam $@
+ cp $</fs_lists.beam $@
+
+$(RELS)/stage/$(RELS).rel.src: $(RELS).rel.src.tmp
+ cp $< $@
+
+$(RELS)/stage/$(RELS).config.src: $(RELS).config.src
+ cp $< $@
+
+$(RELS)/stage/yaws.conf.src: yaws.conf.src
+ cp $< $@
+
+$(RELS)/install.sh:
+ @echo '#!/bin/sh' > $@
+ @echo "" >> $@
+ @echo "if [ \$$# -eq 1 ];then" >> $@
+ @echo " INSTALL_DIR=\$$1;" >> $@
+ @echo "else" >> $@
+ @echo " INSTALL_DIR=$(INSTALL_DIR);" >> $@
+ @echo "fi" >> $@
+ @echo "" >> $@
+ @echo "function munge() {" >> $@
+ @echo " sed -e \"s;%LOG_OTP%;\$$INSTALL_DIR/$(RELS)/log/$(REL_VSN);g\" \\" >> $@
+ @echo " -e \"s;%VAR_OTP%;\$$INSTALL_DIR/$(RELS)/var/$(REL_VSN);g\" \\" >> $@
+ @echo " -e \"s;%RELS%;$(RELS);g\" \\" >> $@
+ @echo " -e \"s;%REL_VSN%;$(REL_VSN);g\" \\" >> $@
+ @echo " -e \"s;%USER%;$$USER;g\" \\" >> $@
+ @echo " -e \"s;%HTDOC_ROOT%;\$$INSTALL_DIR/$(RELS)/var/$(REL_VSN)/www/htdocs;g\" \\" >> $@
+ @echo " -e \"s;%MHOST%;\`hostname\`;g\" \\" >> $@
+ @echo " -e \"s;%BROADCAST_ADDRESS%;$(BROADCAST_ADDRESS);g\" \\" >> $@
+ @echo " -e \"s;%INSTALL_DIR%;\$$INSTALL_DIR;g\" \\" >> $@
+ @echo " -e \"s;%CONTACT_NODE%;$(CONTACT_NODE);g\" \\" >> $@
+ @echo " -e \"s;%HOSTNAME%;\`hostname --long\`;g\" \\" >> $@
+ @echo " -e \"s;%APP_NAME%;$(APP_NAME);g\" \\" >> $@
+ @echo " -e \"s;%APP_VERSION%;$(APP_VERSION);g\" \\" >> $@
+ @echo ' $$1 > $$2' >> $@
+ @echo "}" >> $@
+ @echo "" >> $@
+ @echo "munge stage/yaws.conf.src var/$(REL_VSN)/www/conf/yaws.conf;" >> $@
+ @echo "munge stage/$(RELS).config.src release/$(REL_VSN)/$(RELS).config;" >> $@
+ @echo "munge stage/$(RELS).sh.src release/$(REL_VSN)/$(RELS).sh;" >> $@
+ @echo "munge stage/$(RELS).rel.src release/$(REL_VSN)/$(RELS).rel;" >> $@
+ @echo "chmod +x release/$(REL_VSN)/$(RELS).sh;" >> $@
+ @echo "" >> $@
+ @echo "cd ..;" >> $@
+ @echo "find $(RELS) | cpio -o > \$$INSTALL_DIR/$(RELS).cpio;" >> $@
+ @echo "cd -;" >> $@
+ @echo "cd \$$INSTALL_DIR; " >> $@
+ @echo "echo -n \"Unpacked: \"" >> $@
+ @echo "cpio -uid < $(RELS).cpio;" >> $@
+ @echo "rm $(RELS).cpio;" >> $@
+ @echo "" >> $@
+ @echo "echo \"pwd is \`pwd\`\";" >> $@
+ @echo "cd $(RELS);" >> $@
+ @echo " erl -pz build/$(REL_VSN) \\" >> $@
+ @echo " -noshell \\" >> $@
+ @echo -n " -s fs_lib s_apply fs_boot_smithe make_script_and_boot \"[\\\"$(ERL_RUN_TOP)/*\\\", \\\"lib/\\\"]. \" " >> $@
+ @echo -n "\"\\\"stage/$$(basename `pwd`).rel.src\\\". \" " >> $@
+ @echo -n "\"[local]. \" " >> $@
+ @echo "-s init stop | egrep '*terminate*|ERROR'" >> $@
+ @echo "if [ \$$? -eq 0 ]; then" >> $@
+ @echo "echo \"============================================\";" >> $@
+ @echo "echo \"STAGE FAILURE \$$? - Silence the discord.\";" >> $@
+ @echo "echo \"============================================\";" >> $@
+ @echo "exit 1;" >> $@
+ @echo "fi" >> $@
+ @echo "" >> $@
+ @echo "mv $(RELS).rel $(RELS).script $(RELS).boot release/$(REL_VSN);" >> $@
+ @echo "" >> $@
+ @echo "rm -r stage;" >> $@
+ @echo "rm -r build;" >> $@
+ @echo "cd -;" >> $@
+ @echo "" >> $@
+ @echo "chgrp -R erts $(RELS); " >> $@
+ @echo "chmod -R 775 $(RELS); " >> $@
+ @echo "cd -" >> $@
+ @echo "" >> $@
+ @echo "rm -f /usr/local/bin/$(APP_NAME);" >> $@
+ @echo "ln -s \$$INSTALL_DIR/$(RELS)/release/$(REL_VSN)/$(RELS).sh /usr/local/bin/$(APP_NAME);" >> $@
+ @echo "chgrp -R erts /usr/local/bin/$(APP_NAME); " >> $@
+ @echo "chmod -R 775 /usr/local/bin/$(APP_NAME); " >> $@
+ @echo "rm \$$INSTALL_DIR/$(RELS)/install.sh;" >> $@
+ @echo "echo -n $$'\e[0;32m'" >> $@
+ @echo "echo \"$(APP_NAME) installation to \$$INSTALL_DIR complete.\"" >> $@
+ @echo "echo -n $$'\e[0m'" >> $@
+ chmod +x $@
+
+
+stage: $(RELS)
+ cd $(RELS); \
+ ./install.sh; \
+ cd -
+
+$(RELS)/var/$(REL_VSN)/www/conf/mime.types: ../../build/mime.types
+ cp $< $@
+
+$(RELS)-$(LOCATION)-$(REL_VSN).tgz: $(RELS)
+ tar -zcvf $@ $<
+
+$(RELS)/release/$(REL_VSN)/clean_release: ../../tools/utilities/clean_release
+ cp $< $@
+
--- /dev/null
+%%% -*- mode:erlang -*-
+%%% Parameter settings for apps on %APP_NAME%
+%%% Warning - this config file *must* end with <dot><whitespace>
+
+%% write log files to sasl_dir
+[
+ {sasl,
+ [
+ {sasl_error_logger, {file, "%LOG_OTP%/sasl_log"}}
+ ]},
+
+
+ {gas,
+ [
+ {mod_specs, [{elwrap, {fs_elwrap_h, start_link}}]},
+
+ % elwrap config.
+ {err_log, "%LOG_OTP%/err_log"},
+ {err_log_wrap_info, {{err,5000000,10},{sasl,5000000,10}}},
+ {err_log_tty, true} % Log to the screen
+ ]},
+
+ {%APP_NAME%,
+ [
+ ]}
+].
--- /dev/null
+%%% -*- mode:erlang -*-
+{release,
+ {"%%APP_NAME%%_rel", "%REL_VSN%"},
+ erts,
+ [
+ kernel,
+ stdlib,
+ sasl,
+ fslib,
+ gas,
+ %%APP_NAME%%
+ ]
+}.
+
--- /dev/null
+REL_VSN=1.0
--- /dev/null
+
+# conf for yaws
+
+
+# first we have a set of globals
+# That apply to all virtual servers
+
+
+# This is the directory where all logfiles for
+# all virtual servers will be written
+
+logdir = /var/log/yaws
+
+# This the path to a directory where additional
+# beam code can be placed. The daemon will add this
+# directory to its search path
+
+ebin_dir = /var/yaws/ebin
+
+
+# This is a directory where application specific .hrl
+# files can be placed. application specifig .yaws code can
+# then include these .hrl files
+
+include_dir = /var/yaws/include
+
+
+
+
+
+# This is a debug variable, possible values are http | traffic | false
+# It is also possible to set the trace (possibly to the tty) while
+# invoking yaws from the shell as in
+# yaws -i -T -x (see man yaws)
+
+trace = false
+
+
+
+
+
+# it is possible to have yaws start additional
+# application specific code at startup
+#
+# runmod = mymodule
+
+
+# By default yaws will copy the erlang error_log and
+# end write it to a wrap log called report.log (in the logdir)
+# this feature can be turned off. This would typically
+# be the case when yaws runs within another larger app
+
+copy_error_log = true
+
+
+# Logs are wrap logs
+
+log_wrap_size = 1000000
+
+
+# Possibly resolve all hostnames in logfiles so webalizer
+# can produce the nice geography piechart
+
+log_resolve_hostname = false
+
+
+
+# fail completely or not if yaws fails
+# to bind a listen socket
+fail_on_bind_err = true
+
+
+
+# If yaws is started as root, it can, once it has opened
+# all relevant sockets for listening, change the uid to a
+# user with lower accessrights than root
+
+# username = nobody
+
+
+# If HTTP auth is used, it is possible to have a specific
+# auth log.
+
+auth_log = true
+
+
+# When we're running multiple yaws systems on the same
+# host, we need to give each yaws system an individual
+# name. Yaws will write a number of runtime files under
+# /tmp/yaws/${id}
+# The default value is "default"
+
+
+# id = myname
+
+
+# earlier versions of Yaws picked the first virtual host
+# in a list of hosts with the same IP/PORT when the Host:
+# header doesn't match any name on any Host
+# This is often nice in testing environments but not
+# acceptable in real live hosting scenarios
+
+pick_first_virthost_on_nomatch = true
+
+
+# All unices are broken since it's not possible to bind to
+# a privileged port (< 1024) unless uid==0
+# There is a contrib in jungerl which makes it possible by means
+# of an external setuid root programm called fdsrv to listen to
+# to privileged port.
+# If we use this feature, it requires fdsrv to be properly installed.
+# Doesn't yet work with SSL.
+
+use_fdsrv = false
+
+
+
+
+# end then a set of virtual servers
+# First two virthosted servers on the same IP (0.0.0.0)
+# in this case, but an explicit IP can be given as well
+
+<server core.martinjlogan.com>
+ port = 80
+ listen = 0.0.0.0
+ docroot = /var/yaws/www
+ arg_rewrite_mod = pwr_arg_rewrite_mod
+ appmods = <pwr, pwr_main_controller_appmod>
+</server>
+
+<server localhost>
+ port = 80
+ listen = 0.0.0.0
+ docroot = /tmp
+ dir_listings = true
+ dav = true
+ <auth>
+ realm = foobar
+ dir = /
+ user = foo:bar
+ user = baz:bar
+ </auth>
+</server>
+
+
+
+# And then an ssl server
+
+<server core.martinjlogan.com>
+ port = 443
+ docroot = /tmp
+ listen = 0.0.0.0
+ dir_listings = true
+ <ssl>
+ keyfile = /usr/local/yaws/etc/yaws-key.pem
+ certfile = /usr/local/yaws/etc/yaws-cert.pem
+ </ssl>
+</server>
+
+
+
+
+
+
+
+
--- /dev/null
+#!/bin/sh
+
+if [ $# -eq 3 ]; then
+ OLD_PREFIX=$1
+ NEW_PREFIX=$2
+ FILENAME=$3
+ NEW_FILENAME=$(echo $FILENAME | sed -e "s/$OLD_PREFIX/$NEW_PREFIX/")
+ echo "moving $FILENAME to $NEW_FILENAME"
+ mv $FILENAME $NEW_FILENAME
+ exit 0;
+fi
+
+
+if [ $# -eq 2 ]; then
+ while read line;
+ do
+ OLD_PREFIX=$1
+ NEW_PREFIX=$2
+ NEW_FILENAME=$(echo ${line} | sed -e "s/$OLD_PREFIX/$NEW_PREFIX/")
+ echo "moving ${line} to $NEW_FILENAME"
+ mv ${line} $NEW_FILENAME
+ done
+ exit 0
+fi
+
--- /dev/null
+#!/bin/sh
+
+
+if [ $# -lt 2 ]; then
+ echo "usage: substitute.sh <variable to replace> <value to replace with> <filename | STDIN>"
+ exit 1
+fi
+
+if [ $# -eq 3 ]; then
+ VARIABLE=$1
+ VALUE=$2
+ FILENAME=$3
+
+ echo "replacing $VARIABLE with $VALUE in $FILENAME"
+ sed -e "s/$VARIABLE/$VALUE/" $FILENAME > "$FILENAME"_tmp
+ mv "$FILENAME"_tmp $FILENAME
+ exit 0
+fi
+
+if [ $# -eq 2 ]; then
+ while read line;
+ do
+ VARIABLE=$1
+ VALUE=$2
+ FILENAME=${line}
+
+ echo "replacing $VARIABLE with $VALUE in $FILENAME"
+ sed -e "s/$VARIABLE/$VALUE/" $FILENAME > "$FILENAME"_tmp
+ mv "$FILENAME"_tmp $FILENAME
+ done
+ exit 0
+fi
+
--- /dev/null
+# ----------------------------------------------------
+# Make file for creating an otp release.
+# ----------------------------------------------------
+
+##
+# Basename of this release.
+##
+RELS=$(shell basename `pwd`)
+APP_NAME=$(shell echo $(RELS) | sed s/_rel$$//)
+
+include ../../build/otp.mk
+
+include ./vsn.mk
+
+#include $(ERL_TOP)/make/target.mk
+#include $(ERL_TOP)/make/$(TARGET)/otp.mk
+
+USR_LIBPATH=../../lib
+INSTALL_DIR=/usr/local/lib
+ABS_USER_LIBPATH=$(shell cd ../../lib;pwd)
+
+# ----------------------------------------------------
+# CREATE DIR STRUCTURE HERE
+# ----------------------------------------------------
+
+HTDOCS=$(wildcard $(ABS_USER_LIBPATH)/$(APP_NAME)/htdocs/*.html) \
+ $(wildcard $(ABS_USER_LIBPATH)/$(APP_NAME)/htdocs/*.htm) \
+ $(wildcard $(ABS_USER_LIBPATH)/$(APP_NAME)/htdocs/*.yaws)
+BUILD_FILES=fs_boot_smithe.beam fs_lists.beam fs_lib.beam
+
+LOCAL_DIR=local
+#LOCAL_DIR=$(shell cat $(RELS).rel.src |grep -m 1 '$(APP_NAME)' |awk -F '"' '{printf "%s-%s", $$2,$$4}')
+
+DIR_STRUCTURE= \
+ $(LOCAL_DIR) \
+ $(LOCAL_DIR)/log/$(REL_VSN) \
+ $(LOCAL_DIR)/var/$(REL_VSN) \
+ $(LOCAL_DIR)/var/$(REL_VSN)/www/conf \
+ $(LOCAL_DIR)/var/$(REL_VSN)/www/htdocs
+
+PRODUCTION_DIR_STRUCTURE= \
+ $(RELS) \
+ $(RELS)/release/$(REL_VSN) \
+ $(RELS)/stage \
+ $(RELS)/log/$(REL_VSN) \
+ $(RELS)/var/$(REL_VSN) \
+ $(RELS)/var/$(REL_VSN)/www \
+ $(RELS)/var/$(REL_VSN)/www/htdocs \
+ $(RELS)/var/$(REL_VSN)/www/conf
+
+# ----------------------------------------------------
+SCRIPT_AND_BOOT_FILES= \
+ $(RELS).script \
+ $(RELS).boot
+
+LOCAL_SCRIPT_AND_BOOT_FILES= \
+ $(LOCAL_DIR)/$(RELS).script \
+ $(LOCAL_DIR)/$(RELS).boot
+
+LOCAL_HTTP_CONF= \
+ $(LOCAL_DIR)/var/$(REL_VSN)/www/conf/yaws.conf \
+ $(LOCAL_DIR)/var/$(REL_VSN)/www/conf/mime.types
+
+PRODUCTION_HTTP_CONF= \
+ $(LOCAL_DIR)/var/$(REL_VSN)/www/conf/yaws.conf \
+ $(LOCAL_DIR)/var/$(REL_VSN)/www/conf/mime.types
+
+LOCAL_TARGET_FILES=$(LOCAL_HTTP_CONF) $(LOCAL_DIR)/$(RELS).config $(LOCAL_SCRIPT_AND_BOOT_FILES)
+
+LOCAL_TARGETS=$(LOCAL_DIR)/$(RELS).sh vsnit $(LOCAL_TARGET_FILES)
+
+PRODUCTION_TARGETS=$(RELS)/build/$(REL_VSN) \
+ $(RELS)/lib \
+ $(RELS)/stage/$(RELS).rel.src \
+ $(RELS)/stage/$(RELS).config.src \
+ $(RELS)/stage/yaws.conf.src \
+ $(RELS)/stage/$(RELS).sh.src \
+ $(RELS)/var/$(REL_VSN)/www/htdocs \
+ $(RELS)/install.sh \
+ $(RELS)/release/$(REL_VSN)/clean_release
+
+# ----------------------------------------------------
+# TARGETS
+# ----------------------------------------------------
+
+all debug opt instr script: $(DIR_STRUCTURE) $(LOCAL_TARGETS) $(PRODUCTION_DIR_STRUCTURE) $(PRODUCTION_TARGETS)
+ @echo $(HTDOCS)
+
+install: stage
+
+tar: $(RELS)-$(LOCATION)-$(REL_VSN).tgz
+
+$(DIR_STRUCTURE):
+ mkdir -p $@
+
+$(PRODUCTION_DIR_STRUCTURE):
+ mkdir -p $@
+
+clean:
+ $(RM) $(REL_SCRIPTS) $(TARGET_FILES)
+ $(RM) -r $(LOCAL_DIR) $(PRODN_DIR)
+ $(RM) $(RELS).rel
+ $(RM) -r $(RELS)
+ $(RM) $(RELS)*.tgz
+ $(RM) $(RELS).rel.src.tmp
+ $(RM) $(SCRIPT_AND_BOOT_FILES)
+
+docs:
+
+# ----------------------------------------------------
+# TARGETS FOR LOCAL MODE
+# ----------------------------------------------------
+
+# startup script for local mode
+$(LOCAL_DIR)/$(RELS).sh:
+ @echo '#!/bin/sh' > $@
+ @echo "cd $(CURDIR)/$(LOCAL_DIR)" >> $@
+ @echo "erl -name $${USER}_$(RELS) -boot $(RELS) -config $(RELS).config \$$@" >> $@
+ chmod +x $@
+ @echo
+ @echo "==== Start local node with \"sh $@\" ===="
+ @echo
+
+# Create the config file for local mode.
+$(LOCAL_DIR)/$(RELS).config: $(RELS).config.src
+ sed -e 's;%LOG_OTP%;$(CURDIR)/$(LOCAL_DIR)/log/$(REL_VSN);' \
+ -e 's;%VAR_OTP%;$(CURDIR)/$(LOCAL_DIR)/var/$(REL_VSN);' \
+ -e 's;%RELS%;$(RELS);g' \
+ -e 's;%HOME%;$(HOME);g' \
+ -e 's;%BROADCAST_ADDRESS%;$(BROADCAST_ADDRESS);g' \
+ -e 's;%CONTACT_NODE%;$(CONTACT_NODE);g' \
+ -e "s;%HOSTNAME%;`hostname --long`;" \
+ -e 's;%APP_NAME%;$(APP_NAME);' \
+ -e 's;%APP_VERSION%;$(APP_VERSION);g' \
+ $< > $@
+
+# Create the httpd conf file for local mode.
+$(LOCAL_DIR)/var/$(REL_VSN)/www/conf/yaws.conf: yaws.conf.src
+ sed -e 's;%VAR_OTP%;$(CURDIR)/$(LOCAL_DIR)/var/$(REL_VSN);' \
+ -e 's;%LOG_OTP%;$(CURDIR)/$(LOCAL_DIR)/log/$(REL_VSN);' \
+ -e 's;%HTDOC_ROOT%;$(ABS_USER_LIBPATH)/$(APP_NAME)/htdocs;' \
+ -e 's;%APP_NAME%;$(APP_NAME);' \
+ -e 's;%RELS%;$(RELS);' \
+ -e 's;%USER%;$(USER);' \
+ -e 's;%HTDOC_ROOT%;$(ABS_USER_LIBPATH);' \
+ -e 's;%MHOST%;$(MHOST);' \
+ $< > $@
+
+# Create the config file for local mode.
+vsnit: $(RELS).rel.src
+ sed -e 's;%REL_VSN%;$(REL_VSN);' \
+ $< > $<.tmp
+
+# Create and position script and boot files for local mode.
+$(LOCAL_SCRIPT_AND_BOOT_FILES):
+ @ erl -pz $(USR_LIBPATH)/fslib/ebin \
+ -noshell \
+ -s fs_lib s_apply fs_boot_smithe make_script_and_boot "[\"$(ERL_RUN_TOP)/*\", \"$(USR_LIBPATH)\"]. " \
+ \"$$(basename `pwd`)".rel.src.tmp\". " \
+ "[local]. " \
+ -s init stop
+ cp $(SCRIPT_AND_BOOT_FILES) $(LOCAL_DIR)/
+
+$(LOCAL_DIR)/var/$(REL_VSN)/www/conf/mime.types: ../../build/mime.types
+ cp $< $@
+
+# ----------------------------------------------------
+# TARGETS FOR PRODUCTION MODE
+# ----------------------------------------------------
+$(RELS)/lib:
+ # For some reason this will not happen if added to PRODUCTION_DIR_STRUCTURE
+ mkdir $@
+ @ erl -pz $(RELS)/build/$(REL_VSN) \
+ -noshell \
+ -s fs_lib s_apply fs_boot_smithe stage_from_relsrc "[\"$(USR_LIBPATH)\"]. " \
+ \"$$(basename `pwd`)".rel.src\". " \
+ \"$@\"". " \
+ -s init stop
+
+# Move the htdocs from the local apps to the production htdoc root directory.
+$(RELS)/var/$(REL_VSN)/www/htdocs/: $(HTDOCS)
+ @mkdir -p $(RELS)/var/$(REL_VSN)/www/htdocs; \
+ for x in $(HTDOCS);do \
+ cp $$x $@; \
+ done
+
+# startup script for production mode
+$(RELS)/stage/$(RELS).sh.src:
+ @echo '#!/bin/sh' > $@
+ @echo "cd %INSTALL_DIR%/$(RELS)/release/$(REL_VSN)" >> $@
+ @echo "erl -name $(RELS) -boot $(RELS) -config $(RELS).config -detached \$$@" >> $@
+ chmod +x $@
+
+$(RELS)/build/$(REL_VSN): $(USR_LIBPATH)/fslib/ebin
+ mkdir -p $(RELS)/build/$(REL_VSN)
+ cp $</fs_boot_smithe.beam $@
+ cp $</fs_lib.beam $@
+ cp $</fs_lists.beam $@
+
+$(RELS)/stage/$(RELS).rel.src: $(RELS).rel.src.tmp
+ cp $< $@
+
+$(RELS)/stage/$(RELS).config.src: $(RELS).config.src
+ cp $< $@
+
+$(RELS)/stage/yaws.conf.src: yaws.conf.src
+ cp $< $@
+
+$(RELS)/install.sh:
+ @echo '#!/bin/sh' > $@
+ @echo "" >> $@
+ @echo "if [ \$$# -eq 1 ];then" >> $@
+ @echo " INSTALL_DIR=\$$1;" >> $@
+ @echo "else" >> $@
+ @echo " INSTALL_DIR=$(INSTALL_DIR);" >> $@
+ @echo "fi" >> $@
+ @echo "" >> $@
+ @echo "function munge() {" >> $@
+ @echo " sed -e \"s;%LOG_OTP%;\$$INSTALL_DIR/$(RELS)/log/$(REL_VSN);g\" \\" >> $@
+ @echo " -e \"s;%VAR_OTP%;\$$INSTALL_DIR/$(RELS)/var/$(REL_VSN);g\" \\" >> $@
+ @echo " -e \"s;%RELS%;$(RELS);g\" \\" >> $@
+ @echo " -e \"s;%REL_VSN%;$(REL_VSN);g\" \\" >> $@
+ @echo " -e \"s;%USER%;$$USER;g\" \\" >> $@
+ @echo " -e \"s;%HTDOC_ROOT%;\$$INSTALL_DIR/$(RELS)/var/$(REL_VSN)/www/htdocs;g\" \\" >> $@
+ @echo " -e \"s;%MHOST%;\`hostname\`;g\" \\" >> $@
+ @echo " -e \"s;%BROADCAST_ADDRESS%;$(BROADCAST_ADDRESS);g\" \\" >> $@
+ @echo " -e \"s;%INSTALL_DIR%;\$$INSTALL_DIR;g\" \\" >> $@
+ @echo " -e \"s;%CONTACT_NODE%;$(CONTACT_NODE);g\" \\" >> $@
+ @echo " -e \"s;%HOSTNAME%;\`hostname --long\`;g\" \\" >> $@
+ @echo " -e \"s;%APP_NAME%;$(APP_NAME);g\" \\" >> $@
+ @echo " -e \"s;%APP_VERSION%;$(APP_VERSION);g\" \\" >> $@
+ @echo ' $$1 > $$2' >> $@
+ @echo "}" >> $@
+ @echo "" >> $@
+ @echo "munge stage/yaws.conf.src var/$(REL_VSN)/www/conf/yaws.conf;" >> $@
+ @echo "munge stage/$(RELS).config.src release/$(REL_VSN)/$(RELS).config;" >> $@
+ @echo "munge stage/$(RELS).sh.src release/$(REL_VSN)/$(RELS).sh;" >> $@
+ @echo "munge stage/$(RELS).rel.src release/$(REL_VSN)/$(RELS).rel;" >> $@
+ @echo "chmod +x release/$(REL_VSN)/$(RELS).sh;" >> $@
+ @echo "" >> $@
+ @echo "cd ..;" >> $@
+ @echo "find $(RELS) | cpio -o > \$$INSTALL_DIR/$(RELS).cpio;" >> $@
+ @echo "cd -;" >> $@
+ @echo "cd \$$INSTALL_DIR; " >> $@
+ @echo "echo -n \"Unpacked: \"" >> $@
+ @echo "cpio -uid < $(RELS).cpio;" >> $@
+ @echo "rm $(RELS).cpio;" >> $@
+ @echo "" >> $@
+ @echo "echo \"pwd is \`pwd\`\";" >> $@
+ @echo "cd $(RELS);" >> $@
+ @echo " erl -pz build/$(REL_VSN) \\" >> $@
+ @echo " -noshell \\" >> $@
+ @echo -n " -s fs_lib s_apply fs_boot_smithe make_script_and_boot \"[\\\"$(ERL_RUN_TOP)/*\\\", \\\"lib/\\\"]. \" " >> $@
+ @echo -n "\"\\\"stage/$$(basename `pwd`).rel.src\\\". \" " >> $@
+ @echo -n "\"[local]. \" " >> $@
+ @echo "-s init stop | egrep '*terminate*|ERROR'" >> $@
+ @echo "if [ \$$? -eq 0 ]; then" >> $@
+ @echo "echo \"============================================\";" >> $@
+ @echo "echo \"STAGE FAILURE \$$? - Silence the discord.\";" >> $@
+ @echo "echo \"============================================\";" >> $@
+ @echo "exit 1;" >> $@
+ @echo "fi" >> $@
+ @echo "" >> $@
+ @echo "mv $(RELS).rel $(RELS).script $(RELS).boot release/$(REL_VSN);" >> $@
+ @echo "" >> $@
+ @echo "rm -r stage;" >> $@
+ @echo "rm -r build;" >> $@
+ @echo "cd -;" >> $@
+ @echo "" >> $@
+ @echo "chgrp -R erts $(RELS); " >> $@
+ @echo "chmod -R 775 $(RELS); " >> $@
+ @echo "cd -" >> $@
+ @echo "" >> $@
+ @echo "rm -f /usr/local/bin/$(APP_NAME);" >> $@
+ @echo "ln -s \$$INSTALL_DIR/$(RELS)/release/$(REL_VSN)/$(RELS).sh /usr/local/bin/$(APP_NAME);" >> $@
+ @echo "chgrp -R erts /usr/local/bin/$(APP_NAME); " >> $@
+ @echo "chmod -R 775 /usr/local/bin/$(APP_NAME); " >> $@
+ @echo "rm \$$INSTALL_DIR/$(RELS)/install.sh;" >> $@
+ @echo "echo -n $$'\e[0;32m'" >> $@
+ @echo "echo \"$(APP_NAME) installation to \$$INSTALL_DIR complete.\"" >> $@
+ @echo "echo -n $$'\e[0m'" >> $@
+ chmod +x $@
+
+
+stage: $(RELS)
+ cd $(RELS); \
+ ./install.sh; \
+ cd -
+
+$(RELS)/var/$(REL_VSN)/www/conf/mime.types: ../../build/mime.types
+ cp $< $@
+
+$(RELS)-$(LOCATION)-$(REL_VSN).tgz: $(RELS)
+ tar -zcvf $@ $<
+
+$(RELS)/release/$(REL_VSN)/clean_release: ../../tools/utilities/clean_release
+ cp $< $@
+
--- /dev/null
+%%% -*- mode:erlang -*-
+%%% Parameter settings for apps on %APP_NAME%
+%%% Warning - this config file *must* end with <dot><whitespace>
+
+%% write log files to sasl_dir
+[
+ {sasl,
+ [
+ {sasl_error_logger, {file, "%LOG_OTP%/sasl_log"}}
+ ]},
+
+
+ {gas,
+ [
+ {mod_specs, [{elwrap, {fs_elwrap_h, start_link}}]},
+
+ % elwrap config.
+ {err_log, "%LOG_OTP%/err_log"},
+ {err_log_wrap_info, {{err,5000000,10},{sasl,5000000,10}}},
+ {err_log_tty, true} % Log to the screen
+ ]},
+
+ {%APP_NAME%,
+ [
+ ]}
+].
--- /dev/null
+%%% -*- mode:erlang -*-
+{release,
+ {"thrift_rel", "%REL_VSN%"},
+ erts,
+ [
+ kernel,
+ stdlib,
+ sasl,
+ fslib,
+ gas,
+ thrift
+ ]
+}.
+
--- /dev/null
+REL_VSN=1.0
--- /dev/null
+
+# conf for yaws
+
+
+# first we have a set of globals
+# That apply to all virtual servers
+
+
+# This is the directory where all logfiles for
+# all virtual servers will be written
+
+logdir = /var/log/yaws
+
+# This the path to a directory where additional
+# beam code can be placed. The daemon will add this
+# directory to its search path
+
+ebin_dir = /var/yaws/ebin
+
+
+# This is a directory where application specific .hrl
+# files can be placed. application specifig .yaws code can
+# then include these .hrl files
+
+include_dir = /var/yaws/include
+
+
+
+
+
+# This is a debug variable, possible values are http | traffic | false
+# It is also possible to set the trace (possibly to the tty) while
+# invoking yaws from the shell as in
+# yaws -i -T -x (see man yaws)
+
+trace = false
+
+
+
+
+
+# it is possible to have yaws start additional
+# application specific code at startup
+#
+# runmod = mymodule
+
+
+# By default yaws will copy the erlang error_log and
+# end write it to a wrap log called report.log (in the logdir)
+# this feature can be turned off. This would typically
+# be the case when yaws runs within another larger app
+
+copy_error_log = true
+
+
+# Logs are wrap logs
+
+log_wrap_size = 1000000
+
+
+# Possibly resolve all hostnames in logfiles so webalizer
+# can produce the nice geography piechart
+
+log_resolve_hostname = false
+
+
+
+# fail completely or not if yaws fails
+# to bind a listen socket
+fail_on_bind_err = true
+
+
+
+# If yaws is started as root, it can, once it has opened
+# all relevant sockets for listening, change the uid to a
+# user with lower accessrights than root
+
+# username = nobody
+
+
+# If HTTP auth is used, it is possible to have a specific
+# auth log.
+
+auth_log = true
+
+
+# When we're running multiple yaws systems on the same
+# host, we need to give each yaws system an individual
+# name. Yaws will write a number of runtime files under
+# /tmp/yaws/${id}
+# The default value is "default"
+
+
+# id = myname
+
+
+# earlier versions of Yaws picked the first virtual host
+# in a list of hosts with the same IP/PORT when the Host:
+# header doesn't match any name on any Host
+# This is often nice in testing environments but not
+# acceptable in real live hosting scenarios
+
+pick_first_virthost_on_nomatch = true
+
+
+# All unices are broken since it's not possible to bind to
+# a privileged port (< 1024) unless uid==0
+# There is a contrib in jungerl which makes it possible by means
+# of an external setuid root programm called fdsrv to listen to
+# to privileged port.
+# If we use this feature, it requires fdsrv to be properly installed.
+# Doesn't yet work with SSL.
+
+use_fdsrv = false
+
+
+
+
+# end then a set of virtual servers
+# First two virthosted servers on the same IP (0.0.0.0)
+# in this case, but an explicit IP can be given as well
+
+<server core.martinjlogan.com>
+ port = 80
+ listen = 0.0.0.0
+ docroot = /var/yaws/www
+ arg_rewrite_mod = pwr_arg_rewrite_mod
+ appmods = <pwr, pwr_main_controller_appmod>
+</server>
+
+<server localhost>
+ port = 80
+ listen = 0.0.0.0
+ docroot = /tmp
+ dir_listings = true
+ dav = true
+ <auth>
+ realm = foobar
+ dir = /
+ user = foo:bar
+ user = baz:bar
+ </auth>
+</server>
+
+
+
+# And then an ssl server
+
+<server core.martinjlogan.com>
+ port = 443
+ docroot = /tmp
+ listen = 0.0.0.0
+ dir_listings = true
+ <ssl>
+ keyfile = /usr/local/yaws/etc/yaws-key.pem
+ certfile = /usr/local/yaws/etc/yaws-cert.pem
+ </ssl>
+</server>
+
+
+
+
+
+
+
+
--- /dev/null
+;; erlang-start.el --- Load this file to initialize the Erlang package.
+
+;; Copyright (C) 1998 Ericsson Telecom AB
+
+;; Author: Anders Lindgren
+;; Version: 2.3
+;; Keywords: erlang, languages, processes
+;; Created: 1996-09-18
+;; Date: 1998-03-16
+
+;;; Commentary:
+
+;; Introduction:
+;; ------------
+;;
+;; This package provides support for the programming language Erlang.
+;; The package provides an editing mode with lots of bells and
+;; whistles, compilation support, and it makes it possible for the
+;; user to start Erlang shells that run inside Emacs.
+;;
+;; See the Erlang distribution for full documentation of this package.
+
+;; Installation:
+;; ------------
+;;
+;; Place this file in Emacs load path, byte-compile it, and add the
+;; following line to the appropriate init file:
+;;
+;; (require 'erlang-start)
+;;
+;; The full documentation contains much more extensive description of
+;; the installation procedure.
+
+;; Reporting Bugs:
+;; --------------
+;;
+;; Please send bug reports to the following email address:
+;; support@erlang.ericsson.se
+;;
+;; Please state as exactly as possible:
+;; - Version number of Erlang Mode (see the menu), Emacs, Erlang,
+;; and of any other relevant software.
+;; - What the expected result was.
+;; - What you did, preferably in a repeatable step-by-step form.
+;; - A description of the unexpected result.
+;; - Relevant pieces of Erlang code causing the problem.
+;; - Personal Emacs customisations, if any.
+;;
+;; Should the Emacs generate an error, please set the emacs variable
+;; `debug-on-error' to `t'. Repeat the error and enclose the debug
+;; information in your bug-report.
+;;
+;; To set the variable you can use the following command:
+;; M-x set-variable RET debug-on-error RET t RET
+;;; Code:
+
+;;
+;; Declare functions in "erlang.el".
+;;
+
+(autoload 'erlang-mode "erlang" "Major mode for editing Erlang code." t)
+(autoload 'erlang-version "erlang"
+ "Return the current version of Erlang mode." t)
+(autoload 'erlang-shell "erlang" "Start a new Erlang shell." t)
+(autoload 'run-erlang "erlang" "Start a new Erlang shell." t)
+
+(autoload 'erlang-compile "erlang"
+ "Compile Erlang module in current buffer." t)
+
+(autoload 'erlang-man-module "erlang"
+ "Find manual page for MODULE." t)
+(autoload 'erlang-man-function "erlang"
+ "Find manual page for NAME, where NAME is module:function." t)
+
+(autoload 'erlang-find-tag "erlang"
+ "Like `find-tag'. Capable of retreiving Erlang modules.")
+(autoload 'erlang-find-tag-other-window "erlang"
+ "Like `find-tag-other-window'. Capable of retreiving Erlang modules.")
+
+
+;;
+;; Associate files extensions ".erl" and ".hrl" with Erlang mode.
+;;
+
+(let ((a '("\\.erl\\'" . erlang-mode))
+ (b '("\\.hrl\\'" . erlang-mode)))
+ (or (assoc (car a) auto-mode-alist)
+ (setq auto-mode-alist (cons a auto-mode-alist)))
+ (or (assoc (car b) auto-mode-alist)
+ (setq auto-mode-alist (cons b auto-mode-alist))))
+
+
+;;
+;; Ignore files ending in ".jam", ".vee", and ".beam" when performing
+;; file completion.
+;;
+
+(let ((erl-ext '(".jam" ".vee" ".beam")))
+ (while erl-ext
+ (let ((cie completion-ignored-extensions))
+ (while (and cie (not (string-equal (car cie) (car erl-ext))))
+ (setq cie (cdr cie)))
+ (if (null cie)
+ (setq completion-ignored-extensions
+ (cons (car erl-ext) completion-ignored-extensions))))
+ (setq erl-ext (cdr erl-ext))))
+
+
+;;
+;; The end.
+;;
+
+(provide 'erlang-start)
+
+;; erlang-start.el ends here.
--- /dev/null
Content-type: text/html
Supwisdom Source - common/thrift.git/commitdiff
500 - Internal Server Error
Unknown encoding 'gb18030' at /usr/local/share/gitweb/gitweb.cgi line 1539