couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dav...@apache.org
Subject [14/44] couchdb commit: updated refs/heads/1843-feature-bigcouch-multi-repo to 2385a37
Date Tue, 04 Feb 2014 23:44:27 GMT
Remove src/couch


Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/ed98610c
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/ed98610c
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/ed98610c

Branch: refs/heads/1843-feature-bigcouch-multi-repo
Commit: ed98610c5f27e5ea7e7528c081e1e7b54330e221
Parents: 4964214
Author: Paul J. Davis <paul.joseph.davis@gmail.com>
Authored: Tue Feb 4 17:39:22 2014 -0600
Committer: Paul J. Davis <paul.joseph.davis@gmail.com>
Committed: Tue Feb 4 17:39:22 2014 -0600

----------------------------------------------------------------------
 src/couch/include/couch_db.hrl                  |  256 ----
 .../couch_ejson_compare/couch_ejson_compare.c   |  457 ------
 .../priv/couch_ejson_compare/erl_nif_compat.h   |  128 --
 src/couch/priv/couch_js/help.h                  |   82 -
 src/couch/priv/couch_js/http.c                  |  698 ---------
 src/couch/priv/couch_js/http.h                  |   27 -
 src/couch/priv/couch_js/main.c                  |   21 -
 src/couch/priv/couch_js/sm185.c                 |  431 ------
 src/couch/priv/couch_js/utf8.c                  |  291 ----
 src/couch/priv/couch_js/utf8.h                  |   19 -
 src/couch/priv/couch_js/util.c                  |  294 ----
 src/couch/priv/couch_js/util.h                  |   35 -
 src/couch/priv/icu_driver/couch_icu_driver.c    |  189 ---
 .../priv/spawnkillable/couchspawnkillable.sh    |   20 -
 .../priv/spawnkillable/couchspawnkillable_win.c |  145 --
 src/couch/priv/stat_descriptions.cfg            |   50 -
 src/couch/rebar.config.script                   |   70 -
 src/couch/src/couch.app.src                     |   22 -
 src/couch/src/couch.erl                         |   65 -
 src/couch/src/couch_app.erl                     |   31 -
 src/couch/src/couch_auth_cache.erl              |  437 ------
 src/couch/src/couch_btree.erl                   |  731 ---------
 src/couch/src/couch_changes.erl                 |  583 --------
 src/couch/src/couch_compaction_daemon.erl       |  514 -------
 src/couch/src/couch_compress.erl                |   84 --
 src/couch/src/couch_config.erl                  |  251 ----
 src/couch/src/couch_config_writer.erl           |   88 --
 src/couch/src/couch_db.erl                      | 1412 ------------------
 src/couch/src/couch_db_update_notifier.erl      |   82 -
 src/couch/src/couch_db_update_notifier_sup.erl  |   68 -
 src/couch/src/couch_db_updater.erl              | 1264 ----------------
 src/couch/src/couch_doc.erl                     |  784 ----------
 src/couch/src/couch_drv.erl                     |   62 -
 src/couch/src/couch_ejson_compare.erl           |  113 --
 src/couch/src/couch_emsort.erl                  |  318 ----
 src/couch/src/couch_event_sup.erl               |   73 -
 src/couch/src/couch_external_manager.erl        |  115 --
 src/couch/src/couch_external_server.erl         |   84 --
 src/couch/src/couch_file.erl                    |  587 --------
 src/couch/src/couch_httpd.erl                   | 1082 --------------
 src/couch/src/couch_httpd_auth.erl              |  376 -----
 src/couch/src/couch_httpd_cors.erl              |  343 -----
 src/couch/src/couch_httpd_db.erl                | 1210 ---------------
 src/couch/src/couch_httpd_external.erl          |  173 ---
 src/couch/src/couch_httpd_misc_handlers.erl     |  306 ----
 src/couch/src/couch_httpd_oauth.erl             |  387 -----
 src/couch/src/couch_httpd_proxy.erl             |  426 ------
 src/couch/src/couch_httpd_rewrite.erl           |  483 ------
 src/couch/src/couch_httpd_stats_handlers.erl    |   56 -
 src/couch/src/couch_httpd_vhost.erl             |  397 -----
 src/couch/src/couch_js_functions.hrl            |  155 --
 src/couch/src/couch_key_tree.erl                |  422 ------
 src/couch/src/couch_log.erl                     |  263 ----
 src/couch/src/couch_lru.erl                     |   48 -
 src/couch/src/couch_native_process.erl          |  422 ------
 src/couch/src/couch_os_daemons.erl              |  377 -----
 src/couch/src/couch_os_process.erl              |  285 ----
 src/couch/src/couch_passwords.erl               |  119 --
 src/couch/src/couch_primary_sup.erl             |   60 -
 src/couch/src/couch_proc_manager.erl            |  307 ----
 src/couch/src/couch_query_servers.erl           |  479 ------
 src/couch/src/couch_secondary_sup.erl           |   42 -
 src/couch/src/couch_server.erl                  |  510 -------
 src/couch/src/couch_stats_aggregator.erl        |  312 ----
 src/couch/src/couch_stats_collector.erl         |  134 --
 src/couch/src/couch_stream.erl                  |  299 ----
 src/couch/src/couch_sup.erl                     |  159 --
 src/couch/src/couch_task_status.erl             |  151 --
 src/couch/src/couch_users_db.erl                |  110 --
 src/couch/src/couch_util.erl                    |  500 -------
 src/couch/src/couch_uuids.erl                   |  116 --
 src/couch/src/couch_work_queue.erl              |  187 ---
 72 files changed, 21677 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/ed98610c/src/couch/include/couch_db.hrl
----------------------------------------------------------------------
diff --git a/src/couch/include/couch_db.hrl b/src/couch/include/couch_db.hrl
deleted file mode 100644
index ffecae0..0000000
--- a/src/couch/include/couch_db.hrl
+++ /dev/null
@@ -1,256 +0,0 @@
-% Licensed under the Apache License, Version 2.0 (the "License"); you may not
-% use this file except in compliance with the License. You may obtain a copy of
-% the License at
-%
-%   http://www.apache.org/licenses/LICENSE-2.0
-%
-% Unless required by applicable law or agreed to in writing, software
-% distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-% WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-% License for the specific language governing permissions and limitations under
-% the License.
-
--define(LOCAL_DOC_PREFIX, "_local/").
--define(DESIGN_DOC_PREFIX0, "_design").
--define(DESIGN_DOC_PREFIX, "_design/").
--define(DEFAULT_COMPRESSION, snappy).
-
--define(MIN_STR, <<"">>).
--define(MAX_STR, <<255>>). % illegal utf string
-
--define(JSON_ENCODE(V), ejson:encode(V)).
--define(JSON_DECODE(V), ejson:decode(V)).
-
--define(b2l(V), binary_to_list(V)).
--define(l2b(V), list_to_binary(V)).
--define(i2b(V), couch_util:integer_to_boolean(V)).
--define(b2i(V), couch_util:boolean_to_integer(V)).
--define(term_to_bin(T), term_to_binary(T, [{minor_version, 1}])).
--define(term_size(T),
-    try
-        erlang:external_size(T)
-    catch _:_ ->
-        byte_size(?term_to_bin(T))
-    end).
-
--define(DEFAULT_ATTACHMENT_CONTENT_TYPE, <<"application/octet-stream">>).
-
--define(LOG_DEBUG(Format, Args), twig:log(debug, Format, Args)).
--define(LOG_INFO(Format, Args), twig:log(info, Format, Args)).
--define(LOG_WARN(Format, Args), twig:log(warn, Format, Args)).
--define(LOG_ERROR(Format, Args), twig:log(error, Format, Args)).
-
-% Tree::term() is really a tree(), but we don't want to require R13B04 yet
--type branch() :: {Key::term(), Value::term(), Tree::term()}.
--type path() :: {Start::pos_integer(), branch()}.
--type tree() :: [branch()]. % sorted by key
-
--record(rev_info,
-    {
-    rev,
-    seq = 0,
-    deleted = false,
-    body_sp = nil % stream pointer
-    }).
-
--record(doc_info,
-    {
-    id = <<"">>,
-    high_seq = 0,
-    revs = [] % rev_info
-    }).
-
--record(full_doc_info,
-    {id = <<"">>,
-    update_seq = 0,
-    deleted = false,
-    rev_tree = [],
-    leafs_size = 0
-    }).
-
--record(httpd,
-    {mochi_req,
-    peer,
-    method,
-    requested_path_parts,
-    path_parts,
-    db_url_handlers,
-    user_ctx,
-    req_body = undefined,
-    design_url_handlers,
-    auth,
-    default_fun,
-    url_handlers
-    }).
-
-
--record(doc,
-    {
-    id = <<"">>,
-    revs = {0, []},
-
-    % the json body object.
-    body = {[]},
-
-    atts = [], % attachments
-
-    deleted = false,
-
-    % key/value tuple of meta information, provided when using special options:
-    % couch_db:open_doc(Db, Id, Options).
-    meta = []
-    }).
-
-
--record(att,
-    {
-    name,
-    type,
-    att_len,
-    disk_len, % length of the attachment in its identity form
-              % (that is, without a content encoding applied to it)
-              % differs from att_len when encoding /= identity
-    md5= <<>>,
-    revpos=0,
-    data,
-    encoding=identity % currently supported values are:
-                      %     identity, gzip
-                      % additional values to support in the future:
-                      %     deflate, compress
-    }).
-
-
--record(user_ctx,
-    {
-    name=null,
-    roles=[],
-    handler
-    }).
-
-% This should be updated anytime a header change happens that requires more
-% than filling in new defaults.
-%
-% As long the changes are limited to new header fields (with inline
-% defaults) added to the end of the record, then there is no need to increment
-% the disk revision number.
-%
-% if the disk revision is incremented, then new upgrade logic will need to be
-% added to couch_db_updater:init_db.
-
--define(LATEST_DISK_VERSION, 6).
-
--record(db_header,
-    {disk_version = ?LATEST_DISK_VERSION,
-     update_seq = 0,
-     unused = 0,
-     id_tree_state = nil,
-     seq_tree_state = nil,
-     local_tree_state = nil,
-     purge_seq = 0,
-     purged_docs = nil,
-     security_ptr = nil,
-     revs_limit = 1000
-    }).
-
--record(db,
-    {main_pid = nil,
-    compactor_pid = nil,
-    instance_start_time, % number of microsecs since jan 1 1970 as a binary string
-    fd,
-    fd_monitor,
-    header = #db_header{},
-    committed_update_seq,
-    id_tree,
-    seq_tree,
-    local_tree,
-    update_seq,
-    name,
-    filepath,
-    validate_doc_funs = undefined,
-    security = [],
-    security_ptr = nil,
-    user_ctx = #user_ctx{},
-    waiting_delayed_commit = nil,
-    revs_limit = 1000,
-    fsync_options = [],
-    options = [],
-    compression,
-    before_doc_update = nil, % nil | fun(Doc, Db) -> NewDoc
-    after_doc_read = nil     % nil | fun(Doc, Db) -> NewDoc
-    }).
-
--record(view_fold_helper_funs, {
-    reduce_count,
-    passed_end,
-    start_response,
-    send_row
-}).
-
--record(reduce_fold_helper_funs, {
-    start_response,
-    send_row
-}).
-
--record(extern_resp_args, {
-    code = 200,
-    stop = false,
-    data = <<>>,
-    ctype = "application/json",
-    headers = [],
-    json = nil
-}).
-
--record(index_header,
-    {seq=0,
-    purge_seq=0,
-    id_btree_state=nil,
-    view_states=nil
-    }).
-
-% small value used in revision trees to indicate the revision isn't stored
--define(REV_MISSING, []).
-
--record(changes_args, {
-    feed = "normal",
-    dir = fwd,
-    since = 0,
-    limit = 1000000000000000,
-    style = main_only,
-    heartbeat,
-    timeout,
-    filter = "",
-    filter_fun,
-    filter_args = [],
-    include_docs = false,
-    conflicts = false,
-    db_open_options = []
-}).
-
--record(btree, {
-    fd,
-    root,
-    extract_kv,
-    assemble_kv,
-    less,
-    reduce = nil,
-    compression = ?DEFAULT_COMPRESSION
-}).
-
--record(proc, {
-    pid,
-    lang,
-    client = nil,
-    ddoc_keys = [],
-    prompt_fun,
-    prompt_many_fun,
-    set_timeout_fun,
-    stop_fun
-}).
-
--record(leaf,  {
-    deleted,
-    ptr,
-    seq,
-    size = nil
-}).
-

