Index: anr/gantt.l
===================================================================
--- anr/gantt.l	(revision 51)
+++ anr/gantt.l	(revision 52)
@@ -39,4 +39,19 @@
     0
 };
+struct partner_def { char *key, *name, *file; } partner_table[] = {
+    { "UNKNOW", "relax",   0,                 },
+    { "irisa",  "irisa",   "table_irisa.tex"  },
+    { "lip",    "lip",     "table_lip.tex"    },
+    { "tima",   "tima",    "table_tima.tex"   },
+    { "ubs",    "ubs",     "table_ubs.tex"    },
+    { "upmc",   "upmc",    "table_upmc.tex"   },
+    { "altera", "altera",  "table_altera.tex" },
+    { "xilinx", "xilinx",  "table_xilinx.tex" },
+    { "bull",   "bull",    "table_bull.tex"   },
+    { "thales", "thales",  "table_thales.tex" },
+    { "zied",   "zied",    "table_zied.tex"   },
+    { "navtel", "navtel",  "table_navtel.tex" },
+    { 0,        0,         0                  },
+};
 
 typedef struct _Tlivrable {
@@ -44,9 +59,12 @@
     char v;            // 0, 1, 2, ..., F 
     char* title;
-    int   bm,em;   // mois de bebut et de fin
+    int   bm,em;       // mois de bebut et de fin
+    double hman[3];    // nombre de mh par an
+    int    partner;    // index dans partner_table
     // these fields are filled by the program for data[tn][0][0][0]
     double task_y;           // top of task
     double task_dy;          // bot of task is task_y+task_dy
     double task_y_del;       // delivrables start at task_y+task_y_del
+    double nbma[3];          // durÃ©e en mois par annee
     // these fields are filled by the program for data[tn][stn][dn][0]
     struct _Tlivrable
@@ -106,5 +124,5 @@
         *l = *data_org.ls[tn][stn][dn][v];
         data->ls[tn][stn][dn][v] = l;
-fprintf(stderr,"selected: [tn][stn][dn][v]=%d,%d,%d,%d\n",tn,stn,dn,v);
+//fprintf(stderr,"selected: [tn][stn][dn][v]=%d,%d,%d,%d\n",tn,stn,dn,v);
     }
     return data;
@@ -196,11 +214,12 @@
 %%
  int tn,stn,dn,v,bm,em; char* title;
+ double an[3];
+ char*  an_comment;
+ int    partner;
 #.*\n   ;
-T=[0-9]+ { tn=atoi(yytext+2); }
-T=D[0-9]+ { tn=atoi(yytext+3); }
-S=[0-9]+ { stn=atoi(yytext+2); }
-D=[0-9]+ { dn=atoi(yytext+2); }
-V=V.     { v=yytext[3]; }
-V=       { v='F'; }
+T=[0-9]+  { tn=atoi(yytext+2); }
+S=[0-9]+  { stn=atoi(yytext+2); }
+D=[0-9]+  { dn=atoi(yytext+2); }
+V=V[1-8F] { v=yytext[3]; }
 ML=[0-9]+ {
         int i;
@@ -208,7 +227,34 @@
         milestones[i] = atoi(yytext+3);
     }
-
 BM=[0-9]+ { bm=atoi(yytext+3); }
 EM=[0-9]+ { em=atoi(yytext+3); }
