2014-12-27

Get the exact version ot Tcl

記錄一下,如何得到 Tcl 目前的版本號。(可以參考 Get the version of TCL from the command-line?)


使用下列的 command
info patchlevel

2014-12-07

Tclgumbo v0.1

Gumbo

Gumbo is an implementation of the [HTML5 parsing algorithm] implemented as a pure C99 library with no outside dependencies. It's designed to serve as a building block for other tools and libraries such as linters, validators, templating languages, and refactoring and analysis tools.
Goals and features:
* Fully conformant with the [HTML5 spec].
* Robust and resilient to bad input.
* Simple API that can be easily wrapped by other languages.
* Support for source locations and pointers back to the original text.
* Relatively lightweight, with no outside dependencies.
* Passes all [html5lib-0.95 tests].
* Tested on over 2.5 billion pages from Google's index.

Download Gumbo from:
https://github.com/google/gumbo-parser
 

Tclgumbo commands and variables

Tclgumbo is Gumbo Tcl bindings.

Implement commands:
gumbo::parse
gumbo::destroy_output
gumbo::output_get_root
gumbo::node_get_type
gumbo::element_get_tag_name
gumbo::element_get_children
gumbo::text_get_text
gumbo::element_get_attributes
gumbo::element_get_tag_open
gumbo::element_get_tag_close

Add variables:
gumbo::GUMBO_NODE_DOCUMENT
gumbo::GUMBO_NODE_ELEMENT
gumbo::GUMBO_NODE_TEXT
gumbo::GUMBO_NODE_CDATA
gumbo::GUMBO_NODE_COMMENT
gumbo::GUMBO_NODE_WHITESPACE

Installation

Installation (Linux/GCC):
cd tclgumbo
./configure
make
make install

Installation (Winodws/MSYS/MinGW):
cd tclgumbo
./configure
make
make install

Installation (Winodws/Visual Studio):
VS does not support C std99. I don't know how to use VS to build this package.


網站:
Tclgumbo

這是我自我練習的程式。我使用 tests 下的 tclgumbo.test 進行基本功能的測試。因為只有很簡單的測試,所以我不確定有沒有沒改好的部份,不過按照 GumboPHP 的說明文件,我已經把我會實作的部份都做完了。

Tcltaglib v0.2

Tcl interface for taglib (Abstract API only).

實作 taglib C binding 的 Tcl command 對映。 測試的 script 是 examples 下的 reader.tcl。


網頁位址:
https://sites.google.com/site/ray2501/tcltaglib 


更新:
整體的 source code 和 v0.1 相同,我只是清除了一些看起來錯誤的註解跟 label 錯誤的地方,然後我的 openSUSE 環境因為已經升到了 13.2,所以 RPM  是用 13.2 的環境製作的。

2014-12-02

Tcl-lzf: Tcl interface for LibLZF

LZF is an extremely fast (not that much slower than a pure memcpy) compression algorithm. It is ideal for applications where you want to save *some* space but not at the cost of speed. It is ideal for repetitive data as well. The module is self-contained and very small.

It's written in ISO-C with no external dependencies other than what C provides and can easily be #include'd into your code, no makefile changes or library builds requires.

