1: /*
   2:  * Copyright (c) 1980 Regents of the University of California.
   3:  * All rights reserved.  The Berkeley software License Agreement
   4:  * specifies the terms and conditions for redistribution.
   5:  *
   6:  *	@(#)wsnmle.c	5.2	8/2/85
   7:  */
   8: 
   9: /*
  10:  *		name-list write
  11:  */
  12: 
  13: #include "fio.h"
  14: #include "lio.h"
  15: #include "nmlio.h"
  16: #include <strings.h>
  17: 
  18: int l_write(), t_putc();
  19: LOCAL char nml_wrt[] = "namelist write";
  20: char namelistkey_ = '&';
  21: 
  22: s_wsne(a) namelist_arglist *a;
  23: {
  24:     int n, first;
  25:     struct namelistentry *entries;
  26:     int *dimptr, *spans, ndim, nelem, offset, vlen, vtype, number;
  27:     char *nmlist_nm, *cptr;
  28: 
  29:     nmlist_nm = a->namelist->namelistname;
  30:     reading = NO;
  31:     formatted = NAMELIST;
  32:     fmtbuf = "ext namelist io";
  33:     if(n=c_le(a,WRITE)) return(n);
  34:     putn = t_putc;
  35:     line_len = LINE-1;  /* so we can always add a comma */
  36:     curunit->uend = NO;
  37:     leof = NO;
  38:     if(!curunit->uwrt && ! nowwriting(curunit)) err(errflag, errno, nml_wrt)
  39: 
  40:     /* begin line with " &namelistname " */
  41:     if(recpos != 0)
  42:         PUT('\n');  /* PUT() adds blank */
  43:     PUT(namelistkey_);
  44:     while(*nmlist_nm != '\0') PUT(*nmlist_nm++);
  45:     PUT(' ');
  46: 
  47:     /* now loop through entries writing them out */
  48:     entries = a->namelist->names;
  49:     first = 1;
  50:     while( entries->varname[0] != 0 )
  51:     {
  52:         /* write out variable name and '=' */
  53:         cptr = entries->varname;
  54:         chk_len( strlen(cptr) + 3);
  55:         if(first++ != 1) PUT(',');
  56:         PUT(' ');
  57:         while( *cptr != '\0') PUT(*cptr++);
  58:         PUT('=');
  59: 
  60:         /* how many value are there? */
  61:         if( (dimptr = entries->dimp) == NULL ) number = 1;
  62:         else number = dimptr[1];
  63:         /* what is element length? */
  64:         vlen = entries->typelen;
  65:         /* get type */
  66:         vtype = entries->type;
  67: 
  68:         if(n=l_write( &number, entries->varaddr, vlen, vtype ))
  69:                 err(errflag,n,nml_wrt);
  70:         entries++;
  71:     }
  72:     PUT('\n');
  73:     PUT(namelistkey_);
  74:     cptr = "end\n";
  75:     while(*cptr != '\0') PUT(*cptr++);
  76:     return(OK);
  77: }
  78: 
  79: LOCAL
  80: t_putc(c) char c;
  81: {
  82:     if(c=='\n') {
  83:         recpos=0;
  84:     } else if(recpos == 0) {
  85:         putc(' ',cf);       /* for namelist,	   */
  86:         recpos = 2;     /* never print in column 1 */
  87:     } else {
  88:         recpos++;
  89:     }
  90:     putc(c,cf);
  91:     return(OK);
  92: }

Defined functions

s_wsne defined in line 22; never used
t_putc defined in line 79; used 2 times

Defined variables

namelistkey_ defined in line 20; used 9 times
nml_wrt defined in line 19; used 2 times
Last modified: 1987-02-18
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 2436
Valid CSS Valid XHTML 1.0 Strict