bless $self, $class;
if (defined($href) && ref($href) eq 'HASH') {
if (!defined($map)) {
- croak "Usage: new Net::Z3950::GRS1($href, $map);";
+ croak 'Usage: new Net::Z3950::GRS1($href, $map);';
}
- $self->Hash2grs($href);
+ $self->Hash2grs($href, $map);
}
return $self;
my $key;
my $content;
my $aref;
+ my $issue;
$mapping = defined($mapping) ? $mapping : $self->{MAP};
+ $self->{MAP} = $mapping;
foreach $key (keys %$href) {
$content = $href->{$key};
+ next unless defined($content);
if (!defined($aref = $mapping->{$key})) {
print STDERR "Hash2grs: Unmapped key: '$key'\n";
next;
}
if (ref($content) eq 'HASH') { ## Subtree?
- my $subtree = new Net::Z3950::GRS1($content);
+ my $subtree = new Net::Z3950::GRS1($content, $mapping);
$self->AddElement($aref->[0], $aref->[1], &Net::Z3950::GRS1::ElementData::Subtree, $subtree);
- } elsif (ref($content) eq '') { ## Regular string?
+ } elsif (!ref($content)) { ## Regular string?
$self->AddElement($aref->[0], $aref->[1], &Net::Z3950::GRS1::ElementData::String, $content);
+ } elsif (ref($content) eq 'ARRAY') {
+ my $issues = new Net::Z3950::GRS1;
+ foreach $issue (@$content) {
+ my $entry = new Net::Z3950::GRS1($issue, $mapping);
+ $issues->AddElement(5, 1, &Net::Z3950::GRS1::ElementData::Subtree, $entry);
+ }
+ $self->AddElement($aref->[0], $aref->[1], &Net::Z3950::GRS1::ElementData::Subtree, $issues);
} else {
print STDERR "Hash2grs: Unsupported content type\n";
next;
}
}
}
+
+
sub GetElementList {
my $self = shift;
=cut
#$Log: GRS1.pm,v $
-#Revision 1.4 2001-05-17 14:07:06 sondberg
+#Revision 1.5 2001-05-21 11:07:02 sondberg
+#Extended maximum numbers of GRS-1 elements. Should be done dynamically.
+#
+#Revision 1.4 2001/05/17 14:07:06 sondberg
#Added some documentation.
#
#Revision 1.3 2001/05/17 13:43:04 sondberg
*/
/*$Log: SimpleServer.c,v $
-/*Revision 1.9 2001-05-17 13:43:04 sondberg
-/*Added method Hash2grs into GRS1 module.
+/*Revision 1.10 2001-05-21 11:07:02 sondberg
+/*Extended maximum numbers of GRS-1 elements. Should be done dynamically.
/*
/*Revision 1.7 2001/03/13 14:17:15 sondberg
/*Added support for GRS-1.
#include <unistd.h>
#include <stdlib.h>
#include <ctype.h>
-#define GRS_MAX_FIELDS 50
+#define GRS_MAX_FIELDS 500
#ifdef ASN_COMPILED
#include <yaz/ill.h>
#endif
odr_malloc(o, sizeof(Z_TaggedElement*) * GRS_MAX_FIELDS);
r->num_elements = 0;
}
+ if (r->num_elements > GRS_MAX_FIELDS)
+ {
+ yaz_log(LOG_WARN, "Max number of GRS-1 elements exceeded [GRS_MAX_FIELDS=%d]", GRS_MAX_FIELDS);
+ exit(0);
+ }
r->elements[r->num_elements] = t = (Z_TaggedElement *) odr_malloc(o, sizeof(Z_TaggedElement));
t->tagType = (int *)odr_malloc(o, sizeof(int));
*t->tagType = type;
}
-#line 912 "SimpleServer.c"
+#line 917 "SimpleServer.c"
XS(XS_Net__Z3950__SimpleServer_set_init_handler)
{
dXSARGS;
Perl_croak(aTHX_ "Usage: Net::Z3950::SimpleServer::set_init_handler(arg)");
{
SV * arg = ST(0);
-#line 908 "SimpleServer.xs"
+#line 913 "SimpleServer.xs"
init_ref = newSVsv(arg);
-#line 922 "SimpleServer.c"
+#line 927 "SimpleServer.c"
}
XSRETURN_EMPTY;
}
Perl_croak(aTHX_ "Usage: Net::Z3950::SimpleServer::set_close_handler(arg)");
{
SV * arg = ST(0);
-#line 915 "SimpleServer.xs"
+#line 920 "SimpleServer.xs"
close_ref = newSVsv(arg);
-#line 936 "SimpleServer.c"
+#line 941 "SimpleServer.c"
}
XSRETURN_EMPTY;
}
Perl_croak(aTHX_ "Usage: Net::Z3950::SimpleServer::set_sort_handler(arg)");
{
SV * arg = ST(0);
-#line 922 "SimpleServer.xs"
+#line 927 "SimpleServer.xs"
sort_ref = newSVsv(arg);
-#line 950 "SimpleServer.c"
+#line 955 "SimpleServer.c"
}
XSRETURN_EMPTY;
}
Perl_croak(aTHX_ "Usage: Net::Z3950::SimpleServer::set_search_handler(arg)");
{
SV * arg = ST(0);
-#line 928 "SimpleServer.xs"
+#line 933 "SimpleServer.xs"
search_ref = newSVsv(arg);
-#line 964 "SimpleServer.c"
+#line 969 "SimpleServer.c"
}
XSRETURN_EMPTY;
}
Perl_croak(aTHX_ "Usage: Net::Z3950::SimpleServer::set_fetch_handler(arg)");
{
SV * arg = ST(0);
-#line 935 "SimpleServer.xs"
+#line 940 "SimpleServer.xs"
fetch_ref = newSVsv(arg);
-#line 978 "SimpleServer.c"
+#line 983 "SimpleServer.c"
}
XSRETURN_EMPTY;
}
Perl_croak(aTHX_ "Usage: Net::Z3950::SimpleServer::set_present_handler(arg)");
{
SV * arg = ST(0);
-#line 942 "SimpleServer.xs"
+#line 947 "SimpleServer.xs"
present_ref = newSVsv(arg);
-#line 992 "SimpleServer.c"
+#line 997 "SimpleServer.c"
}
XSRETURN_EMPTY;
}
Perl_croak(aTHX_ "Usage: Net::Z3950::SimpleServer::set_esrequest_handler(arg)");
{
SV * arg = ST(0);
-#line 949 "SimpleServer.xs"
+#line 954 "SimpleServer.xs"
esrequest_ref = newSVsv(arg);
-#line 1006 "SimpleServer.c"
+#line 1011 "SimpleServer.c"
}
XSRETURN_EMPTY;
}
Perl_croak(aTHX_ "Usage: Net::Z3950::SimpleServer::set_delete_handler(arg)");
{
SV * arg = ST(0);
-#line 956 "SimpleServer.xs"
+#line 961 "SimpleServer.xs"
delete_ref = newSVsv(arg);
-#line 1020 "SimpleServer.c"
+#line 1025 "SimpleServer.c"
}
XSRETURN_EMPTY;
}
Perl_croak(aTHX_ "Usage: Net::Z3950::SimpleServer::set_scan_handler(arg)");
{
SV * arg = ST(0);
-#line 963 "SimpleServer.xs"
+#line 968 "SimpleServer.xs"
scan_ref = newSVsv(arg);
-#line 1034 "SimpleServer.c"
+#line 1039 "SimpleServer.c"
}
XSRETURN_EMPTY;
}
{
dXSARGS;
{
-#line 969 "SimpleServer.xs"
+#line 974 "SimpleServer.xs"
char **argv;
char **argv_buf;
char *ptr;
int i;
STRLEN len;
-#line 1049 "SimpleServer.c"
+#line 1054 "SimpleServer.c"
int RETVAL;
dXSTARG;
-#line 975 "SimpleServer.xs"
+#line 980 "SimpleServer.xs"
argv_buf = (char **)xmalloc((items + 1) * sizeof(char *));
argv = argv_buf;
for (i = 0; i < items; i++)
*argv_buf = NULL;
RETVAL = statserv_main(items, argv, bend_init, bend_close);
-#line 1064 "SimpleServer.c"
+#line 1069 "SimpleServer.c"
XSprePUSH; PUSHi((IV)RETVAL);
}
XSRETURN(1);
*/
/*$Log: SimpleServer.xs,v $
-/*Revision 1.7 2001-03-13 14:17:15 sondberg
+/*Revision 1.8 2001-05-21 11:07:02 sondberg
+/*Extended maximum numbers of GRS-1 elements. Should be done dynamically.
+/*
+/*Revision 1.7 2001/03/13 14:17:15 sondberg
/*Added support for GRS-1.
/**/
#include <unistd.h>
#include <stdlib.h>
#include <ctype.h>
-#define GRS_MAX_FIELDS 50
+#define GRS_MAX_FIELDS 500
#ifdef ASN_COMPILED
#include <yaz/ill.h>
#endif
odr_malloc(o, sizeof(Z_TaggedElement*) * GRS_MAX_FIELDS);
r->num_elements = 0;
}
+ if (r->num_elements > GRS_MAX_FIELDS)
+ {
+ yaz_log(LOG_WARN, "Max number of GRS-1 elements exceeded [GRS_MAX_FIELDS=%d]", GRS_MAX_FIELDS);
+ exit(0);
+ }
r->elements[r->num_elements] = t = (Z_TaggedElement *) odr_malloc(o, sizeof(Z_TaggedElement));
t->tagType = (int *)odr_malloc(o, sizeof(int));
*t->tagType = type;