LibLZF this library was written by Marc Lehmann (See also http://software.schmorp.de/pkg/liblzf).


This package (Tcl-lzf) provides a simple Tcl interface to the LibLZF Library.
Implement commands:
lzf::compress - accepts a string to compress.
lzf::decompress - accepts a string and a size in which the uncompressed result must fit.


網址:
Tcl-lzf

2014-11-01

TLS and Openssl - Static libraries (w32, mingw/msys)

首先是 OpenSSL,按照這篇的資訊,下載目前的版本 openssl-1.0.1j,然後使用下面的設定:

./Configure no-asm mingw --prefix=/c/OpenSSL

而在 test 的部份會有一些編譯失敗,我刪除掉以後繼續編譯,就可以成功編譯 OpenSSL。


再來是 TLS,source code 是從 CVS 下載最新的 tarball。configure 的命令我是這樣下:

./configure --with-tcl=/opt/tcl/lib --with-ssl-dir=/c/OpenSSL --with-gcclib

但是仍然需要修改 Makefile。找到 -lssleay32 -llibeay32,改成 -lssl -lcrypto -lws2_32 -lgdi32 -lcrypt32,這樣就可以編譯成功了。


但是這樣編譯出來的 tls DLL 會非常的大,不知道我是不是哪裡有做錯。

2014-10-07

Build TclVFS, using MinGW (on Windows platform)

Download GNU tarball 下載最新的 code,按照 configure/make 的方法做就可以了,只是需要做一點小修改。

generic\vfs.c,找到 tcl.h,針對 stat 的部份修改如下:

#define _USE_32BIT_TIME_T
#include <sys/stat.h>
#ifndef _stat32i64
# define _stat32i64 _stati64
#endif
#include <tcl.h>

這樣就可以編譯成功了。

2014-09-28

Komodo Edit

Komodo Edit (維基百科)


Powerful free editor for Python, PHP, Perl, Ruby, Tcl, Javascript and other major web languages.


上一次我試著使用的時候(在一開始很久很久以前),Tcl Syntax 的部份需要另外安裝,不過目前的版本已經直接支援了。


下載點:
Download Komodo Edit

2014-09-09

Build tDom 0.8.3 on Windows x86 platform, using MinGW/MSYS

沒有特別需要設定的,只是要注意下列這點:

如果是 Tcl/Tk 8.6.x 系列的,需要使用 GitHub 上的 source code,直接下載 tDom 0.8.3 的 source code package 可能會編譯失敗。

2014-08-31

Build TclX 8.4.1 on Windows x86 platform, using MinGW/MSYS

編譯的環境為 Windows XP SP3 32bit,編譯器為 MinGW/MSYS。

使用 configure 的時候,因為沒有 random/srandom function,使用下列的方式定義:
CPPFLAGS="-Drandom=rand -Dsrandom=srand" ./configure --enable-threads --with-tcl=/opt/tcl/lib


造出 Makefile 以後,需要進行一些修改:
找到 PKG_OBJECTS,然後移除 random.o (不然會編譯錯誤)
random/srandom function 不是標準的 C standard function,所以 TclX 會預設有一個 random.c 要編譯,但是我使用了在 CPPFLAGS 定義的方式,所以移除 random.o,這是不需要的(總不能造一個空的給 GCC 吧,雖然應該也可以)。

再來修改 win\tclXwinPort.h,將 random 的定義修改如下(由 long 改為 int):
extern int    random(void);

再來 TclX 就可以編譯成功了。


執行 make test,會在 profile.test crash 掉,如果移掉 profile.test 不測試,下面是進行 test 以後的結果:
all.tcl:        Total   1481    Passed  1447    Skipped 23      Failed  11

2014-08-23

透過 WMI 取得目前 BIOS 的版本資料 (on WIndows platform)

使用 TWAPI 透過 WMI 取得目前 BIOS 的版本資料,下面是一個測試的 sample code:
package require twapi_wmi
package require twapi_process
namespace path twapi

set wmi [comobj_object winmgmts:root/cimv2]
set wql {SELECT * FROM Win32_BIOS}
set BIOS [$wmi ExecQuery $wql]

$BIOS -iterate bios_info {    
    puts -nonewline "Description: "
    set DescriptionVal [$bios_info -with {Properties_ {Item Description}} Value]          
    puts $DescriptionVal
    
    puts -nonewline "BIOS Manufacturer: "
    set ManufacturerVal [$bios_info -with {Properties_ {Item Manufacturer}} Value]          
    puts $ManufacturerVal
    
    puts -nonewline "Name: "
    set NameVal [$bios_info -with {Properties_ {Item Name}} Value]          
    puts $NameVal        
    
    puts -nonewline "SMBIOSBIOSVersion: "
    set SMBIOSBIOSVersionVal [$bios_info -with {Properties_ {Item SMBIOSBIOSVersion}} Value]          
    puts $SMBIOSBIOSVersionVal
    
    puts -nonewline "Version: "
    set VersionVal [$bios_info -with {Properties_ {Item Version}} Value]          
    puts $VersionVal        

    $bios_info -destroy
}

$BIOS -destroy
$wmi -destroy

2014-08-04

Tclqrencode v0.2

更新了libqrencode 的 code base,所以版本升為 v0.2。 


連結網址:
Tclqrencode


我只有使用 Tclqrencode v0.1 這篇文章的範例進行測試,希望不會有什麼問題。

2014-07-14

Remove Itcl and Itk 3.4 if using ActiveTcl 8.6

ActiveTcl 8.6 在 Tcl\lib\teapot\package\win32-x86_64\lib 或者是 Tcl\lib\teapot\package\win32-ix86\lib 下仍然有提供 Itcl/Itk 3.4,而 Tcl/Tk 8.6 所增加的 Itcl 4 為使用 TclOO 改寫的版本。

如果怕使用上可能會造成問題,可以使用 teacup 移除:
teacup remove Itcl 3.4
teacup remove Itk 3.4

將 ITcl 3.4 與 Itk 3.4 移除,避免 ITcl 3.4 在 Tcl/Tk 8.6 環境下執行會 crash 的問題。

2014-07-01

Tcl on Windows FAQ link

Tcl on Windows FAQ


在網路上搜尋東西的時候發現的,我根據這個 FAQ 的資料,加了幾個我有興趣的 extension 的連結到部落格的右側。


另外就是最近在 Tcler's Wiki 看到的書籍資訊:
BOOK Tcl Programming for Windows

2014-06-27

Tcl Modules

Tcl Modules
TIP #189: Tcl Modules
TIP #190: Implementation Choices for Tcl Modules
TIP #191: Managing Tcl Packages and Modules in a Multi-Version Environment


A Tcl module is a package in a single file that can be sourced. (DLLs may still be embedded in that). There is no pkgIndex.tcl file, the package name and version are expressed in the module filename itself, so that version 3.14 of package foo must be named foo-3.14.tm.

"Tcl Modules" on the other hand is designed with less flexibility in mind and to allow implementations to glean as much information as possible without having to perform lots of accesses to the filesystem.

Additional benefits of the proposed design are a simplified deployment of packages, akin to the way starkits made application deployment simple, and from that an easier implementation and management of repositories.


Tcl Modules (.tm) 檔案的文件。

2014-05-17

Img extension

在 Windows 平台下,使用 ActiveTcl,可以用 teacup 來安裝:
teacup install Img

在 openSUSE,則是安裝 tkimg 這個套件就可以了。可以使用下列的指令安裝:
sudo zypper in tkimg

套件說明 @ openSUSE RPM:
This package contains a collection of image format handlers for the Tk photo image type, and a new image type, pixmaps. The provided format handlers include bmp, gif, ico, jpeg, pcx, png, ppm, ps, sgi, sun, tga, tiff, xbm, and xpm.

2014-05-14

Get Wub snapshot code

Wub snapshot tarball at https://code.google.com/p/wub/ link is "Oops, you've found a dead link." now.


所以後來只好使用 SVN 下載目前的 code base:
svn checkout http://wub.googlecode.com/svn/trunk/ wub


不知道 Wub 什麼時候會釋出新版本,不過如果要使用比 0.5 版更新的 code 來測試,之前是下載 snapshot tarball 就可以了,現在則需要使用 SVN  才行。

2014-04-22

Tcl Extension Archive (teapot)

Tcl Extension Archive


From Tcler's Wiki 的解釋:

The Tcl Extension Archive is a repository of Tcl extensions hosted by ActiveState. Both pure-Tcl and compiled extensions are included, for Windows, Unix and MacOS X platforms. The URL of the archive is http://teapot.activestate.com/


如果使用 ActiveTcl,可以使用 Tcl Extension Archive (teapot) client - Teacup 來查詢與安裝 package,比較常用的應該都可以找到。


Teapot Repos

根據 Tcler's Wiki 的資料,有下列的 Repos 可以使用:
http://teapot.activestate.com/
http://teapot.rkeene.org/
 
 
而網頁的列表,就是目前有收集的 packages。

2014-04-20

freeWrap 6.63

ANNOUNCE: freeWrap 6.63 released



Changes implemented in version 6.63
------------------------------
-----
  1. Wrapping across operating systems has been corrected:
  2. a) between 32-bit and 64-bit Linux
    b) from Windows to Linux
  3. Temporary file names used by freeWrap during the wrapping process have been modified to prevent possible collision with existing file names. This will prevent the possibility of overwriting of an existing file during wrapping.
  4. The ::freewrap::makeZIP command can now be used more than once. Previously, the first usage of the command worked while subsequent use failed with an error.
  5. Options have been added to the freeWrap command line that allow the user to control the amount of compression performed on the wrapped files. See the freeWrap documentation for details.
  6. The tcllib package included in freeWrap has been updated to version 1.16 and is located at the virtual directory of /tcllib1.16.
  7. The -i option can now be used to change the program icon when performing a cross-wrap with the -w option.


