OSDN Git Service

Add: make install
authorAkira <akohta001@gmail.com>
Sat, 9 Nov 2013 15:35:40 +0000 (00:35 +0900)
committerAkira <akohta001@gmail.com>
Sat, 9 Nov 2013 15:35:40 +0000 (00:35 +0900)
Add: Interpolate defective url(ttp:// --> http://).
Add: display referenced numbers in res view.
Add: restrict display res messges to res numbers or ids, the numbers link to a particular res number.

25 files changed:
Makefile
Makefile.in
README
config.h
configure
configure.ac
gen/Readme [deleted file]
help.txt
src/_2ch/model_2ch.c
src/_2ch/model_func.c
src/_2ch/parse_2ch.c
src/_2ch/parse_string.c
src/env.c
src/inc/_2ch/model_2ch.h
src/inc/_2ch/parse_2ch.h
src/inc/config.h [new file with mode: 0644]
src/inc/env.h
src/inc/utils/nt_std_t.h
src/inc/utils/text.h
src/net/nt_cookie.c
src/ui/disp_reslist.c
src/ui/disp_threadlist.c
src/utils/base64.c
src/utils/nt_std_t.c
src/utils/text.c

index 8dfc73c..3dc08a2 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -9,9 +9,9 @@
 #GDBM_COMPT_OPT = -DGDBM_COMPT
 
 #Option for development
-#CFLAGS = -g -Wall -DDEBUG ${CDEF} ${GDBM_COMPT_OPT} 
+#CFLAGS = -g -Wall -DDEBUG ${DEFS} ${CDEF} ${GDBM_COMPT_OPT} 
 #Option for release
-CFLAGS = -Wall ${CDEF} ${GDBM_COMPT_OPT}
+CFLAGS = -Wall ${DEFS} ${CDEF} ${GDBM_COMPT_OPT}
 
 CDEF = -D_REENTRANT -D_XOPEN_SOURCE_EXTENDED 
 #-D_XOPEN_SOURCE
@@ -48,7 +48,8 @@ OBJS = ${OBJ_DIR}/main.o ${OBJ_DIR}/utils/nt_std_t.o \
     ${OBJ_DIR}/ui/disp_html_result.o \
     ${OBJ_DIR}/ui/disp_string.o
 
-INC_FILES = ${INC_DIR}/env.h \
+INC_FILES = ${INC_DIR}/config.h \
+       ${INC_DIR}/env.h \
        ${INC_DIR}/error.h \
        ${INC_DIR}/nt_string.h \
        ${INC_DIR}/_2ch/_2ch.h \
@@ -86,14 +87,15 @@ srcdir = .
 
 CC = gcc
 DEFS = -DHAVE_CONFIG_H
-LIBS = -lz -lssl -lsqlite3 -lpthread -lncursesw -lm -lgdbm_compat -lgdbm -ldl -lcrypto 
+LIBS = -lz -lssl -lsqlite3 -lpthread -lncursesw -lm -lgdbm_compat -ldl -lcrypto 
 #LIBS = -lncursesw -lgdbm -lz -lm -lssl -lcrypto -lgdbm_compat -lsqlite3 -ldl -lpthread
 INCLUDES = -I/usr/include/gdbm -I${INC_DIR}
 OBJ_DIR = ./obj
 GEN_DIR = ./gen
 SRC_DIR = ${srcdir}/src
 INC_DIR = ${SRC_DIR}/inc
-
+INSTALL_DIR = ${prefix}/bin
+INSTALL_PROG = /usr/bin/install -c
 all : ${TARGET}
 
 run : 
@@ -111,10 +113,16 @@ clean:
        @ ${SHELL} prepare_proj.sh -d
        rm -rf ${TARGET} 
 
+install: ${TARGET}
+       ${INSTALL_PROG} -m 755 -t ${INSTALL_DIR} ${TARGET}
+
 $(OBJ_DIR)/print_help.o : help.txt help_gen
        ./help_gen help.txt > ${GEN_DIR}/print_help.c
        ${CC} ${CFLAGS} -c -o $@ ${GEN_DIR}/print_help.c 
 
+${INC_DIR}/config.h : config.h
+       cp -f $< $@
+
 help_gen : help_gen.c
        ${CC} -o $@ $<
 
index 9a8a557..25fb461 100644 (file)
@@ -9,9 +9,9 @@
 #GDBM_COMPT_OPT = -DGDBM_COMPT
 
 #Option for development
-#CFLAGS = -g -Wall -DDEBUG ${CDEF} ${GDBM_COMPT_OPT} 
+#CFLAGS = -g -Wall -DDEBUG ${DEFS} ${CDEF} ${GDBM_COMPT_OPT} 
 #Option for release
-CFLAGS = -Wall ${CDEF} ${GDBM_COMPT_OPT}
+CFLAGS = -Wall ${DEFS} ${CDEF} ${GDBM_COMPT_OPT}
 
 CDEF = -D_REENTRANT -D_XOPEN_SOURCE_EXTENDED 
 #-D_XOPEN_SOURCE
@@ -48,7 +48,8 @@ OBJS = ${OBJ_DIR}/main.o ${OBJ_DIR}/utils/nt_std_t.o \
     ${OBJ_DIR}/ui/disp_html_result.o \
     ${OBJ_DIR}/ui/disp_string.o
 
-INC_FILES = ${INC_DIR}/env.h \
+INC_FILES = ${INC_DIR}/config.h \
+       ${INC_DIR}/env.h \
        ${INC_DIR}/error.h \
        ${INC_DIR}/nt_string.h \
        ${INC_DIR}/_2ch/_2ch.h \
@@ -93,7 +94,8 @@ OBJ_DIR = ./obj
 GEN_DIR = ./gen
 SRC_DIR = ${srcdir}/src
 INC_DIR = ${SRC_DIR}/inc
-
+INSTALL_DIR = ${prefix}/bin
+INSTALL_PROG = @INSTALL@
 all : ${TARGET}
 
 run : 
@@ -111,10 +113,16 @@ clean:
        @ ${SHELL} prepare_proj.sh -d
        rm -rf ${TARGET} 
 
+install: ${TARGET}
+       ${INSTALL_PROG} -m 755 -t ${INSTALL_DIR} ${TARGET}
+
 $(OBJ_DIR)/print_help.o : help.txt help_gen
        ./help_gen help.txt > ${GEN_DIR}/print_help.c
        ${CC} ${CFLAGS} -c -o $@ ${GEN_DIR}/print_help.c 
 
+${INC_DIR}/config.h : config.h
+       cp -f $< $@
+
 help_gen : help_gen.c
        ${CC} -o $@ $<
 
diff --git a/README b/README
index b7b449e..7c40777 100644 (file)
--- a/README
+++ b/README
@@ -1,5 +1,5 @@
 
-    ntch  version 1.0.1.5
+    ntch  version 1.0.1.6
 
     This file is part of ntch.
 
 
 Linux用 2ch専用ブラウザー
 
--v --version
-       バージョンを表示します
-
--h --help
-       このヘルプを表示します
-
--r -refresh-screen
-       冗長な画面更新を行います。
-       画面がうまく更新されない時に指定しますが、ちらつくかもしれません
-
--o --out-path
-       プログラムの作業ファイルを出力するディレクトリを指定します
-       無指定の時は、実行時のカレントディレクトリの配下にlogディレクトリを
-       作成して出力します。
-
-キーコマンド
-
-全般
-       j       下移動
-       k       上移動
-       space 項目選択
-       q       終了
-       c       前画面に戻る
-       f       ページダウン
-       b       ページアップ
-       z       画面リフレッシュ
-
-板メニュー
-       h       左カラムへ移動
-       l       右カラムへ移動
-
-スレタイ一覧
-       :[数字] 指定されたスレッド番号にカーソル移動
-       g       最後の行に移動する
-       h       [数字]で指定する前の表示位置に戻るUNDO
-       l       hで戻った移動を元に戻すREDO
-       r       板を更新する
-       /[検索文字列]      指定文字列の後方検索
-       ?[検索文字列]      指定文字列の前方検索
-                                       検索文字列は任意で有り、指定しなかった場合
-                                       以前に指定した文字列で検索します
-                                       デフォルトでregex関数に渡されるので
-                                       標準関数の正規表現が使用できます
-       :s :sort [number|read|unread] スレタイを並べ替えます
-                                       number  スレッド番号順
-                                       read    取得済みスレッド優先
-                                       unread  未読数順
-                                       リソースファイルに初期値を指定出来ます
-                                       実行ユーザーのホームディレクトリに.ntchrcファイルを
-                                       作成して、以下の書式で指定して下さい。
-                                       sort=[number | read | unread]
-       :d :del [スレ番号 | * ] 指定したスレッドの取得済みログを削除します
-                                       *  表示している板の全ての取得済ログを削除
-                                       スレ番号 以下の2ch形式の番号指定が使えます
-                                       10      - 10番のログを削除
-                                       14,17,20,100 - 指定した4つの番号を削除
-                                       25-50 - 25番から50番までを削除
-
-レス一覧
-       :[数字]        指定されたレス番号にカーソル移動
-       g       最後の行に移動する
-       h       [数字]で指定する前の表示位置に戻るUNDO
-       l       hで戻った移動を元に戻すREDO
-       :w :write スレッドに書き込む為にエディターを起動します
-               標準でviエディターが立ち上がるので、本分を編集して
-               保存終了すると書込を行います。無編集、もしくは
-               本文が無い場合、書込を中止します。
-               編集テキストの上部に、mail:[メール], name:[名前]
-               をそれぞれコロン記号の後に指定出来ます。
-               ※)メール、名前は本文に含まれません。
-               書込確認、クッキー確認、エラーなどがサーバーから
-               返された時には、その内容をviエディターで表示します。
-               内容を確認してエディターを終了して下さい。
-               書込確認を中止する方法が(現時点で)ないでの
-               その場合は強制終了して下さい。
-               ●2chビューアーのIDを指定して書込が出来ます。
-                実行ユーザーのホームディレクトリに.ntchrcファイルを
-                作成して、以下の書式でIDとパスワードを指定して下さい。
-               maru-id=[2chビューアーのユーザーID]
-               maru-pw=[2chビューアーのパスワード]
-       r       スレッドを更新する
-       /[検索文字列]      指定文字列の後方検索
-       ?[検索文字列]      指定文字列の前方検索
-                                       検索文字列は任意で有り、指定しなかった場合
-                                       以前に指定した文字列で検索します
-                                       デフォルトでregex関数に渡されるので
-                                       標準関数の正規表現が使用できます
-       :n :new 新規取得スレにジャンプ
+ntch のインストール方法
 
+ダウンロードファイルを使用する場合、適当なディレクトリにntch-1.0.1.5.tgzファイルを解凍します
 
+tar zxvf ntch-1.0.1.6.tgz
+
+作成されたディレクトリに移動します
+
+cd ntch-1.0.1.6
+
+以下のコマンドを実行して、実行ファイルを作成します
+
+./configure
+
+make
+
+sudo make install
+
+実行ファイルはntchです。
+
+管理者権限が無い場合、適当なディレクトリに作業ディレクトリ内のntchをコピーして
+実行できます。
+
+デフォルトで、カレントディレクトリにlogディレクトリを作成して、2chから取得した
+データのログを保存します。
+-oオプションで出力先を指定出来ます。
+例: ntch -o ~/.ntch
+
+プログラムは実行時に、ユーザーのホームディレクトリ以下にディレクトリ .ntch を
+作成してcookieや、読込位置などのユーザー固有情報を保存します。
+
+
+ntchは以下のライブラリィに依存しています。openssl, gdbm, ncurses, sqlite
+これらのライブラリのデベロップ版がビルドには必要です。
+また、Fedora18で動作確認していますので、その他のディストリビューション等では、
+作成されたMakefileやソースファイルを編集する必要があるかもしれません。
index 481bbed..42a742d 100644 (file)
--- a/config.h
+++ b/config.h
@@ -17,7 +17,7 @@
 #define HAVE_LIBCRYPTO 1
 
 /* Define to 1 if you have the `gdbm' library (-lgdbm). */
-#define HAVE_LIBGDBM 1
+/* #undef HAVE_LIBGDBM */
 
 /* Define to 1 if you have the `gdbm_compat' library (-lgdbm_compat). */
 #define HAVE_LIBGDBM_COMPAT 1
 #define PACKAGE_BUGREPORT "akohta001@gmail.com"
 
 /* Define to the full name of this package. */
-#define PACKAGE_NAME "Ntch"
+#define PACKAGE_NAME "ntch"
 
 /* Define to the full name and version of this package. */
-#define PACKAGE_STRING "Ntch 1.0.1.5"
+#define PACKAGE_STRING "ntch 1.0.1.6"
 
 /* Define to the one symbol short name of this package. */
 #define PACKAGE_TARNAME "ntch"
 #define PACKAGE_URL "https://sourceforge.jp/projects/ntch/"
 
 /* Define to the version of this package. */
-#define PACKAGE_VERSION "1.0.1.5"
+#define PACKAGE_VERSION "1.0.1.6"
 
 /* Define to 1 if you have the ANSI C header files. */
 #define STDC_HEADERS 1
index 8dacebb..ba5bc57 100755 (executable)
--- a/configure
+++ b/configure
@@ -1,6 +1,6 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.69 for Ntch 1.0.1.5.
+# Generated by GNU Autoconf 2.69 for ntch 1.0.1.6.
 #
 # Report bugs to <akohta001@gmail.com>.
 #
@@ -578,10 +578,10 @@ MFLAGS=
 MAKEFLAGS=
 
 # Identity of this package.
-PACKAGE_NAME='Ntch'
+PACKAGE_NAME='ntch'
 PACKAGE_TARNAME='ntch'
-PACKAGE_VERSION='1.0.1.5'
-PACKAGE_STRING='Ntch 1.0.1.5'
+PACKAGE_VERSION='1.0.1.6'
+PACKAGE_STRING='ntch 1.0.1.6'
 PACKAGE_BUGREPORT='akohta001@gmail.com'
 PACKAGE_URL='https://sourceforge.jp/projects/ntch/'
 
@@ -622,7 +622,9 @@ ac_includes_default="\
 # include <unistd.h>
 #endif"
 
+ac_default_prefix=/usr/local
 ac_subst_vars='LTLIBOBJS
+ac_prefix_program
 LIBOBJS
 EGREP
 GREP
@@ -1228,7 +1230,7 @@ if test "$ac_init_help" = "long"; then
   # Omit some internal or obsolete options to make the list less imposing.
   # This message is too long to be a string in the A/UX 3.1 sh.
   cat <<_ACEOF
-\`configure' configures Ntch 1.0.1.5 to adapt to many kinds of systems.
+\`configure' configures ntch 1.0.1.6 to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1289,7 +1291,7 @@ fi
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of Ntch 1.0.1.5:";;
+     short | recursive ) echo "Configuration of ntch 1.0.1.6:";;
    esac
   cat <<\_ACEOF
 
@@ -1307,7 +1309,7 @@ Use these variables to override the choices made by `configure' or to help
 it to find libraries and programs with nonstandard names/locations.
 
 Report bugs to <akohta001@gmail.com>.
-Ntch home page: <https://sourceforge.jp/projects/ntch/>.
+ntch home page: <https://sourceforge.jp/projects/ntch/>.
 _ACEOF
 ac_status=$?
 fi
@@ -1370,7 +1372,7 @@ fi
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
-Ntch configure 1.0.1.5
+ntch configure 1.0.1.6
 generated by GNU Autoconf 2.69
 
 Copyright (C) 2012 Free Software Foundation, Inc.
@@ -1793,7 +1795,7 @@ cat >config.log <<_ACEOF
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
-It was created by Ntch $as_me 1.0.1.5, which was
+It was created by ntch $as_me 1.0.1.6, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   $ $0 $@
@@ -3059,11 +3061,10 @@ test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
 
 
 # Checks for libraries.
-# FIXME: Replace `main' with a function in `-lcrypto':
 
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lcrypto" >&5
-$as_echo_n "checking for main in -lcrypto... " >&6; }
-if ${ac_cv_lib_crypto_main+:} false; then :
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for BIO_ctrl in -lcrypto" >&5
+$as_echo_n "checking for BIO_ctrl in -lcrypto... " >&6; }
+if ${ac_cv_lib_crypto_BIO_ctrl+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   ac_check_lib_save_LIBS=$LIBS
@@ -3071,27 +3072,33 @@ LIBS="-lcrypto  $LIBS"
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
-
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char BIO_ctrl ();
 int
 main ()
 {
-return main ();
+return BIO_ctrl ();
   ;
   return 0;
 }
 _ACEOF
 if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_crypto_main=yes
+  ac_cv_lib_crypto_BIO_ctrl=yes
 else
-  ac_cv_lib_crypto_main=no
+  ac_cv_lib_crypto_BIO_ctrl=no
 fi
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_crypto_main" >&5
-$as_echo "$ac_cv_lib_crypto_main" >&6; }
-if test "x$ac_cv_lib_crypto_main" = xyes; then :
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_crypto_BIO_ctrl" >&5
+$as_echo "$ac_cv_lib_crypto_BIO_ctrl" >&6; }
+if test "x$ac_cv_lib_crypto_BIO_ctrl" = xyes; then :
   cat >>confdefs.h <<_ACEOF
 #define HAVE_LIBCRYPTO 1
 _ACEOF
@@ -3100,10 +3107,9 @@ _ACEOF
 
 fi
 
