Update for new keydata interface.
[catacomb-perl] / key.xs
CommitLineData
660b443c 1# ---?---
2#
a1a90aaf 3# $Id$
660b443c 4#
5# Key-management interface
6#
7# (c) 2001 Straylight/Edgeware
8#
9
10#----- Licensing notice -----------------------------------------------------
11#
12# This file is part of the Perl interface to Catacomb.
13#
14# Catacomb/Perl is free software; you can redistribute it and/or modify
15# it under the terms of the GNU General Public License as published by
16# the Free Software Foundation; either version 2 of the License, or
17# (at your option) any later version.
18#
19# Catacomb/Perl is distributed in the hope that it will be useful,
20# but WITHOUT ANY WARRANTY; without even the implied warranty of
21# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22# GNU General Public License for more details.
23#
24# You should have received a copy of the GNU General Public License
25# along with Catacomb/Perl; if not, write to the Free Software Foundation,
26# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
27
a1a90aaf 28MODULE = Catacomb PACKAGE = Catacomb::Key PREFIX = key_
660b443c 29
fcd15e0b 30SV *
31DESTROY(k)
32 Key *k
33 CODE:
34 keyfile_dec(k->kf);
35 DESTROY(k);
36 XSRETURN_YES;
37
a1a90aaf 38bool
39key_chkident(me, p)
40 SV *me
41 char *p
42 C_ARGS:
43 p
44
45bool
46key_chkcomment(me, p)
47 SV *me
48 char *p
49 C_ARGS:
50 p
51
52time_t
53exp(k)
54 Key *k
55 CODE:
56 RETVAL = k->k->exp;
57 OUTPUT:
58 RETVAL
59
60time_t
61del(k)
62 Key *k
63 CODE:
64 RETVAL = k->k->del;
65 OUTPUT:
66 RETVAL
67
bfdf19cb 68Key_Data *
69data(k)
a1a90aaf 70 Key *k
71 CODE:
bfdf19cb 72 RETVAL = k->k->k;
73 key_incref(RETVAL);
74 OUTPUT:
75 RETVAL
76
77KeyErr
78setdata(k, kd)
79 Key *k
80 Key_Data *kd
81 CODE:
82 RETVAL = key_setkeydata(&k->kf->kf, k->k, kd);
a1a90aaf 83 OUTPUT:
84 RETVAL
85
86char *
87comment(k)
88 Key *k
89 CODE:
90 RETVAL = k->k->c;
91 OUTPUT:
92 RETVAL
93
94U32
95id(k)
96 Key *k
97 CODE:
98 RETVAL = k->k->id;
99 OUTPUT:
100 RETVAL
101
102char *
103tag(k)
104 Key *k
105 CODE:
106 RETVAL = k->k->tag;
107 OUTPUT:
108 RETVAL
109
110char *
111type(k)
112 Key *k
113 CODE:
114 RETVAL = k->k->type;
115 OUTPUT:
116 RETVAL
117
118KeyErr
119key_setcomment(k, p)
120 Key *k
121 char *p
122 C_ARGS:
fcd15e0b 123 &k->kf->kf, k->k, p
a1a90aaf 124
125KeyErr
126key_settag(k, p)
127 Key *k
128 char *p
129 C_ARGS:
fcd15e0b 130 &k->kf->kf, k->k, p
a1a90aaf 131
132KeyErr
133key_delete(k)
134 Key *k
135 C_ARGS:
fcd15e0b 136 &k->kf->kf, k->k
a1a90aaf 137
138SV *
139fulltag(k)
140 Key *k
141 PREINIT:
142 dstr d = DSTR_INIT;
143 CODE:
144 key_fulltag(k->k, &d);
fcd15e0b 145 RETVAL = newSVpvn(d.buf, d.len);
a1a90aaf 146 dstr_destroy(&d);
147 OUTPUT:
148 RETVAL
149
150const char *
151key_getattr(k, a)
152 Key *k
153 char *a
154 C_ARGS:
fcd15e0b 155 &k->kf->kf, k->k, a
a1a90aaf 156
157KeyErr
fcd15e0b 158putattr(k, a, v = &PL_sv_undef)
a1a90aaf 159 Key *k
160 char *a
fcd15e0b 161 SV *v
162 PREINIT:
163 char *vv;
164 STRLEN len;
165 CODE:
166 if (!SvOK(v))
167 vv = 0;
168 else
169 vv = SvPV(v, len);
170 RETVAL = key_putattr(&k->kf->kf, k->k, a, vv);
171 OUTPUT:
172 RETVAL
a1a90aaf 173
fcd15e0b 174Key_AttrIter *
175attriter(k)
a1a90aaf 176 Key *k
fcd15e0b 177 CODE:
178 RETVAL = CREATE(Key_AttrIter);
179 key_mkattriter(&RETVAL->i, k->k);
180 RETVAL->kf = k->kf;
181 k->kf->ref++;
182 OUTPUT:
183 RETVAL
a1a90aaf 184
185bool
186expiredp(k)
187 Key *k
188 CODE:
189 RETVAL = key_expired(k->k);
190 OUTPUT:
191 RETVAL
192
193KeyErr
194key_expire(k)
195 Key *k
196 C_ARGS:
fcd15e0b 197 &k->kf->kf, k->k
a1a90aaf 198
199KeyErr
200key_used(k, t)
201 Key *k
202 time_t t
203 C_ARGS:
fcd15e0b 204 &k->kf->kf, k->k, t
a1a90aaf 205
206bool
fcd15e0b 207key_fingerprint(k, h, kf = 0)
a1a90aaf 208 Key *k
209 ghash *h
fcd15e0b 210 Key_Filter *kf
211 C_ARGS:
212 k->k, h, kf
a1a90aaf 213
214const char *
215key_strerror(me, err)
216 SV *me
217 int err
218 C_ARGS:
219 err
220
fcd15e0b 221MODULE = Catacomb PACKAGE = Catacomb::Key::AttrIter
222
223void
224next(i)
225 Key_AttrIter *i
226 PREINIT:
227 const char *a, *v;
228 PPCODE:
229 if (key_nextattr(&i->i, &a, &v)) {
230 XPUSHs(sv_2mortal(newSVpv(a, 0)));
231 if (GIMME_V == G_ARRAY)
232 XPUSHs(sv_2mortal(newSVpv(v, 0)));
233 }
234
235SV *
236DESTROY(i)
237 Key_AttrIter *i
238 CODE:
239 keyfile_dec(i->kf);
240 DESTROY(i);
241 XSRETURN_YES;
242
243MODULE = Catacomb PACKAGE = Catacomb::Key::Filter
244
245Key_Filter *
246new(me, f = 0, m = 0)
247 SV *me
248 SV *f
249 SV *m
250 PREINIT:
251 char *p;
252 STRLEN len;
253 CODE:
254 RETVAL = CREATE(Key_Filter);
255 if (!f || !SvOK(f))
256 RETVAL->f = RETVAL->m = 0;
257 else if (m) {
258 RETVAL->f = SvUV(f);
259 RETVAL->m = SvUV(m);
260 } else {
261 p = SvPV(f, len);
262 if (key_readflags(p, 0, &RETVAL->f, &RETVAL->m)) {
263 DESTROY(RETVAL);
264 RETVAL = 0;
265 }
266 }
267 OUTPUT:
268 RETVAL
269
270SV *
271DESTROY(kf)
272 Key_Filter *kf
273 CODE:
274 if (!kf)
275 XSRETURN_UNDEF;
276 DESTROY(kf);
277 XSRETURN_YES;
278
279SV *
280tostring(kf)
281 Key_Filter *kf
282 PREINIT:
283 dstr d = DSTR_INIT;
284 CODE:
285 if (!kf)
286 XSRETURN_UNDEF;
287 key_writeflags(kf->f, &d);
288 RETVAL = newSVpvn(d.buf, d.len);
289 dstr_destroy(&d);
290 OUTPUT:
291 RETVAL
292
293UV
294f(kf)
295 Key_Filter *kf
296 CODE:
297 RETVAL = kf ? kf->f : 0;
298 OUTPUT:
299 RETVAL
a1a90aaf 300
fcd15e0b 301UV
302m(kf)
303 Key_Filter *kf
304 CODE:
305 RETVAL = kf ? kf->m : 0;
306 OUTPUT:
307 RETVAL
308
bfdf19cb 309MODULE = Catacomb PACKAGE = Catacomb::Key::Data PREFIX = key_
a1a90aaf 310
311SV *
bfdf19cb 312DESTROY(kd)
313 Key_Data *kd
fcd15e0b 314 CODE:
bfdf19cb 315 key_drop(kd);
fcd15e0b 316 XSRETURN_YES;
317
bfdf19cb 318U32
319flags(kd)
320 Key_Data *kd
a1a90aaf 321 CODE:
bfdf19cb 322 RETVAL = kd->e;
323 OUTPUT:
324 RETVAL
a1a90aaf 325
bfdf19cb 326void
327readflags(me, p)
328 SV *me
329 char *p
a1a90aaf 330 PREINIT:
bfdf19cb 331 unsigned f, m;
332 PPCODE:
333 if (key_readflags(p, &p, &f, &m) || *p)
334 croak("bad flags string");
335 XPUSHs(sv_2mortal(newSVuv(m)));
336 XPUSHs(sv_2mortal(newSVuv(f)));
a1a90aaf 337
338SV *
bfdf19cb 339getflags(me, f)
340 SV *me
341 U32 f
a1a90aaf 342 PREINIT:
bfdf19cb 343 dstr d = DSTR_INIT;
a1a90aaf 344 CODE:
bfdf19cb 345 key_writeflags(f, &d);
346 RETVAL = newSVpvn(d.buf, d.len);
347 dstr_destroy(&d);
348 OUTPUT:
349 RETVAL
a1a90aaf 350
351SV *
bfdf19cb 352setflags(kd, f)
353 Key_Data *kd
354 U32 f
a1a90aaf 355 CODE:
bfdf19cb 356 kd->e = (kd->e & KF_ENCMASK) | (f & ~KF_ENCMASK);
a1a90aaf 357 XSRETURN_YES;
358
bfdf19cb 359void
360read(me, p)
361 SV *me
a1a90aaf 362 char *p
bfdf19cb 363 PREINIT:
364 key_data *kd;
365 char *pp;
366 PPCODE:
367 if ((kd = key_read(p, &pp)) != 0) {
368 XPUSHs(RET(kd, keydata_type(kd)));
369 if (GIMME_V == G_ARRAY)
370 XPUSHs(sv_2mortal(newSVpvn(pp, strlen(pp))));
371 }
a1a90aaf 372
373SV *
bfdf19cb 374write(kd, kf = 0)
375 Key_Data *kd
376 Key_Filter *kf
377 PREINIT:
378 dstr d = DSTR_INIT;
a1a90aaf 379 CODE:
bfdf19cb 380 if (key_write(kd, &d, kf))
381 RETVAL = newSVpvn(d.buf, d.len);
382 else
383 RETVAL = &PL_sv_undef;
384 dstr_destroy(&d);
385 OUTPUT:
a1a90aaf 386 RETVAL
387
bfdf19cb 388Key_Data *
389decode(me, sv)
390 SV *me
391 SV *sv
392 PREINIT:
393 char *p;
394 STRLEN len;
a1a90aaf 395 CODE:
bfdf19cb 396 p = SvPV(sv, len);
397 RETVAL = key_decode(p, len);
a1a90aaf 398 OUTPUT:
399 RETVAL
400
401SV *
bfdf19cb 402encode(kd, kf = 0)
403 Key_Data *kd
404 Key_Filter *kf
405 PREINIT:
406 dstr d = DSTR_INIT;
a1a90aaf 407 CODE:
bfdf19cb 408 if (key_encode(kd, &d, kf))
409 RETVAL = newSVpvn(d.buf, d.len);
410 else
411 RETVAL = &PL_sv_undef;
412 dstr_destroy(&d);
a1a90aaf 413 OUTPUT:
414 RETVAL
415
bfdf19cb 416Key_Data *
417lock(kd, key)
418 Key_Data *kd
419 SV *key
420 PREINIT:
421 STRLEN len;
422 char *p;
a1a90aaf 423 CODE:
bfdf19cb 424 p = SvPV(key, len);
425 key_lock(&RETVAL, kd, p, len);
a1a90aaf 426 OUTPUT:
427 RETVAL
428
bfdf19cb 429Key_Data *
430plock(kd, tag)
431 Key_Data *kd
432 char *tag
433 PREINIT:
434 int rc;
a1a90aaf 435 CODE:
bfdf19cb 436 if ((rc = key_plock(&RETVAL, kd, tag)) != 0) {
437 keyerr(rc);
438 RETVAL = 0;
439 }
a1a90aaf 440 OUTPUT:
441 RETVAL
442
bfdf19cb 443bool
444key_match(kd, kf)
445 Key_Data *kd
446 Key_Filter *kf
447
448MODULE = Catacomb PACKAGE = Catacomb::Key::Data::Binary PREFIX = key_
449
450Key_Data *
451new(me, sv, f = 0)
452 SV *me
453 SV *sv
454 unsigned f
455 PREINIT:
456 char *p;
457 STRLEN len;
a1a90aaf 458 CODE:
bfdf19cb 459 p = SvPV(sv, len);
460 RETVAL = key_newbinary(f, p, len);
a1a90aaf 461 OUTPUT:
462 RETVAL
463
464SV *
bfdf19cb 465bin(kd)
466 Key_Data *kd
a1a90aaf 467 CODE:
bfdf19cb 468 RETVAL = newSVpvn((char *)kd->u.k.k, kd->u.k.sz);
469 OUTPUT:
470 RETVAL
a1a90aaf 471
bfdf19cb 472MODULE = Catacomb PACKAGE = Catacomb::Key::Data::Encrypted PREFIX = key_
a1a90aaf 473
bfdf19cb 474Key_Data *
475new(me, sv, f = 0)
476 SV *me
477 SV *sv
478 unsigned f
479 PREINIT:
480 char *p;
481 STRLEN len;
fcd15e0b 482 CODE:
bfdf19cb 483 p = SvPV(sv, len);
484 RETVAL = key_newencrypted(f, p, len);
fcd15e0b 485 OUTPUT:
486 RETVAL
a1a90aaf 487
488SV *
bfdf19cb 489ct(kd)
490 Key_Data *kd
a1a90aaf 491 CODE:
bfdf19cb 492 RETVAL = newSVpvn((char *)kd->u.k.k, kd->u.k.sz);
fcd15e0b 493 OUTPUT:
494 RETVAL
495
bfdf19cb 496SV *
fcd15e0b 497lock(kd, key)
bfdf19cb 498 Key_Data *kd
fcd15e0b 499 SV *key
a1a90aaf 500 CODE:
bfdf19cb 501 croak("already encrypted");
502
503SV *
504plock(kd, tag)
505 Key_Data *kd
506 char *tag
507 CODE:
508 croak("already encrypted");
a1a90aaf 509
bfdf19cb 510Key_Data *
fcd15e0b 511unlock(kd, key)
bfdf19cb 512 Key_Data *kd
fcd15e0b 513 SV *key
a1a90aaf 514 PREINIT:
fcd15e0b 515 STRLEN len;
516 char *p;
517 int rc;
a1a90aaf 518 CODE:
fcd15e0b 519 p = SvPV(key, len);
bfdf19cb 520 if ((rc = key_unlock(&RETVAL, kd, p, len)) != 0) {
fcd15e0b 521 keyerr(rc);
a1a90aaf 522 RETVAL = 0;
523 }
524 OUTPUT:
525 RETVAL
526
bfdf19cb 527Key_Data *
528punlock(kd, tag)
529 Key_Data *kd
a1a90aaf 530 char *tag
fcd15e0b 531 PREINIT:
532 int rc;
a1a90aaf 533 CODE:
bfdf19cb 534 if ((rc = key_punlock(&RETVAL, kd, tag)) != 0) {
fcd15e0b 535 keyerr(rc);
a1a90aaf 536 RETVAL = 0;
537 }
538 OUTPUT:
539 RETVAL
540
bfdf19cb 541MODULE = Catacomb PACKAGE = Catacomb::Key::Data::MP PREFIX = key_
542
543Key_Data *
544new(me, x, f = 0)
545 SV *me
546 mp *x
547 unsigned f
a1a90aaf 548 CODE:
bfdf19cb 549 RETVAL = key_newmp(f, x);
a1a90aaf 550 OUTPUT:
551 RETVAL
552
bfdf19cb 553mp *
554mp(kd)
555 Key_Data *kd
556 CODE:
557 RETVAL = MP_COPY(kd->u.m);
558 OUTPUT:
559 RETVAL
560
561MODULE = Catacomb PACKAGE = Catacomb::Key::Data::EC PREFIX = key_
562
563Key_Data *
564new(me, p, f = 0)
a1a90aaf 565 SV *me
bfdf19cb 566 ec *p
567 unsigned f
568 CODE:
569 RETVAL = key_newec(f, p);
570 OUTPUT:
571 RETVAL
a1a90aaf 572
bfdf19cb 573ec *
574ec(kd)
575 Key_Data *kd
a1a90aaf 576 CODE:
bfdf19cb 577 RETVAL = CREATE(ec);
578 EC_CREATE(RETVAL);
579 EC_COPY(RETVAL, &kd->u.e);
a1a90aaf 580 OUTPUT:
581 RETVAL
582
bfdf19cb 583MODULE = Catacomb PACKAGE = Catacomb::Key::Data::String PREFIX = key_
584
585Key_Data *
586new(me, p, f = 0)
a1a90aaf 587 SV *me
bfdf19cb 588 char *p
589 unsigned f
a1a90aaf 590 CODE:
bfdf19cb 591 RETVAL = key_newstring(f, p);
a1a90aaf 592 OUTPUT:
593 RETVAL
594
bfdf19cb 595char *
596str(kd)
597 Key_Data *kd
a1a90aaf 598 CODE:
bfdf19cb 599 RETVAL = kd->u.p;
600 OUTPUT:
601 RETVAL
602
603MODULE = Catacomb PACKAGE = Catacomb::Key::Data::Structured PREFIX = key_
604
605Key_Data *
606new()
607 CODE:
608 RETVAL = key_newstruct();
609 OUTPUT:
610 RETVAL
611
612Key_StructIter *
613iterate(kd)
614 Key_Data *kd
615 CODE:
616 RETVAL = CREATE(Key_StructIter);
617 sym_mkiter(RETVAL, &kd->u.s);
618 OUTPUT:
619 RETVAL
620
621Key_Data *
622find(kd, tag)
623 Key_Data *kd
624 char *tag
625 CODE:
626 RETVAL = key_structfind(kd, tag);
627 if (RETVAL) key_incref(RETVAL);
a1a90aaf 628 OUTPUT:
629 RETVAL
660b443c 630
bfdf19cb 631SV *
632del(kd, tag)
633 Key_Data *kd
634 char *tag
635 CODE:
636 key_structset(kd, tag, 0);
637 XSRETURN_YES;
638
639SV *
640set(kd, tag, kdnew = 0)
641 Key_Data *kd
642 char *tag
643 Key_Data *kdnew
644 CODE:
645 key_structset(kd, tag, kdnew);
646 XSRETURN_YES;
647
fcd15e0b 648MODULE = Catacomb PACKAGE = Catacomb::Key::StructIter
649
650SV *
651next(i)
652 Key_StructIter *i
653 PREINIT:
654 key_struct *s;
655 CODE:
656 if ((s = sym_next(i)) == 0)
657 XSRETURN_UNDEF;
658 RETVAL = newSVpvn(SYM_NAME(s), SYM_LEN(s));
659 OUTPUT:
660 RETVAL
661
662SV *
663DESTROY(i)
664 Key_StructIter *i
665 CODE:
666 DESTROY(i);
667 XSRETURN_YES;
668
669MODULE = Catacomb PACKAGE = Catacomb::Key::Data
670
660b443c 671MODULE = Catacomb PACKAGE = Catacomb::Key::File PREFIX = key_
672
673Key_File *
fcd15e0b 674new(me, file, how = KOPEN_READ, report = &PL_sv_undef)
a1a90aaf 675 SV *me
660b443c 676 char *file
677 unsigned how
fcd15e0b 678 SV *report
660b443c 679 CODE:
680 RETVAL = CREATE(key_file);
fcd15e0b 681 if (key_open(&RETVAL->kf, file, how, keyreport, report)) {
660b443c 682 DESTROY(RETVAL);
683 RETVAL = 0;
684 }
685 OUTPUT:
686 RETVAL
687
688SV *
689DESTROY(kf)
690 Key_File *kf
691 CODE:
fcd15e0b 692 keyfile_dec(kf);
660b443c 693 XSRETURN_UNDEF;
694
a1a90aaf 695KeyErr
fcd15e0b 696merge(kf, name, fp, report = &PL_sv_undef)
660b443c 697 Key_File *kf
698 char *name
699 FILE *fp
fcd15e0b 700 SV *report
660b443c 701 CODE:
fcd15e0b 702 RETVAL = key_merge(&kf->kf, name, fp, keyreport, report);
660b443c 703 OUTPUT:
704 RETVAL
705
a1a90aaf 706bool
fcd15e0b 707key_extract(kf, k, fp, kfilt = 0)
a1a90aaf 708 Key_File *kf
709 Key *k
710 FILE *fp
fcd15e0b 711 Key_Filter *kfilt
712 C_ARGS:
713 &kf->kf, k->k, fp, kfilt
a1a90aaf 714
bfdf19cb 715void
716qtag(kf, tag, kdnew = 0)
717 Key_File *kf
718 char *tag
719 Key_Data *kdnew
720 PREINIT:
721 dstr d = DSTR_INIT;
722 key_data **kd;
723 key_data *okd;
724 key *k;
725 Key *kk;
726 PPCODE:
727 if (key_qtag(&kf->kf, tag, &d, &k, &kd)) {
728 keyerr(KERR_NOTFOUND);
729 XSRETURN_UNDEF;
730 }
731 okd = *kd;
732 if (kdnew) {
733 if (!(kf->kf.f & KF_WRITE)) {
734 keyerr(KERR_READONLY);
735 XSRETURN_UNDEF;
736 }
737 kf->kf.f |= KF_MODIFIED;
738 *kd = kdnew;
739 }
740 key_incref(*kd);
741 kk = CREATE(Key);
742 kk->k = k;
743 kk->kf = kf;
744 kf->ref++;
745 XPUSHs(sv_2mortal(newSVpvn(d.buf, d.len)));
746 XPUSHs(RET(kk, "Catacomb::Key"));
747 XPUSHs(RET(okd, keydata_type(okd)));
748 dstr_destroy(&d);
749
a1a90aaf 750int
751key_save(kf)
752 Key_File *kf
fcd15e0b 753 C_ARGS:
754 &kf->kf
a1a90aaf 755
756Key *
757bytype(kf, type)
758 Key_File *kf
759 char *type
760 CODE:
761 RETVAL = CREATE(Key);
fcd15e0b 762 if ((RETVAL->k = key_bytype(&kf->kf, type)) != 0) {
763 kf->ref++;
a1a90aaf 764 RETVAL->kf = kf;
fcd15e0b 765 } else {
a1a90aaf 766 DESTROY(RETVAL);
767 RETVAL = 0;
768 }
769 OUTPUT:
770 RETVAL
771
772Key *
773byid(kf, id)
774 Key_File *kf
775 U32 id
776 CODE:
777 RETVAL = CREATE(Key);
fcd15e0b 778 if ((RETVAL->k = key_byid(&kf->kf, id)) != 0) {
779 kf->ref++;
a1a90aaf 780 RETVAL->kf = kf;
fcd15e0b 781 } else {
a1a90aaf 782 DESTROY(RETVAL);
783 RETVAL = 0;
784 }
785 OUTPUT:
786 RETVAL
787
788Key *
789bytag(kf, tag)
790 Key_File *kf
791 char *tag
792 CODE:
793 RETVAL = CREATE(Key);
fcd15e0b 794 if ((RETVAL->k = key_bytag(&kf->kf, tag)) != 0) {
795 kf->ref++;
a1a90aaf 796 RETVAL->kf = kf;
fcd15e0b 797 } else {
a1a90aaf 798 DESTROY(RETVAL);
799 RETVAL = 0;
800 }
801 OUTPUT:
802 RETVAL
803
fcd15e0b 804Key *
bfdf19cb 805newkey(kf, id, type, exp = KEXP_FOREVER)
a1a90aaf 806 Key_File *kf
fcd15e0b 807 U32 id
808 const char *type
809 time_t exp
a1a90aaf 810 PREINIT:
fcd15e0b 811 int err;
812 CODE:
813 RETVAL = CREATE(Key);
bfdf19cb 814 if ((err = key_new(&kf->kf, id, type, exp, &RETVAL->k)) == 0) {
fcd15e0b 815 DESTROY(RETVAL);
816 keyerr(err);
817 RETVAL = 0;
818 } else {
819 kf->ref++;
820 RETVAL->kf = kf;
821 }
822 OUTPUT:
823 RETVAL
fcd15e0b 824
825Key_FileIter *
826iterate(kf)
827 Key_File *kf
828 CODE:
829 RETVAL = CREATE(Key_FileIter);
830 key_mkiter(&RETVAL->i, &kf->kf);
831 RETVAL->kf = kf;
832 kf->ref++;
833 OUTPUT:
834 RETVAL
835
836MODULE = Catacomb PACKAGE = Catacomb::Key::FileIter
837
838Key *
839next(ki)
840 Key_FileIter *ki
841 CODE:
842 RETVAL = CREATE(Key);
843 if ((RETVAL->k = key_next(&ki->i)) == 0) {
844 DESTROY(RETVAL);
845 RETVAL = 0;
846 } else {
847 RETVAL->kf = ki->kf;
848 ki->kf->ref++;
a1a90aaf 849 }
fcd15e0b 850 OUTPUT:
851 RETVAL
852
853SV *
854DESTROY(ki)
855 Key_FileIter *ki
856 CODE:
857 keyfile_dec(ki->kf);
858 DESTROY(ki);
859 XSRETURN_YES;
660b443c 860
861#----- That's all, folks ----------------------------------------------------