Tcl/Tk 的版本一樣是 8.6.1。

2014-04-13

Tcl/Tk 的多國語言做法

Tcl/Tk 的多國語言做法是使用 msgcat 這個 command,他的使用概念是直接把一個字串當做是 index , 再去根據系統目前設定的語系,找出翻譯好的字串替代。

source 功能和 BASH 的 source 類似,也和 C 的 include 類似。 我們可以利用這個函數去載入翻譯檔。簡單說,就是自己判斷語系,然後自行載入翻譯檔。

如果沒有該語系的翻譯檔,它就什麼都不翻譯,而是使用你程式所寫的字串。

2014-03-26

Build TclVfs on openSUSE 13.1

TclVfs


下載  tclvfs-20080503.tar.gz 來 build,結果 fail.

經過 Google 以及研究以後,要去 Source Forge 裡 CVS 目前的 code base (web-based CVS repository viewer) 去下載最新的 vfs.c,這樣就可以修正升到 Tcl 8.6 以後 build fail 的問題。


更新:
我發現我做了一件笨事情,其實按 Download GNU tarball 下載最新的 code 就好了。

2014-03-22

Tclqrencode v0.1

連結網址:
Tclqrencode


使用 libqrencode 這個函式庫提供的功能,可以用來造出 QR code file.

