[thrift] highly concurrent Erlang goodness
authorChristopher Piro <cpiro@apache.org>
Wed, 18 Jul 2007 00:26:12 +0000 (00:26 +0000)
committerChristopher Piro <cpiro@apache.org>
Wed, 18 Jul 2007 00:26:12 +0000 (00:26 +0000)
Summary:
 * shim to use object-oriented code as gen_servers
 * high(er) performance Erlang-style server and transport
 * sane packaging based on otp-base, i.e. Makefiles and real structure

Test Plan: tutorial server offers the same (subset of) functionality as previous version

Revert Plan: ok

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665164 13f79535-47bb-0310-9956-ffa450edef68

133 files changed:
compiler/cpp/src/generate/t_erl_generator.cc
lib/erl/Makefile [new file with mode: 0644]
lib/erl/README [new file with mode: 0644]
lib/erl/build/beamver [new file with mode: 0644]
lib/erl/build/buildtargets.mk [new file with mode: 0644]
lib/erl/build/colors.mk [new file with mode: 0644]
lib/erl/build/docs.mk [new file with mode: 0644]
lib/erl/build/mime.types [new file with mode: 0644]
lib/erl/build/otp.mk [new file with mode: 0644]
lib/erl/build/otp_subdir.mk [new file with mode: 0644]
lib/erl/build/raw_test.mk [new file with mode: 0644]
lib/erl/lib/Makefile [new file with mode: 0644]
lib/erl/lib/thrift/COPYING [new file with mode: 0644]
lib/erl/lib/thrift/HEADER [new file with mode: 0644]
lib/erl/lib/thrift/LICENSE [new file with mode: 0644]
lib/erl/lib/thrift/Makefile [new file with mode: 0644]
lib/erl/lib/thrift/README [new file with mode: 0644]
lib/erl/lib/thrift/TODO [new file with mode: 0644]
lib/erl/lib/thrift/include/oop.hrl [new file with mode: 0644]
lib/erl/lib/thrift/include/protocol/tBinaryProtocol.hrl [new file with mode: 0644]
lib/erl/lib/thrift/include/protocol/tBinaryProtocolFactory.hrl [new file with mode: 0644]
lib/erl/lib/thrift/include/protocol/tProtocol.hrl [new file with mode: 0644]
lib/erl/lib/thrift/include/protocol/tProtocolException.hrl [new file with mode: 0644]
lib/erl/lib/thrift/include/protocol/tProtocolFactory.hrl [new file with mode: 0644]
lib/erl/lib/thrift/include/server/tErlServer.hrl [new file with mode: 0644]
lib/erl/lib/thrift/include/server/tServer.hrl [new file with mode: 0644]
lib/erl/lib/thrift/include/server/tSimpleServer.hrl [new file with mode: 0644]
lib/erl/lib/thrift/include/tApplicationException.hrl [moved from lib/erl/src-loose/tApplicationException.hrl with 57% similarity]
lib/erl/lib/thrift/include/tErlProcessor.hrl [new file with mode: 0644]
lib/erl/lib/thrift/include/tException.hrl [new file with mode: 0644]
lib/erl/lib/thrift/include/tProcessor.hrl [new file with mode: 0644]
lib/erl/lib/thrift/include/thrift.hrl [new file with mode: 0644]
lib/erl/lib/thrift/include/transport/tBufferedTransport.hrl [new file with mode: 0644]
lib/erl/lib/thrift/include/transport/tBufferedTransportFactory.hrl [new file with mode: 0644]
lib/erl/lib/thrift/include/transport/tErlAcceptor.hrl [new file with mode: 0644]
lib/erl/lib/thrift/include/transport/tServerSocket.hrl [new file with mode: 0644]
lib/erl/lib/thrift/include/transport/tServerTransport.hrl [new file with mode: 0644]
lib/erl/lib/thrift/include/transport/tSocket.hrl [new file with mode: 0644]
lib/erl/lib/thrift/include/transport/tTransport.hrl [new file with mode: 0644]
lib/erl/lib/thrift/include/transport/tTransportException.hrl [new file with mode: 0644]
lib/erl/lib/thrift/include/transport/tTransportFactory.hrl [new file with mode: 0644]
lib/erl/lib/thrift/server.sh [new file with mode: 0755]
lib/erl/lib/thrift/src/Makefile [new file with mode: 0644]
lib/erl/lib/thrift/src/oop.erl [new file with mode: 0644]
lib/erl/lib/thrift/src/protocol/tBinaryProtocol.erl [new file with mode: 0644]
lib/erl/lib/thrift/src/protocol/tBinaryProtocolFactory.erl [new file with mode: 0644]
lib/erl/lib/thrift/src/protocol/tProtocol.erl [new file with mode: 0644]
lib/erl/lib/thrift/src/protocol/tProtocolException.erl [new file with mode: 0644]
lib/erl/lib/thrift/src/protocol/tProtocolFactory.erl [new file with mode: 0644]
lib/erl/lib/thrift/src/server/tErlServer.erl [new file with mode: 0644]
lib/erl/lib/thrift/src/server/tServer.erl [new file with mode: 0644]
lib/erl/lib/thrift/src/server/tSimpleServer.erl [new file with mode: 0644]
lib/erl/lib/thrift/src/tApplicationException.erl [new file with mode: 0644]
lib/erl/lib/thrift/src/tErlProcessor.erl [new file with mode: 0644]
lib/erl/lib/thrift/src/tException.erl [new file with mode: 0644]
lib/erl/lib/thrift/src/tProcessor.erl [new file with mode: 0644]
lib/erl/lib/thrift/src/thrift.app.src [new file with mode: 0755]
lib/erl/lib/thrift/src/thrift.appup.src [new file with mode: 0755]
lib/erl/lib/thrift/src/thrift_oop_server.erl [new file with mode: 0644]
lib/erl/lib/thrift/src/transport/tBufferedTransport.erl [new file with mode: 0644]
lib/erl/lib/thrift/src/transport/tBufferedTransportFactory.erl [new file with mode: 0644]
lib/erl/lib/thrift/src/transport/tErlAcceptor.erl [new file with mode: 0644]
lib/erl/lib/thrift/src/transport/tServerSocket.erl [new file with mode: 0644]
lib/erl/lib/thrift/src/transport/tServerTransport.erl [new file with mode: 0644]
lib/erl/lib/thrift/src/transport/tSocket.erl [new file with mode: 0644]
lib/erl/lib/thrift/src/transport/tTransport.erl [new file with mode: 0644]
lib/erl/lib/thrift/src/transport/tTransportException.erl [new file with mode: 0644]
lib/erl/lib/thrift/src/transport/tTransportFactory.erl [new file with mode: 0644]
lib/erl/lib/thrift/tutorial [new symlink]
lib/erl/lib/thrift/user [new symlink]
lib/erl/lib/thrift/vsn.mk [new file with mode: 0644]
lib/erl/licence.txt [new file with mode: 0644]
lib/erl/release_DISABLED/Makefile [new file with mode: 0644]
lib/erl/release_DISABLED/thrift_rel/Makefile [new file with mode: 0755]
lib/erl/release_DISABLED/thrift_rel/local/thrift_rel.config [new file with mode: 0644]
lib/erl/release_DISABLED/thrift_rel/local/thrift_rel.sh [new file with mode: 0755]
lib/erl/release_DISABLED/thrift_rel/local/var/1.0/www/conf/mime.types [new file with mode: 0644]
lib/erl/release_DISABLED/thrift_rel/local/var/1.0/www/conf/yaws.conf [new file with mode: 0644]
lib/erl/release_DISABLED/thrift_rel/thrift_rel.config.src [new file with mode: 0755]
lib/erl/release_DISABLED/thrift_rel/thrift_rel.rel.src [new file with mode: 0644]
lib/erl/release_DISABLED/thrift_rel/thrift_rel.rel.src.tmp [new file with mode: 0644]
lib/erl/release_DISABLED/thrift_rel/vsn.mk [new file with mode: 0755]
lib/erl/release_DISABLED/thrift_rel/yaws.conf.src [new file with mode: 0644]
lib/erl/src-loose/protocol/tBinaryProtocol.erl [deleted file]
lib/erl/src-loose/protocol/tBinaryProtocol.hrl [deleted file]
lib/erl/src-loose/protocol/tProtocol.erl [deleted file]
lib/erl/src-loose/protocol/tProtocol.hrl [deleted file]
lib/erl/src-loose/protocol/tProtocolException.erl [deleted file]
lib/erl/src-loose/protocol/tProtocolException.hrl [deleted file]
lib/erl/src-loose/server/tServer.erl [deleted file]
lib/erl/src-loose/server/tServer.hrl [deleted file]
lib/erl/src-loose/tApplicationException.erl [deleted file]
lib/erl/src-loose/tException.erl [deleted file]
lib/erl/src-loose/tException.hrl [deleted file]
lib/erl/src-loose/thrift.hrl [deleted file]
lib/erl/src-loose/transport/tBufferedTransport.erl [deleted file]
lib/erl/src-loose/transport/tBufferedTransport.hrl [deleted file]
lib/erl/src-loose/transport/tServerSocket.erl [deleted file]
lib/erl/src-loose/transport/tServerSocket.hrl [deleted file]
lib/erl/src-loose/transport/tSocket.erl [deleted file]
lib/erl/src-loose/transport/tSocket.hrl [deleted file]
lib/erl/src-loose/transport/tTransport.erl [deleted file]
lib/erl/src-loose/transport/tTransportException.erl [deleted file]
lib/erl/src-loose/transport/tTransportException.hrl [deleted file]
lib/erl/thrift [deleted symlink]
lib/erl/tools/.appgen/blank_app/Makefile [new file with mode: 0755]
lib/erl/tools/.appgen/blank_app/include/blank_app.hrl [new file with mode: 0755]
lib/erl/tools/.appgen/blank_app/src/Makefile [new file with mode: 0755]
lib/erl/tools/.appgen/blank_app/src/ba_server.erl [new file with mode: 0755]
lib/erl/tools/.appgen/blank_app/src/ba_sup.erl [new file with mode: 0755]
lib/erl/tools/.appgen/blank_app/src/blank_app.app.src [new file with mode: 0755]
lib/erl/tools/.appgen/blank_app/src/blank_app.appup.src [new file with mode: 0755]
lib/erl/tools/.appgen/blank_app/src/blank_app.erl [new file with mode: 0755]
lib/erl/tools/.appgen/blank_app/vsn.mk [new file with mode: 0755]
lib/erl/tools/.appgen/blank_app_rel/Makefile [new file with mode: 0755]
lib/erl/tools/.appgen/blank_app_rel/blank_app_rel.config.src [new file with mode: 0755]
lib/erl/tools/.appgen/blank_app_rel/blank_app_rel.rel.src [new file with mode: 0755]
lib/erl/tools/.appgen/blank_app_rel/vsn.mk [new file with mode: 0755]
lib/erl/tools/.appgen/blank_app_rel/yaws.conf.src [new file with mode: 0644]
lib/erl/tools/.appgen/rename.sh [new file with mode: 0755]
lib/erl/tools/.appgen/substitute.sh [new file with mode: 0755]
lib/erl/tools/.appgen/thrift_rel/Makefile [new file with mode: 0755]
lib/erl/tools/.appgen/thrift_rel/thrift_rel.config.src [new file with mode: 0755]
lib/erl/tools/.appgen/thrift_rel/thrift_rel.rel.src [new file with mode: 0644]
lib/erl/tools/.appgen/thrift_rel/vsn.mk [new file with mode: 0755]
lib/erl/tools/.appgen/thrift_rel/yaws.conf.src [new file with mode: 0644]
lib/erl/tools/emacs/erlang-start.el [new file with mode: 0755]
lib/erl/tools/emacs/erlang.el [new file with mode: 0755]
lib/erl/tools/utilities/appgen [new file with mode: 0755]
lib/erl/tools/utilities/clean_release [new file with mode: 0755]
lib/erl/tools/utilities/edoc [new file with mode: 0755]
tutorial/erl/calculatorHandler.erl [deleted file]
tutorial/erl/server.erl [new file with mode: 0644]

index ff2e287..4407cf5 100644 (file)
@@ -9,13 +9,12 @@
 #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.
@@ -99,8 +98,9 @@ string t_erl_generator::erl_autogen_comment() {
  */
 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";
 }
 
 /**
@@ -414,7 +414,7 @@ void t_erl_generator::generate_erl_struct_reader(ostream& out,
   indent_up();
     
   out <<
-    indent() << "?M0(Iprot, readStructBegin)," << endl <<   
+    indent() << "?R0(Iprot, readStructBegin)," << endl <<   
     indent() << "Str = " << uncapitalize(type_name(tstruct)) << "_read_loop(Iprot, ";
 
   //  if (fields.size() > 0) { // cpiro: sensible default for non-empty structs
@@ -424,7 +424,7 @@ void t_erl_generator::generate_erl_struct_reader(ostream& out,
     //  }
 
   out << ")," << endl <<
-    indent() << "?M0(Iprot, readStructEnd)," << endl <<
+    indent() << "?R0(Iprot, readStructEnd)," << endl <<
     indent() << "Str." << endl;
   
   indent_down();
@@ -434,9 +434,9 @@ void t_erl_generator::generate_erl_struct_reader(ostream& out,
   indent_up();
 
     // Read beginning field marker
-    indent(out) <<
-      "{ Fname, Ftype, Fid } = ?M0(Iprot, readFieldBegin)," << endl <<
-      indent() << "Fid, Fname, % suppress unused warnings" << endl;
+  out <<
+    indent() << "{ _Fname, Ftype, Fid } = ?R0(Iprot, readFieldBegin)," << endl <<
+    indent() << "Fid, % suppress unused warnings" << endl;
 
     // Check for field STOP marker and break
     indent(out) << "if" << endl;
@@ -470,7 +470,7 @@ void t_erl_generator::generate_erl_struct_reader(ostream& out,
       indent_up();
       generate_deserialize_field(out, *f_iter, "Val");
 
-      out << indent() << "?M0(Iprot, readFieldEnd)," << endl
+      out << indent() << "?R0(Iprot, readFieldEnd)," << endl
          << indent() << uncapitalize(type_name(tstruct)) << "_read_loop(Iprot, "
          << "Str#" << uncapitalize(type_name(tstruct))
          << "{" << (*f_iter)->get_name()
@@ -481,8 +481,8 @@ void t_erl_generator::generate_erl_struct_reader(ostream& out,
     // In the default case we skip the field
     out <<
       indent() << "true -> " << endl <<
-      indent() << "  ?M1(Iprot, skip, Ftype)," << endl <<
-      indent() << "  ?M0(Iprot, readFieldEnd)," << endl <<
+      indent() << "  ?R1(Iprot, skip, Ftype)," << endl <<
+      indent() << "  ?R0(Iprot, readFieldEnd)," << endl <<
       indent() << "  " << uncapitalize(type_name(tstruct)) << "_read_loop(Iprot, Str)" << endl;
     indent_down();
     indent(out) << "end." << endl; 
@@ -519,9 +519,9 @@ void t_erl_generator::generate_erl_struct_writer(ostream& out, // TODO
   indent(out) << fname << "(Str, Oprot) -> %xy" << endl;
   indent_up();
   
-  indent(out) <<
-    "Str, % suppress unused warnings" << endl << 
-    indent() << "?M1(Oprot, writeStructBegin, \"" << name << "\")," << endl;
+  out <<
+    indent() << "Str, % suppress unused warnings" << endl <<
+    indent() << "?R1(Oprot, writeStructBegin, \"" << name << "\")," << endl;
 
 
   string prefix = string("Str#") + uncapitalize(type_name(tstruct)) + ".";
@@ -532,7 +532,7 @@ void t_erl_generator::generate_erl_struct_writer(ostream& out, // TODO
       "if " << prefix << (*f_iter)->get_name() << " /= undefined ->" << endl;
     indent_up();
     indent(out) <<
-      "?M3(Oprot, writeFieldBegin, " <<
+      "?R3(Oprot, writeFieldBegin, " <<
       "\"" << (*f_iter)->get_name() << "\", " <<
       type_to_enum((*f_iter)->get_type()) << ", " <<
       (*f_iter)->get_key() << ")," << endl;
@@ -542,7 +542,7 @@ void t_erl_generator::generate_erl_struct_writer(ostream& out, // TODO
 
     // Write field closer
     indent(out) <<
-      "?M0(Oprot, writeFieldEnd);" << endl <<
+      "?R0(Oprot, writeFieldEnd);" << endl <<
       indent() << "true -> ok" << endl;
 
     indent_down();
@@ -551,8 +551,8 @@ void t_erl_generator::generate_erl_struct_writer(ostream& out, // TODO
 
   // Write the struct map
   out <<
-    indent() << "?M0(Oprot, writeFieldStop)," << endl <<
-    indent() << "?M0(Oprot, writeStructEnd)," << endl <<
+    indent() << "?R0(Oprot, writeFieldStop)," << endl <<
+    indent() << "?R0(Oprot, writeStructEnd)," << endl <<
     indent() << "ok." << endl;
 
   indent_down();
@@ -598,7 +598,7 @@ void t_erl_generator::generate_service(t_service* tservice) {
 
   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();
 
@@ -763,8 +763,9 @@ void t_erl_generator::generate_service_client(t_service* tservice) {
 
       // 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;
@@ -779,9 +780,9 @@ void t_erl_generator::generate_service_client(t_service* tservice) {
 
       // Write to the stream
       f_service_ <<
-        indent() << "?M0(Oprot, writeMessageEnd)," << endl <<
-       indent() << "%% side-effect: not gonna happen" << endl <<
-       indent() << "%% ?M0(?M0(Oprot, trans), flush)," << endl <<
+        indent() << "?R0(Oprot, writeMessageEnd)," << endl <<
+       indent() << "Trans = ?R1(Oprot, get, trans)," << endl <<
+       indent() << "?R0(Trans, effectful_flush)," << endl <<
         indent() << "ok." << endl;  
 
     indent_down();
@@ -806,18 +807,17 @@ void t_erl_generator::generate_service_client(t_service* tservice) {
       // 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() << "    ?M0(Iprot, readMessageEnd), " << endl <<
+       indent() << "    tApplicationException:read(X, Iprot), %% cpiro rly treat exceptions different?" << endl <<
+       indent() << "    ?R0(Iprot, readMessageEnd), " << endl <<
        indent() << "    {error, X};" << endl <<
        indent() << "  true ->" << endl <<
        indent() << "    Result = " << resultname << "_read(Iprot)," << endl <<
-       indent() << "    ?M0(Iprot, readMessageEnd)," << endl <<
+       indent() << "    ?R0(Iprot, readMessageEnd)," << endl <<
        indent() << "    if % time to figure out retval" << endl;
 
        //      indent() << "    {ok, Success} % result.success casing? Success even for void?" << endl <<
@@ -845,7 +845,7 @@ void t_erl_generator::generate_service_client(t_service* tservice) {
       // 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 {
@@ -923,8 +923,7 @@ void t_erl_generator::generate_service_server(t_service* tservice) {
   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
 
@@ -940,14 +939,14 @@ void t_erl_generator::generate_service_server(t_service* tservice) {
 
     indent(f_service_) << "  %% TODO(cpiro): pass to super" << endl;
     indent(f_service_) << "  _ -> % unknown function" << endl <<
-    indent() << "    ?M1(Iprot, skip, ?tType_STRUCT)," << endl <<
-    indent() << "    ?M0(Iprot, readMessageEnd)," << endl <<
+    indent() << "    ?R1(Iprot, skip, ?tType_STRUCT)," << endl <<
+    indent() << "    ?R0(Iprot, readMessageEnd)," << endl <<
     indent() << "    X = tApplicationException:new(?tApplicationException_UNKNOWN_METHOD, \"Unknown function \" ++ Name)," << endl <<
-    indent() << "    ?M3(Oprot, writeMessageBegin, Name, ?tMessageType_EXCEPTION, Seqid)," << endl <<
-    indent() << "    ?M1(X, write, Oprot)," << endl <<
-    indent() << "    ?M0(Oprot, writeMessageEnd)," << endl <<
-    indent() << "    %% side-effect: not gonna happen" << endl <<
-    indent() << "    %% ?M0(?M0(Oprot, trans), flush)," << endl <<
+    indent() << "    ?R3(Oprot, writeMessageBegin, Name, ?tMessageType_EXCEPTION, Seqid)," << endl <<
+    indent() << "    tApplicationException:write(X, Oprot)," << endl <<
+    indent() << "    ?R0(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;
@@ -1000,13 +999,17 @@ void t_erl_generator::generate_process_function(t_service* tservice,
     "(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();
@@ -1040,7 +1043,7 @@ void t_erl_generator::generate_process_function(t_service* tservice,
     } 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;
 
@@ -1093,11 +1096,11 @@ void t_erl_generator::generate_process_function(t_service* tservice,
     indent(f_service_) << "% async" << endl;
   } else {
     f_service_ <<
-      indent() << "?M3(Oprot, writeMessageBegin, \"" << tfunction->get_name() << "\", ?tMessageType_REPLY, Seqid)," << endl <<
+      indent() << "?R3(Oprot, writeMessageBegin, \"" << tfunction->get_name() << "\", ?tMessageType_REPLY, Seqid)," << endl <<
       indent() << tfunction->get_name() << "_result_write(Result, Oprot)," << endl <<
-      indent() << "?M0(Oprot, writeMessageEnd)," << endl <<
-      indent() << "%% side-effect: not gonna happen" << endl <<
-      indent() << "%% ?M0(?M0(Oprot, trans), flush)," << endl;
+      indent() << "?R0(Oprot, writeMessageEnd)," << endl <<
+      indent() << "Trans = ?R1(Oprot, get, trans)," << endl <<
+      indent() << "?R0(Trans, effectful_flush)," << endl;
   }
   
   indent(f_service_) << "Result." << endl << endl;
@@ -1135,7 +1138,7 @@ void t_erl_generator::generate_deserialize_field(ostream &out,
   } else if (type->is_base_type() || type->is_enum()) {
     indent(out) <<
       //      name << " = iprot.";
-      name << " = ?M0(Iprot, ";
+      name << " = ?R0(Iprot, ";
     
     if (type->is_base_type()) {
       t_base_type::t_base tbase = ((t_base_type*)type)->get_base();
@@ -1334,7 +1337,7 @@ void t_erl_generator::generate_serialize_field(ostream &out,
     string name = prefix + tfield->get_name();
 
     indent(out) <<
-      "?M1(Oprot, ";
+      "?R1(Oprot, ";
     
     if (type->is_base_type()) {
       t_base_type::t_base tbase = ((t_base_type*)type)->get_base();
@@ -1390,7 +1393,7 @@ void t_erl_generator::generate_serialize_struct(ostream &out,
                                                string prefix) {
   indent(out) << tstruct->get_program()->get_name() << "_types:" <<  uncapitalize(tstruct->get_name()) << "_write(" << prefix << ", Oprot), % generate_serialize_struct" << endl;
   //  indent(out) <<
-  //    "?M1(" << prefix << ", write, Oprot), % generate_serialize_struct" << endl;
+  //    "?R1(" << prefix << ", write, Oprot), % generate_serialize_struct" << endl;
 }
 
 void t_erl_generator::generate_serialize_container(ostream &out,
@@ -1398,18 +1401,18 @@ void t_erl_generator::generate_serialize_container(ostream &out,
                                                   string prefix) {
   if (ttype->is_map()) {
     indent(out) <<
-      "?M3(Oprot, writeMapBegin, " <<
+      "?R3(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) <<
-      "?M2(Oprot, writeSetBegin, " <<
+      "?R2(Oprot, writeSetBegin, " <<
       type_to_enum(((t_set*)ttype)->get_elem_type()) << ", length(" <<
       prefix << ")), % generate_serialize_container" << endl;
   } else if (ttype->is_list()) {
     indent(out) <<
-      "?M2(Oprot, writeListBegin, " <<
+      "?R2(Oprot, writeListBegin, " <<
       type_to_enum(((t_list*)ttype)->get_elem_type()) << ", length(" <<
       prefix << ")), % generate_serialize_container" << endl;
   }
@@ -1444,13 +1447,13 @@ void t_erl_generator::generate_serialize_container(ostream &out,
     
   if (ttype->is_map()) {
     indent(out) <<
-      "?M0(Oprot, writeMapEnd), % generate_serialize_container" << endl;
+      "?R0(Oprot, writeMapEnd), % generate_serialize_container" << endl;
   } else if (ttype->is_set()) {
     indent(out) <<
-      "?M0(Oprot, writeSetEnd), % generate_serialize_container" << endl;
+      "?R0(Oprot, writeSetEnd), % generate_serialize_container" << endl;
   } else if (ttype->is_list()) {
     indent(out) <<
-      "?M0(Oprot, writeListEnd), % generate_serialize_container" << endl;
+      "?R0(Oprot, writeListEnd), % generate_serialize_container" << endl;
   }
 }
 
diff --git a/lib/erl/Makefile b/lib/erl/Makefile
new file mode 100644 (file)
index 0000000..072c8fa
--- /dev/null
@@ -0,0 +1,14 @@
+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
diff --git a/lib/erl/README b/lib/erl/README
new file mode 100644 (file)
index 0000000..84211bd
--- /dev/null
@@ -0,0 +1,68 @@
+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
+  
+
+
diff --git a/lib/erl/build/beamver b/lib/erl/build/beamver
new file mode 100644 (file)
index 0000000..fe448b9
--- /dev/null
@@ -0,0 +1,59 @@
+#!/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
+
diff --git a/lib/erl/build/buildtargets.mk b/lib/erl/build/buildtargets.mk
new file mode 100644 (file)
index 0000000..24d0bf8
--- /dev/null
@@ -0,0 +1,14 @@
+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 $@) $<
+
diff --git a/lib/erl/build/colors.mk b/lib/erl/build/colors.mk
new file mode 100644 (file)
index 0000000..4d69c41
--- /dev/null
@@ -0,0 +1,24 @@
+# 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'
diff --git a/lib/erl/build/docs.mk b/lib/erl/build/docs.mk
new file mode 100644 (file)
index 0000000..b0b7377
--- /dev/null
@@ -0,0 +1,12 @@
+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)       
+
diff --git a/lib/erl/build/mime.types b/lib/erl/build/mime.types
new file mode 100644 (file)
index 0000000..d6e3c0d
--- /dev/null
@@ -0,0 +1,98 @@
+
+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
diff --git a/lib/erl/build/otp.mk b/lib/erl/build/otp.mk
new file mode 100644 (file)
index 0000000..4e93ea8
--- /dev/null
@@ -0,0 +1,146 @@
+# +----------------------------------------------------------------------+
+# $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
+
diff --git a/lib/erl/build/otp_subdir.mk b/lib/erl/build/otp_subdir.mk
new file mode 100644 (file)
index 0000000..7333969
--- /dev/null
@@ -0,0 +1,85 @@
+# 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
diff --git a/lib/erl/build/raw_test.mk b/lib/erl/build/raw_test.mk
new file mode 100644 (file)
index 0000000..dbacf18
--- /dev/null
@@ -0,0 +1,29 @@
+# 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  
+
diff --git a/lib/erl/lib/Makefile b/lib/erl/lib/Makefile
new file mode 100644 (file)
index 0000000..4e3bfda
--- /dev/null
@@ -0,0 +1,10 @@
+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
diff --git a/lib/erl/lib/thrift/COPYING b/lib/erl/lib/thrift/COPYING
new file mode 100644 (file)
index 0000000..039f21e
--- /dev/null
@@ -0,0 +1,24 @@
+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.
diff --git a/lib/erl/lib/thrift/HEADER b/lib/erl/lib/thrift/HEADER
new file mode 100644 (file)
index 0000000..abd3efb
--- /dev/null
@@ -0,0 +1,6 @@
+%%% 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/
+
diff --git a/lib/erl/lib/thrift/LICENSE b/lib/erl/lib/thrift/LICENSE
new file mode 100644 (file)
index 0000000..039f21e
--- /dev/null
@@ -0,0 +1,24 @@
+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.
diff --git a/lib/erl/lib/thrift/Makefile b/lib/erl/lib/thrift/Makefile
new file mode 100644 (file)
index 0000000..0f2c8a8
--- /dev/null
@@ -0,0 +1,7 @@
+MODULES = \
+       src
+
+all clean docs:
+       for dir in $(MODULES); do \
+               (cd $$dir; ${MAKE} $@); \
+       done
diff --git a/lib/erl/lib/thrift/README b/lib/erl/lib/thrift/README
new file mode 100644 (file)
index 0000000..3d2fd6d
--- /dev/null
@@ -0,0 +1,39 @@
+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
diff --git a/lib/erl/lib/thrift/TODO b/lib/erl/lib/thrift/TODO
new file mode 100644 (file)
index 0000000..e2a870d
--- /dev/null
@@ -0,0 +1,10 @@
+tutorial client
+
+find TODO(cpiro)s
+make all methods effectful, remove the special casing (optionally, implement monads for Erlang)
+
+inheritance
+
+test suites
+
+undisgustify codegen
diff --git a/lib/erl/lib/thrift/include/oop.hrl b/lib/erl/lib/thrift/include/oop.hrl
new file mode 100644 (file)
index 0000000..b48e1ce
--- /dev/null
@@ -0,0 +1,26 @@
+%%% 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)
+).
diff --git a/lib/erl/lib/thrift/include/protocol/tBinaryProtocol.hrl b/lib/erl/lib/thrift/include/protocol/tBinaryProtocol.hrl
new file mode 100644 (file)
index 0000000..c976839
--- /dev/null
@@ -0,0 +1,10 @@
+%%% 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}).
diff --git a/lib/erl/lib/thrift/include/protocol/tBinaryProtocolFactory.hrl b/lib/erl/lib/thrift/include/protocol/tBinaryProtocolFactory.hrl
new file mode 100644 (file)
index 0000000..266932c
--- /dev/null
@@ -0,0 +1,7 @@
+%%% 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}).
diff --git a/lib/erl/lib/thrift/include/protocol/tProtocol.hrl b/lib/erl/lib/thrift/include/protocol/tProtocol.hrl
new file mode 100644 (file)
index 0000000..3e42d67
--- /dev/null
@@ -0,0 +1,7 @@
+%%% 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}).
diff --git a/lib/erl/lib/thrift/include/protocol/tProtocolException.hrl b/lib/erl/lib/thrift/include/protocol/tProtocolException.hrl
new file mode 100644 (file)
index 0000000..2de72d7
--- /dev/null
@@ -0,0 +1,15 @@
+%%% 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}).
+
+
diff --git a/lib/erl/lib/thrift/include/protocol/tProtocolFactory.hrl b/lib/erl/lib/thrift/include/protocol/tProtocolFactory.hrl
new file mode 100644 (file)
index 0000000..56c7fee
--- /dev/null
@@ -0,0 +1,7 @@
+%%% 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, {}).
diff --git a/lib/erl/lib/thrift/include/server/tErlServer.hrl b/lib/erl/lib/thrift/include/server/tErlServer.hrl
new file mode 100644 (file)
index 0000000..0a66993
--- /dev/null
@@ -0,0 +1,7 @@
+%%% 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}).
diff --git a/lib/erl/lib/thrift/include/server/tServer.hrl b/lib/erl/lib/thrift/include/server/tServer.hrl
new file mode 100644 (file)
index 0000000..502a137
--- /dev/null
@@ -0,0 +1,7 @@
+%%% 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}).
diff --git a/lib/erl/lib/thrift/include/server/tSimpleServer.hrl b/lib/erl/lib/thrift/include/server/tSimpleServer.hrl
new file mode 100644 (file)
index 0000000..f115d0b
--- /dev/null
@@ -0,0 +1,7 @@
+%%% 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}).
@@ -1,3 +1,9 @@
+%%% 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).
@@ -6,4 +12,4 @@
 -define(tApplicationException_BAD_SEQUENCE_ID, 4).
 -define(tApplicationException_MISSING_RESULT, 5).
 
--record(tApplicationException, {message, type=?tApplicationException_UNKNOWN}).
+-record(tApplicationException, {super, type}).
diff --git a/lib/erl/lib/thrift/include/tErlProcessor.hrl b/lib/erl/lib/thrift/include/tErlProcessor.hrl
new file mode 100644 (file)
index 0000000..78b91f1
--- /dev/null
@@ -0,0 +1,7 @@
+%%% 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}).
diff --git a/lib/erl/lib/thrift/include/tException.hrl b/lib/erl/lib/thrift/include/tException.hrl
new file mode 100644 (file)
index 0000000..808a474
--- /dev/null
@@ -0,0 +1,7 @@
+%%% 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}).
diff --git a/lib/erl/lib/thrift/include/tProcessor.hrl b/lib/erl/lib/thrift/include/tProcessor.hrl
new file mode 100644 (file)
index 0000000..3d138cd
--- /dev/null
@@ -0,0 +1,8 @@
+%%% 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, {}).
+
diff --git a/lib/erl/lib/thrift/include/thrift.hrl b/lib/erl/lib/thrift/include/thrift.hrl
new file mode 100644 (file)
index 0000000..b47fd39
--- /dev/null
@@ -0,0 +1,100 @@
+%%% 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").
diff --git a/lib/erl/lib/thrift/include/transport/tBufferedTransport.hrl b/lib/erl/lib/thrift/include/transport/tBufferedTransport.hrl
new file mode 100644 (file)
index 0000000..05c738e
--- /dev/null
@@ -0,0 +1,7 @@
+%%% 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}).
diff --git a/lib/erl/lib/thrift/include/transport/tBufferedTransportFactory.hrl b/lib/erl/lib/thrift/include/transport/tBufferedTransportFactory.hrl
new file mode 100644 (file)
index 0000000..3a4cdc5
--- /dev/null
@@ -0,0 +1,7 @@
+%%% 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}).
diff --git a/lib/erl/lib/thrift/include/transport/tErlAcceptor.hrl b/lib/erl/lib/thrift/include/transport/tErlAcceptor.hrl
new file mode 100644 (file)
index 0000000..333feb5
--- /dev/null
@@ -0,0 +1,7 @@
+%%% 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}).
diff --git a/lib/erl/lib/thrift/include/transport/tServerSocket.hrl b/lib/erl/lib/thrift/include/transport/tServerSocket.hrl
new file mode 100644 (file)
index 0000000..a2c25ac
--- /dev/null
@@ -0,0 +1,7 @@
+%%% 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}).
diff --git a/lib/erl/lib/thrift/include/transport/tServerTransport.hrl b/lib/erl/lib/thrift/include/transport/tServerTransport.hrl
new file mode 100644 (file)
index 0000000..207bbf6
--- /dev/null
@@ -0,0 +1,7 @@
+%%% 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, {}).
diff --git a/lib/erl/lib/thrift/include/transport/tSocket.hrl b/lib/erl/lib/thrift/include/transport/tSocket.hrl
new file mode 100644 (file)
index 0000000..0317d5a
--- /dev/null
@@ -0,0 +1,7 @@
+%%% 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}).
diff --git a/lib/erl/lib/thrift/include/transport/tTransport.hrl b/lib/erl/lib/thrift/include/transport/tTransport.hrl
new file mode 100644 (file)
index 0000000..ca89413
--- /dev/null
@@ -0,0 +1,7 @@
+%%% 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, {}).
diff --git a/lib/erl/lib/thrift/include/transport/tTransportException.hrl b/lib/erl/lib/thrift/include/transport/tTransportException.hrl
new file mode 100644 (file)
index 0000000..1a60aad
--- /dev/null
@@ -0,0 +1,13 @@
+%%% 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}).
diff --git a/lib/erl/lib/thrift/include/transport/tTransportFactory.hrl b/lib/erl/lib/thrift/include/transport/tTransportFactory.hrl
new file mode 100644 (file)
index 0000000..d488140
--- /dev/null
@@ -0,0 +1,7 @@
+%%% 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, {}).
diff --git a/lib/erl/lib/thrift/server.sh b/lib/erl/lib/thrift/server.sh
new file mode 100755 (executable)
index 0000000..c02c0e4
--- /dev/null
@@ -0,0 +1,5 @@
+#!/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
diff --git a/lib/erl/lib/thrift/src/Makefile b/lib/erl/lib/thrift/src/Makefile
new file mode 100644 (file)
index 0000000..29352c8
--- /dev/null
@@ -0,0 +1,112 @@
+# $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
diff --git a/lib/erl/lib/thrift/src/oop.erl b/lib/erl/lib/thrift/src/oop.erl
new file mode 100644 (file)
index 0000000..bb6f34f
--- /dev/null
@@ -0,0 +1,146 @@
+%%% 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.
diff --git a/lib/erl/lib/thrift/src/protocol/tBinaryProtocol.erl b/lib/erl/lib/thrift/src/protocol/tBinaryProtocol.erl
new file mode 100644 (file)
index 0000000..b745298
--- /dev/null
@@ -0,0 +1,214 @@
+%%% 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)).
diff --git a/lib/erl/lib/thrift/src/protocol/tBinaryProtocolFactory.erl b/lib/erl/lib/thrift/src/protocol/tBinaryProtocolFactory.erl
new file mode 100644 (file)
index 0000000..ff7fa56
--- /dev/null
@@ -0,0 +1,57 @@
+%%% 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]).
+
diff --git a/lib/erl/lib/thrift/src/protocol/tProtocol.erl b/lib/erl/lib/thrift/src/protocol/tProtocol.erl
new file mode 100644 (file)
index 0000000..8900c5d
--- /dev/null
@@ -0,0 +1,217 @@
+%%% 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).
diff --git a/lib/erl/lib/thrift/src/protocol/tProtocolException.erl b/lib/erl/lib/thrift/src/protocol/tProtocolException.erl
new file mode 100644 (file)
index 0000000..d926aff
--- /dev/null
@@ -0,0 +1,58 @@
+%%% 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
+%%%
diff --git a/lib/erl/lib/thrift/src/protocol/tProtocolFactory.erl b/lib/erl/lib/thrift/src/protocol/tProtocolFactory.erl
new file mode 100644 (file)
index 0000000..d697263
--- /dev/null
@@ -0,0 +1,54 @@
+%%% 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.
diff --git a/lib/erl/lib/thrift/src/server/tErlServer.erl b/lib/erl/lib/thrift/src/server/tErlServer.erl
new file mode 100644 (file)
index 0000000..8a94709
--- /dev/null
@@ -0,0 +1,112 @@
+%%% 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.                                                                                                            %%
+%%                                                                                                                    %%
diff --git a/lib/erl/lib/thrift/src/server/tServer.erl b/lib/erl/lib/thrift/src/server/tServer.erl
new file mode 100644 (file)
index 0000000..23aef22
--- /dev/null
@@ -0,0 +1,81 @@
+%%% 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.
diff --git a/lib/erl/lib/thrift/src/server/tSimpleServer.erl b/lib/erl/lib/thrift/src/server/tSimpleServer.erl
new file mode 100644 (file)
index 0000000..5b457cd
--- /dev/null
@@ -0,0 +1,106 @@
+%%% 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.
diff --git a/lib/erl/lib/thrift/src/tApplicationException.erl b/lib/erl/lib/thrift/src/tApplicationException.erl
new file mode 100644 (file)
index 0000000..568b9c9
--- /dev/null
@@ -0,0 +1,115 @@
+%%% 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.
diff --git a/lib/erl/lib/thrift/src/tErlProcessor.erl b/lib/erl/lib/thrift/src/tErlProcessor.erl
new file mode 100644 (file)
index 0000000..a95ef53
--- /dev/null
@@ -0,0 +1,62 @@
+%%% 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]).
diff --git a/lib/erl/lib/thrift/src/tException.erl b/lib/erl/lib/thrift/src/tException.erl
new file mode 100644 (file)
index 0000000..0ec4c94
--- /dev/null
@@ -0,0 +1,50 @@
+%%% 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
+%%%
+
diff --git a/lib/erl/lib/thrift/src/tProcessor.erl b/lib/erl/lib/thrift/src/tProcessor.erl
new file mode 100644 (file)
index 0000000..003748a
--- /dev/null
@@ -0,0 +1,50 @@
+%%% 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
+%%%
+
diff --git a/lib/erl/lib/thrift/src/thrift.app.src b/lib/erl/lib/thrift/src/thrift.app.src
new file mode 100755 (executable)
index 0000000..dc2926a
--- /dev/null
@@ -0,0 +1,41 @@
+%%% -*- 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%, []}}
+ ]
+}.
+
diff --git a/lib/erl/lib/thrift/src/thrift.appup.src b/lib/erl/lib/thrift/src/thrift.appup.src
new file mode 100755 (executable)
index 0000000..54a6383
--- /dev/null
@@ -0,0 +1 @@
+{"%VSN%",[],[]}.
diff --git a/lib/erl/lib/thrift/src/thrift_oop_server.erl b/lib/erl/lib/thrift/src/thrift_oop_server.erl
new file mode 100644 (file)
index 0000000..8fc9123
--- /dev/null
@@ -0,0 +1,213 @@
+%%% 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
+%%====================================================================
diff --git a/lib/erl/lib/thrift/src/transport/tBufferedTransport.erl b/lib/erl/lib/thrift/src/transport/tBufferedTransport.erl
new file mode 100644 (file)
index 0000000..48d9fba
--- /dev/null
@@ -0,0 +1,84 @@
+%%% 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}.
diff --git a/lib/erl/lib/thrift/src/transport/tBufferedTransportFactory.erl b/lib/erl/lib/thrift/src/transport/tBufferedTransportFactory.erl
new file mode 100644 (file)
index 0000000..9746aba
--- /dev/null
@@ -0,0 +1,54 @@
+%%% 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]}).
diff --git a/lib/erl/lib/thrift/src/transport/tErlAcceptor.erl b/lib/erl/lib/thrift/src/transport/tErlAcceptor.erl
new file mode 100644 (file)
index 0000000..fd06260
--- /dev/null
@@ -0,0 +1,226 @@
+%%% 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.                                                                                                     %%
+
diff --git a/lib/erl/lib/thrift/src/transport/tServerSocket.erl b/lib/erl/lib/thrift/src/transport/tServerSocket.erl
new file mode 100644 (file)
index 0000000..d0cbf92
--- /dev/null
@@ -0,0 +1,96 @@
+%%% 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.
diff --git a/lib/erl/lib/thrift/src/transport/tServerTransport.erl b/lib/erl/lib/thrift/src/transport/tServerTransport.erl
new file mode 100644 (file)
index 0000000..dfc9ccb
--- /dev/null
@@ -0,0 +1,52 @@
+%%% 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.
diff --git a/lib/erl/lib/thrift/src/transport/tSocket.erl b/lib/erl/lib/thrift/src/transport/tSocket.erl
new file mode 100644 (file)
index 0000000..3ac066c
--- /dev/null
@@ -0,0 +1,126 @@
+%%% 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.
+
diff --git a/lib/erl/lib/thrift/src/transport/tTransport.erl b/lib/erl/lib/thrift/src/transport/tTransport.erl
new file mode 100644 (file)
index 0000000..c15a632
--- /dev/null
@@ -0,0 +1,86 @@
+%%% 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}.
diff --git a/lib/erl/lib/thrift/src/transport/tTransportException.erl b/lib/erl/lib/thrift/src/transport/tTransportException.erl
new file mode 100644 (file)
index 0000000..43a7afa
--- /dev/null
@@ -0,0 +1,58 @@
+%%% 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
+%%%
diff --git a/lib/erl/lib/thrift/src/transport/tTransportFactory.erl b/lib/erl/lib/thrift/src/transport/tTransportFactory.erl
new file mode 100644 (file)
index 0000000..1c8ca61
--- /dev/null
@@ -0,0 +1,52 @@
+%%% 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.
diff --git a/lib/erl/lib/thrift/tutorial b/lib/erl/lib/thrift/tutorial
new file mode 120000 (symlink)
index 0000000..9720a4c
--- /dev/null
@@ -0,0 +1 @@
+../../../../tutorial
\ No newline at end of file
diff --git a/lib/erl/lib/thrift/user b/lib/erl/lib/thrift/user
new file mode 120000 (symlink)
index 0000000..a5aac6e
--- /dev/null
@@ -0,0 +1 @@
+../../../../tutorial/erl
\ No newline at end of file
diff --git a/lib/erl/lib/thrift/vsn.mk b/lib/erl/lib/thrift/vsn.mk
new file mode 100644 (file)
index 0000000..d9b4001
--- /dev/null
@@ -0,0 +1 @@
+THRIFT_VSN=0.1
diff --git a/lib/erl/licence.txt b/lib/erl/licence.txt
new file mode 100644 (file)
index 0000000..8ee2992
--- /dev/null
@@ -0,0 +1,20 @@
+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.
diff --git a/lib/erl/release_DISABLED/Makefile b/lib/erl/release_DISABLED/Makefile
new file mode 100644 (file)
index 0000000..c3274cd
--- /dev/null
@@ -0,0 +1,10 @@
+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
diff --git a/lib/erl/release_DISABLED/thrift_rel/Makefile b/lib/erl/release_DISABLED/thrift_rel/Makefile
new file mode 100755 (executable)
index 0000000..5d35956
--- /dev/null
@@ -0,0 +1,298 @@
+# ----------------------------------------------------
+# 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 $< $@
+
diff --git a/lib/erl/release_DISABLED/thrift_rel/local/thrift_rel.config b/lib/erl/release_DISABLED/thrift_rel/local/thrift_rel.config
new file mode 100644 (file)
index 0000000..39091ef
--- /dev/null
@@ -0,0 +1,26 @@
+%%% -*- 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,
+  [
+  ]}
+]. 
diff --git a/lib/erl/release_DISABLED/thrift_rel/local/thrift_rel.sh b/lib/erl/release_DISABLED/thrift_rel/local/thrift_rel.sh
new file mode 100755 (executable)
index 0000000..d30a43c
--- /dev/null
@@ -0,0 +1,3 @@
+#!/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 $@
diff --git a/lib/erl/release_DISABLED/thrift_rel/local/var/1.0/www/conf/mime.types b/lib/erl/release_DISABLED/thrift_rel/local/var/1.0/www/conf/mime.types
new file mode 100644 (file)
index 0000000..d6e3c0d
--- /dev/null
@@ -0,0 +1,98 @@
+
+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
diff --git a/lib/erl/release_DISABLED/thrift_rel/local/var/1.0/www/conf/yaws.conf b/lib/erl/release_DISABLED/thrift_rel/local/var/1.0/www/conf/yaws.conf
new file mode 100644 (file)
index 0000000..8857aac
--- /dev/null
@@ -0,0 +1,166 @@
+
+# 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>
+                               
+       
+
+
+
+
+
+
diff --git a/lib/erl/release_DISABLED/thrift_rel/thrift_rel.config.src b/lib/erl/release_DISABLED/thrift_rel/thrift_rel.config.src
new file mode 100755 (executable)
index 0000000..c701c5a
--- /dev/null
@@ -0,0 +1,26 @@
+%%% -*- 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%,
+  [
+  ]}
+]. 
diff --git a/lib/erl/release_DISABLED/thrift_rel/thrift_rel.rel.src b/lib/erl/release_DISABLED/thrift_rel/thrift_rel.rel.src
new file mode 100644 (file)
index 0000000..a11d240
--- /dev/null
@@ -0,0 +1,14 @@
+%%% -*- mode:erlang -*-
+{release, 
+ {"thrift_rel", "%REL_VSN%"},
+ erts,
+ [
+  kernel,
+  stdlib,
+  sasl,
+  fslib,
+  gas,
+  thrift
+ ]
+}. 
+
diff --git a/lib/erl/release_DISABLED/thrift_rel/thrift_rel.rel.src.tmp b/lib/erl/release_DISABLED/thrift_rel/thrift_rel.rel.src.tmp
new file mode 100644 (file)
index 0000000..b334f70
--- /dev/null
@@ -0,0 +1,14 @@
+%%% -*- mode:erlang -*-
+{release, 
+ {"thrift_rel", "1.0"},
+ erts,
+ [
+  kernel,
+  stdlib,
+  sasl,
+  fslib,
+  gas,
+  thrift
+ ]
+}. 
+
diff --git a/lib/erl/release_DISABLED/thrift_rel/vsn.mk b/lib/erl/release_DISABLED/thrift_rel/vsn.mk
new file mode 100755 (executable)
index 0000000..0ac8e07
--- /dev/null
@@ -0,0 +1 @@
+REL_VSN=1.0
diff --git a/lib/erl/release_DISABLED/thrift_rel/yaws.conf.src b/lib/erl/release_DISABLED/thrift_rel/yaws.conf.src
new file mode 100644 (file)
index 0000000..8857aac
--- /dev/null
@@ -0,0 +1,166 @@
+
+# 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>
+                               
+       
+
+
+
+
+
+
diff --git a/lib/erl/src-loose/protocol/tBinaryProtocol.erl b/lib/erl/src-loose/protocol/tBinaryProtocol.erl
deleted file mode 100644 (file)
index b82af73..0000000
+++ /dev/null
@@ -1,232 +0,0 @@
--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)).
diff --git a/lib/erl/src-loose/protocol/tBinaryProtocol.hrl b/lib/erl/src-loose/protocol/tBinaryProtocol.hrl
deleted file mode 100644 (file)
index cfd4836..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
--define(VERSION_MASK, 16#FFFF0000).
--define(VERSION_1, 16#80010000).
--record(tBinaryProtocol, {trans}).
-
diff --git a/lib/erl/src-loose/protocol/tProtocol.erl b/lib/erl/src-loose/protocol/tProtocol.erl
deleted file mode 100644 (file)
index a36ca11..0000000
+++ /dev/null
@@ -1,69 +0,0 @@
--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.
-
-
diff --git a/lib/erl/src-loose/protocol/tProtocol.hrl b/lib/erl/src-loose/protocol/tProtocol.hrl
deleted file mode 100644 (file)
index 4385124..0000000
+++ /dev/null
@@ -1 +0,0 @@
--record(tProtocol, {trans}).
diff --git a/lib/erl/src-loose/protocol/tProtocolException.erl b/lib/erl/src-loose/protocol/tProtocolException.erl
deleted file mode 100644 (file)
index b9aa48a..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
--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).
diff --git a/lib/erl/src-loose/protocol/tProtocolException.hrl b/lib/erl/src-loose/protocol/tProtocolException.hrl
deleted file mode 100644 (file)
index 96bf3ac..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
--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).
-
diff --git a/lib/erl/src-loose/server/tServer.erl b/lib/erl/src-loose/server/tServer.erl
deleted file mode 100644 (file)
index 0c3182e..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
--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.
-
diff --git a/lib/erl/src-loose/server/tServer.hrl b/lib/erl/src-loose/server/tServer.hrl
deleted file mode 100644 (file)
index 23da029..0000000
+++ /dev/null
@@ -1 +0,0 @@
--record(tServer, {processorModule, handlerModule, serverTransport}).
diff --git a/lib/erl/src-loose/tApplicationException.erl b/lib/erl/src-loose/tApplicationException.erl
deleted file mode 100644 (file)
index c6453a3..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
--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).
diff --git a/lib/erl/src-loose/tException.erl b/lib/erl/src-loose/tException.erl
deleted file mode 100644 (file)
index 3a4a9e8..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
--module(tException).
--include("tException.hrl").
--export([new/0]).
-
-new() ->
-    #tException{}.
-
diff --git a/lib/erl/src-loose/tException.hrl b/lib/erl/src-loose/tException.hrl
deleted file mode 100644 (file)
index 6b10551..0000000
+++ /dev/null
@@ -1 +0,0 @@
--record(tException, {message}).
diff --git a/lib/erl/src-loose/thrift.hrl b/lib/erl/src-loose/thrift.hrl
deleted file mode 100644 (file)
index 845d61c..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
--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").
diff --git a/lib/erl/src-loose/transport/tBufferedTransport.erl b/lib/erl/src-loose/transport/tBufferedTransport.erl
deleted file mode 100644 (file)
index 1cc809d..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
--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?
diff --git a/lib/erl/src-loose/transport/tBufferedTransport.hrl b/lib/erl/src-loose/transport/tBufferedTransport.hrl
deleted file mode 100644 (file)
index d8d71e1..0000000
+++ /dev/null
@@ -1 +0,0 @@
--record(tBufferedTransport, {transport, wbuf}).
diff --git a/lib/erl/src-loose/transport/tServerSocket.erl b/lib/erl/src-loose/transport/tServerSocket.erl
deleted file mode 100644 (file)
index 239af6e..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
--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.
diff --git a/lib/erl/src-loose/transport/tServerSocket.hrl b/lib/erl/src-loose/transport/tServerSocket.hrl
deleted file mode 100644 (file)
index 34ed320..0000000
+++ /dev/null
@@ -1 +0,0 @@
--record(tServerSocket, {port, handle}).
diff --git a/lib/erl/src-loose/transport/tSocket.erl b/lib/erl/src-loose/transport/tSocket.erl
deleted file mode 100644 (file)
index 850c3b9..0000000
+++ /dev/null
@@ -1,96 +0,0 @@
--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.
-
diff --git a/lib/erl/src-loose/transport/tSocket.hrl b/lib/erl/src-loose/transport/tSocket.hrl
deleted file mode 100644 (file)
index dc1cc20..0000000
+++ /dev/null
@@ -1 +0,0 @@
--record(tSocket, {host, port, handle}).
diff --git a/lib/erl/src-loose/transport/tTransport.erl b/lib/erl/src-loose/transport/tTransport.erl
deleted file mode 100644 (file)
index 91b7228..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
--module(tTransport).
-
--include("thrift/transport/tTransportException.hrl").
-
diff --git a/lib/erl/src-loose/transport/tTransportException.erl b/lib/erl/src-loose/transport/tTransportException.erl
deleted file mode 100644 (file)
index b31bb20..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
--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).
diff --git a/lib/erl/src-loose/transport/tTransportException.hrl b/lib/erl/src-loose/transport/tTransportException.hrl
deleted file mode 100644 (file)
index fa8554b..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
--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}).
diff --git a/lib/erl/thrift b/lib/erl/thrift
deleted file mode 120000 (symlink)
index 1ab4c5c..0000000
+++ /dev/null
@@ -1 +0,0 @@
-src-loose
\ No newline at end of file
diff --git a/lib/erl/tools/.appgen/blank_app/Makefile b/lib/erl/tools/.appgen/blank_app/Makefile
new file mode 100755 (executable)
index 0000000..0f2c8a8
--- /dev/null
@@ -0,0 +1,7 @@
+MODULES = \
+       src
+
+all clean docs:
+       for dir in $(MODULES); do \
+               (cd $$dir; ${MAKE} $@); \
+       done
diff --git a/lib/erl/tools/.appgen/blank_app/include/blank_app.hrl b/lib/erl/tools/.appgen/blank_app/include/blank_app.hrl
new file mode 100755 (executable)
index 0000000..e69de29
diff --git a/lib/erl/tools/.appgen/blank_app/src/Makefile b/lib/erl/tools/.appgen/blank_app/src/Makefile
new file mode 100755 (executable)
index 0000000..13b06f0
--- /dev/null
@@ -0,0 +1,112 @@
+# $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
diff --git a/lib/erl/tools/.appgen/blank_app/src/ba_server.erl b/lib/erl/tools/.appgen/blank_app/src/ba_server.erl
new file mode 100755 (executable)
index 0000000..9a98f1c
--- /dev/null
@@ -0,0 +1,124 @@
+%%%-------------------------------------------------------------------
+%%% @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
+%%====================================================================
diff --git a/lib/erl/tools/.appgen/blank_app/src/ba_sup.erl b/lib/erl/tools/.appgen/blank_app/src/ba_sup.erl
new file mode 100755 (executable)
index 0000000..b5f48d1
--- /dev/null
@@ -0,0 +1,74 @@
+%%%-------------------------------------------------------------------
+%%% @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
+%%====================================================================
diff --git a/lib/erl/tools/.appgen/blank_app/src/blank_app.app.src b/lib/erl/tools/.appgen/blank_app/src/blank_app.app.src
new file mode 100755 (executable)
index 0000000..a1513fb
--- /dev/null
@@ -0,0 +1,41 @@
+%%% -*- 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%, []}}
+ ]
+}.
+
diff --git a/lib/erl/tools/.appgen/blank_app/src/blank_app.appup.src b/lib/erl/tools/.appgen/blank_app/src/blank_app.appup.src
new file mode 100755 (executable)
index 0000000..54a6383
--- /dev/null
@@ -0,0 +1 @@
+{"%VSN%",[],[]}.
diff --git a/lib/erl/tools/.appgen/blank_app/src/blank_app.erl b/lib/erl/tools/.appgen/blank_app/src/blank_app.erl
new file mode 100755 (executable)
index 0000000..8db6fe0
--- /dev/null
@@ -0,0 +1,63 @@
+%%%-------------------------------------------------------------------
+%%% @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.
+
diff --git a/lib/erl/tools/.appgen/blank_app/vsn.mk b/lib/erl/tools/.appgen/blank_app/vsn.mk
new file mode 100755 (executable)
index 0000000..9ba174b
--- /dev/null
@@ -0,0 +1 @@
+%%APP_NAME_UPPER_CASE%%_VSN=1.0
diff --git a/lib/erl/tools/.appgen/blank_app_rel/Makefile b/lib/erl/tools/.appgen/blank_app_rel/Makefile
new file mode 100755 (executable)
index 0000000..5d35956
--- /dev/null
@@ -0,0 +1,298 @@
+# ----------------------------------------------------
+# 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 $< $@
+
diff --git a/lib/erl/tools/.appgen/blank_app_rel/blank_app_rel.config.src b/lib/erl/tools/.appgen/blank_app_rel/blank_app_rel.config.src
new file mode 100755 (executable)
index 0000000..c701c5a
--- /dev/null
@@ -0,0 +1,26 @@
+%%% -*- 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%,
+  [
+  ]}
+]. 
diff --git a/lib/erl/tools/.appgen/blank_app_rel/blank_app_rel.rel.src b/lib/erl/tools/.appgen/blank_app_rel/blank_app_rel.rel.src
new file mode 100755 (executable)
index 0000000..f69578e
--- /dev/null
@@ -0,0 +1,14 @@
+%%% -*- mode:erlang -*-
+{release, 
+ {"%%APP_NAME%%_rel", "%REL_VSN%"},
+ erts,
+ [
+  kernel,
+  stdlib,
+  sasl,
+  fslib,
+  gas,
+  %%APP_NAME%%
+ ]
+}. 
+
diff --git a/lib/erl/tools/.appgen/blank_app_rel/vsn.mk b/lib/erl/tools/.appgen/blank_app_rel/vsn.mk
new file mode 100755 (executable)
index 0000000..0ac8e07
--- /dev/null
@@ -0,0 +1 @@
+REL_VSN=1.0
diff --git a/lib/erl/tools/.appgen/blank_app_rel/yaws.conf.src b/lib/erl/tools/.appgen/blank_app_rel/yaws.conf.src
new file mode 100644 (file)
index 0000000..8857aac
--- /dev/null
@@ -0,0 +1,166 @@
+
+# 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>
+                               
+       
+
+
+
+
+
+
diff --git a/lib/erl/tools/.appgen/rename.sh b/lib/erl/tools/.appgen/rename.sh
new file mode 100755 (executable)
index 0000000..6f077c2
--- /dev/null
@@ -0,0 +1,25 @@
+#!/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
+
diff --git a/lib/erl/tools/.appgen/substitute.sh b/lib/erl/tools/.appgen/substitute.sh
new file mode 100755 (executable)
index 0000000..5305b75
--- /dev/null
@@ -0,0 +1,33 @@
+#!/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
+
diff --git a/lib/erl/tools/.appgen/thrift_rel/Makefile b/lib/erl/tools/.appgen/thrift_rel/Makefile
new file mode 100755 (executable)
index 0000000..5d35956
--- /dev/null
@@ -0,0 +1,298 @@
+# ----------------------------------------------------
+# 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 $< $@
+
diff --git a/lib/erl/tools/.appgen/thrift_rel/thrift_rel.config.src b/lib/erl/tools/.appgen/thrift_rel/thrift_rel.config.src
new file mode 100755 (executable)
index 0000000..c701c5a
--- /dev/null
@@ -0,0 +1,26 @@
+%%% -*- 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%,
+  [
+  ]}
+]. 
diff --git a/lib/erl/tools/.appgen/thrift_rel/thrift_rel.rel.src b/lib/erl/tools/.appgen/thrift_rel/thrift_rel.rel.src
new file mode 100644 (file)
index 0000000..a11d240
--- /dev/null
@@ -0,0 +1,14 @@
+%%% -*- mode:erlang -*-
+{release, 
+ {"thrift_rel", "%REL_VSN%"},
+ erts,
+ [
+  kernel,
+  stdlib,
+  sasl,
+  fslib,
+  gas,
+  thrift
+ ]
+}. 
+
diff --git a/lib/erl/tools/.appgen/thrift_rel/vsn.mk b/lib/erl/tools/.appgen/thrift_rel/vsn.mk
new file mode 100755 (executable)
index 0000000..0ac8e07
--- /dev/null
@@ -0,0 +1 @@
+REL_VSN=1.0
diff --git a/lib/erl/tools/.appgen/thrift_rel/yaws.conf.src b/lib/erl/tools/.appgen/thrift_rel/yaws.conf.src
new file mode 100644 (file)
index 0000000..8857aac
--- /dev/null
@@ -0,0 +1,166 @@
+
+# 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>
+                               
+       
+
+
+
+
+
+
diff --git a/lib/erl/tools/emacs/erlang-start.el b/lib/erl/tools/emacs/erlang-start.el
new file mode 100755 (executable)
index 0000000..5181b9a
--- /dev/null
@@ -0,0 +1,115 @@
+;; 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.
diff --git a/lib/erl/tools/emacs/erlang.el b/lib/erl/tools/emacs/erlang.el
new file mode 100755 (executable)
index 0000000..5916f73
--- /dev/null
@@ -0,0 +1,6291 @@
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