64 |
static int buf_write (struct pfm_writer *, const void *, size_t); |
static int buf_write (struct pfm_writer *, const void *, size_t); |
65 |
static int write_header (struct pfm_writer *); |
static int write_header (struct pfm_writer *); |
66 |
static int write_version_data (struct pfm_writer *); |
static int write_version_data (struct pfm_writer *); |
67 |
static int write_variables (struct pfm_writer *, const struct dictionary *); |
static int write_variables (struct pfm_writer *, struct dictionary *); |
68 |
static int write_value_labels (struct pfm_writer *, const struct dictionary *); |
static int write_value_labels (struct pfm_writer *, const struct dictionary *); |
69 |
|
|
70 |
/* Writes the dictionary DICT to portable file HANDLE. Returns |
/* Writes the dictionary DICT to portable file HANDLE. Returns |
71 |
nonzero only if successful. */ |
nonzero only if successful. DICT will not be modified, except |
72 |
|
to assign short names. */ |
73 |
struct pfm_writer * |
struct pfm_writer * |
74 |
pfm_open_writer (struct file_handle *fh, const struct dictionary *dict) |
pfm_open_writer (struct file_handle *fh, struct dictionary *dict) |
75 |
{ |
{ |
76 |
struct pfm_writer *w = NULL; |
struct pfm_writer *w = NULL; |
77 |
size_t i; |
size_t i; |
369 |
|
|
370 |
/* Write variable records, and return success. */ |
/* Write variable records, and return success. */ |
371 |
static int |
static int |
372 |
write_variables (struct pfm_writer *w, const struct dictionary *dict) |
write_variables (struct pfm_writer *w, struct dictionary *dict) |
373 |
{ |
{ |
374 |
int i; |
int i; |
375 |
|
|
376 |
|
dict_assign_short_names (dict); |
377 |
|
|
378 |
if (!buf_write (w, "4", 1) || !write_int (w, dict_get_var_cnt (dict)) |
if (!buf_write (w, "4", 1) || !write_int (w, dict_get_var_cnt (dict)) |
379 |
|| !write_int (w, 161)) |
|| !write_int (w, 161)) |
392 |
struct variable *v = dict_get_var (dict, i); |
struct variable *v = dict_get_var (dict, i); |
393 |
|
|
394 |
if (!buf_write (w, "7", 1) || !write_int (w, v->width) |
if (!buf_write (w, "7", 1) || !write_int (w, v->width) |
395 |
|| !write_string (w, v->name) |
|| !write_string (w, v->short_name) |
396 |
|| !write_format (w, &v->print) || !write_format (w, &v->write)) |
|| !write_format (w, &v->print) || !write_format (w, &v->write)) |
397 |
return 0; |
return 0; |
398 |
|
|
425 |
|
|
426 |
if (!buf_write (w, "D", 1) |
if (!buf_write (w, "D", 1) |
427 |
|| !write_int (w, 1) |
|| !write_int (w, 1) |
428 |
|| !write_string (w, v->name) |
|| !write_string (w, v->short_name) |
429 |
|| !write_int (w, val_labs_count (v->val_labs))) |
|| !write_int (w, val_labs_count (v->val_labs))) |
430 |
return 0; |
return 0; |
431 |
|
|