Exemple de script C :


/* FONCTION REPRISE DE util.c 
 * ====================================================================
 * Copyright (c) 1995 The Apache Group.  All rights reserved.
 * ====================================================================
 * http://www.apache.org/
 * 
 * 
 * Nicolas Cros - CICT - Novembre 96
 */

int ind(const char *s, char c) {
    register int x;

    for(x=0;s[x];x++)
        if(s[x] == c) return x;

    return -1;
}

main()
{
    register int x;
    char *chaine;

    /* Ici on souhaite filtrer tous les caracteres de controle du shell */
    scanf("%s",chaine);
    
    for(x=0;chaine[x];x++) {
        if(ind("&;`'\"|*?~<>^()[]{}$\\\n\t",chaine[x]) != -1)
	  {
            printf ("Le caractere %c est interdit\n",chaine[x]);
	  }
	else
	  {
	    printf ("%c",chaine[x]);
	  }
    }


}


Pour récupérer le script, cliquer ici.

Mis à jour le 02/06/97
[Sommaire CICT] CICT
Vos commentaires sur ce serveur : www@cict.fr