1 /* Copyright 2013 Akira Ohta (akohta001@gmail.com)
2 This file is part of ntch.
4 The ntch is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
9 The ntch is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with ntch. If not, see <http://www.gnu.org/licenses/>.
28 #include "utils/nt_std_t.h"
29 #include "usr/usr_db_t.h"
30 #include "utils/text.h"
31 #include "_2ch/_2ch.h"
32 #include "_2ch/model_2ch.h"
33 #include "_2ch/parse_2ch.h"
35 #include "ui/disp_string.h"
37 #define NT_CMD_NONE -1
38 #define NT_CMD_WRITE 1
39 #define NT_CMD_JMP_NEW 2
42 #define NT_CMD_SEARCH_THREAD 5
43 #define NT_CMD_FAVORITE 6
44 #define NT_CMD_HISTORY 7
45 #define NT_CMD_AUTO_SCROLL 8
46 #define NT_CMD_ADD_NGWORD 9
47 #define NT_CMD_ADD_NGNAME 10
48 #define NT_CMD_ADD_NGID 11
49 #define NT_CMD_EDT_NGWORD 12
50 #define NT_CMD_EDT_NGNAME 13
51 #define NT_CMD_EDT_NGID 14
53 #define AUTO_SCROLL_NONE 0
54 #define AUTO_SCROLL_UP -1
55 #define AUTO_SCROLL_DOWN 1
57 typedef struct tag_ctx_reslist_t *ctx_reslist_tp;
58 typedef struct tag_ctx_reslist_t
67 nt_stack_tp selected_num_stackp;
76 nt_link_tp res_disp_list;
78 nt_stack_tp child_ctx_stackp;
82 typedef struct tag_res_data_t *res_data_tp;
83 typedef struct tag_res_data_t {
86 nt_link_tp cite_num_list;
87 nt_link_tp cited_num_list;
89 int msg_header_line_num;
90 nt_link_tp msg_line_linkp;
94 static ctx_reslist_tp init_context(nt_2ch_selected_item_handle h_select,
95 nt_usr_db_handle usr_db_handle);
96 static BOOL reslist_clone(nt_thread_handle h_thread, ctx_reslist_tp ctxp);
97 static void int_ptr_free(void *ptr);
98 static int parse_cmd1(const char *param, const char **end);
99 static BOOL search_line_asc(regex_t *regexp, nt_link_tp reslistp,
100 int *sel_res_no, int *sel_res_line, int column,
101 nt_ng_word_handle h_ngword);
102 static BOOL search_line_desc(regex_t *regexp, ctx_reslist_tp ctxp,
104 int *sel_res_no, int *sel_res_line, int column,
105 nt_ng_word_handle h_ngword);
106 static int parse_res_msg(nt_link_tp disp_res_list,
107 res_data_tp res_datap, size_t colmns, nt_ng_word_handle h_ngword);
108 static void res_msg_free(void *ptr);
109 static nt_link_tp get_cited_num_list(nt_link_tp res_listp, int seq_no);
110 static BOOL reslist_copy(ctx_reslist_tp ctxp, ctx_reslist_tp copy_ctxp,
111 nt_link_tp num_listp);
112 static ctx_reslist_tp init_sub_context(ctx_reslist_tp ctxp, nt_link_tp num_listp);
113 static void free_reslist_sub_ctx(void *ptr);
114 static void free_disp_lines_ctx(void *ptr);
115 static nt_link_tp parse_tree_list(ctx_reslist_tp ctxp, const char *param);
116 static nt_link_tp parse_id_list(ctx_reslist_tp ctxp, const char *param);
117 static void search_up_tree(int seq_no, nt_link_tp disp_list, nt_link_tp *num_linkp);
118 static void search_down_tree(int seq_no, nt_link_tp disp_list, nt_link_tp *num_linkp);
119 static int get_id_num(ctx_reslist_tp ctxp, const wchar_t *misc);
120 static BOOL set_res_header(ctx_reslist_tp ctxp, res_data_tp res_datap,
121 wchar_t *buf, size_t buf_len);
123 int disp_reslist(nt_window_tp wp, int prev_state, nt_2ch_selected_item_handle h_select,
124 nt_usr_db_handle usr_db_handle, nt_ng_word_handle h_ng_word, nt_cloud_handle h_cloud)
126 ctx_reslist_tp ctxp, child_ctxp;
127 res_data_tp res_datap;
138 wchar_t buf[1024*3+1];
140 nt_link_tp link_curp;
149 int auto_scroll_state;
151 ctxp = (ctx_reslist_tp)wp->data;
153 ctxp = init_context(h_select, usr_db_handle);
155 return DISP_STATE_ERROR;
157 }else if(ctxp->child_ctx_stackp){
158 ctxp = (ctx_reslist_tp)nt_stack_peek(
159 ctxp->child_ctx_stackp);
161 ctxp->child_ctx_stackp = NULL;
162 ctxp = (ctx_reslist_tp)wp->data;
166 if(prev_state == DISP_STATE_THREADTITLE ||
167 prev_state == DISP_STATE_SEARCH_THREAD ||
168 prev_state == DISP_STATE_FAVORITE ||
169 prev_state == DISP_STATE_HISTORY){
170 ctxp->prev_state = prev_state;
174 result_state = DISP_STATE_RESLIST;
176 if(ctxp->max_cur_res < 0 || ctxp->max_cur_offset < 0){
178 int cur_res = ctxp->res_num - 1;
179 /* get the bottom scroll position*/
180 clistp = ctxp->res_disp_list->prev;
181 while(clistp != ctxp->res_disp_list){
182 res_datap = (res_data_tp)clistp->data;
183 if(!res_datap->msg_line_linkp){
184 parse_res_msg(ctxp->res_disp_list, res_datap, wp->cols-5, h_ng_word);
187 if(res_datap->msg_header_line_num <= 0){
188 if(!set_res_header((ctx_reslist_tp)wp->data,
189 res_datap, buf, sizeof(buf)/sizeof(buf[0]))){
190 res_datap->msg_header_line_num = 1;
195 num = nt_get_wc_count_within_colmns(
199 res_datap->msg_header_line_num++;
207 ctxp->max_cur_offset = res_datap->msg_header_line_num;
208 ctxp->max_cur_offset += res_datap->msg_line_num;
209 ctxp->max_cur_res = cur_res;
212 if(wlines <= res_datap->msg_line_num){
213 ctxp->max_cur_offset = res_datap->msg_header_line_num;
214 ctxp->max_cur_offset += res_datap->msg_line_num - wlines;
215 ctxp->max_cur_res = cur_res;
218 wlines -= res_datap->msg_line_num;
219 if(wlines <= res_datap->msg_header_line_num){
220 ctxp->max_cur_offset =
221 res_datap->msg_header_line_num - wlines;
222 ctxp->max_cur_res = cur_res;
225 wlines -= res_datap->msg_header_line_num;
228 ctxp->max_cur_offset = 0;
229 ctxp->max_cur_res = 0;
232 clistp = clistp->prev;
236 auto_scroll_state = ctxp->auto_scroll;
237 if(ch == NT_KEY_CMD_AUTO_SCROLL){
238 result_state |= DISP_CMD_AUTO_SCROLL;
239 if(ctxp->auto_scroll == AUTO_SCROLL_UP){
243 ctxp->auto_scroll = AUTO_SCROLL_DOWN;
246 ctxp->auto_scroll = AUTO_SCROLL_NONE;
250 case NT_KEY_CMD_BOARD_UPDATE:
251 case NT_KEY_CMD_FAVORITE_UPDATE:
252 if(auto_scroll_state != AUTO_SCROLL_NONE){
253 result_state |= DISP_CMD_AUTO_SCROLL;
254 ctxp->auto_scroll = auto_scroll_state;
258 return DISP_CMD_REFRESH;
260 return DISP_STATE_THREADTITLE;
263 return ctxp->prev_state;
266 if(ctxp->cur_res == ctxp->res_num - 1)
268 if(!ctxp->res_disp_list)
270 clistp = ctxp->res_disp_list->prev;
271 ctxp->cur_res = ctxp->max_cur_res;
272 ctxp->cur_res_offset = ctxp->max_cur_offset;
275 if(!ctxp->selected_num_stackp)
277 if(0 >= nt_stack_get_position(ctxp->selected_num_stackp)){
278 if((ctx_reslist_tp)wp->data != ctxp){
279 stackp = ((ctx_reslist_tp)wp->data)->child_ctx_stackp;
281 if(0 >= nt_stack_get_position(stackp)){
282 ctxp = (ctx_reslist_tp)wp->data;
283 nt_stack_free(stackp, free_reslist_sub_ctx);
284 ((ctx_reslist_tp)wp->data)->child_ctx_stackp = NULL;
287 child_ctxp = nt_stack_pop(stackp);
290 child_ctxp = nt_stack_peek(stackp);
298 nptr = malloc(sizeof(int));
299 *nptr = ctxp->cur_res;
300 ptr = nt_stack_add_last(ctxp->selected_num_stackp, nptr);
304 nptr = nt_stack_pop(ctxp->selected_num_stackp);
308 if(ctxp->cur_res == num)
310 if(num >= ctxp->res_num)
313 ctxp->cur_res_offset = 0;
314 if(!ctxp->res_disp_list)
316 clistp = ctxp->res_disp_list;
317 for(i = 0; i < num; i++)
318 clistp = clistp->next;
321 if(!ctxp->selected_num_stackp)
323 nptr = nt_stack_cursor_next(ctxp->selected_num_stackp);
327 if(ctxp->cur_res == num)
329 if(num >= ctxp->res_num)
332 ctxp->cur_res_offset = 0;
333 if(!ctxp->res_disp_list)
335 clistp = ctxp->res_disp_list;
336 for(i = 0; i < num; i++)
337 clistp = clistp->next;
339 case NT_KEY_COMMAND2:
340 case NT_KEY_COMMAND3:
341 search_asc = (ch == NT_KEY_COMMAND2);
342 if(wp->cmd_param && wp->cmd_param[0] != '\0'){
343 if(0 != regcomp(&(ctxp->regex),
344 wp->cmd_param, REG_EXTENDED)){
345 if(ctxp->regex_init){
346 regfree(&(ctxp->regex));
347 ctxp->regex_init = FALSE;
351 if(!ctxp->regex_init)
352 ctxp->regex_init = TRUE;
354 if(!ctxp->regex_init)
358 if(search_line_asc(&(ctxp->regex),ctxp->res_disp_list,
359 &ctxp->sel_res_no, &ctxp->sel_res_line,
360 wp->cols - 5, h_ng_word)){
364 if(search_line_desc(&(ctxp->regex),ctxp,
366 &ctxp->sel_res_no, &ctxp->sel_res_line,
367 wp->cols - 5, h_ng_word)){
373 rows = ctxp->res_num - 1;
374 wlines = wp->lines / 2;
375 wlines -= ctxp->sel_res_line;
376 clistp = ctxp->res_disp_list->prev;
378 if(rows <= ctxp->sel_res_no){
379 res_datap = (res_data_tp)clistp->data;
380 //resp = (nt_res_tp)clistp->data;
381 if(!res_datap->msg_line_linkp){
382 parse_res_msg(ctxp->res_disp_list, res_datap, wp->cols-5, h_ng_word);
384 if(res_datap->msg_header_line_num <= 0){
385 if(!set_res_header((ctx_reslist_tp)wp->data,
386 res_datap, buf, sizeof(buf)/sizeof(buf[0]))){
387 res_datap->msg_header_line_num = 1;
392 num = nt_get_wc_count_within_colmns(
396 res_datap->msg_header_line_num++;
402 if(rows == ctxp->sel_res_no){
403 if(wlines <= ctxp->sel_res_line){
404 ctxp->cur_res = rows;
405 ctxp->cur_res_offset =
406 res_datap->msg_header_line_num +
407 (ctxp->sel_res_line - wlines);
411 wlines -= ctxp->sel_res_line;
412 }else if(wlines <= (res_datap->msg_line_num+1)){
413 ctxp->cur_res = rows;
414 ctxp->cur_res_offset =
415 res_datap->msg_header_line_num + wlines;
419 wlines -= res_datap->msg_line_num + 1;
421 if(wlines <= res_datap->msg_header_line_num){
422 ctxp->cur_res = rows;
423 ctxp->cur_res_offset =
424 res_datap->msg_header_line_num - wlines;
428 wlines -= res_datap->msg_header_line_num;
431 clistp = clistp->prev;
432 }while(clistp != ctxp->res_disp_list->prev);
435 ctxp->cur_res_offset = 0;
439 case NT_KEY_COMMAND1:
440 assert(wp->cmd_param);
441 cmd = parse_cmd1(wp->cmd_param, &endp);
443 case NT_CMD_AUTO_SCROLL:
444 return DISP_CMD_AUTO_SCROLL | DISP_STATE_RESLIST;
445 case NT_CMD_SEARCH_THREAD:
446 return DISP_STATE_SEARCH_THREAD;
447 case NT_CMD_FAVORITE:
448 return DISP_STATE_FAVORITE;
450 return DISP_STATE_HISTORY;
452 return DISP_STATE_EDITOR;
454 if(ctxp->prev_read_cnt <= 0)
456 else if(ctxp->prev_read_cnt >= ctxp->res_num){
457 ctxp->cur_res = ctxp->res_num - 1;
459 ctxp->cur_res = ctxp->prev_read_cnt;
461 ctxp->cur_res_offset = 0;
463 case NT_CMD_ADD_NGWORD:
464 nt_ng_word_add_ng_word(h_cloud, h_ng_word, endp);
465 free_disp_lines_ctx(wp->data);
466 return DISP_CMD_REENTER | DISP_STATE_RESLIST;
467 case NT_CMD_ADD_NGNAME:
468 nt_ng_word_add_ng_name(h_cloud, h_ng_word, endp);
469 free_disp_lines_ctx(wp->data);
470 return DISP_CMD_REENTER | DISP_STATE_RESLIST;
471 case NT_CMD_ADD_NGID:
472 nt_ng_word_add_ng_id(h_cloud, h_ng_word, endp);
473 free_disp_lines_ctx(wp->data);
474 return DISP_CMD_REENTER | DISP_STATE_RESLIST;
475 case NT_CMD_EDT_NGWORD:
476 free_disp_lines_ctx(wp->data);
477 return DISP_CMD_EDIT_NGWORD | DISP_STATE_RESLIST;
478 case NT_CMD_EDT_NGNAME:
479 free_disp_lines_ctx(wp->data);
480 return DISP_CMD_EDIT_NGNAME | DISP_STATE_RESLIST;
481 case NT_CMD_EDT_NGID:
482 free_disp_lines_ctx(wp->data);
483 return DISP_CMD_EDIT_NGID | DISP_STATE_RESLIST;
485 if(cmd == NT_CMD_TREE){
486 linkp = parse_tree_list((ctx_reslist_tp)wp->data, endp);
487 }else if(cmd == NT_CMD_ID){
488 linkp = parse_id_list((ctx_reslist_tp)wp->data, endp);
490 linkp = nt_parse_number_list(wp->cmd_param, NULL);
494 num = nt_link_num(linkp);
501 if(ctxp->cur_res == num)
503 if(num >= ctxp->res_num)
505 nptr = malloc(sizeof(int));
506 *nptr = ctxp->cur_res;
508 ctxp->cur_res_offset = 0;
509 if(!ctxp->res_disp_list){
513 clistp = ctxp->res_disp_list;
514 for(i = 0; i < num; i++)
515 clistp = clistp->next;
516 nt_stack_push(ctxp->selected_num_stackp, nptr);
518 child_ctxp = init_sub_context((ctx_reslist_tp)wp->data, linkp);
522 nt_all_link_free(linkp, NULL);
529 if(auto_scroll_state != AUTO_SCROLL_NONE){
530 result_state |= DISP_CMD_AUTO_SCROLL;
531 ctxp->auto_scroll = AUTO_SCROLL_UP;
533 ctxp->cur_res_offset--;
534 if(0 <= ctxp->cur_res_offset){
537 if(0 >= ctxp->cur_res){
538 ctxp->cur_res_offset = 0;
543 clistp = ctxp->res_disp_list;
544 for(i = 0; i < ctxp->res_num; i++){
545 if(i == ctxp->cur_res)
547 clistp = clistp->next;
549 if(i == ctxp->res_num)
551 res_datap = (res_data_tp)clistp->data;
552 if(!res_datap->msg_line_linkp){
553 parse_res_msg(ctxp->res_disp_list, res_datap, wp->cols-5, h_ng_word);
555 if(res_datap->msg_header_line_num <= 0){
556 if(!set_res_header((ctx_reslist_tp)wp->data,
557 res_datap, buf, sizeof(buf)/sizeof(buf[0]))){
558 res_datap->msg_header_line_num = 1;
563 num = nt_get_wc_count_within_colmns(
567 res_datap->msg_header_line_num++;
573 num = res_datap->msg_header_line_num;
574 num += res_datap->msg_line_num;
575 ctxp->cur_res_offset = num;
579 if(auto_scroll_state != AUTO_SCROLL_NONE){
580 result_state |= DISP_CMD_AUTO_SCROLL;
581 ctxp->auto_scroll = AUTO_SCROLL_DOWN;
583 ctxp->cur_res_offset++;
584 clistp = ctxp->res_disp_list;
585 for(i = 0; i < ctxp->res_num; i++){
586 if(i == ctxp->cur_res)
588 clistp = clistp->next;
590 if(i == ctxp->res_num)
592 res_datap = (res_data_tp)clistp->data;
593 if(!res_datap->msg_line_linkp){
594 parse_res_msg(ctxp->res_disp_list, res_datap, wp->cols-5, h_ng_word);
596 if(res_datap->msg_header_line_num <= 0){
597 if(!set_res_header((ctx_reslist_tp)wp->data,
598 res_datap, buf, sizeof(buf)/sizeof(buf[0]))){
599 res_datap->msg_header_line_num = 1;
604 num = nt_get_wc_count_within_colmns(
608 res_datap->msg_header_line_num++;
614 num = res_datap->msg_header_line_num;
615 num += res_datap->msg_line_num + 1;
616 if(ctxp->cur_res_offset >= num){
618 ctxp->cur_res_offset = 0;
623 if(auto_scroll_state != AUTO_SCROLL_NONE){
624 result_state |= DISP_CMD_AUTO_SCROLL;
625 ctxp->auto_scroll = AUTO_SCROLL_UP;
627 ctxp->cur_res_offset -= wp->lines;
628 if(ctxp->cur_res_offset >= 0){
632 clistp = ctxp->res_disp_list;
633 for(i = 0; i < ctxp->res_num; i++){
634 if(i == ctxp->cur_res)
636 clistp = clistp->next;
638 if(i == ctxp->res_num){
639 ctxp->cur_res_offset = 0;
643 res_datap = (res_data_tp)clistp->data;
644 if(!res_datap->msg_line_linkp){
645 parse_res_msg(ctxp->res_disp_list, res_datap, wp->cols-5, h_ng_word);
647 if(res_datap->msg_header_line_num <= 0){
648 if(!set_res_header((ctx_reslist_tp)wp->data,
649 res_datap, buf, sizeof(buf)/sizeof(buf[0]))){
650 res_datap->msg_header_line_num = 1;
655 num = nt_get_wc_count_within_colmns(
659 res_datap->msg_header_line_num++;
665 num = res_datap->msg_header_line_num;
666 num += res_datap->msg_line_num;
667 if(ctxp->cur_res_offset + num < 0){
668 ctxp->cur_res_offset += num;
670 clistp = clistp->prev;
673 ctxp->cur_res_offset += num;
678 ctxp->cur_res_offset = 0;
681 case NT_KEY_PAGEDOWN:
683 if(auto_scroll_state != AUTO_SCROLL_NONE){
684 result_state |= DISP_CMD_AUTO_SCROLL;
685 ctxp->auto_scroll = AUTO_SCROLL_DOWN;
687 clistp = ctxp->res_disp_list;
688 if(0 > ctxp->cur_res)
690 for(i = 0; i < ctxp->res_num; i++){
691 if(i == ctxp->cur_res)
693 clistp = clistp->next;
695 if(i == ctxp->res_num)
698 ctxp->cur_res_offset += wp->lines;
699 for( ; i < ctxp->res_num; i++){
700 res_datap = (res_data_tp)clistp->data;
701 if(!res_datap->msg_line_linkp){
702 parse_res_msg(ctxp->res_disp_list, res_datap, wp->cols-5, h_ng_word);
704 if(res_datap->msg_header_line_num <= 0){
705 if(!set_res_header((ctx_reslist_tp)wp->data,
706 res_datap, buf, sizeof(buf)/sizeof(buf[0]))){
707 res_datap->msg_header_line_num = 1;
712 num = nt_get_wc_count_within_colmns(
716 res_datap->msg_header_line_num++;
722 num = res_datap->msg_header_line_num;
723 num += res_datap->msg_line_num + 1;
724 if(num > ctxp->cur_res_offset){
728 ctxp->cur_res_offset -= num;
730 clistp = clistp->next;
735 if(ctxp->cur_res > ctxp->max_cur_res ||
736 (ctxp->cur_res == ctxp->max_cur_res &&
737 ctxp->cur_res_offset > ctxp->max_cur_offset)){
738 ctxp->cur_res = ctxp->max_cur_res;
739 ctxp->cur_res_offset = ctxp->max_cur_offset;
742 clistp = ctxp->res_disp_list;
745 for(i = 0; i < ctxp->res_num; i++){
746 if(i < ctxp->cur_res){
747 clistp = clistp->next;
751 if(rows == wp->lines)
754 res_datap = (res_data_tp)clistp->data;
756 if(!set_res_header((ctx_reslist_tp)wp->data,
757 res_datap, buf, sizeof(buf)/sizeof(buf[0]))){
761 num = nt_get_wc_count_within_colmns(buf, wp->cols);
763 if(ctxp->res_num == ctxp->prev_read_cnt)
765 else if(i+1 > ctxp->prev_read_cnt)
766 new_res_attr = WA_BOLD;
771 if(!nt_w_str_move(buf, sizeof(buf), num, 1))
773 if(res_offset >= ctxp->cur_res_offset){
774 wmove(wp->wp, rows, 0);
775 nt_add_wstr(wp->wp, buf, new_res_attr);
780 if(rows == wp->lines)
782 if(res_offset >= ctxp->cur_res_offset){
783 wmove(wp->wp, rows, 0);
784 nt_add_wnch(wp->wp, L' ', WA_UNDERLINE, 5);
785 nt_add_wnstr(wp->wp, buf + num + 1,
786 new_res_attr | WA_UNDERLINE,
793 if(res_offset >= ctxp->cur_res_offset){
794 wmove(wp->wp, rows, 0);
795 nt_add_wstr(wp->wp, buf,
796 new_res_attr | WA_UNDERLINE);
802 if(rows == wp->lines)
804 if(!res_datap->msg_line_linkp){
805 parse_res_msg(ctxp->res_disp_list, res_datap, wp->cols-5, h_ng_word);
807 if(0 == res_datap->msg_line_num)
810 link_curp = res_datap->msg_line_linkp;
813 cptr = (wchar_t*)link_curp->data;
814 if(res_offset >= ctxp->cur_res_offset){
815 wmove(wp->wp, rows, 5);
816 if(i == ctxp->sel_res_no &&
817 line_num == ctxp->sel_res_line){
818 /*fprintf(stderr, "hilighted no: %d, line: %d\n",
820 nt_add_wstr(wp->wp, cptr, WA_REVERSE);
822 nt_add_wstr(wp->wp, cptr, 0);
825 if(rows == wp->lines)
831 link_curp = link_curp->next;
832 }while(res_datap->msg_line_linkp != link_curp);
834 if(rows == wp->lines)
836 if(res_offset >= ctxp->cur_res_offset){
837 wmove(wp->wp, rows, 0);
838 nt_add_wnch(wp->wp, L' ', 0, wp->cols);
839 if(res_datap->cited_num_list){
840 cptr = nt_w_format_number_list(
841 res_datap->cited_num_list);
843 wmove(wp->wp, rows, 0);
844 nt_add_wnch(wp->wp, L' ', 0, 6);
845 nt_add_wstr(wp->wp, L"<<", 0);
846 nt_add_wnstr(wp->wp, cptr,
856 clistp = clistp->next;
863 static int get_id_num(ctx_reslist_tp ctxp, const wchar_t *misc)
869 const wchar_t *misc2;
870 nt_link_tp linkp, disp_list;
874 cptr = wcsstr(misc, L"ID:");
878 cptr = nt_w_trim(cptr);
882 disp_list = ctxp->res_disp_list;
885 datap = (res_data_tp)linkp->data;
886 misc2 = nt_res_get_misc(datap->h_res);
887 if(wcsstr(misc2, cptr))
890 }while(linkp != disp_list);
896 static BOOL set_res_header(ctx_reslist_tp ctxp, res_data_tp res_datap,
897 wchar_t *buf, size_t buf_len)
899 const wchar_t *name, *mail, *misc;
902 seq_no = nt_res_get_seq_number(res_datap->h_res);
903 name = nt_res_get_name(res_datap->h_res);
904 mail = nt_res_get_mail(res_datap->h_res);
905 misc = nt_res_get_misc(res_datap->h_res);
907 id_num = res_datap->id_num;
909 id_num = get_id_num(ctxp, misc);
910 res_datap->id_num = id_num;
913 if(-1 == swprintf(buf, buf_len-1,
914 L"%5d. %ls %ls %ls", seq_no, name, mail, misc)){
918 if(-1 == swprintf(buf, buf_len-1,
919 L"%5d. %ls %ls %ls(%d)", seq_no, name, mail, misc, id_num)){
926 static int parse_cmd1(const char *param, const char **end)
933 if(!nt_strtok(param, ' ', &start, end))
940 if(0 == strncmp(NT_COMMAND1_WRITE_MSG_1, start,len) ||
941 0 == strncmp(NT_COMMAND1_WRITE_MSG_2, start,len)){
943 }else if(0 == strncmp(NT_COMMAND1_JMP_NEW_1,start,len) ||
944 0 == strncmp(NT_COMMAND1_JMP_NEW_2, start,len)){
945 return NT_CMD_JMP_NEW;
946 }else if(0 == strncmp(NT_COMMAND1_TREE_1, start,len) ||
947 0 == strncmp(NT_COMMAND1_TREE_2, start,len)){
949 }else if(0 == strncmp(NT_COMMAND1_ID_1, start,len) ||
950 0 == strncmp(NT_COMMAND1_ID_2, start,len)){
952 }else if(0 == strncmp(NT_COMMAND1_SEARCH_1,param,
953 strlen(NT_COMMAND1_SEARCH_1)) ||
954 0 == strncmp(NT_COMMAND1_SEARCH_2,param,
955 strlen(NT_COMMAND1_SEARCH_2))){
956 return NT_CMD_SEARCH_THREAD;
957 }else if(0 == strncmp(NT_COMMAND1_FAVORITE_1,param,
958 strlen(NT_COMMAND1_FAVORITE_1)) ||
959 0 == strncmp(NT_COMMAND1_FAVORITE_2,param,
960 strlen(NT_COMMAND1_FAVORITE_2))){
961 return NT_CMD_FAVORITE;
962 }else if(0 == strncmp(NT_COMMAND1_HISTORY_1,param,
963 strlen(NT_COMMAND1_HISTORY_1)) ||
964 0 == strncmp(NT_COMMAND1_HISTORY_2,param,
965 strlen(NT_COMMAND1_HISTORY_2))){
966 return NT_CMD_HISTORY;
967 }else if(0 == strncmp(NT_COMMAND1_AUTOSCROLL_1,param,
968 strlen(NT_COMMAND1_AUTOSCROLL_1)) ||
969 0 == strncmp(NT_COMMAND1_AUTOSCROLL_2,param,
970 strlen(NT_COMMAND1_AUTOSCROLL_2))){
971 return NT_CMD_AUTO_SCROLL;
972 }else if(0 == strncmp(NT_COMMAND1_NG_WORD_1,param,len) ||
973 0 == strncmp(NT_COMMAND1_NG_WORD_2,param, len)){
974 if(!nt_strtok(*end, ' ', &start, end))
975 return NT_CMD_EDT_NGWORD;
979 return NT_CMD_EDT_NGWORD;
981 return NT_CMD_ADD_NGWORD;
982 }else if(0 == strncmp(NT_COMMAND1_NG_NAME_1,param,len) ||
983 0 == strncmp(NT_COMMAND1_NG_NAME_2,param, len)){
984 if(!nt_strtok(*end, ' ', &start, end))
985 return NT_CMD_EDT_NGNAME;
989 return NT_CMD_EDT_NGNAME;
991 return NT_CMD_ADD_NGNAME;
992 }else if(0 == strncmp(NT_COMMAND1_NG_ID_1,param,len)){
993 if(!nt_strtok(*end, ' ', &start, end))
994 return NT_CMD_EDT_NGID;
998 return NT_CMD_EDT_NGID;
1000 return NT_CMD_ADD_NGID;
1005 static ctx_reslist_tp init_context(nt_2ch_selected_item_handle h_select,
1006 nt_usr_db_handle usr_db_handle)
1008 nt_thread_handle h_thread;
1009 ctx_reslist_tp ctxp;
1010 const wchar_t *board_name, *dat_name;
1013 board_name = nt_2ch_selected_item_get_board_name(h_select);
1014 dat_name = nt_2ch_selected_item_get_thread_dat_name(h_select);
1018 ctxp = (ctx_reslist_tp)calloc(1,sizeof(ctx_reslist_t));
1023 h_thread = nt_get_selected_thread(h_select);
1029 ctxp->cur_res_offset = 0;
1030 ctxp->max_cur_res = -1;
1031 ctxp->max_cur_offset = -1;
1032 ctxp->selected_num_stackp = nt_stack_alloc();
1033 ctxp->regex_init = FALSE;
1034 ctxp->sel_res_no = -1;
1035 ctxp->sel_res_line = -1;
1036 ctxp->child_ctx_stackp = NULL;
1037 ctxp->prev_state = DISP_STATE_THREADTITLE;
1038 ctxp->auto_scroll = AUTO_SCROLL_NONE;
1040 b_result = reslist_clone(h_thread, ctxp);
1041 nt_thread_release_ref(h_thread);
1043 free_reslist_ctx(ctxp);
1047 ctxp->prev_read_cnt =
1048 nt_usr_db_update_read_count(usr_db_handle,
1049 board_name, dat_name,
1050 ctxp->res_num, NULL);
1051 if(ctxp->prev_read_cnt < 0)
1052 ctxp->prev_read_cnt = 0;
1053 if(ctxp->prev_read_cnt > 0){
1054 ctxp->cur_res = ctxp->prev_read_cnt;
1060 static ctx_reslist_tp init_sub_context(ctx_reslist_tp ctxp, nt_link_tp num_listp)
1062 ctx_reslist_tp child_ctxp;
1063 child_ctxp = (ctx_reslist_tp)calloc(1,sizeof(ctx_reslist_t));
1067 child_ctxp->cur_res = 0;
1068 child_ctxp->cur_res_offset = 0;
1069 child_ctxp->max_cur_res = -1;
1070 child_ctxp->max_cur_offset = -1;
1071 child_ctxp->selected_num_stackp = nt_stack_alloc();
1072 child_ctxp->regex_init = FALSE;
1073 child_ctxp->sel_res_no = -1;
1074 child_ctxp->sel_res_line = -1;
1075 child_ctxp->child_ctx_stackp = NULL;
1076 child_ctxp->prev_read_cnt = 0;
1077 child_ctxp->prev_state = ctxp->prev_state;
1079 if(!reslist_copy(ctxp, child_ctxp, num_listp)){
1080 nt_stack_free(child_ctxp->selected_num_stackp, NULL);
1085 if(!ctxp->child_ctx_stackp){
1086 ctxp->child_ctx_stackp = nt_stack_alloc();
1087 if(!ctxp->child_ctx_stackp){
1088 nt_stack_free(child_ctxp->selected_num_stackp, NULL);
1093 if(!nt_stack_push(ctxp->child_ctx_stackp, child_ctxp)){
1094 nt_stack_free(child_ctxp->selected_num_stackp, NULL);
1101 static const wchar_t *get_id(const wchar_t *source)
1103 const wchar_t *cptr;
1106 cptr = wcsstr(source, L"ID:");
1110 if(cptr[0] == L'\0' || cptr[0] == L'?')
1115 static BOOL reslist_clone(nt_thread_handle h_thread, ctx_reslist_tp ctxp)
1117 nt_enum_handle h_enum_res;
1119 nt_res_handle h_res;
1123 h_enum_res = nt_thread_get_res_enum(h_thread);
1128 while(NULL != (h_res = (nt_res_handle)nt_enum_fetch(h_enum_res))){
1129 datap = (res_data_tp)calloc(1, sizeof(res_data_t));
1132 datap->h_res = h_res;
1133 datap->res_msg = nt_parse_res_msg(
1134 nt_res_get_msg(h_res),
1135 &datap->cite_num_list);
1136 if(!datap->res_msg){
1137 datap->res_msg = nt_w_str_clone(NT_ERR_MSG_DECODE_TEXT);
1139 linkp = nt_link_add_data(ctxp->res_disp_list, datap);
1141 free(datap->res_msg);
1145 if(!ctxp->res_disp_list)
1146 ctxp->res_disp_list = linkp;
1147 nt_res_add_ref(h_res);
1151 nt_enum_unset(h_enum_res);
1152 ctxp->res_num = num_res;
1156 static BOOL reslist_copy(ctx_reslist_tp ctxp, ctx_reslist_tp copy_ctxp, nt_link_tp num_listp)
1158 nt_link_tp linkp, r_linkp;
1160 nt_res_handle h_res;
1165 assert(ctxp && copy_ctxp && num_listp);
1170 seq_no = linkp->n_data;
1171 d_linkp = ctxp->res_disp_list;
1173 datap = (res_data_tp)d_linkp->data;
1174 h_res = datap->h_res;
1175 if(seq_no == nt_res_get_seq_number(h_res)){
1176 r_linkp = nt_link_add_data(copy_ctxp->res_disp_list, datap);
1178 if(!copy_ctxp->res_disp_list)
1179 copy_ctxp->res_disp_list = r_linkp;
1184 d_linkp = d_linkp->next;
1185 }while(d_linkp != ctxp->res_disp_list);
1186 linkp = linkp->next;
1187 }while(linkp != num_listp);
1188 copy_ctxp->res_num = num_res;
1192 void free_reslist_ctx(void *ptr)
1194 ctx_reslist_tp ctxp;
1198 ctxp = (ctx_reslist_tp)ptr;
1199 nt_stack_free(ctxp->selected_num_stackp, &int_ptr_free);
1200 if(ctxp->regex_init)
1201 regfree(&(ctxp->regex));
1202 if(ctxp->res_disp_list){
1203 nt_all_link_free(ctxp->res_disp_list, res_msg_free);
1205 stackp = ctxp->child_ctx_stackp;
1207 nt_stack_free(stackp, free_reslist_sub_ctx);
1212 static void free_disp_lines_ctx(void *ptr)
1214 ctx_reslist_tp ctxp;
1217 res_data_tp res_datap;
1220 ctxp = (ctx_reslist_tp)ptr;
1221 if(ctxp->res_disp_list){
1222 linkp = ctxp->res_disp_list;
1224 res_datap = (res_data_tp)linkp->data;
1225 if(res_datap->msg_line_linkp){
1226 free(res_datap->msg_line_linkp->data);
1227 nt_all_link_free(res_datap->msg_line_linkp, NULL);
1228 res_datap->msg_line_linkp = NULL;
1230 res_datap->msg_line_num = 0;
1231 linkp = linkp->next;
1232 }while(linkp != ctxp->res_disp_list);
1234 stackp = ctxp->child_ctx_stackp;
1236 nt_stack_free(stackp, free_reslist_sub_ctx);
1237 ctxp->child_ctx_stackp = NULL;
1241 static void free_reslist_sub_ctx(void *ptr)
1243 ctx_reslist_tp ctxp;
1246 ctxp = (ctx_reslist_tp)ptr;
1247 nt_stack_free(ctxp->selected_num_stackp, &int_ptr_free);
1248 if(ctxp->regex_init)
1249 regfree(&(ctxp->regex));
1250 if(ctxp->res_disp_list){
1251 nt_all_link_free(ctxp->res_disp_list, NULL);
1256 static void int_ptr_free(void *ptr)
1261 static void res_msg_free(void *ptr)
1263 nt_link_tp curp, nextp;
1264 res_data_tp res_datap;
1268 res_datap = (res_data_tp)ptr;
1270 free(res_datap->res_msg);
1272 nt_res_release_ref(res_datap->h_res);
1274 if(res_datap->cite_num_list)
1275 nt_all_link_free(res_datap->cite_num_list, NULL);
1276 if(res_datap->cited_num_list)
1277 nt_all_link_free(res_datap->cited_num_list, NULL);
1279 if(res_datap->msg_line_linkp){
1280 curp = res_datap->msg_line_linkp->next;
1281 while(curp != res_datap->msg_line_linkp){
1283 /* We must not free the data pointer
1284 * except the first one
1285 * because they're alocated as a same block.
1286 * This is wrong --> free(curp->data);
1293 res_datap->msg_line_linkp = NULL;
1300 static nt_link_tp get_cited_num_list(nt_link_tp res_listp, int seq_no)
1302 nt_link_tp linkp, wrkp, wrk2p;
1303 nt_link_tp num_listp;
1304 res_data_tp res_datap;
1310 res_datap = (res_data_tp)linkp->data;
1311 if(res_datap->cite_num_list){
1312 wrkp = res_datap->cite_num_list;
1314 if(wrkp->n_data == seq_no){
1315 wrk2p = nt_link_add_n_data(
1317 nt_res_get_seq_number(res_datap->h_res));
1318 if(wrk2p && !num_listp)
1323 }while(wrkp != res_datap->cite_num_list);
1325 linkp = linkp->next;
1326 }while(linkp != res_listp);
1328 nt_link_n_sort(&num_listp, nt_comp_int);
1332 static int parse_res_msg(nt_link_tp disp_res_list,
1333 res_data_tp res_datap, size_t colmns,
1334 nt_ng_word_handle h_ngword)
1336 int i, len, start, lines, nwrite;
1338 wchar_t *buf, *cptr, *srcp, *wrk_buf;
1339 const wchar_t *name, *id, *misc;
1344 int buf_idx, buf_size;
1345 const int delta = 64;
1348 assert(res_datap->h_res);
1349 assert(res_datap->res_msg);
1351 //res_msg_free(res_datap);
1352 res_datap->msg_line_num = 0;
1354 name = nt_res_get_name(res_datap->h_res);
1355 misc = nt_res_get_misc(res_datap->h_res);
1361 if(name && NG_ITEM_NAME ==
1362 ng_word_match(h_ngword, NG_ITEM_NAME, name,
1363 match, sizeof(match)/sizeof(wchar_t))){
1365 }else if(id && NG_ITEM_ID ==
1366 ng_word_match(h_ngword, NG_ITEM_ID, id,
1367 match, sizeof(match)/sizeof(wchar_t))){
1369 }else if(NG_ITEM_MSG == ng_word_match(h_ngword, NG_ITEM_MSG,
1371 match, sizeof(match)/sizeof(wchar_t))){
1375 len = wcslen(cptr) + wcslen(match) + 1;
1376 buf = malloc(len*sizeof(wchar_t));
1379 swprintf(buf, len, L"%ls%ls", cptr, match);
1380 nwrite = nt_get_wc_count_within_colmns(buf, colmns);
1385 buf[nwrite] = L'\0';
1386 res_datap->msg_line_num = 1;
1387 res_datap->msg_line_linkp = nt_link_add_data(NULL, buf);
1391 srcp = res_datap->res_msg;
1396 buf_size = len + delta;
1400 buf = malloc(sizeof(wchar_t) * (buf_size));
1409 for(i = 0; i < len; i++){
1414 buf[buf_idx] = L'\0';
1416 linkp = nt_link_add_data(
1417 res_datap->msg_line_linkp, cptr);
1420 if(res_datap->msg_line_linkp == NULL)
1421 res_datap->msg_line_linkp = linkp;
1428 if(ch <= 128 || (ch >= 0xff66 && ch <= 0xff9d))
1433 if(consume_colmns + offset > colmns){
1435 buf[buf_idx] = L'\0';
1436 linkp = nt_link_add_data(
1437 res_datap->msg_line_linkp, cptr);
1440 if(res_datap->msg_line_linkp == NULL)
1441 res_datap->msg_line_linkp = linkp;
1449 consume_colmns += offset;
1455 if(buf_idx >= (buf_size-1)){
1456 wrk_buf = nt_w_str_resize(buf, buf_size, (buf_size + delta));
1459 res_datap->msg_line_linkp, NULL);
1461 res_datap->msg_line_linkp = NULL;
1469 if(consume_colmns > 0){
1471 buf[buf_idx] = L'\0';
1472 linkp = nt_link_add_data(
1473 res_datap->msg_line_linkp, cptr);
1475 if(res_datap->msg_line_linkp == NULL)
1476 res_datap->msg_line_linkp = linkp;
1480 res_datap->msg_line_num = lines;
1482 if(!res_datap->cited_num_list){
1483 res_datap->cited_num_list =
1484 get_cited_num_list(disp_res_list,
1485 nt_res_get_seq_number(res_datap->h_res));
1490 static BOOL search_line_asc(regex_t *regexp, nt_link_tp reslistp,
1491 int *sel_res_no, int *sel_res_line, int column, nt_ng_word_handle h_ngword)
1493 nt_link_tp clistp, listp;
1495 res_data_tp res_datap;
1496 int cur, line, res_no, res_line;
1500 regmatch_t pmatch[5];
1508 res_no = *sel_res_no;
1509 if(*sel_res_line < 0)
1512 res_line = *sel_res_line + 1;
1518 res_datap = (res_data_tp)clistp->data;
1519 //resp = res_datap->resp;
1520 if(!res_datap->msg_line_linkp)
1521 parse_res_msg(reslistp, res_datap, column, h_ngword);
1522 listp = res_datap->msg_line_linkp;
1525 if(line >= res_line){
1526 cptr = (wchar_t*)listp->data;
1527 if(0 < wcstombs(buf, cptr, sizeof(buf))){
1528 if(0 == regexec(regexp, buf,
1529 nmatch, pmatch, 0)){
1530 *sel_res_line = line;
1537 listp = listp->next;
1538 }while(listp != res_datap->msg_line_linkp);
1542 clistp = clistp->next;
1543 }while(clistp != reslistp);
1551 res_datap = (res_data_tp)clistp->data;
1552 if(!res_datap->msg_line_linkp)
1553 parse_res_msg(reslistp, res_datap, column, h_ngword);
1554 listp = res_datap->msg_line_linkp;
1557 if(line >= res_line){
1558 cptr = (wchar_t*)listp->data;
1559 if(0 < wcstombs(buf, cptr, sizeof(buf))){
1560 if(0 == regexec(regexp, buf,
1561 nmatch, pmatch, 0)){
1562 *sel_res_line = line;
1569 listp = listp->next;
1570 }while(listp != res_datap->msg_line_linkp);
1573 clistp = clistp->next;
1574 }while(clistp != reslistp);
1578 static BOOL search_line_desc(regex_t *regexp, ctx_reslist_tp ctxp,
1579 nt_link_tp reslistp,
1580 int *sel_res_no, int *sel_res_line, int column,
1581 nt_ng_word_handle h_ngword)
1583 nt_link_tp clistp, listp;
1585 res_data_tp res_datap;
1586 int cur, line, res_no, res_line;
1590 regmatch_t pmatch[5];
1595 if(*sel_res_no < 0){
1596 res_no = ctxp->res_num - 1;
1598 res_no = *sel_res_no;
1600 if(*sel_res_line < 0){
1603 res_line = *sel_res_line - 1;
1606 cur = ctxp->res_num - 1;
1607 clistp = reslistp->prev;
1610 res_datap = (res_data_tp)clistp->data;
1611 //resp = res_datap->resp;
1612 if(!res_datap->msg_line_linkp)
1613 parse_res_msg(reslistp, res_datap, column, h_ngword);
1614 listp = res_datap->msg_line_linkp->prev;
1615 line = res_datap->msg_line_num - 1;
1617 if(line <= res_line){
1618 cptr = (wchar_t*)listp->data;
1619 if(0 < wcstombs(buf, cptr, sizeof(buf))){
1620 if(0 == regexec(regexp, buf,
1621 nmatch, pmatch, 0)){
1622 *sel_res_line = line;
1629 listp = listp->prev;
1630 }while(listp != res_datap->msg_line_linkp->prev);
1631 res_line = res_datap->msg_line_num - 1;
1634 clistp = clistp->prev;
1635 }while(clistp != reslistp->prev);
1637 cur = ctxp->res_num - 1;
1638 clistp = reslistp->prev;
1643 res_datap = (res_data_tp)clistp->data;
1644 //resp = (nt_res_tp)clistp->data;
1645 if(!res_datap->msg_line_linkp)
1646 parse_res_msg(reslistp, res_datap, column, h_ngword);
1647 listp = res_datap->msg_line_linkp->prev;
1648 line = res_datap->msg_line_num - 1;
1650 if(line >= res_line){
1651 cptr = (wchar_t*)listp->data;
1652 if(0 < wcstombs(buf, cptr, sizeof(buf))){
1653 if(0 == regexec(regexp, buf,
1654 nmatch, pmatch, 0)){
1655 *sel_res_line = line;
1662 listp = listp->prev;
1663 }while(listp != res_datap->msg_line_linkp->prev);
1664 res_line = res_datap->msg_line_num - 1;
1666 clistp = clistp->prev;
1667 }while(clistp != reslistp->prev);
1672 static nt_link_tp parse_id_list(ctx_reslist_tp ctxp, const char *param)
1674 nt_link_tp linkp, disp_list;
1675 nt_link_tp wrkp, num_linkp;
1679 const wchar_t *misc;
1681 const char *start, *end;
1682 res_data_tp res_datap;
1683 nt_res_handle h_res;
1687 assert(ctxp->res_disp_list);
1689 if(!nt_strtok(param, ' ', &start, &end))
1696 strncat(buf, start, len);
1698 if((size_t)-1 == mbstowcs(wc, buf, sizeof(wc)/sizeof(wchar_t)-1))
1702 disp_list = ctxp->res_disp_list;
1705 res_datap = (res_data_tp)linkp->data;
1706 h_res = res_datap->h_res;
1707 misc = nt_res_get_misc(h_res);
1708 cptr = wcsstr(misc, wc);
1710 seq_no = nt_res_get_seq_number(h_res);
1711 wrkp = nt_link_add_n_data(num_linkp, seq_no);
1715 linkp = linkp->next;
1716 }while(linkp != disp_list);
1722 static nt_link_tp parse_tree_list(ctx_reslist_tp ctxp, const char *param)
1724 nt_link_tp linkp, disp_list;
1725 nt_link_tp wrkp, num_linkp;
1727 const char *start, *end;
1728 res_data_tp res_datap;
1729 nt_res_handle h_res;
1733 assert(ctxp->res_disp_list);
1735 if(!nt_strtok(param, ' ', &start, &end))
1744 num_linkp = nt_link_add_n_data(NULL, num);
1748 disp_list = ctxp->res_disp_list;
1751 res_datap = (res_data_tp)linkp->data;
1752 h_res = res_datap->h_res;
1753 if(num == nt_res_get_seq_number(h_res)){
1754 if(res_datap->cite_num_list){
1755 wrkp = res_datap->cite_num_list;
1757 if(wrkp->n_data < num)
1758 search_up_tree(wrkp->n_data, disp_list, &num_linkp);
1760 }while(wrkp != res_datap->cite_num_list);
1762 if(res_datap->cited_num_list){
1763 wrkp = res_datap->cited_num_list;
1765 if(wrkp->n_data > num)
1766 search_down_tree(wrkp->n_data, disp_list, &num_linkp);
1768 }while(wrkp != res_datap->cited_num_list);
1772 linkp = linkp->next;
1773 }while(linkp != disp_list);
1775 nt_link_n_sort(&num_linkp, nt_comp_int);
1778 static void search_up_tree(int seq_no, nt_link_tp disp_list, nt_link_tp *num_linkp)
1780 nt_link_tp linkp, wrkp;
1781 nt_link_add_n_data(*num_linkp, seq_no);
1782 res_data_tp res_datap;
1783 nt_res_handle h_res;
1787 res_datap = (res_data_tp)linkp->data;
1788 h_res = res_datap->h_res;
1789 if(seq_no == nt_res_get_seq_number(h_res)){
1790 if(res_datap->cite_num_list){
1791 wrkp = res_datap->cite_num_list;
1793 if(wrkp->n_data < seq_no)
1794 search_up_tree(wrkp->n_data, disp_list, num_linkp);
1796 }while(wrkp != res_datap->cite_num_list);
1800 linkp = linkp->next;
1801 }while(linkp != disp_list);
1804 static void search_down_tree(int seq_no, nt_link_tp disp_list, nt_link_tp *num_linkp)
1806 nt_link_tp linkp, wrkp;
1807 nt_link_add_n_data(*num_linkp, seq_no);
1808 res_data_tp res_datap;
1809 nt_res_handle h_res;
1813 res_datap = (res_data_tp)linkp->data;
1814 h_res = res_datap->h_res;
1815 if(seq_no == nt_res_get_seq_number(h_res)){
1816 if(res_datap->cited_num_list){
1817 wrkp = res_datap->cited_num_list;
1819 if(wrkp->n_data > seq_no)
1820 search_down_tree(wrkp->n_data, disp_list, num_linkp);
1822 }while(wrkp != res_datap->cited_num_list);
1826 linkp = linkp->next;
1827 }while(linkp != disp_list);