#ifndef PROJET_H #define PROJET_H #include #include #include #ifdef UNIX #define EVOL "/usr/local/2020src" #define VCSID "USER" #define KITGROUPE "/kit/groupe" #define KITOMBRE "/kit/ombre" #define KITBUILD "/kit/build" #define KITOBJ "/home/obj/groupe" #define KITLIVRE "/kit/livre" #define KITSYNC "/kit/sync" #else #define EVOL "e:" #define VCSID "VCSID" #define KITGROUPE "n:/kit/groupe" #define KITOMBRE "n:/kit/ombre" #define KITBUILD "n:/kit/build" #define KITOBJ "n:/kitobj" #define KITLIVRE "n:/kit/livre" #define KITSYNC "n:/kit/sync" #endif #define MAXSIZ_PROJET 8 #define MAXSIZ_REVISION 15 /* D‚finition pour le systŠme de gestion de projet */ struct ONE_LOCK { // une ligne du fichier lck char *prog; // nom du programmeur char locktype; // type de r‚servation // X : exclusif // G : r‚vision en groupe char *objet; // objet accapar‚ char *path; // path du programmeur char *version; // version majeure accapar‚e }; class USERINFO; class PRJLOCK{ int nblock; // nombre d'entr‚e int maxlock; // nombre maximum d'entr‚e USERINFO *user; char projet[MAXSIZ_PROJET+1]; // nom du projet ONE_LOCK *tb; // table de lock char lock_other; // Un autre usager fait des transactions // On doit donc bloquer l'usager courant /*~PROTOBEG~ PRJLOCK */ public: PRJLOCK (USERINFO *_user, const char *_projet); void add (int exclusif, const char *objet, const char *path); int del (const char *objet); int getprog (char *tbprog[])const; int islock (const char *objet, ONE_LOCK *tblock[]); int islockx (const char *projet); int isok (void); int issublock (int exclusif, const char *objet, char *prog, char *lock); int progstat (const char *prog, const char *projet); void save (void); ~PRJLOCK (void); /*~PROTOEND~ PRJLOCK */ }; #define LOCK_EXT ".lck" class PAGE_EDIT; // Liste de wildcards #ifndef MISC_H #include #endif /* Controle le transfert de fichier entre le r‚pertoire usager et le r‚pertoire groupe */ class PRJCTRL{ public: SSTRINGS hidlst; // N'affiche pas ces fichiers durant int‚gration SSTRINGS explst; // Exporte vers projet usager SSTRINGS expmsg; // Exporte messages vers projet usager SSTRINGS expobj; // Exporte fichiers objets vers projet usager /*~PROTOBEG~ PRJCTRL */ public: PRJCTRL (USERINFO *user); int dirsource (const char *path, const char *wild, SSTRINGS&tb); int isdir (const char *fname); ~PRJCTRL (void); /*~PROTOEND~ PRJCTRL */ }; enum REVISION_TYPE { REVISION_VERSION, REVISION_INTEGRE, REVISION_LIVRE}; class REVISION{ int version; int integre; int prog; int livre; /*~PROTOBEG~ REVISION */ public: REVISION (const REVISION *rev); REVISION (const char *revstr); REVISION (void); static int check (const char *revstr); int cmp (const REVISION *rev)const; void cnv (REVISION_TYPE type); void format (char *revstr)const; void formatbld (char *path)const; void formatpath (char *path)const; int getlivre (void)const; int getprog (void); int isnull (void); int next (int _prog, REVISION_TYPE _type); int set (const char *revstr); void strip (void); REVISION_TYPE type (void)const; /*~PROTOEND~ REVISION */ }; class VERSION_ONE; class PROJET_LOG; class USERINFO{ protected: char prog[MAXSIZ_PROJET+1]; int noprog; // Num‚ro identification pour composer les // r‚visions. char version[MAXSIZ_PROJET+1]; // Version majeure de la r‚vision. char revpath[MAXSIZ_NAME+1]; // R‚vision en format nom_de_r‚pertoire char *usrpath; // r‚pertoire usr/prog/version char *objpath; // obj/version ou NULL // L'ensemble de projetx utilise USERINFO pour d‚terminer // les r‚pertoires important. Ce traitement a ‚t‚ centralis‚ ici // pour permettre un jour d'op‚rer en mode "test" dans un archive // ind‚pendante. char *groupe; // R‚pertoire KITGROUPE char *ombre; // R‚pertoire KITOMBRE char *build; // R‚pertoire KITBUILD char *livre; // R‚pertoire KITLIVRE char *sync; // R‚pertoire KITSYNC REVISION rev; // R‚vision d'int‚gration /*~PROTOBEG~ USERINFO */ public: USERINFO (const USERINFO *user); USERINFO (const char *_prog, const char *_version, const char *_usrpath, const char *_groupe, const char *_ombre, const char *_livre, const char *_sync); protected: USERINFO (void); public: void chgenv (REVISION_TYPE revtype, int renomme, PROJET_LOG *log); int difusrobj (void)const; protected: int findobj (void); public: void getbld (char *path)const; const char *getgroupe (void)const; void gethome (char *path)const; const char *getlivre (void)const; int getno (void)const; const char *getnom (void)const; const char *getombre (void)const; virtual const REVISION *getrevdst (void)const; virtual const REVISION *getrevsrc (void)const; const char *getsyncpath (void)const; const char *getusrpath (void)const; const char *getversion (void)const; private: void init (void); public: virtual int isbuild (void)const; void logerr (const char *ctl, ...)const; void makbldpath (const char *projet, char *path)const; void maklivpath (const char *projet, char *path)const; int makobjpath (const char *projet, char *path)const; void makombpath (const char *projet, char *path)const; void makrefpath (const char *projet, char *path)const; void maksyncpath (const char *site, char *path)const; int makusrpath (const char *autre, const char *projet, char *userdir)const; void makusrpath (const char *projet, char *path)const; bool nobuild (void)const; virtual void setrevnxt (REVISION *newrev, REVISION_TYPE revtype)const; int setversion (const VERSION_ONE *one); int setversion (const char *newver); virtual ~USERINFO (void); /*~PROTOEND~ USERINFO */ }; class USERBUILD: public USERINFO{ /*~PROTOBEG~ USERBUILD */ public: USERBUILD (const char *_version, const REVISION *_rev); virtual int isbuild (void)const; /*~PROTOEND~ USERBUILD */ }; class USERINTG: public USERBUILD{ protected: REVISION revbase; // Provenance dans l'archive /*~PROTOBEG~ USERINTG */ public: USERINTG (const char *_version, const REVISION *_revbase, const REVISION *_revdest); const REVISION *getrevsrc (void)const; void setrevnxt (REVISION *newrev, REVISION_TYPE)const; /*~PROTOEND~ USERINTG */ }; class MAKEFILE; #define HISTORY_SIZE 5 // On retient les cinq derniŠres r‚vision // pr‚c‚dant la r‚vision courante class MAKEFILE_FILE{ friend class MAKEFILE; char nom[MAXSIZ_NAME*2]; // Peut contenir 1 nom plus 1 r‚pertoire REVISION rev; long date; char *path; // Path relatif dans le r‚pertoire ombre. // Historique des r‚visions pr‚c‚dantes du modules char tbhist[HISTORY_SIZE][MAXSIZ_REVISION+1]; int nbhist; char efface; // Indique si le fichier devra ˆtre effac‚ // … la fin de la session de livraison. // Ce fichier fait encore partie du projet. char is_dir; // C'est un r‚pertoire, pas un fichier. char archive; // C'est un fichier archivable // Il y a certain fichiers qui ne sont jamais // archiv‚s mais plac‚ tout de mˆme dans le makefile.dat // pour simplifier l'accŠs (*.p, *.na? ...) char mark; // Flag permettant de s‚lectionn‚ ou exclure // ce fichier de la recherche, voir MAKEFILE::itermark() char is_del; // Ce fichier ne fait plus partie du projet // On le garde temporairement pour produire un rapport. /*~PROTOBEG~ MAKEFILE_FILE */ public: MAKEFILE_FILE (void); const char *gethistory (int no); int getnbhistory (void); const char *getnom (void); void getombpath (USERINFO *user, char *ombpath); const char *getref (void); const char *getrelpath (void); const REVISION *getrev (void)const; int isdel (void); void pushrev (const REVISION *newrev); void setmark (int val); void setombpath (const char *projet); ~MAKEFILE_FILE (void); /*~PROTOEND~ MAKEFILE_FILE */ }; class MAKEFILE{ char fname[MAXSIZ_PATH]; // Nom et path du fichier makefile.dat MAKEFILE_FILE *moi; // Description du fichier makefile.dat // pointe dans tbfile. const USERINFO *user; char projet[MAXSIZ_PATH+1]; int noprog; // Num‚ro du programmeur pour composer // les r‚visions. MAKEFILE_FILE *tbfile; // Tableau des fichiers int nbfile; int positer; // Position de recherche pour iter() char is_modif; // A ‚t‚ modifi‚ ? char readok; // Le makefile.dat a ‚t‚ lue correctement /*~PROTOBEG~ MAKEFILE */ public: MAKEFILE (const char *_fname, bool silence, const REVISION *rev, const char *_projet, const USERINFO *_user); MAKEFILE (const char *_fname, bool silence, const char *_projet, const USERINFO *_user); int addbuild (void); protected: int archive (MAKEFILE_FILE *file, const char *); public: int cleanup (void); int copy2usr (MAKEFILE_FILE *file); int copy2usr (void); int creation (const char *nomver, const REVISION *newrev); int delfil (const char *fname); int ecrit (const char *fichier, int archivable); int ecrit (int archivable); int extract (MAKEFILE_FILE *file, int force); int extract (int extr_file); int getnbdel (void); const char *getref (const char *fichier); const REVISION *getrev (void); private: void init (const char *_fname, bool silence, const char *_projet, const USERINFO *_user); public: int isok (void); MAKEFILE_FILE *iter (const char *match); MAKEFILE_FILE *iter (const char *match, int mark); MAKEFILE_FILE *iterdel (const char *match); int livre (const char *fname, REVISION_TYPE revtype, const char *doc, const SSTRINGS&tbnew, bool&doarch); bool livre_test (MAKEFILE_FILE *file); int livretoi (REVISION_TYPE revtype, bool keep, const char *newversion, const char *comment); MAKEFILE_FILE *locate (const char *fname); MAKEFILE_FILE *locate (const char *fname, bool finddeleted); protected: MAKEFILE_FILE *locateadd (const char *fname); int logversion (const char *nomver, const REVISION *newrev, const char *comment); public: int save (void); MAKEFILE_FILE *setabsrev (const char *fname, long date, const REVISION *absrev); void setiter (void); void setmark (int val); MAKEFILE_FILE *setrev (const char *fname, REVISION_TYPE revtype, REVISION *oldrev); MAKEFILE_FILE *setrev (const char *fname, const REVISION *newrev, const char *path, unsigned long date, int archivable); protected: int setusrpath (SAVEPATH *save); public: MAKEFILE_FILE *toi (void); protected: int unzip (const char *abs_ombpath, const REVISION *rev, const char *nom); public: ~MAKEFILE (void); /*~PROTOEND~ MAKEFILE */ }; #ifndef MISC_H #include #endif #ifndef __STDIO_DEF_ #include #endif class VERSION_ONE: public ARRAY_OBJ{ public: char vername[30]; char progname[30]; REVISION rev; unsigned short date; char *info; // Information suppl‚mentaire sur la provenance de la // version. VERSION_ONE *integ; // Une des r‚visions dans laquelle cette r‚vision // a ‚t‚ int‚gr‚e. /*~PROTOBEG~ VERSION_ONE */ public: VERSION_ONE (const VERSION_ONE *v); VERSION_ONE (const char *_vername, const char *_progname, const REVISION *_rev, const char *datestr); VERSION_ONE (const char *_vername, const char *_progname, const char *revstr, const char *datestr); void addinfo (const char *ctl, ...); void format (char *buf1, char *buf2)const; const char *getprog (void); const REVISION *getrev (void)const; const char *getversion (void)const; int isinteg (void)const; void save (FILE *fout)const; void setprog (const char *_progname); void showinfo (void); ~VERSION_ONE (void); /*~PROTOEND~ VERSION_ONE */ }; class VERSION_LIST: public ARRAY{ /*~PROTOBEG~ VERSION_LIST */ public: VERSION_ONE *getitem (int no)const; /*~PROTOEND~ VERSION_LIST */ }; struct EVENT; class BOUTON_FCT; class VERSION_DAT; struct VERSION_EDIT{ // Structure pass‚ … bouton_setupfct() VERSION_DAT *v; int *lookup; VERSION_EDIT(VERSION_DAT *_v, int *_lookup){ v = _v; lookup = _lookup; } }; class FIELD_COMBO; class VERSION_DAT{ char *path; // path du fichier version.dat VERSION_LIST list; enum INTG_SETUP { notdone, done }; INTG_SETUP intgstatus; /*~PROTOBEG~ VERSION_DAT */ public: VERSION_DAT (const USERINFO *user); VERSION_DAT (const USERINFO *user, const char *projet); VERSION_DAT (const char *fname); void add (VERSION_ONE *ver); VERSION_ONE *add (const char *vername, const char *progname, const REVISION *newrev); int creation (USERINFO *user); int delrev (const REVISION *rev); VERSION_ONE *get (const REVISION *rev); VERSION_ONE *get (const REVISION *rev, int &noitem); VERSION_ONE *get (int sel); int getnb (void); protected: void init (const char *fname); public: int merge (const char *fname); int save (const USERINFO *user)const; VERSION_ONE *select (REVISION_TYPE minsel, REVISION_TYPE maxsel, const char *path_check); VERSION_ONE *select (const char *vername, const char *progname); int selmany (const char *titre, USERINFO *user, VERSION_ONE *tbvar[]); void setcombo (FIELD_COMBO *comb); void setintgstatus (void); int setselect (DIALOG&dia, REVISION_TYPE minsel, REVISION_TYPE maxsel, unsigned *selitem, const char *path_check, int lookup[]); void setuppick (DIALOG&dia); void sort (void); ~VERSION_DAT (void); /*~PROTOEND~ VERSION_DAT */ }; class CHANGE_FILE: public ARRAY_OBJ{ public: char fichier[MAXSIZ_NAME]; char *doc; /*~PROTOBEG~ CHANGE_FILE */ public: CHANGE_FILE (const char *_fichier, const char *_doc); void setdoc (const char *_doc); ~CHANGE_FILE (void); /*~PROTOEND~ CHANGE_FILE */ }; class CHANGE_LIST: public ARRAY{ /*~PROTOBEG~ CHANGE_LIST */ public: CHANGE_FILE *getitem (int no)const; /*~PROTOEND~ CHANGE_LIST */ }; class CHANGE_DAT{ char *fname; // Path pour sauver CHANGE_DAT CHANGE_LIST list; /*~PROTOBEG~ CHANGE_DAT */ public: CHANGE_DAT (const char *_fname); const char *getdoc (const char *fichier); CHANGE_FILE *locate (const char *fichier); int save (void); void setdoc (const char *fichier, const char *doc); void sort (void); ~CHANGE_DAT (void); /*~PROTOEND~ CHANGE_DAT */ }; #ifndef __STDARG_H #include #endif class PROJET_LOG{ FILE *fout; /*~PROTOBEG~ PROJET_LOG */ public: PROJET_LOG (const char *fname, int append); void printf (const char *ctl, ...); protected: virtual void sendstr (const char *str); public: void vprintf (const char *ctl, va_list list); virtual ~PROJET_LOG (void); /*~PROTOEND~ PROJET_LOG */ }; class WINDOW_LOG: public PROJET_LOG{ SSTRING buf; int maxlin; // Nombre maximum de ligne affich‚ en mˆme temps DIALOG *dia; char fpath[MAXSIZ_PATH]; // Path du fichier log, pour afficher dans window /*~PROTOBEG~ WINDOW_LOG */ public: WINDOW_LOG (const char *fname, int append); void edit (void); void hide (void); protected: virtual void sendstr (const char *str); public: void show (void); ~WINDOW_LOG (void); /*~PROTOEND~ WINDOW_LOG */ }; class INTEGRE_FILE; enum INTG_OPER { INTEGRE_MODIF, INTEGRE_EFFACE, INTEGRE_NOUVEAU }; /* #Sp‚cification: fusion / Combinaison / sp‚cification d'un fichier Pour comprendre le r“le d'un fichier durant une int‚gration/fusion on foit avoir trois informations. # -De quelle r‚vision/racine provient t'il -De quelle r‚vision/r‚pertoire provient t'il -Quel est sa r‚vision # Par exemple, la r‚vision X d'un fichier peut faire partie de plusieurs r‚visions Y d'un sous-r‚pertoire qui lui-mˆme peut appartenir … plusieurs r‚visions Z du r‚pertoire ancˆtre et ainsi de suite. Avec trois num‚ro de r‚vision, on a une bonne id‚e du contexte d'o— provient ce fichier. */ struct FILE_REV_SPEC{ const REVISION *fichier; const REVISION *dir; const REVISION *root; }; // MŠme chose en format ASCII struct TRA_REV_SPEC{ char fichier[MAXSIZ_REVISION]; // R‚vision de la version r‚f‚rence char dir[MAXSIZ_REVISION]; char root[MAXSIZ_REVISION]; }; class INTG_TRANS: public ARRAY_OBJ{ friend class INTEGRE_FILE; INTG_OPER oper; char *path; TRA_REV_SPEC revs; /*~PROTOBEG~ INTG_TRANS */ public: INTG_TRANS (char _oper, const char *rev_fichier, const char *rev_dir, const char *rev_root, const char *_path); INTG_TRANS (char _oper, const char *str); const char *getrevdir (void); const char *getrevfile (void); const char *getrevroot (void); void write (FILE *fout); ~INTG_TRANS (void); /*~PROTOEND~ INTG_TRANS */ }; class _INTEGRE_FILE: public ARRAY{ /*~PROTOBEG~ _INTEGRE_FILE */ /*~PROTOEND~ _INTEGRE_FILE */ }; class INTEGRE_DAT; // Controle l'integration d'un fichier class INTEGRE_FILE: public _INTEGRE_FILE{ friend class INTEGRE_DAT; char fname[2*MAXSIZ_NAME]; // Nom du fichier (peut contenir // nom d'un sous-makefile.dat TRA_REV_SPEC revs; char nouveau; // Ce fichier existe pas pour la r‚vision // courante. char *path; // Path dans kit\ombre char done; // Ce fichier a ‚t‚ int‚gr‚ et il // faut le montrer comme tel // dans la ligne des fichiers a int‚grer. /*~PROTOBEG~ INTEGRE_FILE */ public: INTEGRE_FILE (const char *_name, const REVISION *rev_fichier, const REVISION *rev_dir, const REVISION *rev_root, const char *_path, int _nouveau); protected: INTEGRE_FILE (const char *buf); public: int addcond (char oper, TRA_REV_SPEC&rev, const char *path); int conflit (void); void efface (void); const char *getfname (void); INTG_TRANS *getitem (int no)const; int menu (long mskwin, EVENT *cmd, BOUTON_FCT *but, MAKEFILE *mkf, const USERINFO *user); int menudir (void); void select_tra (const USERINFO *user, int select, MAKEFILE *mkf); void write (FILE *fout); ~INTEGRE_FILE (void); /*~PROTOEND~ INTEGRE_FILE */ }; class _INTEGRE_DAT: public ARRAY{ /*~PROTOBEG~ _INTEGRE_DAT */ /*~PROTOEND~ _INTEGRE_DAT */ }; class INTEGRE_DAT: public _INTEGRE_DAT{ char *fname; // Path du fichier /*~PROTOBEG~ INTEGRE_DAT */ public: INTEGRE_DAT (const char *_fname); void addtrans (const char *fname, FILE_REV_SPEC&ref, const char *refpath, char oper, FILE_REV_SPEC&rev, const char *path); INTEGRE_FILE *getitem (int no)const; INTEGRE_FILE *locate (const char *fname); void menu (USERINFO *user); ~INTEGRE_DAT (void); /*~PROTOEND~ INTEGRE_DAT */ }; class PREFER_PATH{ SSTRING key; SSTRING path; /*~PROTOBEG~ PREFER_PATH */ public: PREFER_PATH (const char *k, const char *p); const char *getval (char *s, int len); /*~PROTOEND~ PREFER_PATH */ }; class PREFER_INT{ SSTRING key; int defval; /*~PROTOBEG~ PREFER_INT */ public: PREFER_INT (const char *k, int v); int getval (void); /*~PROTOEND~ PREFER_INT */ }; extern PREFER_PATH configPath; extern PREFER_PATH projet_tmppath; extern PREFER_PATH applicationPath; class PRJLISTE; class VERSION_PAIRE; #include "projetx.p" #endif