WillieBotha
Programmer
Hi,
I am a beginner in C++ and Writing Dat file headers and info. I have to change some of the coding now but I have to know what it exactly does ?
Thanks a lot !
int MMWriteHdr_UserName(FILE* fp, char* username)
{
short len=strlen(username)+1;
char* cp = username;
MMBufCrypt((unsigned char*)cp, len-1);
if (len<=MAX_USERNAME_LEN)
{
if (!fseek(fp, 0L, SEEK_SET))
if (fwrite(&len, sizeof(short), 1, fp))
return fwrite(cp, sizeof(char), len, fp);
}
return 0;
}
int MMWriteHdr(FILE* fp, struct sHdr* pHdr)
{
if (!MMWriteHdr_UserName(fp, pHdr->UserName))
return 0;
if (!fseek(fp, OFF_RELMONTH, SEEK_SET))
{
fwrite(&pHdr->dbRelMonth, sizeof(short), 1, fp);
fwrite(&pHdr->dbRelYear, sizeof(short), 1, fp);
fwrite(&pHdr->dbRelRevision, sizeof(short), 1, fp);
fwrite(&pHdr->nMakeTbl, sizeof(short), 1, fp);
fwrite(&pHdr->oMakeTbl, sizeof(long), 1, fp);
fwrite(&pHdr->nModelTbl, sizeof(short), 1, fp);
fwrite(&pHdr->oModelTbl, sizeof(long), 1, fp);
fwrite(&pHdr->nVariantTbl, sizeof(short), 1, fp);
fwrite(&pHdr->oVariantTbl, sizeof(long), 1, fp);
fwrite(&pHdr->nPriceTbl, sizeof(short), 1, fp);
fwrite(&pHdr->oPriceTbl, sizeof(long), 1, fp);
fwrite(&pHdr->nMileageTbl, sizeof(short), 1, fp);
fwrite(&pHdr->oMileageTbl, sizeof(long), 1, fp);
fwrite(&pHdr->nConditionTbl, sizeof(short), 1, fp);
fwrite(&pHdr->oConditionTbl, sizeof(long), 1, fp);
fwrite(&pHdr->nOptionTbl, sizeof(short), 1, fp);
fwrite(&pHdr->oOptionTbl, sizeof(long), 1, fp);
return 1;
}
return 0;
} Willie Botha
Programmer
Mead & McGrouther
South-Africa
I am a beginner in C++ and Writing Dat file headers and info. I have to change some of the coding now but I have to know what it exactly does ?
Thanks a lot !
int MMWriteHdr_UserName(FILE* fp, char* username)
{
short len=strlen(username)+1;
char* cp = username;
MMBufCrypt((unsigned char*)cp, len-1);
if (len<=MAX_USERNAME_LEN)
{
if (!fseek(fp, 0L, SEEK_SET))
if (fwrite(&len, sizeof(short), 1, fp))
return fwrite(cp, sizeof(char), len, fp);
}
return 0;
}
int MMWriteHdr(FILE* fp, struct sHdr* pHdr)
{
if (!MMWriteHdr_UserName(fp, pHdr->UserName))
return 0;
if (!fseek(fp, OFF_RELMONTH, SEEK_SET))
{
fwrite(&pHdr->dbRelMonth, sizeof(short), 1, fp);
fwrite(&pHdr->dbRelYear, sizeof(short), 1, fp);
fwrite(&pHdr->dbRelRevision, sizeof(short), 1, fp);
fwrite(&pHdr->nMakeTbl, sizeof(short), 1, fp);
fwrite(&pHdr->oMakeTbl, sizeof(long), 1, fp);
fwrite(&pHdr->nModelTbl, sizeof(short), 1, fp);
fwrite(&pHdr->oModelTbl, sizeof(long), 1, fp);
fwrite(&pHdr->nVariantTbl, sizeof(short), 1, fp);
fwrite(&pHdr->oVariantTbl, sizeof(long), 1, fp);
fwrite(&pHdr->nPriceTbl, sizeof(short), 1, fp);
fwrite(&pHdr->oPriceTbl, sizeof(long), 1, fp);
fwrite(&pHdr->nMileageTbl, sizeof(short), 1, fp);
fwrite(&pHdr->oMileageTbl, sizeof(long), 1, fp);
fwrite(&pHdr->nConditionTbl, sizeof(short), 1, fp);
fwrite(&pHdr->oConditionTbl, sizeof(long), 1, fp);
fwrite(&pHdr->nOptionTbl, sizeof(short), 1, fp);
fwrite(&pHdr->oOptionTbl, sizeof(long), 1, fp);
return 1;
}
return 0;
} Willie Botha
Programmer
Mead & McGrouther
South-Africa