/***************************************************************************
* CVSID: $Id$
*
* hal_find_by_property.c : Find hal devices
*
* Copyright (C) 2005 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 <string.h>
#include <unistd.h>
#include <getopt.h>
#include <libhal.h>
/** Print out program usage.
*
* @param argc Number of arguments given to program
* @param argv Arguments given to program
*/
static void
{
"\n"
"usage : hal-find-by-property --key <key> --string <value>\n"
" [--help] [--verbose] [--version]\n");
/** @todo support other property types a'la hal-[get|set]-property */
"\n"
" --key Key of the property to check\n"
" --string String value of property\n"
" --verbose Be verbose\n"
" --version Show version and exit\n"
" --help Show this information and exit\n"
"\n"
"This program prints the Unique Device Identifiers for HAL device\n"
"objects where a given property assumes a given value. On success\n"
"the program exists with exit code 0. If there is an error, the\n"
"program exits 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
{
int i;
int num_udis;
char **udis;
if (argc <= 1) {
return 1;
}
while (1) {
int c;
int option_index = 0;
const char *opt;
{"verbose", 0, NULL, 0},
{"version", 0, NULL, 0},
{"help", 0, NULL, 0},
};
if (c == -1)
break;
switch (c) {
case 0:
return 0;
is_verbose = TRUE;
is_version = TRUE;
}
break;
default:
return 1;
break;
}
}
if (is_version) {
return 0;
}
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;
}
if (dbus_error_is_set (&error)) {
return 1;
}
if (is_verbose)
if (num_udis == 0) {
return 1;
}
for (i = 0; i < num_udis; i++) {
}
return 0;
}
/**
* @}
*/