http://git-wip-us.apache.org/repos/asf/couchdb/blob/ed98610c/src/couch/priv/couch_ejson_compare/couch_ejson_compare.c
----------------------------------------------------------------------
diff --git a/src/couch/priv/couch_ejson_compare/couch_ejson_compare.c b/src/couch/priv/couch_ejson_compare/couch_ejson_compare.c
deleted file mode 100644
index df68c2a..0000000
--- a/src/couch/priv/couch_ejson_compare/couch_ejson_compare.c
+++ /dev/null
@@ -1,457 +0,0 @@
-/**
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-#include <stdio.h>
-#include <assert.h>
-#include "erl_nif_compat.h"
-#include "unicode/ucol.h"
-#include "unicode/ucasemap.h"
-
-#define MAX_DEPTH 10
-
-#if (ERL_NIF_MAJOR_VERSION > 2) || \
-    (ERL_NIF_MAJOR_VERSION == 2 && ERL_NIF_MINOR_VERSION >= 3)
-/* OTP R15B or higher */
-#define term_is_number(env, t) enif_is_number(env, t)
-#else
-#define term_is_number(env, t)  \
-    (!enif_is_binary(env, t) && \
-     !enif_is_list(env, t) &&   \
-     !enif_is_tuple(env, t))
-#endif
-
-static ERL_NIF_TERM ATOM_TRUE;
-static ERL_NIF_TERM ATOM_FALSE;
-static ERL_NIF_TERM ATOM_NULL;
-
-typedef struct {
-    ErlNifEnv* env;
-    int error;
-    UCollator* coll;
-} ctx_t;
-
-static UCollator** collators = NULL;
-static int collStackTop = 0;
-static int numCollators = 0;
-static ErlNifMutex* collMutex = NULL;
-
-static ERL_NIF_TERM less_json_nif(ErlNifEnv*, int, const ERL_NIF_TERM []);
-static int on_load(ErlNifEnv*, void**, ERL_NIF_TERM);
-static void on_unload(ErlNifEnv*, void*);
-static __inline int less_json(int, ctx_t*, ERL_NIF_TERM, ERL_NIF_TERM);
-static __inline int atom_sort_order(ErlNifEnv*, ERL_NIF_TERM);
-static __inline int compare_strings(ctx_t*, ErlNifBinary, ErlNifBinary);
-static __inline int compare_lists(int, ctx_t*, ERL_NIF_TERM, ERL_NIF_TERM);
-static __inline int compare_props(int, ctx_t*, ERL_NIF_TERM, ERL_NIF_TERM);
-static __inline void reserve_coll(ctx_t*);
-static __inline void release_coll(ctx_t*);
-
-
-void
-reserve_coll(ctx_t *ctx)
-{
-    if (ctx->coll == NULL) {
-        enif_mutex_lock(collMutex);
-        assert(collStackTop < numCollators);
-        ctx->coll = collators[collStackTop];
-        collStackTop += 1;
-        enif_mutex_unlock(collMutex);
-    }
-}
-
-
-void
-release_coll(ctx_t *ctx)
-{
-    if (ctx->coll != NULL) {
-        enif_mutex_lock(collMutex);
-        collStackTop -= 1;
-        assert(collStackTop >= 0);
-        enif_mutex_unlock(collMutex);
-    }
-}
-
-
-
-ERL_NIF_TERM
-less_json_nif(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
-{
-    ctx_t ctx;
-    int result;
-
-    ctx.env = env;
-    ctx.error = 0;
-    ctx.coll = NULL;
-
-    result = less_json(1, &ctx, argv[0], argv[1]);
-    release_coll(&ctx);
-
-    /*
-     * There are 2 possible failure reasons:
-     *
-     * 1) We got an invalid EJSON operand;
-     * 2) The EJSON structures are too deep - to avoid allocating too
-     *    many C stack frames (because less_json is a recursive function),
-     *    and running out of memory, we throw a badarg exception to Erlang
-     *    and do the comparison in Erlang land. In practice, views keys are
-     *    EJSON structures with very little nesting.
-     */
-    return ctx.error ? enif_make_badarg(env) : enif_make_int(env, result);
-}
-
-
-int
-less_json(int depth, ctx_t* ctx, ERL_NIF_TERM a, ERL_NIF_TERM b)
-{
-    int aIsAtom, bIsAtom;
-    int aIsBin, bIsBin;
-    int aIsNumber, bIsNumber;
-    int aIsList, bIsList;
-    int aArity, bArity;
-    const ERL_NIF_TERM *aProps, *bProps;
-
-    /*
-     * Avoid too much recursion. Normally there isn't more than a few levels
-     * of recursion, as in practice view keys do not go beyond 1 to 3 levels
-     * of nesting. In case of too much recursion, signal it to the Erlang land
-     * via an exception and do the EJSON comparison in Erlang land.
-     */
-    if (depth > MAX_DEPTH) {
-        ctx->error = 1;
-        return 0;
-    }
-
-    aIsAtom = enif_is_atom(ctx->env, a);
-    bIsAtom = enif_is_atom(ctx->env, b);
-
-    if (aIsAtom) {
-        if (bIsAtom) {
-            int aSortOrd, bSortOrd;
-
-            if ((aSortOrd = atom_sort_order(ctx->env, a)) == -1) {
-                ctx->error = 1;
-                return 0;
-            }
-
-            if ((bSortOrd = atom_sort_order(ctx->env, b)) == -1) {
-                ctx->error = 1;
-                return 0;
-            }
-
-            return aSortOrd - bSortOrd;
-        }
-
-        return -1;
-    }
-
-    if (bIsAtom) {
-        return 1;
-    }
-
-    aIsNumber = term_is_number(ctx->env, a);
-    bIsNumber = term_is_number(ctx->env, b);
-
-    if (aIsNumber) {
-        if (bIsNumber) {
-            return enif_compare_compat(ctx->env, a, b);
-        }
-
-        return -1;
-    }
-
-    if (bIsNumber) {
-        return 1;
-    }
-
-    aIsBin = enif_is_binary(ctx->env, a);
-    bIsBin = enif_is_binary(ctx->env, b);
-
-    if (aIsBin) {
-        if (bIsBin) {
-            ErlNifBinary binA, binB;
-
-            enif_inspect_binary(ctx->env, a, &binA);
-            enif_inspect_binary(ctx->env, b, &binB);
-
-            return compare_strings(ctx, binA, binB);
-        }
-
-        return -1;
-    }
-
-    if (bIsBin) {
-        return 1;
-    }
-
-    aIsList = enif_is_list(ctx->env, a);
-    bIsList = enif_is_list(ctx->env, b);
-
-    if (aIsList) {
-        if (bIsList) {
-            return compare_lists(depth, ctx, a, b);
-        }
-
-        return -1;
-    }
-
-    if (bIsList) {
-        return 1;
-    }
-
-    if (!enif_get_tuple(ctx->env, a, &aArity, &aProps)) {
-        ctx->error = 1;
-        return 0;
-    }
-    if ((aArity != 1) || !enif_is_list(ctx->env, aProps[0])) {
-        ctx->error = 1;
-        return 0;
-    }
-
-    if (!enif_get_tuple(ctx->env, b, &bArity, &bProps)) {
-        ctx->error = 1;
-        return 0;
-    }
-    if ((bArity != 1) || !enif_is_list(ctx->env, bProps[0])) {
-        ctx->error = 1;
-        return 0;
-    }
-
-    return compare_props(depth, ctx, aProps[0], bProps[0]);
-}
-
-
-int
-atom_sort_order(ErlNifEnv* env, ERL_NIF_TERM a)
-{
-    if (enif_compare_compat(env, a, ATOM_NULL) == 0) {
-        return 1;
-    } else if (enif_compare_compat(env, a, ATOM_FALSE) == 0) {
-        return 2;
-    } else if (enif_compare_compat(env, a, ATOM_TRUE) == 0) {
-        return 3;
-    }
-
-    return -1;
-}
-
-
-int
-compare_lists(int depth, ctx_t* ctx, ERL_NIF_TERM a, ERL_NIF_TERM b)
-{
-    ERL_NIF_TERM headA, tailA;
-    ERL_NIF_TERM headB, tailB;
-    int aIsEmpty, bIsEmpty;
-    int result;
-
-    while (1) {
-        aIsEmpty = !enif_get_list_cell(ctx->env, a, &headA, &tailA);
-        bIsEmpty = !enif_get_list_cell(ctx->env, b, &headB, &tailB);
-
-        if (aIsEmpty) {
-            if (bIsEmpty) {
-                return 0;
-            }
-            return -1;
-        }
-
-        if (bIsEmpty) {
-            return 1;
-        }
-
-        result = less_json(depth + 1, ctx, headA, headB);
-
-        if (ctx->error || result != 0) {
-            return result;
-        }
-
-        a = tailA;
-        b = tailB;
-    }
-
-    return result;
-}
-
-
-int
-compare_props(int depth, ctx_t* ctx, ERL_NIF_TERM a, ERL_NIF_TERM b)
-{
-    ERL_NIF_TERM headA, tailA;
-    ERL_NIF_TERM headB, tailB;
-    int aArity, bArity;
-    const ERL_NIF_TERM *aKV, *bKV;
-    ErlNifBinary keyA, keyB;
-    int aIsEmpty, bIsEmpty;
-    int keyCompResult, valueCompResult;
-
-    while (1) {
-        aIsEmpty = !enif_get_list_cell(ctx->env, a, &headA, &tailA);
-        bIsEmpty = !enif_get_list_cell(ctx->env, b, &headB, &tailB);
-
-        if (aIsEmpty) {
-            if (bIsEmpty) {
-                return 0;
-            }
-            return -1;
-        }
-
-        if (bIsEmpty) {
-            return 1;
-        }
-
-        if (!enif_get_tuple(ctx->env, headA, &aArity, &aKV)) {
-            ctx->error = 1;
-            return 0;
-        }
-        if ((aArity != 2) || !enif_inspect_binary(ctx->env, aKV[0], &keyA)) {
-            ctx->error = 1;
-            return 0;
-        }
-
-        if (!enif_get_tuple(ctx->env, headB, &bArity, &bKV)) {
-            ctx->error = 1;
-            return 0;
-        }
-        if ((bArity != 2) || !enif_inspect_binary(ctx->env, bKV[0], &keyB)) {
-            ctx->error = 1;
-            return 0;
-        }
-
-        keyCompResult = compare_strings(ctx, keyA, keyB);
-
-        if (ctx->error || keyCompResult != 0) {
-            return keyCompResult;
-        }
-
-        valueCompResult = less_json(depth + 1, ctx, aKV[1], bKV[1]);
-
-        if (ctx->error || valueCompResult != 0) {
-            return valueCompResult;
-        }
-
-        a = tailA;
-        b = tailB;
-    }
-
-    return 0;
-}
-
-
-int
-compare_strings(ctx_t* ctx, ErlNifBinary a, ErlNifBinary b)
-{
-    UErrorCode status = U_ZERO_ERROR;
-    UCharIterator iterA, iterB;
-    int result;
-
-    uiter_setUTF8(&iterA, (const char *) a.data, (uint32_t) a.size);
-    uiter_setUTF8(&iterB, (const char *) b.data, (uint32_t) b.size);
-
-    reserve_coll(ctx);
-    result = ucol_strcollIter(ctx->coll, &iterA, &iterB, &status);
-
-    if (U_FAILURE(status)) {
-        ctx->error = 1;
-        return 0;
-    }
-
-    /* ucol_strcollIter returns 0, -1 or 1
-     * (see type UCollationResult in unicode/ucol.h) */
-
-    return result;
-}
-
-
-int
-on_load(ErlNifEnv* env, void** priv, ERL_NIF_TERM info)
-{
-    UErrorCode status = U_ZERO_ERROR;
-    int i, j;
-
-    if (!enif_get_int(env, info, &numCollators)) {
-        return 1;
-    }
-
-    if (numCollators < 1) {
-        return 2;
-    }
-
-    collMutex = enif_mutex_create("coll_mutex");
-
-    if (collMutex == NULL) {
-        return 3;
-    }
-
-    collators = enif_alloc(sizeof(UCollator*) * numCollators);
-
-    if (collators == NULL) {
-        enif_mutex_destroy(collMutex);
-        return 4;
-    }
-
-    for (i = 0; i < numCollators; i++) {
-        collators[i] = ucol_open("", &status);
-
-        if (U_FAILURE(status)) {
-            for (j = 0; j < i; j++) {
-                ucol_close(collators[j]);
-            }
-
-            enif_free(collators);
-            enif_mutex_destroy(collMutex);
-
-            return 5;
-        }
-    }
-
-    ATOM_TRUE = enif_make_atom(env, "true");
-    ATOM_FALSE = enif_make_atom(env, "false");
-    ATOM_NULL = enif_make_atom(env, "null");
-
-    return 0;
-}
-
-
-void
-on_unload(ErlNifEnv* env, void* priv_data)
-{
-    if (collators != NULL) {
-        int i;
-
-        for (i = 0; i < numCollators; i++) {
-            ucol_close(collators[i]);
-        }
-
-        enif_free(collators);
-    }
-
-    if (collMutex != NULL) {
-        enif_mutex_destroy(collMutex);
-    }
-}
-
-
-static ErlNifFunc nif_functions[] = {
-    {"less_nif", 2, less_json_nif}
-};
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-ERL_NIF_INIT(couch_ejson_compare, nif_functions, &on_load, NULL, NULL, &on_unload);
-
-#ifdef __cplusplus
-}
-#endif

