/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* Included files
*/
#include <netdb.h>
#include <libintl.h>
/*
* Defined macros
*/
/*
* typedefs & structs
*/
/*
* Static variables
*/
/*
* File table of contents
*/
static void pskip_till_next_word(wchar_t **cp);
/*
* read_make_machines(Name make_machines_name)
*
* For backwards compatibility w/ PMake 1.x, when DMake 2.x is
* being run in parallel mode, DMake should parse the PMake startup
* file $(HOME)/.make.machines to get the PMake max jobs.
*
* Return value:
* int of PMake max jobs
*
* Parameters:
* make_machines_name Name of .make.machines file
*
*/
int
{
wchar_t c;
int local_host_wslen;
int full_host_wslen = 0;
char *homedir;
wchar_t *mp;
wchar_t *ms;
int pmake_max_jobs = 0;
/* Did the user specify a .make.machines file on the command line? */
default_make_machines = false;
if (make_machines_name == NULL) {
/* Try reading the default .make.machines file, in $(HOME). */
"%s/.make.machines", homedir);
default_make_machines = true;
}
if (make_machines_name == NULL) {
/*
* No $(HOME)/.make.machines file.
* Return 0 for PMake max jobs.
*/
return(0);
}
}
/*
make_machines_list_mb = getenv(MAKE_MACHINES->string_mb);
*/
/* Open the .make.machines file. */
if (!default_make_machines) {
/* Error opening .make.machines file. */
} else {
/*
* No $(HOME)/.make.machines file.
* Return 0 for PMake max jobs.
*/
return(0);
}
/* Stat the .make.machines file to get the size of the file. */
/* Error stat'ing .make.machines file. */
} else {
/* Allocate memory for "MAKE_MACHINES=<contents of .m.m>" */
2 +
"%s=",
/* Read in the .make.machines file. */
sizeof(char),
(int) make_machines_buf.st_size,
/*
* Error reading .make.machines file.
* Return 0 for PMake max jobs.
*/
(void) fclose(make_machines_file);
return(0);
} else {
(void) fclose(make_machines_file);
/* putenv "MAKE_MACHINES=<contents of .m.m>" */
1 +
if (putenv(make_machines_list_mb) != 0) {
} else {
(void) mbstowcs(make_machines_list,
}
}
}
// There is no getdomainname() function on Solaris.
// And netname2host() function does not work on Linux.
// So we have to use different APIs.
}
for (ms = make_machines_list;
) {
/*
* Skip white space and comments till you reach
* a machine name.
*/
/*
* If we haven't reached the end of file, process the
* machine name.
*/
if (*ms) {
/*
* If invalid machine name decrement counter
* and skip line.
*/
c = *ms;
/*
* If this was the beginning of a comment
* (we overwrote a # sign) and it's not
* end of line yet, shift the # sign.
*/
*ms = '#';
}
/*
* Print "Ignoring unknown host" if:
* 1) hostname is longer than MAX_HOSTNAMELEN, or
* 2) hostname is unknown
*/
/* Increment ptr if not end of file. */
if (*ms) {
ms++;
}
} else {
/* Compare current hostname with local_host. */
/*
* Bingo, local_host is in .make.machines.
* Continue reading.
*/
/* Compare current hostname with full_host. */
/*
* Bingo, full_host is in .make.machines.
* Continue reading.
*/
} else {
if (c != '\n') {
if (*ms) {
ms++;
}
}
continue;
}
/* If we get here, local_host is in .make.machines. */
if (c != '\n') {
/* Now look for keyword 'max'. */
if (*ms == '#') {
pskip_comment(&ms);
/* Skip "max". */
ms += 3;
} else {
break;
}
}
}
break; /* out of outermost for() loop. */
}
}
}
return(pmake_max_jobs);
}
/*
* pskip_till_next_word(cp)
*
* Parameters:
* cp the address of the string pointer.
*
* On return:
* cp points to beginning of machine name.
*
*/
static void
{
/*
* Keep recursing until all combinations of white spaces
* and comments have been skipped.
*/
}
}
/*
* pskip_white_space(cp_address)
*
* Advances the string pointer so that it points to the first
*
* Parameters:
* cp_address the address of the string pointer.
*
* Return Value:
* True if the pointer was changed.
*
*/
static Boolean
{
cp++;
}
/* Have we skipped any characters? */
if (cp != *cp_address) {
*cp_address = cp;
return(true);
} else {
return(false);
}
}
/*
* pskip_comment(cp_address)
*
* If cp_address is pointing to '#' (the beginning of a comment),
* increment the pointer till you reach end of line.
*
* Parameters:
* cp_address the address of the string pointer.
*
* Return Value:
* True if the pointer was changed.
*
*/
static Boolean
{
/* Is this the beginning of a comment? Skip till end of line. */
if (*cp == '#') {
}
/* Have we skipped a comment line? */
if (cp != *cp_address) {
*cp_address = cp;
return(true);
} else {
return(false);
}
}
static int
{
/* Look for `='. */
*ms_address = ms;
return((int) limit);
} else {
ms++;
/* We've found, hopefully, a valid "max" value. */
if (limit < 1) {
}
} else {
/* No "max" value after "max=". */
}
*ms_address = ms;
return(limit);
}
}