Path: csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder3.hal-mli.net!feeder.news-service.com!feeder.news-service.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Rainer Weikusat Newsgroups: comp.unix.shell,comp.unix.programmer,comp.programming.contests Subject: Re: The First Pure Shell Contest (PUSH): relativepath Date: Fri, 19 Aug 2011 22:18:15 +0100 Lines: 76 Message-ID: <87d3g185ig.fsf@sapphire.mobileactivedefense.com> References: <9b7kg7F3njU1@mid.individual.net> <87pqk18byo.fsf@sapphire.mobileactivedefense.com> <9b7rgqFiseU2@mid.individual.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: individual.net gpc5Mq2QbJfTsan15iCsbwEmtjIX8KEYTeqAZQeENiHvkU1mQ= Cancel-Lock: sha1:3Q+OyPfzbuKbcKRplSoFzpZMpLA= sha1:/LXAelfZrJLJTdbuA1slqBqfAtM= User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.2 (gnu/linux) Xref: x330-a1.tempe.blueboxinc.net comp.unix.shell:1728 comp.unix.programmer:1167 comp.programming.contests:18 Jens Schweikhardt writes: > In comp.unix.programmer Rainer Weikusat wrote: > # Jens Schweikhardt writes: > # > #> The First Pure Shell Contest (PUSH) > #> > #> == Motivation == [...] > # I spent some thoughts on this because I was interested in at least > # having a general idea how a solution could look like. OTOH, the reason > # why I work in miserably paid programming jobs is essentially because I > # enjoy solving software problems a lot more than dicksizing contests. > > Well, this is a badly paid contest :-) No prize money. People are in it, > I hope, just for the fun of it. I certainly am. I've just spent about two hours of my time (not counting the several days I need to even get to this point) with determining how to get an xauth username out of the internal racoon data structures, provided an xauth username was supposed to be provided and was actually provided. The result of that looks like this (not compiled so far): static char const *locate_xauth_user(struct ph1handle const *iph1) { #ifndef ENABLE_HYBRID return NULL; #else char const *user, *xauth_user; vchar_t const *login; unsigned len; xauth_user = NULL; if (iph1->side == INITIATOR) { if (iph1->rmconf && iph1->rmconf->xauth) { login = xauth->login; if (login) { xauth_user = login->v; len = login->l; } } } else { if (iph1->mode_cfg) { xauth_user = iph1->mode_cfg->xauth.authdata.generic.usr; if (xauth_user) len = strlen(xauth_user); } } if (!(xauth_user && len)) return NULL; /* The reason for this is that the rmconf xauth user is not 0-terminated for some idiotic reason. */ user = malloc(len + 1); if (!user) return NULL; memcpy(user, xauth_user, len); user[len] = 0; return user; #endif } This was sort-of fun (to the degree that work can be fun) because it was an intellectual challenge. But 'trying to run as fast as you can, in the hope that none of the persons living on this planet who can run faster is in the same contest' isn't. Somebody (probably, a lot of somebodies) will be able to write a faster shell function than me, and very probably not the least because I usually resent code-uglification except if necessary. NB: This is just 'my 0.02'.