http://git-wip-us.apache.org/repos/asf/couchdb/blob/ed98610c/src/couch/priv/couch_ejson_compare/erl_nif_compat.h
----------------------------------------------------------------------
diff --git a/src/couch/priv/couch_ejson_compare/erl_nif_compat.h b/src/couch/priv/couch_ejson_compare/erl_nif_compat.h
deleted file mode 100644
index 0aa3ae6..0000000
--- a/src/couch/priv/couch_ejson_compare/erl_nif_compat.h
+++ /dev/null
@@ -1,128 +0,0 @@
-/* Copyright (c) 2010-2011 Basho Technologies, Inc.
- * With some minor modifications for Apache CouchDB.
- *
- * This file is provided to you under the Apache License,
- * Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License.  You may obtain
- * a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
-*/
-
-#ifndef ERL_NIF_COMPAT_H_
-#define ERL_NIF_COMPAT_H_
-
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
-#include "erl_nif.h"
-
-
-#if ERL_NIF_MAJOR_VERSION == 0 && ERL_NIF_MINOR_VERSION == 1
-#define OTP_R13B03
-#elif ERL_NIF_MAJOR_VERSION == 1 && ERL_NIF_MINOR_VERSION == 0
-#define OTP_R13B04
-#elif ERL_NIF_MAJOR_VERSION == 2 && ERL_NIF_MINOR_VERSION == 0
-#define OTP_R14A
-#define OTP_R14B
-#define OTP_R14B01
-#elif ERL_NIF_MAJOR_VERSION == 2 && ERL_NIF_MINOR_VERSION == 1
-#define OTP_R14B02
-#elif ERL_NIF_MAJOR_VERSION == 2 && ERL_NIF_MINOR_VERSION == 2
-#define OTP_R14B03
-#endif
-
-
-#ifdef OTP_R13B03
-
-#define enif_open_resource_type_compat enif_open_resource_type
-#define enif_alloc_resource_compat enif_alloc_resource
-#define enif_release_resource_compat enif_release_resource
-#define enif_alloc_binary_compat enif_alloc_binary
-#define enif_alloc_compat enif_alloc
-#define enif_release_binary_compat enif_release_binary
-#define enif_free_compat enif_free
-#define enif_get_atom_compat enif_get_atom
-#define enif_priv_data_compat enif_get_data
-#define enif_make_uint_compat enif_make_ulong
-
-#define enif_make_string_compat(E, B, Enc) \
-    enif_make_string(E, B)
-
-#define enif_compare_compat enif_compare
-
-#endif /* R13B03 */
-
-
-#ifdef OTP_R13B04
-
-#define enif_open_resource_type_compat enif_open_resource_type
-#define enif_alloc_resource_compat enif_alloc_resource
-#define enif_release_resource_compat enif_release_resource
-#define enif_alloc_binary_compat enif_alloc_binary
-#define enif_realloc_binary_compat enif_realloc_binary
-#define enif_release_binary_compat enif_release_binary
-#define enif_alloc_compat enif_alloc
-#define enif_free_compat enif_free
-#define enif_get_atom_compat enif_get_atom
-#define enif_priv_data_compat enif_priv_data
-#define enif_make_string_compat enif_make_string
-#define enif_make_uint_compat enif_make_uint
-#define enif_compare_compat enif_compare
-
-#endif /* R13B04 */
-
-
-/* OTP R14 and future releases */
-#if !defined(OTP_R13B03) && !defined(OTP_R13B04)
-
-#define enif_open_resource_type_compat(E, N, D, F, T) \
-    enif_open_resource_type(E, NULL, N, D, F, T)
-
-#define enif_alloc_resource_compat(E, T, S) \
-    enif_alloc_resource(T, S)
-
-#define enif_release_resource_compat(E, H) \
-    enif_release_resource(H)
-
-#define enif_alloc_binary_compat(E, S, B) \
-    enif_alloc_binary(S, B)
-
-#define enif_realloc_binary_compat(E, S, B) \
-    enif_realloc_binary(S, B)
-
-#define enif_release_binary_compat(E, B) \
-    enif_release_binary(B)
-
-#define enif_alloc_compat(E, S) \
-    enif_alloc(S)
-
-#define enif_free_compat(E, P) \
-    enif_free(P)
-
-#define enif_get_atom_compat(E, T, B, S) \
-    enif_get_atom(E, T, B, S, ERL_NIF_LATIN1)
-
-#define enif_priv_data_compat enif_priv_data
-#define enif_make_string_compat enif_make_string
-#define enif_make_uint_compat enif_make_uint
-
-#define enif_compare_compat(E, A, B) \
-    enif_compare(A, B)
-
-#endif  /* R14 and future releases */
-
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-#endif /* ERL_NIF_COMPAT_H_ */

http://git-wip-us.apache.org/repos/asf/couchdb/blob/ed98610c/src/couch/priv/couch_js/help.h
----------------------------------------------------------------------
diff --git a/src/couch/priv/couch_js/help.h b/src/couch/priv/couch_js/help.h
deleted file mode 100644
index b31bb8c..0000000
--- a/src/couch/priv/couch_js/help.h
+++ /dev/null
@@ -1,82 +0,0 @@
-// Licensed under the Apache License, Version 2.0 (the "License"); you may not
-// use this file except in compliance with the License. You may obtain a copy of
-// the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-// License for the specific language governing permissions and limitations under
-// the License.
-
-#ifndef COUCHJS_HELP_H
-#define COUCHJS_HELP_H
-
-#include "config.h"
-
-static const char VERSION_TEMPLATE[] =
-    "%s - %s\n"
-    "\n"
-    "Licensed under the Apache License, Version 2.0 (the \"License\"); you may "
-        "not use\n"
-    "this file except in compliance with the License. You may obtain a copy of"
-        "the\n"
-    "License at\n"
-    "\n"
-    "  http://www.apache.org/licenses/LICENSE-2.0\n"
-    "\n"
-    "Unless required by applicable law or agreed to in writing, software "
-        "distributed\n"
-    "under the License is distributed on an \"AS IS\" BASIS, WITHOUT "
-        "WARRANTIES OR\n"
-    "CONDITIONS OF ANY KIND, either express or implied. See the License "
-        "for the\n"
-    "specific language governing permissions and limitations under the "
-        "License.\n";
-
-static const char USAGE_TEMPLATE[] =
-    "Usage: %s [FILE]\n"
-    "\n"
-    "The %s command runs the %s JavaScript interpreter.\n"
-    "\n"
-    "The exit status is 0 for success or 1 for failure.\n"
-    "\n"
-    "Options:\n"
-    "\n"
-    "  -h          display a short help message and exit\n"
-    "  -V          display version information and exit\n"
-    "  -H          enable %s cURL bindings (only avaiable\n"
-    "              if package was built with cURL available)\n"
-    "  -S SIZE     specify that the interpreter should set the\n"
-    "              stack quota for JS contexts to SIZE bytes\n"
-    "  -u FILE     path to a .uri file containing the address\n"
-    "              (or addresses) of one or more servers\n"
-    "\n"
-    "Report bugs at <%s>.\n";
-
-#define BASENAME COUCHJS_NAME
-
-#define couch_version(basename)  \
-    fprintf(                     \
-            stdout,              \
-            VERSION_TEMPLATE,    \
-            basename,            \
-            PACKAGE_STRING)
-
-#define DISPLAY_VERSION couch_version(BASENAME)
-
-
-#define couch_usage(basename) \
-    fprintf(                                    \
-            stdout,                             \
-            USAGE_TEMPLATE,                     \
-            basename,                           \
-            basename,                           \
-            PACKAGE_NAME,                       \
-            basename,                           \
-            PACKAGE_BUGREPORT)
-
-#define DISPLAY_USAGE couch_usage(BASENAME)
-
-#endif // Included help.h