下面是一個使用的例子:
#!/usr/bin/tclsh

package require tclqrencode

qrencode::setsize  5
qrencode::setforeground  000000
qrencode::setbackground  ff8fff

qrencode::encode http://tcl-eval.blogspot.tw/ tcl-eval.png

結果:


2014/03/22更新:
qrspec.c and mqrspec.c 使用了 pthread,我改寫成 Tcl 所提供的 thread function.

2014-03-21

tcltest

Tcler's Wiki: tcltest
Getting started with tcltest

 
The tcltest package provides the user with utility tools for writing and running tests in the Tcl test suite. It can also be used to create a customized test harness for an extension.


所以一些 extension 下 tests 目錄裡的檔案,應該都是使用 tcltest 來進行測試的相關檔案。我記錄一下相關的連結。

2014-03-19

Tcllib/TKlib RPM spec @ openSUSE

Source code 裡的 RPM spec (tcllib.spec, tklib.spec),大致上的問題都一樣:

Copyright: BSD

改成:

License: BSD


然後如果要安裝附帶的 application,在 -pkg-path 之前加上一列:

    -app-path $RPM_BUILD_ROOT/usr/bin \


再來因為是 openSUSE,所以 library 的路徑要指向 /usr/share/tcl:

    -pkg-path $RPM_BUILD_ROOT/usr/lib/%{name}-%{version}\

