% . ..% pkgIndex.tcl% msgcat.tclif {![package vsatisfies [package provide Tcl] 8.2]} {return} package ifneeded msgcat 1.3.4 [list source [file join $dir msgcat.tcl]] # msgcat.tcl -- # # This file defines various procedures which implement a # message catalog facility for Tcl programs. It should be # loaded with the command "package require msgcat". # # Copyright (c) 1998-2000 by Ajuba Solutions. # Copyright (c) 1998 by Mark Harrison. # # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # # RCS: @(#) $Id: msgcat.tcl,v 1.17.2.6 2006/09/10 18:23:45 dgp Exp $ package require Tcl 8.2 # When the version number changes, be sure to update the pkgIndex.tcl file, # and the installation directory in the Makefiles. package provide msgcat 1.3.4 namespace eval msgcat { namespace export mc mcload mclocale mcmax mcmset mcpreferences mcset \ mcunknown # Records the current locale as passed to mclocale variable Locale "" # Records the list of locales to search variable Loclist {} # Records the mapping between source strings and translated strings. The # array key is of the form ",," and the value is # the translated string. array set Msgs {} # Map of language codes used in Windows registry to those of ISO-639 if { [string equal $::tcl_platform(platform) windows] } { array set WinRegToISO639 { 01 ar 0401 ar_SA 0801 ar_IQ 0c01 ar_EG 1001 ar_LY 1401 ar_DZ 1801 ar_MA 1c01 ar_TN 2001 ar_OM 2401 ar_YE 2801 ar_SY 2c01 ar_JO 3001 ar_LB 3401 ar_KW 3801 ar_AE 3c01 ar_BH 4001 ar_QA 02 bg 0402 bg_BG 03 ca 0403 ca_ES 04 zh 0404 zh_TW 0804 zh_CN 0c04 zh_HK 1004 zh_SG 1404 zh_MO 05 cs 0405 cs_CZ 06 da 0406 da_DK 07 de 0407 de_DE 0807 de_CH 0c07 de_AT 1007 de_LU 1407 de_LI 08 el 0408 el_GR 09 en 0409 en_US 0809 en_GB 0c09 en_AU 1009 en_CA 1409 en_NZ 1809 en_IE 1c09 en_ZA 2009 en_JM 2409 en_GD 2809 en_BZ 2c09 en_TT 3009 en_ZW 3409 en_PH 0a es 040a es_ES 080a es_MX 0c0a es_ES@modern 100a es_GT 140a es_CR 180a es_PA 1c0a es_DO 200a es_VE 240a es_CO 280a es_PE 2c0a es_AR 300a es_EC 340a es_CL 380a es_UY 3c0a es_PY 400a es_BO 440a es_SV 480a es_HN 4c0a es_NI 500a es_PR 0b fi 040b fi_FI 0c fr 040c fr_FR 080c fr_BE 0c0c fr_CA 100c fr_CH 140c fr_LU 180c fr_MC 0d he 040d he_IL 0e hu 040e hu_HU 0f is 040f is_IS 10 it 0410 it_IT 0810 it_CH 11 ja 0411 ja_JP 12 ko 0412 ko_KR 13 nl 0413 nl_NL 0813 nl_BE 14 no 0414 no_NO 0814 nn_NO 15 pl 0415 pl_PL 16 pt 0416 pt_BR 0816 pt_PT 17 rm 0417 rm_CH 18 ro 0418 ro_RO 19 ru 1a hr 041a hr_HR 081a sr_YU 0c1a sr_YU@cyrillic 1b sk 041b sk_SK 1c sq 041c sq_AL 1d sv 041d sv_SE 081d sv_FI 1e th 041e th_TH 1f tr 041f tr_TR 20 ur 0420 ur_PK 0820 ur_IN 21 id 0421 id_ID 22 uk 0422 uk_UA 23 be 0423 be_BY 24 sl 0424 sl_SI 25 et 0425 et_EE 26 lv 0426 lv_LV 27 lt 0427 lt_LT 28 tg 0428 tg_TJ 29 fa 0429 fa_IR 2a vi 042a vi_VN 2b hy 042b hy_AM 2c az 042c az_AZ@latin 082c az_AZ@cyrillic 2d eu 2e wen 042e wen_DE 2f mk 042f mk_MK 30 bnt 0430 bnt_TZ 31 ts 0431 ts_ZA 33 ven 0433 ven_ZA 34 xh 0434 xh_ZA 35 zu 0435 zu_ZA 36 af 0436 af_ZA 37 ka 0437 ka_GE 38 fo 0438 fo_FO 39 hi 0439 hi_IN 3a mt 043a mt_MT 3b se 043b se_NO 043c gd_UK 083c ga_IE 3d yi 043d yi_IL 3e ms 043e ms_MY 083e ms_BN 3f kk 043f kk_KZ 40 ky 0440 ky_KG 41 sw 0441 sw_KE 42 tk 0442 tk_TM 43 uz 0443 uz_UZ@latin 0843 uz_UZ@cyrillic 44 tt 0444 tt_RU 45 bn 0445 bn_IN 46 pa 0446 pa_IN 47 gu 0447 gu_IN 48 or 0448 or_IN 49 ta 4a te 044a te_IN 4b kn 044b kn_IN 4c ml 044c ml_IN 4d as 044d as_IN 4e mr 044e mr_IN 4f sa 044f sa_IN 50 mn 51 bo 0451 bo_CN 52 cy 0452 cy_GB 53 km 0453 km_KH 54 lo 0454 lo_LA 55 my 0455 my_MM 56 gl 0456 gl_ES 57 kok 0457 kok_IN 58 mni 0458 mni_IN 59 sd 5a syr 045a syr_TR 5b si 045b si_LK 5c chr 045c chr_US 5d iu 045d iu_CA 5e am 045e am_ET 5f ber 045f ber_MA 60 ks 0460 ks_PK 0860 ks_IN 61 ne 0461 ne_NP 0861 ne_IN 62 fy 0462 fy_NL 63 ps 64 tl 0464 tl_PH 65 div 0465 div_MV 66 bin 0466 bin_NG 67 ful 0467 ful_NG 68 ha 0468 ha_NG 69 nic 0469 nic_NG 6a yo 046a yo_NG 70 ibo 0470 ibo_NG 71 kau 0471 kau_NG 72 om 0472 om_ET 73 ti 0473 ti_ET 74 gn 0474 gn_PY 75 cpe 0475 cpe_US 76 la 0476 la_VA 77 so 0477 so_SO 78 sit 0478 sit_CN 79 pap 0479 pap_AN } } } # msgcat::mc -- # # Find the translation for the given string based on the current # locale setting. Check the local namespace first, then look in each # parent namespace until the source is found. If additional args are # specified, use the format command to work them into the traslated # string. # # Arguments: # src The string to translate. # args Args to pass to the format command # # Results: # Returns the translatd string. Propagates errors thrown by the # format command. proc msgcat::mc {src args} { # Check for the src in each namespace starting from the local and # ending in the global. variable Msgs variable Loclist variable Locale set ns [uplevel 1 [list ::namespace current]] while {$ns != ""} { foreach loc $Loclist { if {[info exists Msgs($loc,$ns,$src)]} { if {[llength $args] == 0} { return $Msgs($loc,$ns,$src) } else { return [uplevel 1 \ [linsert $args 0 ::format $Msgs($loc,$ns,$src)]] } } } set ns [namespace parent $ns] } # we have not found the translation return [uplevel 1 \ [linsert $args 0 [::namespace origin mcunknown] $Locale $src]] } # msgcat::mclocale -- # # Query or set the current locale. # # Arguments: # newLocale (Optional) The new locale string. Locale strings # should be composed of one or more sublocale parts # separated by underscores (e.g. en_US). # # Results: # Returns the current locale. proc msgcat::mclocale {args} { variable Loclist variable Locale set len [llength $args] if {$len > 1} { error {wrong # args: should be "mclocale ?newLocale?"} } if {$len == 1} { set newLocale [lindex $args 0] if {$newLocale ne [file tail $newLocale]} { return -code error "invalid newLocale value \"$newLocale\":\ could be path to unsafe code." } set Locale [string tolower $newLocale] set Loclist {} set word "" foreach part [split $Locale _] { set word [string trimleft "${word}_${part}" _] set Loclist [linsert $Loclist 0 $word] } } return $Locale } # msgcat::mcpreferences -- # # Fetch the list of locales used to look up strings, ordered from # most preferred to least preferred. # # Arguments: # None. # # Results: # Returns an ordered list of the locales preferred by the user. proc msgcat::mcpreferences {} { variable Loclist return $Loclist } # msgcat::mcload -- # # Attempt to load message catalogs for each locale in the # preference list from the specified directory. # # Arguments: # langdir The directory to search. # # Results: # Returns the number of message catalogs that were loaded. proc msgcat::mcload {langdir} { set x 0 foreach p [mcpreferences] { set langfile [file join $langdir $p.msg] if {[file exists $langfile]} { incr x set fid [open $langfile "r"] fconfigure $fid -encoding utf-8 uplevel 1 [read $fid] close $fid } } return $x } # msgcat::mcset -- # # Set the translation for a given string in a specified locale. # # Arguments: # locale The locale to use. # src The source string. # dest (Optional) The translated string. If omitted, # the source string is used. # # Results: # Returns the new locale. proc msgcat::mcset {locale src {dest ""}} { variable Msgs if {[llength [info level 0]] == 3} { ;# dest not specified set dest $src } set ns [uplevel 1 [list ::namespace current]] set Msgs([string tolower $locale],$ns,$src) $dest return $dest } # msgcat::mcmset -- # # Set the translation for multiple strings in a specified locale. # # Arguments: # locale The locale to use. # pairs One or more src/dest pairs (must be even length) # # Results: # Returns the number of pairs processed proc msgcat::mcmset {locale pairs } { variable Msgs set length [llength $pairs] if {$length % 2} { error {bad translation list: should be "mcmset locale {src dest ...}"} } set locale [string tolower $locale] set ns [uplevel 1 [list ::namespace current]] foreach {src dest} $pairs { set Msgs($locale,$ns,$src) $dest } return $length } # msgcat::mcunknown -- # # This routine is called by msgcat::mc if a translation cannot # be found for a string. This routine is intended to be replaced # by an application specific routine for error reporting # purposes. The default behavior is to return the source string. # If additional args are specified, the format command will be used # to work them into the traslated string. # # Arguments: # locale The current locale. # src The string to be translated. # args Args to pass to the format command # # Results: # Returns the translated value. proc msgcat::mcunknown {locale src args} { if {[llength $args]} { return [uplevel 1 [linsert $args 0 ::format $src]] } else { return $src } } # msgcat::mcmax -- # # Calculates the maximun length of the translated strings of the given # list. # # Arguments: # args strings to translate. # # Results: # Returns the length of the longest translated string. proc msgcat::mcmax {args} { set max 0 foreach string $args { set translated [uplevel 1 [list [namespace origin mc] $string]] set len [string length $translated] if {$len>$max} { set max $len } } return $max } # Convert the locale values stored in environment variables to a form # suitable for passing to [mclocale] proc msgcat::ConvertLocale {value} { # Assume $value is of form: $language[_$territory][.$codeset][@modifier] # Convert to form: $language[_$territory][_$modifier] # # Comment out expanded RE version -- bugs alleged # regexp -expanded { # ^ # Match all the way to the beginning # ([^_.@]*) # Match "lanugage"; ends with _, ., or @ # (_([^.@]*))? # Match (optional) "territory"; starts with _ # ([.]([^@]*))? # Match (optional) "codeset"; starts with . # (@(.*))? # Match (optional) "modifier"; starts with @ # $ # Match all the way to the end # } $value -> language _ territory _ codeset _ modifier if {![regexp {^([^_.@]+)(_([^.@]*))?([.]([^@]*))?(@(.*))?$} $value \ -> language _ territory _ codeset _ modifier]} { return -code error "invalid locale '$value': empty language part" } set ret $language if {[string length $territory]} { append ret _$territory } if {[string length $modifier]} { append ret _$modifier } return $ret } # Initialize the default locale proc msgcat::Init {} { # # set default locale, try to get from environment # foreach varName {LC_ALL LC_MESSAGES LANG} { if {[info exists ::env($varName)] && ![string equal "" $::env($varName)]} { if {![catch {mclocale [ConvertLocale $::env($varName)]}]} { return } } } # # On Darwin, fallback to current CFLocale identifier if available. # if {[string equal $::tcl_platform(os) Darwin] && [string equal $::tcl_platform(platform) unix] && [info exists ::tcl::mac::locale] && ![string equal $::tcl::mac::locale ""]} { if {![catch {mclocale [ConvertLocale $::tcl::mac::locale]}]} { return } } # # The rest of this routine is special processing for Windows; # all other platforms, get out now. # if { ![string equal $::tcl_platform(platform) windows] } { mclocale C return } # # On Windows, try to set locale depending on registry settings, # or fall back on locale of "C". # set key {HKEY_CURRENT_USER\Control Panel\International} if {[catch {package require registry}] \ || [catch {registry get $key "locale"} locale]} { mclocale C return } # # Keep trying to match against smaller and smaller suffixes # of the registry value, since the latter hexadigits appear # to determine general language and earlier hexadigits determine # more precise information, such as territory. For example, # 0409 - English - United States # 0809 - English - United Kingdom # Add more translations to the WinRegToISO639 array above. # variable WinRegToISO639 set locale [string tolower $locale] while {[string length $locale]} { if {![catch {mclocale [ConvertLocale $WinRegToISO639($locale)]}]} { return } set locale [string range $locale 1 end] } # # No translation known. Fall back on "C" locale # mclocale C } msgcat::Init % . ..% pkgIndex.tcl%http.tcl# Tcl package index file, version 1.0 # This file is generated by the "pkg_mkIndex" command # and sourced either when an application starts up or # by a "package unknown" script. It invokes the # "package ifneeded" command to set up package-related # information so that packages will be loaded automatically # in response to "package require" commands. When this # script is sourced, the variable $dir must contain the # full path name of this file's directory. package ifneeded http 1.0 [list tclPkgSetup $dir http 1.0 {{http.tcl source {httpCopyDone httpCopyStart httpEof httpEvent httpFinish httpMapReply httpProxyRequired http_code http_config http_data http_formatQuery http_get http_reset http_size http_status http_wait}}}] # http.tcl # Client-side HTTP for GET, POST, and HEAD commands. # These routines can be used in untrusted code that uses the Safesock # security policy. # These procedures use a callback interface to avoid using vwait, # which is not defined in the safe base. # # RCS: @(#) $Id: http.tcl,v 1.4 2000/02/01 11:48:30 hobbs Exp $ # # See the http.n man page for documentation package provide http 1.0 array set http { -accept */* -proxyhost {} -proxyport {} -useragent {Tcl http client package 1.0} -proxyfilter httpProxyRequired } proc http_config {args} { global http set options [lsort [array names http -*]] set usage [join $options ", "] if {[llength $args] == 0} { set result {} foreach name $options { lappend result $name $http($name) } return $result } regsub -all -- - $options {} options set pat ^-([join $options |])$ if {[llength $args] == 1} { set flag [lindex $args 0] if {[regexp -- $pat $flag]} { return $http($flag) } else { return -code error "Unknown option $flag, must be: $usage" } } else { foreach {flag value} $args { if {[regexp -- $pat $flag]} { set http($flag) $value } else { return -code error "Unknown option $flag, must be: $usage" } } } } proc httpFinish { token {errormsg ""} } { upvar #0 $token state global errorInfo errorCode if {[string length $errormsg] != 0} { set state(error) [list $errormsg $errorInfo $errorCode] set state(status) error } catch {close $state(sock)} catch {after cancel $state(after)} if {[info exists state(-command)]} { if {[catch {eval $state(-command) {$token}} err]} { if {[string length $errormsg] == 0} { set state(error) [list $err $errorInfo $errorCode] set state(status) error } } unset state(-command) } } proc http_reset { token {why reset} } { upvar #0 $token state set state(status) $why catch {fileevent $state(sock) readable {}} httpFinish $token if {[info exists state(error)]} { set errorlist $state(error) unset state(error) eval error $errorlist } } proc http_get { url args } { global http if {![info exists http(uid)]} { set http(uid) 0 } set token http#[incr http(uid)] upvar #0 $token state http_reset $token array set state { -blocksize 8192 -validate 0 -headers {} -timeout 0 state header meta {} currentsize 0 totalsize 0 type text/html body {} status "" } set options {-blocksize -channel -command -handler -headers \ -progress -query -validate -timeout} set usage [join $options ", "] regsub -all -- - $options {} options set pat ^-([join $options |])$ foreach {flag value} $args { if {[regexp $pat $flag]} { # Validate numbers if {[info exists state($flag)] && \ [regexp {^[0-9]+$} $state($flag)] && \ ![regexp {^[0-9]+$} $value]} { return -code error "Bad value for $flag ($value), must be integer" } set state($flag) $value } else { return -code error "Unknown option $flag, can be: $usage" } } if {! [regexp -nocase {^(http://)?([^/:]+)(:([0-9]+))?(/.*)?$} $url \ x proto host y port srvurl]} { error "Unsupported URL: $url" } if {[string length $port] == 0} { set port 80 } if {[string length $srvurl] == 0} { set srvurl / } if {[string length $proto] == 0} { set url http://$url } set state(url) $url if {![catch {$http(-proxyfilter) $host} proxy]} { set phost [lindex $proxy 0] set pport [lindex $proxy 1] } if {$state(-timeout) > 0} { set state(after) [after $state(-timeout) [list http_reset $token timeout]] } if {[info exists phost] && [string length $phost]} { set srvurl $url set s [socket $phost $pport] } else { set s [socket $host $port] } set state(sock) $s # Send data in cr-lf format, but accept any line terminators fconfigure $s -translation {auto crlf} -buffersize $state(-blocksize) # The following is disallowed in safe interpreters, but the socket # is already in non-blocking mode in that case. catch {fconfigure $s -blocking off} set len 0 set how GET if {[info exists state(-query)]} { set len [string length $state(-query)] if {$len > 0} { set how POST } } elseif {$state(-validate)} { set how HEAD } puts $s "$how $srvurl HTTP/1.0" puts $s "Accept: $http(-accept)" puts $s "Host: $host" puts $s "User-Agent: $http(-useragent)" foreach {key value} $state(-headers) { regsub -all \[\n\r\] $value {} value set key [string trim $key] if {[string length $key]} { puts $s "$key: $value" } } if {$len > 0} { puts $s "Content-Length: $len" puts $s "Content-Type: application/x-www-form-urlencoded" puts $s "" fconfigure $s -translation {auto binary} puts -nonewline $s $state(-query) } else { puts $s "" } flush $s fileevent $s readable [list httpEvent $token] if {! [info exists state(-command)]} { http_wait $token } return $token } proc http_data {token} { upvar #0 $token state return $state(body) } proc http_status {token} { upvar #0 $token state return $state(status) } proc http_code {token} { upvar #0 $token state return $state(http) } proc http_size {token} { upvar #0 $token state return $state(currentsize) } proc httpEvent {token} { upvar #0 $token state set s $state(sock) if {[eof $s]} { httpEof $token return } if {$state(state) == "header"} { set n [gets $s line] if {$n == 0} { set state(state) body if {![regexp -nocase ^text $state(type)]} { # Turn off conversions for non-text data fconfigure $s -translation binary if {[info exists state(-channel)]} { fconfigure $state(-channel) -translation binary } } if {[info exists state(-channel)] && ![info exists state(-handler)]} { # Initiate a sequence of background fcopies fileevent $s readable {} httpCopyStart $s $token } } elseif {$n > 0} { if {[regexp -nocase {^content-type:(.+)$} $line x type]} { set state(type) [string trim $type] } if {[regexp -nocase {^content-length:(.+)$} $line x length]} { set state(totalsize) [string trim $length] } if {[regexp -nocase {^([^:]+):(.+)$} $line x key value]} { lappend state(meta) $key $value } elseif {[regexp ^HTTP $line]} { set state(http) $line } } } else { if {[catch { if {[info exists state(-handler)]} { set n [eval $state(-handler) {$s $token}] } else { set block [read $s $state(-blocksize)] set n [string length $block] if {$n >= 0} { append state(body) $block } } if {$n >= 0} { incr state(currentsize) $n } } err]} { httpFinish $token $err } else { if {[info exists state(-progress)]} { eval $state(-progress) {$token $state(totalsize) $state(currentsize)} } } } } proc httpCopyStart {s token} { upvar #0 $token state if {[catch { fcopy $s $state(-channel) -size $state(-blocksize) -command \ [list httpCopyDone $token] } err]} { httpFinish $token $err } } proc httpCopyDone {token count {error {}}} { upvar #0 $token state set s $state(sock) incr state(currentsize) $count if {[info exists state(-progress)]} { eval $state(-progress) {$token $state(totalsize) $state(currentsize)} } if {([string length $error] != 0)} { httpFinish $token $error } elseif {[eof $s]} { httpEof $token } else { httpCopyStart $s $token } } proc httpEof {token} { upvar #0 $token state if {$state(state) == "header"} { # Premature eof set state(status) eof } else { set state(status) ok } set state(state) eof httpFinish $token } proc http_wait {token} { upvar #0 $token state if {![info exists state(status)] || [string length $state(status)] == 0} { vwait $token\(status) } if {[info exists state(error)]} { set errorlist $state(error) unset state(error) eval error $errorlist } return $state(status) } # Call http_formatQuery with an even number of arguments, where the first is # a name, the second is a value, the third is another name, and so on. proc http_formatQuery {args} { set result "" set sep "" foreach i $args { append result $sep [httpMapReply $i] if {$sep != "="} { set sep = } else { set sep & } } return $result } # do x-www-urlencoded character mapping # The spec says: "non-alphanumeric characters are replaced by '%HH'" # 1 leave alphanumerics characters alone # 2 Convert every other character to an array lookup # 3 Escape constructs that are "special" to the tcl parser # 4 "subst" the result, doing all the array substitutions proc httpMapReply {string} { global httpFormMap set alphanumeric a-zA-Z0-9 if {![info exists httpFormMap]} { for {set i 1} {$i <= 256} {incr i} { set c [format %c $i] if {![string match \[$alphanumeric\] $c]} { set httpFormMap($c) %[format %.2x $i] } } # These are handled specially array set httpFormMap { " " + \n %0d%0a } } regsub -all \[^$alphanumeric\] $string {$httpFormMap(&)} string regsub -all \n $string {\\n} string regsub -all \t $string {\\t} string regsub -all {[][{})\\]\)} $string {\\&} string return [subst $string] } # Default proxy filter. proc httpProxyRequired {host} { global http if {[info exists http(-proxyhost)] && [string length $http(-proxyhost)]} { if {![info exists http(-proxyport)] || ![string length $http(-proxyport)]} { set http(-proxyport) 8080 } return [list $http(-proxyhost) $http(-proxyport)] } else { return {} } } #!/bin/sh # # ldAix ldCmd ldArg ldArg ... # # This shell script provides a wrapper for ld under AIX in order to # create the .exp file required for linking. Its arguments consist # of the name and arguments that would normally be provided to the # ld command. This script extracts the names of the object files # from the argument list, creates a .exp file describing all of the # symbols exported by those files, and then invokes "ldCmd" to # perform the real link. # # RCS: @(#) $Id: ldAix,v 1.4 2002/09/27 01:28:26 hobbs Exp $ # Extract from the arguments the names of all of the object files. args=$* ofiles="" for i do x=`echo $i | grep '[^.].o$'` if test "$x" != ""; then ofiles="$ofiles $i" fi done # Extract the name of the object file that we're linking. outputFile=`echo $args | sed -e 's/.*-o \([^ ]*\).*/\1/'` # Create the export file from all of the object files, using nm followed # by sed editing. Here are some tricky aspects of this: # # 1. Nm produces different output under AIX 4.1 than under AIX 3.2.5; # the following statements handle both versions. # 2. Use the -g switch to nm instead of -e under 4.1 (this shows just # externals, not statics; -g isn't available under 3.2.5, though). # 3. Use the -X32_64 switch to nm on AIX-4+ to handle 32 or 64bit compiles. # 4. Eliminate lines that end in ":": these are the names of object # files (relevant in 4.1 only). # 5. Eliminate entries with the "U" key letter; these are undefined # symbols (relevant in 4.1 only). # 6. Eliminate lines that contain the string "0|extern" preceded by space; # in 3.2.5, these are undefined symbols (address 0). # 7. Eliminate lines containing the "unamex" symbol. In 3.2.5, these # are also undefined symbols. # 8. If a line starts with ".", delete the leading ".", since this will # just cause confusion later. # 9. Eliminate everything after the first field in a line, so that we're # left with just the symbol name. nmopts="-g -C" osver=`uname -v` if test $osver -eq 3; then nmopts="-e" fi if test $osver -gt 3; then nmopts="$nmopts -X32_64" fi rm -f lib.exp echo "#! $outputFile" >lib.exp /usr/ccs/bin/nm $nmopts -h $ofiles | sed -e '/:$/d' -e '/ U /d' -e '/[ ]0|extern/d' -e '/unamex/d' -e 's/^\.//' -e 's/[ |].*//' | sort | uniq >>lib.exp # If we're linking a .a file, then link all the objects together into a # single file "shr.o" and then put that into the archive. Otherwise link # the object files directly into the .a file. outputFile=`echo $args | sed -e 's/.*-o \([^ ]*\).*/\1/'` noDotA=`echo $outputFile | sed -e '/\.a$/d'` echo "noDotA=\"$noDotA\"" if test "$noDotA" = "" ; then linkArgs=`echo $args | sed -e 's/-o .*\.a /-o shr.o /'` echo $linkArgs eval $linkArgs echo ar cr $outputFile shr.o ar cr $outputFile shr.o rm -f shr.o else eval $args fi # parray: # Print the contents of a global array on stdout. # # RCS: @(#) $Id: parray.tcl,v 1.3 1998/09/14 18:40:03 stanton Exp $ # # Copyright (c) 1991-1993 The Regents of the University of California. # Copyright (c) 1994 Sun Microsystems, Inc. # # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # proc parray {a {pattern *}} { upvar 1 $a array if {![array exists array]} { error "\"$a\" isn't an array" } set maxl 0 foreach name [lsort [array names array $pattern]] { if {[string length $name] > $maxl} { set maxl [string length $name] } } set maxl [expr {$maxl + [string length $a] + 2}] foreach name [lsort [array names array $pattern]] { set nameString [format %s(%s) $a $name] puts stdout [format "%-*s = %s" $maxl $nameString $array($name)] } } # history.tcl -- # # Implementation of the history command. # # RCS: @(#) $Id: history.tcl,v 1.5.14.1 2005/07/22 21:59:40 dgp Exp $ # # Copyright (c) 1997 Sun Microsystems, Inc. # # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # # The tcl::history array holds the history list and # some additional bookkeeping variables. # # nextid the index used for the next history list item. # keep the max size of the history list # oldest the index of the oldest item in the history. namespace eval tcl { variable history if {![info exists history]} { array set history { nextid 0 keep 20 oldest -20 } } } # history -- # # This is the main history command. See the man page for its interface. # This does argument checking and calls helper procedures in the # history namespace. proc history {args} { set len [llength $args] if {$len == 0} { return [tcl::HistInfo] } set key [lindex $args 0] set options "add, change, clear, event, info, keep, nextid, or redo" switch -glob -- $key { a* { # history add if {$len > 3} { return -code error "wrong # args: should be \"history add event ?exec?\"" } if {![string match $key* add]} { return -code error "bad option \"$key\": must be $options" } if {$len == 3} { set arg [lindex $args 2] if {! ([string match e* $arg] && [string match $arg* exec])} { return -code error "bad argument \"$arg\": should be \"exec\"" } } return [tcl::HistAdd [lindex $args 1] [lindex $args 2]] } ch* { # history change if {($len > 3) || ($len < 2)} { return -code error "wrong # args: should be \"history change newValue ?event?\"" } if {![string match $key* change]} { return -code error "bad option \"$key\": must be $options" } if {$len == 2} { set event 0 } else { set event [lindex $args 2] } return [tcl::HistChange [lindex $args 1] $event] } cl* { # history clear if {($len > 1)} { return -code error "wrong # args: should be \"history clear\"" } if {![string match $key* clear]} { return -code error "bad option \"$key\": must be $options" } return [tcl::HistClear] } e* { # history event if {$len > 2} { return -code error "wrong # args: should be \"history event ?event?\"" } if {![string match $key* event]} { return -code error "bad option \"$key\": must be $options" } if {$len == 1} { set event -1 } else { set event [lindex $args 1] } return [tcl::HistEvent $event] } i* { # history info if {$len > 2} { return -code error "wrong # args: should be \"history info ?count?\"" } if {![string match $key* info]} { return -code error "bad option \"$key\": must be $options" } return [tcl::HistInfo [lindex $args 1]] } k* { # history keep if {$len > 2} { return -code error "wrong # args: should be \"history keep ?count?\"" } if {$len == 1} { return [tcl::HistKeep] } else { set limit [lindex $args 1] if {[catch {expr {~$limit}}] || ($limit < 0)} { return -code error "illegal keep count \"$limit\"" } return [tcl::HistKeep $limit] } } n* { # history nextid if {$len > 1} { return -code error "wrong # args: should be \"history nextid\"" } if {![string match $key* nextid]} { return -code error "bad option \"$key\": must be $options" } return [expr {$tcl::history(nextid) + 1}] } r* { # history redo if {$len > 2} { return -code error "wrong # args: should be \"history redo ?event?\"" } if {![string match $key* redo]} { return -code error "bad option \"$key\": must be $options" } return [tcl::HistRedo [lindex $args 1]] } default { return -code error "bad option \"$key\": must be $options" } } } # tcl::HistAdd -- # # Add an item to the history, and optionally eval it at the global scope # # Parameters: # command the command to add # exec (optional) a substring of "exec" causes the # command to be evaled. # Results: # If executing, then the results of the command are returned # # Side Effects: # Adds to the history list proc tcl::HistAdd {command {exec {}}} { variable history # Do not add empty commands to the history if {[string trim $command] eq ""} { return "" } set i [incr history(nextid)] set history($i) $command set j [incr history(oldest)] unset -nocomplain history($j) if {[string match e* $exec]} { return [uplevel #0 $command] } else { return {} } } # tcl::HistKeep -- # # Set or query the limit on the length of the history list # # Parameters: # limit (optional) the length of the history list # # Results: # If no limit is specified, the current limit is returned # # Side Effects: # Updates history(keep) if a limit is specified proc tcl::HistKeep {{limit {}}} { variable history if {$limit eq ""} { return $history(keep) } else { set oldold $history(oldest) set history(oldest) [expr {$history(nextid) - $limit}] for {} {$oldold <= $history(oldest)} {incr oldold} { unset -nocomplain history($oldold) } set history(keep) $limit } } # tcl::HistClear -- # # Erase the history list # # Parameters: # none # # Results: # none # # Side Effects: # Resets the history array, except for the keep limit proc tcl::HistClear {} { variable history set keep $history(keep) unset history array set history [list \ nextid 0 \ keep $keep \ oldest -$keep \ ] } # tcl::HistInfo -- # # Return a pretty-printed version of the history list # # Parameters: # num (optional) the length of the history list to return # # Results: # A formatted history list proc tcl::HistInfo {{num {}}} { variable history if {$num eq ""} { set num [expr {$history(keep) + 1}] } set result {} set newline "" for {set i [expr {$history(nextid) - $num + 1}]} \ {$i <= $history(nextid)} {incr i} { if {![info exists history($i)]} { continue } set cmd [string map [list \n \n\t] [string trimright $history($i) \ \n]] append result $newline[format "%6d %s" $i $cmd] set newline \n } return $result } # tcl::HistRedo -- # # Fetch the previous or specified event, execute it, and then # replace the current history item with that event. # # Parameters: # event (optional) index of history item to redo. Defaults to -1, # which means the previous event. # # Results: # Those of the command being redone. # # Side Effects: # Replaces the current history list item with the one being redone. proc tcl::HistRedo {{event -1}} { variable history if {$event eq ""} { set event -1 } set i [HistIndex $event] if {$i == $history(nextid)} { return -code error "cannot redo the current event" } set cmd $history($i) HistChange $cmd 0 uplevel #0 $cmd } # tcl::HistIndex -- # # Map from an event specifier to an index in the history list. # # Parameters: # event index of history item to redo. # If this is a positive number, it is used directly. # If it is a negative number, then it counts back to a previous # event, where -1 is the most recent event. # A string can be matched, either by being the prefix of # a command or by matching a command with string match. # # Results: # The index into history, or an error if the index didn't match. proc tcl::HistIndex {event} { variable history if {[catch {expr {~$event}}]} { for {set i [expr {$history(nextid)-1}]} {[info exists history($i)]} \ {incr i -1} { if {[string match $event* $history($i)]} { return $i; } if {[string match $event $history($i)]} { return $i; } } return -code error "no event matches \"$event\"" } elseif {$event <= 0} { set i [expr {$history(nextid) + $event}] } else { set i $event } if {$i <= $history(oldest)} { return -code error "event \"$event\" is too far in the past" } if {$i > $history(nextid)} { return -code error "event \"$event\" hasn't occured yet" } return $i } # tcl::HistEvent -- # # Map from an event specifier to the value in the history list. # # Parameters: # event index of history item to redo. See index for a # description of possible event patterns. # # Results: # The value from the history list. proc tcl::HistEvent {event} { variable history set i [HistIndex $event] if {[info exists history($i)]} { return [string trimright $history($i) \ \n] } else { return ""; } } # tcl::HistChange -- # # Replace a value in the history list. # # Parameters: # cmd The new value to put into the history list. # event (optional) index of history item to redo. See index for a # description of possible event patterns. This defaults # to 0, which specifies the current event. # # Side Effects: # Changes the history list. proc tcl::HistChange {cmd {event 0}} { variable history set i [HistIndex $event] set history($i) $cmd } # ldAout.tcl -- # # This "tclldAout" procedure in this script acts as a replacement # for the "ld" command when linking an object file that will be # loaded dynamically into Tcl or Tk using pseudo-static linking. # # Parameters: # The arguments to the script are the command line options for # an "ld" command. # # Results: # The "ld" command is parsed, and the "-o" option determines the # module name. ".a" and ".o" options are accumulated. # The input archives and object files are examined with the "nm" # command to determine whether the modules initialization # entry and safe initialization entry are present. A trivial # C function that locates the entries is composed, compiled, and # its .o file placed before all others in the command; then # "ld" is executed to bind the objects together. # # RCS: @(#) $Id: ldAout.tcl,v 1.5 2001/09/28 01:21:53 dgp Exp $ # # Copyright (c) 1995, by General Electric Company. All rights reserved. # # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # # This work was supported in part by the ARPA Manufacturing Automation # and Design Engineering (MADE) Initiative through ARPA contract # F33615-94-C-4400. proc tclLdAout {{cc {}} {shlib_suffix {}} {shlib_cflags none}} { global env global argv if {[string equal $cc ""]} { set cc $env(CC) } # if only two parameters are supplied there is assumed that the # only shlib_suffix is missing. This parameter is anyway available # as "info sharedlibextension" too, so there is no need to transfer # 3 parameters to the function tclLdAout. For compatibility, this # function now accepts both 2 and 3 parameters. if {[string equal $shlib_suffix ""]} { set shlib_cflags $env(SHLIB_CFLAGS) } elseif {[string equal $shlib_cflags "none"]} { set shlib_cflags $shlib_suffix } # seenDotO is nonzero if a .o or .a file has been seen set seenDotO 0 # minusO is nonzero if the last command line argument was "-o". set minusO 0 # head has command line arguments up to but not including the first # .o or .a file. tail has the rest of the arguments. set head {} set tail {} # nmCommand is the "nm" command that lists global symbols from the # object files. set nmCommand {|nm -g} # entryProtos is the table of _Init and _SafeInit prototypes found in the # module. set entryProtos {} # entryPoints is the table of _Init and _SafeInit entries found in the # module. set entryPoints {} # libraries is the list of -L and -l flags to the linker. set libraries {} set libdirs {} # Process command line arguments foreach a $argv { if {!$minusO && [regexp {\.[ao]$} $a]} { set seenDotO 1 lappend nmCommand $a } if {$minusO} { set outputFile $a set minusO 0 } elseif {![string compare $a -o]} { set minusO 1 } if {[regexp {^-[lL]} $a]} { lappend libraries $a if {[regexp {^-L} $a]} { lappend libdirs [string range $a 2 end] } } elseif {$seenDotO} { lappend tail $a } else { lappend head $a } } lappend libdirs /lib /usr/lib # MIPS -- If there are corresponding G0 libraries, replace the # ordinary ones with the G0 ones. set libs {} foreach lib $libraries { if {[regexp {^-l} $lib]} { set lname [string range $lib 2 end] foreach dir $libdirs { if {[file exists [file join $dir lib${lname}_G0.a]]} { set lname ${lname}_G0 break } } lappend libs -l$lname } else { lappend libs $lib } } set libraries $libs # Extract the module name from the "-o" option if {![info exists outputFile]} { error "-o option must be supplied to link a Tcl load module" } set m [file tail $outputFile] if {[regexp {\.a$} $outputFile]} { set shlib_suffix .a } else { set shlib_suffix "" } if {[regexp {\..*$} $outputFile match]} { set l [expr {[string length $m] - [string length $match]}] } else { error "Output file does not appear to have a suffix" } set modName [string tolower $m 0 [expr {$l-1}]] if {[regexp {^lib} $modName]} { set modName [string range $modName 3 end] } if {[regexp {[0-9\.]*(_g0)?$} $modName match]} { set modName [string range $modName 0 [expr {[string length $modName]-[string length $match]-1}]] } set modName [string totitle $modName] # Catalog initialization entry points found in the module set f [open $nmCommand r] while {[gets $f l] >= 0} { if {[regexp {T[ ]*_?([A-Z][a-z0-9_]*_(Safe)?Init(__FP10Tcl_Interp)?)$} $l trash symbol]} { if {![regexp {_?([A-Z][a-z0-9_]*_(Safe)?Init)} $symbol trash s]} { set s $symbol } append entryProtos {extern int } $symbol { (); } \n append entryPoints { } \{ { "} $s {", } $symbol { } \} , \n } } close $f if {[string equal $entryPoints ""]} { error "No entry point found in objects" } # Compose a C function that resolves the initialization entry points and # embeds the required libraries in the object code. set C {#include } append C \n append C {char TclLoadLibraries_} $modName { [] =} \n append C { "@LIBS: } $libraries {";} \n append C $entryProtos append C {static struct } \{ \n append C { char * name;} \n append C { int (*value)();} \n append C \} {dictionary [] = } \{ \n append C $entryPoints append C { 0, 0 } \n \} \; \n append C {typedef struct Tcl_Interp Tcl_Interp;} \n append C {typedef int Tcl_PackageInitProc (Tcl_Interp *);} \n append C {Tcl_PackageInitProc *} \n append C TclLoadDictionary_ $modName { (symbol)} \n append C { CONST char * symbol;} \n append C { { int i; for (i = 0; dictionary [i] . name != 0; ++i) { if (!strcmp (symbol, dictionary [i] . name)) { return dictionary [i].value; } } return 0; } } append C \n # Write the C module and compile it set cFile tcl$modName.c set f [open $cFile w] puts -nonewline $f $C close $f set ccCommand "$cc -c $shlib_cflags $cFile" puts stderr $ccCommand eval exec $ccCommand # Now compose and execute the ld command that packages the module if {[string equal $shlib_suffix ".a"]} { set ldCommand "ar cr $outputFile" regsub { -o} $tail {} tail } else { set ldCommand ld foreach item $head { lappend ldCommand $item } } lappend ldCommand tcl$modName.o foreach item $tail { lappend ldCommand $item } puts stderr $ldCommand eval exec $ldCommand if {[string equal $shlib_suffix ".a"]} { exec ranlib $outputFile } # Clean up working files exec /bin/rm $cFile [file rootname $cFile].o } # word.tcl -- # # This file defines various procedures for computing word boundaries # in strings. This file is primarily needed so Tk text and entry # widgets behave properly for different platforms. # # Copyright (c) 1996 by Sun Microsystems, Inc. # Copyright (c) 1998 by Scritpics Corporation. # # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # # RCS: @(#) $Id: word.tcl,v 1.7.2.1 2005/07/22 21:59:41 dgp Exp $ # The following variables are used to determine which characters are # interpreted as white space. if {$::tcl_platform(platform) eq "windows"} { # Windows style - any but a unicode space char set tcl_wordchars "\\S" set tcl_nonwordchars "\\s" } else { # Motif style - any unicode word char (number, letter, or underscore) set tcl_wordchars "\\w" set tcl_nonwordchars "\\W" } # tcl_wordBreakAfter -- # # This procedure returns the index of the first word boundary # after the starting point in the given string, or -1 if there # are no more boundaries in the given string. The index returned refers # to the first character of the pair that comprises a boundary. # # Arguments: # str - String to search. # start - Index into string specifying starting point. proc tcl_wordBreakAfter {str start} { global tcl_nonwordchars tcl_wordchars set str [string range $str $start end] if {[regexp -indices "$tcl_wordchars$tcl_nonwordchars|$tcl_nonwordchars$tcl_wordchars" $str result]} { return [expr {[lindex $result 1] + $start}] } return -1 } # tcl_wordBreakBefore -- # # This procedure returns the index of the first word boundary # before the starting point in the given string, or -1 if there # are no more boundaries in the given string. The index returned # refers to the second character of the pair that comprises a boundary. # # Arguments: # str - String to search. # start - Index into string specifying starting point. proc tcl_wordBreakBefore {str start} { global tcl_nonwordchars tcl_wordchars if {$start eq "end"} { set start [string length $str] } if {[regexp -indices "^.*($tcl_wordchars$tcl_nonwordchars|$tcl_nonwordchars$tcl_wordchars)" [string range $str 0 $start] result]} { return [lindex $result 1] } return -1 } # tcl_endOfWord -- # # This procedure returns the index of the first end-of-word location # after a starting index in the given string. An end-of-word location # is defined to be the first whitespace character following the first # non-whitespace character after the starting point. Returns -1 if # there are no more words after the starting point. # # Arguments: # str - String to search. # start - Index into string specifying starting point. proc tcl_endOfWord {str start} { global tcl_nonwordchars tcl_wordchars if {[regexp -indices "$tcl_nonwordchars*$tcl_wordchars+$tcl_nonwordchars" \ [string range $str $start end] result]} { return [expr {[lindex $result 1] + $start}] } return -1 } # tcl_startOfNextWord -- # # This procedure returns the index of the first start-of-word location # after a starting index in the given string. A start-of-word # location is defined to be a non-whitespace character following a # whitespace character. Returns -1 if there are no more start-of-word # locations after the starting point. # # Arguments: # str - String to search. # start - Index into string specifying starting point. proc tcl_startOfNextWord {str start} { global tcl_nonwordchars tcl_wordchars if {[regexp -indices "$tcl_wordchars*$tcl_nonwordchars+$tcl_wordchars" \ [string range $str $start end] result]} { return [expr {[lindex $result 1] + $start}] } return -1 } # tcl_startOfPreviousWord -- # # This procedure returns the index of the first start-of-word location # before a starting index in the given string. # # Arguments: # str - String to search. # start - Index into string specifying starting point. proc tcl_startOfPreviousWord {str start} { global tcl_nonwordchars tcl_wordchars if {$start eq "end"} { set start [string length $str] } if {[regexp -indices \ "$tcl_nonwordchars*($tcl_wordchars+)$tcl_nonwordchars*\$" \ [string range $str 0 [expr {$start - 1}]] result word]} { return [lindex $word 0] } return -1 } # Tcl autoload index file, version 2.0 # This file is generated by the "auto_mkindex" command # and sourced to set up indexing information for one or # more commands. Typically each line is a command that # sets an element in the auto_index array, where the # element name is the name of a command and the value is # a script that loads the command. set auto_index(auto_reset) [list source [file join $dir auto.tcl]] set auto_index(tcl_findLibrary) [list source [file join $dir auto.tcl]] set auto_index(auto_mkindex) [list source [file join $dir auto.tcl]] set auto_index(auto_mkindex_old) [list source [file join $dir auto.tcl]] set auto_index(::auto_mkindex_parser::init) [list source [file join $dir auto.tcl]] set auto_index(::auto_mkindex_parser::cleanup) [list source [file join $dir auto.tcl]] set auto_index(::auto_mkindex_parser::mkindex) [list source [file join $dir auto.tcl]] set auto_index(::auto_mkindex_parser::hook) [list source [file join $dir auto.tcl]] set auto_index(::auto_mkindex_parser::slavehook) [list source [file join $dir auto.tcl]] set auto_index(::auto_mkindex_parser::command) [list source [file join $dir auto.tcl]] set auto_index(::auto_mkindex_parser::commandInit) [list source [file join $dir auto.tcl]] set auto_index(::auto_mkindex_parser::fullname) [list source [file join $dir auto.tcl]] set auto_index(history) [list source [file join $dir history.tcl]] set auto_index(::tcl::HistAdd) [list source [file join $dir history.tcl]] set auto_index(::tcl::HistKeep) [list source [file join $dir history.tcl]] set auto_index(::tcl::HistClear) [list source [file join $dir history.tcl]] set auto_index(::tcl::HistInfo) [list source [file join $dir history.tcl]] set auto_index(::tcl::HistRedo) [list source [file join $dir history.tcl]] set auto_index(::tcl::HistIndex) [list source [file join $dir history.tcl]] set auto_index(::tcl::HistEvent) [list source [file join $dir history.tcl]] set auto_index(::tcl::HistChange) [list source [file join $dir history.tcl]] set auto_index(tclLdAout) [list source [file join $dir ldAout.tcl]] set auto_index(pkg_compareExtension) [list source [file join $dir package.tcl]] set auto_index(pkg_mkIndex) [list source [file join $dir package.tcl]] set auto_index(tclPkgSetup) [list source [file join $dir package.tcl]] set auto_index(tclPkgUnknown) [list source [file join $dir package.tcl]] set auto_index(::tcl::MacOSXPkgUnknown) [list source [file join $dir package.tcl]] set auto_index(::tcl::MacPkgUnknown) [list source [file join $dir package.tcl]] set auto_index(::pkg::create) [list source [file join $dir package.tcl]] set auto_index(parray) [list source [file join $dir parray.tcl]] set auto_index(::safe::InterpStatics) [list source [file join $dir safe.tcl]] set auto_index(::safe::InterpNested) [list source [file join $dir safe.tcl]] set auto_index(::safe::interpCreate) [list source [file join $dir safe.tcl]] set auto_index(::safe::interpInit) [list source [file join $dir safe.tcl]] set auto_index(::safe::CheckInterp) [list source [file join $dir safe.tcl]] set auto_index(::safe::interpConfigure) [list source [file join $dir safe.tcl]] set auto_index(::safe::InterpCreate) [list source [file join $dir safe.tcl]] set auto_index(::safe::InterpSetConfig) [list source [file join $dir safe.tcl]] set auto_index(::safe::interpFindInAccessPath) [list source [file join $dir safe.tcl]] set auto_index(::safe::interpAddToAccessPath) [list source [file join $dir safe.tcl]] set auto_index(::safe::InterpInit) [list source [file join $dir safe.tcl]] set auto_index(::safe::AddSubDirs) [list source [file join $dir safe.tcl]] set auto_index(::safe::interpDelete) [list source [file join $dir safe.tcl]] set auto_index(::safe::setLogCmd) [list source [file join $dir safe.tcl]] set auto_index(::safe::SyncAccessPath) [list source [file join $dir safe.tcl]] set auto_index(::safe::InterpStateName) [list source [file join $dir safe.tcl]] set auto_index(::safe::IsInterp) [list source [file join $dir safe.tcl]] set auto_index(::safe::PathToken) [list source [file join $dir safe.tcl]] set auto_index(::safe::PathListName) [list source [file join $dir safe.tcl]] set auto_index(::safe::VirtualPathListName) [list source [file join $dir safe.tcl]] set auto_index(::safe::PathNumberName) [list source [file join $dir safe.tcl]] set auto_index(::safe::StaticsOkName) [list source [file join $dir safe.tcl]] set auto_index(::safe::NestedOkName) [list source [file join $dir safe.tcl]] set auto_index(::safe::Toplevel) [list source [file join $dir safe.tcl]] set auto_index(::safe::Set) [list source [file join $dir safe.tcl]] set auto_index(::safe::Lappend) [list source [file join $dir safe.tcl]] set auto_index(::safe::Unset) [list source [file join $dir safe.tcl]] set auto_index(::safe::Exists) [list source [file join $dir safe.tcl]] set auto_index(::safe::GetAccessPath) [list source [file join $dir safe.tcl]] set auto_index(::safe::StaticsOk) [list source [file join $dir safe.tcl]] set auto_index(::safe::NestedOk) [list source [file join $dir safe.tcl]] set auto_index(::safe::DeleteHookName) [list source [file join $dir safe.tcl]] set auto_index(::safe::TranslatePath) [list source [file join $dir safe.tcl]] set auto_index(::safe::Log) [list source [file join $dir safe.tcl]] set auto_index(::safe::CheckFileName) [list source [file join $dir safe.tcl]] set auto_index(::safe::AliasSource) [list source [file join $dir safe.tcl]] set auto_index(::safe::AliasLoad) [list source [file join $dir safe.tcl]] set auto_index(::safe::FileInAccessPath) [list source [file join $dir safe.tcl]] set auto_index(::safe::Subset) [list source [file join $dir safe.tcl]] set auto_index(::safe::AliasSubset) [list source [file join $dir safe.tcl]] set auto_index(tcl_wordBreakAfter) [list source [file join $dir word.tcl]] set auto_index(tcl_wordBreakBefore) [list source [file join $dir word.tcl]] set auto_index(tcl_endOfWord) [list source [file join $dir word.tcl]] set auto_index(tcl_startOfNextWord) [list source [file join $dir word.tcl]] set auto_index(tcl_startOfPreviousWord) [list source [file join $dir word.tcl]] % . ..% pkgIndex.tcl%http.tcl# Tcl package index file, version 1.1 # This file is generated by the "pkg_mkIndex" command # and sourced either when an application starts up or # by a "package unknown" script. It invokes the # "package ifneeded" command to set up package-related # information so that packages will be loaded automatically # in response to "package require" commands. When this # script is sourced, the variable $dir must contain the # full path name of this file's directory. if {![package vsatisfies [package provide Tcl] 8.4]} {return} package ifneeded http 2.5.5 [list tclPkgSetup $dir http 2.5.5 {{http.tcl source {::http::config ::http::formatQuery ::http::geturl ::http::reset ::http::wait ::http::register ::http::unregister ::http::mapReply}}}] # http.tcl -- # # Client-side HTTP for GET, POST, and HEAD commands. These routines can # be used in untrusted code that uses the Safesock security policy. These # procedures use a callback interface to avoid using vwait, which is not # defined in the safe base. # # See the file "license.terms" for information on usage and redistribution of # this file, and for a DISCLAIMER OF ALL WARRANTIES. # # RCS: @(#) $Id: http.tcl,v 1.43.2.15 2008/02/27 23:58:18 patthoyts Exp $ # Rough version history: # 1.0 Old http_get interface. # 2.0 http:: namespace and http::geturl. # 2.1 Added callbacks to handle arriving data, and timeouts. # 2.2 Added ability to fetch into a channel. # 2.3 Added SSL support, and ability to post from a channel. This version # also cleans up error cases and eliminates the "ioerror" status in # favor of raising an error # 2.4 Added -binary option to http::geturl and charset element to the state # array. package require Tcl 8.4 # Keep this in sync with pkgIndex.tcl and with the install directories # in Makefiles package provide http 2.5.5 namespace eval http { variable http array set http { -accept */* -proxyhost {} -proxyport {} -proxyfilter http::ProxyRequired -urlencoding utf-8 } set http(-useragent) "Tcl http client package [package provide http]" proc init {} { # Set up the map for quoting chars. RFC3986 Section 2.3 say percent # encode all except: "... percent-encoded octets in the ranges of ALPHA # (%41-%5A and %61-%7A), DIGIT (%30-%39), hyphen (%2D), period (%2E), # underscore (%5F), or tilde (%7E) should not be created by URI # producers ..." for {set i 0} {$i <= 256} {incr i} { set c [format %c $i] if {![string match {[-._~a-zA-Z0-9]} $c]} { set map($c) %[format %.2x $i] } } # These are handled specially set map(\n) %0d%0a variable formMap [array get map] } init variable urlTypes array set urlTypes { http {80 ::socket} } variable encodings [string tolower [encoding names]] # This can be changed, but iso8859-1 is the RFC standard. variable defaultCharset "iso8859-1" # Force RFC 3986 strictness in geturl url verification? Not for 8.4.x variable strict 0 namespace export geturl config reset wait formatQuery register unregister # Useful, but not exported: data size status code } # http::register -- # # See documentation for details. # # Arguments: # proto URL protocol prefix, e.g. https # port Default port for protocol # command Command to use to create socket # Results: # list of port and command that was registered. proc http::register {proto port command} { variable urlTypes set urlTypes($proto) [list $port $command] } # http::unregister -- # # Unregisters URL protocol handler # # Arguments: # proto URL protocol prefix, e.g. https # Results: # list of port and command that was unregistered. proc http::unregister {proto} { variable urlTypes if {![info exists urlTypes($proto)]} { return -code error "u