PostGIS  2.1.10dev-r@@SVN_REVISION@@
static void DBFWriteHeader ( DBFHandle  psDBF)
static

Definition at line 198 of file dbfopen.c.

References FALSE, and XBASE_FLDHDR_SZ.

Referenced by DBFClose(), DBFUpdateHeader(), DBFWriteAttribute(), DBFWriteAttributeDirectly(), and DBFWriteTuple().

200 {
201  unsigned char abyHeader[XBASE_FLDHDR_SZ];
202  int i;
203 
204  if( !psDBF->bNoHeader )
205  return;
206 
207  psDBF->bNoHeader = FALSE;
208 
209 /* -------------------------------------------------------------------- */
210 /* Initialize the file header information. */
211 /* -------------------------------------------------------------------- */
212  for( i = 0; i < XBASE_FLDHDR_SZ; i++ )
213  abyHeader[i] = 0;
214 
215  abyHeader[0] = 0x03; /* memo field? - just copying */
216 
217  /* write out a dummy date */
218  abyHeader[1] = 95; /* YY */
219  abyHeader[2] = 7; /* MM */
220  abyHeader[3] = 26; /* DD */
221 
222  /* record count preset at zero */
223 
224  abyHeader[8] = (unsigned char) (psDBF->nHeaderLength % 256);
225  abyHeader[9] = (unsigned char) (psDBF->nHeaderLength / 256);
226 
227  abyHeader[10] = (unsigned char) (psDBF->nRecordLength % 256);
228  abyHeader[11] = (unsigned char) (psDBF->nRecordLength / 256);
229 
230  abyHeader[29] = (unsigned char) (psDBF->iLanguageDriver);
231 
232 /* -------------------------------------------------------------------- */
233 /* Write the initial 32 byte file header, and all the field */
234 /* descriptions. */
235 /* -------------------------------------------------------------------- */
236  psDBF->sHooks.FSeek( psDBF->fp, 0, 0 );
237  psDBF->sHooks.FWrite( abyHeader, XBASE_FLDHDR_SZ, 1, psDBF->fp );
238  psDBF->sHooks.FWrite( psDBF->pszHeader, XBASE_FLDHDR_SZ, psDBF->nFields,
239  psDBF->fp );
240 
241 /* -------------------------------------------------------------------- */
242 /* Write out the newline character if there is room for it. */
243 /* -------------------------------------------------------------------- */
244  if( psDBF->nHeaderLength > 32*psDBF->nFields + 32 )
245  {
246  char cNewline;
247 
248  cNewline = 0x0d;
249  psDBF->sHooks.FWrite( &cNewline, 1, 1, psDBF->fp );
250  }
251 }
#define XBASE_FLDHDR_SZ
#define FALSE
Definition: dbfopen.c:169

Here is the caller graph for this function: