blob: b0bb349aedc3ed3cd9dedc80106707092dad6c1a (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
#include "todo.h"
#ifdef CONFIG_TODO
int bbs_todo( term_screen *ts, const char *fname)
{
int ret=-1;
int ret_len;
size_t in_size=0;
char *in_buf=NULL;
int quit_loop=0;
if ( ts == NULL )
return ret;
if ( fname == NULL )
fname = CONFIG_TODO_DEFAULT_FILE;
//LOAD DATA FROM FILE TO LINKED LIST
List *todo_list = llist_new();
f_file *file = f_file_open( fname, F_FILE_READ );
if ( file != NULL )
{
const int l_s = 128;
int r_v;
{
cycle0:;
char *l = malloc( l_s );
r_v = f_file_readl( file, l_s, l );
if ( r_v < 0 ) goto exit_cycle0;
l[r_v] = '\0';
llist_push( todo_list, l );
goto cycle0;
exit_cycle0:;
}
}
f_file_close( file );
//LOAD DATA FROM FILE TO LINKED LIST
//END
//log that someone use todo
bbs_log( NULL, "we are in todo" );
while( (quit_loop == 0) )
{
printf("(S)how todo list,(Q)uit:");
ret_len = getline( &in_buf, &in_size, stdin );
if ( ret_len > 0 )
{
char ch = in_buf[0];
switch( ch )
{
case 'q':
case 'Q':
quit_loop = 1;
ret = 0;
break;
case 's':
case 'S':
{
struct ListNode *iter=todo_list->first;
int cnt = 1;
while (iter != NULL)
{
printf( "[%02d] -> %s\n", cnt, (char *)iter->val);
cnt += 1;
iter = iter->next;
}
}
break;
default:
printf("Try more\n");
}
}
}
llist_free( todo_list );
return ret;
}
#endif
|