2015-10-09

Tclunqlite v0.1

我實作了 UnQLite 一部份的 Database Engine Handle, Key/Value Store Interfaces, Cursor Iterator Interfaces 與 Manual Transaction Manager 功能。

UnQLite 的儲存方式有二種,一種是 key-pair,一種是 JSON 文件。目前我已經實作了一部份 key-pair 方式的功能。

這是一個嘗試實作的 draft 版本,我有寫一些簡單的測試檔案進行測試目前實作的部份,不過因為沒有大量測試,所以請不要用在需要高可靠度的環境。

檔案放置網頁

Tclunqlite

About

This is the UnQLite extension for Tcl using the Tcl Extension Architecture (TEA).

UnQLite is a in-process software library which implements a self-contained, serverless, zero-configuration, transactional NoSQL database engine. This extension provides an easy to use interface for accessing UnQLite database files from Tcl.

License and version

BSD license, v0.1 (draft version)

UNIX BUILD

Building under most UNIX systems is easy, just run the configure script and then run make. For more information about the build process, see the tcl/unix/README file in the Tcl src dist. The following minimal example will install the extension in the /opt/tcl directory.

$ cd tclunqlite
$ ./configure --prefix=/opt/tcl
$ make
$ make install

WINDOWS BUILD

The recommended method to build extensions under windows is to use the Msys + Mingw build process. This provides a Unix-style build while generating native Windows binaries. Using the Msys + Mingw build tools means that you can use the same configure script as per the Unix build to create a Makefile.

Implement commands

Basic usage

unqlite DBNAME FILENAME ?-readonly BOOLEAN? ?-mmap BOOLEAN? ?-create BOOLEAN? ?-in-memory BOOLEAN? ?-nomutex BOOLEAN?
DBNAME close
DBNAME config ?-disableautocommit BOOLEAN?

Key/value features

DBNAME kv_store key value
DBNAME kv_append key value
DBNAME kv_fetch key
DBNAME kv_delete key

Transactions

DBNAME begin
DBNAME commit
DBNAME rollback

Cursors

DBNAME cursor_init CURSORNAME
CURSORNAME seek
CURSORNAME first
CURSORNAME last
CURSORNAME next
CURSORNAME prev
CURSORNAME isvalid
CURSORNAME getkey
CURSORNAME getdata
CURSORNAME delete
CURSORNAME reset
CURSORNAME release

Misc

DBNAME random_string buf_size
DBNAME version

2015-09-15

TclRAL: Tcl Relational Algebra Library

最近剛釋出了新版:
ANNOUNCE TclRAL Version 0.11.7 

網頁上的介紹:

TclRAL is a "C" based extention of the TCL language that is an implementation of the Relational Algebra. From a programmers point of view, the library is a Tcl package that introduces two new native data types and a set of commands that operate on them. The new data types are:
  • Tuple
  • Relation

也是很有趣的套件。

2015-09-06

A 3-D Canvas Widget For Tcl/Tk

我在閱讀 AndroWish 資料的時候,發現 AndroWish 包含了一個 3-D Canvas Widget,我想應該是用來支援 Open GL 的部份。

官網的介紹如下:

The 3-D Canvas Widget provides Tk programs with 3-D graphics capabilities through the use of OpenGL. But the 3-D Canvas widget is not another thin wrapper around the OpenGL interface. This widget is a much higher-level abstraction. Just as the built-in canvas widget of Tk is a high-level abstraction of the X11 drawing routines, so too the 3-D Canvas widget is a high-level abstraction of OpenGL. 

The 3dcanvas project is stable and has been in use and relatively unchanged for several years. New contributors who want to expand and enhance 3dcanvas are welcomed.

我覺得很有趣,所以從 3-D Canvas Widget timeline page 選取了 tag 1.2.1 然後下載,並且使用 MSYS/MinGW 的組合來編譯看看。

結果很順利的編譯成功,同時 demo 的部份也可以執行,所以看起來是可以使用的。

2015-08-23

Tcl extension: VecTcl

我在 comp.lang.tcl 看到了一篇文章:
Ann: VecTcl 0.2 release + binaries available


VecTcl 釋出了 0.2 版,並且有 binaries 可以使用。


官網:
VecTcl - numerical math in Tcl


官網的介紹如下:

This package provides a numerical array extension for Tcl with support for vectors, matrices and higher-rank tensors of integers, floating point and complex numbers. It has builtin support for basic array shaping, slicing and linear algebra subroutines and is designed to integrate seamlessly with Tcl. The user interface consists of a single command, vexpr, which acts as an expression evaluator similar to expr. The language supported by vexpr is inspired by Matlab, which closely models the language used by textbook math.


很有趣的一個套件,如果執行的時候夠高效的話,應該對於一些數學運算有幫助。

2015-07-14

Build Tix extension package

Tix Widget Set for Tk/Tcl and Python


使用 MSYS/MINGW 來編譯。在 make 的時候發現編譯 tixGrSort.c 會發生錯誤。觀察錯誤訊息以後,應該是要設 flag 否則在 Tcl 8.6,無法直接使用 Tcl_Interp member result。

