----- Original Message -----
From: manish jaggi
Sent: Monday, August 27, 2001 9:09 AM
To: s s
Subject: Emulator vs RealDevice
Hello Everybody,
I am facing a very strange problem.
I have made a pdb file using the docs availbale for pdb file.
The file when uploaded on the emulator displays the records as 4059 and
size 151k
but when the file is hotsync to the palm device palm m105 the size
reduces to 13k and the records are 256.
I am totally confused by this behaviour ,
I am enclosing the source
#include <iostream.h>
#include <io.h>
#include <fcntl.h>
#include <sys\stat.h>
#include <errno.h>
#include <string.h>
#include <time.h>
#include <windows.h>
void fopen_error (char* file_name);
void exit ();
# include <stdio.h>
//PUT RECORD SIZE HERE
#define REC_SIZE 30
#define invert32(x) (((x & 0x000000ff)<<24) | ((x & 0x0000ff00)<<8) | ((x &
0x00ff0000)>>8) | ((x & 0xff000000) >> 24))
#define invert16(x) (((x & 0x00ff)<<8) | ((x & 0xff)>>8))
// Global variables
int g_hSource = -1;
int g_hOutput = -1;
int g_iLen;
// struct def
#pragma pack (push)
#pragma pack (1)
typedef struct
{
char name [32];
unsigned short attributes;
unsigned short version;
DWORD creationDate;
DWORD modificationDate;
DWORD lastBackupDate;
DWORD modificationNumber;
DWORD appInfoID;
DWORD sortInfoID;
DWORD type;
DWORD creator;
DWORD unqueIDSeed;
} PDBHeader;
struct xA
{
char s[35];
short int a1;
short int a2;
char b;
};
typedef struct
{
DWORD nextRecordistID;
WORD numRecords;
} RecordListType;
typedef struct
{
DWORD localChunkID;
char attributes;
char uid [3];
} FieldDescrType;
#pragma pack (pop)
int main()
{
DWORD iResult,i;
WORD rec_num;
time_t ct;
void* buf;
PDBHeader header;
RecordListType rl;
FieldDescrType fd;
g_hSource = _open ("newatlas.tmp", O_RDONLY | O_BINARY);
iResult = _open ("aug_27.pdb", O_RDONLY);
g_iLen = _filelength (g_hSource);
rec_num = (g_iLen / REC_SIZE) + 1;//change
time (&ct);
ct += 2082844800;
strcpy (header.name, "aug_27_cid");
header.attributes = 0x1000;
header.version = 0;
header.creationDate = invert32(ct);
header.modificationDate = invert32(ct);
header.lastBackupDate = invert32(ct);
header.modificationNumber = 0;
header.appInfoID = NULL;
header.sortInfoID = NULL;
header.type = invert32('pl00');
header.creator = invert32('pl01');
header.unqueIDSeed = 0;
rl.nextRecordistID = NULL;
// rl.numRecords =invert16(rec_num);
BYTE btlow = LOBYTE(rec_num);
BYTE bthigh = HIBYTE(rec_num);
rl.numRecords = MAKEWORD(bthigh,btlow);
cout<<rl.numRecords;
g_hOutput = _open ("aug_27.pdb", _O_WRONLY | _O_CREAT | _O_BINARY,
_S_IWRITE);
_write (g_hOutput, (void*) &header, sizeof (header));
_write (g_hOutput, (void*) &rl, sizeof (rl));
for ( i = 0; i < rec_num; i++)
{
iResult = sizeof (header) + sizeof (rl) + (rec_num * sizeof (fd)) + (i *
REC_SIZE);
fd.localChunkID = invert32(iResult);
fd.attributes = 0;
fd.uid [2] = i;
_write (g_hOutput, (void*) &fd, sizeof (fd));
}
buf = new (char [g_iLen]);
_read (g_hSource, buf, g_iLen);
_write (g_hOutput, buf, g_iLen);
delete (buf);
exit ();
return 0;
}
void fopen_error (char* file_name)
{
switch (errno)
{
case ENOENT:
cout<<"**Fatal** Command line: Can't locate file: "<<file_name<<endl;
break;
case EMFILE:
cout<<"**Fatal** Command line: Too many open files: "<<file_name<<endl;
break;
case EACCES:
cout<<"**Fatal** Command line: Can't open file: "<<file_name<<endl;
break;
}
}
void exit ()
{
if (g_hSource != -1) close (g_hSource);
if (g_hOutput != -1) close (g_hOutput);
}
Manish
--------------------------------------------------------------------------------
Get your FREE download of MSN Explorer at http://explorer.msn.com
--------------------------------------------------------------------------------
Get your FREE download of MSN Explorer at http://explorer.msn.com
_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/tech/support/forums/