+R=none    { an[0]=0; an[1]=0; an[2]=0; an_comment=0; }
+R=[0-9:.]+ {
+        char tmp[1000];
+        int status = sscanf(yytext+2,"%lf:%lf:%lf:%s",an+0,an+1,an+2,tmp);
+        if (status<3) {
+            fprintf(stderr,"%s: is not resource definition, expected format \"N:N:N\" (near D%d%d%d-V%c)\n",
+               yytext+2,tn,stn,dn,v);
+            an[0]=0; an[1]=0; an[2]=0; an_comment=0;
+        } else if (status==3) {
+            an_comment = 0;
+        } else
+            an_comment = strdup(tmp);
+    }
+PART="{"[^}]+"}"  {
+        int i;
+        partner=-1;
+        for (i=0; partner_table[i].key!=0 ; i++) {
+            if (strstr(yytext,partner_table[i].key)!=0 ) {
+                partner=i;
+                break;
+            }
+        }
+        if ( partner==-1 ) {
+            fprintf(stderr,"%s: does not contains a partner key (near D%d%d%d-V%c)\n",
+               yytext+5,tn,stn,dn,v);
+            partner=0;
+        }
+    }
 TITLE=.*\n {
         char* pc=yytext+6;
@@ -221,4 +267,8 @@
         p->dn = dn;
         p->v  = v;
+        p->hman[0] = an[0];
+        p->hman[1] = an[1];
+        p->hman[2] = an[2];
+        p->partner = partner;
         p->title = title;
         p->bm = bm;
@@ -228,8 +278,9 @@
         for (v=0; data_org.ls[tn][stn][dn][v]!=0 ; v++);
         data_org.ls[tn][stn][dn][v] = p;
-fprintf(stderr,"ADDED: %d %d %d %d\n",tn,stn,dn,v);
-//{int i,tn=0; fprintf(stderr,"CURR:t=%d:: ",tn); for (i=0; i<S_MAX ; i++) fprintf(stderr,"%d:%p ",i,data[tn][i][0][0]); fprintf(stderr,"\n"); }
-    }
-.|\n ;
+//fprintf(stderr,"ADDED: %d %d %d %d\n",tn,stn,dn,v);
+    }
+[ \t\n] ;
+.   { fprintf(stderr,"%c: unexpected value in anr.gantt file (near D%d%d%d-V%c)\n",
+        *yytext,tn,stn,dn,v); }
 %%
 
@@ -327,4 +378,25 @@
             h += (p->vers[p->nbvers-1]->nbTitleLines-1)*(DELIVRABLE_TITLEHEIGHT/5.);
             if ( h>p->height) p->height=h;
+        }
+        Tlivrable* lu= p->vers[p->nbvers-1];
+        int i;
+fprintf(stderr,"--------------------\n");
+        for (i=0 ; i<p->nbvers ; i++) {
+            Tlivrable* l= p->vers[i];
+            double bm= l->bm;
+            double em= l->em;
+//fprintf(stderr,"  %d%d%d-V%c: bm=%2.f em=%2.f --> %2.1f %2.1f %2.1f\n",l->tn,l->stn,l->dn,l->v,bm,em, lu->nbma[0],lu->nbma[1],lu->nbma[2]);
+            if (bm<12 && em>0) {
+                lu->nbma[0] += (em>12?12:em)-bm;
+                bm=12;
+            }
+            if (bm<24 && em>12) {
+                lu->nbma[1] += (em>24?24:em)-bm;
+                bm=24;
+            }
+            if (bm<36 && em>24) {
+                lu->nbma[2] += em-bm;
+            }
+//fprintf(stderr,"  %d%d%d-V%c: bm=%2.f em=%2.f --> %2.1f %2.1f %2.1f %p\n",l->tn,l->stn,l->dn,l->v,bm,em, lu->nbma[0],lu->nbma[1],lu->nbma[2], lu);
         }
     }
@@ -536,4 +608,72 @@
     print_milestones(gantt_x,0,gantt_dx,gantt_dy+gantt_y);
     fprintf(curr->os,"\\end{picture}\n");
