Exemplo n.º 1
0
/*
 * getdaon -
 *	checks if device_allocate has string DEVICE_ALLOCATION=ON or
 *	DEVICE_ALLOCATION=OFF string in it.
 *	returns 1 if the string is DEVICE_ALLOCATION=ON, 0 if it is
 *	DEVICE_ALLOCATION=OFF, -1 if neither string present.
 */
int
getdaon()
{
	int		is_on = -1;
	char		line1[DA_BUFSIZE + 1];
	struct _dabuff *_da = _daalloc();

	setdaent();
	if ((_da == NULL) || (daf == NULL)) {
		enddaent();
		return (is_on);
	}
	while (getdadmline(line1, (int)sizeof (line1), daf) != 0) {
		if (strncmp(line1, DA_ON_STR, (strlen(DA_ON_STR) - 1)) == 0) {
			is_on = 1;
			break;
		} else if (strncmp(line1, DA_OFF_STR,
		    (strlen(DA_OFF_STR) - 1)) == 0) {
			is_on = 0;
			break;
		}
	}
	enddaent();

	return (is_on);
}
Exemplo n.º 2
0
/*
 * getdadefent -
 *	When first called, returns a pointer to the first da_defs_t
 * 	structure in devalloc_defaults; thereafter, it returns a pointer to the
 *	next da_defs_t structure in the file. Thus, successive calls can be
 *	used to search the entire file.
 *	call to getdadefent should be bracketed by setdadefent and enddadefent.
 *	returns NULL on error.
 */
da_defs_t *
getdadefent(void)
{
	char			line1[DA_BUFSIZE + 1];
	da_defs_t		*da_def;
	struct _dadefbuff	*_df = _dadefalloc();

	if ((_df == 0) || (dadeff == NULL))
		return (NULL);

	while (getdadmline(line1, (int)sizeof (line1), dadeff) != 0) {
		if ((da_def = dadef_interpret(line1)) == NULL)
			continue;
		return (da_def);
	}

	return (NULL);
}
Exemplo n.º 3
0
/*
 * getdaent -
 *	When first called, returns a pointer to the first devalloc_t
 * 	structure in device_allocate; thereafter, it returns a pointer to the
 *	next devalloc_t structure in the file. Thus, successive calls can be
 *	used to search the entire file.
 *	call to getdaent should be bracketed by setdaent and enddaent.
 *	returns NULL on error.
 */
devalloc_t *
getdaent(void)
{
	char		line1[DA_BUFSIZE + 1];
	devalloc_t	*da;
	struct _dabuff	*_da = _daalloc();

	if ((_da == 0) || (daf == NULL))
		return (NULL);

	while (getdadmline(line1, (int)sizeof (line1), daf) != 0) {
		if ((strncmp(line1, DA_ON_STR, (strlen(DA_ON_STR) - 1)) == 0) ||
		    (strncmp(line1, DA_OFF_STR, (strlen(DA_OFF_STR) - 1)) == 0))
			continue;
		if ((da = da_interpret(line1)) == NULL)
			continue;
		return (da);
	}

	return (NULL);
}
Exemplo n.º 4
0
/*
 * getdadeftype -
 * 	searches from the beginning of devalloc_defaults for the device
 *	specified by its type.
 *	call to getdadeftype should be bracketed by setdadefent and enddadefent.
 * 	returns pointer to da_defs_t for the device if it is found, else
 *	returns NULL if device not found or in case of error.
 */
da_defs_t *
getdadeftype(char *type)
{
	char			line1[DA_BUFSIZE + 1];
	da_defs_t		*da_def;
	struct _dadefbuff	*_df = _dadefalloc();

	if ((type == NULL) || (_df == NULL) || (dadeff == NULL))
		return (NULL);

	while (getdadmline(line1, (int)sizeof (line1), dadeff) != 0) {
		if (strstr(line1, type) == NULL)
			continue;
		if ((da_def = dadef_interpret(line1)) == NULL)
			continue;
		if (dadef_matchtype(da_def, type))
			return (da_def);
		freedadefent(da_def);
	}

	return (NULL);
}
Exemplo n.º 5
0
/*
 * getdatype -
 * 	searches from the beginning of device_allocate for the device specified
 * 	by its type.
 *	call to getdatype should be bracketed by setdaent and enddaent.
 * 	returns pointer to devalloc_t for the device if it is found, else
 *	returns NULL if device not found or in case of error.
 */
devalloc_t *
getdatype(char *type)
{
	char		line1[DA_BUFSIZE + 1];
	devalloc_t	*da;
	struct _dabuff	*_da = _daalloc();

	if ((type == NULL) || (_da == NULL) || (daf == NULL))
		return (NULL);

	while (getdadmline(line1, (int)sizeof (line1), daf) != 0) {
		if (strstr(line1, type) == NULL)
			continue;
		if ((da = da_interpret(line1)) == NULL)
			continue;
		if (da_matchtype(da, type))
			return (da);
		freedaent(da);
	}

	return (NULL);
}
Exemplo n.º 6
0
/*
 * getdanam
 * 	searches from the beginning of device_allocate for the device specified
 * 	by its name.
 *	call to getdanam should be bracketed by setdaent and enddaent.
 * 	returns pointer to devalloc_t for the device if it is found, else
 *	returns NULL if device not found or in case of error.
 */
devalloc_t *
getdanam(char *name)
{
	char		line[DA_BUFSIZE + 1];
	devalloc_t	*da;
	struct _dabuff	*_da = _daalloc();

	if ((name == NULL) || (_da == 0) || (daf == NULL))
		return (NULL);

	while (getdadmline(line, (int)sizeof (line), daf) != 0) {
		if (strstr(line, name) == NULL)
			continue;
		if ((da = da_interpret(line)) == NULL)
			continue;
		if (da_matchname(da, name)) {
			enddaent();
			return (da);
		}
		freedaent(da);
	}

	return (NULL);
}