Accueil > > > STRUCTURE DES FICHIERS DBF
STRUCTURE DES FICHIERS DBF
Information sur la source
Description
Pour chaque fichier DBF existant dans le dossier courrant, le programme fait un autre fichier, ayant meme nom et STR comme extension, qui contient code source C utilisable.
Source
- //03-sep-2008 10:06:02
-
- #include <dos.h>
- #include <stdio.h>
- #include <io.h>
- #include <string.h>
- #include <dir.h>
-
- typedef unsigned short ushort;
- typedef unsigned long ulong;
- typedef unsigned char uchar;
-
- #define O_BINARY 0x8000
- #define O_RDONLY 1
-
- struct date d;
-
- ushort RCS,N,N1;
- uchar nom_dbf[40];
- uchar nom_str[40];
- short nf;
- FILE *fis;
-
- ushort i,j,k;
- uchar alfa[100];
-
- struct DBF1
- {
- uchar version;
- uchar aallzz[3];
- ulong nart;
- ushort lg_antet;
- ushort RCS;
- uchar rien[20];
- } ant1;
- struct DBF2
- {
- uchar nom[11];
- uchar tip;
- ushort depl;
- ushort rien1;
- uchar longueur;
- uchar decimals;
- uchar rien2[14];
- } ant2;
- struct ffblk a;
- int I;
- uchar man[1024];
- uchar buf[BUFSIZ];
-
- void main(void)
- {
- getdate(&d);
- sprintf(man,"*.DBF");
- I=findfirst(man,&a,0);
- while(!I)
- {
- strcpy(nom_dbf,a.ff_name);
- I=findnext(&a);
- strcpy(nom_str,nom_dbf);
- sprintf(nom_str+strlen(nom_str)-3,"str");
- printf("\n%s ==> %s",nom_dbf,nom_str);
- if((nf=open(nom_dbf,O_BINARY|O_RDONLY))<1)
- {
- printf("\nFichier %s absent.",nom_dbf);
- return;
- }
- RCS=filelength(nf);
- if(RCS<sizeof(ant1)+sizeof(ant2))
- {
- printf("\nFichier %s trop petit.",nom_dbf);
- return;
- }
- RCS=sizeof(ant1);
- read(nf,&ant1,RCS);
- if(ant1.version<3)
- {
- printf("\nVersion %s incorrecte.",nom_dbf);
- return;
- }
- fis=fopen(nom_str,"wt");
- setbuf(fis,buf);
- fprintf(fis,"//%s\n//RCS:%u NART:%lu\n",
- nom_dbf,ant1.RCS,ant1.nart);
- fprintf(fis,"struct DBF\n");
- fprintf(fis,"{\n");
- sprintf(man,"uchar efface;");
- fprintf(fis,"\t%s\n",man);
- N=(ant1.lg_antet-32)/32;
- N1=0;
- for(i=0;i<N;i++)
- {
- read(nf,&ant2,32);
- if(ant2.nom[0]==0x0D) break;
- N1++;
- for(j=0;j<11;j++)
- {
- if(!ant2.nom[j]) break;
- if(ant2.nom[j]==' ') break;
- }
- sprintf(man,"uchar %*.*s[%u];%100s",
- j,j,ant2.nom,ant2.longueur,"");
- sprintf(man+22," //%c",ant2.tip);
- if(ant2.decimals) sprintf(man+strlen(man),
- " %-2u DEC",ant2.decimals);
- else sprintf(man+strlen(man)," %6s","");
- sprintf(man+strlen(man)," C%u",i+1);
- fprintf(fis,"\t%s\n",man);
- }
- N=N1;
- N1=ant1.lg_antet-(N+1)*32;
- fprintf(fis,"} dbf;\n");
- fprintf(fis,"#define N %lu\n",N);
- fprintf(fis,"struct ANTET_BASE\n");
- fprintf(fis,"{\n");
- fprintf(fis,"\tuchar version;\n");
- fprintf(fis,"\tuchar annee;\n");
- fprintf(fis,"\tuchar mois;\n");
- fprintf(fis,"\tuchar jour;\n");
- fprintf(fis,"\tulong nb_art;\n");
- fprintf(fis,"\tushort lg_antet;\n");
- fprintf(fis,"\tushort RCS;\n");
- fprintf(fis,"\tuchar rien[20];\n");
- fprintf(fis,"\tstruct\n");
- fprintf(fis,"\t{\n");
- fprintf(fis,"\t\tuchar den_champ[11];\n");
- fprintf(fis,"\t\tuchar tip_champ;\n");
- fprintf(fis,"\t\tulong adresse;\n");
- fprintf(fis,"\t\tuchar lg_champ;\n");
- fprintf(fis,"\t\tuchar nb_dec;\n");
- fprintf(fis,"\t\tuchar rien[14];\n");
- fprintf(fis,"\t} champs[N];\n");
- fprintf(fis,"} a=\n");
- fprintf(fis,"{\n");
- lseek(nf,0l,SEEK_SET);
- RCS=sizeof(ant1);
- read(nf,man,RCS);
- man[1]=d.da_year-1900;
- man[2]=d.da_mon;
- man[3]=d.da_day;
- man[4]=man[5]=man[6]=man[7]=0;
- fprintf(fis,"\t");
- fprintf(fis,"%u,%u,%u,%u,0,%u,%u,\
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\n",
- man[0],man[1],man[2],man[3],
- man[9]*256+man[8],man[11]*256+man[10]);
- for(i=0;i<N;i++)
- {
- read(nf,man,RCS);
- fprintf(fis,"\t");
- memset(alfa,0,12);
- for(k=0;k<11;k++)
- {
- if(!man[k]) break;
- alfa[k]=man[k];
- }
- k=11-k;
- fprintf(fis,"\"%s\"%*s,'%c',%4lu,%3u,%2u,\
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0",
- alfa,k,"",man[11],man[12]+256l*(man[13]+
- 256l*(man[14]+256l*man[15])),man[16],man[17]);
- if(i<N-1) fprintf(fis,",");
- fprintf(fis,"\n");
- }
- fprintf(fis,"};\n");
- if(N1)
- {
- N=N1/RCS;
- fprintf(fis,"uchar b[%lu]=\n{",N1);
- N1-=N*RCS;
- for(i=0;i<N;i++)
- {
- read(nf,man,RCS);
- fprintf(fis,"\n\t");
- for(j=0;j<RCS;j++)
- {
- fprintf(fis,"%u",man[j]);
- if(N1||j<RCS-1||i<N-1) fprintf(fis,",");
- }
- }
- if(N1)
- {
- read(nf,man,N1);
- fprintf(fis,"\n\t");
- for(j=0;j<N1;j++)
- {
- fprintf(fis,"%u",man[j]);
- if(j<N1-1) fprintf(fis,",");
- }
- }
- fprintf(fis,"\n};\n");
- }
- fclose(fis);
- close(nf);
- }
- }
//03-sep-2008 10:06:02
#include <dos.h>
#include <stdio.h>
#include <io.h>
#include <string.h>
#include <dir.h>
typedef unsigned short ushort;
typedef unsigned long ulong;
typedef unsigned char uchar;
#define O_BINARY 0x8000
#define O_RDONLY 1
struct date d;
ushort RCS,N,N1;
uchar nom_dbf[40];
uchar nom_str[40];
short nf;
FILE *fis;
ushort i,j,k;
uchar alfa[100];
struct DBF1
{
uchar version;
uchar aallzz[3];
ulong nart;
ushort lg_antet;
ushort RCS;
uchar rien[20];
} ant1;
struct DBF2
{
uchar nom[11];
uchar tip;
ushort depl;
ushort rien1;
uchar longueur;
uchar decimals;
uchar rien2[14];
} ant2;
struct ffblk a;
int I;
uchar man[1024];
uchar buf[BUFSIZ];
void main(void)
{
getdate(&d);
sprintf(man,"*.DBF");
I=findfirst(man,&a,0);
while(!I)
{
strcpy(nom_dbf,a.ff_name);
I=findnext(&a);
strcpy(nom_str,nom_dbf);
sprintf(nom_str+strlen(nom_str)-3,"str");
printf("\n%s ==> %s",nom_dbf,nom_str);
if((nf=open(nom_dbf,O_BINARY|O_RDONLY))<1)
{
printf("\nFichier %s absent.",nom_dbf);
return;
}
RCS=filelength(nf);
if(RCS<sizeof(ant1)+sizeof(ant2))
{
printf("\nFichier %s trop petit.",nom_dbf);
return;
}
RCS=sizeof(ant1);
read(nf,&ant1,RCS);
if(ant1.version<3)
{
printf("\nVersion %s incorrecte.",nom_dbf);
return;
}
fis=fopen(nom_str,"wt");
setbuf(fis,buf);
fprintf(fis,"//%s\n//RCS:%u NART:%lu\n",
nom_dbf,ant1.RCS,ant1.nart);
fprintf(fis,"struct DBF\n");
fprintf(fis,"{\n");
sprintf(man,"uchar efface;");
fprintf(fis,"\t%s\n",man);
N=(ant1.lg_antet-32)/32;
N1=0;
for(i=0;i<N;i++)
{
read(nf,&ant2,32);
if(ant2.nom[0]==0x0D) break;
N1++;
for(j=0;j<11;j++)
{
if(!ant2.nom[j]) break;
if(ant2.nom[j]==' ') break;
}
sprintf(man,"uchar %*.*s[%u];%100s",
j,j,ant2.nom,ant2.longueur,"");
sprintf(man+22," //%c",ant2.tip);
if(ant2.decimals) sprintf(man+strlen(man),
" %-2u DEC",ant2.decimals);
else sprintf(man+strlen(man)," %6s","");
sprintf(man+strlen(man)," C%u",i+1);
fprintf(fis,"\t%s\n",man);
}
N=N1;
N1=ant1.lg_antet-(N+1)*32;
fprintf(fis,"} dbf;\n");
fprintf(fis,"#define N %lu\n",N);
fprintf(fis,"struct ANTET_BASE\n");
fprintf(fis,"{\n");
fprintf(fis,"\tuchar version;\n");
fprintf(fis,"\tuchar annee;\n");
fprintf(fis,"\tuchar mois;\n");
fprintf(fis,"\tuchar jour;\n");
fprintf(fis,"\tulong nb_art;\n");
fprintf(fis,"\tushort lg_antet;\n");
fprintf(fis,"\tushort RCS;\n");
fprintf(fis,"\tuchar rien[20];\n");
fprintf(fis,"\tstruct\n");
fprintf(fis,"\t{\n");
fprintf(fis,"\t\tuchar den_champ[11];\n");
fprintf(fis,"\t\tuchar tip_champ;\n");
fprintf(fis,"\t\tulong adresse;\n");
fprintf(fis,"\t\tuchar lg_champ;\n");
fprintf(fis,"\t\tuchar nb_dec;\n");
fprintf(fis,"\t\tuchar rien[14];\n");
fprintf(fis,"\t} champs[N];\n");
fprintf(fis,"} a=\n");
fprintf(fis,"{\n");
lseek(nf,0l,SEEK_SET);
RCS=sizeof(ant1);
read(nf,man,RCS);
man[1]=d.da_year-1900;
man[2]=d.da_mon;
man[3]=d.da_day;
man[4]=man[5]=man[6]=man[7]=0;
fprintf(fis,"\t");
fprintf(fis,"%u,%u,%u,%u,0,%u,%u,\
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\n",
man[0],man[1],man[2],man[3],
man[9]*256+man[8],man[11]*256+man[10]);
for(i=0;i<N;i++)
{
read(nf,man,RCS);
fprintf(fis,"\t");
memset(alfa,0,12);
for(k=0;k<11;k++)
{
if(!man[k]) break;
alfa[k]=man[k];
}
k=11-k;
fprintf(fis,"\"%s\"%*s,'%c',%4lu,%3u,%2u,\
0,0,0,0,0,0,0,0,0,0,0,0,0,0",
alfa,k,"",man[11],man[12]+256l*(man[13]+
256l*(man[14]+256l*man[15])),man[16],man[17]);
if(i<N-1) fprintf(fis,",");
fprintf(fis,"\n");
}
fprintf(fis,"};\n");
if(N1)
{
N=N1/RCS;
fprintf(fis,"uchar b[%lu]=\n{",N1);
N1-=N*RCS;
for(i=0;i<N;i++)
{
read(nf,man,RCS);
fprintf(fis,"\n\t");
for(j=0;j<RCS;j++)
{
fprintf(fis,"%u",man[j]);
if(N1||j<RCS-1||i<N-1) fprintf(fis,",");
}
}
if(N1)
{
read(nf,man,N1);
fprintf(fis,"\n\t");
for(j=0;j<N1;j++)
{
fprintf(fis,"%u",man[j]);
if(j<N1-1) fprintf(fis,",");
}
}
fprintf(fis,"\n};\n");
}
fclose(fis);
close(nf);
}
}
Historique
- 03 septembre 2008 11:54:29 :
- Title
Sources du même auteur
Sources de la même categorie
Commentaires et avis
Discussions en rapport avec ce code source dans le forum
Taille de ma structure [ par crocejf2000 ]
Salut a tous, J'ai un tres gros probleme qui me bloque toute mon avancé dans mon prog : j'ai une structure : typedef struct{ unsigned short Locate; ch
structure d'un fichier video [ par jopop ]
Je cherche à connaître la structure d'un fichier video du type AVI, voire plus simple s'il en est. De la même manière que l'on trouve cette structure
dessiner des polygones a partir d'n fichier [ par NICKO ]
Bonjour,Je cherche à dessiner des polygones (2 triangles pour commencer) dont les informations sont contenues dans un fichier.J'utilise les fonctions
Lecture Ecriture fichier [ par wannie ]
Salut tt le monde. Je suis nouveau ici et j'aimerai beaucoup obtenir de l'aide de développeur confirmé.Comme je suis novice sous le langage C++ j'aime
Info Dbase et C [ par coopertel ]
Bonjour,Je me lance dans la prog C (pas ++).J'ai comme compilateur Miracle C et Borland 5 ligne de commande.Je développe uniquement de programme sans
Règles d'alignement + structure + fichier [ par visualstar ]
Bonsoir, J'ai fais un p'tit programme qui écris simplement des structures dans un fichier. Puis après je fais le dump du fichier en question et j'aura
Fonction dans une structure ? [ par mayti ]
Bonjour, voilà j'esseye d'utiliser une fonction dans une structure pour par exemple effacer un fichier: struct FICHIER {
Structure d'un fichier IFO [ par highcobra ]
Salut à tous, Qqun pourrait-il me dire comment sont architecturés les fichiers IFO contenus sur les DVD... Merci d'avanceHigh_Cobra ;)
fichier binaire [ par stivi_45 ]
Bonjour a tous, j'ai une petite question, je travaille sur un fichier binaire en c.Je stocke des informations dans ce fichier avec une structure : typ
Fichiers ico, taille et structure ? [ par anarchysniper ]
Disposant d'un pointeur vers le début d'un fichier .ico dans une ressource, comment obtenir l'emplacement de la donnée suivante ? En fait il
|
Derniers Blogs
SESSION SILVERLIGHT 5 3D : SLIDES ET DEMOSSESSION SILVERLIGHT 5 3D : SLIDES ET DEMOS par Groc
Durant les techdays, j'ai eu le plaisir d'animer une session sur Silverlight 5 et la 3D avec Simon Ferquel. Comme promis, voici nos slides et mes démos (celles avec le viper BSG) ici et là. Pour mémoire, les démos utilisent toutes le viper BSG...
Cliquez pour lire la suite de l'article par Groc [TECHDAYS 2012] SESSION WEBMATRIX 2 : LE COUTEAU SUISSE GRATUIT POUR VOS DéVELOPPEMENTS WEB - SLIDES[TECHDAYS 2012] SESSION WEBMATRIX 2 : LE COUTEAU SUISSE GRATUIT POUR VOS DéVELOPPEMENTS WEB - SLIDES par gpommier
Suite à la session que j'ai présenté sur WebMatrix 2, vous pouvez trouver les slides ici, ainsi que les démos en packages nuget : démos1 et démos2 J'en profite pour remercier chaleureusement tous ceux qui sont venus très nombreux à cette sess...
Cliquez pour lire la suite de l'article par gpommier [SHAREPOINT] LES SESSIONS TECHDAYS 2012.[SHAREPOINT] LES SESSIONS TECHDAYS 2012. par Patrick Guimonet
Voici donc pour ceux qui n'ont pas pu venir, ou ceux qui n'ont pas pu toutes les suivre la liste des sessions SharePoint aux TechDays 2012, que je mettrais à jour dès que les liens des vidéo seront disponibles. Ou ici : http...
Cliquez pour lire la suite de l'article par Patrick Guimonet TECHDAYS PARIS 2012 : SESSION PLEINIèRE JOUR 3TECHDAYS PARIS 2012 : SESSION PLEINIèRE JOUR 3 par ROMELARD Fabrice
Speaker: Bernard Ourghanlian Cette session est comme chaque jour transmise en live par BrainSonic, et j'ai donc suivi cette troisième pleinière par ce moyen sur mon iPad . Elle est dédiée comme chaque année à la mise en perspective de l'é...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice MISHRA READER : UN LECTEUR RSS TRèS ZUNE STYLE EN OPEN SOURCE !MISHRA READER : UN LECTEUR RSS TRèS ZUNE STYLE EN OPEN SOURCE ! par Vko
Hier durant une session dédiée aux Techdays 2012, j'ai eu le plaisir d'annoncer la sortie de la Béta 2 de Mishra Reader. C'est quoi ? Pour les utilisateurs, c'est une vraie expérience de lecture de flux RSS sur Windows. Rien à voir avec les produit...
Cliquez pour lire la suite de l'article par Vko
Logiciels
Tribler (2012)TRIBLER (2012)Tribler est un client pair à pair (P2P/Peer-to-Peer) open source avec la capacité de regarder des... Cliquez pour télécharger Tribler OneSwarm (2012)ONESWARM (2012)Le peer-to-peer qui protège votre vie privée, c'est OneSwarm.
Ce logiciel de peer-to-peer crypté... Cliquez pour télécharger OneSwarm PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO (V8.4)PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO (V8.4)PONAMEDIA TV DEVIENS HELLLOOO FLASH
LA TV SUR VOTRE ORDINATEUR.
Toute une plateforme Multi... Cliquez pour télécharger PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO Academy System (17.2.1.0)ACADEMY SYSTEM (17.2.1.0)Logiciel de gestion des établissements.
- élèves/étudiants (inscription, dossier, absence...)
-... Cliquez pour télécharger Academy System Easy-Planning (1.0.0.1)EASY-PLANNING (1.0.0.1)Basé sur les mêmes principes que MyPlanning, Easy-Planning permet de créer des plannings sous la ... Cliquez pour télécharger Easy-Planning
|