Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 802552
Collapse All | Expand All

(-)libgudev-234/gudev/gudevdevice.c (-10 / +37 lines)
Lines 896-901 Link Here
896
  return result;
896
  return result;
897
}
897
}
898
898
899
static char *
900
truncate_at_linefeed (const char *value)
901
{
902
  const char *p;
903
904
  p = strchr (value, '\n');
905
  if (!p)
906
    return NULL;
907
  return g_strndup (value, p - value);
908
}
909
899
/**
910
/**
900
 * g_udev_device_get_sysfs_attr_as_boolean:
911
 * g_udev_device_get_sysfs_attr_as_boolean:
901
 * @device: A #GUdevDevice.
912
 * @device: A #GUdevDevice.
Lines 903-909 Link Here
903
 *
914
 *
904
 * Look up the sysfs attribute with @name on @device and convert it to an
915
 * Look up the sysfs attribute with @name on @device and convert it to an
905
 * boolean. This is done by doing a case-insensitive string comparison
916
 * boolean. This is done by doing a case-insensitive string comparison
906
 * on the string value against "1" and "true". The retrieved value is
917
 * on the string value against "1", "true", "Y" and "y". The retrieved value is
907
 * cached in the device. Repeated calls will return the same value and
918
 * cached in the device. Repeated calls will return the same value and
908
 * not open the attribute again, unless updated through one of the
919
 * not open the attribute again, unless updated through one of the
909
 * "uncached" functions.
920
 * "uncached" functions.
Lines 916-933 Link Here
916
                                         const gchar  *name)
927
                                         const gchar  *name)
917
{
928
{
918
  gboolean result;
929
  gboolean result;
919
  const gchar *s;
930
  const gchar *raw;
931
  g_autofree char *truncated = NULL;
932
  const char *s;
920
933
921
  g_return_val_if_fail (G_UDEV_IS_DEVICE (device), FALSE);
934
  g_return_val_if_fail (G_UDEV_IS_DEVICE (device), FALSE);
922
  g_return_val_if_fail (name != NULL, FALSE);
935
  g_return_val_if_fail (name != NULL, FALSE);
923
936
924
  result = FALSE;
937
  result = FALSE;
925
  s = g_udev_device_get_sysfs_attr (device, name);
938
  raw = g_udev_device_get_sysfs_attr (device, name);
926
  if (s == NULL)
939
  if (raw == NULL)
927
    goto out;
940
    goto out;
928
941
929
  if (strcmp (s, "1") == 0 || g_ascii_strcasecmp (s, "true") == 0)
942
  truncated = truncate_at_linefeed (raw);
943
  s = truncated ?: raw;
944
  if (strcmp (s, "1") == 0 ||
945
      g_ascii_strcasecmp (s, "true") == 0 ||
946
      g_ascii_strcasecmp (s, "y") == 0) {
930
    result = TRUE;
947
    result = TRUE;
948
  }
949
931
 out:
950
 out:
932
  return result;
951
  return result;
933
}
952
}
Lines 1141-1147 Link Here
1141
 *
1160
 *
1142
 * Look up the sysfs attribute with @name on @device and convert it to an
1161
 * Look up the sysfs attribute with @name on @device and convert it to an
1143
 * boolean. This is done by doing a case-insensitive string comparison
1162
 * boolean. This is done by doing a case-insensitive string comparison
1144
 * on the string value against "1" and "true". This function does
1163
 * on the string value against "1", "true", "Y" and "y". This function does
1145
 * blocking I/O, and updates the sysfs attributes cache.
1164
 * blocking I/O, and updates the sysfs attributes cache.
1146
 *
1165
 *
1147
 * Returns: The value of the sysfs attribute or %FALSE if there is no such
1166
 * Returns: The value of the sysfs attribute or %FALSE if there is no such
Lines 1152-1169 Link Here
1152
                                                  const gchar  *name)
1171
                                                  const gchar  *name)
1153
{
1172
{
1154
  gboolean result;
1173
  gboolean result;
1155
  const gchar *s;
1174
  const gchar *raw;
1175
  g_autofree char *truncated = NULL;
1176
  const char *s;
1156
1177
1157
  g_return_val_if_fail (G_UDEV_IS_DEVICE (device), FALSE);
1178
  g_return_val_if_fail (G_UDEV_IS_DEVICE (device), FALSE);
1158
  g_return_val_if_fail (name != NULL, FALSE);
1179
  g_return_val_if_fail (name != NULL, FALSE);
1159
1180
1160
  result = FALSE;
1181
  result = FALSE;
1161
  s = g_udev_device_get_sysfs_attr_uncached (device, name);
1182
  raw = g_udev_device_get_sysfs_attr_uncached (device, name);
1162
  if (s == NULL)
1183
  if (raw == NULL)
1163
    goto out;
1184
    goto out;
1164
1185
1165
  if (strcmp (s, "1") == 0 || g_ascii_strcasecmp (s, "true") == 0)
1186
  truncated = truncate_at_linefeed (raw);
1187
  s = truncated ?: raw;
1188
  if (strcmp (s, "1") == 0 ||
1189
      g_ascii_strcasecmp (s, "true") == 0 ||
1190
      g_ascii_strcasecmp (s, "y") == 0) {
1166
    result = TRUE;
1191
    result = TRUE;
1192
  }
1193
1167
 out:
1194
 out:
1168
  return result;
1195
  return result;
1169
}
1196
}
(-)libgudev-234/gudev/gudevenumtypes.h (-19 lines)
Lines 1-19 Link Here
1
2
/* This file is generated by glib-mkenums, do not modify it. This code is licensed under the same license as the containing project. Note that it links to GLib, so must comply with the LGPL linking clauses. */
3
4
#ifndef __GUDEV_ENUM_TYPES_H__
5
#define __GUDEV_ENUM_TYPES_H__
6
7
#include <glib-object.h>
8
9
G_BEGIN_DECLS
10
11
/* enumerations from "/home/hadess/Projects/jhbuild/libgudev/gudev/gudevenums.h" */
12
GType g_udev_device_type_get_type (void) G_GNUC_CONST;
13
#define G_TYPE_UDEV_DEVICE_TYPE (g_udev_device_type_get_type ())
14
G_END_DECLS
15
16
#endif /* __GUDEV_ENUM_TYPES_H__ */
17
18
/* Generated data ends here */
19

Return to bug 802552