locator.c revision 06e46062ef4f5f4b687cbafb4518fb123fe23920
/*
* 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 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <libintl.h>
#include <locale.h>
#include <unistd.h>
#include <picl.h>
#define DEFAULT_NAME "system"
typedef struct locator_info {
int found; /* Nonzero if found during walk */
int err; /* Last error from picl */
char *name; /* Name/LocatorName of locator node */
int new_state; /* 0 = logical off, 1 = logical on */
char *on; /* Logical on value for State */
char *off; /* Logical off value for State */
static void
{
exit(1);
}
static int
{
char state[PICL_PROPNAMELEN_MAX];
int err;
char *new_state;
if (err != PICL_SUCCESS) {
gettext("picl_get_prop_by_name failed: %s\n"),
picl_strerror(err));
return (err);
}
if (err != PICL_SUCCESS) {
gettext("picl_get_propval failed: %s\n"),
picl_strerror(err));
return (err);
}
if (err != PICL_SUCCESS) {
gettext("picl_get_propinfo failed: %s\n"),
picl_strerror(err));
return (err);
}
if (err != PICL_SUCCESS) {
gettext("picl_set_propval failed: %s\n"),
picl_strerror(err));
return (err);
}
}
return (err);
}
static int
{
char state[PICL_PROPNAMELEN_MAX];
char *display_state;
int err;
if (err != PICL_SUCCESS) {
gettext("picl_get_propval_by_name failed: %s\n"),
picl_strerror(err));
return (err);
}
else
return (err);
}
static int
{
int err;
char is_locator[PICL_PROPNAMELEN_MAX];
char name[PICL_PROPNAMELEN_MAX];
char locator_on[PICL_PROPNAMELEN_MAX];
char locator_off[PICL_PROPNAMELEN_MAX];
sizeof (is_locator));
if (err != PICL_SUCCESS)
return (PICL_WALK_CONTINUE);
return (PICL_WALK_CONTINUE);
sizeof (name));
if (err == PICL_PROPNOTFOUND)
sizeof (name));
if (err != PICL_SUCCESS)
return (err);
return (PICL_WALK_CONTINUE);
sizeof (locator_on));
if (err == PICL_SUCCESS) {
} else if (err == PICL_PROPNOTFOUND) {
} else {
return (err);
}
sizeof (locator_off));
if (err == PICL_SUCCESS) {
} else if (err == PICL_PROPNOTFOUND) {
} else {
return (err);
}
return (PICL_WALK_TERMINATE);
}
int
{
locator_info_t locator_info = {0, 0, 0, 0, 0};
int err;
int c;
int on_flag = 0;
int off_flag = 0;
char *progname;
char *locator_name = DEFAULT_NAME;
(void) textdomain(TEXT_DOMAIN);
else
progname++;
switch (c) {
case 'n':
on_flag++;
break;
case 'f':
off_flag++;
break;
case '?':
/*FALLTHROUGH*/
default:
}
}
/* We only take one option */
err = picl_initialize();
if (err != PICL_SUCCESS) {
picl_strerror(err));
exit(2);
}
if (err != PICL_SUCCESS) {
picl_strerror(err));
err = 2;
goto OUT;
}
if (on_flag) {
} else if (off_flag) {
locator_info.new_state = 0;
} else {
}
if (err != PICL_SUCCESS) {
gettext("picl_walk_tree_by_class failed: %s\n"),
picl_strerror(err));
err = 2;
goto OUT;
}
if (locator_info.found == 0) {
err = 2;
}
err = 2;
OUT:
(void) picl_shutdown();
return (err);
}