summaryrefslogtreecommitdiffstats
path: root/debian/uncrustify-trinity/uncrustify-trinity-0.78.0/tests/expected/c/00103-bugs-3.c
blob: 07d410b18e242fb91ddceabcaadca986449fedfa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49

#ifdef CRUD
#define JUNK    a
#endif

#ifdef __QNX__
/**
 * Does all that QNX trickery to get the MAC address of the interface
 *
 * @param if_name The interface name: ie "en0" or "eth0"
 * @param mac     Pointer to a 6-byte array
 * @return        SUCCESS or FAILURE
 */
static INT32 socket_get_mac_qnx(const CHAR *if_name, UINT8 *mac)
{
   CHAR  ionet_name[50];
   INT32 en_fd;

#if QNX_RELEASE >= 630
   nic_config_t nic;
   INT32        dcmd = DCMD_IO_NET_GET_CONFIG;
#else
   Nic_t        nic;
   INT32        dcmd = DCMD_IO_NET_NICINFO;
#endif
   INT32        ret_val = FAILURE;

   memset(mac, 0, 6);

   /* Build the full name */
   snprintf(ionet_name, sizeof(ionet_name), "/dev/io-net/%s", if_name);

   /* Open the device */
   en_fd = open(ionet_name, O_RDWR);
   if (en_fd >= 0)
   {
      /* Get the interface info */
      if (devctl(en_fd, dcmd, &nic, sizeof(nic), NULL) == EOK)
      {
         memcpy(mac, nic.current_address, 6);
         ret_val = SUCCESS;
      }

      close(en_fd);
   }
   return(ret_val);
}
#endif