Projet mkd/mkd.c

De Wiki EELL.

Cette page n'est pas finie. Veuillez considérer le plan et le contenu comme incomplets et en préparation, temporaires et sujets à caution. Si vous souhaitez participer, il vous est recommandé de consulter sa page de discussion au préalable.

Retour aux fichiers en développement →


version.h

mkd.h

	// asm.cpp:
	extern int asm_(FILE *pfdoc, FILE *pnfile);

     
	// File: basic.c
	void basic_ (FILE * pfdoc, FILE * pnfile);

     
	// File: cpp.c
	extern int cpp_ (FILE * pfdoc, FILE * pnfile);
     
	// File: fortran.c
	void fortran_ (FILE * pfdoc, FILE * pnfile);
     
	// File: pascal.c (Comments for UTF-8 text editor)
	void pascal_ (FILE * pfdoc, FILE * pnfile);

     
	// File: shell.c (Comments for UTF-8 text editor)
	void shell_ (FILE * pfdoc, FILE * pnfile);

     
	// File: tri.c
	void tri_ (FILE * pfdoc, FILE * pnfile);

cpp.c

/*
* © mkd, version 2009.12 et ultérieures
*
* Concédée sous licence EUPL, version 1.1 ou – dès leur approbation par la
* Commission européenne - versions ultérieures de l’EUPL (la «Licence»).
* Vous ne pouvez utiliser la présente oeuvre que conformément à la Licence.
* Vous pouvez obtenir une copie de la Licence à l’adresse suivante:
*
* http://ec.europa.eu/idabc/eupl5
*
* Sauf obligation légale ou contractuelle écrite, le logiciel distribué sous
* la Licence est distribué «en l’état»,
* SANS GARANTIES OU CONDITIONS QUELLES QU’ELLES SOIENT, expresses ou implicites.
* Consultez la Licence pour les autorisations et les restrictions linguistiques
* spécifiques relevant de la Licence.
*/

/*P
	NOM DU FICHIER: mkd.c
	PROJET INITIAL: mkd console linux & Windows 7
	DOSSIER INITIAL : mkdoc3.12 Centre d'Electronique de Montpellier
	PROGRAMMEUR: JPL
	DATE: 18/12/2009
	MODIFICATIONS:
	le: 10/03/2010 par JPL objet de la modification Mise à jour pour Visual C 10
	le: ../../.. par
*/

#include "version.h"
#include "strings.h"
#include "mkd.h"



unsigned char A,B,C,F,P,S,a,f,j,l,n,p,s,t,v,w; /*P ajout n et v version 3.1 */
/* static */ char codes[5] = {0,0,0,0,0};


/** #######################################
    #           SOUS PROGRAMMES           #
    ####################################### */


// #include "asm.inc.c"         /* Compilation globale et C standard */
#include "basic.inc.c"
// #include "c.inc.c"
#include "fortran.inc.c"
#include "pascal.inc.c"
#include "shell.inc.c"
#include "tri.inc.c"



int tolower(char c)
// char c;
     {
     if( c>='A' && c <='Z' ) c=(c-'A')+'a';
     return(c);
     }


int toupper(char c)
// char c;
     {
     if( c>='a' && c <='z' ) c=(c-'a')+'A';
     return(c);
     }



#ifdef UNIX
int getch()
     {
     int c;
     c=getc(stdin);
     if (c=='\r')c='\n';
     return(c);
     }
#endif




/** #######################################
    #               MAIN()                #
    ####################################### */


