# # This file is part of gtkDjs. # # gtkDjs is free software; you can redistribute it and/or modify # it under the terms of the GNU Lesser General Public License as published by # the Free Software Foundation; either version 2.1 of the License, or # (at your option) any later version. # # gtkDjs is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with gtkDjs; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # ignoreEnum: svn_errno_t wrap: svn jsPackage: Svn addTypes: start union svn_opt_revision_value_t { int number; long date; }; addTypes: end structCode: svn_auth_baton_t structCode: end structCode: svn_stream_t structCode: end hfile: svn_types.h houtFile: hfile: svn_string.h houtFile: hfile: svn_auth.h houtFile: hfile: svn_opt.h houtFile: hfile: svn_pools.h houtFile: hfile: svn_sorts.h houtFile: hfile: svn_config.h houtFile: hfile: svn_client.h class: Svn jsClass: Svn prefix: svn_client_ struct: svn_client_ctx_t constructorMethod: ctxTNew import: apr.bindingaprtypes import: apr.bindingapr import: svn._version_t import: svn._client_commit_item2_t import: svn._client_proplist_item_t import: svn._client_diff_summarize_t argFetch: svn_client_ctx_t* ctx STRUCT argFetch: svn_opt_revision_t* start createRevision( arglist.length > %N% ? cast(int) (arglist[%N%].toNumber() : -1) argFetch: svn_opt_revision_t* end createRevision( arglist.length > %N% ? cast(int) (arglist[%N%].toNumber() : -1) argFetch: svn_opt_revision_t* revision_1 createRevision( arglist.length > %N% ? cast(int) (arglist[%N%].toNumber() : -1) argFetch: svn_opt_revision_t* revision_2 createRevision( arglist.length > %N% ? cast(int) (arglist[%N%].toNumber() : -1) argFetch: apr_pool_t* pool cast(Wrapped_apr_pool_t*)svn_pool_create_ex((cast(dsWrapped_svn_client_ctx_t)othis).pool,null); #argFetch: svn_revnum_t* new svn_revnum_t argFetch: svn_wc_status_func_t status_func &statusFuncCallback argFetch: void* status_baton cast(void*)ret; argReturn: svn_error_t* if (_ret) { throw errToException(_ret); } ret.putVundefined(); argPost: apr_pool_t* apr_pool_destroy(_arg_pool); #fake new.. jsfunc: svn_client_ctx_t* svn_client_ctx_t_new(); jscode: svn_client_ctx_t_new dsWrapped_svn_client_ctx_t sthis = newWrapper(); ret.putVobject(sthis); return null; } static dsWrapped_svn_client_ctx_t newWrapper() { dsWrapped_svn_client_ctx_t sthis; Wrapped_svn_error_t* err; ThreadContext *tc = ThreadContext.getThreadContext(); Wrapped_svn_client_ctx_t* ctx; if ((cast(dsWrapped_svn_client_ctx_t)tc.protoTable["Svn"]).pool) { // copy data.. sthis = new dsWrapped_svn_client_ctx_t(cast(Wrapped_svn_client_ctx_t*)tc.protoTable["Svn"].getStruct()); sthis.pool = (cast(dsWrapped_svn_client_ctx_t)tc.protoTable["Svn"]).pool; return sthis; } (cast(dsWrapped_svn_client_ctx_t)tc.protoTable["Svn"]).pool = svn_pool_create_ex(null,null); err = svn_client_create_context (&ctx, (cast(dsWrapped_svn_client_ctx_t)tc.protoTable["Svn"]).pool); if (err) { throw errToException(err); } tc.protoTable["Svn"].setStruct(cast(void*) ctx); sthis = new dsWrapped_svn_client_ctx_t(cast(Wrapped_svn_client_ctx_t*)tc.protoTable["Svn"].getStruct()); sthis.pool = (cast(dsWrapped_svn_client_ctx_t)tc.protoTable["Svn"]).pool; sthis.setStruct(cast(void*) ctx); err = svn_config_get_config(&(ctx.config), null, sthis.pool); if (err) { throw errToException(err); } //sthis.ctx->log_msg_func = ds_svn_get_commit_log; Wrapped_apr_array_header_t * providers = apr_array_make (sthis.pool, 10, (Wrapped_svn_auth_provider_object_t *).sizeof); Wrapped_svn_auth_provider_object_t *provider; svn_client_get_simple_provider (&provider,sthis.pool); (*(cast(Wrapped_svn_auth_provider_object_t **)apr_array_push(providers))) = provider; svn_client_get_username_provider (&provider, sthis.pool); (*(cast(Wrapped_svn_auth_provider_object_t **)apr_array_push(providers))) = provider; //svn_client_get_ssl_server_trust_prompt_provider (&provider, dswrap_svn_auth_ssl_client_server_trust_prompter, null, sthis.pool); //APR_ARRAY_PUSH (providers, svn_auth_provider_object_t *) = provider; /* The server-cert, client-cert, and client-cert-password providers. */ svn_client_get_ssl_server_trust_file_provider (&provider, sthis.pool); (*(cast(Wrapped_svn_auth_provider_object_t **)apr_array_push(providers))) = provider; svn_client_get_ssl_client_cert_file_provider (&provider, sthis.pool); (*(cast(Wrapped_svn_auth_provider_object_t **)apr_array_push(providers))) = provider; svn_client_get_ssl_client_cert_pw_file_provider (&provider, sthis.pool); (*(cast(Wrapped_svn_auth_provider_object_t **)apr_array_push(providers))) = provider; Wrapped_svn_auth_baton_t *ab; svn_auth_open (cast(void**)&ab, providers, sthis.pool); /* turn off prompting */ svn_auth_set_parameter(cast(void*)ab, "svn:auth:non-interactive", null); /* turn off storing passwords */ svn_auth_set_parameter(cast(void*)ab, "svn:auth:dont-store-passwords", null); ctx.auth_baton = ab; return sthis; } Wrapped_apr_pool_t *pool; static Exception errToException(Wrapped_svn_error_t *error) { Wrapped_svn_error_t *itr = error; char[255] buf; char[] str = "Subversion Error: \n"; svn_strerror(itr.apr_err, buf.ptr, 255); while (itr) { str ~= std.string.toString(itr.apr_err) ~ " (" ~ std.string.toString(buf.ptr) ~ ")" ~ std.string.toString(error.message); if (itr.child) { str ~= "\n"; itr = itr.child; continue; } break; } str ~="\n"; return new Exception(str); } static Wrapped_svn_opt_revision_t* createRevision(int revno) { Wrapped_svn_opt_revision_t* revision = new Wrapped_svn_opt_revision_t; if (revno > 0) { revision.kind = Enum_svn_opt_revision_kind.svn_opt_revision_number; revision.value.number = revno; return revision; } revision.kind = Enum_svn_opt_revision_kind.svn_opt_revision_head; return revision; } void* dummy() { jscode: end #dot indicates force dynamic method. jscode: svn_client_import Wrapped_svn_client_commit_info_t *_arg_commit_info_p = null; Wrapped_svn_client_ctx_t* _arg_ctx = cast(Wrapped_svn_client_ctx_t*) (othis.getStruct()); Wrapped_apr_pool_t* _arg_subpool = svn_pool_create_ex((cast(dsWrapped_svn_client_ctx_t)othis).pool,null); char* _arg_path = arglist[0].vtype == V_NULL ? null : std.string.toStringz(arglist[0].toString()); char* _arg_url = arglist[1].vtype == V_NULL ? null : std.string.toStringz(arglist[1].toString()); int _arg_nonrecursive = cast(int) (arglist[2].toNumber()); Wrapped_svn_error_t *_ret = svn_client_import(&_arg_commit_info_p, _arg_path, _arg_url, _arg_nonrecursive, _arg_ctx, _arg_subpool); if (_ret) { throw dsWrapped_svn_client_ctx_t.errToException(_ret); } apr_pool_destroy(_arg_subpool); // final? ret.putVundefined(); jscode: end jscode: svn_client_checkout Wrapped_svn_client_ctx_t* _arg_ctx = cast(Wrapped_svn_client_ctx_t*) (othis.getStruct()); Wrapped_apr_pool_t* _arg_subpool = svn_pool_create_ex((cast(dsWrapped_svn_client_ctx_t)othis).pool,null); char* _arg_repos = arglist[0].vtype == V_NULL ? null : std.string.toStringz(arglist[0].toString()); char* _arg_target = arglist[1].vtype == V_NULL ? null : std.string.toStringz(arglist[1].toString()); int _arg_revno = cast(int) (arglist[2].toNumber()); Wrapped_svn_error_t *_ret = svn_client_checkout (null, _arg_repos, _arg_target, createRevision(_arg_revno), true, _arg_ctx, _arg_subpool); if (_ret) { throw dsWrapped_svn_client_ctx_t.errToException(_ret); } apr_pool_destroy(_arg_subpool); ret.putVundefined(); jscode: end jscode: svn_client_cat Wrapped_svn_client_ctx_t* _arg_ctx = cast(Wrapped_svn_client_ctx_t*) (othis.getStruct()); Wrapped_apr_pool_t* _arg_subpool = svn_pool_create_ex((cast(dsWrapped_svn_client_ctx_t)othis).pool,null); char* _arg_repos = arglist[0].vtype == V_NULL ? null : std.string.toStringz(arglist[0].toString()); int _arg_revno = arglist.length > 1 ? cast(int) (arglist[1].toNumber()) : -1; Wrapped_svn_stringbuf_t* buf = svn_stringbuf_create("", _arg_subpool); // error handling!? Wrapped_svn_stream_t* _arg_out = cast(Wrapped_svn_stream_t*) svn_stream_from_stringbuf(buf, _arg_subpool); Wrapped_svn_error_t *_ret = svn_client_cat (_arg_out, _arg_repos, createRevision(_arg_revno), _arg_ctx, _arg_subpool); if (_ret) throw dsWrapped_svn_client_ctx_t.errToException(_ret); char* retdata = std.string.toStringz(new char[buf.len +1]); _ret = svn_stream_read(_arg_out, retdata, &(buf.len)); if (_ret) throw dsWrapped_svn_client_ctx_t.errToException(_ret); retdata[buf.len] = '\0'; ret.putVstring(std.string.toString(retdata)); // dupe it? apr_pool_destroy(_arg_subpool); jscode: end jscode: svn_client_ls /* Wrapped_svn_client_ctx_t* _arg_ctx = cast(Wrapped_svn_client_ctx_t*) (othis.getStruct()); Wrapped_apr_pool_t* _arg_subpool = svn_pool_create_ex((cast(dsWrapped_svn_client_ctx_t)othis).pool,null); char* _arg_repos = arglist[0].vtype == V_NULL ? null : std.string.toStringz(arglist[0].toString()); int _arg_revno = cast(int) (arglist[2].toNumber()); Wrapped_apr_hash_t *_arg_dirents; Wrapped_svn_error_t *_ret = svn_client_ls (&_arg_dirents, _arg_repos, createRevision(_arg_revno), 0, _arg_ctx, _arg_subpool); if (_ret) throw dsWrapped_svn_client_ctx_t.errToException(_ret); Wrapped_apr_array_header_t *array = svn_sort__hash (_arg_dirents, svn_sort_compare_items_as_paths, _arg_subpool); Darray ret_arr = new Darray(); long apr_time_sec(long t) { return t / 1000000; } for (int i = 0; i < array.nelts; ++i) { ulong now = apr_time_now(); Wrapped_apr_time_exp_t exp_time; int apr_err; int size; char timestr[20]; char *utf8_timestr; Wrapped_svn_sort__item_t* sitem = cast(Wrapped_svn_sort__item_t *) ((array.elts)[i]); char* utf8_entryname = cast(char*) sitem.key; Wrapped_svn_dirent_t* dirent = cast(Wrapped_svn_dirent_t*) apr_hash_get (_arg_dirents, utf8_entryname, sitem.klen); apr_time_exp_lt (&exp_time, dirent.time); if (apr_time_sec(now - dirent.time) < (365 * 86400 / 2) && apr_time_sec(dirent.time - now) < (365 * 86400 / 2)) { apr_err = apr_strftime (timestr, &size, (timestr).sizeof, "%b %d %H:%M", &exp_time); } else { apr_err = apr_strftime (timestr, &size, (timestr).sizeof, "%b %d %Y", &exp_time); } if (apr_err) timestr[0] = '\0'; Dobject row = new Dobject(Dobject.getPrototype()); row.Put("created_rev", cast(d_number) dirent.created_rev, 0); row.Put("last_author", dirent.last_author ? std.string.toString(cast(char *) dirent.last_author) : " ? ", 0); row.Put("size", cast(d_number) dirent.size, 0); row.Put("time", std.string.toString(timestr) , 0); row.Put("time_t", cast(d_number) apr_time_sec(dirent.time), 0); row.Put("name", std.string.toString(cast(char *) utf8_entryname),0); row.Put("type", (dirent.kind == svn_node_dir) ? "dir" : "file",1); ret_arr.Put(i,row,0); } ret.putVobject(ret_array); apr_pool_destroy(_arg_subpool); */ ret.putVundefined(); jscode: end houtFile: Svn hfile: svn_auth.h class: Svn jsClass: Svn.Auth prefix: svn_auth_ ctype: static jscode: svn_auth_set_parameter /* dsWrapped_svn_client_ctx_t sthis = dsWrapped_svn_client_ctx_t.newWrapper(); char* _arg_key = arglist[0].vtype == V_NULL ? null : std.string.toStringz(arglist[0].toString()); char* _arg_value = arglist[0].vtype == V_NULL ? null : std.string.toStringz(arglist[1].toString()); Wrapped_svn_client_ctx_t* _arg_ctx = cast(Wrapped_svn_client_ctx_t*) (sthis.getStruct()); svn_auth_set_parameter(ctx.auth_baton, apr_pstrdup(sthis.pool, _arg_key), apr_pstrdup(sthis.pool, _arg_value)); */ ret.putVundefined(); jscode: end houtFile: Auth structDump: svn_version_t structDump: svn_client_proplist_item_t structDump: svn_client_commit_item2_t structDump: svn_client_diff_summarize_t