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 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187
| #include <stdio.h>
#include <unistd.h>
int main(void)
{
void num(int,char[2100],FILE*,FILE*);
void type(int,char[2100],FILE*,FILE*);
void initialise(char[2100]);
char ligne[2100];
FILE* fIn;
FILE* fOut;
int position,j,type_ligne;
if((fIn= fopen("YSTOCK.D", "rb")) == NULL) // ouverture du fichier source
{
printf("erreur, mauvais fichier source rentré");
system("pause");
return (1);
}
if((fOut = fopen("stock.tmp", "w")) == NULL) //ouverture du fichier destination
{
printf("erreur, mauvais fichier destination entré");
fclose(fIn);
return (1);
}
fprintf(fOut,"numero;prix achat;remarque;formule;prix vente euros;prix vente francs;\n");
while(fgets(ligne, sizeof ligne, fIn)!=NULL)
{
type_ligne=0;
if (ligne[0]==0 && (ligne[1]=='N' || ligne[1]==' ') && ligne[2]==' ' && ligne[3]==' ' && ligne[169]=='0' && ligne[170]=='0')
{
type_ligne=10;
}
if (ligne[0]==0 && ligne[1]==1 && ligne[2]==0 && ligne[3]==1 && ligne[4]=='0' && ligne[5]=='0')
{
type_ligne=11;
}
if (ligne[0]==0 && ligne[1]=='À' && (ligne[7]==26 || ligne[7]== 42) && ligne[9]=='N' && ligne[10]==' ' && ligne[176]==1 && ligne[177]=='0')
{
type_ligne=12;
}
if (ligne[0]==0 && ligne[1]=='À' && (ligne[7]==26 || ligne[7]== 42) && ligne[9]=='N' && ligne[10]==' ' && ligne[167]==1 && ligne[168]=='0' )
{
type_ligne=13;
}
if (ligne[0]==0 && ligne[1]==0 && (ligne[2]=='M' || ligne[2]=='L' || ligne[2]=='S' || ligne[2]=='F'))
{
type_ligne=20;
}
if (ligne[0]==0 && ligne[1]=='À' && ligne[9]=='À'&& (ligne[17]=='M' || ligne[17]=='L' || ligne[17]=='O' || ligne[17]=='S' || ligne[17]=='F' || ligne[17]==' ') )
{
type_ligne=21;
}
if (ligne[0]==0 && ligne[1]==0 && ligne[2]==' ')
{
type_ligne=20;
}
if (ligne[1]==0 && (ligne[2]==' ' || ligne[2]=='O'))
{
type_ligne=20;
}
if (ligne[2]=='M' || ligne[2]=='L' || ligne[2]=='S' || ligne[2]=='F')
{
type_ligne=20;
}
if (isdigit(ligne[1]) && isdigit(ligne[2]) && isdigit(ligne[3]) && isdigit(ligne[4]) && isdigit(ligne[5]) && isdigit(ligne[6]) && isdigit(ligne[7]) && isdigit(ligne[8]))
{
type_ligne=30;
}
switch(type_ligne)
{
case 10 :
fprintf(fOut,"\n");
num(169,ligne,fIn,fOut);
break;
case 11 :
fprintf(fOut,"\n");
num(4,ligne,fIn,fOut);
break;
case 12 :
fprintf(fOut,"\n");
num(177,ligne,fIn,fOut);
break;
case 13 :
fprintf(fOut,"\n");
num(167,ligne,fIn,fOut);
break;
case 20 :
fprintf(fOut,"00001.00;");
type(2,ligne,fIn,fOut);
break;
case 21 :
for(j=12;j<16;j++)
{
if (ligne[j]=='a')
fprintf(fOut,".");
else fprintf(fOut,"%02x",ligne[j]);
}
fprintf(fOut,";");
type(17,ligne,fIn,fOut);
break;
/* case 30 :
for(j=1;j<9;j++)
{
fprintf(fOut,"%c",ligne[j]);
}
fprintf(fOut,";");
break;*/
}
initialise(ligne);
}
fclose(fIn);
fclose(fOut);
return(0);
}
void num(int decalage,char ligne[2100],FILE* fIn,FILE* fOut)
{int j;
for(j=0+decalage;j<13+decalage;j++)
{
fprintf(fOut,"%c",ligne[j]);
}
fprintf(fOut,";");
}
void type(int decalage,char ligne[2100],FILE* fIn,FILE* fOut)
{
int j;
for(j=0+decalage;j<60+decalage;j++)
{
fprintf(fOut,"%c",ligne[j]);
}
fprintf(fOut,";%c%c%c;",ligne[60+decalage],ligne[61+decalage],ligne[62+decalage]);
for(j=68+decalage;j<72+decalage;j++)
{
if (ligne[j]=='a')
fprintf(fOut,".");
else fprintf(fOut,"%02x",ligne[j]);
}
fprintf(fOut,";");
for(j=76+decalage;j<80+decalage;j++)
{
if (ligne[j]=='a')
fprintf(fOut,".");
else fprintf(fOut,"%02x",ligne[j]);
}
fprintf(fOut,";");
}
void initialise(char ligne[2100])
{int j;
for (j=0;j<2100;j++)
{
ligne[j]=0;
}
} |
Partager