http://git-wip-us.apache.org/repos/asf/couchdb/blob/ed98610c/src/couch/priv/couch_js/http.c
----------------------------------------------------------------------
diff --git a/src/couch/priv/couch_js/http.c b/src/couch/priv/couch_js/http.c
deleted file mode 100644
index c66b5da..0000000
--- a/src/couch/priv/couch_js/http.c
+++ /dev/null
@@ -1,698 +0,0 @@
-// Licensed under the Apache License, Version 2.0 (the "License"); you may not
-// use this file except in compliance with the License. You may obtain a copy of
-// the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-// License for the specific language governing permissions and limitations under
-// the License.
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <jsapi.h>
-#include "config.h"
-#include "utf8.h"
-#include "util.h"
-
-// Soft dependency on cURL bindings because they're
-// only used when running the JS tests from the
-// command line which is rare.
-#ifndef HAVE_CURL
-
-void
-http_check_enabled()
-{
-    fprintf(stderr, "HTTP API was disabled at compile time.\n");
-    exit(3);
-}
-
-
-JSBool
-http_ctor(JSContext* cx, JSObject* req)
-{
-    return JS_FALSE;
-}
-
-
-JSBool
-http_dtor(JSContext* cx, JSObject* req)
-{
-    return JS_FALSE;
-}
-
-
-JSBool
-http_open(JSContext* cx, JSObject* req, jsval mth, jsval url, jsval snc)
-{
-    return JS_FALSE;
-}
-
-
-JSBool
-http_set_hdr(JSContext* cx, JSObject* req, jsval name, jsval val)
-{
-    return JS_FALSE;
-}
-
-
-JSBool
-http_send(JSContext* cx, JSObject* req, jsval body)
-{
-    return JS_FALSE;
-}
-
-
-int
-http_status(JSContext* cx, JSObject* req, jsval body)
-{
-    return -1;
-}
-
-JSBool
-http_uri(JSContext* cx, JSObject* req, couch_args* args, jsval* uri_val)
-{
-    return JS_FALSE;
-}
-
-
-#else
-#include <curl/curl.h>
-#include <unistd.h>
-
-
-void
-http_check_enabled()
-{
-    return;
-}
-
-
-// Map some of the string function names to things which exist on Windows
-#ifdef XP_WIN
-#define strcasecmp _strcmpi
-#define strncasecmp _strnicmp
-#define snprintf _snprintf
-#endif
-
-
-typedef struct curl_slist CurlHeaders;
-
-
-typedef struct {
-    int             method;
-    char*           url;
-    CurlHeaders*    req_headers;
-    jsint           last_status;
-} HTTPData;
-
-
-char* METHODS[] = {"GET", "HEAD", "POST", "PUT", "DELETE", "COPY", "OPTIONS", NULL};
-
-
-#define GET     0
-#define HEAD    1
-#define POST    2
-#define PUT     3
-#define DELETE  4
-#define COPY    5
-#define OPTIONS 6
-
-
-static JSBool
-go(JSContext* cx, JSObject* obj, HTTPData* http, char* body, size_t blen);
-
-
-static JSString*
-str_from_binary(JSContext* cx, char* data, size_t length);
-
-
-JSBool
-http_ctor(JSContext* cx, JSObject* req)
-{
-    HTTPData* http = NULL;
-    JSBool ret = JS_FALSE;
-
-    http = (HTTPData*) malloc(sizeof(HTTPData));
-    if(!http)
-    {
-        JS_ReportError(cx, "Failed to create CouchHTTP instance.");
-        goto error;
-    }
-
-    http->method = -1;
-    http->url = NULL;
-    http->req_headers = NULL;
-    http->last_status = -1;
-
-    if(!JS_SetPrivate(cx, req, http))
-    {
-        JS_ReportError(cx, "Failed to set private CouchHTTP data.");
-        goto error;
-    }
-
-    ret = JS_TRUE;
-    goto success;
-
-error:
-    if(http) free(http);
-
-success:
-    return ret;
-}
-
-
-void
-http_dtor(JSContext* cx, JSObject* obj)
-{
-    HTTPData* http = (HTTPData*) JS_GetPrivate(cx, obj);
-    if(http) { 
-        if(http->url) free(http->url);
-        if(http->req_headers) curl_slist_free_all(http->req_headers);
-        free(http);
-    }
-}
-
-
-JSBool
-http_open(JSContext* cx, JSObject* req, jsval mth, jsval url, jsval snc)
-{
-    HTTPData* http = (HTTPData*) JS_GetPrivate(cx, req);
-    char* method = NULL;
-    int methid;
-    JSBool ret = JS_FALSE;
-
-    if(!http) {
-        JS_ReportError(cx, "Invalid CouchHTTP instance.");
-        goto done;
-    }
-
-    if(JSVAL_IS_VOID(mth)) {
-        JS_ReportError(cx, "You must specify a method.");
-        goto done;
-    }
-
-    method = enc_string(cx, mth, NULL);
-    if(!method) {
-        JS_ReportError(cx, "Failed to encode method.");
-        goto done;
-    }
-    
-    for(methid = 0; METHODS[methid] != NULL; methid++) {
-        if(strcasecmp(METHODS[methid], method) == 0) break;
-    }
-    
-    if(methid > OPTIONS) {
-        JS_ReportError(cx, "Invalid method specified.");
-        goto done;
-    }
-
-    http->method = methid;
-
-    if(JSVAL_IS_VOID(url)) {
-        JS_ReportError(cx, "You must specify a URL.");
-        goto done;
-    }
-
-    if(http->url != NULL) {
-        free(http->url);
-        http->url = NULL;
-    }
-
-    http->url = enc_string(cx, url, NULL);
-    if(http->url == NULL) {
-        JS_ReportError(cx, "Failed to encode URL.");
-        goto done;
-    }
-    
-    if(JSVAL_IS_BOOLEAN(snc) && JSVAL_TO_BOOLEAN(snc)) {
-        JS_ReportError(cx, "Synchronous flag must be false.");
-        goto done;
-    }
-    
-    if(http->req_headers) {
-        curl_slist_free_all(http->req_headers);
-        http->req_headers = NULL;
-    }
-    
-    // Disable Expect: 100-continue
-    http->req_headers = curl_slist_append(http->req_headers, "Expect:");
-
-    ret = JS_TRUE;
-
-done:
-    if(method) free(method);
-    return ret;
-}
-
-
-JSBool
-http_set_hdr(JSContext* cx, JSObject* req, jsval name, jsval val)
-{
-    HTTPData* http = (HTTPData*) JS_GetPrivate(cx, req);
-    char* keystr = NULL;
-    char* valstr = NULL;
-    char* hdrbuf = NULL;
-    size_t hdrlen = -1;
-    JSBool ret = JS_FALSE;
-
-    if(!http) {
-        JS_ReportError(cx, "Invalid CouchHTTP instance.");
-        goto done;
-    }
-
-    if(JSVAL_IS_VOID(name))
-    {
-        JS_ReportError(cx, "You must speciy a header name.");
-        goto done;
-    }
-
-    keystr = enc_string(cx, name, NULL);
-    if(!keystr)
-    {
-        JS_ReportError(cx, "Failed to encode header name.");
-        goto done;
-    }
-    
-    if(JSVAL_IS_VOID(val))
-    {
-        JS_ReportError(cx, "You must specify a header value.");
-        goto done;
-    }
-    
-    valstr = enc_string(cx, val, NULL);
-    if(!valstr)
-    {
-        JS_ReportError(cx, "Failed to encode header value.");
-        goto done;
-    }
-    
-    hdrlen = strlen(keystr) + strlen(valstr) + 3;
-    hdrbuf = (char*) malloc(hdrlen * sizeof(char));
-    if(!hdrbuf) {
-        JS_ReportError(cx, "Failed to allocate header buffer.");
-        goto done;
-    }
-    
-    snprintf(hdrbuf, hdrlen, "%s: %s", keystr, valstr);
-    http->req_headers = curl_slist_append(http->req_headers, hdrbuf);
-
-    ret = JS_TRUE;
-
-done:
-    if(keystr) free(keystr);
-    if(valstr) free(valstr);
-    if(hdrbuf) free(hdrbuf);
-    return ret;
-}
-
-JSBool
-http_send(JSContext* cx, JSObject* req, jsval body)
-{
-    HTTPData* http = (HTTPData*) JS_GetPrivate(cx, req);
-    char* bodystr = NULL;
-    size_t bodylen = 0;
-    JSBool ret = JS_FALSE;
-    
-    if(!http) {
-        JS_ReportError(cx, "Invalid CouchHTTP instance.");
-        goto done;
-    }
-
-    if(!JSVAL_IS_VOID(body)) {
-        bodystr = enc_string(cx, body, &bodylen);
-        if(!bodystr) {
-            JS_ReportError(cx, "Failed to encode body.");
-            goto done;
-        }
-    }
-
-    ret = go(cx, req, http, bodystr, bodylen);
-
-done:
-    if(bodystr) free(bodystr);
-    return ret;
-}
-
-int
-http_status(JSContext* cx, JSObject* req)
-{
-    HTTPData* http = (HTTPData*) JS_GetPrivate(cx, req);
-    
-    if(!http) {
-        JS_ReportError(cx, "Invalid CouchHTTP instance.");
-        return JS_FALSE;
-    }
-
-    return http->last_status;
-}
-
-JSBool
-http_uri(JSContext* cx, JSObject* req, couch_args* args, jsval* uri_val)
-{
-    FILE* uri_fp = NULL;
-    JSString* uri_str;
-
-    // Default is http://localhost:5984/ when no uri file is specified
-    if (!args->uri_file) {
-        uri_str = JS_InternString(cx, "http://localhost:5984/");
-        *uri_val = STRING_TO_JSVAL(uri_str);
-        return JS_TRUE;
-    }
-
-    // Else check to see if the base url is cached in a reserved slot
-    if (JS_GetReservedSlot(cx, req, 0, uri_val) && !JSVAL_IS_VOID(*uri_val)) {
-        return JS_TRUE;
-    }
-
-    // Read the first line of the couch.uri file.
-    if(!((uri_fp = fopen(args->uri_file, "r")) &&
-         (uri_str = couch_readline(cx, uri_fp)))) {
-        JS_ReportError(cx, "Failed to read couch.uri file.");
-        goto error;
-    }
-
-    fclose(uri_fp);
-    *uri_val = STRING_TO_JSVAL(uri_str);
-    JS_SetReservedSlot(cx, req, 0, *uri_val);
-    return JS_TRUE;
-
-error:
-    if(uri_fp) fclose(uri_fp);
-    return JS_FALSE;
-}
-
-
-// Curl Helpers
-
-typedef struct {
-    HTTPData*   http;
-    JSContext*  cx;
-    JSObject*   resp_headers;
-    char*       sendbuf;
-    size_t      sendlen;
-    size_t      sent;
-    int         sent_once;
-    char*       recvbuf;
-    size_t      recvlen;
-    size_t      read;
-} CurlState;
-
-/*
- * I really hate doing this but this doesn't have to be
- * uber awesome, it just has to work.
- */
-CURL*       HTTP_HANDLE = NULL;
-char        ERRBUF[CURL_ERROR_SIZE];
-
-static size_t send_body(void *ptr, size_t size, size_t nmem, void *data);
-static int seek_body(void *ptr, curl_off_t offset, int origin);
-static size_t recv_body(void *ptr, size_t size, size_t nmem, void *data);
-static size_t recv_header(void *ptr, size_t size, size_t nmem, void *data);
-
-static JSBool
-go(JSContext* cx, JSObject* obj, HTTPData* http, char* body, size_t bodylen)
-{
-    CurlState state;
-    char* referer;
-    JSString* jsbody;
-    JSBool ret = JS_FALSE;
-    jsval tmp;
-    
-    state.cx = cx;
-    state.http = http;
-    
-    state.sendbuf = body;
-    state.sendlen = bodylen;
-    state.sent = 0;
-    state.sent_once = 0;
-
-    state.recvbuf = NULL;
-    state.recvlen = 0;
-    state.read = 0;
-
-    if(HTTP_HANDLE == NULL) {
-        HTTP_HANDLE = curl_easy_init();
-        curl_easy_setopt(HTTP_HANDLE, CURLOPT_READFUNCTION, send_body);
-        curl_easy_setopt(HTTP_HANDLE, CURLOPT_SEEKFUNCTION,
-                                        (curl_seek_callback) seek_body);
-        curl_easy_setopt(HTTP_HANDLE, CURLOPT_HEADERFUNCTION, recv_header);
-        curl_easy_setopt(HTTP_HANDLE, CURLOPT_WRITEFUNCTION, recv_body);
-        curl_easy_setopt(HTTP_HANDLE, CURLOPT_NOPROGRESS, 1);
-        curl_easy_setopt(HTTP_HANDLE, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
-        curl_easy_setopt(HTTP_HANDLE, CURLOPT_ERRORBUFFER, ERRBUF);
-        curl_easy_setopt(HTTP_HANDLE, CURLOPT_COOKIEFILE, "");
-        curl_easy_setopt(HTTP_HANDLE, CURLOPT_USERAGENT,
-                                            "CouchHTTP Client - Relax");
-    }
-    
-    if(!HTTP_HANDLE) {
-        JS_ReportError(cx, "Failed to initialize cURL handle.");
-        goto done;
-    }
-
-    if(!JS_GetReservedSlot(cx, obj, 0, &tmp)) {
-      JS_ReportError(cx, "Failed to readreserved slot.");
-      goto done;
-    }
-
-    if(!(referer = enc_string(cx, tmp, NULL))) {
-      JS_ReportError(cx, "Failed to encode referer.");
-      goto done;
-    }
-    curl_easy_setopt(HTTP_HANDLE, CURLOPT_REFERER, referer);
-    free(referer);
-
-    if(http->method < 0 || http->method > OPTIONS) {
-        JS_ReportError(cx, "INTERNAL: Unknown method.");
-        goto done;
-    }
-
-    curl_easy_setopt(HTTP_HANDLE, CURLOPT_CUSTOMREQUEST, METHODS[http->method]);
-    curl_easy_setopt(HTTP_HANDLE, CURLOPT_NOBODY, 0);
-    curl_easy_setopt(HTTP_HANDLE, CURLOPT_FOLLOWLOCATION, 1);
-    curl_easy_setopt(HTTP_HANDLE, CURLOPT_UPLOAD, 0);
-    
-    if(http->method == HEAD) {
-        curl_easy_setopt(HTTP_HANDLE, CURLOPT_NOBODY, 1);
-        curl_easy_setopt(HTTP_HANDLE, CURLOPT_FOLLOWLOCATION, 0);
-    } else if(http->method == POST || http->method == PUT) {
-        curl_easy_setopt(HTTP_HANDLE, CURLOPT_UPLOAD, 1);
-        curl_easy_setopt(HTTP_HANDLE, CURLOPT_FOLLOWLOCATION, 0);
-    }
-    
-    if(body && bodylen) {
-        curl_easy_setopt(HTTP_HANDLE, CURLOPT_INFILESIZE, bodylen);        
-    } else {
-        curl_easy_setopt(HTTP_HANDLE, CURLOPT_INFILESIZE, 0);
-    }
-
-    // curl_easy_setopt(HTTP_HANDLE, CURLOPT_VERBOSE, 1);
-
-    curl_easy_setopt(HTTP_HANDLE, CURLOPT_URL, http->url);
-    curl_easy_setopt(HTTP_HANDLE, CURLOPT_HTTPHEADER, http->req_headers);
-    curl_easy_setopt(HTTP_HANDLE, CURLOPT_READDATA, &state);
-    curl_easy_setopt(HTTP_HANDLE, CURLOPT_SEEKDATA, &state);
-    curl_easy_setopt(HTTP_HANDLE, CURLOPT_WRITEHEADER, &state);
-    curl_easy_setopt(HTTP_HANDLE, CURLOPT_WRITEDATA, &state);
-
-    if(curl_easy_perform(HTTP_HANDLE) != 0) {
-        JS_ReportError(cx, "Failed to execute HTTP request: %s", ERRBUF);
-        goto done;
-    }
-    
-    if(!state.resp_headers) {
-        JS_ReportError(cx, "Failed to recieve HTTP headers.");
-        goto done;
-    }
-
-    tmp = OBJECT_TO_JSVAL(state.resp_headers);
-    if(!JS_DefineProperty(
-        cx, obj,
-        "_headers",
-        tmp,
-        NULL, NULL,
-        JSPROP_READONLY
-    )) {
-        JS_ReportError(cx, "INTERNAL: Failed to set response headers.");
-        goto done;
-    }
-    
-    if(state.recvbuf) {
-        state.recvbuf[state.read] = '\0';
-        jsbody = dec_string(cx, state.recvbuf, state.read+1);
-        if(!jsbody) {
-            // If we can't decode the body as UTF-8 we forcefully
-            // convert it to a string by just forcing each byte
-            // to a jschar.
-            jsbody = str_from_binary(cx, state.recvbuf, state.read);
-            if(!jsbody) {
-                if(!JS_IsExceptionPending(cx)) {
-                    JS_ReportError(cx, "INTERNAL: Failed to decode body.");
-                }
-                goto done;
-            }
-        }
-        tmp = STRING_TO_JSVAL(jsbody);
-    } else {
-        tmp = JS_GetEmptyStringValue(cx);
-    }
-    
-    if(!JS_DefineProperty(
-        cx, obj,
-        "responseText",
-        tmp,
-        NULL, NULL,
-        JSPROP_READONLY
-    )) {
-        JS_ReportError(cx, "INTERNAL: Failed to set responseText.");
-        goto done;
-    }
-    
-    ret = JS_TRUE;
-
-done:
-    if(state.recvbuf) JS_free(cx, state.recvbuf);
-    return ret;
-}
-
-static size_t
-send_body(void *ptr, size_t size, size_t nmem, void *data)
-{
-    CurlState* state = (CurlState*) data;
-    size_t length = size * nmem;
-    size_t towrite = state->sendlen - state->sent;
-
-    // Assume this is cURL trying to resend a request that
-    // failed.
-    if(towrite == 0 && state->sent_once == 0) {
-        state->sent_once = 1;
-        return 0;
-    } else if(towrite == 0) {
-        state->sent = 0;
-        state->sent_once = 0;
-        towrite = state->sendlen;
-    }
-
-    if(length < towrite) towrite = length;
-
-    memcpy(ptr, state->sendbuf + state->sent, towrite);
-    state->sent += towrite;
-
-    return towrite;
-}
-
-static int
-seek_body(void* ptr, curl_off_t offset, int origin)
-{
-    CurlState* state = (CurlState*) ptr;
-    if(origin != SEEK_SET) return -1;
-
-    state->sent = (size_t) offset;
-    return (int) state->sent;
-}
-
-static size_t
-recv_header(void *ptr, size_t size, size_t nmem, void *data)
-{
-    CurlState* state = (CurlState*) data;
-    char code[4];
-    char* header = (char*) ptr;
-    size_t length = size * nmem;
-    JSString* hdr = NULL;
-    jsuint hdrlen;
-    jsval hdrval;
-    
-    if(length > 7 && strncasecmp(header, "HTTP/1.", 7) == 0) {
-        if(length < 12) {
-            return CURLE_WRITE_ERROR;
-        }
-
-        memcpy(code, header+9, 3*sizeof(char));
-        code[3] = '\0';
-        state->http->last_status = atoi(code);
-
-        state->resp_headers = JS_NewArrayObject(state->cx, 0, NULL);
-        if(!state->resp_headers) {
-            return CURLE_WRITE_ERROR;
-        }
-
-        return length;
-    }
-
-    // We get a notice at the \r\n\r\n after headers.
-    if(length <= 2) {
-        return length;
-    }
-
-    // Append the new header to our array.
-    hdr = dec_string(state->cx, header, length);
-    if(!hdr) {
-        return CURLE_WRITE_ERROR;
-    }
-
-    if(!JS_GetArrayLength(state->cx, state->resp_headers, &hdrlen)) {
-        return CURLE_WRITE_ERROR;
-    }
-
-    hdrval = STRING_TO_JSVAL(hdr);
-    if(!JS_SetElement(state->cx, state->resp_headers, hdrlen, &hdrval)) {
-        return CURLE_WRITE_ERROR;
-    }
-
-    return length;
-}
-
-static size_t
-recv_body(void *ptr, size_t size, size_t nmem, void *data)
-{
-    CurlState* state = (CurlState*) data;
-    size_t length = size * nmem;
-    char* tmp = NULL;
-    
-    if(!state->recvbuf) {
-        state->recvlen = 4096;
-        state->read = 0;
-        state->recvbuf = JS_malloc(state->cx, state->recvlen);
-    }
-    
-    if(!state->recvbuf) {
-        return CURLE_WRITE_ERROR;
-    }
-
-    // +1 so we can add '\0' back up in the go function.
-    while(length+1 > state->recvlen - state->read) state->recvlen *= 2;
-    tmp = JS_realloc(state->cx, state->recvbuf, state->recvlen);
-    if(!tmp) return CURLE_WRITE_ERROR;
-    state->recvbuf = tmp;
-   
-    memcpy(state->recvbuf + state->read, ptr, length);
-    state->read += length;
-    return length;
-}
-
-JSString*
-str_from_binary(JSContext* cx, char* data, size_t length)
-{
-    jschar* conv = (jschar*) JS_malloc(cx, length * sizeof(jschar));
-    JSString* ret = NULL;
-    size_t i;
-
-    if(!conv) return NULL;
-
-    for(i = 0; i < length; i++) {
-        conv[i] = (jschar) data[i];
-    }
-
-    ret = JS_NewUCString(cx, conv, length);
-    if(!ret) JS_free(cx, conv);
-
-    return ret;
-}
-
-#endif /* HAVE_CURL */

http://git-wip-us.apache.org/repos/asf/couchdb/blob/ed98610c/src/couch/priv/couch_js/http.h
----------------------------------------------------------------------
diff --git a/src/couch/priv/couch_js/http.h b/src/couch/priv/couch_js/http.h
deleted file mode 100644
index 63d45bd..0000000
--- a/src/couch/priv/couch_js/http.h
+++ /dev/null
@@ -1,27 +0,0 @@
-// Licensed under the Apache License, Version 2.0 (the "License"); you may not
-// use this file except in compliance with the License. You may obtain a copy of
-// the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-// License for the specific language governing permissions and limitations under
-// the License.
-
-#ifndef COUCH_JS_HTTP_H
-#define COUCH_JS_HTTP_H
-
-#include "util.h"
-
-void http_check_enabled();
-JSBool http_ctor(JSContext* cx, JSObject* req);
-void http_dtor(JSContext* cx, JSObject* req);
-JSBool http_open(JSContext* cx, JSObject* req, jsval mth, jsval url, jsval snc);
-JSBool http_set_hdr(JSContext* cx, JSObject* req, jsval name, jsval val);
-JSBool http_send(JSContext* cx, JSObject* req, jsval body);
-int http_status(JSContext* cx, JSObject* req);
-JSBool http_uri(JSContext* cx, JSObject *req, couch_args* args, jsval* uri);
-
-#endif

http://git-wip-us.apache.org/repos/asf/couchdb/blob/ed98610c/src/couch/priv/couch_js/main.c
----------------------------------------------------------------------
diff --git a/src/couch/priv/couch_js/main.c b/src/couch/priv/couch_js/main.c
deleted file mode 100644
index 209bb02..0000000
--- a/src/couch/priv/couch_js/main.c
+++ /dev/null
@@ -1,21 +0,0 @@
-// Licensed under the Apache License, Version 2.0 (the "License"); you may not
-// use this file except in compliance with the License. You may obtain a copy of
-// the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-// License for the specific language governing permissions and limitations under
-// the License.
-
-#include "config.h"
-
-#if defined(SM185)
-#include "sm185.c"
-#elif defined(SM180)
-#include "sm180.c"
-#else
-#include "sm170.c"
-#endif

http://git-wip-us.apache.org/repos/asf/couchdb/blob/ed98610c/src/couch/priv/couch_js/sm185.c
----------------------------------------------------------------------
diff --git a/src/couch/priv/couch_js/sm185.c b/src/couch/priv/couch_js/sm185.c
deleted file mode 100644
index bfee023..0000000
--- a/src/couch/priv/couch_js/sm185.c
+++ /dev/null
@@ -1,431 +0,0 @@
-// Licensed under the Apache License, Version 2.0 (the "License"); you may not
-// use this file except in compliance with the License. You may obtain a copy of
-// the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-// License for the specific language governing permissions and limitations under
-// the License.
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-
-#include <jsapi.h>
-#include "http.h"
-#include "utf8.h"
-#include "util.h"
-
-
-#define SETUP_REQUEST(cx) \
-    JS_SetContextThread(cx); \
-    JS_BeginRequest(cx);
-#define FINISH_REQUEST(cx) \
-    JS_EndRequest(cx); \
-    JS_ClearContextThread(cx);
-
-
-static JSClass global_class = {
-    "GlobalClass",
-    JSCLASS_GLOBAL_FLAGS,
-    JS_PropertyStub,
-    JS_PropertyStub,
-    JS_PropertyStub,
-    JS_StrictPropertyStub,
-    JS_EnumerateStub,
-    JS_ResolveStub,
-    JS_ConvertStub,
-    JS_FinalizeStub,
-    JSCLASS_NO_OPTIONAL_MEMBERS
-};
-
-
-static JSBool
-req_ctor(JSContext* cx, uintN argc, jsval* vp)
-{
-    JSBool ret;
-    JSObject* obj = JS_NewObjectForConstructor(cx, vp);
-    if(!obj) {
-        JS_ReportError(cx, "Failed to create CouchHTTP instance.\n");
-        return JS_FALSE;
-    }
-    ret = http_ctor(cx, obj);
-    JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(obj));
-    return ret;
-}
-
-
-static void 
-req_dtor(JSContext* cx, JSObject* obj)
-{
-    http_dtor(cx, obj);
-}
-
-
-static JSBool
-req_open(JSContext* cx, uintN argc, jsval* vp)
-{
-    JSObject* obj = JS_THIS_OBJECT(cx, vp);
-    jsval* argv = JS_ARGV(cx, vp);
-    JSBool ret = JS_FALSE;
-
-    if(argc == 2) {
-        ret = http_open(cx, obj, argv[0], argv[1], JSVAL_FALSE);
-    } else if(argc == 3) {
-        ret = http_open(cx, obj, argv[0], argv[1], argv[2]);
-    } else {
-        JS_ReportError(cx, "Invalid call to CouchHTTP.open");
-    }
-
-    JS_SET_RVAL(cx, vp, JSVAL_VOID);
-    return ret;
-}
-
-
-static JSBool
-req_set_hdr(JSContext* cx, uintN argc, jsval* vp)
-{
-    JSObject* obj = JS_THIS_OBJECT(cx, vp);
-    jsval* argv = JS_ARGV(cx, vp);
-    JSBool ret = JS_FALSE;
-
-    if(argc == 2) {
-        ret = http_set_hdr(cx, obj, argv[0], argv[1]);
-    } else {
-        JS_ReportError(cx, "Invalid call to CouchHTTP.set_header");
-    }
-
-    JS_SET_RVAL(cx, vp, JSVAL_VOID);
-    return ret;
-}
-
-
-static JSBool
-req_send(JSContext* cx, uintN argc, jsval* vp)
-{
-    JSObject* obj = JS_THIS_OBJECT(cx, vp);
-    jsval* argv = JS_ARGV(cx, vp);
-    JSBool ret = JS_FALSE;
-
-    if(argc == 1) {
-        ret = http_send(cx, obj, argv[0]);
-    } else {
-        JS_ReportError(cx, "Invalid call to CouchHTTP.send");
-    }
-
-    JS_SET_RVAL(cx, vp, JSVAL_VOID);
-    return ret;
-}
-
-
-static JSBool
-req_status(JSContext* cx, JSObject* obj, jsid pid, jsval* vp)
-{
-    int status = http_status(cx, obj);
-    if(status < 0)
-        return JS_FALSE;
-
-    JS_SET_RVAL(cx, vp, INT_TO_JSVAL(status));
-    return JS_TRUE;
-}
-
-
-static JSBool
-base_url(JSContext *cx, JSObject* obj, jsid pid, jsval* vp)
-{
-    couch_args *args = (couch_args*)JS_GetContextPrivate(cx);
-    return http_uri(cx, obj, args, &JS_RVAL(cx, vp));
-}
-
-
-static JSBool
-evalcx(JSContext *cx, uintN argc, jsval* vp)
-{
-    jsval* argv = JS_ARGV(cx, vp);
-    JSString* str;
-    JSObject* sandbox;
-    JSObject* global;
-    JSContext* subcx;
-    JSCrossCompartmentCall* call = NULL;
-    const jschar* src;
-    size_t srclen;
-    jsval rval;
-    JSBool ret = JS_FALSE;
-    char *name = NULL;
-
-    sandbox = NULL;
-    if(!JS_ConvertArguments(cx, argc, argv, "S / o", &str, &sandbox)) {
-        return JS_FALSE;
-    }
-
-    subcx = JS_NewContext(JS_GetRuntime(cx), 8L * 1024L);
-    if(!subcx) {
-        JS_ReportOutOfMemory(cx);
-        return JS_FALSE;
-    }
-
-    SETUP_REQUEST(subcx);
-
-    src = JS_GetStringCharsAndLength(cx, str, &srclen);
-
-    // Re-use the compartment associated with the main context,
-    // rather than creating a new compartment */
-    global = JS_GetGlobalObject(cx);
-    if(global == NULL) goto done;
-    call = JS_EnterCrossCompartmentCall(subcx, global);
-
-    if(!sandbox) {
-        sandbox = JS_NewGlobalObject(subcx, &global_class);
-        if(!sandbox || !JS_InitStandardClasses(subcx, sandbox)) {
-            goto done;
-        }
-    }
-
-    if(argc > 2) {
-        name = enc_string(cx, argv[2], NULL);
-    }
-
-    if(srclen == 0) {
-        JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(sandbox));
-    } else {
-        JS_EvaluateUCScript(subcx, sandbox, src, srclen, name, 1, &rval);
-        JS_SET_RVAL(cx, vp, rval);
-    }
-    
-    ret = JS_TRUE;
-
-done:
-    if(name) JS_free(cx, name);
-    JS_LeaveCrossCompartmentCall(call);
-    FINISH_REQUEST(subcx);
-    JS_DestroyContext(subcx);
-    return ret;
-}
-
-
-static JSBool
-gc(JSContext* cx, uintN argc, jsval* vp)
-{
-    JS_GC(cx);
-    JS_SET_RVAL(cx, vp, JSVAL_VOID);
-    return JS_TRUE;
-}
-
-
-static JSBool
-print(JSContext* cx, uintN argc, jsval* vp)
-{
-    jsval* argv = JS_ARGV(cx, vp);
-    couch_print(cx, argc, argv);
-    JS_SET_RVAL(cx, vp, JSVAL_VOID);
-    return JS_TRUE;
-}
-
-
-static JSBool
-quit(JSContext* cx, uintN argc, jsval* vp)
-{
-    jsval* argv = JS_ARGV(cx, vp);
-    int exit_code = 0;
-    JS_ConvertArguments(cx, argc, argv, "/i", &exit_code);
-    exit(exit_code);
-}
-
-
-static JSBool
-readline(JSContext* cx, uintN argc, jsval* vp)
-{
-    JSString* line;
-
-    /* GC Occasionally */
-    JS_MaybeGC(cx);
-
-    line = couch_readline(cx, stdin);
-    if(line == NULL) return JS_FALSE;
-
-    JS_SET_RVAL(cx, vp, STRING_TO_JSVAL(line));
-    return JS_TRUE;
-}
-
-
-static JSBool
-seal(JSContext* cx, uintN argc, jsval* vp)
-{
-    jsval* argv = JS_ARGV(cx, vp);
-    JSObject *target;
-    JSBool deep = JS_FALSE;
-    JSBool ret;
-
-    if(!JS_ConvertArguments(cx, argc, argv, "o/b", &target, &deep))
-        return JS_FALSE;
-
-    if(!target) {
-        JS_SET_RVAL(cx, vp, JSVAL_VOID);
-        return JS_TRUE;
-    }
-
-    
-    ret = deep ? JS_DeepFreezeObject(cx, target) : JS_FreezeObject(cx, target);
-    JS_SET_RVAL(cx, vp, JSVAL_VOID);
-    return ret;
-}
-
-
-JSClass CouchHTTPClass = {
-    "CouchHTTP",
-    JSCLASS_HAS_PRIVATE
-        | JSCLASS_CONSTRUCT_PROTOTYPE
-        | JSCLASS_HAS_RESERVED_SLOTS(2),
-    JS_PropertyStub,
-    JS_PropertyStub,
-    JS_PropertyStub,
-    JS_StrictPropertyStub,
-    JS_EnumerateStub,
-    JS_ResolveStub,
-    JS_ConvertStub,
-    req_dtor,
-    JSCLASS_NO_OPTIONAL_MEMBERS
-};
-
-
-JSPropertySpec CouchHTTPProperties[] = {
-    {"status", 0, JSPROP_READONLY, req_status, NULL},
-    {"base_url", 0, JSPROP_READONLY | JSPROP_SHARED, base_url, NULL},
-    {0, 0, 0, 0, 0}
-};
-
-
-JSFunctionSpec CouchHTTPFunctions[] = {
-    JS_FS("_open", req_open, 3, 0),
-    JS_FS("_setRequestHeader", req_set_hdr, 2, 0),
-    JS_FS("_send", req_send, 1, 0),
-    JS_FS_END
-};
-
-
-static JSFunctionSpec global_functions[] = {
-    JS_FS("evalcx", evalcx, 0, 0),
-    JS_FS("gc", gc, 0, 0),
-    JS_FS("print", print, 0, 0),
-    JS_FS("quit", quit, 0, 0),
-    JS_FS("readline", readline, 0, 0),
-    JS_FS("seal", seal, 0, 0),
-    JS_FS_END
-};
-
-
-int
-main(int argc, const char* argv[])
-{
-    JSRuntime* rt = NULL;
-    JSContext* cx = NULL;
-    JSObject* global = NULL;
-    JSCrossCompartmentCall *call = NULL;
-    JSObject* klass = NULL;
-    JSSCRIPT_TYPE script;
-    JSString* scriptsrc;
-    const jschar* schars;
-    size_t slen;
-    jsval sroot;
-    jsval result;
-    int i;
-
-    couch_args* args = couch_parse_args(argc, argv);
-
-    rt = JS_NewRuntime(64L * 1024L * 1024L);
-    if(rt == NULL)
-        return 1;
-
-    cx = JS_NewContext(rt, args->stack_size);
-    if(cx == NULL)
-        return 1;
-
-    JS_SetErrorReporter(cx, couch_error);
-    JS_ToggleOptions(cx, JSOPTION_XML);
-    JS_SetOptions(cx, JSOPTION_METHODJIT);
-#ifdef JSOPTION_TYPE_INFERENCE
-    JS_SetOptions(cx, JSOPTION_TYPE_INFERENCE);
-#endif
-    JS_SetContextPrivate(cx, args);
-    
-    SETUP_REQUEST(cx);
-
-    global = JS_NewCompartmentAndGlobalObject(cx, &global_class, NULL);
-    if(global == NULL)
-        return 1;
-
-    call = JS_EnterCrossCompartmentCall(cx, global);
-
-    JS_SetGlobalObject(cx, global);
-    
-    if(!JS_InitStandardClasses(cx, global))
-        return 1;
-
-    if(couch_load_funcs(cx, global, global_functions) != JS_TRUE)
-        return 1;
- 
-    if(args->use_http) {
-        http_check_enabled();
-
-        klass = JS_InitClass(
-            cx, global,
-            NULL,
-            &CouchHTTPClass, req_ctor,
-            0,
-            CouchHTTPProperties, CouchHTTPFunctions,
-            NULL, NULL
-        );
-
-        if(!klass)
-        {
-            fprintf(stderr, "Failed to initialize CouchHTTP class.\n");
-            exit(2);
-        }
-    } 
-
-    for(i = 0 ; args->scripts[i] ; i++) {
-        // Convert script source to jschars.
-        scriptsrc = couch_readfile(cx, args->scripts[i]);
-        if(!scriptsrc)
-            return 1;
-
-        schars = JS_GetStringCharsAndLength(cx, scriptsrc, &slen);
-
-        // Root it so GC doesn't collect it.
-        sroot = STRING_TO_JSVAL(scriptsrc);
-        if(JS_AddValueRoot(cx, &sroot) != JS_TRUE) {
-            fprintf(stderr, "Internal root error.\n");
-            return 1;
-        }
-
-        // Compile and run
-        script = JS_CompileUCScript(cx, global, schars, slen,
-                                    args->scripts[i], 1);
-        if(!script) {
-            fprintf(stderr, "Failed to compile script.\n");
-            return 1;
-        }
-
-        if(JS_ExecuteScript(cx, global, script, &result) != JS_TRUE) {
-            fprintf(stderr, "Failed to execute script.\n");
-            return 1;
-        }
-
-        // Warning message if we don't remove it.
-        JS_RemoveValueRoot(cx, &sroot);
-
-        // Give the GC a chance to run.
-        JS_MaybeGC(cx);
-    }
-
-    JS_LeaveCrossCompartmentCall(call);
-    FINISH_REQUEST(cx);
-    JS_DestroyContext(cx);
-    JS_DestroyRuntime(rt);
-    JS_ShutDown();
-
-    return 0;
-}

