1*35181Smarc /*
2*35181Smarc 
3*35181Smarc  *      Copyright (c) 1984, 1985, 1986 AT&T
4*35181Smarc  *      All Rights Reserved
5*35181Smarc 
6*35181Smarc  *      THIS IS UNPUBLISHED PROPRIETARY SOURCE
7*35181Smarc  *      CODE OF AT&T.
8*35181Smarc  *      The copyright notice above does not
9*35181Smarc  *      evidence any actual or intended
10*35181Smarc  *      publication of such source code.
11*35181Smarc 
12*35181Smarc  */
13*35181Smarc /* @(#)assnum.c	1.1 */
14*35181Smarc 
15*35181Smarc /*
16*35181Smarc  *   ASSNUM.C
17*35181Smarc  *
18*35181Smarc  *   Programmer:  D. G. Korn
19*35181Smarc  *
20*35181Smarc  *        Owner:  D. A. Lambeth
21*35181Smarc  *
22*35181Smarc  *         Date:  April 17, 1980
23*35181Smarc  *
24*35181Smarc  *
25*35181Smarc  *
26*35181Smarc  *
27*35181Smarc  *   ASSCADR (NODE, CHARP)
28*35181Smarc  *
29*35181Smarc  *        Assign the string address CHARP to the Namnod given
30*35181Smarc  *        by node.
31*35181Smarc  *
32*35181Smarc  *   ASSLONG (NODE, NUM)
33*35181Smarc  *
34*35181Smarc  *        Assign the long integer NUM to NODE.  NODE should have
35*35181Smarc  *        the L_FLAG and INT_GER attributes.
36*35181Smarc  *
37*35181Smarc  *
38*35181Smarc  *
39*35181Smarc  *   See Also:  assign(III), unassign(III), valup(III), ltos(III)
40*35181Smarc  */
41*35181Smarc 
42*35181Smarc #include	"name.h"
43*35181Smarc #include        "flags.h"
44*35181Smarc 
45*35181Smarc extern char *ltos(), *malloc();
46*35181Smarc #ifdef NAME_SCOPE
47*35181Smarc extern struct Namnod *copy_nod();
48*35181Smarc #endif
49*35181Smarc extern union Namval *aget_up();
50*35181Smarc extern void	assign();
51*35181Smarc 
52*35181Smarc 
53*35181Smarc /*
54*35181Smarc  *   ASSCADR (NODE, CHARP)
55*35181Smarc  *
56*35181Smarc  *        struct Namnod *NODE;
57*35181Smarc  *
58*35181Smarc  *        char *CHARP;
59*35181Smarc  *
60*35181Smarc  *   Assign the string address CHARP to the Namnod given by NODE.
61*35181Smarc  *   The attributes of NODE are neither inspected nor altered.
62*35181Smarc  *   Thus, to guarantee success, NODE should have the N_DEFAULT
63*35181Smarc  *   value-determining attribute.
64*35181Smarc  *   The following code has been replaced by a macro in name.h.
65*35181Smarc 
66*35181Smarc asscadr(node,charp)
67*35181Smarc struct Namnod *node;
68*35181Smarc char *charp;
69*35181Smarc {
70*35181Smarc 	node->value.namval.cp = charp;
71*35181Smarc }
72*35181Smarc  */
73*35181Smarc 
74*35181Smarc /*
75*35181Smarc  *   ASSLONG (NODE, NUM)
76*35181Smarc  *
77*35181Smarc  *        struct Namnod *NODE;
78*35181Smarc  *
79*35181Smarc  *        int NUM;
80*35181Smarc  *
81*35181Smarc  *   Assign the value NUM to the Namnod given by NODE.  All
82*35181Smarc  *   appropriate conversions are made.
83*35181Smarc  */
84*35181Smarc 
85*35181Smarc asslong(node,num)
86*35181Smarc struct Namnod *node;
87*35181Smarc long num;
88*35181Smarc {
89*35181Smarc 	register struct Namnod *np=node;
90*35181Smarc 	register union Namval *up = &np->value.namval;
91*35181Smarc 	if (attest (np, INT_GER))
92*35181Smarc 	{
93*35181Smarc 		if (attest (np, ARRAY))
94*35181Smarc 			up = aget_up(np,up);
95*35181Smarc #ifdef NAME_SCOPE
96*35181Smarc 		if (attest (np, C_WRITE))
97*35181Smarc 			np = copy_nod(np,1);
98*35181Smarc #endif	/* NAME_SCOPE */
99*35181Smarc         	if (attest (np, IN_DIR))
100*35181Smarc 			up = up->up;
101*35181Smarc         	if (attest (np, BLT_NOD))
102*35181Smarc 			(*up->fp->f_ap)((unsigned)num);
103*35181Smarc 		else
104*35181Smarc 		{
105*35181Smarc 			if(up->lp==0)
106*35181Smarc 				up->lp = (long*)malloc((unsigned)sizeof(long));
107*35181Smarc 			*(up->lp) = num;
108*35181Smarc 			if(np->namsz == 0)
109*35181Smarc 				np->namsz = lastbase;
110*35181Smarc 		}
111*35181Smarc 	}
112*35181Smarc 	else
113*35181Smarc 		assign(np,ltos(num,10));
114*35181Smarc }
115