static void device_added_cb (NMClient *client, NMDevice *device, gpointer user_data) { g_print ("New device added\n"); dump_device (device); g_signal_connect (G_OBJECT (device), "notify::state", (GCallback) device_state_changed, NULL); }
static switch_status_t skinny_api_cmd_status_profile_device(const char *profile_name, const char *device_name, switch_stream_handle_t *stream) { skinny_profile_t *profile; if ((profile = skinny_find_profile(profile_name))) { dump_device(profile, device_name, stream); } else { stream->write_function(stream, "Profile not found!\n"); } return SWITCH_STATUS_SUCCESS; }
static void dump_nodes(device_node_cookie *node, uint8 level) { status_t err; device_node_cookie child = *node; dump_device(node, level); if (get_child(&child) != B_OK) return; do { dump_nodes(&child, level + 1); } while ((err = get_next_child(&child)) == B_OK); }
static gboolean test_devices (NMClient *client) { const GPtrArray *devices; int i; devices = nm_client_get_devices (client); g_print ("Got devices:\n"); if (!devices) { g_print (" NONE\n"); return TRUE; } for (i = 0; i < devices->len; i++) { NMDevice *device = g_ptr_array_index (devices, i); dump_device (device); g_print ("\n"); } return TRUE; }
int main(int argc, char **argv) { DBusError error; DBusConnection *conn; LibHalContext *hal_ctx; int err; int c; int all = 0; int list = 0; int dev = 0; char *dev_name; if (argc < 2) { return (0); } while ((c = getopt(argc, argv, "ald:")) != EOF) { switch (c) { case 'a': all = 1; break; case 'l': list = 1; break; case 'd': dev = 1; dev_name = optarg; break; default: exit(1); } } dbus_error_init(&error); if (!(conn = dbus_bus_get(DBUS_BUS_SYSTEM, &error))) { fprintf(stderr, "error: dbus_bus_get: %s: %s\n", error.name, error.message); LIBHAL_FREE_DBUS_ERROR(&error); return (2); } if (!(hal_ctx = libhal_ctx_new())) { return (3); } if (!libhal_ctx_set_dbus_connection(hal_ctx, conn)) { return (4); } if (!libhal_ctx_init(hal_ctx, &error)) { if (dbus_error_is_set(&error)) { fprintf(stderr, "error: libhal_ctx_init: %s: %s\n", error.name, error.message); LIBHAL_FREE_DBUS_ERROR(&error); } fprintf(stderr, "Could not initialise connection to hald.\n" "Normally this means the HAL daemon (hald) is not running or not ready.\n"); return (5); } err = 0; if (list) { err = list_battery_devices(hal_ctx); } if (all) { err = dump_all_devices(hal_ctx); } if (dev) { err = dump_device(hal_ctx, dev_name); } libhal_ctx_shutdown(hal_ctx, &error); libhal_ctx_free(hal_ctx); dbus_connection_unref(conn); dbus_error_free(&error); return (err); }
static void device_removed_cb (NMClient *client, NMDevice *device, gpointer user_data) { g_print ("Device removed\n"); dump_device (device); }
static void dump_platform(int index, cl_platform_id platform_id) { static struct { cl_platform_info info; size_t size; void *addr; } catalog[] = { PLATFORM_ATTR(CL_PLATFORM_PROFILE, profile), PLATFORM_ATTR(CL_PLATFORM_VERSION, version), PLATFORM_ATTR(CL_PLATFORM_NAME, name), PLATFORM_ATTR(CL_PLATFORM_VENDOR, vendor), PLATFORM_ATTR(CL_PLATFORM_EXTENSIONS, extensions), }; cl_device_id device_ids[256]; cl_uint device_num; cl_int i, rc; for (i=0; i < lengthof(catalog); i++) { rc = clGetPlatformInfo(platform_id, catalog[i].info, catalog[i].size, catalog[i].addr, NULL); if (rc != CL_SUCCESS) { fprintf(stderr, "failed on clGetPlatformInfo (%s)\n", opencl_strerror(rc)); exit(1); } } rc = clGetDeviceIDs(platform_id, CL_DEVICE_TYPE_ALL, lengthof(device_ids), device_ids, &device_num); if (rc != CL_SUCCESS) { fprintf(stderr, "failed on clGetDeviceIDs (%s)\n", opencl_strerror(rc)); exit(1); } if (only_list) printf("Platform-%02d: %s / %s - %s\n", index + 1, platform_info.vendor, platform_info.name, platform_info.version); else { printf("platform-index: %d\n", index + 1); printf("platform-vendor: %s\n", platform_info.vendor); printf("platform-name: %s\n", platform_info.name); printf("platform-version: %s\n", platform_info.version); printf("platform-profile: %s\n", platform_info.profile); printf("platform-extensions: %s\n", platform_info.extensions); } for (i=0; i < device_num; i++) { if (only_device < 0 || i + 1 == only_device) dump_device(i, device_ids[i]); } putchar('\n'); }