From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29814 invoked by alias); 8 Jun 2017 10:04:22 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 41256 Received: (qmail 26509 invoked from network); 8 Jun 2017 10:04:22 -0000 X-Qmail-Scanner-Diagnostics: from aok120.rev.netart.pl by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(85.128.245.120):SA:0(0.0/5.0):. Processed in 2.16589 secs); 08 Jun 2017 10:04:22 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=unavailable autolearn_force=no version=3.4.1 X-Envelope-From: psprint@zdharma.org X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: none (ns1.primenet.com.au: domain at zdharma.org does not designate permitted sender hosts) X-Virus-Scanned: by amavisd-new using ClamAV (11) Date: Thu, 8 Jun 2017 12:04:06 +0200 From: Sebastian Gniazdowski To: Bart Schaefer , zsh-workers@zsh.org Message-ID: In-Reply-To: <170607091113.ZM17152@torch.brasslantern.com> References: <170607091113.ZM17152@torch.brasslantern.com> Subject: Re: Return value from execstring(), or construct Options for a builtin? X-Mailer: Airmail (231) MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline On 7 czerwca 2017 at 18:11:30, Bart Schaefer (schaefer=40brasslantern.com= ) wrote: > On Jun 7, 12:20pm, Sebastian Gniazdowski wrote: > =7D > =7D backend=5Fcmd =3D =22zrtie=22; // (or =22zgtie=22) > =7D execstring(backend=5Fcmd, 1, 0, =22ztie=22); > =20 > I believe this is very much the wrong way to do this (even though I > suggested it as a solution for a different specific problem). I tried the parameter-way, to pass to backend via ZSH=5FDATABASE=5FSPEC. = No problem with builtintab searching, it's fixed. > The right thing would be to handle this the way that ZLE entry points > are managed (see Src/init.c:zleentry), with one module to contain ztie > and related functions which makes an entry point call back to the chose= n > backend module. I depend on coffee, which has ended for today, worked for 6 hours on the = zleentry-way, I think I got it. I declare the following in db.c: /* =46or casts, as below mod=5Fexport variables are void-no-arguments */ typedef int (*DbBackendEntryPoint)(VA=5FALIST1(int cmd)); /**/ mod=5Fexport void (*backend=5Fgdbm=5Fentry=5Fptr)(); /**/ mod=5Fexport void (*backend=5Fredis=5Fentry=5Fptr)(); /**/ mod=5Fexport void (*backend=5Fcustom1=5Fentry=5Fptr)(); ... There are three custom =22db/custom=5B0-9=5D=22 backends. This way a cust= om module can attach, or also, it can fully replace db.c and provide own = above variables in its custom db.c. In backend I include db.epro, to have= the declarations of above vars, but backend module can just define own e= xterns. This is to not depend on zsh.h. =46or this I also used macros not= enum, for command ids. > The decisions about how to abstract bin=5Fztie et al. from gdbm should = be > made by discussion with this group, not by you racing ahead on your own= . > Proposed approaches are of course welcome (see for example the discussi= on > about numeric sorting). This goes on me, coffee+interesting topic+coding. Hope current method is = OK, if not I can change. I've commited zredis plugin using two modules: https://github.com/zdharma/zredis/blob/master/module/Src/zdharma/db.c https://github.com/zdharma/zredis/blob/master/module/Src/zdharma/zredis.c= =46rom the last one, on-topic are functions=C2=A0redis=5Fmain=5Fentry,=C2= =A0zrtie=5Fcmd and=C2=A0zruntie=5Fcmd. -- Sebastian Gniazdowski psprint /at/ zdharma.org