http://git-wip-us.apache.org/repos/asf/couchdb/blob/ed98610c/src/couch/priv/couch_js/utf8.c
----------------------------------------------------------------------
diff --git a/src/couch/priv/couch_js/utf8.c b/src/couch/priv/couch_js/utf8.c
deleted file mode 100644
index d606426..0000000
--- a/src/couch/priv/couch_js/utf8.c
+++ /dev/null
@@ -1,291 +0,0 @@
-// Licensed under the Apache License, Version 2.0 (the "License"); you may not
-// use this file except in compliance with the License. You may obtain a copy of
-// the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-// License for the specific language governing permissions and limitations under
-// the License.
-
-#include <jsapi.h>
-#include "config.h"
-
-static int
-enc_char(uint8 *utf8Buffer, uint32 ucs4Char)
-{
-    int utf8Length = 1;
-
-    if (ucs4Char < 0x80)
-    {
-        *utf8Buffer = (uint8)ucs4Char;
-    }
-    else
-    {
-        int i;
-        uint32 a = ucs4Char >> 11;
-        utf8Length = 2;
-        while(a)
-        {
-            a >>= 5;
-            utf8Length++;
-        }
-        i = utf8Length;
-        while(--i)
-        {
-            utf8Buffer[i] = (uint8)((ucs4Char & 0x3F) | 0x80);
-            ucs4Char >>= 6;
-        }
-        *utf8Buffer = (uint8)(0x100 - (1 << (8-utf8Length)) + ucs4Char);
-    }
-
-    return utf8Length;
-}
-
-static JSBool
-enc_charbuf(const jschar* src, size_t srclen, char* dst, size_t* dstlenp)
-{
-    size_t i;
-    size_t utf8Len;
-    size_t dstlen = *dstlenp;
-    size_t origDstlen = dstlen;
-    jschar c;
-    jschar c2;
-    uint32 v;
-    uint8 utf8buf[6];
-
-    if(!dst)
-    {
-        dstlen = origDstlen = (size_t) -1;
-    }
-
-    while(srclen)
-    {
-        c = *src++;
-        srclen--;
-
-        if((c >= 0xDC00) && (c <= 0xDFFF)) goto bad_surrogate;
-        
-        if(c < 0xD800 || c > 0xDBFF)
-        {
-            v = c;
-        }
-        else
-        {
-            if(srclen < 1) goto buffer_too_small;
-            c2 = *src++;
-            srclen--;
-            if ((c2 < 0xDC00) || (c2 > 0xDFFF))
-            {
-                c = c2;
-                goto bad_surrogate;
-            }
-            v = ((c - 0xD800) << 10) + (c2 - 0xDC00) + 0x10000;
-        }
-        if(v < 0x0080)
-        {
-            /* no encoding necessary - performance hack */
-            if(!dstlen) goto buffer_too_small;
-            if(dst) *dst++ = (char) v;
-            utf8Len = 1;
-        }
-        else
-        {
-            utf8Len = enc_char(utf8buf, v);
-            if(utf8Len > dstlen) goto buffer_too_small;
-            if(dst)
-            {
-                for (i = 0; i < utf8Len; i++)
-                {
-                    *dst++ = (char) utf8buf[i];
-                }
-            }
-        }
-        dstlen -= utf8Len;
-    }
-    
-    *dstlenp = (origDstlen - dstlen);
-    return JS_TRUE;
-
-bad_surrogate:
-    *dstlenp = (origDstlen - dstlen);
-    return JS_FALSE;
-
-buffer_too_small:
-    *dstlenp = (origDstlen - dstlen);
-    return JS_FALSE;
-}
-
-char*
-enc_string(JSContext* cx, jsval arg, size_t* buflen)
-{
-    JSString* str = NULL;
-    const jschar* src = NULL;
-    char* bytes = NULL;
-    size_t srclen = 0;
-    size_t byteslen = 0;
-    
-    str = JS_ValueToString(cx, arg);
-    if(!str) goto error;
-
-#ifdef HAVE_JS_GET_STRING_CHARS_AND_LENGTH
-    src = JS_GetStringCharsAndLength(cx, str, &srclen);
-#else
-    src = JS_GetStringChars(str);
-    srclen = JS_GetStringLength(str);
-#endif
-
-    if(!enc_charbuf(src, srclen, NULL, &byteslen)) goto error;
-    
-    bytes = JS_malloc(cx, (byteslen) + 1);
-    bytes[byteslen] = 0;
-    
-    if(!enc_charbuf(src, srclen, bytes, &byteslen)) goto error;
-
-    if(buflen) *buflen = byteslen;
-    goto success;
-
-error:
-    if(bytes != NULL) JS_free(cx, bytes);
-    bytes = NULL;
-
-success:
-    return bytes;
-}
-
-static uint32
-dec_char(const uint8 *utf8Buffer, int utf8Length)
-{
-    uint32 ucs4Char;
-    uint32 minucs4Char;
-
-    /* from Unicode 3.1, non-shortest form is illegal */
-    static const uint32 minucs4Table[] = {
-        0x00000080, 0x00000800, 0x0001000, 0x0020000, 0x0400000
-    };
-
-    if (utf8Length == 1)
-    {
-        ucs4Char = *utf8Buffer;
-    }
-    else
-    {
-        ucs4Char = *utf8Buffer++ & ((1<<(7-utf8Length))-1);
-        minucs4Char = minucs4Table[utf8Length-2];
-        while(--utf8Length)
-        {
-            ucs4Char = ucs4Char<<6 | (*utf8Buffer++ & 0x3F);
-        }
-        if(ucs4Char < minucs4Char || ucs4Char == 0xFFFE || ucs4Char == 0xFFFF)
-        {
-            ucs4Char = 0xFFFD;
-        }
-    }
-
-    return ucs4Char;
-}
-
-static JSBool
-dec_charbuf(const char *src, size_t srclen, jschar *dst, size_t *dstlenp)
-{
-    uint32 v;
-    size_t offset = 0;
-    size_t j;
-    size_t n;
-    size_t dstlen = *dstlenp;
-    size_t origDstlen = dstlen;
-
-    if(!dst) dstlen = origDstlen = (size_t) -1;
-
-    while(srclen)
-    {
-        v = (uint8) *src;
-        n = 1;
-        
-        if(v & 0x80)
-        {
-            while(v & (0x80 >> n))
-            {
-                n++;
-            }
-            
-            if(n > srclen) goto buffer_too_small;
-            if(n == 1 || n > 6) goto bad_character;
-            
-            for(j = 1; j < n; j++)
-            {
-                if((src[j] & 0xC0) != 0x80) goto bad_character;
-            }
-
-            v = dec_char((const uint8 *) src, n);
-            if(v >= 0x10000)
-            {
-                v -= 0x10000;
-                
-                if(v > 0xFFFFF || dstlen < 2)
-                {
-                    *dstlenp = (origDstlen - dstlen);
-                    return JS_FALSE;
-                }
-                
-                if(dstlen < 2) goto buffer_too_small;
-
-                if(dst)
-                {
-                    *dst++ = (jschar)((v >> 10) + 0xD800);
-                    v = (jschar)((v & 0x3FF) + 0xDC00);
-                }
-                dstlen--;
-            }
-        }
-
-        if(!dstlen) goto buffer_too_small;
-        if(dst) *dst++ = (jschar) v;
-
-        dstlen--;
-        offset += n;
-        src += n;
-        srclen -= n;
-    }
-
-    *dstlenp = (origDstlen - dstlen);
-    return JS_TRUE;
-
-bad_character:
-    *dstlenp = (origDstlen - dstlen);
-    return JS_FALSE;
-
-buffer_too_small:
-    *dstlenp = (origDstlen - dstlen);
-    return JS_FALSE;
-}
-
-JSString*
-dec_string(JSContext* cx, const char* bytes, size_t byteslen)
-{
-    JSString* str = NULL;
-    jschar* chars = NULL;
-    size_t charslen;
-    
-    if(!dec_charbuf(bytes, byteslen, NULL, &charslen)) goto error;
-
-    chars = JS_malloc(cx, (charslen + 1) * sizeof(jschar));
-    if(!chars) return NULL;
-    chars[charslen] = 0;
-
-    if(!dec_charbuf(bytes, byteslen, chars, &charslen)) goto error;
-
-    str = JS_NewUCString(cx, chars, charslen - 1);
-    if(!str) goto error;
-
-    goto success;
-
-error:
-    if(chars != NULL) JS_free(cx, chars);
-    str = NULL;
-
-success:
-    return str;
-}

