2
# $Id: expand.tcl 1266 2009-07-14 18:39:12Z hubert@u.washington.edu $
3
# ========================================================================
4
# Copyright 2008 University of Washington
6
# Licensed under the Apache License, Version 2.0 (the "License");
7
# you may not use this file except in compliance with the License.
8
# You may obtain a copy of the License at
10
# http://www.apache.org/licenses/LICENSE-2.0
12
# ========================================================================
16
# Purpose: CGI script to supply data to composer
19
# along with possible search parameters:
26
# inherit global config
29
# Import data validate it and get session id
30
if {[catch {WPGetInputAndID sessid} result]} {
31
error "expand.tcl: $result"
35
foreach item $expand_args {
36
if {[catch {eval WPImport $item} result]} {
37
error "expand.tcl: $result"
45
if {[regexp {^[0-9]*$} $book] && [regexp {^[0-9,]*$} $index]} {
46
foreach i [split $index ","] {
47
if {[catch {WPCmd PEAddress entry $book "" $i} entry]} {
48
lappend errlist $entry
50
regsub -all "'" [lindex $entry 0] "\\'" resaddr
51
lappend expaddr $resaddr
55
} elseif {[string length $addrs]} {
56
if {[catch {WPCmd PEAddress expand $addrs [lindex [WPCmd PECompose fccdefault] 1]} result]} {
59
set expaddr [list [lindex $result 0]]
60
set fcc [lindex $result 2]
63
set errstr "Unknown expand options"
66
puts stdout "Content-type: text/xml; charset=\"UTF-8\"\n"
67
puts stdout {<?xml version="1.0" encoding="UTF-8"?>}
69
if {[info exists errstr] && [string length $errstr]} {
70
puts stdout "<ResultSet totalResultsAvailable=\"1\"><Result>"
71
puts stdout "<Error>$errstr</Error>"
72
puts stdout "</Result></ResultSet>"
74
puts stdout "<ResultSet totalResultsAvailable=\"[expr {[llength $expaddr] + [llength $errlist]}]\">"
76
puts stdout "<Result><Error>[cgi_quote_html $e]</Error></Result>"
80
puts stdout "<Result><Address>[cgi_quote_html $a]</Address><Fcc>[cgi_quote_html $fcc]</Fcc></Result>"
83
puts stdout "</ResultSet>"