2
* lftp - file transfer program
4
* Copyright (c) 1996-2007 by Alexander V. Lukyanov (lav@yars.free.net)
4
* Copyright (c) 1996-2015 by Alexander V. Lukyanov (lav@yars.free.net)
6
6
* This program is free software; you can redistribute it and/or modify
7
7
* it under the terms of the GNU General Public License as published by
14
14
* GNU General Public License for more details.
16
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
* along with this program. If not, see <http://www.gnu.org/licenses/>.
21
/* $Id: CmdExec.h,v 1.70 2009/07/17 12:48:41 lav Exp $ */
56
53
virtual void Fg() {}
57
54
virtual void Bg() {}
56
virtual bool IsInteractive() const { return false; }
60
59
extern CmdFeeder *lftp_feeder; // feeder to use after 'lftp' command
62
class CmdExec : public SessionJob
61
class CmdExec : public SessionJob, public ResClient
65
64
// current command data
146
150
void ReuseSavedSession();
147
151
void RevertToSavedSession();
153
void init(LocalDirectory *c);
150
156
void FeedCmd(const char *c);
151
157
void FeedArgV(const ArgV *,int start=0);
152
158
void PrependCmd(const char *c);
153
159
void ExecParsed(ArgV *a,FDStream *o=0,bool b=false);
154
static int unquote(char *buf,const char *str); // returns buf length
155
static const char *unquote(const char *str);
156
static bool needs_quotation(const char *buf);
160
static bool needs_quotation(const char *buf,int len);
161
static bool needs_quotation(const char *buf) { return needs_quotation(buf,strlen(buf)); }
157
162
static bool quotable(char c,char in_quotes);
158
163
static bool is_space(char c) { return c==' ' || c=='\t'; }
159
164
static bool is_quote(char c) { return c=='"' || c=='\''; }
160
165
void FeedQuoted(const char *c);
163
172
void EmptyCmds();
164
173
bool WriteCmds(int fd) const;
165
174
bool ReadCmds(int fd); // does not clear queue before reading (appends)
176
void AddNewJob(Job *new_job);
167
177
void SuspendJob(Job *j);
169
179
CmdExec(FileAccess *s,LocalDirectory *c);
180
CmdExec(CmdExec *parent);
172
183
bool Idle(); // when we have no command running and command buffer is empty
174
int ExitCode() { return exit_code; }
185
int ExitCode() { return failed_exit_code ? failed_exit_code : exit_code; }
176
void PrintStatus(int,const char *prefix="\t");
187
xstring& FormatStatus(xstring&,int,const char *prefix="\t");
177
188
void ShowRunStatus(const SMTaskRef<StatusLine>& s);
178
189
int AcceptSig(int sig);
213
225
void top_vfprintf(FILE *file,const char *f,va_list v);
215
227
void SetInteractive(bool i);
228
void SetInteractive();
216
229
void SetTopLevel()
221
235
void SetStatusLine(StatusLine *s) { status_line=s; }
222
236
void SetAutoTerminateInBackground(bool b) { auto_terminate_in_bg=b; }
233
247
Job *builtin_glob();
234
248
Job *builtin_queue();
235
249
Job *builtin_queue_edit();
250
Job *builtin_local();
252
bool load_cmd_module(const char *op);
237
253
Job *default_cmd();
239
255
void ChangeSession(FileAccess *new_session);
241
void print_cmd_help(const char *cmd);
257
bool print_cmd_help(const char *cmd);
242
258
void print_cmd_index();
244
260
static const char *CmdByIndex(int i);