|
Packit |
8f70b4 |
/*
|
|
Packit |
8f70b4 |
* lftp - file transfer program
|
|
Packit |
8f70b4 |
*
|
|
Packit |
8f70b4 |
* Copyright (c) 1996-2012 by Alexander V. Lukyanov (lav@yars.free.net)
|
|
Packit |
8f70b4 |
*
|
|
Packit |
8f70b4 |
* This program is free software; you can redistribute it and/or modify
|
|
Packit |
8f70b4 |
* it under the terms of the GNU General Public License as published by
|
|
Packit |
8f70b4 |
* the Free Software Foundation; either version 3 of the License, or
|
|
Packit |
8f70b4 |
* (at your option) any later version.
|
|
Packit |
8f70b4 |
*
|
|
Packit |
8f70b4 |
* This program is distributed in the hope that it will be useful,
|
|
Packit |
8f70b4 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
8f70b4 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
Packit |
8f70b4 |
* GNU General Public License for more details.
|
|
Packit |
8f70b4 |
*
|
|
Packit |
8f70b4 |
* You should have received a copy of the GNU General Public License
|
|
Packit |
8f70b4 |
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
Packit |
8f70b4 |
*/
|
|
Packit |
8f70b4 |
|
|
Packit |
8f70b4 |
#ifndef QUEUEFEEDER_H
|
|
Packit |
8f70b4 |
#define QUEUEFEEDER_H
|
|
Packit |
8f70b4 |
|
|
Packit |
8f70b4 |
#include "CmdExec.h"
|
|
Packit |
8f70b4 |
|
|
Packit |
8f70b4 |
class QueueFeeder : public CmdFeeder
|
|
Packit |
8f70b4 |
{
|
|
Packit |
8f70b4 |
struct QueueJob {
|
|
Packit |
8f70b4 |
xstring_c cmd;
|
|
Packit |
8f70b4 |
xstring_c pwd;
|
|
Packit |
8f70b4 |
xstring_c lpwd;
|
|
Packit |
8f70b4 |
|
|
Packit |
8f70b4 |
QueueJob *next, *prev;
|
|
Packit |
8f70b4 |
QueueJob(): next(0), prev(0) {}
|
|
Packit |
8f70b4 |
} *jobs, *lastjob;
|
|
Packit |
8f70b4 |
xstring_c cur_pwd;
|
|
Packit |
8f70b4 |
xstring_c cur_lpwd;
|
|
Packit |
8f70b4 |
|
|
Packit |
8f70b4 |
xstring buffer;
|
|
Packit |
8f70b4 |
|
|
Packit |
8f70b4 |
/* remove the given job from the list */
|
|
Packit |
8f70b4 |
void unlink_job(QueueJob *job);
|
|
Packit |
8f70b4 |
|
|
Packit |
8f70b4 |
/* get the n'th job */
|
|
Packit |
8f70b4 |
QueueJob *get_job(int n);
|
|
Packit |
8f70b4 |
|
|
Packit |
8f70b4 |
/* get the n'th job, removed from the list: */
|
|
Packit |
8f70b4 |
QueueJob *grab_job(int n);
|
|
Packit |
8f70b4 |
|
|
Packit |
8f70b4 |
/* get all jobs (linked and removed from the list)
|
|
Packit |
8f70b4 |
* that match the cmd: */
|
|
Packit |
8f70b4 |
QueueJob *grab_job(const char *cmd);
|
|
Packit |
8f70b4 |
|
|
Packit |
8f70b4 |
/* get the next job in j that matches cmd (including j) */
|
|
Packit |
8f70b4 |
static QueueJob *get_next_match(const char *cmd, QueueJob *j);
|
|
Packit |
8f70b4 |
void PrintJobs(const QueueJob *job, int v, const char *plur) const;
|
|
Packit |
8f70b4 |
xstring& FormatJobs(xstring& s,const QueueJob *job, int v, const char *plur) const;
|
|
Packit |
8f70b4 |
|
|
Packit |
8f70b4 |
void insert_jobs(QueueJob *job,
|
|
Packit |
8f70b4 |
QueueJob *&lst_head, QueueJob *&lst_tail,
|
|
Packit |
8f70b4 |
QueueJob *before);
|
|
Packit |
8f70b4 |
|
|
Packit |
8f70b4 |
void FreeList(QueueJob *j);
|
|
Packit |
8f70b4 |
|
|
Packit |
8f70b4 |
public:
|
|
Packit |
8f70b4 |
const char *NextCmd(CmdExec *exec,const char *prompt);
|
|
Packit |
8f70b4 |
|
|
Packit |
8f70b4 |
/* Add a command to the queue at a given position; a 0 position inserts at the end. */
|
|
Packit |
8f70b4 |
void QueueCmd(const char *cmd, const char *pwd, const char *lpwd, int pos = 0, int verbose = 0);
|
|
Packit |
8f70b4 |
|
|
Packit |
8f70b4 |
/* delete jobs (by index or wildcard expr) */
|
|
Packit |
8f70b4 |
bool DelJob(int from, int v = 0);
|
|
Packit |
8f70b4 |
bool DelJob(const char *cmd, int v = 0);
|
|
Packit |
8f70b4 |
|
|
Packit |
8f70b4 |
/* move one or more jobs (by index or wildcard expr). */
|
|
Packit |
8f70b4 |
bool MoveJob(int from, int to, int v = 0);
|
|
Packit |
8f70b4 |
bool MoveJob(const char *cmd, int to, int v = 0);
|
|
Packit |
8f70b4 |
|
|
Packit |
8f70b4 |
static int JobCount(const QueueJob *);
|
|
Packit |
8f70b4 |
int JobCount() const { return JobCount(jobs); }
|
|
Packit |
8f70b4 |
|
|
Packit |
8f70b4 |
enum { PrintRequeue = 9999 };
|
|
Packit |
8f70b4 |
xstring& FormatStatus(xstring&,int v,const char *prefix="\t") const;
|
|
Packit |
8f70b4 |
|
|
Packit |
8f70b4 |
QueueFeeder(const char *pwd, const char *lpwd):
|
|
Packit |
8f70b4 |
jobs(0), lastjob(0), cur_pwd(pwd), cur_lpwd(lpwd) {}
|
|
Packit |
8f70b4 |
virtual ~QueueFeeder();
|
|
Packit |
8f70b4 |
};
|
|
Packit |
8f70b4 |
|
|
Packit |
8f70b4 |
#endif//QUEUEFEEDER_H
|