2014-03-02

UDP and IPv6

來自於 comp.lang.tcl 的資料:

A new version 1.0.10 of tcludp is available with IPv6 support added. To obtain the snapshot and windows binaries, please read the following (bottom page):
http://wiki.tcl.tk/8493

2014-02-17

Tcllib 1.16 release

Standard Tcl Library (tcllib) 在最近釋出了新的版本,是為 v1.16 版。

README of Changes


Overview
========

    11  new packages                in 7   modules
    45  changed packages            in 26  modules
    288 internally changed packages in 100 modules
    61  unchanged packages          in 11  modules
    411 packages, total             in 114 modules, total

New in tcllib 1.16
==================

    Module      Package                New Version   Comments
    ----------- ---------------------- ------------- ----------
    debug       debug                  1.0.2
                debug::caller          1
                debug::heartbeat       1
                debug::timestamp       1
    ----------- ---------------------- ------------- ----------
    dtplite     dtplite                1.1
    pt          pt::rde::oo            1.0.2
    sasl        SASL::SCRAM            0.1
    ----------- ---------------------- ------------- ----------
    string      string::token          1
                string::token::shell   1.1
    ----------- ---------------------- ------------- ----------
    tepam       tepam::doc_gen         0.1.1
    websocket   websocket              1.3
    ----------- ---------------------- ------------- ----------


下載網頁:
Download distributions 

2014-01-12

freeWrap 6.62

freeWrap


Changes for version 6.62 (01/04/2014) -
  • This version is based on TCL/TK 8.6.1
  • This version is built with thread support enabled.
所以使用的版本升到 8.6.1 了。

2013-12-19

SampleExtension

SampleExtension implements an extension calculating the Core Secure Hash Algorithm (sha1).

