/***************************************************************************
* CVSID: $Id$
*
* hal_set_property.c : Set property for a device
*
* Copyright (C) 2003 David Zeuthen, <david@fubar.dk>
*
* Licensed under the Academic Free License version 2.1
*
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
**************************************************************************/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <getopt.h>
#include <libhal.h>
enum property_op {
};
/**
* @defgroup HalSetProperty Set HAL device property
* @ingroup HalMisc
*
* @brief A commandline tool setting a property of a device. Uses libhal
*
* @{
*/
/** Print out program usage.
*
* @param argc Number of arguments given to program
* @param argv Arguments given to program
*/
static void
{
"\n"
"usage : hal-set-property --udi <udi> --key <key>\n"
" (--int <value> | --string <value> | --bool <value> |\n"
" --strlist-pre <value> | --strlist-post <value> |\n"
" --strlist-rem <value> | --double <value> | --remove)\n"
" [--help] [--version]\n");
"\n" " --udi Unique Device Id\n"
" --key Key of the property to set\n"
" --int Set value to an integer. Accepts decimal and "
" hexadecimal prefixed with 0x or x\n"
" --uint64 Set value to an integer. Accepts decimal and "
" hexadecimal prefixed with 0x or x\n"
" --string Set value to a string\n"
" --double Set value to a floating point number\n"
" --bool Set value to a boolean, ie. true or false\n"
" --strlist-pre Prepend a string to a list\n"
" --strlist-post Append a string to a list\n"
" --strlist-rem Remove a string from a list\n"
" --remove Indicates that the property should be removed\n"
" --version Show version and exit\n"
" --help Show this information and exit\n"
"\n"
"This program attempts to set property for a device. Note that, due to\n"
"security considerations, it may not be possible to set a property; on\n"
"success this program exits with exit code 0. On error, the program exits\n"
"with an exit code different from 0\n" "\n");
}
/** Entry point
*
* @param argc Number of arguments given to program
* @param argv Arguments given to program
* @return Return code
*/
int
{
if (argc <= 1) {
return 1;
}
while (1) {
int c;
int option_index = 0;
const char *opt;
{"remove", 0, NULL, 0},
{"version", 0, NULL, 0},
{"help", 0, NULL, 0},
};
if (c == -1)
break;
switch (c) {
case 0:
return 0;
type = PROP_STRING;
type = PROP_UINT64;
type = PROP_DOUBLE;
bool_value = TRUE;
bool_value = FALSE;
else {
return 1;
}
is_version = TRUE;
}
break;
default:
return 1;
break;
}
}
if (is_version) {
return 0;
}
/* must have at least one, but not neither or both */
return 1;
}
dbus_error_init (&error);
return 1;
}
return 1;
}
if (dbus_error_is_set(&error)) {
}
"Normally this means the HAL daemon (hald) is not running or not ready.\n");
return 1;
}
/* check UDI exists */
if (!udi_exists) {
return 1;
}
if (dbus_error_is_set(&error)) {
dbus_error_free (&error);
return 1;
}
if (remove) {
if (!rc) {
if (dbus_error_is_set(&error)) {
dbus_error_free (&error);
} else {
}
return 1;
}
} else {
switch (type) {
case PROP_STRING:
break;
case PROP_INT:
break;
case PROP_UINT64:
break;
case PROP_DOUBLE:
break;
case PROP_BOOL:
break;
case PROP_STRLIST_PRE:
break;
case PROP_STRLIST_POST:
break;
case PROP_STRLIST_REM:
break;
}
if (!rc) {
if (dbus_error_is_set(&error)) {
dbus_error_free (&error);
} else {
}
return 1;
}
}
return rc ? 0 : 1;
}
/**
* @}
*/