PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ DBFWriteHeader()

static void DBFWriteHeader ( DBFHandle  psDBF)
static

Definition at line 197 of file dbfopen.c.

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

References FALSE, and XBASE_FLDHDR_SZ.

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

Here is the caller graph for this function: