1 #################################################################################################
2 #################################################################################################
3 # Subrutines to get parameters for commands from Query String (query string parsing)
4 #################################################################################################
5 #################################################################################################
10 my ($l , $r) = split(/,/,$bind,2);
11 if (index($bind ,",") == -1) { return $error{"add_no_sep"}; }
12 elsif (index($r ,",") != -1) { return $error{"add_many_sep"}; }
13 elsif (($l eq "") or ($r eq "")) { return $error{"add_null_bind"}; }
18 #addparsequery($querystring,\@binds)
22 my $query = shift(@_);
23 my $value_ptr = shift(@_);
24 if ($query eq "") { return $error{"add_no_bind"}; }
27 foreach my $params (split(/&/,$query))
29 my ($k , $v) = split(/=/,$params,2);
31 if ($k ne "bind") { return $error{"add_oth"}; }
32 elsif ($v eq "") { return $error{"add_null_bind"}; }
33 elsif (my $err=add_comma_analysis($v)) { return $err; }
34 else { push @$value_ptr,$v;}
42 my $query = shift(@_);
46 if (index($query, "&") == -1)
48 ($k , $v) = split(/=/,$query,2);
50 if ($k ne "keys") { return $error{"re_oth"}; }
51 elsif ($v eq "") { return $error{"re_null_keys"}; }
52 elsif ((index($v,",")==0) or (index($v,",,")!=-1) or (substr($v,-1) eq ","))
54 return $error{"re_null_keys"};
56 else { $_[0] = $v; return 0; }
58 else { return $error{"re_many"}; }
63 my $arr_ptr = shift(@_);
66 foreach my $el (@$arr_ptr)
68 my ($k , $v) = split(/=/,$el,2);
70 if ($k eq "param") { return $error{"apply_no_dots_param"}; }
71 elsif ($k eq "prop") { return $error{"apply_no_dots_prop"}; }
72 elsif ($k eq "xmluri")
74 if ($xmluri_found) { return $error{"apply_many_uri"}; }
77 if ($v eq "") { return $error{"apply_null_uri"}; }
78 else { $_[0] = $v; $xmluri_found = 1; }
83 if ($keys_found) { return $error{"apply_many_keys"}; }
86 if ($v eq "") { return $error{"apply_null_keys"}; }
87 elsif ((index($v,",")==0) or (index($v,",,")!=-1) or (substr($v,-1) eq ","))
89 return $error{"apply_null_keys"};
91 else { $_[1] = $v; $keys_found = 1; }
94 else { return $error{"apply_oth"}; }
95 }#foreach my $el (@$arr_ptr)
96 if ((!$xmluri_found or !$keys_found)) { return $error{"apply_few_pars"}; }
102 my $query = shift(@_);
103 my $apply_keys_ptr = shift(@_);
104 my $keyparshoh = shift(@_);
105 my $proph_ptr = shift(@_);
112 if ($query eq "") { return $error{"apply_few_pars"}; }
113 if (index($query, "&") == -1) { return $error{"apply_few_pars"}; }
114 foreach my $param (split(/&/,$query))
116 my ($k , $v) = split(/=/,$param,2);
118 if (index($k, ".") == -1) { push @nodots,$param; }
121 my ($l , $r) = split(/\./,$k,2);
124 if (($r eq "") or ($v eq "")) { return $error{"apply_null_prop"}; }
125 elsif (index($r, ".") > -1) { return $error{"apply_dots_prop"}; }
126 else { $prop_h{$r} = $v; }
128 elsif ($l eq "param")
130 if (($r eq "") or ($v eq "")) { return $error{"apply_null_param"}; }
131 elsif (index($r, ".") == -1) { $genparam_h{$r} = $v; }
134 my ($kk , $va) = split(/\./,$r,2);
135 if (index($va, ".") > -1) { return $error{"apply_dots_param"}; }
136 elsif (($kk eq "") or ($va eq "")) { return $error{"apply_null_param"}; }
137 else { $keyparam_h{$kk}{$va}=$v; }
140 else { return $error{"apply_oth"}; }
144 if (my $err = get_req(\@nodots,$_[0],$applykeys)) { return $err; }
145 while (my ($gn, $gv) = each %prop_h)
147 $proph_ptr->{$gn} = $gv;
149 foreach my $pkey ( keys %keyparam_h )
152 foreach my $verkey (split (/,/,$applykeys))
154 if ($pkey eq $verkey) { $k_found = 1; }
156 if (! $k_found) { return $error{"apply_inv_param"}; }
159 foreach my $applykey (split (/,/,$applykeys))
161 while (my ($gn, $gv) = each %genparam_h)
163 $keyparshoh->{$applykey}{$gn} = $gv;
165 while (my ($kn, $kv) = each %{ $keyparam_h{$applykey} } )
167 $keyparshoh->{$applykey}{$kn} = $kv;
169 push @$apply_keys_ptr, $applykey;