#include #include #include #include #include #include "projet.h" #include "projetx.m" /* Lit les sp‚cifications controlant le traitement d'un projet. Si pas de fichier de controle, utilise des valeurs par d‚faut. Certaines valeurs obligatoires sont ajout‚s de toutes fa‡on, quelques soit le contenu du fichier de configuration. Retourne -1 si erreur. ATTENTION: Certaines des rubriques du fichier de configuration ne servent plus. */ /* #Sp‚cification: archivage / exclusions Certains types de fichiers sont non originaux. Ils sont produits … partir d'autres fichiers (g‚n‚ralement via la commande mak export). Il n'est donc pas n‚cessaire de les archiver. On retrouve la liste de ces fichiers dans le source adm/projet/prjctrl.c dans la fonction PRJCTRL::PRJCTRL */ PUBLIC PRJCTRL::PRJCTRL (USERINFO *user) { const char *refpath = user->getombre(); str_splitline ("*.obj *.lib",' ',expobj); char path[MAXSIZ_PATH]; if (file_findanc (refpath,"projet.cfg",path) != -1 || file_findanc(refpath,"project.cfg",path) != -1){ FILE *fin = fopen_err (path,"r",1); if (fin != NULL){ char buf[300]; while (fgets_strip (buf,sizeof(buf),fin,'\\',';',NULL)!=NULL){ char mot[30]; char *pt = str_copyword(mot,buf,sizeof(mot)-1); if (mot[0] != '\0'){ if (strcmp(mot,"#ignore")==0){ str_splitline (pt,' ',hidlst); }else if (strcmp(mot,"#exporte")==0){ str_splitline (pt,' ',explst); }else if (strcmp(mot,"#exporteobj")==0){ str_splitline (pt,' ',expobj); }else if (strcmp(mot,"#message")==0){ str_splitline (pt,' ',expmsg); }else{ xconf_error (MSG_U(E_CONFIG ,"Fichier de configuration invalide\n%s\n") ,buf); } } } fclose (fin); } }else{ // error_showdef (MSGERR_NOCONFIG,refpath); } static char *defval[]={ "*.na*","*.i","*.ob*","*.lib", "tlib.inp","*.com","*.exe", "*.bak","*.n","*.old","makefile.dep","*.sym", "*.er?","*.bld", "*.dbg","*.asv","*.$$$","*.map","*.sav","core","a.out", "projet.cfg","version.dat","makefile.dat","makefile.del", "revision.dat","change.dat","integre.dat","logfile.log", "*~","*.a","*.o","*.os","*.orig","*.rej","*.so.*","*.so", "*.dic.old","*.hc", }; for (unsigned i=0; i < NB_ELM(defval); i++){ hidlst.add (new SSTRING(defval[i])); } } /* LibŠre information de controle sur transaction d'un projet */ PUBLIC PRJCTRL::~PRJCTRL () { } static bool prjctrl_iself (const char *path, const char *add, const char *name) { bool ret = false; // We assume that binary file do not have extension to speed things up if (strchr(name,'.')==NULL){ char abspath[PATH_MAX]; snprintf (abspath,sizeof(abspath),"%s/%s/%s",path,add,name); int fd = open (abspath,O_RDONLY); if (fd != -1){ char buf[2]; if (read(fd,buf,2)==2){ if (buf[0] == 0x7f && buf[1] == 0x45){ foper_logprintf ("Excluded binary %s\n",abspath); // fprintf (stderr,"Excluded binary %s\n",name); ret = true; } } close (fd); } } return ret; } static SSTRINGS *tbstr; static int fct( const FILEINFO *info, const char *path, const char *add, int nbf) { int ok = 0; if (info->name[0] != '.'){ char name[MAXSIZ_NAME]; strcpy (name,info->name); #ifdef MSDOS strlwr (name); #endif #ifdef MISSING /* #Sp‚cification: archivage / exclusions Les sous-r‚pertoire h et doc ne sont jamais archiv‚s. Leur contenu est non original. Il peut ˆtre recontruit g‚n‚ralement via les commandes "mak export" et "mak doc". */ if (strcmp(name,"h")!= 0 && strcmp(name,"doc")!=0 #endif if (name[strlen(name)-1] != '%'){ // backup de textedit if (info->type == FILETYPE_DIR){ path_addback (name,name); tbstr->add (new SSTRING(name)); ok = 1; }else if(!prjctrl_iself (path,add,name)){ tbstr->add (new SSTRING(name)); ok = 1; } } } return (ok); } /* Extrait la liste des sources d'un r‚pertoires. Obtient la liste des fichiers et des sous-r‚pertoires. */ PUBLIC int PRJCTRL::dirsource ( const char *path, const char *wild, SSTRINGS &tb) { static const char *tbsel[]={NULL,NULL}; tbstr = &tb; tbsel[0] = wild; int nbhid = hidlst.getnb(); const char *tbhide[nbhid+1]; for (int i=0; iget(); } tbhide[nbhid] = NULL; int nb = dir_gen (path,tbsel,tbhide,0,fct,0); tb.sort(); return nb; } /* D‚termine si un nom obtenue via dirsource() est un directory. Retourne != 0 si oui. */ PUBLIC int PRJCTRL::isdir (const char *fname) { const char *pt = fname + strlen(fname) -1; return path_issep(*pt); }