* Copyright (c) 1980 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
LOCAL
char nml_wrt
[] = "namelist write";
s_wsne(a
) namelist_arglist
*a
;
struct namelistentry
*entries
;
int *dimptr
, *spans
, ndim
, nelem
, offset
, vlen
, vtype
, number
;
nmlist_nm
= a
->namelist
->namelistname
;
fmtbuf
= "ext namelist io";
if(n
=c_le(a
,WRITE
)) return(n
);
line_len
= LINE
-1; /* so we can always add a comma */
if(!curunit
->uwrt
&& ! nowwriting(curunit
)) err(errflag
, errno
, nml_wrt
)
/* begin line with " &namelistname " */
PUT('\n'); /* PUT() adds blank */
while(*nmlist_nm
!= '\0') PUT(*nmlist_nm
++);
/* now loop through entries writing them out */
entries
= a
->namelist
->names
;
while( entries
->varname
[0] != 0 )
/* write out variable name and '=' */
chk_len( strlen(cptr
) + 3);
if(first
++ != 1) PUT(',');
while( *cptr
!= '\0') PUT(*cptr
++);
/* how many value are there? */
if( (dimptr
= entries
->dimp
) == NULL
) number
= 1;
/* what is element length? */
if(n
=l_write( &number
, entries
->varaddr
, vlen
, vtype
))
while(*cptr
!= '\0') PUT(*cptr
++);
putc(' ',cf
); /* for namelist, */
recpos
= 2; /* never print in column 1 */