+    fclose(curr->os);
+    curr->os=0;
+}
+
+void do_partner_table(int partner)
+{
+    struct partner_def* part = partner_table+partner;
+    if ( (curr->os=fopen(part->file,"w"))==0 ) {
+        fprintf(stderr,"can not open %s file for writing.\n",part->file);
+        fprintf(stderr,"generation of %s partner table is skipped.\n",part->file);
+        return;
+    }
+    fprintf(curr->os,"\\begin{tabular}{|c|p{3.5cm}||r|r|r||r|}\\hline\n");
+    fprintf(curr->os,
+        "number & \\multicolumn{1}{c||}{title} & \\multicolumn{3}{c||}{years } & total \\\\\\cline{3-5}\n");
+    fprintf(curr->os,
+        " & & \\multicolumn{1}{c|}{1} & \\multicolumn{1}{c|}{2} & "
+        "\\multicolumn{1}{c||}{3} &  \\\\\\hline\\hline\n");
+    int tn,stn,dn,v=0;
+    double an1=0,an2=0,an3=0,an=0;
+    int newlineadded=1;
+    for (tn=0 ; tn<T_MAX ; tn++) {
+        if (curr->ls[tn][0][0][0]==0) break;
+        if (tn!=0 && newlineadded==0 ) {
+            newlineadded = 1;
+            fprintf(curr->os,"\\hline ");
+        }
+        for (stn=0; stn<S_MAX; stn++) {
+            for (dn=0; dn<D_MAX; dn++) {
+                Tlivrable* top=curr->ls[tn][stn][dn][v];
+                if (top==0) continue;
+                Tlivrable* last=top->vers[top->nbvers-1];
+                if (last->partner!=partner) continue;
+                double sum1,sum2,sum3,sum=0;
+                sum1 = last->hman[0]; sum +=sum1;
+                sum2 = last->hman[1]; sum +=sum2;
+                sum3 = last->hman[2]; sum +=sum3;
+                char label[1000],title[1000];
+                gen_label_base(label,last);
+                sprintf(title,"\\resstablestyletitle{%s}",last->title);
+                fprintf(curr->os,"%s & %s & %2.1f & %2.1f & %2.1f & %2.1f \\\\\\hline\n",
+                   label,title,sum1,sum2,sum3,sum);
+                an1 += sum1 ;
+                an2 += sum2 ;
+                an3 += sum3 ;
+                an  += sum  ;
+                newlineadded=0;
+                if ( (sum1!=0 && sum1>last->nbma[0] ) || (sum1==0 && last->nbma[0]!=0) )
+                    fprintf(stderr,"ERROR: %s:%s probleme sur l'an 1 (in table=%2.1f, in gantt=%2.1f\n",
+                        part->name,label,sum1,last->nbma[0]);
+                if ( (sum2!=0 && sum2>last->nbma[1]) || (sum2==0 && last->nbma[1]!=0) )
+                    fprintf(stderr,"ERROR: %s:%s probleme sur l'an 2 (in table=%2.1f, in gantt=%2.1f\n",
+                        part->name,label,sum2,last->nbma[1]);
+                if ( (sum3!=0 && sum3>last->nbma[2]) || (sum3==0 && last->nbma[2]!=0) )
+                    fprintf(stderr,"ERROR: %s:%s probleme sur l'an 3 (in table=%2.1f, in gantt=%2.1f\n",
+                        part->name,label,sum3,last->nbma[2]);
+            }
+        }
+    }
+    if ( an!=(an1+an2+an3) ) {
+        fprintf(stderr,"bad computation in %s table.\n",part->file);
+    }
+    fprintf(curr->os,"%s & %s & %2.1f & %2.1f & %2.1f & %2.1f \\\\\\hline\n",
+            "","total",an1,an2,an3,an);
+
+    fprintf(curr->os,"\\end{tabular}\n");
+    fclose(curr->os);
+    curr->os=0;
 }
 
@@ -548,4 +688,12 @@
     do_gantt("gantt2.tex",0,tnmoins);
 
+    curr = data_new(0,0);
+    prepare0(curr);
+    prepare1(curr);
+    prepare2(curr);
+    prepare3(curr);
+    do_partner_table(4);
+    do_partner_table(5);
+
     return 0;
 }
