#ifndef __PREFIX_H
#define __PREFIX_H

#ifndef __EXTCTYPE_H
#include <extctype.h>
#endif

#ifndef __FILES_H
#include <files.h>
#endif

#ifndef __STRINGS_H
#include <strings.h>
#endif

// @C
// class TPrefix : public TObject
// @END

class TPrefix : public TObject
{
  // @DPRIV
  TString _prefix;
  int*          _dirfl;
  int*          _recfl;
  long _filelevel;
  int _items;
  
  SecDef* _fdir;
  SecDef* _rdir;
  
  bool test(const char* s) const ;
  void put();

public:
  // @FPUB
  void set(const char* name = NULL, bool force = FALSE, TFilelock mode = _manulock);
  bool exist(long codditta) const;
  bool test(long codditta) const;
  long get_codditta() const ;
  bool set_codditta(long codditta, bool force = FALSE);
  const char* name() const { return _prefix;}
  long filelevel() const {return _filelevel;} 

  int items() const { return _items; }
  const char* description(const char* cod) const;
  const char* description(int cod) const;
  bool is_firm() const { return _prefix.len() == 6 && _prefix[5] == 'a';}
  bool is_com() const  { return !is_firm();}

  TPrefix();
  virtual ~TPrefix();
};


const char* firm2dir(long codditta);

TString& user();

TPrefix& prefix_init(); 
TPrefix& prefix();
void prefix_destroy();

#endif // __PREFIX_H