Blame src/alias.h

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 ALIAS_H
Packit 8f70b4
#define ALIAS_H
Packit 8f70b4
Packit 8f70b4
#include "xstring.h"
Packit 8f70b4
Packit 8f70b4
class Alias
Packit 8f70b4
{
Packit 8f70b4
   Alias *next;
Packit 8f70b4
   xstring_c alias;
Packit 8f70b4
   xstring_c value;
Packit 8f70b4
Packit 8f70b4
   static Alias *base;
Packit 8f70b4
Packit 8f70b4
   Alias(const char *alias,const char *value,Alias *next)
Packit 8f70b4
      : next(next), alias(alias), value(value) {}
Packit 8f70b4
Packit 8f70b4
public:
Packit 8f70b4
   static const char *Find(const char *alias);
Packit 8f70b4
Packit 8f70b4
   static void Add(const char *alias,const char *value);
Packit 8f70b4
   static void Del(const char *alias);
Packit 8f70b4
Packit 8f70b4
   static char *Format();
Packit 8f70b4
Packit 8f70b4
   friend char *command_generator(const char *text,int state);
Packit 8f70b4
};
Packit 8f70b4
Packit 8f70b4
class TouchedAlias
Packit 8f70b4
{
Packit 8f70b4
   xstring_c alias;
Packit 8f70b4
   TouchedAlias *next;
Packit 8f70b4
public:
Packit 8f70b4
   TouchedAlias(const char *a,TouchedAlias *n)
Packit 8f70b4
      : alias(a), next(n) {}
Packit 8f70b4
   static void FreeChain(TouchedAlias *chain)
Packit 8f70b4
   {
Packit 8f70b4
      while(chain)
Packit 8f70b4
	 delete replace_value(chain,chain->next);
Packit 8f70b4
   }
Packit 8f70b4
   static bool IsTouched(const char *a,TouchedAlias *chain)
Packit 8f70b4
   {
Packit 8f70b4
      while(chain)
Packit 8f70b4
      {
Packit 8f70b4
	 if(chain->alias.eq(a))
Packit 8f70b4
	    return true;
Packit 8f70b4
	 chain=chain->next;
Packit 8f70b4
      }
Packit 8f70b4
      return false;
Packit 8f70b4
   }
Packit 8f70b4
};
Packit 8f70b4
Packit 8f70b4
#endif//ALIAS_H