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
|
#include <time.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <malloc.h>
/* Fonction qui permet de passer un boundary */
int genererBoundary(char *tab){
time_t now;
int taille;
struct tm now_here;
char *entete="boundary=";
now=time(&now_here);
taille=strlen(entete)+10;
tab=malloc(sizeof(char)*(taille+1));
if(!tab) {
fprintf(stderr,"--erreur de generation de boundary--\n");
return -1;
}
snprintf(tab,taille,"%s%10d",entete,now);
return 0;
}
/* Generer un boundary */
int main (int argc, char* argv[]){
char *bound;
genererBoundary(bound);
fprintf(stdout,"--%s\n",bound);
} |
Partager