Below is how to download SampleExtension and tclconfig source code method (from Tcler's Wiki):
# Replace sample with the name of your extension
wget -qO- http://core.tcl.tk/sampleextension/tarball/sample.tar.gz | tar xzv
cd sample
wget -qO- http://core.tcl.tk/tclconfig/tarball/tclconfig.tar.gz | tar xzv
# Write your source files
# Edit configure.in
autoconf
# And then the usual:
./configure
make

2013-11-19

openSUSE 13.1 updated Tcl/Tk to 8.6.1

 Please check Features 13.1


Tcl/Tk updated to 8.6.1
  • Tcl major new features:
    • threads enabled by default
    • coroutines
    • IPv6 support
    • built-in OOP witch TclOO
    • built-in zlib support
    • stacked channels
  • Tk major new features:
    • built-in PNG support
    • new portable fontchooser
    • canvas: commands to move items, rotate text
    • additional wm hints
所以如果升級到 openSUSE 13.1,內建的 Tcl/Tk 為 8.6.1.

2013-10-09

Build TclX 8.4.1

在 build 的時候,需要 Tcl 的 source code。configure 使用下列的方式設定:

CPPFLAGS="-I/home/danilo/rpm/SOURCES/tcl8.6.1/generic/ -I/home/danilo/rpm/SOURCES/tcl8.6.1/unix/" ./configure --enable-threads --with-tcl=/usr/lib64


* notice:因為我是使用 x86_64 的作業系統,所以目錄指向 /usr/lib64,如果是 32 位元應該要指向 /usr/lib 才對。然後,因為 TclX 有使用 Tcl 的內部宣告,所以要設定  CPPFLAGS 讓 TclX 在 build 的時候可以找到 header file。


再來就是 make,跟 make install 就可以了。

Build a Tcl/Tk RPM (on openSUSE 12.3)

首先,要先安裝 rpm-build 這個工具。如果是 Ubuntu 的使用者,安裝的命令如下:
sudo apt-get install rpm

在 openSUSE 上我是使用 GUI 安裝軟體,下列是我猜可以使用的 openSUSE 命令,但是我沒試過:
sudo zypper install rpm-build

再來是環境設定,首先在自己的家目錄建立下列的目錄:
  • */rpm
  • */rpm/BUILD
  • */rpm/RPMS
  • */rpm/SOURCES
  • */rpm/SPECS
  • */rpm/SRPMS
Create the .rpmmacros at your home folder for your own rpm build configuratio(下面是相關的範例):

%packager       test <test@gmail.com>
 
%_topdir        /home/test/rpm
%_tmppath       /var/tmp
 
%_rpmtopdir     %{_topdir}
%_builddir      %{_rpmtopdir}/BUILD
%_rpmdir        %{_rpmtopdir}/RPMS
%_sourcedir     %{_rpmtopdir}/SOURCES
%_specdir       %{_rpmtopdir}/SPECS
%_srcrpmdir     %{_rpmtopdir}/SRPMS


再來就下載 Tcl 和 Tk 8.6.1 的 source code package。放到 rpm/SOURCES,使用下列的命令解壓縮:

tar xzvf tcl8.6.1-src.tar.gz
tar xzvf tk8.6.1-src.tar.gz

1. tcl

進入 tcl8.6.1 的目錄下,再進入 unix 目錄,對於 tcl.spec 我們有二個地方要修改:
  1. 預設的安裝目錄:原本是 /usr/local,可以改成 /usr
  2. 在最後再加入一行 %{directory}/share/man/mann,有檔案會安裝到這裡,如果不加會出現問題
如果要建立一個 tclsh 的連結,在  make INSTALL_ROOT=%{buildroot} install 之後,加入下面這一行:
ln -s tclsh%{majorver} $RPM_BUILD_ROOT%{_bindir}/tclsh


然後 tcl.spec 要在 Name:          tcl 這行之前加入版本宣告:

%global majorver1 8
%global majorver2 6
%global majorver %{majorver1}.%{majorver2}


再來使用下列的命令建立 RPM:
rpmbuild --bb tcl.spec

2. tk

先確定 tcl 做好 rpm 之後有安裝成功。另外,還需要 XFree86-dev 有安裝才行。

進入 tk8.6.1 的目錄下,再進入 unix 目錄,對於 tk.spec 我們有一個地方要修改:
  1. 預設的安裝目錄:原本是 /usr/local,可以改成 /usr 
如果要建立一個 wish 的連結,在  make INSTALL_ROOT=%{buildroot} install 之後,加入下面這一行:
ln -s wish%{majorver} $RPM_BUILD_ROOT%{_bindir}/wish

然後在 Name:          tk 這行之前加入版本宣告:

%global majorver1 8
%global majorver2 6
%global majorver %{majorver1}.%{majorver2}


再來使用下列的命令建立 RPM:
rpmbuild --bb tk.spec

2013-10-02

Network Time Protocol (NTP) client

範例:來自 Network Time Protocol - NTP

使用了 Tcllib 中的 NTP package,並且需要使用 TclUDP 或者是 ceptcl 來提供 UDP 支援。
 
package require time

set timeserver "time.stdtime.gov.tw"

proc NetTime {server} {
set tok [time::getsntp $server] ;# or gettime to use the TIME protocol
time::wait $tok
if {[time::status $tok] eq "ok"} {
   set result [time::unixtime $tok]
   set code ok
} else {
   set result [time::error $tok]
   set code error
}
time::cleanup $tok
return -code $code $result
}


exec cmd.exe /c time [clock format [NetTime $timeserver] -format %H:%M:%S]

2013-09-14

PHP on Wub (Wndows Platform, update)

測試環境資料:

Windows 7 64 bit,
ActiveTcl 64 bit,
Tcllib 1.15,
PHP 5.4.19

我在另外一台 Windows XP 重做一次無法成功,目前找不出來失敗的原因,不過我發現我之前沒有全盤讀懂 source code,做了一些沒有用的步驟,更新一次方法。


資料放置目錄:
Wub 放在 c:/Wub
PHP 放在 c:/php


PHP 要修改的地方集中在 php.ini,為下列三個項目:
doc_root = c:/Wub/docroot
cgi.force_redirect = 0
cgi.redirect_status_env = ENV_VAR_NAME


Wub 我修改了二個項目,第一項是 c:/Wub/site.config:

/CGI/ {
    domain CGI
    root $Wub::docroot/cgi
    # windows tcl executor
    executors   {.TCL C:/Tcl/bin/tclsh86.exe .PHP C:/php/php-cgi.exe}
}

另外一個則是增加 PHP mime type 到 Wub 設定 (檔案為 c:/Wub/mime.types):

application/x-php              php

這樣就可以了,不用修改 CGI.tcl。


然後在 c:/Wub/docroot 建立 CGI 目錄,放一個 info.php 測試:

<?php
    phpinfo();
?>    

連線 http://localhost:8080/CGI/info.php 如果有出現資訊就表示成功了。

2013-09-13

Get current OS string

使用下面的變數就可以拿到目前的 OS 字串:

$::tcl_platform(os)


以 Windows XP 來說,結果是下面的字串:

Windows NT