int main (int argc, char * argv[])
// int argc;
// char *argv[];
     { /*S main */
     char *fprj;       /* nom fichier projet s'il existe     */
     char fdoc[MAX];   /* nom fichier documentaire en sortie */
     char fsrc[MAX];   /* nom fichier source a documenter    */
     extern  char codes[];  /* codes */
     extern unsigned char A,B,C,F,P,S,a,f,j,l,n,p,s,t,v,w;  /* rappels options booleennes */
     int i,k;          /* compteurs */
     char isource;     /* position nom du fichier source dans path source */
     char itarget;     /* position fin du path_target avec '*' ou ':'(PC) */
     char ktar;        /* position du '.' dans p_target */
     static char O;    /* booleen =1 si option validee */
     static char L;    /* booleen =1 si option langage */
     register int c;   /* char (variable) */
     int c1;           /* char (variable) pour version PC */
	 int ret = 0;			// essai

     FILE *pfprj;  /* FICHIER PROJET       */
     FILE *pnfile; /* FICHIER A TRIER      */
     FILE *pfdoc;  /* FICHIER DOCUMENTAIRE */


/*##########################################################################*/
/*O si argc < 3 ou arc > 5: */
     if ( argc < 3 || argc > 5 )
/*##########################################################################*/
/*O alors ecrire 'USAGE', donner la syntaxe puis quitter */
        { /*S syntaxe */

#ifdef PC
        ret = printf("mkd PC version, Release %s, USAGE:\n",VERSION);
        printf("syntax: mkd [-ABCFPSafjlnpstvw] char_codes path_source [path_target]\n");
        puts  ("    or: mkd ? .See also mkd.doc or manual.");
#endif

#ifdef UNIX
        printf("mkdoc UNIX version, Release %s, USAGE:\n",VERSION);
        printf("syntax: mkdoc [-ABCFPSafjlnpstvw] char_codes path_source [path_target]\n");
        puts  ("    or: mkdoc \\? .See also nanual: \'man mkdoc\'");
#endif

        if( argc==2 && argv[1][0]=='?' )
           { /*S*/
           printf(" --> options:\n");
           printf("      -A decode Assembler comment style only\n");
/* #ifndef UNIX_ONLY */
           printf("      -B        Basic style\n");
/* #endif */
           printf("      -C        C++ style\n");
           printf("      -F        Fortran style\n");
           printf("      -P        Pascal style\n");
/* #ifndef PC_ONLY */
           printf("      -S        Shell style\n");
/* #endif */
           printf("      -a append target file\n");
           printf("      -f:\n");

#ifndef UNIX_ONLY
           printf("          find language ( .ASM .BAS .C .FOR .PAS .PRO )\n");
#endif

#ifndef PC_ONLY
           printf("          find language ( .s .S .c .h .i .f .F .r .p .sh .csh )\n");
#endif

           printf("      -j use only with project sources file.\n");
           printf("      -l and p;   line:  (compil.: %c or %c in first column or %c in line)\n",CD1,CD2,CD3);
           printf("                  page:  (compil.: begin with %c and end with %c)\n",CD4,CD5);
           printf("      -n insert line number\n");
           printf("      -s copy and add to screen\n");
           printf("      -t copy the comment only\n");
           printf("      -v verbose\n");
           printf("      -w overwrite (default option: switch off)\n");
           printf(" --> char_codes: all ASCII ");

#ifdef PC
           printf("except space:' '  (5 char max)\n");
           printf("                 example codes = UM or *OPTw or *HOS or ** for all\n");
#endif

#ifdef UNIX
           printf(" (5 char max)\n");
           printf("                 example codes = UM or \\*OPTw or '* HOS' or '**' for all\n");
#endif

           printf(" --> path_source: source file (option j: if it is a project file) \n");
           printf(" --> path_target: target file\n");

#ifdef UNIX
           printf("Example: mkdoc -Csnv '*S' file.c \\*.verif_struct\n");
#endif

#ifdef PC
           printf("Example: mkd -Cs *Snv file.c *.str\n");
#endif
           printf(".Exit 2\n");
           exit(2); /* Pour un controle eventuel (make) */
           } /*S*/
        } /*S syntaxe */


/*O sinon executer la suite de la commande: */
     else
        { /*S corps */

/*O   valider QUIT par CTRL \ */
#ifdef UNIX
        signal(SIGQUIT,SIG_DFL);
#endif

/*www n'est pas utile lorsque break est 'on' avant lancement de mkd
 eliminer cette procedure evite la recherche de command.com sur disque.
#ifdef PC
        c=system("BREAK ON");
#endif
www*/

/*O    init fsrc & fdoc buffers */
           for(i=0;i<MAX;fsrc[i]='\0',fdoc[i]='\0',++i);
/*O    init options par defaut */
           {A=0;B=0;C=0;F=0;P=0;S=0;a=0;f=0;j=0;l=0;n=0,p=0;s=0;t=0;v=0;w=0;} /*O*/
           O=0; /* Option=0 */
/*O    si argc>3 */
           if (argc>3)
           { /*S argc>3 */
/*O       si en 2 eme parametre 1er char = '-' decoder les options */
              if( argv[1][0]=='-')
              { /*S*/
/*O          initialiser les parametres du tant que */
                 O=1; /* Option=1 */
                 c=1;
                 i=1;
/*O          tant que pas fin parametres options & (5 options max) */
                 while (c != '\0' && i < 13)
                 { /*S*/
/*O             valider les options */
                    if ((c=argv[1][i]) == 'a') a=1;
                    else if (c=='w') w=1;
                       else if (c=='l') l=1;
                           else if (c=='p') p=1;
                              else if (c=='j') j=1;
                                 else if (c=='f') f=1;
                                    else if (c=='s') s=1;
                                       else if (c=='t') t=1;
                                          else if (c=='A') A=1;
                                             else if (c=='B') B=1;
                                                else if (c=='C') C=1;
                                                   else if (c=='F') F=1;
                                                      else if (c=='P') P=1;
                                                         else if (c=='S') S=1;
                                                            else if (c=='n') n=1;
                                                               else if (c=='v') v=1;
                    i++;
                 } /*S*/
/*O          si A+B+C+F+P+S > 1 il y a erreur le dire et quitter */
              if((L=A+B+C+F+P+S)>1)
                 {
                 printf("Syntax error: Too many 'Language' options:\n");
                 printf(" A or B or C or...please.\n.Exit 2\n");
                 exit(2);
                 }
/*O          sinon si option langage = 1 imposer (find) f = 0 */
              else if(L==1)
                 {
                 f=0;
                 }
/*O             sinon si pas d'option de langage et p=1 ou l=1 alors f=0 */
                 else if (L==0 && p==0 && l==0) f=1;

/*O          si a=1 et w=1 alors a=w=0 */
                 if (a==1 && w==1)
                 {
                 if (v) printf("Options a or w please... ");
                 a=w=0;
                 }
              } /*S*/
              /*wwwO sinon ecrire Option syntax error (OPTION DE COMPILATION) */
              /*www else {printf("Option '-' syntax error\n");exit(2);} */
           } /*S argc>3 */

/*O    si langage et mode verbose : */
        if(L && v)
           { /*SL*/
/*O       donner les options a l'ecran */
           printf ("Force language comment, style ");
           if(A)printf("ASSEMBLER\n");
           else if(B)printf("BASIC\n");
              else if(C)printf("C\n");
                 else if(F)printf("FORTRAN\n");
                    else if(P)printf("PASCAL\n");
                       else if(S)printf("SHELL\n");
           } /*SL*/

           if (v) printf ("Options a=%d f=%d j=%d l=%d n=%d p=%d s=%d t=%d w=%d\n",a,f,j,l,n,p,s,t,w);

/*###########################################################################*/
/*O    si ( argc > 3 et Opt ) examiner les cas ramenes a path_target=""      */
/*###########################################################################*/
        if (argc > 3+O && ((c=argv[O+3][0])=='.'||c=='*') )
           { /*S cas ramenes */
           if(c=='*')
              { /*S *. *.* */
              if(argv[O+3][1]=='.'&&((c=argv[O+3][2])=='*'||c=='\0') )argc=O+3;
              } /*S * */
           else
              { /*S . */ /*P meme repertoire */
              if(argv[O+3][1]=='\0')argc=O+3;
/*      Les cas '\*'.... sont examines plus loin */
              } /*S . */
           } /*S cas ramenes */

/*##########################################################################*/
/*O    si argc<4 ou (argc<5 avec Options)
                  - ligne de commande "mkdoc -options char_codes path"
                  -                ou "mkdoc char_codes path"
                  - (source et dest auront meme path avec suffixe different) */
/*###########################################################################*/
           if (argc<4+O)
           { /*S meme path */

/*O       alors si j=1 fprj=4eme argument de la ligne de commande */
              if (j==1) fprj=argv[3]; /* fichier projet si j */

/*O       fsrc=O+2eme arg. de la ligne de commande a copier dans fsrc */
              { /*S source */
              k=0;isource=0;
              c=1;
#ifdef PC
              if(argv[O+2][1]==':')isource=2;
#endif
              for (i=0; c != '\0' && i < MAX-5;++i)
                 { /*S*/
                 if((c=argv[O+2][i])=='.')k=i; /* pour find */
#ifdef PC
                 if(c=='\\')isource=i+1;
#endif
#ifdef UNIX
                 if(c=='/')isource=i+1;
#endif
                    else if(c=='*')
                    { /*S*/
                    printf("Syntax error '*' in path_source.\n.Exit 2\n");
                    exit(2);
                    } /*S*/
                 fsrc[i]=c;
                 } /*S*/
#ifdef PC
/*O             si  '\:'  adresser un message d'erreur et quitter */
                 if (isource==1&&argv[O+2][1]==':')
                 { /*S*/
                 printf("Arg. syntax error '\\:'\n.Exit 2 \n");
                 exit(2);
                 } /*S*/
#endif

/*O             si find est positionne et pas j: chercher le langage */
                 if(f&&!j)
                 { /*S*/
#include"find.inc.c"

              if (j==1) fprj=argv[O+2]; /* fichier projet si j trouve */
                 } /*S*/
              } /*S source */



/*O       recopier le nomfichier sans path dans fdoc et noter l'emplacement du point s'il existe */
               k=0;
              for ( i = 0 ;(c=argv[O+2][i+isource]) != '\0' && i < MAX-5; ++i )
              { /*S*/
               fdoc[i]=c;
               if(c=='.')k=i;
              } /*S*/
/*O       si le source a le suffixe .DOC l'ecrire et quitter le pgm  */
              if(k)i=k;
              if ( fdoc[i]=='.' && ((c=(fdoc[i+1]))=='d'||c=='D')
                                && ((c=(fdoc[i+2]))=='o'||c=='O')
                                && ((c=(fdoc[i+3]))=='c'||c=='C'))
                 { /*S*/
                 printf("Syntax error: path_source, suffixe '.doc'\n.Exit 2\n");
                 exit(2);
                 } /*S*/
/*O       sinon donner le suffixe .doc au fichier documentaire */
              else
              { /*S*/
              fdoc[i] = '.'  ;
              fdoc[i+1] = 'd' ;
              fdoc[i+2] = 'o' ;
              fdoc[i+3] = 'c' ;
              fdoc[i+4] = '\0' ;
              } /*S*/
           } /*S meme path */


/*###########################################################################*/
/*O    sinon si ( argc > 3 et Opt )
                     -ligne de commande "mkdoc char_codes path_src path_target
                     -     ou " mkdoc -options char_codes path_src path_target
                     -(path doc et path src seront differents) */
/*##########################################################################*/
           else if (argc > 3+O)
              { /*S path differents */
/*O          copier les noms de fichier: */
/*O             si j=1 fprj=4eme argument de la ligne de commande */
                    if (j==1) fprj=argv[3];  /* 3 = O+2 */


/*              fsrc est O+2eme arg. de la ligne de commande a copier dans fsrc */
/*O             copier le path source dans fsrc pour evaluation des parametres */
                    { /*S source */
                    isource=0;itarget=0;
#ifdef PC
                    if(argv[O+2][1]==':')isource=2;
#endif

                    for (i=0; (c=argv[O+2][i]) != '\0' && i < MAX-1;++i)
                       { /*S examen des positions de '/' et '.' */
                       if(c=='.')k=i;  /* pour find */
#ifdef PC
                       else if(c=='\\')isource=i+1;  /* '\:' n'est pas evalue */
#endif
#ifdef UNIX
                       else if(c=='/')isource=i+1;
#endif
                          else if(c=='*')
                          { /*S*/
                          printf("Syntax error '*' in path_source.\n.Exit 2\n");
                          exit(2);
                          } /*S*/
                       fsrc[i]=c;
                       } /*S examen des positions de '/' et '.' */
                       fsrc[i]='\0';

#ifdef PC
/*O                   si  '\:'  adresser un message d'erreur et quitter */
                      if (isource==1&&argv[O+2][1]==':')
                       { /*S*/
                       printf("Arg. syntax error '\\:'\n.Exit 2\n");
                       exit(2);
                       } /*S*/
#endif
/*O                si find est positionne et pas j: chercher le langage */
                    if(f&&!j)
                       { /*S*/
#include "find.inc.c"
/*O                   si le fichier est un fichier projet affecter le nom a fprj */
                       if (j==1) fprj=argv[O+2]; /* fichier projet si j trouve */
                       } /*S*/
                    } /*S source */


/*O             traitement du dernier argument de la ligne de commande */
/*O                reperer  '/ *' ou ':' et '.' dans fdoc */
                    ktar=0;itarget=0;c=1;
#ifdef PC
                    if(argv[O+3][1]==':')itarget=2;
                    for (i=0; c!='\0' && i<MAX-1 ; ++i)
                       { /*S*/
                       if((c=argv[O+3][i])=='\\')
                          { /*S*/
                          if((c=argv[O+3][i+1])=='*')itarget=i+1;
/*O                      si  '\\0' erreur de syntaxe quitter */
                          if(c=='\0')
                             { /* err */
                             printf("Path_target: syntax error at or near '\\'\n.Exit 2\n");
                             exit(2);
                             } /* err */
                          } /*S*/
                       else if(c=='.')ktar=i;
                       } /*S*/
#endif
#ifdef UNIX
                    c=1;
                    for (i=0; c!='\0' && i<MAX-1 ; ++i)
                       { /*S*/
                       if((c=argv[O+3][i])=='/')
                          { /*S*/
                          if((c=argv[O+3][i+1])=='*')itarget=i+1;
/*O                      si  '/ \0' erreur de syntaxe quitter */
                          if(c=='\0')
                             { /* err */
                             printf("Path_target: syntax error at or near '/'\n.Exit 2\n");
                             exit(2);
                             } /* err */
                          } /*S*/
                       else if(c=='.')ktar=i;
                       } /*S*/
#endif
/*O                si nomfichier commence par '*': '/ *' ou ':' ou target commence par '*': */
                    if(itarget||argv[O+3][0]=='*')
/*O                alors: */
                    { /*S*/
/*O                   si * n'est pas en 1ere position copier le path target dans fdoc tq pas '*' */
                       if(itarget){for(i=0;i<itarget;i++)fdoc[i]=argv[argc-1][i];}
/*O                   concatener le nom du fichier source  */
                       k=0;
                       for(i=0;(c=argv[argc-2][i+isource]) !=0 && i < (MAX-5); ++i)
                       { /*S*/
                          fdoc[i+itarget]=c;
/*O                      si il y a un point, noter la derniere place */
                          if(c=='.') k=i+itarget; /* position du dernier '.' dans la recopie */
                       } /*S*/
/*O                   ajouter le suffixe: */
/*O                      si le '.' existe dans le path_target */
                          if( argv[argc-1][ktar]== '.')
                          { /*S*/
/*O                         si c'est .* ou s'il n'est pas suivi d'une chaine */
                             if( (c=argv[argc-1][ktar+1]) =='\0'||c=='*')
/*O                         alors donner le suffixe .doc au fichier documentaire */
                             { /*S*/
                             if(k)i=k;
                             fdoc[i] = '.'  ;
                             fdoc[i+1] = 'd' ;
                             fdoc[i+2] = 'o' ;
                             fdoc[i+3] = 'c' ;
                             fdoc[i+4] = '\0' ;
                             } /*S*/
/*O                         sinon (le '.' existe) concatener le suffixe demande */
                             else
                             { /*S*/
                             for(i=ktar;(c=argv[argc-1][i])!='\0'&&k<(MAX-1);++i)
                                { /*S*/
                                fdoc[k]=c;
                                k++;
                                } /*S*/
                             fdoc[k]='\0';
                             } /*S*/
                          } /*S*/
/*O                      sinon le nom du suffixe est indedermine */
                          else
                          { /*S*/
                          printf("Path target: suffixe not determined.\n");
                          fdoc[k]='\0';
                          } /*S*/
                    } /*S*/

/*O                sinon: xxx xxx. xxx.* .xxx .*  */
                    else
                    { /*S else */
/*O                si le point existe: (abc. abc.def abc.* .abc .*) */
                       if( argv[argc-1][ktar]== '.')
                       { /*S '. */
/*O                   copier le nom du fichier target  */
                       k=0;c=1;
                       for(i=0;(c=argv[argc-1][i]) !=0 && i < (MAX-5); ++i)
                          { /*S*/
                          fdoc[i]=c;
/*O                      noter la position du point dans la recopie */
                          if(c=='.') k=i;
                          } /*S*/
/*O                   ajouter le suffixe: */
/*O                      si le point est suivi de '*' ou rien: */
                          if( (c=argv[argc-1][k+1])=='\0'||c=='*')
/*O                      alors donner le suffixe .doc au fichier documentaire */
                          { /*S xxx.* */
                          fdoc[k] = '.'  ;
                          fdoc[k+1] = 'd' ;
                          fdoc[k+2] = 'o' ;
                          fdoc[k+3] = 'c' ;
                          fdoc[k+4] = '\0' ;
                          } /*S xxx.* */
/*O                      sinon (le '.' existe) concatener le suffixe demande */
                          else
                          { /*S xxx.abc */
                          for(i=0;(c=argv[argc-1][i+ktar])!='\0'&&k<(MAX-1);++i)
                             { /*S*/
                             fdoc[i+k]=c;
                             } /*S*/
                          fdoc[i+k]='\0';
                          } /*S xxx.abc*/
                       } /*S '.' */

/*O                   sinon le nom du suffixe est indedermine */
                       else /* abcde */
                       { /*S*/
                       for(i=0;(c=argv[argc-1][i]) != '\0' && i<MAX-1;fdoc[i]=c,++i);
                       printf("Path target: suffixe not determined.\n");
                       fdoc[i]='\0';
                       } /*S*/
                    } /*S else */
              } /*S path differents */

/*########### controle des arguments ########################################*/
/*O    si le fichier source est idendique au fichier target : */
        k=1;
        for(i=0;k>0&&i<MAX;i++)
           { /*S*/
#ifdef PC
           c=toupper(fdoc[i]);
           c1=toupper(fsrc[i]);
           if(c>0 && c!=c1)k=0;                         /* exit */
           else if(c=='\0'|| fsrc[i]=='\0')k=0;         /* exit */
#endif
#ifdef UNIX
           if((c=fdoc[i])>0&&c!=fsrc[i])k=0;            /* exit */
           else if(c=='\0'|| fsrc[i]=='\0')k=0;         /* exit */
#endif
/*Test     printf("%c%c",c,fsrc[i]); */
           } /*S*/
       if(c=='\0'&& fsrc[i]=='\0')
/*O    alors : */
           { /*S*/
/*O       envoi du message d'erreur et quitter */
           printf("Syntax error: (path_source : \'%s\') == (path_target = \'%s\')\n",fsrc,fdoc);
           printf(".Exit 2 \n");
           exit(2);
           } /*S*/

/*## FIN DE L'EXAMEN DES ARGUMENTS ##########################################*/

/*O    copier les codes dans le buffer codes */
           for ( i = 0 ; *(argv[1+O]+i) != '\0' && i < 5 ; ++i) codes[i] = *(argv[1+O]+i);
           if(codes[0]=='*'&&codes[1]=='*')codes[0]=0;
           /*T printf("code nx1 pour test: %c\n",codes[0]); T*/

/*O    si option v ecrire le nom du fichier documentaire a l'ecran */
        if(v) printf("doc file : \'%s\' \n", fdoc);
/*O    si pas d'option a ni w v‚rifier l'existence et ses protections */
        if (w==0 && a==0)
           { /*S si !a !w */
/*O       si le fichier existe: */
           if( (access(fdoc, 00 )) == 0 )
/*O       alors si il n'est pas prot‚g‚ en ‚criture */
              if( (access(fdoc, 02 )) == 0 )
              { /*S*/
/*O          alors demander si overwrit ...si pas 'y'es quitter le programme */
                 {
                 printf("\n OVERWRIT \'%s\' ...  y?\n",fdoc);
                 if ( (c=(getch()))=='y' || c=='Y');
                 else
                    { /*S*/
                    printf(".Exit 1\n");
                    exit(1);
                    } /*S*/
                 }
              } /*S*/
/*O          sinon pr‚ciser qu'il existe et est prot‚g‚ puis quitter avec retour = 2 */
              else
              { /*S*/
                 printf("%s is write protected.\n", fdoc);
                 puts(".Exit 2\n");
                 exit(2);
              } /*S*/
/*O       faire option w=1 (puisque overwrit) */
              w=1;
           } /*S si !a !w */


/*O    si option a ouvrir fdoc en ajout */
           if (a==1)
           { /*S option a */
/*O       si erreur l'ecrire et sortir */
#ifdef VC10
			  if ( fopen_s( &pfdoc,fdoc,"ab") != 0 )
#else
              if((pfdoc = fopen(fdoc,"ab")) == NULL)
#endif
              {
              printf("fopen file \'%s\' error for append\n.Exit 2\n",fdoc);
              exit(2);
              }
           } /*S option a */
/*O       sinon si option w ouvrir fdoc en ecriture */
              else if (w==1)
                 { /*S option w */
/*O             si erreur l'ecrire et sortir */
#ifdef VC10
					 if (fopen_s(&pfdoc,fdoc,"wb") != 0)
#else
                     if((pfdoc = fopen(fdoc,"wb")) == NULL)
#endif
                     { /*S*/
                     printf("fopen file \'%s\' error for overwrit\n.Exit 2\n",fdoc);
                     exit(2);
                     } /*S*/
                 } /*S option w */
/*T          sinon ecrire message d'erreur -a -w pas trouve */
                 else /* ne doit jamais arriver.... */
                 { /*Test*/
                 printf("error option -a or -w not found\n");
                 exit(255);
                 } /*Test*/

/*O    si option j */
           if (j==1)
           { /*S si option j */
/*O       ecrire le nom du fichier projet a l'ecran */
              printf("project file : \'%s\' \n", fprj);
/*O       si erreur d'ouverture ecrire not found et quitter le programme */
#ifdef VC10
			  if ( fopen_s(&pfprj,fprj,"r") != 0 )
#else
			  if (( pfprj = fopen ( fprj,"r" )) == 0 )
#endif
              { /*S*/
              printf ("project file \'%s\' not found\n.Exit 2\n",fprj);
              exit(2);
              } /*S*/
/*O       sinon : */
              else
              { /*S copy src & tri */
/*O          tant que pas fin de fichier projet */
                 while ( (c = getc(pfprj)) != EOF )
                 { /*S tq !EOF */
/*O             lire le nom du fichier a documenter */
                    ungetc(c,pfprj);
                    for (i=0 ; (c = getc(pfprj)) != '\n' && c != EOF ;
                         ++i) fsrc[i] = (char)c ;
                    fsrc[i] = '\0';
/*O             si le nomfichier existe et ne commence pas par '#' */
                 if( fsrc[0]!='\0' || fsrc[0]!='#' )
                 { /*S namefile exist */
/*O                si option v ecrire le nom du fichier a documenter */
                    if(v) printf("\n\nfile for doc: \'%s\'\n",fsrc);
/*O                si option f determiner la place du point separateur du langage */
                    if(f)
                    { /*S source */
                    k=0;
                    c=1;
/*O                   determiner l'emplacement du point s'il existe */
                       for (i=0; fsrc[i] != '\0' && i < MAX-5;++i)
                      { /*S*/
                       if(fsrc[i]=='.')k=i;
                       } /*S*/
                    if(k)
#include "find.inc.h"
#include "find.inc.c"
                    } /*S source */

/*O                si le decriptage (langage) est determine */
                    if(L==1||p||l)
/*O                alors: */
                       { /*S alors*/
/*O                   si l'ouverture du fichier source n'est pas correcte */
#ifdef VC10
						  if ( fopen_s(&pnfile,fsrc,"rb" ) != 0 )
#else
                          if  (( pnfile = fopen ( fsrc,"rb" )) == 0 )
#endif
/*O                      ecrire file "nomfich" not found */
                             printf ("file \'%s\' not found for read\n",fsrc);
/*O                   sinon call tri ou langage */
                          else
                          { /*S else*/
/*O                      	si: on a option n ou s et mode bavard (option v) écrire le nom du fichier lu et les options */
							if(n||s||v) /*www modifié le 10/03/2010 par JPL */
							{ /*S si*/
								if(v)fprintf(pfdoc,"%s\n(file %s :)", NL, fsrc );
								if( v || s ) printf("\n\n(file %s :)\n",fsrc);
								if(v)fprintf (pfdoc,"Options a=%d f=%d j=%d l=%d n=%d p=%d s=%d t=%d w=%d",a,f,j,l,n,p,s,t,w);
								fprintf (pfdoc, "%s", NL );
							} /*S fin si*/
                          if(l||p)tri_(pfdoc,pnfile);
                          if(A)asm_(pfdoc,pnfile);
                             else if(B)basic_(pfdoc,pnfile);
                                else if(C)cpp_(pfdoc,pnfile); /*www modifié le 10 mars 2010 */
                                   else if(F)fortran_(pfdoc,pnfile);
                                      else if(P)pascal_(pfdoc,pnfile);
                                         else if(S)shell_(pfdoc,pnfile);
                                            else if(l==0&&p==0)printf("Error, language not determined !.\n");
/*O                      fermer le fichier source */
                          if (fclose(pnfile))
                             { /*S si*/
                             printf("Closure error: \'%s\'\n.Exit 2\n",fsrc);
                             /*www exit(2); */
                             } /*S fin si*/
                          } /*S fin else*/
                       } /*S fin alors*/
                    } /*S namefile exist */
                 } /*S tq !EOF */
/*O          fermer le fichier projet */
                 if (fclose(pfprj))
                 { /*S*/
                 printf("Closure error: \'%s\'\n.Exit 2\n",fprj);
                 exit(2);
                 } /*S*/
              } /*S copy src & tri */
           } /*S si option j */
/*O    sinon: (pas option j) */
           else
           { /*S !j */
/*O       si option v ecrire le nom du fichier a documenter */
              if(v) printf("\n\nfile for doc: \'%s\' \n",fsrc);
/*O       si l'ouverture du fichier n'est pas correcte */
#ifdef VC10
			  if ( fopen_s(&pnfile,fsrc,"rb") != 0 )
#else
			  if (( pnfile = fopen ( fsrc,"rb" )) == 0 )
#endif
              { /*S*/
/*O          ecrire file "nomfich" not found */
                 printf("file \'%s\' not found for read\n.Exit 2\n",fsrc);
                 exit(2);
              } /*S*/
/*O       sinon call langage... */
              else
              { /*S*/
/*O          si: on a option n (on n'a pas l'option j) et mode bavard (option v) écrire le nom du fichier lu et les option */
              if(n||v||s) /*www modifié le 10/03/2010 par JPL */
                 { /*S*/
					if(v)fprintf(pfdoc,"%s\n(file %s :)", NL, fsrc );
					if( v || s ) printf("\n\n(file %s :)\n",fsrc);
					if(v)fprintf (pfdoc,"Options a=%d f=%d j=%d l=%d n=%d p=%d s=%d t=%d w=%d",a,f,j,l,n,p,s,t,w);
					fprintf (pfdoc, "%s", NL );
                 } /*S*/
              if(l||p) tri_(pfdoc,pnfile);
              if(A)asm_(pfdoc,pnfile);
              else if(B)basic_(pfdoc,pnfile);
                 else if(C) cpp_(pfdoc,pnfile); /*www modifié le 10/03/2010 par JPL */
                    else if(F)fortran_(pfdoc,pnfile);
                       else if(P)pascal_(pfdoc,pnfile);
                          else if(S) shell_(pfdoc,pnfile);
                                else if(l==0&&p==0)
                                { /*S*/
                                printf("Error, language not determined !.\n.Exit 2\n");
                                exit(2);
                                } /*S*/
/*O          fermer le fichier depouille */
                 if (fclose(pnfile))
                 { /*S*/
                 printf("Closure error: \'%s\'\n.Exit 2 \n",fdoc);
                 exit(2);
                 } /*S*/
              } /*S*/
           } /*S !j */
/*O    fermer le fichier documentaire */
           if (fclose(pfdoc))
           { /*S*/
           printf("Closure \'%s\' error\n.Exit 2\n",fdoc);
           exit(2);
           } /*S*/
/*O    ecrire DOC "file_src" END */
           if(v) printf("\n\nDOC %s END\n",fdoc);
        } /*S corps */
} /*S main */
Outils personnels