/usr/share/jed/jed-extra/dict-curl.sl is in jed-extra 2.5.7-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 | % dict-curl.sl: a backend to dict mode using the curl module
%
% Copyright (c) 2006 Paul Boekholt
% Released under the terms of the GNU General Public License (ver. 2 or later)
%
% Usage
% -----
%
% Place in the jed library path. If dict-cli.sl is in the path as
% well but you prefer the curl interface, set the custom variable
% Dict_Backends, e.g. in jed.rc
%
% variable Dict_Backends = "dict-curl.sl";
%
% Versions:
% ---------
%
% 0.1 2006-03-03 First public version
% 0.2 2006-09-27 dollar strings caused segfaults with slang 2.0.6
% fized lookup of multi word keywords
% 0.3 2006-09-28 Removed quoting of multi word keywords again after
% upgrading to libcurl 7.15
require("curl");
provide("dict-backend");
provide("dict-curl");
private define write_callback (v, data)
{
insert(data);
return 0;
}
private define do_curl()
{
variable args=__pop_args(_NARGS);
variable v;
variable c = curl_new (sprintf(__push_args(args)));
curl_setopt (c, CURLOPT_WRITEFUNCTION, &write_callback, &v);
curl_perform (c);
}
define dict_define(word, database, host)
{
variable db, line;
foreach db (strtok(database, ","))
do_curl("dict://%s/d:%s:%s", host, word, db);
bob();
replace("\r", "");
push_mark();
forever
{
!if (bol_fsearch("151 "))
{
eob();
del_region();
bob();
return;
}
% convert
% 151 "mode" jargon "Jargon File (4.4.4, 14 Aug 2003)"
% to
% From "Jargon File (4.4.4, 14 Aug 2003)" [jargon]:
push_mark_eol();
line = strtok(bufsubstr_delete(), " ");
db = line[2];
line = strjoin(line[[3:]], " ");
go_down_1();
del_region();
vinsert("From %s [%s]:\n", line, db);
while (bol_fsearch("."))
{
if (looking_at(".."))
{
del();
eol();
}
else
{
push_mark();
break;
}
}
}
}
define dict_match(word, strategy, database, host)
{
variable db;
foreach db (strtok(database, ","))
do_curl("dict://%s/m:%s:%s:%s", host, word, db, strategy);
bob();
replace("\r", "");
push_mark();
forever
{
!if (bol_fsearch("152 "))
{
eob();
del_region();
bob();
return;
}
go_down_1();
del_region();
push_spot();
while (bol_fsearch("."))
{
if (looking_at(".."))
{
del();
eol();
}
else
{
push_mark();
break;
}
}
}
}
define dict_show(what, host)
{
do_curl("dict://%s/show:%s", host, what);
bob();
replace("\r", "");
bob();
if(bol_fsearch("110")) delete_line();
bob();
while(bol_fsearch(".")) del();
bob();
while(bol_fsearch("2")) delete_line();
}
|