21 /*
22 * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
24 */
25
26 #ifdef TEAMWARE_MAKE_CMN
27
28 /*
29 * Included files
30 */
31 #include <arpa/inet.h>
32 #include <mk/defs.h>
33 #include <mksh/misc.h>
34 #include <netdb.h>
35 #include <netinet/in.h>
36 #include <sys/socket.h>
37 #include <sys/stat.h>
38 #include <sys/types.h>
39 #include <sys/utsname.h>
40 #include <rpc/rpc.h> /* host2netname(), netname2host() */
41 #ifdef linux
42 # include <unistd.h> /* getdomainname() */
43 #endif
44
45 /*
46 * Defined macros
47 */
48
49 /*
50 * typedefs & structs
51 */
52
53 /*
54 * Static variables
55 */
56
57 /*
58 * File table of contents
59 */
60 static int get_max(wchar_t **ms_address, wchar_t *hostname);
61 static Boolean pskip_comment(wchar_t **cp_address);
62 static void pskip_till_next_word(wchar_t **cp);
63 static Boolean pskip_white_space(wchar_t **cp_address);
181 warning(catgets(catd, 1, 317, "Couldn't put contents of %s in environment"),
182 make_machines_name->string_mb);
183 } else {
184 make_machines_list_mb += strlen(MAKE_MACHINES->string_mb) + 1;
185 make_machines_list = ALLOC_WC(strlen(make_machines_list_mb) + 1);
186 (void) mbstowcs(make_machines_list,
187 make_machines_list_mb,
188 (strlen(make_machines_list_mb) + 1));
189 }
190 }
191 }
192
193 uname(&uts_info);
194 strcpy(local_host_mb, &uts_info.nodename[0]);
195 MBSTOWCS(local_host, local_host_mb);
196 local_host_wslen = wslen(local_host);
197
198 // There is no getdomainname() function on Solaris.
199 // And netname2host() function does not work on Linux.
200 // So we have to use different APIs.
201 #ifdef linux
202 if (getdomainname(mbs_buffer, MAXNETNAMELEN+1) == 0) {
203 sprintf(mbs_buffer2, "%s.%s", local_host_mb, mbs_buffer);
204 #else
205 if (host2netname(mbs_buffer, NULL, NULL) &&
206 netname2host(mbs_buffer, mbs_buffer2, MAXNETNAMELEN+1)) {
207 #endif
208 MBSTOWCS(full_host, mbs_buffer2);
209 full_host_wslen = wslen(full_host);
210 }
211
212 for (ms = make_machines_list;
213 (ms) && (*ms );
214 ) {
215 /*
216 * Skip white space and comments till you reach
217 * a machine name.
218 */
219 pskip_till_next_word(&ms);
220
221 /*
222 * If we haven't reached the end of file, process the
223 * machine name.
224 */
225 if (*ms) {
226 /*
227 * If invalid machine name decrement counter
|
21 /*
22 * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
24 */
25
26 #ifdef TEAMWARE_MAKE_CMN
27
28 /*
29 * Included files
30 */
31 #include <arpa/inet.h>
32 #include <mk/defs.h>
33 #include <mksh/misc.h>
34 #include <netdb.h>
35 #include <netinet/in.h>
36 #include <sys/socket.h>
37 #include <sys/stat.h>
38 #include <sys/types.h>
39 #include <sys/utsname.h>
40 #include <rpc/rpc.h> /* host2netname(), netname2host() */
41
42 /*
43 * Defined macros
44 */
45
46 /*
47 * typedefs & structs
48 */
49
50 /*
51 * Static variables
52 */
53
54 /*
55 * File table of contents
56 */
57 static int get_max(wchar_t **ms_address, wchar_t *hostname);
58 static Boolean pskip_comment(wchar_t **cp_address);
59 static void pskip_till_next_word(wchar_t **cp);
60 static Boolean pskip_white_space(wchar_t **cp_address);
178 warning(catgets(catd, 1, 317, "Couldn't put contents of %s in environment"),
179 make_machines_name->string_mb);
180 } else {
181 make_machines_list_mb += strlen(MAKE_MACHINES->string_mb) + 1;
182 make_machines_list = ALLOC_WC(strlen(make_machines_list_mb) + 1);
183 (void) mbstowcs(make_machines_list,
184 make_machines_list_mb,
185 (strlen(make_machines_list_mb) + 1));
186 }
187 }
188 }
189
190 uname(&uts_info);
191 strcpy(local_host_mb, &uts_info.nodename[0]);
192 MBSTOWCS(local_host, local_host_mb);
193 local_host_wslen = wslen(local_host);
194
195 // There is no getdomainname() function on Solaris.
196 // And netname2host() function does not work on Linux.
197 // So we have to use different APIs.
198 if (host2netname(mbs_buffer, NULL, NULL) &&
199 netname2host(mbs_buffer, mbs_buffer2, MAXNETNAMELEN+1)) {
200 MBSTOWCS(full_host, mbs_buffer2);
201 full_host_wslen = wslen(full_host);
202 }
203
204 for (ms = make_machines_list;
205 (ms) && (*ms );
206 ) {
207 /*
208 * Skip white space and comments till you reach
209 * a machine name.
210 */
211 pskip_till_next_word(&ms);
212
213 /*
214 * If we haven't reached the end of file, process the
215 * machine name.
216 */
217 if (*ms) {
218 /*
219 * If invalid machine name decrement counter
|