+/* Write the alignment, width and scale values */
+static int
+write_variable_display_parameters (struct sfm_writer *w,
+ const struct dictionary *dict)
+{
+ int i;
+
+ struct
+ {
+ int32 rec_type P;
+ int32 subtype P;
+ int32 elem_size P;
+ int32 n_elem P;
+ } vdp_hdr;
+
+ vdp_hdr.rec_type = 7;
+ vdp_hdr.subtype = 11;
+ vdp_hdr.elem_size = 4;
+ vdp_hdr.n_elem = w->var_cnt * 3;
+
+ if (!buf_write (w, &vdp_hdr, sizeof vdp_hdr))
+ return 0;
+
+ for ( i = 0 ; i < w->var_cnt ; ++i )
+ {
+ struct variable *v;
+ struct
+ {
+ int32 measure P;
+ int32 width P;
+ int32 align P;
+ }
+ params;
+
+ v = dict_get_var(dict, i);
+
+ params.measure = v->measure;
+ params.width = v->display_width;
+ params.align = v->alignment;
+
+ if (!buf_write (w, ¶ms, sizeof(params)))
+ return 0;
+ }
+
+ return 1;
+}
+
+/* Writes the long variable name table */
+static int
+write_longvar_table (struct sfm_writer *w, const struct dictionary *dict)
+{
+ char *buf = 0;
+ int bufsize = 0;
+
+ struct
+ {
+ int32 rec_type P;
+ int32 subtype P;
+ int32 elem_size P;
+ int32 n_elem P;
+ } lv_hdr;
+
+ lv_hdr.rec_type = 7;
+ lv_hdr.subtype = 13;
+ lv_hdr.elem_size = 1;
+
+
+ dict_get_varname_block(dict, &buf, &bufsize);
+
+ if ( bufsize == 0 )
+ return 1;
+
+ lv_hdr.n_elem = bufsize ;
+
+ if (!buf_write (w, &lv_hdr, sizeof(lv_hdr) ))
+ goto error;
+
+ if (!buf_write (w, buf, bufsize))
+ goto error;
+
+ free (buf);
+ return 1;
+
+ error:
+ free ( buf ) ;
+ return 0;
+}
+