...
| Code Block | ||
|---|---|---|
| ||
enum { NO_FILE_POS_VALUES = 3 };
errno_tint 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, "%u %u %u", &file_w, &file_h, &file_o)
!= NO_FILE_POS_VALUES) { return EIO; }
rc = fsetpos(file, &offset);
if (rc != 0 ) { return rc; }
*width = file_w;
*height = file_h;
*data_offset = file_o;
return 0;
}
|
...
| Code Block | ||
|---|---|---|
| ||
enum { NO_FILE_POS_VALUES = 3 };
errno_tint 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; }
rc = fgetpos(file, &offset);
if (rc != 0 ) { return rc; }
if (fscanf(file, "%u %u %u", &file_w, &file_h, &file_o)
!= NO_FILE_POS_VALUES) { return EIO; }
rc = fsetpos(file, &offset);
if (rc != 0 ) { return rc; }
*width = file_w;
*height = file_h;
*data_offset = file_o;
return 0;
}
|
...