http://git-wip-us.apache.org/repos/asf/couchdb/blob/ed98610c/src/couch/priv/couch_js/utf8.h
----------------------------------------------------------------------
diff --git a/src/couch/priv/couch_js/utf8.h b/src/couch/priv/couch_js/utf8.h
deleted file mode 100644
index c5cb86c..0000000
--- a/src/couch/priv/couch_js/utf8.h
+++ /dev/null
@@ -1,19 +0,0 @@
-// Licensed under the Apache License, Version 2.0 (the "License"); you may not
-// use this file except in compliance with the License. You may obtain a copy of
-// the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-// License for the specific language governing permissions and limitations under
-// the License.
-
-#ifndef COUCH_JS_UTF_8_H
-#define COUCH_JS_UTF_8_H
-
-char* enc_string(JSContext* cx, jsval arg, size_t* buflen);
-JSString* dec_string(JSContext* cx, const char* buf, size_t buflen);
-
-#endif

http://git-wip-us.apache.org/repos/asf/couchdb/blob/ed98610c/src/couch/priv/couch_js/util.c
----------------------------------------------------------------------
diff --git a/src/couch/priv/couch_js/util.c b/src/couch/priv/couch_js/util.c
deleted file mode 100644
index 5c88402..0000000
--- a/src/couch/priv/couch_js/util.c
+++ /dev/null
@@ -1,294 +0,0 @@
-// Licensed under the Apache License, Version 2.0 (the "License"); you may not
-// use this file except in compliance with the License. You may obtain a copy of
-// the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-// License for the specific language governing permissions and limitations under
-// the License.
-
-#include <stdlib.h>
-#include <string.h>
-
-#include <jsapi.h>
-
-#include "help.h"
-#include "util.h"
-#include "utf8.h"
-
-
-size_t
-slurp_file(const char* file, char** outbuf_p)
-{
-    FILE* fp;
-    char fbuf[16384];
-    char *buf = NULL;
-    char* tmp;
-    size_t nread = 0;
-    size_t buflen = 0;
-
-    if(strcmp(file, "-") == 0) {
-        fp = stdin;
-    } else {
-        fp = fopen(file, "r");
-        if(fp == NULL) {
-            fprintf(stderr, "Failed to read file: %s\n", file);
-            exit(3);
-        }
-    }
-
-    while((nread = fread(fbuf, 1, 16384, fp)) > 0) {
-        if(buf == NULL) {
-            buf = (char*) malloc(nread + 1);
-            if(buf == NULL) {
-                fprintf(stderr, "Out of memory.\n");
-                exit(3);
-            }
-            memcpy(buf, fbuf, nread);
-        } else {
-            tmp = (char*) malloc(buflen + nread + 1);
-            if(tmp == NULL) {
-                fprintf(stderr, "Out of memory.\n");
-                exit(3);
-            }
-            memcpy(tmp, buf, buflen);
-            memcpy(tmp+buflen, fbuf, nread);
-            free(buf);
-            buf = tmp;
-        }
-        buflen += nread;
-        buf[buflen] = '\0';
-    }
-    *outbuf_p = buf;
-    return buflen + 1;
-}
-
-couch_args*
-couch_parse_args(int argc, const char* argv[])
-{
-    couch_args* args;
-    int i = 1;
-
-    args = (couch_args*) malloc(sizeof(couch_args));
-    if(args == NULL)
-        return NULL;
-
-    memset(args, '\0', sizeof(couch_args));
-    args->stack_size = 8L * 1024L;
-
-    while(i < argc) {
-        if(strcmp("-h", argv[i]) == 0) {
-            DISPLAY_USAGE;
-            exit(0);
-        } else if(strcmp("-V", argv[i]) == 0) {
-            DISPLAY_VERSION;
-            exit(0);
-        } else if(strcmp("-H", argv[i]) == 0) {
-            args->use_http = 1;
-        } else if(strcmp("-S", argv[i]) == 0) {
-            args->stack_size = atoi(argv[++i]);
-            if(args->stack_size <= 0) {
-                fprintf(stderr, "Invalid stack size.\n");
-                exit(2);
-            }
-        } else if(strcmp("-u", argv[i]) == 0) {
-            args->uri_file = argv[++i];
-        } else if(strcmp("--", argv[i]) == 0) {
-            i++;
-            break;
-        } else {
-            break;
-        }
-        i++;
-    }
-
-    if(i >= argc) {
-        DISPLAY_USAGE;
-        exit(3);
-    }
-    args->scripts = argv + i;
-
-    return args;
-}
-
-
-int
-couch_fgets(char* buf, int size, FILE* fp)
-{
-    int n, i, c;
-
-    if(size <= 0) return -1;
-    n = size - 1;
-
-    for(i = 0; i < n && (c = getc(fp)) != EOF; i++) {
-        buf[i] = c;
-        if(c == '\n') {
-            i++;
-            break;
-        }
-    }
-
-    buf[i] = '\0';
-    return i;
-}
-
-
-JSString*
-couch_readline(JSContext* cx, FILE* fp)
-{
-    JSString* str;
-    char* bytes = NULL;
-    char* tmp = NULL;
-    size_t used = 0;
-    size_t byteslen = 256;
-    size_t readlen = 0;
-
-    bytes = JS_malloc(cx, byteslen);
-    if(bytes == NULL) return NULL;
-    
-    while((readlen = couch_fgets(bytes+used, byteslen-used, fp)) > 0) {
-        used += readlen;
-        
-        if(bytes[used-1] == '\n') {
-            bytes[used-1] = '\0';
-            break;
-        }
-        
-        // Double our buffer and read more.
-        byteslen *= 2;
-        tmp = JS_realloc(cx, bytes, byteslen);
-        if(!tmp) {
-            JS_free(cx, bytes);
-            return NULL;
-        }
-        
-        bytes = tmp;
-    }
-
-    // Treat empty strings specially
-    if(used == 0) {
-        JS_free(cx, bytes);
-        return JSVAL_TO_STRING(JS_GetEmptyStringValue(cx));
-    }
-
-    // Shring the buffer to the actual data size
-    tmp = JS_realloc(cx, bytes, used);
-    if(!tmp) {
-        JS_free(cx, bytes);
-        return NULL;
-    }
-    bytes = tmp;
-    byteslen = used;
-
-    str = dec_string(cx, bytes, byteslen);
-    JS_free(cx, bytes);
-    return str;
-}
-
-
-JSString*
-couch_readfile(JSContext* cx, const char* filename)
-{
-    JSString *string;
-    size_t byteslen;
-    char *bytes;
-
-    if((byteslen = slurp_file(filename, &bytes))) {
-        string = dec_string(cx, bytes, byteslen);
-
-        free(bytes);
-        return string;
-    }
-    return NULL;    
-}
-
-
-void
-couch_print(JSContext* cx, uintN argc, jsval* argv)
-{
-    char *bytes = NULL;
-    FILE *stream = stdout;
-
-    if (argc) {
-        if (argc > 1 && argv[1] == JSVAL_TRUE) {
-          stream = stderr;
-        }
-        bytes = enc_string(cx, argv[0], NULL);
-        if(!bytes) return;
-        fprintf(stream, "%s", bytes);
-        JS_free(cx, bytes);
-    }
-
-    fputc('\n', stream);
-    fflush(stream);
-}
-
-
-void
-couch_error(JSContext* cx, const char* mesg, JSErrorReport* report)
-{
-    jsval v, replace;
-    char* bytes;
-    JSObject* regexp, *stack;
-    jsval re_args[2];
-
-    if(!report || !JSREPORT_IS_WARNING(report->flags))
-    {
-        fprintf(stderr, "%s\n", mesg);
-
-        // Print a stack trace, if available.
-        if (JSREPORT_IS_EXCEPTION(report->flags) &&
-            JS_GetPendingException(cx, &v))
-        {
-            // Clear the exception before an JS method calls or the result is
-            // infinite, recursive error report generation.
-            JS_ClearPendingException(cx);
-
-            // Use JS regexp to indent the stack trace.
-            // If the regexp can't be created, don't JS_ReportError since it is
-            // probably not productive to wind up here again.
-#ifdef SM185
-            if(JS_GetProperty(cx, JSVAL_TO_OBJECT(v), "stack", &v) &&
-               (regexp = JS_NewRegExpObjectNoStatics(
-                   cx, "^(?=.)", 6, JSREG_GLOB | JSREG_MULTILINE)))
-#else
-            if(JS_GetProperty(cx, JSVAL_TO_OBJECT(v), "stack", &v) &&
-               (regexp = JS_NewRegExpObject(
-                   cx, "^(?=.)", 6, JSREG_GLOB | JSREG_MULTILINE)))
-#endif
-            {
-                // Set up the arguments to ``String.replace()``
-                re_args[0] = OBJECT_TO_JSVAL(regexp);
-                re_args[1] = STRING_TO_JSVAL(JS_InternString(cx, "\t"));
-
-                // Perform the replacement
-                if(JS_ValueToObject(cx, v, &stack) &&
-                   JS_GetProperty(cx, stack, "replace", &replace) &&
-                   JS_CallFunctionValue(cx, stack, replace, 2, re_args, &v))
-                {
-                    // Print the result
-                    bytes = enc_string(cx, v, NULL);
-                    fprintf(stderr, "Stacktrace:\n%s", bytes);
-                    JS_free(cx, bytes);
-                }
-            }
-        }
-    }
-}
-
-
-JSBool
-couch_load_funcs(JSContext* cx, JSObject* obj, JSFunctionSpec* funcs)
-{
-    JSFunctionSpec* f;
-    for(f = funcs; f->name != NULL; f++) {
-        if(!JS_DefineFunction(cx, obj, f->name, f->call, f->nargs, f->flags)) {
-            fprintf(stderr, "Failed to create function: %s\n", f->name);
-            return JS_FALSE;
-        }
-    }
-    return JS_TRUE;
-}

