${OBJ_DIR}/ui/disp_history.o \
${OBJ_DIR}/ui/disp_win.o \
${OBJ_DIR}/ui/disp_editor.o \
+ ${OBJ_DIR}/ui/disp_alert.o \
${OBJ_DIR}/ui/disp_html_result.o \
${OBJ_DIR}/ui/disp_string.o
valgrind --leak-check=yes --track-origins=yes -v ./${TARGET}
memtest2 :
- valgrind --tool=helgrind --leak-check=yes --track-origins=yes -v ./${TARGET}
+ valgrind --tool=helgrind -v ./${TARGET}
${TARGET} : ${OBJS}
${CC} ${CFLAGS} -o $@ ${OBJS} ${LIBS}
@ ${SHELL} prepare_proj.sh
${CC} ${CFLAGS} ${INCLUDES} -c -o $@ $<
+$(OBJ_DIR)/ui/disp_alert.o : ${SRC_DIR}/ui/disp_alert.c ${INC_FILES}
+ @ ${SHELL} prepare_proj.sh
+ ${CC} ${CFLAGS} ${INCLUDES} -c -o $@ $<
+
$(OBJ_DIR)/ui/disp_html_result.o : ${SRC_DIR}/ui/disp_html_result.c ${INC_FILES}
@ ${SHELL} prepare_proj.sh
${CC} ${CFLAGS} ${INCLUDES} -c -o $@ $<
${OBJ_DIR}/ui/disp_history.o \
${OBJ_DIR}/ui/disp_win.o \
${OBJ_DIR}/ui/disp_editor.o \
+ ${OBJ_DIR}/ui/disp_alert.o \
${OBJ_DIR}/ui/disp_html_result.o \
${OBJ_DIR}/ui/disp_string.o
valgrind --leak-check=yes --track-origins=yes -v ./${TARGET}
memtest2 :
- valgrind --tool=helgrind --leak-check=yes --track-origins=yes -v ./${TARGET}
+ valgrind --tool=helgrind -v ./${TARGET}
${TARGET} : ${OBJS}
${CC} ${CFLAGS} -o $@ ${OBJS} ${LIBS}
@ ${SHELL} prepare_proj.sh
${CC} ${CFLAGS} ${INCLUDES} -c -o $@ $<
+$(OBJ_DIR)/ui/disp_alert.o : ${SRC_DIR}/ui/disp_alert.c ${INC_FILES}
+ @ ${SHELL} prepare_proj.sh
+ ${CC} ${CFLAGS} ${INCLUDES} -c -o $@ $<
+
$(OBJ_DIR)/ui/disp_html_result.o : ${SRC_DIR}/ui/disp_html_result.c ${INC_FILES}
@ ${SHELL} prepare_proj.sh
${CC} ${CFLAGS} ${INCLUDES} -c -o $@ $<
- ntch version 1.0.2.7
+ ntch version 1.0.2.8
This file is part of ntch.
#define PACKAGE_NAME "ntch"
/* Define to the full name and version of this package. */
-#define PACKAGE_STRING "ntch 1.0.2.7"
+#define PACKAGE_STRING "ntch 1.0.2.8"
/* 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.2.7"
+#define PACKAGE_VERSION "1.0.2.8"
/* Define to 1 if you have the ANSI C header files. */
#define STDC_HEADERS 1
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.69 for ntch 1.0.2.7.
+# Generated by GNU Autoconf 2.69 for ntch 1.0.2.8.
#
# Report bugs to <akohta001@gmail.com>.
#
# Identity of this package.
PACKAGE_NAME='ntch'
PACKAGE_TARNAME='ntch'
-PACKAGE_VERSION='1.0.2.7'
-PACKAGE_STRING='ntch 1.0.2.7'
+PACKAGE_VERSION='1.0.2.8'
+PACKAGE_STRING='ntch 1.0.2.8'
PACKAGE_BUGREPORT='akohta001@gmail.com'
PACKAGE_URL='https://sourceforge.jp/projects/ntch/'
# 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.2.7 to adapt to many kinds of systems.
+\`configure' configures ntch 1.0.2.8 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
if test -n "$ac_init_help"; then
case $ac_init_help in
- short | recursive ) echo "Configuration of ntch 1.0.2.7:";;
+ short | recursive ) echo "Configuration of ntch 1.0.2.8:";;
esac
cat <<\_ACEOF
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
-ntch configure 1.0.2.7
+ntch configure 1.0.2.8
generated by GNU Autoconf 2.69
Copyright (C) 2012 Free Software Foundation, Inc.
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.2.7, which was
+It was created by ntch $as_me 1.0.2.8, which was
generated by GNU Autoconf 2.69. Invocation command line was
$ $0 $@
# 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.2.7, which was
+This file was extended by ntch $as_me 1.0.2.8, which was
generated by GNU Autoconf 2.69. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
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.2.7
+ntch config.status 1.0.2.8
configured by $0, generated by GNU Autoconf 2.69,
with options \\"\$ac_cs_config\\"
# Process this file with autoconf to produce a configure script.
AC_PREREQ([2.69])
-AC_INIT([ntch], [1.0.2.7], [akohta001@gmail.com],[ntch],[https://sourceforge.jp/projects/ntch/])
+AC_INIT([ntch], [1.0.2.8], [akohta001@gmail.com],[ntch],[https://sourceforge.jp/projects/ntch/])
AC_CONFIG_SRCDIR([src/main.c])
AC_CONFIG_HEADERS([config.h])
- ntch version 1.0.2.7
+ ntch version 1.0.2.8
This file is part of ntch.
例
:ngwd \\/[a-z]/ 左は正規表現を使わずに文字列として
/[a-z]/ にマッチします。
+ :timer [ NNNN | NNNm | NNNs ] 指定時間後に通知ダイアログを表示します
+ NNNN 表示するまでの時間をミリ秒で指定します
+ 例: :timer 120000 (2分をミリ秒で指定)
+ NNNm 時間を分単位で指定します
+ 例: :timer 2m (2分を分単位で指定)
+ NNNs 時間を秒単位で指定します
+ 例: :timer 120s (2分を秒単位で指定)
+ :link :l [2ch アドレス] 2chのリンクを指定して開きます(前スレなどの表示に使います)
+ 例: :link http://pc11.2ch.net/test/read.cgi/linux/1118024349/
+ ※ 何らかの理由で開けないこともあります
お気に入り一覧
d 選択項目をお気に入りから削除
*/
include_once "user.php";
include_once "database.php";
+include_once "http_util.php";
$ERROR_MSG;
return $user;
}
+function chk_file_name(&$val){
+ if(!isset($val)){
+ return false;
+ }
+ if(0 == strlen($val)){
+ return false;
+ }
+ if(FALSE === inspect_file_name($val)){
+ return false;
+ }
+ return true;
+}
+
function chk_param(&$val){
if(!isset($val)){
return false;
if(0 == strlen($val)){
return false;
}
- if(!get_magic_quotes_gpc()){
- $val = addslashes($val);
+ if(FALSE === inspect_base64_param($val)){
+ return false;
}
return true;
}
date: 2013-apr-13th
License: GPLv3
*/
-$needle_64encode = array("=","+","/");
-$needle_urlencode = array("%3D","%2B","%2f");
+$needle_64encode = array("=","+","/","=","+","/");
+$needle_urlencode = array("%3D","%2B","%2F","%3d","%2b","%2f");
+$base64_param_pattern = "/^([a-zA-Z0-9]|\%2B|\%2F|\+|\/)+(\%3D|=){0,2}$/i";
+$file_name_pattern = "/^(\w)+((\.)?[a-zA-Z0-9]*)*$/";
function replace_64symbol2urlencode($source){
global $needle_64encode;
$needle_64encode, $source);
return $result;
}
+
+function inspect_base64_param($param){
+ global $base64_param_pattern;
+ if(preg_match($base64_param_pattern, $param)){
+ return TRUE;
+ }else{
+ return FALSE;
+ }
+}
+function inspect_file_name($param){
+ global $file_name_pattern;
+ if(preg_match($file_name_pattern, $param)){
+ return TRUE;
+ }else{
+ return FALSE;
+ }
+}
?>
\ No newline at end of file
//--- parameter check start ---
if(!chk_param($board_name) || !chk_param($dat_name) ||
- !chk_param($res_number) || !chk_param($record_type)){
+ !chk_param($res_number)){
echo ERROR303;
exit;
}
exit;
}
-if(!chk_param($file_name) || !$num || FALSE == is_numeric($num)){
+if(!chk_file_name($file_name) || !$num || FALSE == is_numeric($num)){
echo ERROR303;
exit;
}
exit;
}
-if(!chk_param($file_name) || !$num || FALSE == is_numeric($num)){
+if(!chk_file_name($file_name) || !$num || FALSE == is_numeric($num)){
echo ERROR303;
exit;
}
exit;
}
-if(!chk_param($file_name) || !$data){
+if(!chk_file_name($file_name) || !$data){
echo ERROR303;
exit;
}
echo SUCCESS100;
-echo "\n".$file_path;
+
?>
-/* Copyright 2013 Akira Ohta (akohta001@gmail.com)
+/* Copyright 2013,2014 Akira Ohta (akohta001@gmail.com)
This file is part of ntch.
The ntch is free software: you can redistribute it and/or modify
nt_searched_thread_handle h_searched_thread, const wchar_t** errorpp)
{
const wchar_t *board_name, *dat_name, *title;
+ wchar_t *cptr;
nt_category_handle h_category;
nt_board_handle h_board;
nt_thread_handle h_thread;
assert(h_sel_itemp);
+ h_thread = NULL;
+
h_sel_item = nt_2ch_selected_item_alloc();
if(!h_sel_item){
return FALSE;
h_thread = nt_get_thread_by_dat_name(h_board, dat_name);
if(!h_thread){
if(!title)
- title = L"Dummy";
- h_thread = nt_thread_dummy_alloc(title, dat_name, 0);
+ h_thread = nt_thread_dummy_alloc(L"Dummy", dat_name, 0);
+ else
+ h_thread = nt_thread_dummy_alloc(title, dat_name, 0);
if(!h_thread){
*errorpp = L"スレッド情報が見つかりませんでした";
goto ERROR_TRAP;
}
nt_set_selected_thread(h_sel_item, h_thread);
- nt_thread_release_ref(h_thread);
if(!nt_read_thread(h_sel_item)){
*errorpp = L"スレッドが開けませんでした";
goto ERROR_TRAP;
}
+ if(!title){
+ cptr = nt_read_thread_title(h_board, dat_name);
+ if(cptr){
+ nt_thread_set_title(h_thread, cptr);
+ free(cptr);
+ }
+ }
+ nt_thread_release_ref(h_thread);
nt_board_release_ref(h_board);
nt_category_release_ref(h_category);
*h_sel_itemp = h_sel_item;
return TRUE;
ERROR_TRAP:
+ if(h_thread)
+ nt_thread_release_ref(h_thread);
nt_board_release_ref(h_board);
nt_category_release_ref(h_category);
nt_2ch_selected_item_release_ref(h_sel_item);
-/* Copyright 2013 Akira Ohta (akohta001@gmail.com)
+/* Copyright 2013,2014 Akira Ohta (akohta001@gmail.com)
This file is part of ntch.
The ntch is free software: you can redistribute it and/or modify
return threadp->name;
}
+const wchar_t* nt_thread_set_title(
+ nt_thread_handle h_thread, const wchar_t* title)
+{
+ nt_thread_tp threadp;
+ assert(h_thread);
+ assert(h_thread->chk_sum == NT_2CH_THREAD_CHK_SUM);
+ assert(title);
+ threadp = (nt_thread_tp)h_thread;
+
+ if(threadp->name)
+ free(threadp->name);
+ threadp->name = nt_w_str_clone(title);
+ return threadp->name;
+}
+
const wchar_t* nt_thread_get_dat_name(nt_thread_handle h_thread)
{
nt_thread_tp threadp;
len = strlen(source);
state = 0;
prev = 0;
+ start = source;
for(i = 0; i < len; i++){
switch(source[i]){
-/* Copyright 2013 Akira Ohta (akohta001@gmail.com)
+/* Copyright 2013,2014 Akira Ohta (akohta001@gmail.com)
This file is part of ntch.
The ntch is free software: you can redistribute it and/or modify
return &sthreadp->handle;
}
+nt_searched_thread_handle nt_searched_thread_alloc2(
+ nt_2ch_model_handle h_model,
+ const char *url)
+{
+ wchar_t *board_name;
+ wchar_t *dat_name;
+ nt_searched_thread_tp sthreadp;
+ char *cptr, *cptr1;
+ nt_board_handle h_board;
+ wchar_t wbuf[128];
+ char buf[128];
+ int len;
+
+ cptr = strstr(url, "test/read.cgi/");
+ if(!cptr)
+ return NULL;
+ cptr += strlen("test/read.cgi/");
+
+ cptr1 = strchr(cptr, '/');
+ if(!cptr1)
+ return NULL;
+ len = cptr1 - cptr;
+ memcpy(buf, cptr, len);
+ buf[len] = '\0';
+
+ if((size_t)-1 == mbstowcs(wbuf, buf, sizeof(wbuf)/sizeof(wchar_t))){
+ return NULL;
+ }
+
+ h_board = nt_get_board_by_address_match(h_model, wbuf);
+ if(!h_board){
+ return NULL;
+ }
+ board_name = nt_w_str_clone(nt_board_get_name(h_board));
+ nt_board_release_ref(h_board);
+ if(!board_name){
+ return NULL;
+ }
+ cptr1++;
+ cptr = strchr(cptr1, '/');
+ if(!cptr){
+ free(board_name);
+ return NULL;
+ }
+ len = cptr - cptr1;
+ memcpy(buf, cptr1, len);
+ strcpy(buf+len, ".dat");
+ buf[len+4] = '\0';
+
+ if((size_t)-1 == mbstowcs(wbuf, buf, sizeof(wbuf)/sizeof(wchar_t))){
+ free(board_name);
+ return NULL;
+ }
+ dat_name = nt_w_str_clone(wbuf);
+ if(!dat_name){
+ free(board_name);
+ return NULL;
+ }
+
+ sthreadp = malloc(sizeof(nt_searched_thread_t));
+ if(!sthreadp){
+ free(board_name);
+ free(dat_name);
+ return NULL;
+ }
+
+ sthreadp->board_name = board_name;
+ sthreadp->dat_name = dat_name;
+ sthreadp->title = NULL;
+ sthreadp->handle.chk_sum = NT_SEARCHED_THREAD_CHK_SUM;
+ sthreadp->ref_count = 1;
+ return &sthreadp->handle;
+}
+
int nt_searched_thread_add_ref(nt_searched_thread_handle h_searched_thread)
{
nt_searched_thread_tp sthreadp;
nt_usr_db_handle db_handle, int depth)
{
char *url, *post_data, *line, *cptr;
- char buf1[1024*16];
+ char *buf1;
char buf2[256];
char buf3[256];
wchar_t board_nm_buf[128];
strcat(post_data, "&last_query=");
strcat(post_data, last_query);
}
-
- if(!nt_http_post(url, post_data,
- buf1, sizeof(buf1), NULL, NULL, NULL, NULL)){
+ buf1 = NULL;
+ if(!nt_http_post3(url, post_data,
+ &buf1, NULL, NULL, NULL, NULL)){
nt_crypt_release_ref(h_crypt);
if(last_query)
free(last_query);
free(post_data);
free(url);
+ free(buf1);
return FALSE;
}
if(last_query)
if(result_code == 301 && depth == 0){
if(!nt_cloud_chk_user(handle)){
nt_crypt_release_ref(h_crypt);
+ free(buf1);
return FALSE;
}
return nt_cloud_query_attributes(handle,
db_handle, ++depth);
}else if(result_code != 100){
nt_crypt_release_ref(h_crypt);
+ free(buf1);
return FALSE;
}
linkp = nt_split_line(buf1);
if(!linkp){
nt_crypt_release_ref(h_crypt);
+ free(buf1);
return FALSE;
}
/* There is little data. */
if(nt_link_num(linkp) < 4){
nt_crypt_release_ref(h_crypt);
+ free(buf1);
return TRUE;
}
wrkp = linkp;
last_query = nt_str_clone((const char*)wrkp->data);
if(!last_query){
nt_crypt_release_ref(h_crypt);
+ free(buf1);
return FALSE;
}
wrkp = wrkp->next;
icd = iconv_open("wchar_t", "cp932");
if(((iconv_t)-1) == icd){
nt_crypt_release_ref(h_crypt);
+ free(buf1);
free(last_query);
return FALSE;
}
L"favorite", L"query_time", 0, last_query);
free(last_query);
+ free(buf1);
nt_all_link_free(linkp, NULL);
iconv_close(icd);
nt_crypt_release_ref(h_crypt);
-/* Copyright 2013 Akira Ohta (akohta001@gmail.com)
+/* Copyright 2013,2014 Akira Ohta (akohta001@gmail.com)
This file is part of ntch.
The ntch is free software: you can redistribute it and/or modify
extern int nt_board_get_thread_count(nt_board_handle h_board);
extern int nt_thread_get_seq_number(nt_thread_handle h_thread);
extern const wchar_t* nt_thread_get_title(nt_thread_handle h_thread);
+extern const wchar_t* nt_thread_set_title(
+ nt_thread_handle h_thread, const wchar_t* title);
extern const wchar_t* nt_thread_get_dat_name(nt_thread_handle h_thread);
extern int nt_thread_get_res_count(nt_thread_handle h_thread);
extern int nt_res_get_seq_number(nt_res_handle h_res);
-/* Copyright 2013 Akira Ohta (akohta001@gmail.com)
+/* Copyright 2013,2014 Akira Ohta (akohta001@gmail.com)
This file is part of ntch.
The ntch is free software: you can redistribute it and/or modify
extern nt_searched_thread_handle nt_searched_thread_alloc(
const wchar_t *board_name,const wchar_t *dat_name,
const wchar_t *title);
+extern nt_searched_thread_handle nt_searched_thread_alloc2(
+ nt_2ch_model_handle h_model,
+ const char *url);
extern int nt_searched_thread_add_ref(nt_searched_thread_handle h_searched_thread);
extern int nt_searched_thread_release_ref(nt_searched_thread_handle h_searched_thread);
#define PACKAGE_NAME "ntch"
/* Define to the full name and version of this package. */
-#define PACKAGE_STRING "ntch 1.0.2.7"
+#define PACKAGE_STRING "ntch 1.0.2.8"
/* 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.2.7"
+#define PACKAGE_VERSION "1.0.2.8"
/* Define to 1 if you have the ANSI C header files. */
#define STDC_HEADERS 1
#define NT_INTI_DISP_FAVORITE 2
#define NT_INTI_DISP_HISTORY 3
-#define NT_KEY_NONE (-1)
+#define NT_KEY_NONE (0)
#define NT_KEY_UP 'k'
#define NT_KEY_DOWN 'j'
#define NT_KEY_LEFT 'h'
#define NT_COMMAND1_HISTORY_2 "h"
#define NT_COMMAND1_AUTOSCROLL_1 "autoscroll"
#define NT_COMMAND1_AUTOSCROLL_2 "a"
+#define NT_COMMAND1_TIMER "timer"
#define NT_COMMAND1_UPLOAD_1 "upload"
#define NT_COMMAND1_UPLOAD_BOARD1 "board"
#define NT_COMMAND1_UPLOAD_BOARD2 "b"
#define NT_COMMAND1_NG_NAME_1 "ngname"
#define NT_COMMAND1_NG_NAME_2 "ngnm"
#define NT_COMMAND1_NG_ID_1 "ngid"
+#define NT_COMMAND1_OPEN_LINK_1 "link"
+#define NT_COMMAND1_OPEN_LINK_2 "l"
+#define NT_COMMAND1_REPLACE_RES_TEXT_1 "replace"
+#define NT_COMMAND1_REPLACE_RES_TEXT_2 "r"
extern int set_option(int argc, char* argv[]);
char *out_buf, size_t out_buf_len,
const char *referer, const char *user_agent,
nt_link_tp headers, nt_cookie_tp cookiep);
+extern int nt_http_post3(const char *url, const char *post_data,
+ char **out_buf,
+ const char *referer, const char *user_agent,
+ nt_link_tp extend_headers,
+ nt_cookie_tp cookiep);
extern BOOL nt_http_get(const char *url, const char *out_path,
const char *referer, const char *user_agent,
nt_link_tp headers, BOOL range, BOOL ignore_cache);
-/* Copyright 2013 Akira Ohta (akohta001@gmail.com)
+/* Copyright 2013,2014 Akira Ohta (akohta001@gmail.com)
This file is part of ntch.
The ntch is free software: you can redistribute it and/or modify
#define NT_INFO_REFRESH_BOARD_SUCCESS (L"板を更新しました")
#define NT_INFO_ADD_FAVORITE_SUCCEEDED (L"お気に入りに追加しました")
#define NT_INFO_DEL_FAVORITE_SUCCEEDED (L"お気に入りから削除しました")
+#define NT_INFO_SET_ALERT_SUCCEEDED (L"アラートタイマーを設定しました")
#define NT_INFO_UPLOAD_FAVORITE_SUCCEEDED (L"クラウドのお気に入りを更新しました")
#define NT_INFO_UPLOAD_NG_FILES_SUCCEEDED (L"クラウドのNGファイルを更新しました")
-/* Copyright 2013 Akira Ohta (akohta001@gmail.com)
+/* Copyright 2013,2014 Akira Ohta (akohta001@gmail.com)
This file is part of ntch.
The ntch is free software: you can redistribute it and/or modify
#define DISP_CMD_UPLOAD_NG_FILES (17*256)
#define DISP_CMD_EDIT_FAVORITE_BOARD (18*256)
#define DISP_CMD_EDIT_FAVORITE_THREAD (19*256)
-
+#define DISP_CMD_OPEN_2CH_LINK (20*256)
+#define DISP_CMD_SET_ALERT (21*256)
extern int disp_board_menu(nt_window_tp wp,
nt_2ch_model_handle h_model, nt_2ch_selected_item_handle h_select);
extern int disp_threadlist(nt_window_tp wp, int state,
nt_2ch_selected_item_handle h_select, nt_usr_db_handle usr_db_handle);
extern int disp_reslist(nt_window_tp wp, int state,
- nt_2ch_selected_item_handle h_select, nt_usr_db_handle usr_db_handle,
- nt_ng_word_handle h_ng_word, nt_cloud_handle h_cloud);
+ nt_2ch_model_handle h_model,
+ nt_usr_db_handle usr_db_handle,
+ nt_ng_word_handle h_ng_word, nt_cloud_handle h_cloud,
+ nt_2ch_selected_item_handle h_select,
+ nt_searched_thread_handle *h_sel_threadp);
extern int disp_thread_search(nt_window_tp wp,
int prev_state, nt_link_tp thread_list,
nt_searched_thread_handle *h_sel_threadp);
nt_usr_db_handle h_usr_db,
nt_searched_thread_handle *h_sel_threadp,
nt_link_tp *update_board_list);
+extern nt_window_tp disp_alert_win_alloc(
+ WINDOW *parent,
+ int src_lines, int src_cols,
+ const wchar_t *message,
+ const char *cmd_param);
+extern int disp_alert(nt_window_tp wp);
+extern int nt_disp_alert_get_alarm_value(const char *param);
+extern int init_alert_ctx(void *ptr, const wchar_t *msg);
+extern int free_alert_ctx(void *ptr);
+
extern void free_board_menu_ctx(void *ptr);
extern void init_threadlist_ctx(void *ptr);
extern void free_threadlist_ctx(void *ptr);
#define TIMER_ID_AUTO_UPDATE_NONE 0
#define TIMER_ID_AUTO_UPDATE 1
#define TIMER_ID_AUTO_SCROLL 2
+#define TIMER_ID_ALERT 3
static int auto_update_timer_func(int id)
{
switch(id){
return TIMER_ID_AUTO_UPDATE;
case TIMER_ID_AUTO_SCROLL:
return TIMER_ID_AUTO_SCROLL;
+ case TIMER_ID_ALERT:
+ return TIMER_ID_ALERT;
}
return TIMER_ID_AUTO_UPDATE_NONE;
}
nt_window_tp search_winp = NULL;
nt_window_tp favorite_winp = NULL;
nt_window_tp history_winp = NULL;
+ nt_window_tp alert_winp = NULL;
char buf[256];
wchar_t title_buf[128];
wchar_t wch;
BOOL auto_scrolling;
nt_timer_handle h_timer_auto_update;
nt_timer_handle h_timer_auto_scroll;
+ nt_timer_handle h_timer_alert;
nt_timer_handle h_timer;
+ int expire;
+ BOOL show_alert = FALSE;
state = DISP_STATE_BOARDMENU;
if(INIT_DISP_STATE == NT_INTI_DISP_FAVORITE){
TIMER_ID_AUTO_SCROLL, -1, auto_update_timer_func);
h_timer_auto_update = nt_timer_alloc(
TIMER_ID_AUTO_UPDATE, NT_AUTO_UPDATE_INTERVAL, auto_update_timer_func);
+ h_timer_alert = nt_timer_alloc(
+ TIMER_ID_ALERT, -1, auto_update_timer_func);
h_write_data = NULL;
marup = NULL;
LINES - num, COLS, num, 0))
goto END_WHILE;
rwinp->key = ch;
- state = disp_reslist(rwinp, state, h_sel_items, db_handle, h_ng_word, h_cloud);
+ h_searched_thread = NULL;
+ state = disp_reslist(rwinp, state,
+ app_2ch_model, db_handle, h_ng_word, h_cloud,
+ h_sel_items, &h_searched_thread);
auto_scrolling = FALSE;
- if(DISP_CMD(state)){
- if(DISP_CMD(state) == DISP_CMD_AUTO_SCROLL){
- if(0 >= nt_timer_get_interval(h_timer_auto_scroll)){
- nt_timer_set_interval(
- h_timer_auto_scroll, NT_AUTO_SCROLL_INTERVAL);
- }
- auto_scrolling = TRUE;
- state = DISP_STATE_RESLIST;
- }else if(DISP_CMD(state) == DISP_CMD_REFRESH){
- state = DISP_STATE_RESLIST;
- ch = NT_KEY_NONE;
- if(!nt_read_thread(h_sel_items)){
- status_msg = NT_ERR_MSG_REFRESH_THREAD_FAILED;
- wclear(scrp);
- continue;
- }
+ if(DISP_CMD(state) == DISP_CMD_AUTO_SCROLL){
+ if(0 >= nt_timer_get_interval(h_timer_auto_scroll)){
+ nt_timer_set_interval(
+ h_timer_auto_scroll, NT_AUTO_SCROLL_INTERVAL);
+ }
+ auto_scrolling = TRUE;
+ state = DISP_STATE_RESLIST;
+ }else if(DISP_CMD(state) == DISP_CMD_REFRESH){
+ state = DISP_STATE_RESLIST;
+ ch = NT_KEY_NONE;
+ if(!nt_read_thread(h_sel_items)){
+ status_msg = NT_ERR_MSG_REFRESH_THREAD_FAILED;
+ wclear(scrp);
+ continue;
+ }
+ if(rwinp->data){
+ free_reslist_ctx(rwinp->data);
+ rwinp->data = NULL;
+ }
+ status_msg = NT_INFO_REFRESH_THREAD_SUCCESS;
+ wclear(scrp);
+ continue;
+ }else if(DISP_CMD(state) == DISP_CMD_REENTER){
+ DISP_CLR_CMD(state);
+ ch = NT_KEY_NONE;
+ continue;
+ }else if(DISP_CMD(state) == DISP_CMD_SET_ALERT){
+ DISP_CLR_CMD(state);
+ ch = NT_KEY_NONE;
+ expire = nt_disp_alert_get_alarm_value(buf);
+ if(expire <= 0)
+ break;
+ if(!alert_winp){
+ alert_winp = disp_alert_win_alloc(scrp, LINES, COLS, L"Time expired.", buf);
+ }
+ if(!alert_winp)
+ goto END_WHILE;
+ nt_timer_set_interval(
+ h_timer_alert, expire);
+ status_msg = NT_INFO_SET_ALERT_SUCCEEDED;
+ continue;
+ }else if(DISP_CMD(state) == DISP_CMD_OPEN_2CH_LINK && h_searched_thread){
+ ch = NT_KEY_NONE;
+ if(nt_set_sel_item(app_2ch_model,
+ &h_sel_items_tmp, h_searched_thread, &status_msg)){
+ disp_state = DISP_STATE_RESLIST;
+ nt_2ch_selected_item_release_ref(h_sel_items);
+ h_sel_items = h_sel_items_tmp;
if(rwinp->data){
free_reslist_ctx(rwinp->data);
rwinp->data = NULL;
}
- status_msg = NT_INFO_REFRESH_THREAD_SUCCESS;
- wclear(scrp);
- continue;
- }else if(DISP_CMD(state) == DISP_CMD_REENTER){
- DISP_CLR_CMD(state);
- ch = NT_KEY_NONE;
- continue;
- }else if(DISP_CMD(state) == DISP_CMD_EDIT_NGWORD){
- ch = NT_KEY_NONE;
- if(!h_ng_word)
- break;
- linkp = nt_ng_word_get_words(h_ng_word);
- linkp = disp_editor3(linkp);
- if(linkp && nt_ng_word_set_words(h_ng_word, linkp, h_cloud)){
- ch = NT_KEY_CMD_NGWORD_UPDATE;
- }
- DISP_CLR_CMD(state);
- keypad(stdscr, true);
- wclear(scrp);
- continue;
- }else if(DISP_CMD(state) == DISP_CMD_EDIT_NGNAME){
- ch = NT_KEY_NONE;
- if(!h_ng_word)
- break;
- linkp = nt_ng_word_get_names(h_ng_word);
- linkp = disp_editor3(linkp);
- if(linkp && nt_ng_word_set_names(h_ng_word, linkp, h_cloud)){
- ch = NT_KEY_CMD_NGWORD_UPDATE;
- }
- DISP_CLR_CMD(state);
- keypad(stdscr, true);
- wclear(scrp);
- continue;
- }else if(DISP_CMD(state) == DISP_CMD_EDIT_NGID){
- ch = NT_KEY_NONE;
- if(!h_ng_word)
- break;
- linkp = nt_ng_word_get_ids(h_ng_word);
- linkp = disp_editor3(linkp);
- if(linkp && nt_ng_word_set_ids(h_ng_word, linkp, h_cloud)){
- ch = NT_KEY_CMD_NGWORD_UPDATE;
+ if(twinp->data){
+ free_threadlist_ctx(twinp->data);
+ twinp->data = NULL;
}
- DISP_CLR_CMD(state);
- keypad(stdscr, true);
- wclear(scrp);
- continue;
}
+ nt_searched_thread_release_ref(h_searched_thread);
+ h_searched_thread = NULL;
+ DISP_CLR_CMD(state);
+ wclear(scrp);
+ continue;
+ }else if(DISP_CMD(state) == DISP_CMD_EDIT_NGWORD){
+ ch = NT_KEY_NONE;
+ if(!h_ng_word)
+ break;
+ linkp = nt_ng_word_get_words(h_ng_word);
+ linkp = disp_editor3(linkp);
+ if(linkp && nt_ng_word_set_words(h_ng_word, linkp, h_cloud)){
+ ch = NT_KEY_CMD_NGWORD_UPDATE;
+ }
+ DISP_CLR_CMD(state);
+ keypad(stdscr, true);
+ wclear(scrp);
+ continue;
+ }else if(DISP_CMD(state) == DISP_CMD_EDIT_NGNAME){
+ ch = NT_KEY_NONE;
+ if(!h_ng_word)
+ break;
+ linkp = nt_ng_word_get_names(h_ng_word);
+ linkp = disp_editor3(linkp);
+ if(linkp && nt_ng_word_set_names(h_ng_word, linkp, h_cloud)){
+ ch = NT_KEY_CMD_NGWORD_UPDATE;
+ }
+ DISP_CLR_CMD(state);
+ keypad(stdscr, true);
+ wclear(scrp);
+ continue;
+ }else if(DISP_CMD(state) == DISP_CMD_EDIT_NGID){
+ ch = NT_KEY_NONE;
+ if(!h_ng_word)
+ break;
+ linkp = nt_ng_word_get_ids(h_ng_word);
+ linkp = disp_editor3(linkp);
+ if(linkp && nt_ng_word_set_ids(h_ng_word, linkp, h_cloud)){
+ ch = NT_KEY_CMD_NGWORD_UPDATE;
+ }
+ DISP_CLR_CMD(state);
+ keypad(stdscr, true);
+ wclear(scrp);
+ continue;
}
+ DISP_CLR_CMD(state);
if(!auto_scrolling){
nt_timer_set_interval(h_timer_auto_scroll, -1);
}
print_error(scrp, status_msg);
status_msg = NULL;
}
-
+ if(show_alert && alert_winp){
+ disp_alert(alert_winp);
+ }
+
move(LINES-1,COLS-1);
touchwin(scrp);
wrefresh(scrp);
nt_all_link_free(linkp, _2ch_selected_item_free);
//fprintf(stderr, "Update request calling.!\n");
}
+ ch = NT_KEY_NONE;
+ break;
+ case TIMER_ID_ALERT:
+ //fputs("Timer expired!\n", stderr);
+ show_alert = TRUE;
+ nt_timer_set_interval(h_timer_alert, -1);
+ ch = NT_KEY_NONE;
break;
}
nt_timer_release_ref(h_timer);
case NT_KEY_BOTTOM:
case KEY_END:
case NT_KEY_REFRESH:
+ show_alert = FALSE;
break;
case NT_KEY_CLOSE:
case KEY_LEFT:
wclear(scrp);
+ show_alert = FALSE;
break;
case KEY_HOME:
ch = NT_KEY_COMMAND1;
nt_add_wch(scrp,ch,0);
strncpy(buf,"1",2);
+ show_alert = FALSE;
break;
case NT_KEY_COMMAND1:
case NT_KEY_COMMAND2:
getstr(buf);
cbreak();
noecho();
+ show_alert = FALSE;
break;
case NT_KEY_ERASE:
wclear(scrp);
+ show_alert = FALSE;
break;
case NT_KEY_QUIT:
result = TRUE;
}/* end switch*/
}/* end while */
END_WHILE:
+ if(h_timer_alert)
+ nt_timer_release_ref(h_timer_alert);
if(h_timer_auto_update)
nt_timer_release_ref(h_timer_auto_update);
if(h_timer_auto_scroll)
free_board_menu_ctx(bwinp->data);
free_threadlist_ctx(twinp->data);
free_reslist_ctx(rwinp->data);
+ if(alert_winp){
+ if(alert_winp->data)
+ free_alert_ctx(alert_winp->data);
+ nt_disp_win_free(alert_winp);
+ }
if(history_winp){
if(history_winp->data)
free_history_ctx(history_winp->data);
static void nt_http_free_header(nt_http_header_tp headerp);
static BOOL nt_http_init_header2(
nt_http_header_tp headerp, const char *out_path);
+static int nt_http_post_local(const char *url, const char *post_data,
+ char **out_buf, size_t out_buf_len,
+ const char *referer, const char *user_agent,
+ nt_link_tp extend_headers,
+ nt_cookie_tp cookiep);
BOOL nt_http_post(const char *url, const char *post_data,
char *out_buf, size_t out_buf_len,
nt_cookie_tp cookiep)
{
int result_code;
- result_code = nt_http_post2(url, post_data,
- out_buf, out_buf_len, referer, user_agent,
+ result_code = nt_http_post_local(url, post_data,
+ &out_buf, out_buf_len, referer, user_agent,
extend_headers, cookiep);
return (result_code == 200) ? TRUE : FALSE;
}
nt_link_tp extend_headers,
nt_cookie_tp cookiep)
{
+ return nt_http_post_local(url, post_data,
+ &out_buf, out_buf_len,
+ referer, user_agent,
+ extend_headers,
+ cookiep);
+}
+int nt_http_post3(const char *url, const char *post_data,
+ char **out_buf,
+ const char *referer, const char *user_agent,
+ nt_link_tp extend_headers,
+ nt_cookie_tp cookiep)
+{
+ return nt_http_post_local(url, post_data,
+ out_buf, 0,
+ referer, user_agent,
+ extend_headers,
+ cookiep);
+}
+
+#define BUF_LEN_DELTA (1024*4)
+int nt_http_post_local(const char *url, const char *post_data,
+ char **out_buf, size_t out_buf_len,
+ const char *referer, const char *user_agent,
+ nt_link_tp extend_headers,
+ nt_cookie_tp cookiep)
+{
nt_socket_tp socketp = NULL;
int fd = -1, sockfd = 0;
char data[1024*8];
char itoa_buf[33];
char cookie_data[1024];
char *cptr, *p1, *p2, *p3;
+ int len, new_len;
+ char *tmp_buf;
+ BOOL is_realloc_buf;
+
result = 0;
nt_http_header_tp headerp = nt_http_init_header(url);
nt_http_free_header(headerp);
return result;
}
- memcpy(out_buf, data+nread, data_len-nread);
- out_buf[data_len - nread] = '\0';
+ memcpy(*out_buf, data+nread, data_len-nread);
+ (*out_buf)[data_len - nread] = '\0';
}else{
if(headerp->port == -1)
headerp->port = 80;
return result;
}
}
+
+
result = responsep->status_code;
switch(result){
case 200:
if(IS_SET_FLAG(headerp,SSL_FLAG)){
}else{
- cptr = out_buf;
+ if(out_buf_len == 0){
+ tmp_buf = malloc(BUF_LEN_DELTA);
+ if(!tmp_buf)
+ goto ERROR_TRAP;
+ *out_buf = tmp_buf;
+ out_buf_len = BUF_LEN_DELTA;
+ is_realloc_buf = TRUE;
+ }else{
+ is_realloc_buf = FALSE;
+ }
+ cptr = *out_buf;
do{
nread = read(sockfd, data, sizeof(data));
switch(nread){
case 0:
break;
default:
- if(out_buf_len <= (cptr - out_buf) + nread){
- goto ERROR_TRAP;
+ len = cptr - (*out_buf);
+ if(out_buf_len <= len + nread){
+ if(!is_realloc_buf)
+ goto ERROR_TRAP;
+ new_len = ((len + nread) / BUF_LEN_DELTA + 1) * BUF_LEN_DELTA;
+ tmp_buf = malloc(new_len);
+ if(!tmp_buf)
+ goto ERROR_TRAP;
+ memcpy(tmp_buf, *out_buf, len);
+ free(*out_buf);
+ *out_buf = tmp_buf;
+ out_buf_len = new_len;
+ cptr = (*out_buf) + len;
}
memcpy(cptr, data, nread);
cptr[nread] = '\0';
if(nread > 0){
result = 0;
}else if(IS_SET_FLAG(responsep, CHUNKED_FLAG)){
- p3 = p1 = out_buf;
+ p3 = p1 = *out_buf;
while(0 < (nread = strtol(p1, &p2, 16))){
memmove(p3, p2+2, nread);
p3 += nread;
struct addrinfo *addr_out, *addr_list;
struct sockaddr_in *s_addr;
struct sockaddr_in6 *s_addr6;
+ int err;
#else
struct hostent *hostinfo;
addr_limit.ai_family = AF_UNSPEC;
addr_limit.ai_socktype = SOCK_STREAM;
addr_limit.ai_protocol = IPPROTO_TCP;
- if(0 != getaddrinfo(addr, NULL, &addr_limit, &addr_out)){
+ err = getaddrinfo(addr, NULL, &addr_limit, &addr_out);
+ if(0 != err){
+ fprintf(stderr, "getaddrinfo: %s\n", gai_strerror(err));
free(ptr);
return NULL;
}
--- /dev/null
+/* Copyright 2014 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 <stdio.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <string.h>
+#include <assert.h>
+#include <signal.h>
+#include <limits.h>
+
+
+#include "env.h"
+#include "error.h"
+#include "nt_string.h"
+#include "_2ch/_2ch.h"
+#include "utils/nt_std_t.h"
+#include "utils/text.h"
+#include "utils/file.h"
+#include "ui/disp.h"
+#include "ui/disp_string.h"
+
+#define NT_ALERT_WIN_TITLE_HEIGHT 3
+#define NT_ALERT_WIN_CLIENT_HEIGHT 8
+#define NT_ALERT_WIN_HEIGHT (NT_ALERT_WIN_TITLE_HEIGHT + NT_ALERT_WIN_CLIENT_HEIGHT)
+#define NT_ALERT_WIN_WIDTH 40
+
+typedef struct tag_ctx_alert_t *ctx_alert_tp;
+typedef struct tag_ctx_alert_t{
+ wchar_t *message;
+ int x;
+ int y;
+ int lines;
+ int cols;
+}ctx_alert_t;
+
+
+nt_window_tp disp_alert_win_alloc(
+ WINDOW *parent,
+ int src_lines, int src_cols,
+ const wchar_t *message,
+ const char *cmd_param)
+{
+ nt_window_tp winp = NULL;
+ wchar_t *cptr;
+ int x, y, cols, lines;
+ ctx_alert_tp ctxp;
+
+ cptr = nt_w_str_clone(message);
+ if(!cptr){
+ return NULL;
+ }
+ ctxp = malloc(sizeof(ctx_alert_t));
+ if(!ctxp){
+ free(cptr);
+ return NULL;
+ }
+ ctxp->message = cptr;
+
+ if(src_lines > NT_ALERT_WIN_HEIGHT){
+ lines = NT_ALERT_WIN_HEIGHT;
+ y = (src_lines - NT_ALERT_WIN_HEIGHT) / 2;
+ }else{
+ lines = src_lines;
+ y = 0;
+ }
+ if(src_cols > NT_ALERT_WIN_WIDTH){
+ cols = NT_ALERT_WIN_WIDTH;
+ x = (src_cols - NT_ALERT_WIN_WIDTH) / 2;
+ }else{
+ cols = src_cols;
+ x = 0;
+ }
+
+ winp = nt_disp_win_alloc(parent, lines, cols, y, x, cmd_param);
+ if(!winp){
+ free(cptr);
+ free(ctxp);
+ return NULL;
+ }
+ winp->data = ctxp;
+ ctxp->x = x;
+ ctxp->y = y;
+ ctxp->cols = cols;
+ ctxp->lines = lines;
+ return winp;
+}
+
+
+static void draw_frame(nt_window_tp wp, int cols, int lines)
+{
+ int i;
+
+ wmove(wp->wp, 0, 0);
+ nt_add_wch(wp->wp, L'+', 0);
+ nt_add_wnch(wp->wp, L'-', 0, cols - 2);
+ nt_add_wch(wp->wp, L'+', 0);
+
+ wmove(wp->wp, 1, 0);
+ nt_add_wch(wp->wp, L'|', 0);
+ nt_add_wnch(wp->wp, L' ', 0, cols - 2);
+ nt_add_wch(wp->wp, L'|', 0);
+
+ wmove(wp->wp, 2, 0);
+ nt_add_wch(wp->wp, L'+', 0);
+ nt_add_wnch(wp->wp, L'-', 0, cols - 2);
+ nt_add_wch(wp->wp, L'+', 0);
+
+ for(i = 3; i < (lines - 1); i++){
+ wmove(wp->wp, i, 0);
+ nt_add_wch(wp->wp, L'|', 0);
+ nt_add_wnch(wp->wp, L' ', 0, cols - 2);
+ nt_add_wch(wp->wp, L'|', 0);
+ }
+ wmove(wp->wp, i, 0);
+ nt_add_wch(wp->wp, L'+', 0);
+ nt_add_wnch(wp->wp, L'-', 0, cols - 2);
+ nt_add_wch(wp->wp, L'+', 0);
+
+}
+
+int disp_alert(nt_window_tp wp)
+{
+ ctx_alert_tp ctxp;
+ int offset_y, offset_x, length;
+
+ ctxp = (ctx_alert_tp)wp->data;
+ assert(ctxp);
+ assert(ctxp->message);
+
+ draw_frame(wp, ctxp->cols, ctxp->lines);
+
+ offset_y = (ctxp->lines - 3) / 2 + 3;
+
+ length = nt_get_wc_count_within_colmns(ctxp->message, ctxp->cols - 2);
+
+ offset_x = (ctxp->cols - length ) / 2;
+
+ wmove(wp->wp, offset_y, offset_x);
+ nt_add_wnstr(wp->wp, ctxp->message, 0, length);
+
+ return 0;
+}
+
+
+int nt_disp_alert_get_alarm_value(const char *param)
+{
+ const char *start, *end;
+ long int num;
+ if(!nt_strtok(param, ' ', &start, &end))
+ return -1;
+
+ if(start >= end)
+ return -1;
+
+ if(0 != strncmp(start,
+ NT_COMMAND1_TIMER, strlen(NT_COMMAND1_TIMER)))
+ return -1;
+
+ if(!nt_strtok(end, ' ', &start, &end))
+ return -1;
+
+
+ num = strtol(start, (char**)&end, 10);
+ if(num < 0 || num == LONG_MIN || num == LONG_MAX)
+ return -1;
+ switch(*end){
+ case ' ':
+ case '\0':
+ case '\n':
+ case '\t':
+ break;
+ case 's':
+ num *= 1000;
+ break;
+ case 'm':
+ num *= 60000;
+ break;
+ default:
+ return -1;
+ }
+ return num;
+}
+
+
+int init_alert_ctx(void *ptr, const wchar_t *msg)
+{
+ return 0;
+}
+int free_alert_ctx(void *ptr)
+{
+ ctx_alert_tp ctxp;
+
+ ctxp = (ctx_alert_tp)ptr;
+ free(ctxp->message);
+ free(ctxp);
+ return 0;
+}
+
#define NT_CMD_EDT_NGWORD 12
#define NT_CMD_EDT_NGNAME 13
#define NT_CMD_EDT_NGID 14
+#define NT_CMD_OPEN_LINK 15
+#define NT_CMD_REPLACE_RES_TEXT 16
+#define NT_CMD_SET_ALTER 17
#define AUTO_SCROLL_NONE 0
#define AUTO_SCROLL_UP -1
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, int prev_state, nt_2ch_selected_item_handle h_select,
- nt_usr_db_handle usr_db_handle, nt_ng_word_handle h_ng_word, nt_cloud_handle h_cloud)
+int disp_reslist(nt_window_tp wp, int prev_state,
+ nt_2ch_model_handle h_model,
+ nt_usr_db_handle usr_db_handle,
+ nt_ng_word_handle h_ng_word, nt_cloud_handle h_cloud,
+ nt_2ch_selected_item_handle h_select,
+ nt_searched_thread_handle *h_sel_threadp)
{
ctx_reslist_tp ctxp, child_ctxp;
res_data_tp res_datap;
switch(cmd){
case NT_CMD_AUTO_SCROLL:
return DISP_CMD_AUTO_SCROLL | DISP_STATE_RESLIST;
+ case NT_CMD_SET_ALTER:
+ return DISP_CMD_SET_ALERT | DISP_STATE_RESLIST;
case NT_CMD_SEARCH_THREAD:
return DISP_STATE_SEARCH_THREAD;
case NT_CMD_FAVORITE:
case NT_CMD_EDT_NGID:
free_disp_lines_ctx(wp->data);
return DISP_CMD_EDIT_NGID | DISP_STATE_RESLIST;
+ case NT_CMD_OPEN_LINK:
+ *h_sel_threadp = nt_searched_thread_alloc2(h_model, endp);
+ if(h_sel_threadp)
+ return DISP_CMD_OPEN_2CH_LINK | DISP_STATE_RESLIST;
+ break;
+ case NT_CMD_REPLACE_RES_TEXT:
+ break;
default:
if(cmd == NT_CMD_TREE){
linkp = parse_tree_list((ctx_reslist_tp)wp->data, endp);
0 == strncmp(NT_COMMAND1_AUTOSCROLL_2,param,
strlen(NT_COMMAND1_AUTOSCROLL_2))){
return NT_CMD_AUTO_SCROLL;
+ }else if(0 == strncmp(NT_COMMAND1_TIMER,param,
+ strlen(NT_COMMAND1_TIMER))){
+ return NT_CMD_SET_ALTER;
}else if(0 == strncmp(NT_COMMAND1_NG_WORD_1,param,len) ||
0 == strncmp(NT_COMMAND1_NG_WORD_2,param, len)){
if(!nt_strtok(*end, ' ', &start, end))
return NT_CMD_EDT_NGID;
*end = start;
return NT_CMD_ADD_NGID;
+ }else if(0 == strncmp(NT_COMMAND1_OPEN_LINK_1,param,len) ||
+ 0 == strncmp(NT_COMMAND1_OPEN_LINK_2,param, len)){
+ if(!nt_strtok(*end, ' ', &start, end))
+ return NT_CMD_NONE;
+
+ len = *end - start;
+ if(len <= 0)
+ return NT_CMD_NONE;
+ *end = start;
+ return NT_CMD_OPEN_LINK;
+ }else if(0 == strncmp(NT_COMMAND1_REPLACE_RES_TEXT_1,param,len) ||
+ 0 == strncmp(NT_COMMAND1_REPLACE_RES_TEXT_2,param, len)){
+ if(!nt_strtok(*end, ' ', &start, end))
+ return NT_CMD_NONE;
+
+ len = *end - start;
+ if(len <= 0)
+ return NT_CMD_NONE;
+ *end = start;
+ return NT_CMD_REPLACE_RES_TEXT;
}
return NT_CMD_NONE;
}
};
-static BOOL s2i(const char** cpp, char *cp)
+static BOOL s2i(char** cpp, char *cp)
{
char c, c1, c2;
+ char *p;
c1 = (*cpp)[0];
c2 = (*cpp)[1];
else
return FALSE;
*cp = c;
- *cpp += 2;
+ p = *cpp;
+ p += 2;
+ *cpp = p;
return TRUE;
}
}else if(c == -2){/* % */
if(cptr + 2 > end_ptr)
return -1;
- if(!s2i((const char**)&cptr, &c))
+ if(!s2i((char**)&cptr, &c))
return -1;
if(c == '='){
state = 5;
-/* Copyright 2013 Akira Ohta (akohta001@gmail.com)
+/* Copyright 2013,2014 Akira Ohta (akohta001@gmail.com)
This file is part of ntch.
The ntch is free software: you can redistribute it and/or modify
-/* Copyright 2013 Akira Ohta (akohta001@gmail.com)
+/* Copyright 2013,2014 Akira Ohta (akohta001@gmail.com)
This file is part of ntch.
The ntch is free software: you can redistribute it and/or modify
#include <string.h>
#include <assert.h>
#include <openssl/sha.h>
+#include <pthread.h>
#include "env.h"
#include "utils/nt_std_t.h"
#include "utils/db.h"
+static pthread_mutex_t g_init_path_lock_mutex = PTHREAD_MUTEX_INITIALIZER;
+
const char *nt_db_get_log_path()
{
static char path[256];
static int f = 0;
+ pthread_mutex_lock(&g_init_path_lock_mutex);
if(f == 0){
strcpy(path, LOG_PATH);
strcat(path, "/");
strcat(path, LOG_DB_NAME);
}
+ pthread_mutex_unlock(&g_init_path_lock_mutex);
return path;
}
{
static char path[256];
static int f = 0;
+ pthread_mutex_lock(&g_init_path_lock_mutex);
if(f == 0){
strcpy(path, LOG_PATH);
strcat(path, "/");
strcat(path, INDEX_DB_NAME);
}
+ pthread_mutex_unlock(&g_init_path_lock_mutex);
return path;
}
-/* Copyright 2013 Akira Ohta (akohta001@gmail.com)
+/* Copyright 2013,2014 Akira Ohta (akohta001@gmail.com)
This file is part of ntch.
The ntch is free software: you can redistribute it and/or modify
assert(h_pthread->chk_sum == NT_PTHREAD_CHK_SUM);
pthreadp = (nt_pthread_tp)h_pthread;
assert(pthreadp->ref_count > 0);
- return ++pthreadp->ref_count;
+ return nt_pthread_increment_int(&pthreadp->ref_count);
}
int nt_pthread_release_ref(nt_pthread_handle h_pthread)
{
nt_pthread_tp pthreadp;
+ int c;
assert(h_pthread);
assert(h_pthread->chk_sum == NT_PTHREAD_CHK_SUM);
pthreadp = (nt_pthread_tp)h_pthread;
assert(pthreadp->ref_count > 0);
- if(0 != --pthreadp->ref_count)
- return pthreadp->ref_count;
+ c = nt_pthread_decrement_int(&pthreadp->ref_count);
+ if(0 != c)
+ return c;
free(h_pthread);
return 0;
}
-/* Copyright 2013 Akira Ohta (akohta001@gmail.com)
+/* Copyright 2013,2014 Akira Ohta (akohta001@gmail.com)
This file is part of ntch.
The ntch is free software: you can redistribute it and/or modify
int nread, len;
in_buf_remain = chunk_remain = 0;
+ nread = 0;
do{
if(in_buf_remain == 0){