-# FIXME: Replace `main' with a function in `-ldl':
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -ldl" >&5
-$as_echo_n "checking for main in -ldl... " >&6; }
-if ${ac_cv_lib_dl_main+:} false; then :
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5
+$as_echo_n "checking for dlopen in -ldl... " >&6; }
+if ${ac_cv_lib_dl_dlopen+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   ac_check_lib_save_LIBS=$LIBS
@@ -3111,27 +3117,33 @@ LIBS="-ldl  $LIBS"
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
-
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char dlopen ();
 int
 main ()
 {
-return main ();
+return dlopen ();
   ;
   return 0;
 }
 _ACEOF
 if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_dl_main=yes
+  ac_cv_lib_dl_dlopen=yes
 else
-  ac_cv_lib_dl_main=no
+  ac_cv_lib_dl_dlopen=no
 fi
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_main" >&5
-$as_echo "$ac_cv_lib_dl_main" >&6; }
-if test "x$ac_cv_lib_dl_main" = xyes; then :
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5
+$as_echo "$ac_cv_lib_dl_dlopen" >&6; }
+if test "x$ac_cv_lib_dl_dlopen" = xyes; then :
   cat >>confdefs.h <<_ACEOF
 #define HAVE_LIBDL 1
 _ACEOF
@@ -3140,10 +3152,9 @@ _ACEOF
 
 fi
 
-# FIXME: Replace `main' with a function in `-lgdbm':
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lgdbm" >&5
-$as_echo_n "checking for main in -lgdbm... " >&6; }
-if ${ac_cv_lib_gdbm_main+:} false; then :
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for dbm_open in -lgdbm" >&5
+$as_echo_n "checking for dbm_open in -lgdbm... " >&6; }
+if ${ac_cv_lib_gdbm_dbm_open+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   ac_check_lib_save_LIBS=$LIBS
@@ -3151,27 +3162,33 @@ LIBS="-lgdbm  $LIBS"
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
-
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char dbm_open ();
 int
 main ()
 {
-return main ();
+return dbm_open ();
   ;
   return 0;
 }
 _ACEOF
 if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_gdbm_main=yes
+  ac_cv_lib_gdbm_dbm_open=yes
 else
-  ac_cv_lib_gdbm_main=no
+  ac_cv_lib_gdbm_dbm_open=no
 fi
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_gdbm_main" >&5
-$as_echo "$ac_cv_lib_gdbm_main" >&6; }
-if test "x$ac_cv_lib_gdbm_main" = xyes; then :
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_gdbm_dbm_open" >&5
+$as_echo "$ac_cv_lib_gdbm_dbm_open" >&6; }
+if test "x$ac_cv_lib_gdbm_dbm_open" = xyes; then :
   cat >>confdefs.h <<_ACEOF
 #define HAVE_LIBGDBM 1
 _ACEOF
@@ -3180,10 +3197,9 @@ _ACEOF
 
 fi
 
-# FIXME: Replace `main' with a function in `-lgdbm_compat':
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lgdbm_compat" >&5
-$as_echo_n "checking for main in -lgdbm_compat... " >&6; }
-if ${ac_cv_lib_gdbm_compat_main+:} false; then :
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for dbm_open in -lgdbm_compat" >&5
+$as_echo_n "checking for dbm_open in -lgdbm_compat... " >&6; }
+if ${ac_cv_lib_gdbm_compat_dbm_open+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   ac_check_lib_save_LIBS=$LIBS
@@ -3191,27 +3207,33 @@ LIBS="-lgdbm_compat  $LIBS"
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
-
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char dbm_open ();
 int
 main ()
 {
-return main ();
+return dbm_open ();
   ;
   return 0;
 }
 _ACEOF
 if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_gdbm_compat_main=yes
+  ac_cv_lib_gdbm_compat_dbm_open=yes
 else
-  ac_cv_lib_gdbm_compat_main=no
+  ac_cv_lib_gdbm_compat_dbm_open=no
 fi
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_gdbm_compat_main" >&5
-$as_echo "$ac_cv_lib_gdbm_compat_main" >&6; }
-if test "x$ac_cv_lib_gdbm_compat_main" = xyes; then :
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_gdbm_compat_dbm_open" >&5
+$as_echo "$ac_cv_lib_gdbm_compat_dbm_open" >&6; }
+if test "x$ac_cv_lib_gdbm_compat_dbm_open" = xyes; then :
   cat >>confdefs.h <<_ACEOF
 #define HAVE_LIBGDBM_COMPAT 1
 _ACEOF
@@ -3220,10 +3242,9 @@ _ACEOF
 
 fi
 
-# FIXME: Replace `main' with a function in `-lm':
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lm" >&5
-$as_echo_n "checking for main in -lm... " >&6; }
-if ${ac_cv_lib_m_main+:} false; then :
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for sqrt in -lm" >&5
+$as_echo_n "checking for sqrt in -lm... " >&6; }
+if ${ac_cv_lib_m_sqrt+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   ac_check_lib_save_LIBS=$LIBS
@@ -3231,27 +3252,33 @@ LIBS="-lm  $LIBS"
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
-
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char sqrt ();
 int
 main ()
 {
-return main ();
+return sqrt ();
   ;
   return 0;
 }
 _ACEOF
 if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_m_main=yes
+  ac_cv_lib_m_sqrt=yes
 else
-  ac_cv_lib_m_main=no
+  ac_cv_lib_m_sqrt=no
 fi
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_m_main" >&5
-$as_echo "$ac_cv_lib_m_main" >&6; }
-if test "x$ac_cv_lib_m_main" = xyes; then :
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_m_sqrt" >&5
+$as_echo "$ac_cv_lib_m_sqrt" >&6; }
+if test "x$ac_cv_lib_m_sqrt" = xyes; then :
   cat >>confdefs.h <<_ACEOF
 #define HAVE_LIBM 1
 _ACEOF
@@ -3260,10 +3287,9 @@ _ACEOF
 
 fi
 
-# FIXME: Replace `main' with a function in `-lncursesw':
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lncursesw" >&5
-$as_echo_n "checking for main in -lncursesw... " >&6; }
-if ${ac_cv_lib_ncursesw_main+:} false; then :
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for initscr in -lncursesw" >&5
+$as_echo_n "checking for initscr in -lncursesw... " >&6; }
+if ${ac_cv_lib_ncursesw_initscr+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   ac_check_lib_save_LIBS=$LIBS
@@ -3271,27 +3297,33 @@ LIBS="-lncursesw  $LIBS"
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
-
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char initscr ();
 int
 main ()
 {
-return main ();
+return initscr ();
   ;
   return 0;
 }
 _ACEOF
 if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_ncursesw_main=yes
+  ac_cv_lib_ncursesw_initscr=yes
 else
-  ac_cv_lib_ncursesw_main=no
+  ac_cv_lib_ncursesw_initscr=no
 fi
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_ncursesw_main" >&5
-$as_echo "$ac_cv_lib_ncursesw_main" >&6; }
-if test "x$ac_cv_lib_ncursesw_main" = xyes; then :
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_ncursesw_initscr" >&5
+$as_echo "$ac_cv_lib_ncursesw_initscr" >&6; }
+if test "x$ac_cv_lib_ncursesw_initscr" = xyes; then :
   cat >>confdefs.h <<_ACEOF
 #define HAVE_LIBNCURSESW 1
 _ACEOF
@@ -3300,10 +3332,9 @@ _ACEOF
 
 fi
 
-# FIXME: Replace `main' with a function in `-lpthread':
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lpthread" >&5
-$as_echo_n "checking for main in -lpthread... " >&6; }
-if ${ac_cv_lib_pthread_main+:} false; then :
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread_create in -lpthread" >&5
+$as_echo_n "checking for pthread_create in -lpthread... " >&6; }
+if ${ac_cv_lib_pthread_pthread_create+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   ac_check_lib_save_LIBS=$LIBS
@@ -3311,27 +3342,33 @@ LIBS="-lpthread  $LIBS"
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
-
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char pthread_create ();
 int
 main ()
 {
-return main ();
+return pthread_create ();
   ;
   return 0;
 }
 _ACEOF
 if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_pthread_main=yes
+  ac_cv_lib_pthread_pthread_create=yes
 else
-  ac_cv_lib_pthread_main=no
+  ac_cv_lib_pthread_pthread_create=no
 fi
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pthread_main" >&5
-$as_echo "$ac_cv_lib_pthread_main" >&6; }
-if test "x$ac_cv_lib_pthread_main" = xyes; then :
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pthread_pthread_create" >&5
+$as_echo "$ac_cv_lib_pthread_pthread_create" >&6; }
+if test "x$ac_cv_lib_pthread_pthread_create" = xyes; then :
   cat >>confdefs.h <<_ACEOF
 #define HAVE_LIBPTHREAD 1
 _ACEOF
@@ -3340,10 +3377,9 @@ _ACEOF
 
 fi
 
-# FIXME: Replace `main' with a function in `-lsqlite3':
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lsqlite3" >&5
-$as_echo_n "checking for main in -lsqlite3... " >&6; }
-if ${ac_cv_lib_sqlite3_main+:} false; then :
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for sqlite3_initialize in -lsqlite3" >&5
+$as_echo_n "checking for sqlite3_initialize in -lsqlite3... " >&6; }
+if ${ac_cv_lib_sqlite3_sqlite3_initialize+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   ac_check_lib_save_LIBS=$LIBS
@@ -3351,27 +3387,33 @@ LIBS="-lsqlite3  $LIBS"
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
-
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char sqlite3_initialize ();
 int
 main ()
 {
-return main ();
+return sqlite3_initialize ();
   ;
   return 0;
 }
 _ACEOF
 if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_sqlite3_main=yes
+  ac_cv_lib_sqlite3_sqlite3_initialize=yes
 else
-  ac_cv_lib_sqlite3_main=no
+  ac_cv_lib_sqlite3_sqlite3_initialize=no
 fi
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_sqlite3_main" >&5
-$as_echo "$ac_cv_lib_sqlite3_main" >&6; }
-if test "x$ac_cv_lib_sqlite3_main" = xyes; then :
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_sqlite3_sqlite3_initialize" >&5
+$as_echo "$ac_cv_lib_sqlite3_sqlite3_initialize" >&6; }
+if test "x$ac_cv_lib_sqlite3_sqlite3_initialize" = xyes; then :
   cat >>confdefs.h <<_ACEOF
 #define HAVE_LIBSQLITE3 1
 _ACEOF
@@ -3380,10 +3422,9 @@ _ACEOF
 
 fi
 
-# FIXME: Replace `main' with a function in `-lssl':
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lssl" >&5
-$as_echo_n "checking for main in -lssl... " >&6; }
-if ${ac_cv_lib_ssl_main+:} false; then :
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for SSL_library_init in -lssl" >&5
+$as_echo_n "checking for SSL_library_init in -lssl... " >&6; }
+if ${ac_cv_lib_ssl_SSL_library_init+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   ac_check_lib_save_LIBS=$LIBS
@@ -3391,27 +3432,33 @@ LIBS="-lssl  $LIBS"
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
-
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char SSL_library_init ();
 int
 main ()
 {
-return main ();
+return SSL_library_init ();
   ;
   return 0;
 }
 _ACEOF
 if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_ssl_main=yes
+  ac_cv_lib_ssl_SSL_library_init=yes
 else
-  ac_cv_lib_ssl_main=no
+  ac_cv_lib_ssl_SSL_library_init=no
 fi
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_ssl_main" >&5
-$as_echo "$ac_cv_lib_ssl_main" >&6; }
-if test "x$ac_cv_lib_ssl_main" = xyes; then :
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_ssl_SSL_library_init" >&5
+$as_echo "$ac_cv_lib_ssl_SSL_library_init" >&6; }
+if test "x$ac_cv_lib_ssl_SSL_library_init" = xyes; then :
   cat >>confdefs.h <<_ACEOF
 #define HAVE_LIBSSL 1
 _ACEOF
@@ -3420,10 +3467,9 @@ _ACEOF
 
 fi
 
-# FIXME: Replace `main' with a function in `-lz':
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lz" >&5
-$as_echo_n "checking for main in -lz... " >&6; }
-if ${ac_cv_lib_z_main+:} false; then :
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for inflate in -lz" >&5
+$as_echo_n "checking for inflate in -lz... " >&6; }
+if ${ac_cv_lib_z_inflate+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   ac_check_lib_save_LIBS=$LIBS
@@ -3431,27 +3477,33 @@ LIBS="-lz  $LIBS"
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
-
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char inflate ();
 int
 main ()
 {
-return main ();
+return inflate ();
   ;
   return 0;
 }
 _ACEOF
 if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_z_main=yes
+  ac_cv_lib_z_inflate=yes
 else
-  ac_cv_lib_z_main=no
+  ac_cv_lib_z_inflate=no
 fi
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_z_main" >&5
-$as_echo "$ac_cv_lib_z_main" >&6; }
-if test "x$ac_cv_lib_z_main" = xyes; then :
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_z_inflate" >&5
+$as_echo "$ac_cv_lib_z_inflate" >&6; }
+if test "x$ac_cv_lib_z_inflate" = xyes; then :
   cat >>confdefs.h <<_ACEOF
 #define HAVE_LIBZ 1
 _ACEOF
@@ -4098,6 +4150,102 @@ done
 ac_config_files="$ac_config_files Makefile"
 
 
+ac_config_commands="$ac_config_commands make-gen-dir"
+
+
+if test "x$prefix" = xNONE; then
+  $as_echo_n "checking for prefix by " >&6
+  # Extract the first word of "ntch", so it can be a program name with args.
+set dummy ntch; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_path_ac_prefix_program+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $ac_prefix_program in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_ac_prefix_program="$ac_prefix_program" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_path_ac_prefix_program="$as_dir/$ac_word$ac_exec_ext"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+ac_prefix_program=$ac_cv_path_ac_prefix_program
+if test -n "$ac_prefix_program"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_prefix_program" >&5
+$as_echo "$ac_prefix_program" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  if test -n "$ac_prefix_program"; then
+    prefix=`$as_dirname -- "$ac_prefix_program" ||
+$as_expr X"$ac_prefix_program" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+        X"$ac_prefix_program" : 'X\(//\)[^/]' \| \
+        X"$ac_prefix_program" : 'X\(//\)$' \| \
+        X"$ac_prefix_program" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X"$ac_prefix_program" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+           s//\1/
+           q
+         }
+         /^X\(\/\/\)[^/].*/{
+           s//\1/
+           q
+         }
+         /^X\(\/\/\)$/{
+           s//\1/
+           q
+         }
+         /^X\(\/\).*/{
+           s//\1/
+           q
+         }
+         s/.*/./; q'`
+    prefix=`$as_dirname -- "$prefix" ||
+$as_expr X"$prefix" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+        X"$prefix" : 'X\(//\)[^/]' \| \
+        X"$prefix" : 'X\(//\)$' \| \
+        X"$prefix" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X"$prefix" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+           s//\1/
+           q
+         }
+         /^X\(\/\/\)[^/].*/{
+           s//\1/
+           q
+         }
+         /^X\(\/\/\)$/{
+           s//\1/
+           q
+         }
+         /^X\(\/\).*/{
+           s//\1/
+           q
+         }
+         s/.*/./; q'`
+  fi
+fi
+
+
 cat >confcache <<\_ACEOF
 # This file is a shell script that caches the results of configure
 # tests run on this system so they can be shared between configure
@@ -4604,7 +4752,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
 # report actual input values of CONFIG_FILES etc. instead of their
 # values after options handling.
 ac_log="
-This file was extended by Ntch $as_me 1.0.1.5, which was
+This file was extended by ntch $as_me 1.0.1.6, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -4631,6 +4779,7 @@ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 # Files that config.status was made for.
 config_files="$ac_config_files"
 config_headers="$ac_config_headers"
+config_commands="$ac_config_commands"
 
 _ACEOF
 
@@ -4660,14 +4809,17 @@ $config_files
 Configuration headers:
 $config_headers
 
+Configuration commands:
+$config_commands
+
 Report bugs to <akohta001@gmail.com>.
-Ntch home page: <https://sourceforge.jp/projects/ntch/>."
+ntch home page: <https://sourceforge.jp/projects/ntch/>."
 
 _ACEOF
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
 ac_cs_version="\\
-Ntch config.status 1.0.1.5
+ntch config.status 1.0.1.6
 configured by $0, generated by GNU Autoconf 2.69,
   with options \\"\$ac_cs_config\\"
 
@@ -4791,6 +4943,7 @@ do
   case $ac_config_target in
     "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;;
     "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
+    "make-gen-dir") CONFIG_COMMANDS="$CONFIG_COMMANDS make-gen-dir" ;;
 
   *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
   esac
@@ -4804,6 +4957,7 @@ done
 if $ac_need_defaults; then
   test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files
   test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers
+  test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands
 fi
 
 # Have a temporary directory for convenience.  Make it in the build tree
@@ -5100,7 +5254,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
 fi # test -n "$CONFIG_HEADERS"
 
 
-eval set X "  :F $CONFIG_FILES  :H $CONFIG_HEADERS    "
+eval set X "  :F $CONFIG_FILES  :H $CONFIG_HEADERS    :C $CONFIG_COMMANDS"
 shift
 for ac_tag
 do
@@ -5338,9 +5492,16 @@ $as_echo "$as_me: $ac_file is unchanged" >&6;}
   fi
  ;;
 
