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