改成:

-pkg-path $RPM_BUILD_ROOT/usr/share/tcl/%{name}-%{version}\

改完了以後,使用 rpmbuild 就可以造出來 RPM。

( * 如果是從網站下載,tcllib 的版本仍然是 1.15,需要自己改為 1.16)

(*  我用 rpm -e 移除以後,檔案還在 目錄還在,檔案則被移除了,苦笑中。)

RPM spec for Tcltaglib 0.1

我的測試環境是 openSUSE 13.1 (64 bit),所以安裝的目錄要特別設定,要放到 /usr/lib64/tcl,我放了一個 tcltaglib_SUSE.spec 到原始檔裡,應該可以用

 rpmbuild -bb tcltaglib_SUSE.spec 

來造出 rpm 檔。


檔案的內容:

%{!?directory:%define directory /usr}

%define buildroot %{_tmppath}/%{name}

Name:          tcltaglib
Summary:       Tcl interface for tablib
Version:       0.1
Release:       1
License:       BSD
Group:         Development/Libraries/Tcl
Source:        https://sites.google.com/site/ray2501/tcltaglib/tcltaglib_0.1.zip
URL:           https://sites.google.com/site/ray2501/tcltaglib 
Buildrequires: libtag1 tcl >= 8.1
BuildRoot:     %{buildroot}

%description
Tcl interface for taglib (Abstract API only).

%prep
%setup -q -n %{name}

%build
CFLAGS="%optflags" ./configure \
    --prefix=%{directory} \
    --exec-prefix=%{directory} \
    --libdir=%{directory}/%{_lib}
make 

%install
make DESTDIR=%{buildroot} pkglibdir=%{directory}/%{_lib}/tcl/%{name}%{version} install

%clean
rm -rf %buildroot

%files
%defattr(-,root,root)
%{directory}/%{_lib}/tcl

2014-03-15

Tcltaglib v0.1

Tcl interface for taglib (Abstract API only).

實作 taglib C binding 的 Tcl command 對映。 測試的 script 是 examples 下的 reader.tcl。



網頁位址:
https://sites.google.com/site/ray2501/tcltaglib

2014-03-14

Tclusb v0.3

沒什麼改進,只是我發現 tclusb.h 不用公開,所以從 configure.in 中的 TEA_ADD_HEADERS macro 移除。


網頁連結:
Tclusb


20140315 更新:
Update Windows rc file 
Remove tests folder 

2014-03-09

Tclusb v0.2

增加 USB hotplug 的 command:
usb::hotplug


主要是參考其它的 package 以後,使用 channel 實作 USB hotplug function,但是我不確定這樣做是不是好的做法。不過這樣的實作下可以使用 fileevent 來 detect event,所以當有 event 發生的時候,libusb callback function 就會通知 Channel 現在可以讀取了,然後傳回的是一個 handle 和 arrive or left event 的字串。

然後實作寫入 handle string,就會從 hash table 移除相關 entry 的功能(我會加 sleep 是因為有時候寫入的 function 在處理 hash table entry 時會發生 segmentation fault,加入 sleep 可以大幅度的降低發生頻律)。


Link:
Tclusb

2014-03-06

Tclusb v0.1

Tclusb


雖然我是寫 "The Tclusb extension provides an interface for libusb library.",不過實際上我實作的 Tcl command 大約只夠寫 USB listdevs 這類的程式。

用來學習 Tcl extension 怎麼加入外部的函式庫連結和一些 Tcl C function 的呼叫。也許對某些人有用,所以我把 source code 放一份到我自己的網站上,授權我選 BSD license.

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 了。