lftp
4.4.7
About:
lftp
is a command line ftp client (FTP, HTTP, ssl support, background transfer, reget, reput, ...)
Fossies
Dox
:
lftp-4.4.7.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
ArgV.cc
Go to the documentation of this file.
1
/*
2
* lftp - file transfer program
3
*
4
* Copyright (c) 1996-2012 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
#include <config.h>
21
22
#include "
misc.h
"
23
#include "
ArgV.h
"
24
25
ArgV::ArgV
(
const
char
*a0,
const
char
*args_c)
26
{
27
ind=0;
28
29
Append
(a0);
30
char
*
args
=
alloca_strdup
(args_c);
31
for
(
char
*t=strtok(args,
" "
); t; t=strtok(
NULL
,
" "
))
32
Append
(t);
33
}
34
ArgV::~ArgV
()
35
{
36
}
37
38
void
ArgV::seek
(
int
n
)
39
{
40
if
(n>=
Count
())
41
n=
Count
();
42
ind=
n
;
43
}
44
45
const
char
*
ArgV::getnext
()
46
{
47
const
char
*
s
=
String
(++ind);
48
if
(!s)
49
ind=
Count
();
// getcurr will return 0
50
return
s
;
51
}
52
53
void
ArgV::back
()
54
{
55
if
(ind>0)
56
ind--;
57
}
58
59
char
*
ArgV::Combine
(
int
start,
int
end)
const
60
{
61
xstring
res(
""
);
62
if
(!end)
63
end=
Count
();
64
if
(start>=end)
65
return
res.
borrow
();
66
for
(;;)
67
{
68
res.
append
(
getarg
(start++));
69
if
(start>=end)
70
return
(res.
borrow
());
71
res.
append
(
' '
);
72
}
73
}
74
75
int
ArgV::getopt_long
(
const
char
*opts,
const
struct
option
*lopts,
int
*lind)
76
{
77
optind
=ind;
78
int
r
=
::getopt_long
(
Count
(),
SetNonConst
(),opts,lopts,lind);
79
ind=
optind
;
80
return
r
;
81
}
82
83
const
char
*
ArgV::getopt_error_message
(
int
e)
84
{
85
if
(
optopt
>=32 &&
optopt
<127)
86
{
87
if
(e==
':'
)
88
return
xstring::format
(
"%s -- %c"
,
_
(
"option requires an argument"
),
optopt
);
89
else
90
return
xstring::format
(
"%s -- %c"
,
_
(
"invalid option"
),
optopt
);
91
}
92
if
(ind>1)
93
{
94
if
(e==
':'
)
95
return
xstring::format
(
_
(
"option `%s' requires an argument"
),
getarg
(ind-1));
96
else
97
return
xstring::format
(
_
(
"unrecognized option `%s'"
),
getarg
(ind-1));
98
}
99
return
_
(
"invalid option"
);
100
}
lftp-4.4.7
src
ArgV.cc
Generated by
1.8.4