http://git-wip-us.apache.org/repos/asf/couchdb/blob/ed98610c/src/couch/priv/couch_js/util.h
----------------------------------------------------------------------
diff --git a/src/couch/priv/couch_js/util.h b/src/couch/priv/couch_js/util.h
deleted file mode 100644
index 65a2a06..0000000
--- a/src/couch/priv/couch_js/util.h
+++ /dev/null
@@ -1,35 +0,0 @@
-// Licensed under the Apache License, Version 2.0 (the "License"); you may not
-// use this file except in compliance with the License. You may obtain a copy of
-// the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-// License for the specific language governing permissions and limitations under
-// the License.
-
-#ifndef COUCHJS_UTIL_H
-#define COUCHJS_UTIL_H
-
-#include <jsapi.h>
-
-typedef struct {
-    int          use_http;
-    int          stack_size;
-    const char** scripts;
-    const char*  uri_file;
-    JSString*    uri;
-} couch_args;
-
-couch_args* couch_parse_args(int argc, const char* argv[]);
-int couch_fgets(char* buf, int size, FILE* fp);
-JSString* couch_readline(JSContext* cx, FILE* fp);
-JSString* couch_readfile(JSContext* cx, const char* filename);
-void couch_print(JSContext* cx, uintN argc, jsval* argv);
-void couch_error(JSContext* cx, const char* mesg, JSErrorReport* report);
-JSBool couch_load_funcs(JSContext* cx, JSObject* obj, JSFunctionSpec* funcs);
-
-
-#endif // Included util.h

