Article View: pl.comp.lang.perl
Article #464Re: XSUBy...
From: Piotr Auksztulewicz
Date: Thu, 31 Jul 1997 14:20
Date: Thu, 31 Jul 1997 14:20
59 lines
2324 bytes
2324 bytes
Piotr Auksztulewicz (piotras@polsl.gliwice.pl) wrote:
: pomalu mi cos wychodzi, ale z duzym bolem. Znowu utknalem na takim czyms,
: co mi nie dziala i nie wiem dlaczego...
No tak. Tego sie mozna bylo spodziewac. Glupi blad najtrudniej znalezc.
K....! dwa dni sie meczylem, zanim znalazlem blad. Zagadka dla was:
co tu jest zle i dlaczego. Dla pierwszego, kto zgadnie, stawiam piwo
w Casa Austria w Gliwicach (fajna knajpa, BTW).
Hint: nie trzeba znac perla, wystarczy znac C!
#include <hpsecurity.h>
#include <prot.h>
MODULE = Auth::Hpsecurity PACKAGE = Auth::Hpsecurity
/* tu bylo jeszcze pare funkcji, ale one dzialaly... */
int
putprpwnam(name, href)
char *name
SV *href
PROTOTYPE: $\%
CODE:
if (!SvROK(href) || SvTYPE(SvRV(href)) != SVt_PVHV)
croak("Second argument is not a reference to a hash");
else {
HV *hash = (HV *)SvRV(href);
SV *item;
char *string;
STRLEN slen;
struct pr_passwd pswd;
memset(&pswd, sizeof(pswd), 0);
if (hv_exists(hash, AUTH_U_NAME, strlen(AUTH_U_NAME))) {
pswd.uflg.fg_name = 1;
item = *hv_fetch(hash, AUTH_U_NAME, strlen(AUTH_U_NAME), 0);
string = SvPV(item, slen);
strncpy(pswd.ufld.fd_name, string, slen);
pswd.ufld.fd_name[slen] = '\0';
}
if (hv_exists(hash, AUTH_U_ID, strlen(AUTH_U_ID))) {
pswd.uflg.fg_uid = 1;
item = *hv_fetch(hash, AUTH_U_ID, strlen(AUTH_U_ID), 0);
pswd.ufld.fd_uid = SvIV(item);
}
/* itd. itp. wiecej takich if'ow ... */
RETVAL = putprpwnam(name, &pswd);
}
OUTPUT:
RETVAL
--
Piotr Auksztulewicz piotras@zeus.polsl.gliwice.pl
Centrum Komputerowe Politechniki Slaskiej, Gliwice, Akademicka 16
Technical Details
Message-ID:
<5rq6us$iv2@zeus.polsl.gliwice.pl>Path:
mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!pingwin.icm.edu.pl!agh.edu.pl!news.wnaft.agh.edu.pl!polsl.gliwice.pl!polsl.gliwice.pl!not-for-mailReferences:
<5rnkee$idf@zeus.polsl.gliwice.pl>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!pingwin.icm.edu.pl!agh.edu.pl!news.wnaft.agh.edu.pl!polsl.gliwice.pl!polsl.gliwice.pl!not-for-mail From: piotras@polsl.gliwice.pl (Piotr Auksztulewicz) Newsgroups: pl.comp.lang.perl Subject: Re: XSUBy... Date: 31 Jul 1997 16:20:12 +0200 Organization: Politechnika Slaska, Gliwice Lines: 59 Message-ID: <5rq6us$iv2@zeus.polsl.gliwice.pl> References: <5rnkee$idf@zeus.polsl.gliwice.pl> NNTP-Posting-Host: zeus.polsl.gliwice.pl X-Newsreader: TIN [version 1.2 PL2] MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit