Want more features on Pastebin? Sign Up, it's FREE!
Guest

snippet from bluetooth-killswitch.c

By: tuxor on Nov 26th, 2011  |  syntax: C++  |  size: 0.70 KB  |  views: 86  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. void
  2. bluetooth_killswitch_set_state (BluetoothKillswitch *killswitch,
  3.                                 KillswitchState state)
  4. {
  5.         BluetoothKillswitchPrivate *priv = BLUETOOTH_KILLSWITCH_GET_PRIVATE (killswitch);
  6.         struct rfkill_event event;
  7.         ssize_t len;
  8.  
  9.         g_return_if_fail (state != KILLSWITCH_STATE_HARD_BLOCKED);
  10.  
  11.         memset (&event, 0, sizeof(event));
  12.         event.op = RFKILL_OP_CHANGE_ALL;
  13.         event.type = RFKILL_TYPE_BLUETOOTH;
  14.         if (state == KILLSWITCH_STATE_SOFT_BLOCKED)
  15.                 event.soft = 1;
  16.         else if (state == KILLSWITCH_STATE_UNBLOCKED)
  17.                 event.soft = 0;
  18.         else
  19.                 g_assert_not_reached ();
  20.  
  21.         len = write (priv->fd, &event, sizeof(event));
  22.         if (len < 0)
  23.                 g_warning ("Failed to change RFKILL state: %s",
  24.                            g_strerror (errno));
  25. }
  26.  
clone this paste RAW Paste Data