-
+  :C)  { $as_echo "$as_me:${as_lineno-$LINENO}: executing $ac_file commands" >&5
+$as_echo "$as_me: executing $ac_file commands" >&6;}
+ ;;
   esac
 
+
+  case $ac_file$ac_mode in
+    "make-gen-dir":C) mkdir -p gen ;;
+
+  esac
 done # for ac_tag
 
 
index 1da2fc6..9269635 100644 (file)
@@ -2,7 +2,7 @@
 # Process this file with autoconf to produce a configure script.
 
 AC_PREREQ([2.69])
-AC_INIT([Ntch], [1.0.1.5], [akohta001@gmail.com],[ntch],[https://sourceforge.jp/projects/ntch/])
+AC_INIT([ntch], [1.0.1.6], [akohta001@gmail.com],[ntch],[https://sourceforge.jp/projects/ntch/])
 AC_CONFIG_SRCDIR([src/main.c])
 AC_CONFIG_HEADERS([config.h])
 
@@ -11,26 +11,16 @@ AC_PROG_CC
 AC_PROG_INSTALL
 
 # Checks for libraries.
-# FIXME: Replace `main' with a function in `-lcrypto':
-AC_CHECK_LIB([crypto], [main])
-# FIXME: Replace `main' with a function in `-ldl':
-AC_CHECK_LIB([dl], [main])
-# FIXME: Replace `main' with a function in `-lgdbm':
-AC_CHECK_LIB([gdbm], [main])
-# FIXME: Replace `main' with a function in `-lgdbm_compat':
-AC_CHECK_LIB([gdbm_compat], [main])
-# FIXME: Replace `main' with a function in `-lm':
-AC_CHECK_LIB([m], [main])
-# FIXME: Replace `main' with a function in `-lncursesw':
-AC_CHECK_LIB([ncursesw], [main])
-# FIXME: Replace `main' with a function in `-lpthread':
-AC_CHECK_LIB([pthread], [main])
-# FIXME: Replace `main' with a function in `-lsqlite3':
-AC_CHECK_LIB([sqlite3], [main])
-# FIXME: Replace `main' with a function in `-lssl':
-AC_CHECK_LIB([ssl], [main])
-# FIXME: Replace `main' with a function in `-lz':
-AC_CHECK_LIB([z], [main])
+AC_CHECK_LIB([crypto], [BIO_ctrl])
+AC_CHECK_LIB([dl], [dlopen])
+AC_CHECK_LIB([gdbm], [dbm_open])
+AC_CHECK_LIB([gdbm_compat], [dbm_open])
+AC_CHECK_LIB([m], [sqrt])
+AC_CHECK_LIB([ncursesw], [initscr])
+AC_CHECK_LIB([pthread], [pthread_create])
+AC_CHECK_LIB([sqlite3], [sqlite3_initialize])
+AC_CHECK_LIB([ssl], [SSL_library_init])
+AC_CHECK_LIB([z], [inflate])
 
 # Checks for header files.
 AC_CHECK_HEADERS([arpa/inet.h fcntl.h limits.h locale.h memory.h netdb.h netinet/in.h stdlib.h string.h sys/socket.h unistd.h wchar.h])
@@ -47,4 +37,8 @@ AC_CHECK_FUNCS([gethostbyname memset mkdir regcomp setlocale socket strchr strrc
 
 AC_CONFIG_FILES([Makefile])
 
+AC_CONFIG_COMMANDS([make-gen-dir], [mkdir -p gen])
+AC_PREFIX_DEFAULT([/usr/local])
+AC_PREFIX_PROGRAM([ntch])
+
 AC_OUTPUT
diff --git a/gen/Readme b/gen/Readme
deleted file mode 100644 (file)
index f6d161b..0000000
+++ /dev/null
@@ -1 +0,0 @@
-This directory will contain files generated by the project.
index b7b449e..653cfec 100644 (file)
--- a/help.txt
+++ b/help.txt
@@ -1,5 +1,5 @@
 
-    ntch  version 1.0.1.5
+    ntch  version 1.0.1.6
 
     This file is part of ntch.
 
 Linux用 2ch専用ブラウザー
 
 -v --version
-       バージョンを表示します
+    バージョンを表示します
 
 -h --help
-       このヘルプを表示します
+    このヘルプを表示します
 
 -r -refresh-screen
-       冗長な画面更新を行います。
-       画面がうまく更新されない時に指定しますが、ちらつくかもしれません
+    冗長な画面更新を行います。
+    画面がうまく更新されない時に指定しますが、ちらつくかもしれません
 
 -o --out-path
-       プログラムの作業ファイルを出力するディレクトリを指定します
-       無指定の時は、実行時のカレントディレクトリの配下にlogディレクトリを
-       作成して出力します。
+    プログラムの作業ファイルを出力するディレクトリを指定します
+    無指定の時は、実行時のカレントディレクトリの配下にlogディレクトリを
+    作成して出力します。
 
 キーコマンド
 
 全般
-       j       下移動
-       k       上移動
-       space 項目選択
-       q       終了
-       c       前画面に戻る
-       f       ページダウン
-       b       ページアップ
-       z       画面リフレッシュ
+    j   下移動
+    k   上移動
+    space 項目選択
+    q   終了
+    c   前画面に戻る
+    f   ページダウン
+    b   ページアップ
+    z   画面リフレッシュ
 
 板メニュー
-       h       左カラムへ移動
-       l       右カラムへ移動
+    h   左カラムへ移動
+    l   右カラムへ移動
 
 スレタイ一覧
-       :[数字] 指定されたスレッド番号にカーソル移動
-       g       最後の行に移動する
-       h       [数字]で指定する前の表示位置に戻るUNDO
-       l       hで戻った移動を元に戻すREDO
-       r       板を更新する
-       /[検索文字列]      指定文字列の後方検索
-       ?[検索文字列]      指定文字列の前方検索
-                                       検索文字列は任意で有り、指定しなかった場合
-                                       以前に指定した文字列で検索します
-                                       デフォルトでregex関数に渡されるので
-                                       標準関数の正規表現が使用できます
-       :s :sort [number|read|unread] スレタイを並べ替えます
-                                       number  スレッド番号順
-                                       read    取得済みスレッド優先
-                                       unread  未読数順
-                                       リソースファイルに初期値を指定出来ます
-                                       実行ユーザーのホームディレクトリに.ntchrcファイルを
-                                       作成して、以下の書式で指定して下さい。
-                                       sort=[number | read | unread]
-       :d :del [スレ番号 | * ] 指定したスレッドの取得済みログを削除します
-                                       *  表示している板の全ての取得済ログを削除
-                                       スレ番号 以下の2ch形式の番号指定が使えます
-                                       10      - 10番のログを削除
-                                       14,17,20,100 - 指定した4つの番号を削除
-                                       25-50 - 25番から50番までを削除
+    :[数字] 指定されたスレッド番号にカーソル移動
+    g   最後の行に移動する
+    h   [数字]で指定する前の表示位置に戻るUNDO
+    l   hで戻った移動を元に戻すREDO
+    r   板を更新する
+    /[検索文字列]   指定文字列の後方検索
+    ?[検索文字列]   指定文字列の前方検索
+                    検索文字列は任意で有り、指定しなかった場合
+                    以前に指定した文字列で検索します
+                    デフォルトでregex関数に渡されるので
+                    標準関数の正規表現が使用できます
+    :s :sort [number|read|unread] スレタイを並べ替えます
+                    number  スレッド番号順
+                    read    取得済みスレッド優先
+                    unread  未読数順
+                    リソースファイルに初期値を指定出来ます
+                    実行ユーザーのホームディレクトリに.ntchrcファイルを
+                    作成して、以下の書式で指定して下さい。
+                    sort=[number | read | unread]
+    :d :del [スレ番号 | * ] 指定したスレッドの取得済みログを削除します
+                    *  表示している板の全ての取得済ログを削除
+                    スレ番号 以下の2ch形式の番号指定が使えます
+                    10  - 10番のログを削除
+                    14,17,20,100 - 指定した4つの番号を削除
+                    25-50 - 25番から50番までを削除
 
 レス一覧
-       :[数字]        指定されたレス番号にカーソル移動
-       g       最後の行に移動する
-       h       [数字]で指定する前の表示位置に戻るUNDO
-       l       hで戻った移動を元に戻すREDO
-       :w :write スレッドに書き込む為にエディターを起動します
-               標準でviエディターが立ち上がるので、本分を編集して
-               保存終了すると書込を行います。無編集、もしくは
-               本文が無い場合、書込を中止します。
-               編集テキストの上部に、mail:[メール], name:[名前]
-               をそれぞれコロン記号の後に指定出来ます。
-               ※)メール、名前は本文に含まれません。
-               書込確認、クッキー確認、エラーなどがサーバーから
-               返された時には、その内容をviエディターで表示します。
-               内容を確認してエディターを終了して下さい。
-               書込確認を中止する方法が(現時点で)ないでの
-               その場合は強制終了して下さい。
-               ●2chビューアーのIDを指定して書込が出来ます。
-                実行ユーザーのホームディレクトリに.ntchrcファイルを
-                作成して、以下の書式でIDとパスワードを指定して下さい。
-               maru-id=[2chビューアーのユーザーID]
-               maru-pw=[2chビューアーのパスワード]
-       r       スレッドを更新する
-       /[検索文字列]      指定文字列の後方検索
-       ?[検索文字列]      指定文字列の前方検索
-                                       検索文字列は任意で有り、指定しなかった場合
-                                       以前に指定した文字列で検索します
-                                       デフォルトでregex関数に渡されるので
-                                       標準関数の正規表現が使用できます
-       :n :new 新規取得スレにジャンプ
+    :[数字]         指定されたレス番号にカーソル移動
+    :[2ch形式の番号 | tree  | t | id | i ]
+                  [2ch形式の番号] 表示するレス番号を以下の2ch形式で指定できます
+                        14,17,20,100 - 指定した4つの番号を表示
+                        25-50 - 25番から50番までを表示
+                  tree [数字] or t [数字] 指定レス番号が参照しているorされている
+                        レスのみを表示します。
+                        数字とtree(もしくはt)の間には空白が必要です
+                    id [ID] or i [ID] 指定IDを持つレスのみを表示します
+                        数字とid(もしくはi)の間には空白が必要です
+    g   最後の行に移動する
+    h   [数字]で指定する前の表示位置に戻るUNDO
+            ※ :treeコマンドなどでレス表示をフィルターしている時は、
+        フィルターする前の画面に戻ります。
+    l   hで戻った移動を元に戻すREDO
+    :w :write スレッドに書き込む為にエディターを起動します
+        標準でviエディターが立ち上がるので、本分を編集して
+        保存終了すると書込を行います。無編集、もしくは
+        本文が無い場合、書込を中止します。
+        編集テキストの上部に、mail:[メール], name:[名前]
+        をそれぞれコロン記号の後に指定出来ます。
+        ※)メール、名前は本文に含まれません。
+        書込確認、クッキー確認、エラーなどがサーバーから
+        返された時には、その内容をviエディターで表示します。
+        内容を確認してエディターを終了して下さい。
+        書込確認を中止する方法が(現時点で)ないでの
+        その場合は強制終了して下さい。
+        ●2chビューアーのIDを指定して書込が出来ます。
+         実行ユーザーのホームディレクトリに.ntchrcファイルを
+         作成して、以下の書式でIDとパスワードを指定して下さい。
+        maru-id=[2chビューアーのユーザーID]
+        maru-pw=[2chビューアーのパスワード]
+    r   スレッドを更新する
+    /[検索文字列]   指定文字列の後方検索
+    ?[検索文字列]   指定文字列の前方検索
+                    検索文字列は任意で有り、指定しなかった場合
+                    以前に指定した文字列で検索します
+                    デフォルトでregex関数に渡されるので
+                    標準関数の正規表現が使用できます
+    :n :new 新規取得スレにジャンプ
 
 
index 18e4fb6..09427f2 100644 (file)
@@ -182,9 +182,6 @@ nt_res_tp nt_res_alloc(nt_thread_tp threadp,
                free(resp);
                return NULL;
        }
-       resp->msg_header_line_num = 0;
-       resp->msg_line_num = 0;
-       resp->msg_line_linkp = NULL;
 
        linkp = threadp->reslistp;
        ptr = nt_link_add_data(linkp, resp);
@@ -368,7 +365,7 @@ void nt_thread_children_free(nt_thread_tp ptr)
 void nt_res_free(nt_res_tp ptr)
 {
        assert(ptr);
-       nt_res_msg_free(ptr);
+       //nt_res_msg_free(ptr);
        free(ptr->name);
        free(ptr->mail);
        free(ptr->misc);
@@ -376,29 +373,6 @@ void nt_res_free(nt_res_tp ptr)
        free(ptr);
 }
 
-void nt_res_msg_free(nt_res_tp ptr)
-{
-       nt_link_tp curp, nextp;
-       assert(ptr);
-       if(ptr->msg_line_linkp){
-               curp = ptr->msg_line_linkp->next;
-               while(curp != ptr->msg_line_linkp){
-                       nextp = curp->next;
-                       /* We must not free the data pointer
-                        * except the first one
-                        * because they're alocated as a same block.
-                        * This is wrong --> free(curp->data);
-                        */
-                       free(curp);
-                       curp = nextp;
-               }
-               free(curp->data);
-               free(curp);
-               ptr->msg_line_linkp = NULL;
-       }
-}
-
-
 nt_write_data_tp nt_write_data_alloc()
 {
        nt_write_data_tp writep
index 5fdf40f..faf6758 100644 (file)
@@ -1,3 +1,20 @@
+/* Copyright 2013 Akira Ohta (akohta001@gmail.com)
+    This file is part of ntch.
+
+    The ntch is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    The ntch is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with ntch.  If not, see <http://www.gnu.org/licenses/>.
+    
+*/
 #include <wchar.h>
 #include <assert.h>
 
index 4782436..527a061 100644 (file)
 
 static nt_category_tp get_last_category(nt_2ch_model_tp modelp);
 
-int parse_res_msg(nt_res_tp resp, size_t colmns)
-{
-       int i, len, start, lines;
-       wchar_t ch;
-       wchar_t *buf, *cptr, *srcp;
-       int offset;
-       nt_link_tp linkp;
-       int consume_colmns;
-       int buf_idx;
-
-       assert(resp->msg);
-
-       nt_res_msg_free(resp);
-       resp->msg_line_num = 0;
-
-       len = wcslen(resp->msg);
-
-       if(len == 0)
-               return 0;
-       buf = malloc(sizeof(wchar_t) * (len + 11));
-       if(!buf)
-               return 0;
-       buf_idx = 0;
-
-       srcp = resp->msg;
-
-       lines = 0;
-       start = 0;
-       consume_colmns = 0;
-       for(i = 0; i < len; i++){
-               ch = srcp[i];
-               switch(ch){
-               case L'&':
-                       if(len > (i+5)){
-                               if(srcp[i+1] == L'q' &&
-                                       srcp[i+2] == L'u' &&
-                                       srcp[i+3] == L'o' &&
-                                       srcp[i+4] == L't' &&
-                                       srcp[i+5] == L';'){
-                                       ch = L'\"';
-                                       buf[buf_idx] = ch;
-                                       buf_idx++;
-                                       i += 5;
-                                       break;
-                               }
-                       }
-                       if(len > (i+4)){
-                               if(srcp[i+1] == L'a' &&
-                                       srcp[i+2] == L'm' &&
-                                       srcp[i+3] == L'p' &&
-                                       srcp[i+4] == L';'){
-                                       ch = L'&';
-                                       buf[buf_idx] = ch;
-                                       buf_idx++;
-                                       i += 4;
-                                       break;
-                               }
-                       }
-                       if(len > (i+3)){
-                               if(srcp[i+1] == L'g' &&
-                                       srcp[i+2] == L't' &&
-                                       srcp[i+3] == L';'){
-                                       ch = L'>';
-                                       buf[buf_idx] = ch;
-                                       buf_idx++;
-                                       i += 3;
-                                       break;
-                               }else if(srcp[i+1] == L'l' &&
-                                       srcp[i+2] == L't' &&
-                                       srcp[i+3] == L';'){
-                                       ch = L'<';
-                                       buf[buf_idx] = ch;
-                                       buf_idx++;
-                                       i += 3;
-                                       break;
-                               }
-                       }
-                       
-                       goto DEF_LABEL; 
-               case L'<': 
-                       if(len > (i+3) && srcp[i+1] == L'b' &&
-                                       srcp[i+2] == L'r' &&
-                                       srcp[i+3] == L'>'){
-                               cptr = buf + start;
-                               buf[buf_idx] = L'\0';
-                               buf_idx++;
-                               linkp = nt_link_add_data(
-                                               resp->msg_line_linkp, cptr);
-                               if(!linkp)
-                                       goto END_FOR;
-                               if(resp->msg_line_linkp == NULL)
-                                       resp->msg_line_linkp = linkp;
-
-                               consume_colmns = 0;
-                               lines++;
-                               start = buf_idx;
-                               i += 3;
-                               break;
-                       }else if(len > (i+7) && srcp[i+1] == L'a' &&
-                                       srcp[i+2] == L' ' &&
-                                       srcp[i+3] == L'h' &&
-                                       srcp[i+4] == L'r' &&
-                                       srcp[i+5] == L'e' &&
-                                       srcp[i+6] == L'f' &&
-                                       srcp[i+7] == L'='){
-                               cptr = wcschr(srcp+i+8, L'>');
-                               if(cptr){
-                                       offset = cptr - &(srcp[i]);
-                                       i += offset;
-                                       break;
-                               }
-                       }else if(len > (i+3) && srcp[i+1] == L'/' &&
-                                       srcp[i+2] == L'a' &&
-                                       srcp[i+3] == L'>'){
-                               i += 3;
-                               break;
-                       }
-               /* fall through */
-               default:
-DEF_LABEL:
-                       if(ch <= 128 || (ch >= 0xff66 && ch <= 0xff9d))
-                               offset = 1;
-                       else
-                               offset = 2;
-
-                       if(consume_colmns + offset > colmns){
-                               cptr = buf + start;
-                               buf[buf_idx] = L'\0';
-                               linkp = nt_link_add_data(
-                                               resp->msg_line_linkp, cptr);
-                               if(!linkp)
-                                       goto END_FOR;
-                               if(resp->msg_line_linkp == NULL)
-                                       resp->msg_line_linkp = linkp;
-                                       
-                               consume_colmns = 0;
-                               lines++;
-                               buf_idx++;
-                               start = buf_idx;
-                               i--;
-                       }else{
-                               consume_colmns += offset;
-                               buf[buf_idx] = ch;
-                               buf_idx++;
-                       }
-                       break;
-               }/* end switch */
-       } /* end for */
-END_FOR:
-       if(consume_colmns > 0){
-               cptr = buf + start;
-               buf[buf_idx] = L'\0';
-               linkp = nt_link_add_data(
-                               resp->msg_line_linkp, cptr);
-               if(linkp){
-                       if(resp->msg_line_linkp == NULL)
-                               resp->msg_line_linkp = linkp;
-                       lines++;
-               }
-       }
-       resp->msg_line_num = lines;
-       return lines;
-}
 
 BOOL parse_thread(nt_thread_tp threadp, const wchar_t *linep)
 {
index 10d0475..2add940 100644 (file)
 
 static nt_link_tp parse_number_list_local (const char *source, 
                                const char **endpp);
+static nt_link_tp w_parse_number_list_local (const wchar_t *source, 
+                               const wchar_t **endpp);
 
-static int comp_int(int a, int b)
+int nt_comp_int(int a, int b)
 {
        if(a == b) return 0;
        else if(a < b) return 1;
        else return -1;
 }
 
-nt_link_tp parse_number_list (const char *source, const char **endpp)
+nt_link_tp nt_parse_number_list (const char *source, const char **endpp)
 {
        nt_link_tp linkp =
                parse_number_list_local(source, endpp);
        if(!linkp)
                return NULL;
-       nt_link_n_sort(&linkp, comp_int);
+       nt_link_n_sort(&linkp, nt_comp_int);
        return linkp;
 }
 
+nt_link_tp nt_w_parse_number_list (const wchar_t *source, const wchar_t **endpp)
+{
+       nt_link_tp linkp =
+               w_parse_number_list_local(source, endpp);
+       if(!linkp)
+               return NULL;
+       nt_link_n_sort(&linkp, nt_comp_int);
+       return linkp;
+}
+
+wchar_t* nt_w_format_number_list (nt_link_tp num_listp)
+{
+       const int delta = 32;
+       wchar_t *buf;
+       int buf_size, len;
+       nt_link_tp linkp;
+       int prev_num, s_num, num, ret;
+       
+       assert(num_listp);
+       
+       buf = nt_w_str_resize(NULL, 0, delta);
+       if(!buf)
+               return NULL;
+       buf_size = delta;
+       len = 0;
+       s_num = -1;
+       prev_num = -1;
+       linkp = num_listp;
+       do{
+               num = linkp->n_data;
+               if(num <= 0){
+                       break;
+               }else if(num == prev_num){
+                       ;
+               }else if(num == prev_num+1){
+                       if(s_num < 0)
+                               s_num = prev_num;
+               }else{
+                       if(s_num < 0){
+                               if(len == 0)
+                                       ret = swprintf(buf, buf_size, L"%d", num);
+                               else
+                                       ret = swprintf(buf+len, buf_size-len, L",%d", num);
+                       }else{
+                               if(len == 0)
+                                       ret = swprintf(buf, buf_size, L"%d-%d", num);
+                               else
+                                       ret = swprintf(buf+len, buf_size-len, L",%d-%d", num);
+                       }
+                       if(ret < 0){
+                               free(buf);
+                               return NULL;
+                       }
+                       len += ret;
+                       if(len+1 >= buf_size-12){
+                               buf = nt_w_str_resize(buf, buf_size, buf_size + delta);
+                               if(!buf)
+                                       return NULL;
+                               buf_size += delta;
+                       }
+               }
+               linkp = linkp->next;
+       }while(linkp != num_listp);
+       
+       return buf;
+}
+
+
 static nt_link_tp parse_number_list_local (const char *source, 
                                const char **endpp)
 {
@@ -159,4 +229,246 @@ END_FOR:
        return top_linkp;
 }
 
+static nt_link_tp w_parse_number_list_local (const wchar_t *source, 
+                               const wchar_t **endpp)
+{
+       nt_link_tp linkp, top_linkp;
+       int i , len, state;
+       const wchar_t *start;
+       int n, prev;
+
+       assert(source);
 
+       if(endpp)
+               *endpp = source;
+       
+       top_linkp = NULL;
+       linkp = NULL;
+       len = wcslen(source);
+       state = 0;
+
+       for(i = 0; i < len; i++){
+               switch(source[i]){
+               case L'0':
+               case L'1':
+               case L'2':
+               case L'3':
+               case L'4':
+               case L'5':
+               case L'6':
+               case L'7':
+               case L'8':
+               case L'9':
+                       if(state == 0){
+                               state = 1;
+                               start = source + i;
+                       }else if(state == 2){
+                               state = 3;
+                               start = source + i;
+                       }else if(state != 1 && state != 3){
+                               assert(0);
+                       }
+                       break;
+               case L' ':
+               case L',':
+                       if(state == 1){
+                               n = (int)wcstol(start, NULL, 10);
+                               linkp = nt_link_add_n_data(top_linkp, n);
+                               if(!top_linkp)
+                                       top_linkp= linkp;
+                               if(endpp)
+                                       *endpp = source + i;
+                       }else if(state == 3){
+                               n = (int)wcstol(start, NULL, 10);
+                               if(prev > n){
+                                       linkp = nt_link_add_n_data(top_linkp, prev);
+                                       if(!top_linkp)
+                                               top_linkp= linkp;
+                                       return top_linkp;
+                               }
+                               while(prev <= n){
+                                       linkp = nt_link_add_n_data(top_linkp, prev);
+                                       if(!top_linkp)
+                                               top_linkp = linkp;
+                                       prev++;
+                               }
+                               if(endpp)
+                                       *endpp = source + i;
+                       }else if(state == 2){
+                               linkp = nt_link_add_n_data(top_linkp, prev);
+                               if(!top_linkp)
+                                       top_linkp = linkp;
+                               return top_linkp;
+                       }else{
+                               return top_linkp;
+                       }
+                       state = 0;
+                       break;
+               case L'-':
+                       if(state == 1){
+                               prev = (int)wcstol(start, NULL, 10);
+                               if(endpp)
+                                       *endpp = source + i;
+                               state = 2;
+                               break;
+                       }
+                       /* fall through */
+               default:
+                       goto END_FOR;
+               }/* end switch */
+       }/* end for */
+END_FOR:
+       if(state == 1){
+               n = (int)wcstol(start, NULL, 10);
+               linkp = nt_link_add_n_data(top_linkp, n);
+               if(!top_linkp)
+                       top_linkp = linkp;
+               if(endpp)
+                       *endpp = source + i;
+       }else if(state == 3){
+               n = (int)wcstol(start, NULL, 10);
+               if(prev > n){
+                       linkp = nt_link_add_n_data(top_linkp, prev);
+                       if(!top_linkp)
+                               top_linkp = linkp;
+                       return top_linkp;
+               }
+               while(prev <= n){
+                       linkp = nt_link_add_n_data(top_linkp, prev);
+                       if(!top_linkp)
+                               top_linkp = linkp;
+                       prev++;
+               }
+       }
+       return top_linkp;
+}
+
+wchar_t*  nt_parse_res_msg(const wchar_t *srcp, nt_link_tp *num_linkpp)
+{
+       int i, len;
+       wchar_t ch;
+       wchar_t *buf, *cptr, *wrk_buf;
+       int offset;
+       int buf_idx, buf_size;
+       nt_link_tp wrk_linkp;
+       
+       assert(num_linkpp);
+       
+       len = wcslen(srcp);
+       const int delta = 20;
+
+       if(len == 0)
+               return NULL;
+       buf_size = len + delta;
+       buf = malloc(sizeof(wchar_t) * (buf_size));
+       if(!buf)
+               return NULL;
+       buf_idx = 0;
+
+       for(i = 0; i < len; i++){
+               ch = srcp[i];
+               switch(ch){
+               case L'&':
+                       if(len > (i+5)){
+                               if(srcp[i+1] == L'q' &&
+                                               srcp[i+2] == L'u' &&
+                                               srcp[i+3] == L'o' &&
+                                               srcp[i+4] == L't' &&
+                                               srcp[i+5] == L';'){
+                                       buf[buf_idx] =L'\"' ;
+                                       buf_idx++;
+                                       i += 5;
+                               }
+                       }
+                       if(len > (i+4)){
+                               if(srcp[i+1] == L'a' &&
+                                               srcp[i+2] == L'm' &&
+                                               srcp[i+3] == L'p' &&
+                                               srcp[i+4] == L';'){
+                                       buf[buf_idx] = L'&';
+                                       buf_idx++;
+                                       i += 4;
+                               }
+                       }
+                       if(len > (i+3)){
+                               if(srcp[i+1] == L'g' &&
+                                               srcp[i+2] == L't' &&
+                                               srcp[i+3] == L';'){
+                                       buf[buf_idx] = L'>';
+                                       buf_idx++;
+                                       i += 3;
+                                       wrk_linkp = w_parse_number_list_local(srcp+i+1, NULL);
+                                       if(wrk_linkp){
+                                               *num_linkpp = nt_link_add_last(*num_linkpp, wrk_linkp);
+                                       }
+                               }else if(srcp[i+1] == L'l' &&
+                                               srcp[i+2] == L't' &&
+                                               srcp[i+3] == L';'){
+                                       buf[buf_idx] = L'<';
+                                       buf_idx++;
+                                       i += 3;
+                               }
+                       }
+                       break;
+               case L'<':
+                       if(len > (i+3) && srcp[i+1] == L'b' &&
+                                       srcp[i+2] == L'r' &&
+                                       srcp[i+3] == L'>'){
+                               buf[buf_idx] = L'\n';
+                               buf_idx++;
+                               i += 3;
+                       }else if(len > (i+7) && srcp[i+1] == L'a' &&
+                                       srcp[i+2] == L' ' &&
+                                       srcp[i+3] == L'h' &&
+                                       srcp[i+4] == L'r' &&
+                                       srcp[i+5] == L'e' &&
+                                       srcp[i+6] == L'f' &&
+                                       srcp[i+7] == L'='){
+                               cptr = wcschr(srcp+i+8, L'>');
+                               if(cptr){
+                                       offset = cptr - &(srcp[i]);
+                                       i += offset;
+                               }
+                       }else if(len > (i+3) && srcp[i+1] == L'/' &&
+                                       srcp[i+2] == L'a' &&
+                                       srcp[i+3] == L'>'){
+                               i += 3;
+                       }
+                       break;
+       /*      case L'>':
+                       wrk_linkp = w_parse_number_list_local(srcp+i, NULL);
+                       if(wrk_linkp){
+                               *num_linkpp = nt_link_add_last(*num_linkpp, wrk_linkp);
+                       }
+                       goto DEF_LABEL; */
+               case L't':
+                       if(len > (i+5) && (i == 0 || (i > 0 && 
+                               srcp[i-1] != L'h' && srcp[i-1] != L'H')) &&
+                                       srcp[i+1] == L't' &&
+                                       srcp[i+2] == L'p' &&
+                                       srcp[i+3] == L':' &&
+                                       srcp[i+4] == L'/' &&
+                                       srcp[i+5] == L'/'){
+                               buf[buf_idx] = L'h';
+                               buf_idx++;
+                       }
+                       /* fall through */
+               default:
+//DEF_LABEL:
+                       buf[buf_idx] = ch;
+                       buf_idx++;
+                       break;
+               }/* end switch */
+               if(buf_idx >= (buf_size-1)){
+                       wrk_buf = nt_w_str_resize(buf, buf_size, (buf_size + delta));
+                       if(!wrk_buf){
+                               free(buf);
+                               return NULL;
+                       }
+                       buf = wrk_buf;
+                       buf_size += delta;
+               }
+       } /* end for */
+       buf[buf_idx] = L'\0';
+       return buf;
+}
index 3b66931..cf38c7e 100644 (file)
--- a/src/env.c
+++ b/src/env.c
@@ -27,6 +27,7 @@
 #define _GNU_SOURCE
 #include <getopt.h>
 
+#include "config.h"
 #include "env.h"
 #include "utils/nt_std_t.h"
 #include "utils/file.h"
@@ -39,8 +40,8 @@ char USR_LOG_DB_PATH[1024];
 char EDITOR_CMD[1024]; 
 int FORCE_REFRESH = 0; 
 int THREAD_SORT_TYPE = NT_THREAD_SORT_BY_READ; 
-static char *app_name = "ntch";
-static char *version_name = "1.0.1.5";
+static char *app_name = PACKAGE_NAME;
+static char *version_name = PACKAGE_VERSION;
 static char *def_editor_cmd = "vi";
 
 char *MARU_ID;
index f544013..f8d78ed 100644 (file)
@@ -50,9 +50,6 @@ typedef struct tag_nt_res_t{
        wchar_t *mail;
        wchar_t *misc;
        wchar_t *msg;
-       int msg_line_num;
-       int msg_header_line_num;
-       nt_link_tp msg_line_linkp;
 } nt_res_t;
 
 typedef struct tag_nt_2ch_model_t *nt_2ch_model_tp;
@@ -98,13 +95,11 @@ extern void nt_board_children_free(nt_board_tp ptr);
 extern void nt_thread_free(nt_thread_tp ptr);
 extern void nt_thread_children_free(nt_thread_tp ptr);
 extern void nt_res_free(nt_res_tp ptr);
-extern void nt_res_msg_free(nt_res_tp ptr);
 
 extern BOOL parse_board_menu(nt_2ch_model_tp modelp,
                const wchar_t *linep);
 extern BOOL parse_board(nt_board_tp boardp, const wchar_t *linep);
 extern BOOL parse_thread(nt_thread_tp boardp, const wchar_t *linep);
-extern int parse_res_msg(nt_res_tp resp, size_t colmns);
 
 extern void nt_set_selected_board(nt_2ch_model_tp modelp,
                nt_category_tp categoryp, nt_board_tp boardp);
index bccdac2..60dcde0 100644 (file)
@@ -1,7 +1,28 @@
+/* Copyright 2013 Akira Ohta (akohta001@gmail.com)
+    This file is part of ntch.
+
+    The ntch is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    The ntch is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with ntch.  If not, see <http://www.gnu.org/licenses/>.
+    
+*/
 #ifndef _PARSE_2CH_H_
 #define _PARSE_2CH_H_
 
-extern nt_link_tp parse_number_list (
+extern int nt_comp_int(int a, int b);
+
+extern nt_link_tp nt_parse_number_list (
                const char *source, const char **endpp);
+extern wchar_t*  nt_parse_res_msg(const wchar_t *srcp, nt_link_tp *num_linkpp);
+extern wchar_t* nt_w_format_number_list (nt_link_tp num_listp);
 
 #endif /* _PARSE_2CH_H_ */
diff --git a/src/inc/config.h b/src/inc/config.h
new file mode 100644 (file)
index 0000000..42a742d
--- /dev/null
@@ -0,0 +1,123 @@
+/* config.h.  Generated from config.h.in by configure.  */
+/* config.h.in.  Generated from configure.ac by autoheader.  */
+
+/* Define to 1 if you have the <arpa/inet.h> header file. */
+#define HAVE_ARPA_INET_H 1
+
+/* Define to 1 if you have the <fcntl.h> header file. */
+#define HAVE_FCNTL_H 1
+
+/* Define to 1 if you have the `gethostbyname' function. */
+#define HAVE_GETHOSTBYNAME 1
+
+/* Define to 1 if you have the <inttypes.h> header file. */
+#define HAVE_INTTYPES_H 1
+
+/* Define to 1 if you have the `crypto' library (-lcrypto). */
+#define HAVE_LIBCRYPTO 1
+
+/* Define to 1 if you have the `gdbm' library (-lgdbm). */
+/* #undef HAVE_LIBGDBM */
+
+/* Define to 1 if you have the `gdbm_compat' library (-lgdbm_compat). */
+#define HAVE_LIBGDBM_COMPAT 1
+
+/* Define to 1 if you have the `m' library (-lm). */
+#define HAVE_LIBM 1
+
+/* Define to 1 if you have the `ncursesw' library (-lncursesw). */
+#define HAVE_LIBNCURSESW 1
+
+/* Define to 1 if you have the `ssl' library (-lssl). */
+#define HAVE_LIBSSL 1
+
+/* Define to 1 if you have the <locale.h> header file. */
+#define HAVE_LOCALE_H 1
+
+/* Define to 1 if your system has a GNU libc compatible `malloc' function, and
+   to 0 otherwise. */
+#define HAVE_MALLOC 1
+
+/* Define to 1 if you have the <memory.h> header file. */
+#define HAVE_MEMORY_H 1
+
+/* Define to 1 if you have the `memset' function. */
+#define HAVE_MEMSET 1
+
+/* Define to 1 if you have the `mkdir' function. */
+#define HAVE_MKDIR 1
+
+/* Define to 1 if you have the <netdb.h> header file. */
+#define HAVE_NETDB_H 1
+
+/* Define to 1 if you have the `setlocale' function. */
+#define HAVE_SETLOCALE 1
+
+/* Define to 1 if you have the `socket' function. */
+#define HAVE_SOCKET 1
+
+/* Define to 1 if you have the <stdint.h> header file. */
+#define HAVE_STDINT_H 1
+
+/* Define to 1 if you have the <stdlib.h> header file. */
+#define HAVE_STDLIB_H 1
+
+/* Define to 1 if you have the `strchr' function. */
+#define HAVE_STRCHR 1
+
+/* Define to 1 if you have the <strings.h> header file. */
+#define HAVE_STRINGS_H 1
+
+/* Define to 1 if you have the <string.h> header file. */
+#define HAVE_STRING_H 1
+
+/* Define to 1 if you have the `strrchr' function. */
+#define HAVE_STRRCHR 1
+
+/* Define to 1 if you have the `strtol' function. */
+#define HAVE_STRTOL 1
+
+/* Define to 1 if you have the <sys/socket.h> header file. */
+#define HAVE_SYS_SOCKET_H 1
+
+/* Define to 1 if you have the <sys/stat.h> header file. */
+#define HAVE_SYS_STAT_H 1
+
+/* Define to 1 if you have the <sys/types.h> header file. */
+#define HAVE_SYS_TYPES_H 1
+
+/* Define to 1 if you have the <unistd.h> header file. */
+#define HAVE_UNISTD_H 1
+
+/* Define to 1 if you have the <wchar.h> header file. */
+#define HAVE_WCHAR_H 1
+
+/* Define to the address where bug reports for this package should be sent. */
+#define PACKAGE_BUGREPORT "akohta001@gmail.com"
+
+/* Define to the full name of this package. */
+#define PACKAGE_NAME "ntch"
+
+/* Define to the full name and version of this package. */
+#define PACKAGE_STRING "ntch 1.0.1.6"
+
+/* Define to the one symbol short name of this package. */
+#define PACKAGE_TARNAME "ntch"
+
+/* Define to the home page for this package. */
+#define PACKAGE_URL "https://sourceforge.jp/projects/ntch/"
+
+/* Define to the version of this package. */
+#define PACKAGE_VERSION "1.0.1.6"
+
+/* Define to 1 if you have the ANSI C header files. */
+#define STDC_HEADERS 1
+
+/* Define to rpl_malloc if the replacement function should be used. */
+/* #undef malloc */
+
+/* Define to `int' if <sys/types.h> does not define. */
+/* #undef pid_t */
+
+/* Define to `unsigned int' if <sys/types.h> does not define. */
+/* #undef size_t */
index a48bc26..a6080ff 100644 (file)
@@ -67,6 +67,10 @@ extern char *MARU_PW;
 #define NT_COMMAND1_SORT_UNREAD_2 "u"
 #define NT_COMMAND1_DEL_THREAD_LOG_1 "del"
 #define NT_COMMAND1_DEL_THREAD_LOG_2 "d"
+#define NT_COMMAND1_TREE_1 "tree"
+#define NT_COMMAND1_TREE_2 "t"
+#define NT_COMMAND1_ID_1 "id"
+#define NT_COMMAND1_ID_2 "i"
 
 extern int set_option(int argc, char* argv[]);
 
index 314a487..1776762 100644 (file)
@@ -47,9 +47,12 @@ typedef struct tag_nt_stack_t{
 } nt_stack_t;
 
 extern void* nt_stack_push(nt_stack_tp stackp, void* data);
+extern void* nt_stack_peek(nt_stack_tp stackp);
 extern void* nt_stack_pop(nt_stack_tp stackp);
 extern void* nt_stack_cursor_next();
 extern void* nt_stack_add_last(nt_stack_tp stackp, void* data);
+extern int nt_stack_get_position(nt_stack_tp stackp);
+extern BOOL nt_stack_is_empty(nt_stack_tp stackp);
 
 extern nt_stack_tp nt_stack_alloc();
 extern void nt_stack_free(nt_stack_tp ptr, nt_memfree_fn free_func);
@@ -58,6 +61,7 @@ extern nt_link_tp nt_link_add_data(nt_link_tp link, void *data);
 extern nt_link_tp nt_link_add_n_data(nt_link_tp link, int  n_data);
 extern nt_link_tp nt_link_insert_before(nt_link_tp top_linkp,
                        nt_link_tp dest, nt_link_tp src);
+extern nt_link_tp nt_link_add_last(nt_link_tp top_linkp, nt_link_tp src);
 extern nt_link_tp nt_link_remove(nt_link_tp src, nt_link_tp target);
 extern nt_link_tp nt_link_remove2(nt_link_tp src, nt_link_tp target);
 extern nt_link_tp nt_link_remove_by_data(nt_link_tp link, void *data);
index 845e765..986d26e 100644 (file)
@@ -30,5 +30,7 @@ extern char* nt_str_clone(const char *cptr);
 extern char* nt_substr(const char *cptr, int start, int end);
 extern BOOL nt_strtok(const char *str, char delim, 
                const char** start, const char **end);
+extern wchar_t* nt_w_str_resize(wchar_t *old_src, 
+               size_t old_size, size_t new_size);
 
 #endif /* _TEXT_H_ */
index 0d9e174..0c50cf1 100644 (file)
@@ -232,8 +232,11 @@ static char* merge_cookie(const char *val1, const char *val2)
                                kvp = nt_key_value_alloc(key, value);
                                if(linkp){
                                        wrk_linkp = nt_link_find(linkp, kvp, cmp_link_func);
-                                       if(wrk_linkp)
-                                               nt_link_remove(linkp, wrk_linkp);
+                                       if(wrk_linkp){
+                                               linkp = nt_link_remove2(linkp, wrk_linkp);
+                                               kvp_free_func(wrk_linkp->data);
+                                               free(wrk_linkp);
+                                       }
                                }
                                wrk_linkp = nt_link_add_data(linkp, kvp);
                                if(!linkp)
@@ -280,11 +283,9 @@ static char* merge_cookie(const char *val1, const char *val2)
                                if(linkp){
                                        wrk_linkp = nt_link_find(linkp, kvp, cmp_link_func);
                                        if(wrk_linkp){
-                                               wrk_linkp = nt_link_remove(linkp, wrk_linkp);
-                                               if(wrk_linkp){
-                                                       kvp_free_func(wrk_linkp->data);
-                                                       free(wrk_linkp);
-                                               }
+                                               linkp = nt_link_remove2(linkp, wrk_linkp);
+                                               kvp_free_func(wrk_linkp->data);
+                                               free(wrk_linkp);
                                        }
                                }
                                wrk_linkp = nt_link_add_data(linkp, kvp);
index 6977835..dc59d9e 100644 (file)
 #include       "utils/text.h"
 #include       "_2ch/_2ch.h"
 #include       "_2ch/model_2ch.h"
+#include       "_2ch/parse_2ch.h"
 #include       "ui/disp.h"
 #include       "ui/disp_string.h"
 
 #define NT_CMD_NONE -1
 #define NT_CMD_WRITE 1
 #define NT_CMD_JMP_NEW 2
+#define NT_CMD_TREE 3
+#define NT_CMD_ID 4
 
 typedef struct tag_ctx_reslist_t *ctx_reslist_tp;
 typedef struct tag_ctx_reslist_t
@@ -53,26 +56,57 @@ typedef struct tag_ctx_reslist_t
        int sel_res_no;
        int sel_res_line;
 
+       nt_link_tp res_disp_list;
+       
+       nt_stack_tp child_ctx_stackp;
+       
 } ctx_reslist_t;
 
+typedef struct tag_res_data_t *res_data_tp;
+typedef struct tag_res_data_t {
+       nt_res_t *resp;
+       nt_link_tp cite_num_list;
+       nt_link_tp cited_num_list;
+       int msg_line_num;
+       int msg_header_line_num;
+       nt_link_tp msg_line_linkp;
+       int id_num;
+}res_data_t;
 
 static ctx_reslist_tp init_context(nt_2ch_model_tp modelp, 
                        void *usr_db_handle);
+static BOOL reslist_clone(nt_thread_tp threadp, ctx_reslist_tp ctxp);
 static void int_ptr_free(void *ptr);
-static int parse_cmd1(const char *param, int *statep);
+static int parse_cmd1(const char *param, int *statep, const char **end);
 static BOOL search_line_asc(regex_t *regexp, nt_link_tp reslistp, 
                        int *sel_res_no, int *sel_res_line, int column);
 static BOOL search_line_desc(regex_t *regexp, ctx_reslist_tp ctxp,
                        nt_link_tp reslistp, 
                        int *sel_res_no, int *sel_res_line, int column);
+static int parse_res_msg(nt_link_tp disp_res_list, 
+                       res_data_tp res_datap, size_t colmns);
+static void res_msg_free(void *ptr);
+static nt_link_tp get_cited_num_list(nt_link_tp res_listp, int seq_no);
+static BOOL reslist_copy(ctx_reslist_tp ctxp, ctx_reslist_tp copy_ctxp, 
+                       nt_link_tp num_listp);
+static ctx_reslist_tp init_sub_context(ctx_reslist_tp ctxp, nt_link_tp num_listp);
+static void free_reslist_sub_ctx(void *ptr);
+static nt_link_tp parse_tree_list(ctx_reslist_tp ctxp, const char *param);
+static nt_link_tp parse_id_list(ctx_reslist_tp ctxp, const char *param);
+static void search_up_tree(int seq_no, nt_link_tp disp_list, nt_link_tp *num_linkp);
+static void search_down_tree(int seq_no, nt_link_tp disp_list, nt_link_tp *num_linkp);
+static int get_id_num(ctx_reslist_tp ctxp, const wchar_t *misc);
+static BOOL set_res_header(ctx_reslist_tp ctxp, res_data_tp res_datap,
+                               wchar_t *buf, size_t buf_len);
 
 int disp_reslist(nt_window_tp wp, nt_2ch_model_tp modelp,
        void *usr_db_handle)
 {
-       ctx_reslist_tp ctxp;
-       nt_res_tp resp;
-       nt_thread_tp threadp;
+       ctx_reslist_tp ctxp, child_ctxp;
+       res_data_tp res_datap;
        nt_link_tp clistp;
+       nt_link_tp linkp;
+       nt_stack_tp stackp;
        int i, rows;
        int wlines;
        int len, ch;
@@ -90,6 +124,7 @@ int disp_reslist(nt_window_tp wp, nt_2ch_model_tp modelp,
        int line_num;
        int  cmd;
        attr_t new_res_attr;
+       const char *endp;
 
        ctxp = (ctx_reslist_tp)wp->data;
        if(!ctxp){
@@ -97,28 +132,36 @@ int disp_reslist(nt_window_tp wp, nt_2ch_model_tp modelp,
                if(!ctxp)
                        return DISP_STATE_ERROR;
                wp->data = ctxp;
+       }else if(ctxp->child_ctx_stackp){
+               ctxp = (ctx_reslist_tp)nt_stack_peek(
+                                       ctxp->child_ctx_stackp);
+               if(!ctxp){
+                       ctxp->child_ctx_stackp = NULL;
+                       ctxp = (ctx_reslist_tp)wp->data;
+               }
        }
        ch = wp->key;
 
-       threadp = modelp->selected_threadp;
 
        if(ctxp->max_cur_res < 0 || ctxp->max_cur_offset < 0){
                wlines = wp->lines;
                int cur_res = ctxp->res_num - 1;
                /* get the bottom scroll position*/
-               clistp = threadp->reslistp->prev;
-               while(clistp != threadp->reslistp){
-                       resp = (nt_res_tp)clistp->data;
-                       if(!resp->msg_line_linkp){
-                               parse_res_msg(resp, wp->cols-5);
+               clistp = ctxp->res_disp_list->prev;
+               while(clistp != ctxp->res_disp_list){
+                       res_datap = (res_data_tp)clistp->data;
+                       if(!res_datap->msg_line_linkp){
+                               parse_res_msg(ctxp->res_disp_list, res_datap, wp->cols-5);
                        }
 
-                       if(resp->msg_header_line_num <= 0){
-                               if(-1 == swprintf(buf, sizeof(buf)-1, 
+                       if(res_datap->msg_header_line_num <= 0){
+                               /*if(-1 == swprintf(buf, sizeof(buf)-1, 
                                                L"%5d. %ls %ls %ls", 
-                                               resp->seq_no, resp->name,
-                                               resp->mail, resp->misc)){
-                                       resp->msg_header_line_num = 1;
+                                               res_datap->resp->seq_no, res_datap->resp->name,
+                                               res_datap->resp->mail, res_datap->resp->misc)){*/
+                               if(!set_res_header((ctx_reslist_tp)wp->data, 
+                                               res_datap, buf, sizeof(buf)/sizeof(buf[0]))){
+                                       res_datap->msg_header_line_num = 1;
                                }else{
                                        len = wcslen(buf);
                                        cptr = buf;
@@ -127,7 +170,7 @@ int disp_reslist(nt_window_tp wp, nt_2ch_model_tp modelp,
                                                                        cptr, wp->cols);
                                                if(num <= 0)
                                                        break;
-                                               resp->msg_header_line_num++;
+                                               res_datap->msg_header_line_num++;
                                                len -= num;
                                                cptr += num;
                                        }
@@ -135,25 +178,25 @@ int disp_reslist(nt_window_tp wp, nt_2ch_model_tp modelp,
                        }
                        wlines--;
                        if(wlines == 0){
-                               ctxp->max_cur_offset = resp->msg_header_line_num;
-                               ctxp->max_cur_offset += resp->msg_line_num;
+                               ctxp->max_cur_offset = res_datap->msg_header_line_num;
+                               ctxp->max_cur_offset += res_datap->msg_line_num;
                                ctxp->max_cur_res = cur_res;
                                break;
                        }
-                       if(wlines <= resp->msg_line_num){
-                               ctxp->max_cur_offset = resp->msg_header_line_num;
-                               ctxp->max_cur_offset += resp->msg_line_num - wlines;
+                       if(wlines <= res_datap->msg_line_num){
+                               ctxp->max_cur_offset = res_datap->msg_header_line_num;
+                               ctxp->max_cur_offset += res_datap->msg_line_num - wlines;
                                ctxp->max_cur_res = cur_res;
                                break;
                        }
-                       wlines -= resp->msg_line_num;
-                       if(wlines <= resp->msg_header_line_num){
+                       wlines -= res_datap->msg_line_num;
+                       if(wlines <= res_datap->msg_header_line_num){
                                ctxp->max_cur_offset = 
-                                               resp->msg_header_line_num - wlines;
+                                               res_datap->msg_header_line_num - wlines;
                                ctxp->max_cur_res = cur_res;
                                break;
                        }
-                       wlines -= resp->msg_header_line_num;
+                       wlines -= res_datap->msg_header_line_num;
                        cur_res--;
                        if(cur_res < 0){
                                ctxp->max_cur_offset = 0;
@@ -174,15 +217,36 @@ int disp_reslist(nt_window_tp wp, nt_2ch_model_tp modelp,
        case KEY_END:
                if(ctxp->cur_res == ctxp->res_num - 1)
                        break;
-               if(!threadp->reslistp)
+               if(!ctxp->res_disp_list)
                        break;
-               clistp = threadp->reslistp->prev;
+               clistp = ctxp->res_disp_list->prev;
                ctxp->cur_res = ctxp->max_cur_res;
                ctxp->cur_res_offset = ctxp->max_cur_offset;
                break;
        case NT_KEY_LEFT:
                if(!ctxp->selected_num_stackp)
                        break;
+               if(0 >= nt_stack_get_position(ctxp->selected_num_stackp)){
+                       if((ctx_reslist_tp)wp->data != ctxp){
+                               stackp = ((ctx_reslist_tp)wp->data)->child_ctx_stackp;
+                               if(stackp){
+                                       if(0 >= nt_stack_get_position(stackp)){
+                                               ctxp = (ctx_reslist_tp)wp->data;
+                                               nt_stack_free(stackp, free_reslist_sub_ctx);
+                                               ((ctx_reslist_tp)wp->data)->child_ctx_stackp = NULL;
+                                               break;
+                                       }
+                                       child_ctxp = nt_stack_pop(stackp);
+                                       if(!child_ctxp)
+                                               break;
+                                       child_ctxp = nt_stack_peek(stackp);
+                                       if(!child_ctxp)
+                                               break;
+                                       ctxp = child_ctxp;
+                               }
+                       }
+                       break;
+               }
                nptr = malloc(sizeof(int));
                *nptr = ctxp->cur_res;
                ptr = nt_stack_add_last(ctxp->selected_num_stackp, nptr);
@@ -199,9 +263,9 @@ int disp_reslist(nt_window_tp wp, nt_2ch_model_tp modelp,
                        break;
                ctxp->cur_res = num;
                ctxp->cur_res_offset = 0;
-               if(!threadp->reslistp)
+               if(!ctxp->res_disp_list)
                        break;
-               clistp = threadp->reslistp;
+               clistp = ctxp->res_disp_list;
                for(i = 0; i < num; i++)
                        clistp = clistp->next;
                break;
@@ -218,9 +282,9 @@ int disp_reslist(nt_window_tp wp, nt_2ch_model_tp modelp,
                        break;
                ctxp->cur_res = num;
                ctxp->cur_res_offset = 0;
-               if(!threadp->reslistp)
+               if(!ctxp->res_disp_list)
                        break;
-               clistp = threadp->reslistp;
+               clistp = ctxp->res_disp_list;
                for(i = 0; i < num; i++)
                        clistp = clistp->next;
                break;
@@ -243,14 +307,14 @@ int disp_reslist(nt_window_tp wp, nt_2ch_model_tp modelp,
                        break;
                adjust = FALSE;
                if(search_asc){
-                       if(search_line_asc(&(ctxp->regex),threadp->reslistp,
+                       if(search_line_asc(&(ctxp->regex),ctxp->res_disp_list,
                                        &ctxp->sel_res_no, &ctxp->sel_res_line, 
                                        wp->cols - 5)){
                                adjust = TRUE;
                        }
                }else{
                        if(search_line_desc(&(ctxp->regex),ctxp,
-                                       threadp->reslistp,
+                                       ctxp->res_disp_list,
                                        &ctxp->sel_res_no, &ctxp->sel_res_line, 
                                        wp->cols - 5)){
                                adjust = TRUE;
@@ -261,19 +325,22 @@ int disp_reslist(nt_window_tp wp, nt_2ch_model_tp modelp,
                        rows = ctxp->res_num - 1;
                        wlines = wp->lines / 2;
                        wlines -= ctxp->sel_res_line;
-                       clistp = threadp->reslistp->prev;
+                       clistp = ctxp->res_disp_list->prev;
                        do{
                                if(rows <= ctxp->sel_res_no){
-                                       resp = (nt_res_tp)clistp->data;
-                                       if(!resp->msg_line_linkp){
-                                               parse_res_msg(resp, wp->cols-5);
+                                       res_datap = (res_data_tp)clistp->data;
+                                       //resp = (nt_res_tp)clistp->data;
+                                       if(!res_datap->msg_line_linkp){
+                                               parse_res_msg(ctxp->res_disp_list, res_datap, wp->cols-5);
                                        }
-                                       if(resp->msg_header_line_num <= 0){
-                                               if(-1 == swprintf(buf, sizeof(buf)-1, 
+                                       if(res_datap->msg_header_line_num <= 0){
+                                               /*if(-1 == swprintf(buf, sizeof(buf)-1, 
                                                                L"%5d. %ls %ls %ls", 
-                                                               resp->seq_no, resp->name,
-                                                               resp->mail, resp->misc)){
-                                                       resp->msg_header_line_num = 1;
+                                                               res_datap->resp->seq_no, res_datap->resp->name,
+                                                               res_datap->resp->mail, res_datap->resp->misc)){*/
+                                               if(!set_res_header((ctx_reslist_tp)wp->data, 
+                                                               res_datap, buf, sizeof(buf)/sizeof(buf[0]))){
+                                                       res_datap->msg_header_line_num = 1;
                                                }else{
                                                        len = wcslen(buf);
                                                        cptr = buf;
@@ -282,7 +349,7 @@ int disp_reslist(nt_window_tp wp, nt_2ch_model_tp modelp,
                                                                                        cptr, wp->cols);
                                                                if(num <= 0)
                                                                        break;
-                                                               resp->msg_header_line_num++;
+                                                               res_datap->msg_header_line_num++;
                                                                len -= num;
                                                                cptr += num;
                                                        }
@@ -292,33 +359,33 @@ int disp_reslist(nt_window_tp wp, nt_2ch_model_tp modelp,
                                                if(wlines <= ctxp->sel_res_line){
                                                        ctxp->cur_res = rows;
                                                        ctxp->cur_res_offset = 
-                                                                       resp->msg_header_line_num + 
+                                                                       res_datap->msg_header_line_num + 
                                                                        (ctxp->sel_res_line - wlines);
                                                        set_value = TRUE;
                                                        break;
                                                }
                                                wlines -= ctxp->sel_res_line;
-                                       }else if(wlines <= (resp->msg_line_num+1)){
+                                       }else if(wlines <= (res_datap->msg_line_num+1)){
                                                ctxp->cur_res = rows;
                                                ctxp->cur_res_offset = 
-                                                               resp->msg_header_line_num + wlines;
+                                                               res_datap->msg_header_line_num + wlines;
                                                set_value = TRUE;
                                                break;
                                        }else{
-                                               wlines -= resp->msg_line_num + 1;
+                                               wlines -= res_datap->msg_line_num + 1;
                                        }
-                                       if(wlines <= resp->msg_header_line_num){
+                                       if(wlines <= res_datap->msg_header_line_num){
                                                ctxp->cur_res = rows;
                                                ctxp->cur_res_offset = 
-                                                               resp->msg_header_line_num - wlines;
+                                                               res_datap->msg_header_line_num - wlines;
                                                set_value = TRUE;
                                                break;
                                        }
-                                       wlines -= resp->msg_header_line_num;
+                                       wlines -= res_datap->msg_header_line_num;
                                }
                                rows--;
                                clistp = clistp->prev;
-                       }while(clistp != threadp->reslistp->prev);
+                       }while(clistp != ctxp->res_disp_list->prev);
                        if(!set_value){
                                ctxp->cur_res = 0;
                                ctxp->cur_res_offset = 0;
@@ -327,7 +394,7 @@ int disp_reslist(nt_window_tp wp, nt_2ch_model_tp modelp,
                break;
        case NT_KEY_COMMAND1:
                assert(wp->cmd_param);
-               cmd = parse_cmd1(wp->cmd_param, &state);
+               cmd = parse_cmd1(wp->cmd_param, &state, &endp);
                switch(cmd){
                case NT_CMD_WRITE:
                        return state;
@@ -342,26 +409,45 @@ int disp_reslist(nt_window_tp wp, nt_2ch_model_tp modelp,
                        ctxp->cur_res_offset = 0;
                        break;
                default:
-                       num = atoi(wp->cmd_param);
-                       if(0 == num)
-                               break;
-                       num--;
-                       if(ctxp->cur_res == num)
-                               break;
-                       if(num >= ctxp->res_num)
+                       if(cmd == NT_CMD_TREE){
+                               linkp = parse_tree_list((ctx_reslist_tp)wp->data, endp);
+                       }else if(cmd == NT_CMD_ID){
+                               linkp = parse_id_list((ctx_reslist_tp)wp->data, endp);
+                       }else{
+                               linkp = nt_parse_number_list(wp->cmd_param, NULL);
+                       }
+                       if(!linkp)
                                break;
-                       nptr = malloc(sizeof(int));
-                       *nptr = ctxp->cur_res;
-                       ctxp->cur_res = num;
-                       ctxp->cur_res_offset = 0;
-                       if(!threadp->reslistp){
-                               free(nptr);
+                       num = nt_link_num(linkp);
+                       if(0 >= num){
                                break;
+                       }else if(1 == num){
+                               num = linkp->n_data;
+                               free(linkp);
+                               num--;
+                               if(ctxp->cur_res == num)
+                                       break;
+                               if(num >= ctxp->res_num)
+                                       break;
+                               nptr = malloc(sizeof(int));
+                               *nptr = ctxp->cur_res;
+                               ctxp->cur_res = num;
+                               ctxp->cur_res_offset = 0;
+                               if(!ctxp->res_disp_list){
+                                       free(nptr);
+                                       break;
+                               }
+                               clistp = ctxp->res_disp_list;
+                               for(i = 0; i < num; i++)
+                                       clistp = clistp->next;
+                               nt_stack_push(ctxp->selected_num_stackp, nptr);
+                       }else{
+                               child_ctxp = init_sub_context((ctx_reslist_tp)wp->data, linkp);
+                               if(child_ctxp){
+                                       ctxp = child_ctxp;
+                               }
+                               nt_all_link_free(linkp, NULL);
                        }
-                       clistp = threadp->reslistp;
-                       for(i = 0; i < num; i++)
-                               clistp = clistp->next;
-                       nt_stack_push(ctxp->selected_num_stackp, nptr);
                        break;
                }/* end switch */
                break;
@@ -377,7 +463,7 @@ int disp_reslist(nt_window_tp wp, nt_2ch_model_tp modelp,
                        break;
                }
                ctxp->cur_res--;
-               clistp = threadp->reslistp;
+               clistp = ctxp->res_disp_list;
                for(i = 0; i < ctxp->res_num; i++){
                        if(i == ctxp->cur_res)
                                break;
@@ -385,16 +471,18 @@ int disp_reslist(nt_window_tp wp, nt_2ch_model_tp modelp,
                }
                if(i == ctxp->res_num)
                        break;
-               resp = (nt_res_tp)clistp->data;
-               if(!resp->msg_line_linkp){
-                       parse_res_msg(resp, wp->cols-5);
+               res_datap = (res_data_tp)clistp->data;
+               if(!res_datap->msg_line_linkp){
+                       parse_res_msg(ctxp->res_disp_list, res_datap, wp->cols-5);
                }
-               if(resp->msg_header_line_num <= 0){
-                       if(-1 == swprintf(buf, sizeof(buf)-1, 
+               if(res_datap->msg_header_line_num <= 0){
+                       /*if(-1 == swprintf(buf, sizeof(buf)-1, 
                                        L"%5d. %ls %ls %ls", 
-                                       resp->seq_no, resp->name,
-                                       resp->mail, resp->misc)){
-                               resp->msg_header_line_num = 1;
+                                       res_datap->resp->seq_no, res_datap->resp->name,
+                                       res_datap->resp->mail, res_datap->resp->misc)){*/
+                       if(!set_res_header((ctx_reslist_tp)wp->data, 
+                                               res_datap, buf, sizeof(buf)/sizeof(buf[0]))){
+                               res_datap->msg_header_line_num = 1;
                        }else{
                                len = wcslen(buf);
                                cptr = buf;
@@ -403,20 +491,20 @@ int disp_reslist(nt_window_tp wp, nt_2ch_model_tp modelp,
                                                                cptr, wp->cols);
                                        if(num <= 0)
                                                break;
-                                       resp->msg_header_line_num++;
+                                       res_datap->msg_header_line_num++;
                                        len -= num;
                                        cptr += num;
                                }
                        }
                }
-               num = resp->msg_header_line_num;
-               num += resp->msg_line_num;
+               num = res_datap->msg_header_line_num;
+               num += res_datap->msg_line_num;
                ctxp->cur_res_offset = num;
                break;
        case NT_KEY_DOWN:
        case KEY_DOWN:
                ctxp->cur_res_offset++;
-               clistp = threadp->reslistp;
+               clistp = ctxp->res_disp_list;
                for(i = 0; i < ctxp->res_num; i++){
                        if(i == ctxp->cur_res)
                                break;
@@ -424,16 +512,18 @@ int disp_reslist(nt_window_tp wp, nt_2ch_model_tp modelp,
                }
                if(i == ctxp->res_num)
                        break;
-               resp = (nt_res_tp)clistp->data;
-               if(!resp->msg_line_linkp){
-                       parse_res_msg(resp, wp->cols-5);
+               res_datap = (res_data_tp)clistp->data;
+               if(!res_datap->msg_line_linkp){
+                       parse_res_msg(ctxp->res_disp_list, res_datap, wp->cols-5);
                }
-               if(resp->msg_header_line_num <= 0){
-                       if(-1 == swprintf(buf, sizeof(buf)-1, 
+               if(res_datap->msg_header_line_num <= 0){
+                       /*if(-1 == swprintf(buf, sizeof(buf)-1, 
                                        L"%5d. %ls %ls %ls", 
-                                       resp->seq_no, resp->name,
-                                       resp->mail, resp->misc)){
-                               resp->msg_header_line_num = 1;
+                                       res_datap->resp->seq_no, res_datap->resp->name,
+                                       res_datap->resp->mail, res_datap->resp->misc)){*/
+                       if(!set_res_header((ctx_reslist_tp)wp->data, 
+                                       res_datap, buf, sizeof(buf)/sizeof(buf[0]))){
+                               res_datap->msg_header_line_num = 1;
                        }else{
                                len = wcslen(buf);
                                cptr = buf;
@@ -442,14 +532,14 @@ int disp_reslist(nt_window_tp wp, nt_2ch_model_tp modelp,
                                                                cptr, wp->cols);
                                        if(num <= 0)
                                                break;
-                                       resp->msg_header_line_num++;
+                                       res_datap->msg_header_line_num++;
                                        len -= num;
                                        cptr += num;
                                }
                        }
                }
-               num = resp->msg_header_line_num;
-               num += resp->msg_line_num + 1;
+               num = res_datap->msg_header_line_num;
+               num += res_datap->msg_line_num + 1;
                if(ctxp->cur_res_offset >= num){
                        ctxp->cur_res++;
                        ctxp->cur_res_offset = 0;
@@ -462,7 +552,7 @@ int disp_reslist(nt_window_tp wp, nt_2ch_model_tp modelp,
                        break;
                }
                ctxp->cur_res--;
-               clistp = threadp->reslistp;
+               clistp = ctxp->res_disp_list;
                for(i = 0; i < ctxp->res_num; i++){
                        if(i == ctxp->cur_res)
                                break;
@@ -473,16 +563,18 @@ int disp_reslist(nt_window_tp wp, nt_2ch_model_tp modelp,
                        break;
                }
                for( ; i > 0; i--){
-                       resp = (nt_res_tp)clistp->data;
-                       if(!resp->msg_line_linkp){
-                               parse_res_msg(resp, wp->cols-5);
+                       res_datap = (res_data_tp)clistp->data;
+                       if(!res_datap->msg_line_linkp){
+                               parse_res_msg(ctxp->res_disp_list, res_datap, wp->cols-5);
                        }
-                       if(resp->msg_header_line_num <= 0){
-                               if(-1 == swprintf(buf, sizeof(buf)-1, 
+                       if(res_datap->msg_header_line_num <= 0){
+                               /*if(-1 == swprintf(buf, sizeof(buf)-1, 
                                                L"%5d. %ls %ls %ls", 
-                                               resp->seq_no, resp->name,
-                                               resp->mail, resp->misc)){
-                                       resp->msg_header_line_num = 1;
+                                               res_datap->resp->seq_no, res_datap->resp->name,
+                                               res_datap->resp->mail, res_datap->resp->misc)){*/
+                               if(!set_res_header((ctx_reslist_tp)wp->data, 
+                                               res_datap, buf, sizeof(buf)/sizeof(buf[0]))){
+                                       res_datap->msg_header_line_num = 1;
                                }else{
                                        len = wcslen(buf);
                                        cptr = buf;
@@ -491,14 +583,14 @@ int disp_reslist(nt_window_tp wp, nt_2ch_model_tp modelp,
                                                                        cptr, wp->cols);
                                                if(num <= 0)
                                                        break;
-                                               resp->msg_header_line_num++;
+                                               res_datap->msg_header_line_num++;
                                                len -= num;
                                                cptr += num;
                                        }
                                }
                        }
-                       num = resp->msg_header_line_num;
-                       num += resp->msg_line_num;
+                       num = res_datap->msg_header_line_num;
+                       num += res_datap->msg_line_num;
                        if(ctxp->cur_res_offset + num < 0){
                                ctxp->cur_res_offset += num;
                                ctxp->cur_res--;
@@ -515,7 +607,7 @@ int disp_reslist(nt_window_tp wp, nt_2ch_model_tp modelp,
                break;
        case NT_KEY_PAGEDOWN:
        case KEY_NPAGE:
-               clistp = threadp->reslistp;
+               clistp = ctxp->res_disp_list;
                if(0 > ctxp->cur_res)
                        ctxp->cur_res = 0;
                for(i = 0; i < ctxp->res_num; i++){
@@ -528,16 +620,18 @@ int disp_reslist(nt_window_tp wp, nt_2ch_model_tp modelp,
                                
                ctxp->cur_res_offset += wp->lines;
                for( ; i < ctxp->res_num; i++){
-                       resp = (nt_res_tp)clistp->data;
-                       if(!resp->msg_line_linkp){
-                               parse_res_msg(resp, wp->cols-5);
+                       res_datap = (res_data_tp)clistp->data;
+                       if(!res_datap->msg_line_linkp){
+                               parse_res_msg(ctxp->res_disp_list, res_datap, wp->cols-5);
                        }
-                       if(resp->msg_header_line_num <= 0){
-                               if(-1 == swprintf(buf, sizeof(buf)-1, 
+                       if(res_datap->msg_header_line_num <= 0){
+                               /*if(-1 == swprintf(buf, sizeof(buf)-1, 
                                                L"%5d. %ls %ls %ls", 
-                                               resp->seq_no, resp->name,
-                                               resp->mail, resp->misc)){
-                                       resp->msg_header_line_num = 1;
+                                               res_datap->resp->seq_no, res_datap->resp->name,
+                                               res_datap->resp->mail, res_datap->resp->misc)){*/
+                               if(!set_res_header((ctx_reslist_tp)wp->data, 
+                                               res_datap, buf, sizeof(buf)/sizeof(buf[0]))){
+                                       res_datap->msg_header_line_num = 1;
                                }else{
                                        len = wcslen(buf);
                                        cptr = buf;
@@ -546,14 +640,14 @@ int disp_reslist(nt_window_tp wp, nt_2ch_model_tp modelp,
                                                                        cptr, wp->cols);
                                                if(num <= 0)
                                                        break;
-                                               resp->msg_header_line_num++;
+                                               res_datap->msg_header_line_num++;
                                                len -= num;
                                                cptr += num;
                                        }
                                }
                        }
-                       num = resp->msg_header_line_num;
-                       num += resp->msg_line_num + 1;
+                       num = res_datap->msg_header_line_num;
+                       num += res_datap->msg_line_num + 1;
                        if(num > ctxp->cur_res_offset){
                                break;
                        }
@@ -572,7 +666,7 @@ int disp_reslist(nt_window_tp wp, nt_2ch_model_tp modelp,
                ctxp->cur_res_offset = ctxp->max_cur_offset;
        }
 
-       clistp = threadp->reslistp;
+       clistp = ctxp->res_disp_list;
        res_offset = 0;
        rows = 0;
        for(i = 0; i < ctxp->res_num; i++){
@@ -584,12 +678,10 @@ int disp_reslist(nt_window_tp wp, nt_2ch_model_tp modelp,
                if(rows == wp->lines)
                        break;
 
-               resp = (nt_res_tp)clistp->data;
+               res_datap = (res_data_tp)clistp->data;
                
-               if(-1 == swprintf(buf, sizeof(buf)-1, 
-                               L"%5d. %ls %ls %ls", 
-                               resp->seq_no, resp->name,
-                               resp->mail, resp->misc)){
+               if(!set_res_header((ctx_reslist_tp)wp->data, 
+                               res_datap, buf, sizeof(buf)/sizeof(buf[0]))){
                        continue;
                }
                len = wcslen(buf);
@@ -636,13 +728,13 @@ int disp_reslist(nt_window_tp wp, nt_2ch_model_tp modelp,
                }
                if(rows == wp->lines)
                        break;
-               if(!resp->msg_line_linkp){
-                       parse_res_msg(resp, wp->cols-5);
+               if(!res_datap->msg_line_linkp){
+                       parse_res_msg(ctxp->res_disp_list, res_datap, wp->cols-5);
                }
-               if(0 == resp->msg_line_num)
+               if(0 == res_datap->msg_line_num)
                        continue;
 
-               link_curp = resp->msg_line_linkp;
+               link_curp = res_datap->msg_line_linkp;
                line_num = 0;
                do{
                        cptr = (wchar_t*)link_curp->data;
@@ -664,13 +756,26 @@ int disp_reslist(nt_window_tp wp, nt_2ch_model_tp modelp,
                        }
                        line_num++;
                        link_curp = link_curp->next;
-               }while(resp->msg_line_linkp != link_curp);
+               }while(res_datap->msg_line_linkp != link_curp);
 
                if(rows == wp->lines)
                        goto END_FOR;
                if(res_offset >= ctxp->cur_res_offset){
                        wmove(wp->wp, rows, 0);
                        nt_add_wnch(wp->wp, L' ', 0, wp->cols);
+                       if(res_datap->cited_num_list){
+                               cptr = nt_w_format_number_list(
+                                               res_datap->cited_num_list);
+                               if(cptr){
+                                       wmove(wp->wp, rows, 0);
+                                       nt_add_wnch(wp->wp, L' ', 0, 6);
+                                       nt_add_wstr(wp->wp, L"<<", 0);
+                                       nt_add_wnstr(wp->wp, cptr, 
+                                                       0, wp->cols - 8);
+                                       free(cptr);
+                               }
+                       }else{
+                       }
                        rows++;
                }else{
                        res_offset++;
@@ -682,23 +787,97 @@ END_FOR:
        return DISP_STATE_RESLIST; 
 }
 
-static int parse_cmd1(const char *param, int *statep)
+static int get_id_num(ctx_reslist_tp ctxp, const wchar_t *misc)
 {
-       assert(param);
+       int num;
+       num = 0;
+       res_data_tp datap;
+       nt_res_tp resp;
+       wchar_t *cptr;
+       nt_link_tp linkp, disp_list;
+       
+       assert(ctxp);
+       
+       cptr = wcsstr(misc, L"ID:");
+       if(!cptr)
+               return 0;
+       
+       cptr = nt_w_trim(cptr);
+       if(!cptr)
+               return 0;
+       
+       disp_list = ctxp->res_disp_list;
+       linkp = disp_list;
+       do{
+               datap = (res_data_tp)linkp->data;
+               resp = datap->resp;
+               if(wcsstr(resp->misc, cptr))
+                       num++;
+               linkp = linkp->next;
+       }while(linkp != disp_list);
+       
+       free(cptr);
+       return num;
+}
 
-       if(0 == strcmp(NT_COMMAND1_WRITE_MSG_1, param) ||
-               0 == strcmp(NT_COMMAND1_WRITE_MSG_2, param)){
+static BOOL set_res_header(ctx_reslist_tp ctxp, res_data_tp res_datap,
+                               wchar_t *buf, size_t buf_len)
+{
+       int id_num;
+       id_num = res_datap->id_num;
+       if(id_num < 0){
+               id_num = get_id_num(ctxp, res_datap->resp->misc);
+               res_datap->id_num = id_num;
+       }
+       if(id_num <= 1){
+               if(-1 == swprintf(buf, buf_len-1, 
+                               L"%5d. %ls %ls %ls", 
+                               res_datap->resp->seq_no, res_datap->resp->name,
+                               res_datap->resp->mail, res_datap->resp->misc)){
+                       return FALSE;
+               }
+       }else{
+               if(-1 == swprintf(buf, buf_len-1, 
+                               L"%5d. %ls %ls %ls(%d)", 
+                               res_datap->resp->seq_no, res_datap->resp->name,
+                               res_datap->resp->mail, res_datap->resp->misc, id_num)){
+                       return FALSE;
+               }
+       }
+       return TRUE;
+}
+
+static int parse_cmd1(const char *param, int *statep, const char **end)
+{
+       int len;
+       const char *start;
+       
+       assert(param);
+       
+       if(!nt_strtok(param, ' ', &start, end))
+               return NT_CMD_NONE;
+       
+       len = *end - start;
+       if(len <= 0)
+               return NT_CMD_NONE;
+       
+       if(0 == strncmp(NT_COMMAND1_WRITE_MSG_1, start,len) ||
+               0 == strncmp(NT_COMMAND1_WRITE_MSG_2, start,len)){
                *statep = DISP_STATE_EDITOR;
                return NT_CMD_WRITE;
-       }else if(0 == strcmp(NT_COMMAND1_JMP_NEW_1, param) ||
-               0 == strcmp(NT_COMMAND1_JMP_NEW_2, param)){
+       }else if(0 == strncmp(NT_COMMAND1_JMP_NEW_1,start,len) ||
+               0 == strncmp(NT_COMMAND1_JMP_NEW_2, start,len)){
                return NT_CMD_JMP_NEW;
+       }else if(0 == strncmp(NT_COMMAND1_TREE_1, start,len) ||
+               0 == strncmp(NT_COMMAND1_TREE_2, start,len)){
+               return NT_CMD_TREE;
+       }else if(0 == strncmp(NT_COMMAND1_ID_1, start,len) ||
+               0 == strncmp(NT_COMMAND1_ID_2, start,len)){
+               return NT_CMD_ID;
        }
        return NT_CMD_NONE;
 }
 
-
-
 static ctx_reslist_tp init_context(nt_2ch_model_tp modelp,
        void *usr_db_handle)
 {
@@ -715,8 +894,6 @@ static ctx_reslist_tp init_context(nt_2ch_model_tp modelp,
        if(!ctxp)
                return NULL;
 
-       if(threadp->reslistp)
-               ctxp->res_num = nt_link_num(threadp->reslistp);
        ctxp->cur_res = 0;
        ctxp->cur_res_offset = 0;
        ctxp->max_cur_res = -1;
@@ -725,7 +902,13 @@ static ctx_reslist_tp init_context(nt_2ch_model_tp modelp,
        ctxp->regex_init = FALSE;
        ctxp->sel_res_no = -1;
        ctxp->sel_res_line = -1;
+       ctxp->child_ctx_stackp = NULL;
 
+       if(!reslist_clone(threadp, ctxp)){
+               free_reslist_ctx(ctxp);
+               return NULL;
+       }
+       
        ctxp->prev_read_cnt = 
                nt_usr_db_update_read_count(usr_db_handle,
                                boardp->name, threadp->file_name,
@@ -735,20 +918,162 @@ static ctx_reslist_tp init_context(nt_2ch_model_tp modelp,
        if(ctxp->prev_read_cnt > 0){
                ctxp->cur_res = ctxp->prev_read_cnt;
        }
-
+       
        return ctxp;
 }
 
+static ctx_reslist_tp init_sub_context(ctx_reslist_tp ctxp, nt_link_tp num_listp)
+{
+       ctx_reslist_tp child_ctxp;
+       child_ctxp = (ctx_reslist_tp)calloc(1,sizeof(ctx_reslist_t));
+       if(!child_ctxp)
+               return NULL;
+       
+       child_ctxp->cur_res = 0;
+       child_ctxp->cur_res_offset = 0;
+       child_ctxp->max_cur_res = -1;
+       child_ctxp->max_cur_offset = -1;
+       child_ctxp->selected_num_stackp = nt_stack_alloc();
+       child_ctxp->regex_init = FALSE;
+       child_ctxp->sel_res_no = -1;
+       child_ctxp->sel_res_line = -1;
+       child_ctxp->child_ctx_stackp = NULL;
+       child_ctxp->prev_read_cnt = 0;
+
+       if(!reslist_copy(ctxp, child_ctxp, num_listp)){
+               nt_stack_free(child_ctxp->selected_num_stackp, NULL);
+               free(child_ctxp);
+               return NULL;
+       }
+       
+       if(!ctxp->child_ctx_stackp){
+               ctxp->child_ctx_stackp = nt_stack_alloc();
+               if(!ctxp->child_ctx_stackp){
+                       nt_stack_free(child_ctxp->selected_num_stackp, NULL);
+                       free(child_ctxp);
+                       return NULL;
+               }
+       }
+       if(!nt_stack_push(ctxp->child_ctx_stackp, child_ctxp)){
+               nt_stack_free(child_ctxp->selected_num_stackp, NULL);
+               free(child_ctxp);
+               return NULL;
+       }
+       return child_ctxp;
+}
+
+static BOOL reslist_clone(nt_thread_tp threadp, ctx_reslist_tp ctxp)
+{
+       nt_link_tp linkp, r_linkp;
+       nt_res_tp resp;
+       res_data_tp datap;
+       int num_res;
+       
+       assert(threadp);
+       assert(threadp->reslistp);
+       
+       num_res = 0;
+       linkp = threadp->reslistp;
+       do{
+               datap = (res_data_tp)calloc(1, sizeof(res_data_t));
+               if(datap){
+                       datap->id_num = -1;
+                       resp = (nt_res_t *)linkp->data;
+                       datap->resp = malloc(sizeof(nt_res_t));
+                       if(datap->resp){
+                               datap->resp->seq_no = resp->seq_no;
+                               datap->resp->name = nt_w_str_clone(resp->name);
+                               datap->resp->mail = nt_w_str_clone(resp->mail);
+                               datap->resp->misc = nt_w_str_clone(resp->misc);
+                               datap->resp->msg = nt_parse_res_msg(resp->msg,
+                                       &datap->cite_num_list);
+                               if(!datap->resp->name || !datap->resp->mail ||
+                                               !datap->resp->misc || !datap->resp->msg){
+                                       free(datap->resp);
+                                       free(datap);
+                               }else{
+                                       r_linkp = nt_link_add_data(ctxp->res_disp_list, datap);
+                                       if(!ctxp->res_disp_list)
+                                               ctxp->res_disp_list = r_linkp;
+                                       num_res++;
+                               }
+                       }
+               }
+               linkp = linkp->next;
+       }while(linkp != threadp->reslistp);
+       
+       ctxp->res_num = num_res;
+       return TRUE;
+}
+
+static BOOL reslist_copy(ctx_reslist_tp ctxp, ctx_reslist_tp copy_ctxp, nt_link_tp num_listp)
+{
+       nt_link_tp linkp, r_linkp;
+       nt_link_tp d_linkp;
+       nt_res_tp resp;
+       res_data_tp datap;
+       int num_res;
+       int seq_no;
+       
+       assert(ctxp && copy_ctxp && num_listp);
+       
+       num_res = 0;
+       linkp = num_listp;
+       do{
+               seq_no = linkp->n_data;
+               d_linkp = ctxp->res_disp_list;
+               do{
+                       datap = (res_data_tp)d_linkp->data;
+                       resp = datap->resp;
+                       if(seq_no == resp->seq_no){
+                               r_linkp = nt_link_add_data(copy_ctxp->res_disp_list, datap);
+                               if(r_linkp){
+                                       if(!copy_ctxp->res_disp_list)
+                                               copy_ctxp->res_disp_list = r_linkp;
+                                       num_res++;
+                               }
+                               break;
+                       }
+                       d_linkp = d_linkp->next;
+               }while(d_linkp != ctxp->res_disp_list);
+               linkp = linkp->next;
+       }while(linkp != num_listp);
+       copy_ctxp->res_num = num_res;
+       return TRUE;
+}
+
 void free_reslist_ctx(void *ptr)
 {
        ctx_reslist_tp ctxp;
+       nt_stack_tp stackp;
+       if(!ptr)
+               return;
+       ctxp = (ctx_reslist_tp)ptr;
+       nt_stack_free(ctxp->selected_num_stackp, &int_ptr_free);
+       if(ctxp->regex_init)
+               regfree(&(ctxp->regex));
+       if(ctxp->res_disp_list){
+               nt_all_link_free(ctxp->res_disp_list, res_msg_free);
+       }
+       stackp = ctxp->child_ctx_stackp;
+       if(stackp){
+               nt_stack_free(stackp, free_reslist_sub_ctx);
+       }
+       free(ptr);
+}
+static void free_reslist_sub_ctx(void *ptr)
+{
+       ctx_reslist_tp ctxp;
        if(!ptr)
                return;
-        ctxp = (ctx_reslist_tp)ptr;
-        nt_stack_free(ctxp->selected_num_stackp, &int_ptr_free);
-        if(ctxp->regex_init)
-               regfree(&(ctxp->regex));
-        free(ptr);
+       ctxp = (ctx_reslist_tp)ptr;
+       nt_stack_free(ctxp->selected_num_stackp, &int_ptr_free);
+       if(ctxp->regex_init)
+               regfree(&(ctxp->regex));
+       if(ctxp->res_disp_list){
+               nt_all_link_free(ctxp->res_disp_list, NULL);
+       }
+       free(ptr);
 }
 
 static void int_ptr_free(void *ptr)
@@ -756,12 +1081,204 @@ static void int_ptr_free(void *ptr)
        free(ptr);
 }
 
+static void res_msg_free(void *ptr)
+{
+       nt_link_tp curp, nextp;
+       res_data_tp res_datap;
+       nt_res_tp resp;
+       
+       assert(ptr);
+       
+       res_datap = (res_data_tp)ptr;
+       
+       resp = res_datap->resp;
+       
+       free(resp->name);
+       free(resp->mail);
+       free(resp->misc);
+       free(resp->msg);
+       free(resp);
+       
+       if(res_datap->cite_num_list)
+               nt_all_link_free(res_datap->cite_num_list, NULL);
+       if(res_datap->cited_num_list)
+               nt_all_link_free(res_datap->cited_num_list, NULL);
+       
+       if(res_datap->msg_line_linkp){
+               curp = res_datap->msg_line_linkp->next;
+               while(curp != res_datap->msg_line_linkp){
+                       nextp = curp->next;
+                       /* We must not free the data pointer
+                        * except the first one
+                        * because they're alocated as a same block.
+                        * This is wrong --> free(curp->data);
+                        */
+                       free(curp);
+                       curp = nextp;
+               }
+               free(curp->data);
+               free(curp);
+               res_datap->msg_line_linkp = NULL;
+       }
+       free(res_datap);
+}
+
+               
+
+static nt_link_tp get_cited_num_list(nt_link_tp res_listp, int seq_no)
+{
+       nt_link_tp linkp, wrkp, wrk2p;
+       nt_link_tp num_listp;
+       res_data_tp res_datap;
+       
+       num_listp = NULL;
+       
+       linkp = res_listp;
+       do{
+               res_datap = (res_data_tp)linkp->data;
+               if(res_datap->cite_num_list){
+                       wrkp = res_datap->cite_num_list;
+                       do{
+                               if(wrkp->n_data == seq_no){
+                                       wrk2p = nt_link_add_n_data(
+                                                       num_listp, res_datap->resp->seq_no);
+                                       if(wrk2p && !num_listp)
+                                               num_listp = wrk2p;
+                                       break;
+                               }
+                               wrkp = wrkp->next;
+                       }while(wrkp != res_datap->cite_num_list);
+               }
+               linkp = linkp->next;
+       }while(linkp != res_listp);
+       if(num_listp)
+               nt_link_n_sort(&num_listp, nt_comp_int);
+       return num_listp;
+}
+
+static int parse_res_msg(nt_link_tp disp_res_list, 
+                               res_data_tp res_datap, size_t colmns)
+{
+       int i, len, start, lines;
+       wchar_t ch;
+       wchar_t *buf, *cptr, *srcp, *wrk_buf;
+       int offset;
+       nt_link_tp linkp;
+       int consume_colmns;
+       int buf_idx, buf_size;
+       const int delta = 64;
+
+       assert(res_datap);
+       assert(res_datap->resp);
+       assert(res_datap->resp->msg);
+
+       //res_msg_free(res_datap);
+       res_datap->msg_line_num = 0;
+
+       len = wcslen(res_datap->resp->msg);
+       if(len == 0)
+               return 0;
+       buf_size = len + delta;
+
+       if(len == 0)
+               return 0;
+       buf = malloc(sizeof(wchar_t) * (buf_size));
+       if(!buf)
+               return 0;
+       buf_idx = 0;
+
+       srcp = res_datap->resp->msg;
+
+       lines = 0;
+       start = 0;
+       consume_colmns = 0;
+       for(i = 0; i < len; i++){
+               ch = srcp[i];
+               switch(ch){
+               case L'\n':
+                       cptr = buf + start;
+                       buf[buf_idx] = L'\0';
+                       buf_idx++;
+                       linkp = nt_link_add_data(
+                                       res_datap->msg_line_linkp, cptr);
+                       if(!linkp)
+                               goto END_FOR;
+                       if(res_datap->msg_line_linkp == NULL)
+                               res_datap->msg_line_linkp = linkp;
+
+                       consume_colmns = 0;
+                       lines++;
+                       start = buf_idx;
+                       break;
+               default:
+                       if(ch <= 128 || (ch >= 0xff66 && ch <= 0xff9d))
+                               offset = 1;
+                       else
+                               offset = 2;
+
+                       if(consume_colmns + offset > colmns){
+                               cptr = buf + start;
+                               buf[buf_idx] = L'\0';
+                               linkp = nt_link_add_data(
+                                               res_datap->msg_line_linkp, cptr);
+                               if(!linkp)
+                                       goto END_FOR;
+                               if(res_datap->msg_line_linkp == NULL)
+                                       res_datap->msg_line_linkp = linkp;
+                                       
+                               lines++;
+                               buf_idx++;
+                               start = buf_idx;
+                               consume_colmns = 0;
+                               i--;
+                       }else{
+                               consume_colmns += offset;
+                               buf[buf_idx] = ch;
+                               buf_idx++;
+                       }
+                       break;
+               }/* end switch */
+               if(buf_idx >= (buf_size-1)){
+                       wrk_buf = nt_w_str_resize(buf, buf_size, (buf_size + delta));
+                       if(!wrk_buf){
+                               nt_all_link_free(
+                                       res_datap->msg_line_linkp, NULL);
+                               free(buf);
+                               res_datap->msg_line_linkp = NULL;
+                               return 0;
+                       }
+                       buf = wrk_buf;
+                       buf_size += delta;
+               }
+       } /* end for */
+END_FOR:
+       if(consume_colmns > 0){
+               cptr = buf + start;
+               buf[buf_idx] = L'\0';
+               linkp = nt_link_add_data(
+                               res_datap->msg_line_linkp, cptr);
+               if(linkp){
+                       if(res_datap->msg_line_linkp == NULL)
+                               res_datap->msg_line_linkp = linkp;
+                       lines++;
+               }
+       }
+       res_datap->msg_line_num = lines;
+       
+       if(!res_datap->cited_num_list){
+               res_datap->cited_num_list = 
+                       get_cited_num_list(disp_res_list, 
+                               res_datap->resp->seq_no);
+       }
+       return lines;
+}
 
 static BOOL search_line_asc(regex_t *regexp, nt_link_tp reslistp, 
                        int *sel_res_no, int *sel_res_line, int column)
 {
        nt_link_tp clistp, listp;
-       nt_res_tp resp;
+       //nt_res_tp resp;
+       res_data_tp res_datap;
        int cur, line, res_no, res_line;
        wchar_t *cptr;
        char buf[256];
@@ -784,10 +1301,11 @@ static BOOL search_line_asc(regex_t *regexp, nt_link_tp reslistp,
        clistp = reslistp;
        do{
                if(cur >= res_no){
-                       resp = (nt_res_tp)clistp->data;
-                       if(!resp->msg_line_linkp)
-                               parse_res_msg(resp, column);
-                       listp = resp->msg_line_linkp;
+                       res_datap = (res_data_tp)clistp->data;
+                       //resp = res_datap->resp;
+                       if(!res_datap->msg_line_linkp)
+                               parse_res_msg(reslistp, res_datap, column);
+                       listp = res_datap->msg_line_linkp;
                        line = 0;
                        do{
                                if(line >= res_line){
@@ -803,7 +1321,7 @@ static BOOL search_line_asc(regex_t *regexp, nt_link_tp reslistp,
                                }
                                line++;
                                listp = listp->next;
-                       }while(listp != resp->msg_line_linkp);
+                       }while(listp != res_datap->msg_line_linkp);
                        res_line = 0;
                }
                cur++;
@@ -816,10 +1334,10 @@ static BOOL search_line_asc(regex_t *regexp, nt_link_tp reslistp,
                if(cur >= res_no)
                        break;
 
-               resp = (nt_res_tp)clistp->data;
-               if(!resp->msg_line_linkp)
-                       parse_res_msg(resp, column);
-               listp = resp->msg_line_linkp;
+               res_datap = (res_data_tp)clistp->data;
+               if(!res_datap->msg_line_linkp)
+                       parse_res_msg(reslistp, res_datap, column);
+               listp = res_datap->msg_line_linkp;
                line = 0;
                do{
                        if(line >= res_line){
@@ -835,7 +1353,7 @@ static BOOL search_line_asc(regex_t *regexp, nt_link_tp reslistp,
                        }
                        line++;
                        listp = listp->next;
-               }while(listp != resp->msg_line_linkp);
+               }while(listp != res_datap->msg_line_linkp);
                res_line = 0;
                cur++;
                clistp = clistp->next;
@@ -848,7 +1366,8 @@ static BOOL search_line_desc(regex_t *regexp, ctx_reslist_tp ctxp,
                        int *sel_res_no, int *sel_res_line, int column)
 {
        nt_link_tp clistp, listp;
-       nt_res_tp resp;
+       //nt_res_tp resp;
+       res_data_tp res_datap;
        int cur, line, res_no, res_line;
        wchar_t *cptr;
        char buf[256];
@@ -873,11 +1392,12 @@ static BOOL search_line_desc(regex_t *regexp, ctx_reslist_tp ctxp,
        clistp = reslistp->prev;
        do{
                if(cur <= res_no){
-                       resp = (nt_res_tp)clistp->data;
-                       if(!resp->msg_line_linkp)
-                               parse_res_msg(resp, column);
-                       listp = resp->msg_line_linkp->prev;
-                       line = resp->msg_line_num - 1;
+                       res_datap = (res_data_tp)clistp->data;
+                       //resp = res_datap->resp;
+                       if(!res_datap->msg_line_linkp)
+                               parse_res_msg(reslistp, res_datap, column);
+                       listp = res_datap->msg_line_linkp->prev;
+                       line = res_datap->msg_line_num - 1;
                        do{
                                if(line <= res_line){
                                        cptr = (wchar_t*)listp->data;
@@ -892,8 +1412,8 @@ static BOOL search_line_desc(regex_t *regexp, ctx_reslist_tp ctxp,
                                }
                                line--;
                                listp = listp->prev;
-                       }while(listp != resp->msg_line_linkp->prev);
-                       res_line = resp->msg_line_num - 1;
+                       }while(listp != res_datap->msg_line_linkp->prev);
+                       res_line = res_datap->msg_line_num - 1;
                }
                cur--;
                clistp = clistp->prev;
@@ -905,11 +1425,12 @@ static BOOL search_line_desc(regex_t *regexp, ctx_reslist_tp ctxp,
                if(cur <= res_no)
                        break;
 
-               resp = (nt_res_tp)clistp->data;
-               if(!resp->msg_line_linkp)
-                       parse_res_msg(resp, column);
-               listp = resp->msg_line_linkp->prev;
-               line = resp->msg_line_num - 1;
+               res_datap = (res_data_tp)clistp->data;
+               //resp = (nt_res_tp)clistp->data;
+               if(!res_datap->msg_line_linkp)
+                       parse_res_msg(reslistp, res_datap, column);
+               listp = res_datap->msg_line_linkp->prev;
+               line = res_datap->msg_line_num - 1;
                do{
                        if(line >= res_line){
                                cptr = (wchar_t*)listp->data;
@@ -924,10 +1445,166 @@ static BOOL search_line_desc(regex_t *regexp, ctx_reslist_tp ctxp,
                        }
                        line--;
                        listp = listp->prev;
-               }while(listp != resp->msg_line_linkp->prev);
-               res_line = resp->msg_line_num - 1;
+               }while(listp != res_datap->msg_line_linkp->prev);
+               res_line = res_datap->msg_line_num - 1;
                cur--;
                clistp = clistp->prev;
        }while(clistp != reslistp->prev);
        return FALSE;
 }
+
+
+static nt_link_tp parse_id_list(ctx_reslist_tp ctxp, const char *param)
+{
+       nt_link_tp  linkp, disp_list;
+       nt_link_tp wrkp, num_linkp;
+       char buf[64];
+       wchar_t wc[64];
+       wchar_t *cptr;
+       int len;
+       const char *start, *end;
+       res_data_tp res_datap;
+       nt_res_tp resp;
+       
+       assert(ctxp);
+       assert(ctxp->res_disp_list);
+       
+       if(!nt_strtok(param, ' ', &start, &end))
+               return NULL;
+       len = end - start;
+       if(len <= 0)
+               return NULL;
+       
+       strcpy(buf,"ID:");
+       strncat(buf, start, len);
+       
+       if((size_t)-1 == mbstowcs(wc, buf, sizeof(wc)-1))
+               return NULL;
+               
+       num_linkp = NULL;
+       disp_list = ctxp->res_disp_list;
+       linkp = disp_list;
+       do{
+               res_datap = (res_data_tp)linkp->data;
+               resp = res_datap->resp;
+               cptr = wcsstr(resp->misc, wc);
+               if(cptr){
+                       wrkp = nt_link_add_n_data(num_linkp, resp->seq_no);
+                       if(!num_linkp)
+                               num_linkp = wrkp;
+               }
+               linkp = linkp->next;
+       }while(linkp != disp_list);
+       
+       return num_linkp;
+}
+
+
+static nt_link_tp parse_tree_list(ctx_reslist_tp ctxp, const char *param)
+{
+       nt_link_tp  linkp, disp_list;
+       nt_link_tp wrkp, num_linkp;
+       int len;
+       const char *start, *end;
+       res_data_tp res_datap;
+       nt_res_tp resp;
+       int num;
+       
+       assert(ctxp);
+       assert(ctxp->res_disp_list);
+       
+       if(!nt_strtok(param, ' ', &start, &end))
+               return NULL;
+       len = end - start;
+       if(len <= 0)
+               return NULL;
+       
+       num = atoi(start);
+       if(num == 0)
+               return NULL;
+       num_linkp = nt_link_add_n_data(NULL, num);
+       if(!num_linkp)
+               return NULL;
+       
+       disp_list = ctxp->res_disp_list;
+       linkp = disp_list;
+       do{
+               res_datap = (res_data_tp)linkp->data;
+               resp = res_datap->resp;
+               if(num == resp->seq_no){
+                       if(res_datap->cite_num_list){
+                               wrkp = res_datap->cite_num_list;
+                               do{
+                                       if(wrkp->n_data < num)
+                                               search_up_tree(wrkp->n_data, disp_list, &num_linkp);
+                                       wrkp = wrkp->next;
+                               }while(wrkp != res_datap->cite_num_list);
+                       }
+                       if(res_datap->cited_num_list){
+                               wrkp = res_datap->cited_num_list;
+                               do{
+                                       if(wrkp->n_data > num)
+                                               search_down_tree(wrkp->n_data, disp_list, &num_linkp);
+                                       wrkp = wrkp->next;
+                               }while(wrkp != res_datap->cited_num_list);
+                       }
+                       break;
+               }
+               linkp = linkp->next;
+       }while(linkp != disp_list);
+       if(num_linkp)
+               nt_link_n_sort(&num_linkp, nt_comp_int);
+       return num_linkp;
+}
+static void search_up_tree(int seq_no, nt_link_tp disp_list, nt_link_tp *num_linkp)
+{
+       nt_link_tp  linkp, wrkp;
+       nt_link_add_n_data(*num_linkp, seq_no);
+       res_data_tp res_datap;
+       nt_res_tp resp;
+       
+       linkp = disp_list;
+       do{
+               res_datap = (res_data_tp)linkp->data;
+               resp = res_datap->resp;
+               if(seq_no == resp->seq_no){
+                       if(res_datap->cite_num_list){
+                               wrkp = res_datap->cite_num_list;
+                               do{
+                                       if(wrkp->n_data < seq_no)
+                                               search_up_tree(wrkp->n_data, disp_list, num_linkp);
+                                       wrkp = wrkp->next;
+                               }while(wrkp != res_datap->cite_num_list);
+                       }
+                       break;
+               }
+               linkp = linkp->next;
+       }while(linkp != disp_list);
+}
+
+static void search_down_tree(int seq_no, nt_link_tp disp_list, nt_link_tp *num_linkp)
+{
+       nt_link_tp  linkp, wrkp;
+       nt_link_add_n_data(*num_linkp, seq_no);
+       res_data_tp res_datap;
+       nt_res_tp resp;
+       
+       linkp = disp_list;
+       do{
+               res_datap = (res_data_tp)linkp->data;
+               resp = res_datap->resp;
+               if(seq_no == resp->seq_no){
+                       if(res_datap->cited_num_list){
+                               wrkp = res_datap->cited_num_list;
+                               do{
+                                       if(wrkp->n_data > seq_no)
+                                               search_down_tree(wrkp->n_data, disp_list, num_linkp);
+                                       wrkp = wrkp->next;
+                               }while(wrkp != res_datap->cited_num_list);
+                       }
+                       break;
+               }
+               linkp = linkp->next;
+       }while(linkp != disp_list);
+}
+
index b368671..9e36806 100644 (file)
@@ -220,7 +220,7 @@ int disp_threadlist(nt_window_tp wp, nt_2ch_model_tp modelp,
                                                break;
                                        return DISP_STATE_REFRESH;
                                }
-                               linkp = parse_number_list(end, NULL);
+                               linkp = nt_parse_number_list(end, NULL);
                                if(!linkp)
                                        break;
                                clistp = linkp;
index 3196fc7..4628bfa 100644 (file)
@@ -20,7 +20,6 @@
 #include <string.h>
 #include <stdio.h>
 #include <assert.h>
-#include <math.h>
 
 #include "utils/nt_std_t.h"
 #include "utils/base64.h"
index 4cd8454..fdd89e7 100644 (file)
@@ -40,6 +40,21 @@ nt_link_tp nt_link_insert_before(nt_link_tp top_linkp,
        return top_linkp;
 }
 
+nt_link_tp nt_link_add_last(nt_link_tp top_linkp, nt_link_tp src)
+{
+       nt_link_tp old_last;
+       
+       if(!top_linkp)
+               return src;
+       
+       old_last = top_linkp->prev;
+       old_last->next = src;
+       top_linkp->prev = src->prev;
+       src->prev->next = top_linkp;
+       src->prev = old_last;
+       return top_linkp;
+}
+
 void nt_link_sort(nt_link_tp *top_linkp, nt_compare_fn comp_func)
 {
        nt_link_tp cur_linkp, next_linkp, work_linkp;
@@ -376,6 +391,34 @@ void* nt_stack_pop(nt_stack_tp stackp)
        return NULL;
 }
 
+void* nt_stack_peek(nt_stack_tp stackp)
+{
+       int cursor;
+       nt_link_tp linkp;
+       assert(stackp);
+       if(!stackp->linkp)
+               return NULL;
+       linkp = stackp->linkp;
+       cursor = 0;
+       do{
+               if(cursor == stackp->cursor){
+                       return linkp->data;
+               }
+               linkp = linkp->next;
+               cursor++;
+       }while(linkp != stackp->linkp);
+       return NULL;
+}
+int nt_stack_get_position(nt_stack_tp stackp)
+{
+       return stackp->cursor;
+}
+
+BOOL nt_stack_is_empty(nt_stack_tp stackp)
+{
+       return (!stackp->linkp);
+}
+
 void* nt_stack_cursor_next(nt_stack_tp stackp)
 {
        int cursor;
index 2dc3330..ff4ff70 100644 (file)
 #include "utils/nt_std_t.h"
 #include "utils/text.h"
 
+
+wchar_t* nt_w_str_resize(wchar_t *old_src, size_t old_size, size_t new_size)
+{
+       wchar_t *wrk_buf;
+       
+       assert(old_size < new_size && new_size > 0);
+       
+       wrk_buf = malloc(sizeof(wchar_t) * (new_size));
+       if(!wrk_buf){
+               return NULL;
+       }
+       
+       if(!old_src){
+               wrk_buf[0] = L'\0';
+               return wrk_buf;
+       }
+       wmemcpy(wrk_buf, old_src, old_size);
+       wrk_buf[old_size] = L'\0';
+       free(old_src);
+       return wrk_buf;
+}
+
 BOOL nt_w_str_move(wchar_t *buf, size_t buf_len, 
                                        int move_index, int offset)
 {
@@ -330,7 +352,7 @@ BOOL nt_strtok(const char *str, char delim,
                        if(state == 0){
                                *start = str + i + 1;
                        }else if(state == 1){
-                               *end = str + i + 1;
+                               *end = str + i;
                                return TRUE;
                        }
                }else{