typedef struct Tcl_Interp
#ifndef TCL_NO_DEPRECATED
{
    /* TIP #330: Strongly discourage extensions from using the string
     * result. */
#ifdef USE_INTERP_RESULT
    char *result TCL_DEPRECATED_API("use Tcl_GetStringResult/Tcl_SetResult");
                /* If the last command returned a string
                 * result, this points to it. */
    void (*freeProc) (char *blockPtr)
        TCL_DEPRECATED_API("use Tcl_GetStringResult/Tcl_SetResult");
                /* Zero means the string result is statically
                 * allocated. TCL_DYNAMIC means it was
                 * allocated with ckalloc and should be freed
                 * with ckfree. Other values give the address
                 * of function to invoke to free the result.
                 * Tcl_Eval must free it before executing next
                 * command. */
#else
    char *resultDontUse; /* Don't use in extensions! */
    void (*freeProcDontUse) (char *); /* Don't use in extensions! */
#endif
#ifdef USE_INTERP_ERRORLINE
    int errorLine TCL_DEPRECATED_API("use Tcl_GetErrorLine/Tcl_SetErrorLine");
                /* When TCL_ERROR is returned, this gives the
                 * line number within the command where the
                 * error occurred (1 if first line). */
#else
    int errorLineDontUse; /* Don't use in extensions! */
#endif
}
#endif /* TCL_NO_DEPRECATED */
Tcl_Interp;

所以我把 source code 改寫為下列的樣子,只是不知道改的對不對。
    order = strtol(Tcl_GetStringResult(sortInterp), &end, 0);
    if ((end == Tcl_GetStringResult(sortInterp)) || (*end != 0)) {

2015-07-10

TLS 1.6.7 與 OpenSSL

TLS 1.6.7 與 OpenSSL 的更新都在最近這一、二天釋出。

TLS 釋出了新版,版本號為 1.6.7。

另外一方面,OpenSSL專案小組近日緊急預告,將於7月9日釋出OpenSSL 1.0.2d和1.0.1p新版,來修補一個高風險漏洞。(新聞:記得要更新!OpenSSL又爆罕見高風險漏洞,官網預告7月9日釋修補)所以如果使用 1.0.2 與 1.0.1 版本 OpenSSL 的使用者需要更新到新版才行。

2015-05-04

Tcllib 1.17 released

Tcllib 1.17 released


An excerpt from the release README:

    6   new packages                in 5   modules
    66  changed packages            in 39  modules
    46  internally changed packages in 31  modules
    293 unchanged packages          in 74  modules
    418 packages, total             in 118 modules, total

The full details can be found in the
[release technote](http://core.tcl.tk/tcllib/technote/56416fe9cf1b0c0f5cd535861225a56af8228999).

2015-02-28

TLS v1.6.4 is out

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


下載 TLS v1.6.4 以後使用之前 MinGW/MSYS 的方式編譯,確定可以編譯。


測試的 script 從 Tcler's Wiki 來的:
package require tls
variable quit 0

proc Read {chan} {
    if {[eof $chan]} { fileevent $chan readable {}; puts "Closed"; set ::forever 1; return }
    puts [read $chan]
    variable quit ; if {!$quit} { puts $chan QUIT; set quit 0 }
}

proc Write {chan} {
    fileevent $chan writable {}
    tls::handshake $chan
    fconfigure $chan -buffering line -blocking 0 -translation crlf
}

set sock [tls::socket -async pop.gmail.com 995]
fconfigure $sock -encoding binary -buffering none -blocking 1
fileevent $sock writable [list Write $sock]
fileevent $sock readable [list Read $sock]

vwait ::forever

2015-02-26

Wub Direct example

Tcler's Wiki: Wub Direct


稍微嘗試了一下 Tcler's Wiki 提供的範例,發現 local.tcl 如果是使用 svn checkout 目前的 code,要放在跟 site.config 與 Wub.tcl 同一個目錄中。


我發現在 examples 有放一個 hello-direct.tcl,想要測試這個檔案,所以在 local.tcl 使用:
source examples/hello-direct.tcl

然後加入下列的設定到 site.config -
hello {
       domain Direct
       url /hello
       namespace ::Hello
}

再打 http://localhost:8080/hello/ 測試,是有網頁內容顯示的(而不是丟出錯誤訊息),看起來有成功。


但是在 local.tcl 直接使用 source 的方式感覺還是有點怪怪的,不知是否有更好的方式。


更新:
在設定  hello-direct.tcl 以後,又用 hello 來測試 Wub 的 rewrite 功能,site.config 設定如下:
testrewrite {
    url /testrewrite
    rewrite /hello
}

如果使用 http://localhost:8080/testrewrite/ 測試,確實會被轉到 http://localhost:8080/hello/。

2015-02-12

REST library at Tcllib

a rest framework
rest - A framework for RESTful web services


寫了一個 FACEBOOK REST API 的小程式來測試:
package require rest

set urls "http://tcl-eval.blogspot.tw/"
set res [rest::get http://api.facebook.com/restserver.php [list method links.getStats urls $urls]]
puts $res

Facebook 回傳回來的是 XML 形式的資料,我只有印出來確定沒問題,但是看樣子是可以使用的。

下面就是結果:
<?xml version="1.0" encoding="UTF-8"?>
<links_getStats_response xmlns="http://api.facebook.com/1.0/" xmlns:xsi="http://
www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://api.facebook.com/
1.0/ http://api.facebook.com/1.0/facebook.xsd" list="true">
  <link_stat>
    <url>http://tcl-eval.blogspot.tw/</url>
    <normalized_url>http://tcl-eval.blogspot.tw/</normalized_url>
    <share_count>0</share_count>
    <like_count>0</like_count>
    <comment_count>0</comment_count>
    <total_count>0</total_count>
    <click_count>0</click_count>
    <comments_fbid xsi:nil="true"/>
    <commentsbox_count>0</commentsbox_count>
  </link_stat>
</links_getStats_response>