#pragma interface #ifndef MISC_H #define MISC_H #include class ARRAY_OBJ{ protected: char modified; /*~PROTOBEG~ ARRAY_OBJ */ public: ARRAY_OBJ (void); virtual int edit (void); void rstmodified (void); void setmodified (void); virtual int was_modified (void); virtual ~ARRAY_OBJ (void); /*~PROTOEND~ ARRAY_OBJ */ }; class ARRAY: public ARRAY_OBJ{ protected: int is_owner; // Is this object allowed to delete // the objects it contains ? ARRAY_OBJ **tb; int nb; int maxtb; // Current maximum length of the table int increm; // growth rate of tb /*~PROTOBEG~ ARRAY */ public: ARRAY (void); void add (ARRAY_OBJ *pt); void clear (void); int editone (ARRAY_OBJ *e); int editone (int no); protected: ARRAY_OBJ *getitem (int no)const; public: int getnb (void)const; protected: void grow (void); private: void grow_realloc (int newmax); public: void insert (int pos, ARRAY_OBJ *pt); void invert (void); int lookup (ARRAY_OBJ *o)const; int manage_edit (ARRAY_OBJ *e, int code); int manage_edit (ARRAY_OBJ *e, int code, int insertpos); void moveto (ARRAY_OBJ *o, int newpos); void neverdelete (void); int remove (ARRAY_OBJ *obj); int remove (int no); void remove_all (void); int remove_del (ARRAY_OBJ *obj); int remove_del (int no); void remove_last (int cut); void rstmodified (void); void set (int pos, ARRAY_OBJ *pt); void setgrowth (int _increm); int size (void)const; void sort (int (*cmp)(const ARRAY_OBJ *, const ARRAY_OBJ *)); virtual int was_modified (void); virtual int write (void); virtual ~ARRAY (void); /*~PROTOEND~ ARRAY */ }; template< class T> class ARRAY_OBJS: public ARRAY{ public: T *getitem(int no) const { return (T*)ARRAY::getitem(no); } void add (T*p) { ARRAY::add (p); } ARRAY_OBJS(){} ~ARRAY_OBJS(){} }; #ifndef SSTRING_H #include "sstring.h" #endif #ifndef CONFIGF_H #include "configf.h" #endif class ARRAY_KEY: public SSTRING{ bool owner; // May delete the object public: ARRAY_OBJ *obj; /*~PROTOBEG~ ARRAY_KEY */ public: ARRAY_KEY (const char *_key, ARRAY_OBJ *_obj, bool is_owner); ~ARRAY_KEY (void); /*~PROTOEND~ ARRAY_KEY */ }; class ARRAY_KEYS: public ARRAY{ /*~PROTOBEG~ ARRAY_KEYS */ public: void add (const char *key, ARRAY_OBJ *obj, bool owner); void add (const char *key, ARRAY_OBJ *obj); ARRAY_KEY *getitem (int no)const; ARRAY_KEY *getobj (const char *key)const; ARRAY_OBJ *getval (const char *key)const; void sort (void); /*~PROTOEND~ ARRAY_KEYS */ }; class SSTRING_KEY: public ARRAY_KEY{ /*~PROTOBEG~ SSTRING_KEY */ public: SSTRING_KEY (const char *_key, const char *_val); SSTRING *getobj (void); const char *getobjval (void); void setobjval (const SSTRING *val); void setobjval (const SSTRING&val); void setobjval (const char *val); /*~PROTOEND~ SSTRING_KEY */ }; class SSTRING_KEYS: public ARRAY_KEYS{ /*~PROTOBEG~ SSTRING_KEYS */ public: SSTRING_KEYS (void); void add (const char *key, const char *val); SSTRING_KEY *getitem (int no)const; SSTRING_KEY *getobj (const char *key)const; const char *getval (const char *key)const; ~SSTRING_KEYS (void); /*~PROTOEND~ SSTRING_KEYS */ }; class CONTEXT_LOCK{ class CONTEXT_LOCK_PRIVATE *priv; /*~PROTOBEG~ CONTEXT_LOCK */ public: CONTEXT_LOCK (const char *_key1, const char *_key2); CONTEXT_LOCK (const char *key); private: void check (bool msg)const; void init (const char *_key1, const char *_key2, int _flags); public: bool isok (int seconds)const; bool isok (void)const; ~CONTEXT_LOCK (void); /*~PROTOEND~ CONTEXT_LOCK */ }; class MESSAGE_DEF: public ARRAY_OBJ{ class MESSAGE_DEF_PRIVATE *priv; /*~PROTOBEG~ MESSAGE_DEF */ public: MESSAGE_DEF (const char *msg); MESSAGE_DEF (const char *msg, const char *argnames[]); const char **getargs (void)const; const char *getmodule (void)const; const char *getmsg (void)const; ~MESSAGE_DEF (void); /*~PROTOEND~ MESSAGE_DEF */ }; class DIALOG; #ifndef DIALOG_DEF_H #include "dialog_def.h" #endif class PRIVILEGE; class CONFDB; class SSTREAM; class USERACCT_COMNGS; class FILE_CFG; #include "module_api.h" #include #include struct PARAM_STRING{ const char *ptr; PARAM_STRING (const char *_ptr){ ptr = _ptr; } PARAM_STRING (const std::string &s){ ptr = s.c_str(); } }; struct PARAM_VECTOR_STRING_BEGIN{ bool is_vs; std::vector::const_iterator vs_it; std::vector::const_iterator vp_it; PARAM_VECTOR_STRING_BEGIN(const std::vector *vs, bool is_end){ if (is_end){ vs_it = vs->end(); }else{ vs_it = vs->begin(); } is_vs = true; } PARAM_VECTOR_STRING_BEGIN(const std::vector *vp, bool is_end){ if (is_end){ vp_it = vp->end(); }else{ vp_it = vp->begin(); } is_vs = false; } PARAM_VECTOR_STRING_BEGIN & operator ++(){ if (is_vs){ vs_it++; }else{ vp_it++; } return *this; } bool operator != (PARAM_VECTOR_STRING_BEGIN &e){ if (is_vs){ return vs_it != e.vs_it; }else{ return vp_it != e.vp_it; } } const char *operator *() const{ if (is_vs){ return vs_it->c_str(); }else{ return *vp_it; } } }; // This is a generic class used to pass either a vector or vector // It is used mainly by build-protocol struct PARAM_VECTOR_STRING { const std::vector *vs; const std::vector*vp; PARAM_VECTOR_STRING(const std::vector &_vs){ vs = &_vs; vp = NULL; } PARAM_VECTOR_STRING(const std::vector &_vp){ vs = NULL; vp = &_vp; } PARAM_VECTOR_STRING_BEGIN begin() const{ if (vs != NULL){ return PARAM_VECTOR_STRING_BEGIN(vs,false); }else{ return PARAM_VECTOR_STRING_BEGIN(vp,false); } } PARAM_VECTOR_STRING_BEGIN end() const { if (vs != NULL){ return PARAM_VECTOR_STRING_BEGIN(vs,true); }else{ return PARAM_VECTOR_STRING_BEGIN(vp,true); } } size_t size() const { if (vs != NULL){ return vs->size(); }else{ return vp->size(); } } }; #include "misc.p" #endif