http://git-wip-us.apache.org/repos/asf/couchdb/blob/ed98610c/src/couch/priv/icu_driver/couch_icu_driver.c
----------------------------------------------------------------------
diff --git a/src/couch/priv/icu_driver/couch_icu_driver.c b/src/couch/priv/icu_driver/couch_icu_driver.c
deleted file mode 100644
index a59e8cb..0000000
--- a/src/couch/priv/icu_driver/couch_icu_driver.c
+++ /dev/null
@@ -1,189 +0,0 @@
-/*
-
-Licensed under the Apache License, Version 2.0 (the "License"); you may not use
-this file except in compliance with the License. You may obtain a copy of the
-License at
-
-  http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software distributed
-under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
-CONDITIONS OF ANY KIND, either express or implied. See the License for the
-specific language governing permissions and limitations under the License.
-
-*/
-
-/* This file is the C port driver for Erlang. It provides a low overhead
- * means of calling into C code, however coding errors in this module can
- * crash the entire Erlang server.
- */
-
-#ifdef DARWIN
-#define U_HIDE_DRAFT_API 1
-#define U_DISABLE_RENAMING 1
-#endif
-
-#include "erl_driver.h"
-#include "unicode/ucol.h"
-#include "unicode/ucasemap.h"
-#ifndef WIN32
-#include <string.h> /* for memcpy */
-#endif
-
-#if ERL_DRV_EXTENDED_MAJOR_VERSION < 2
-typedef int COUCH_SSIZET;
-#else
-typedef ErlDrvSSizeT COUCH_SSIZET;
-#endif
-
-typedef struct {
-    ErlDrvPort port;
-    UCollator* collNoCase;
-    UCollator* coll;
-} couch_drv_data;
-
-static void couch_drv_stop(ErlDrvData data)
-{
-    couch_drv_data* pData = (couch_drv_data*)data;
-    if (pData->coll) {
-        ucol_close(pData->coll);
-    }
-    if (pData->collNoCase) {
-        ucol_close(pData->collNoCase);
-    }
-    driver_free((void*)pData);
-}
-
-static ErlDrvData couch_drv_start(ErlDrvPort port, char *buff)
-{
-    UErrorCode status = U_ZERO_ERROR;
-    couch_drv_data* pData = (couch_drv_data*)driver_alloc(sizeof(couch_drv_data));
-
-    if (pData == NULL)
-        return ERL_DRV_ERROR_GENERAL;
-
-    pData->port = port;
-
-    pData->coll = ucol_open("", &status);
-    if (U_FAILURE(status)) {
-        couch_drv_stop((ErlDrvData)pData);
-        return ERL_DRV_ERROR_GENERAL;
-    }
-
-    pData->collNoCase = ucol_open("", &status);
-    if (U_FAILURE(status)) {
-        couch_drv_stop((ErlDrvData)pData);
-        return ERL_DRV_ERROR_GENERAL;
-    }
-
-    ucol_setAttribute(pData->collNoCase, UCOL_STRENGTH, UCOL_PRIMARY, &status);
-    if (U_FAILURE(status)) {
-        couch_drv_stop((ErlDrvData)pData);
-        return ERL_DRV_ERROR_GENERAL;
-    }
-
-    return (ErlDrvData)pData;
-}
-
-COUCH_SSIZET
-return_control_result(void* pLocalResult, int localLen,
-            char **ppRetBuf, COUCH_SSIZET returnLen)
-{
-    if (*ppRetBuf == NULL || localLen > returnLen) {
-        *ppRetBuf = (char*)driver_alloc_binary(localLen);
-        if(*ppRetBuf == NULL) {
-            return -1;
-        }
-    }
-    memcpy(*ppRetBuf, pLocalResult, localLen);
-    return localLen;
-}
-
-static COUCH_SSIZET
-couch_drv_control(ErlDrvData drv_data, unsigned int command,
-        char *pBuf, COUCH_SSIZET bufLen,
-        char **rbuf, COUCH_SSIZET rlen)
-{
-
-    couch_drv_data* pData = (couch_drv_data*)drv_data;
-    switch(command) {
-    case 0: /* COLLATE */
-    case 1: /* COLLATE_NO_CASE: */
-        {
-        UErrorCode status = U_ZERO_ERROR;
-        int collResult;
-        char response;
-        UCharIterator iterA;
-        UCharIterator iterB;
-        int32_t length;
-
-        /* 2 strings are in the buffer, consecutively
-         * The strings begin first with a 32 bit integer byte length, then the actual
-         * string bytes follow.
-         */
-
-        /* first 32bits are the length */
-        memcpy(&length, pBuf, sizeof(length));
-        pBuf += sizeof(length);
-
-        /* point the iterator at it. */
-        uiter_setUTF8(&iterA, pBuf, length);
-
-        pBuf += length; /* now on to string b */
-
-        /* first 32bits are the length */
-        memcpy(&length, pBuf, sizeof(length));
-        pBuf += sizeof(length);
-
-        /* point the iterator at it. */
-        uiter_setUTF8(&iterB, pBuf, length);
-
-        if (command == 0) /* COLLATE */
-          collResult = ucol_strcollIter(pData->coll, &iterA, &iterB, &status);
-        else              /* COLLATE_NO_CASE */
-          collResult = ucol_strcollIter(pData->collNoCase, &iterA, &iterB, &status);
-
-        if (collResult < 0)
-          response = 0; /*lt*/
-        else if (collResult > 0)
-          response = 2; /*gt*/
-        else
-          response = 1; /*eq*/
-
-        return return_control_result(&response, sizeof(response), rbuf, rlen);
-        }
-
-    default:
-        return -1;
-    }
-}
-
-ErlDrvEntry couch_driver_entry = {
-        NULL,               /* F_PTR init, N/A */
-        couch_drv_start,    /* L_PTR start, called when port is opened */
-        couch_drv_stop,     /* F_PTR stop, called when port is closed */
-        NULL,               /* F_PTR output, called when erlang has sent */
-        NULL,               /* F_PTR ready_input, called when input descriptor ready */
-        NULL,               /* F_PTR ready_output, called when output descriptor ready */
-        "couch_icu_driver", /* char *driver_name, the argument to open_port */
-        NULL,               /* F_PTR finish, called when unloaded */
-        NULL,               /* Not used */
-        couch_drv_control,  /* F_PTR control, port_command callback */
-        NULL,               /* F_PTR timeout, reserved */
-        NULL,               /* F_PTR outputv, reserved */
-        NULL,               /* F_PTR ready_async */
-        NULL,               /* F_PTR flush */
-        NULL,               /* F_PTR call */
-        NULL,               /* F_PTR event */
-        ERL_DRV_EXTENDED_MARKER,
-        ERL_DRV_EXTENDED_MAJOR_VERSION,
-        ERL_DRV_EXTENDED_MINOR_VERSION,
-        ERL_DRV_FLAG_USE_PORT_LOCKING,
-        NULL,               /* Reserved -- Used by emulator internally */
-        NULL,               /* F_PTR process_exit */
-};
-
-DRIVER_INIT(couch_icu_driver) /* must match name in driver_entry */
-{
-        return &couch_driver_entry;
-}

http://git-wip-us.apache.org/repos/asf/couchdb/blob/ed98610c/src/couch/priv/spawnkillable/couchspawnkillable.sh
----------------------------------------------------------------------
diff --git a/src/couch/priv/spawnkillable/couchspawnkillable.sh b/src/couch/priv/spawnkillable/couchspawnkillable.sh
deleted file mode 100644
index f8d042e..0000000
--- a/src/couch/priv/spawnkillable/couchspawnkillable.sh
+++ /dev/null
@@ -1,20 +0,0 @@
-#! /bin/sh -e
-
-# Licensed under the Apache License, Version 2.0 (the "License"); you may not
-# use this file except in compliance with the License. You may obtain a copy of
-# the License at
-#
-#   http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations under
-# the License.
-
-# The purpose of this script is to echo an OS specific command before launching
-# the actual process. This provides a way for Erlang to hard-kill its external
-# processes.
-
-echo "kill -9 $$"
-exec $*


Mime
View raw message