lftp
4.4.6
About:
lftp
is a command line ftp client (FTP, HTTP, ssl support, background transfer, reget, reput, ...)
Fossies
Dox
:
lftp-4.4.6.tar.gz
("inofficial" and yet experimental doxygen-generated source code documentation)
Main Page
Modules
Classes
Files
File List
File Members
All
Classes
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
misc.h
Go to the documentation of this file.
1
/*
2
* lftp - file transfer program
3
*
4
* Copyright (c) 1996-2013 by Alexander V. Lukyanov (lav@yars.free.net)
5
*
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 3 of the License, or
9
* (at your option) any later version.
10
*
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
15
*
16
* You should have received a copy of the GNU General Public License
17
* along with this program. If not, see <http://www.gnu.org/licenses/>.
18
*/
19
20
#ifndef MISC_H
21
#define MISC_H
22
23
#include "
trio.h
"
24
#include <sys/types.h>
25
#include <sys/time.h>
26
#ifdef TIME_WITH_SYS_TIME
27
# include <time.h>
28
#endif
29
#include <stdarg.h>
30
31
class
xstring
;
32
33
// expands tilde; returns pointer to static data
34
const
char
*
expand_home_relative
(
const
char
*);
35
36
// returns ptr to last path element
37
const
char
*
basename_ptr
(
const
char
*);
38
static
inline
char
*
basename_ptr
(
char
*f) {
39
return
const_cast<
char
*
>
(
basename_ptr
(const_cast<const char *>(f)));
40
}
41
42
// glues file to dir; returns pointer to static storage
43
const
char
*
dir_file
(
const
char
*dir,
const
char
*file);
44
45
// glues file to given url; returns pointer to static storage
46
const
char
*
url_file
(
const
char
*
url
,
const
char
*file);
47
48
const
char
*
output_file_name
(
const
char
*
src
,
const
char
*dst,
bool
dst_local,
49
const
char
*dst_base,
bool
make_dirs);
50
51
const
char
*
squeeze_file_name
(
const
char
*name,
int
w
);
52
53
// mkdir -p
54
int
create_directories
(
char
*);
55
56
// rm -rf
57
void
truncate_file_tree
(
const
char
*dir);
58
59
/* returns file descriptor terminal width; -1 on error, 0 on N/A */
60
int
fd_width
(
int
fd);
61
62
/* returns true if current pgrp is the foreground pgrp of controlling tty
63
* or if the fg pgrp is unknown */
64
bool
in_foreground_pgrp
();
65
66
// returns malloc'ed cwd no matter how long it is
67
// returns 0 on error.
68
char
*
xgetcwd
();
69
70
int
percent
(off_t offset,off_t size);
71
72
#define find_char(buf,len,ch) ((const char *)memchr(buf,ch,len))
73
74
extern
const
char
month_names
[][4];
75
76
int
parse_month
(
const
char
*);
77
int
parse_perms
(
const
char
*);
78
const
char
*
format_perms
(
int
p
);
79
int
parse_year_or_time
(
const
char
*year_or_time,
int
*year,
int
*hour,
int
*minute);
80
int
guess_year
(
int
month,
int
day,
int
hour,
int
minute);
81
82
time_t
mktime_from_utc
(
const
struct
tm
*);
83
time_t
mktime_from_tz
(
struct
tm
*,
const
char
*tz);
84
85
bool
re_match
(
const
char
*line,
const
char
*
a
,
int
flags=0);
86
87
struct
subst_t
{
88
char
from
;
89
const
char
*
to
;
90
};
91
92
/* Subst changes escape sequences to given strings, also substitutes \nnn
93
* with corresponding character. Returns allocated buffer to be free'd */
94
char
*
Subst
(
const
char
*txt,
const
subst_t
*
s
);
95
96
/* uses gettimeofday if available */
97
void
xgettimeofday
(time_t *sec,
int
*usec);
98
99
/* returns malloc'd date */
100
char
*
xstrftime
(
const
char
*format,
const
struct
tm
*
tm
);
101
102
void
strip_trailing_slashes
(
xstring
& fn);
103
xstring
&
dirname_modify
(
xstring
& fn);
104
xstring
&
dirname
(
const
char
*path);
// returns a tmp
105
106
/* returns last character of string or \0 if string is empty */
107
char
last_char
(
const
char
*str);
108
109
int
base64_length
(
int
len);
110
void
base64_encode
(
const
char
*
s
,
char
*store,
int
length);
111
112
bool
temporary_network_error
(
int
e);
113
114
CDECL
const
char
*
get_home
();
115
CDECL
const
char
*
get_lftp_config_dir
();
116
CDECL
const
char
*
get_lftp_data_dir
();
117
CDECL
const
char
*
get_lftp_cache_dir
();
118
119
const
char
*
memrchr
(
const
char
*buf,
char
c
,
size_t
len);
120
static
inline
char
*
memrchr
(
char
*buf,
char
c
,
size_t
len) {
121
return
const_cast<
char
*
>
(
memrchr
(const_cast<const char*>(buf),c,len));
122
}
123
124
const
xstring
&
shell_encode
(
const
char
*);
125
void
remove_tags
(
char
*buf);
126
void
rtrim
(
char
*
s
);
127
128
void
random_init
();
129
double
random01
();
130
131
const
char
*
get_nodename
();
132
133
#define ListAdd(type,chain,this,next) \
134
do { \
135
this->next=chain; \
136
chain=this; \
137
} while(0)
138
139
#define ListScan(type,chain,next) \
140
for(type *scan=chain; scan; scan=scan->next)
141
142
#define ListScanPtr(type,chain,next) \
143
for(type **scan=&chain; *scan; scan=&scan[0]->next)
144
145
#define ListDel(type,chain,this,next) \
146
do { \
147
ListScanPtr(type,chain,next) \
148
if(*scan==this) \
149
{ \
150
*scan=scan[0]->next; \
151
break; \
152
} \
153
} while(0)
154
155
#endif // MISC_H
lftp-4.4.6
src
misc.h
Generated by
1.8.3.1-20130512