/ writeHeader() */ / This is called to write out the file header, and field */ descriptions before writing any actual data records. This */ also computes all the DBFDataSet field offset/size/decimals */ and so forth values. */ /
| 69 | /* and so forth values. */ |
| 70 | /************************************************************************/ |
| 71 | static void writeHeader(DBFHandle psDBF) |
| 72 | |
| 73 | { |
| 74 | uchar abyHeader[32]; |
| 75 | int i; |
| 76 | |
| 77 | if( !psDBF->bNoHeader ) |
| 78 | return; |
| 79 | |
| 80 | psDBF->bNoHeader = MS_FALSE; |
| 81 | |
| 82 | /* -------------------------------------------------------------------- */ |
| 83 | /* Initialize the file header information. */ |
| 84 | /* -------------------------------------------------------------------- */ |
| 85 | for( i = 0; i < 32; i++ ) |
| 86 | abyHeader[i] = 0; |
| 87 | |
| 88 | abyHeader[0] = 0x03; /* memo field? - just copying */ |
| 89 | |
| 90 | /* date updated on close, record count preset at zero */ |
| 91 | |
| 92 | abyHeader[8] = psDBF->nHeaderLength % 256; |
| 93 | abyHeader[9] = psDBF->nHeaderLength / 256; |
| 94 | |
| 95 | abyHeader[10] = psDBF->nRecordLength % 256; |
| 96 | abyHeader[11] = psDBF->nRecordLength / 256; |
| 97 | |
| 98 | /* -------------------------------------------------------------------- */ |
| 99 | /* Write the initial 32 byte file header, and all the field */ |
| 100 | /* descriptions. */ |
| 101 | /* -------------------------------------------------------------------- */ |
| 102 | fseek( psDBF->fp, 0, 0 ); |
| 103 | fwrite( abyHeader, 32, 1, psDBF->fp ); |
| 104 | fwrite( psDBF->pszHeader, 32, psDBF->nFields, psDBF->fp ); |
| 105 | |
| 106 | /* -------------------------------------------------------------------- */ |
| 107 | /* Write out the newline character if there is room for it. */ |
| 108 | /* -------------------------------------------------------------------- */ |
| 109 | if( psDBF->nHeaderLength > 32*psDBF->nFields + 32 ) |
| 110 | { |
| 111 | char cNewline; |
| 112 | |
| 113 | cNewline = 0x0d; |
| 114 | fwrite( &cNewline, 1, 1, psDBF->fp ); |
| 115 | } |
| 116 | } |
| 117 | |
| 118 | /************************************************************************/ |
| 119 | /* flushRecord() */ |
no outgoing calls
no test coverage detected