...
| Code Block | ||
|---|---|---|
| ||
enum { NO_FILE_POS_VALUES = 3 };
errno_t opener(FILE* file, unsigned int *width, unsigned int *height, unsigned int *data_offset) {
unsigned int file_w;
unsigned int file_h;
unsigned int file_o;
int rc;
fpos_t offset;
memset(&offset, 0, sizeof(offset));
if (file == NULL) { return EINVAL; }
if (fscanf(file, "%i%u %i%u %i%u", &file_w, &file_h, &file_o) != NO_FILE_POS_VALUES) { return EIO; }
if ((rc = fsetpos(file, &offset)) != 0 ) { return rc; }
*width = file_w;
*height = file_h;
*data_offset = file_o;
return 0;
}
|
...
| Code Block | ||
|---|---|---|
| ||
enum { NO_FILE_POS_VALUES = 3 };
errno_t opener(FILE* file, unsigned int *width, unsigned int *height, unsigned int *data_offset) {
unsigned int file_w;
unsigned int file_h;
unsigned int file_o;
int rc;
fpos_t offset;
if (file == NULL) { return EINVAL; }
if ((rc = fgetpos(file, &offset)) != 0 ) { return rc; }
if (fscanf(file, "%i%u %i%u %i%u", &file_w, &file_h, &file_o) != NO_FILE_POS_VALUES) { return EIO; }
if ((rc = fsetpos(file, &offset)) != 0 ) { return rc; }
*width = file_w;
*height = file_h;
*data_offset = file_o;
return 0;
}
|
...