1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
|
void creer_template(HANDLE port,char *pointeur_ip,char *pointeur_masque,char *pointeur_passerelle,char *pointeur_nom_qualif,char *pointeur_location,char *pointeur_choix){
int i = 0 ;
//Création de pointeur sur fichier
FILE* fichier = NULL;
FILE* new_fichier = NULL;
int NbLus;
char buffer[512];
char ip_tftp[] = "*.*.*.*";
char *input[4];
char buffer_ligne_0[512];
char buffer_ligne_1[512];
char buffer_ligne_2[512];
char buffer_ligne_3[512];
char target[255];
sprintf(target,"\\\\*.*.*.*\\tftp\\%s",pointeur_nom_qualif);
fichier = fopen("template_a2", "r"); //overture template
//new_fichier = fopen("\\\\10.75.23.200\\tftp\\new_template_a2", "w+"); //creation new_template_a2
new_fichier = fopen(target, "w+"); //creation new_template_a2
while ((NbLus = fread(buffer, 1, 512, fichier)) != 0) //copy template dans new_template_a2
fwrite(buffer, 1, NbLus, new_fichier);
fclose(fichier);
sprintf(buffer_ligne_0,"set ip address %s mask %s gateway %s \n\0",pointeur_ip,pointeur_masque,pointeur_passerelle);
input[0] = buffer_ligne_0 ;
sprintf(buffer_ligne_1,"set prompt \"%s\" \n\0",pointeur_nom_qualif);
input[1] = buffer_ligne_1 ;
sprintf(buffer_ligne_2,"set system name \"%s\" \n\0",pointeur_nom_qualif);
input[2] = buffer_ligne_2 ;
sprintf(buffer_ligne_3,"set system location \"%s\" \n\0",pointeur_location);
input[3] = buffer_ligne_3 ;
for (i = 0; i < 4 ; i++){
fputs(input[i],new_fichier);
}
fclose(new_fichier);
charger_config(port,pointeur_nom_qualif,ip_tftp);
lecture_com(port);
} |
Partager