/* Traitement incrémental */ #include #include #include "proto.h" extern int protof_nbfile; extern PROTOF_INFO protof_tb[]; static int protof_increm=0; /* Enregistre demande de traitement incrémental */ void protof_setincrem (void) { if (!protof_increm && protof_nbfile>0){ erreur_signal ( "Option -i avant l'option -f : sans effet\n" ,"Option -i must precede -f : ignored\n"); }else{ protof_increm = 1; } } /* Prépare incrementation pour un fichier */ void protof_loadfile (PROTOF_INFO *inf, const char *nomf, int mode) { if (protof_increm){ int ok; if (mode & MODE_COMMENT){ ok = filep_readnap (&inf->txttb,nomf); }else if (mode & MODE_INDEX){ ok = filep_readnar (&inf->txttb,nomf); }else{ ok = filep_readp (&inf->txttb,nomf); } if (ok==-1){ erreur_signal ( "Mode incrémental : Ne peut relire %s\nAbandon du mode\n" ,"Incremental mode : Can't read %s\nAbort incremental mode\n" ,nomf); protof_increm=0; } } } /* essai de faire le traitement incrémental dépendant de la date du fichier Retourne 0 si ok, -1 sinon */ int protof_doincrem (const char *nomf, unsigned long date) { int ok = -1; if (protof_increm){ int i; PROTOF_INFO *inf = protof_tb; int tbidx[10]; ok = 0; for (i=0; itxttb,nomf,&pdate); if (pdate != date){ ok = -1; break; } } if (ok == 0){ inf = protof_tb; for (i=0; ifout,&inf->txttb,tbidx[i]); } } } return ok; } /* Libère espace associé au mécanisme incrémental */ void protof_free (PROTOF_INFO *inf) { free (inf->txttb.buf); free (inf->txttb.tb); }