blob: 258f3a5d919ad188ba1f5502e682d6a2ea8269c6 (
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
|
#include <HTUtils.h>
#include <LYGlobalDefs.h>
#include <LYUtils.h>
#include <LYClean.h>
#include <LYCurses.h>
#include <LYStrings.h>
#include <LYTraversal.h>
#include <LYexit.h>
#include <LYLeaks.h>
/* routines to handle special traversal feature */
static void final_perror(const char *msg, BOOLEAN clean_flag)
{
int saved_errno = errno;
if (LYCursesON) {
if (clean_flag)
cleanup();
else
stop_curses();
}
set_errno(saved_errno);
perror(msg);
}
static void exit_with_perror(const char *msg)
{
final_perror(msg, TRUE);
exit_immediately(EXIT_FAILURE);
}
BOOLEAN lookup_link(char *target)
{
FILE *ifp;
char *buffer = NULL;
char *line = NULL;
int result = FALSE;
if ((ifp = fopen(TRAVERSE_FILE, TXT_R)) == NULL) {
if ((ifp = LYNewTxtFile(TRAVERSE_FILE)) == NULL) {
exit_with_perror(CANNOT_OPEN_TRAV_FILE);
} else {
LYCloseOutput(ifp);
return (FALSE);
}
}
HTSprintf0(&line, "%s\n", target);
while (LYSafeGets(&buffer, ifp) != NULL) {
if (STREQ(line, buffer)) {
result = TRUE;
break;
}
} /* end while */
FREE(line);
FREE(buffer);
LYCloseInput(ifp);
return (BOOL) (result);
}
void add_to_table(char *target)
{
|