/[RFID]/3m-810.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /3m-810.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 45 by dpavlin, Tue Jun 23 13:29:10 2009 UTC revision 46 by dpavlin, Tue Jun 23 13:50:13 2009 UTC
# Line 82  sub http_server { Line 82  sub http_server {
82    
83                  if ($request =~ m{^GET (/.*) HTTP/1.[01]}) {                  if ($request =~ m{^GET (/.*) HTTP/1.[01]}) {
84                          my $method = $1;                          my $method = $1;
85                            my $param;
86                            if ( $method =~ s{\?(.+)}{} ) {
87                                    foreach my $p ( split(/[&;]/, $1) ) {
88                                            my ($n,$v) = split(/=/, $p, 2);
89                                            $param->{$n} = $v;
90                                    }
91                                    warn "<< param: ",dump( $param );
92                            }
93                          if ( my $path = static( $client,$1 ) ) {                          if ( my $path = static( $client,$1 ) ) {
94                                  warn ">> $path";                                  warn ">> $path";
95                          } elsif ( $method =~ m{/scan} ) {                          } elsif ( $method =~ m{/scan} ) {
                                 my $callback = $1 if $method =~ m{\?callback=([^&;]+)};  
96                                  my $tags = scan_for_tags();                                  my $tags = scan_for_tags();
97                                  my $json;                                  my $json = {};
98                                  map {                                  map {
99                                          my $d = decode_tag($_);                                          my $d = decode_tag($_);
100                                          $d->{sid} = $_;                                          $d->{sid} = $_;
101                                          push @{ $json->{tags} },  $d;                                          push @{ $json->{tags} },  $d;
102                                  } keys %$tags;                                  } keys %$tags;
103                                  print $client "HTTP/1.0 200 OK\r\nContent-Type: application/x-javascript\r\n\r\n$callback(", to_json($json), ")\r\n";                                  print $client "HTTP/1.0 200 OK\r\nContent-Type: application/x-javascript\r\n\r\n",
104                                            $param->{callback}, "(", to_json($json), ")\r\n";
105                          } else {                          } else {
106                                  print $client "HTTP/1.0 404 Unkown method\r\n";                                  print $client "HTTP/1.0 404 Unkown method\r\n";
107                          }                          }

Legend:
Removed from v.45  
changed lines
  Added in v.46

  ViewVC Help
Powered by ViewVC 1.1.26