]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
tweak types
authorMichael Jerris <mike@jerris.com>
Sun, 20 May 2007 15:27:29 +0000 (15:27 +0000)
committerMichael Jerris <mike@jerris.com>
Sun, 20 May 2007 15:27:29 +0000 (15:27 +0000)
git-svn-id: http://svn.openzap.org/svn/openzap/trunk@53 a93c3328-9c30-0410-af19-c9cd2b2d52af

libs/openzap/src/include/sangoma_tdm_api.h

index 24f601c2de2c3fc174d64e1bfe086b0025af5ea9..a58caf5d8d6e4d0a0399a2a7df2382a7c5e40be5 100644 (file)
 
 /* sang_api.h(74) : warning C4201: nonstandard extension used : nameless struct/union */
 
-/* wanpipe_defines.h(219) : warning C4214: nonstandard extension used : bit field types other than int */\r
+/* wanpipe_defines.h(219) : warning C4214: nonstandard extension used : bit field types other than int */
 /* wanpipe_defines.h(220) : warning C4214: nonstandard extension used : bit field types other than int */
 /* this will break for any compilers that are strict ansi or strict c99 */
 
 /* The following definition for that struct should resolve this warning and work for 32 and 64 bit */
 #if 0
-struct iphdr {\r
-       \r
-#if defined(__LITTLE_ENDIAN_BITFIELD)\r
-       unsigned    ihl:4,\r
-                                                       version:4;\r
-#elif defined (__BIG_ENDIAN_BITFIELD)\r
-       unsigned    version:4,\r
-                                                       ihl:4;\r
-#else\r
-# error  "unknown byteorder!"\r
-#endif\r
-       unsigned    tos:8;\r
-       unsigned                tot_len:16;\r
-       unsigned                id:16;\r
-       unsigned                frag_off:16;\r
-       __u8    ttl;\r
-       __u8    protocol;\r
-       __u16   check;\r
-       __u32   saddr;\r
-       __u32   daddr;\r
-       /*The options start here. */\r
-};\r
+struct iphdr {
+       
+#if defined(__LITTLE_ENDIAN_BITFIELD)
+       unsigned    ihl:4,
+                                                       version:4;
+#elif defined (__BIG_ENDIAN_BITFIELD)
+       unsigned    version:4,
+                                                       ihl:4;
+#else
+# error  "unknown byteorder!"
+#endif
+       unsigned    tos:8;
+       unsigned                tot_len:16;
+       unsigned                id:16;
+       unsigned                frag_off:16;
+       __u8    ttl;
+       __u8    protocol;
+       __u16   check;
+       __u32   saddr;
+       __u32   daddr;
+       /*The options start here. */
+};
 #endif /* #if 0 */
 
 #define __inline__ __inline
@@ -90,7 +90,7 @@ struct iphdr {
 /* what should the returns from this function be?? */
 /* I dont think they are currently consistant between windows and *nix */
 #ifdef __WINDOWS__
-static __inline__ int tdmv_api_ioctl(sng_fd_t fd, wanpipe_tdm_api_cmd_t *tdm_api_cmd)
+static __inline__ int tdmv_api_ioctl(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api_cmd)
 {
        /* can we make the structure passed for this on nix and windows the same */
        /* so we don't have to do the extra 2 memcpy's on windows for this ? */
@@ -129,7 +129,7 @@ static __inline__ int tdmv_api_ioctl(sng_fd_t fd, wanpipe_tdm_api_cmd_t *tdm_api
 }
 
 #else
-static __inline__ int tdmv_api_ioctl(sng_fd_t fd, wanpipe_tdm_api_cmd_t *tdm_api_cmd)
+static __inline__ int tdmv_api_ioctl(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api_cmd)
 {
        return ioctl(fd, SIOC_WANPIPE_TDM_API, tdm_api_cmd);
 }
@@ -291,22 +291,22 @@ static __inline__ int tdmv_api_wait_socket(sng_fd_t fd, int timeout, int flags)
 /* we need some what to select if we are reading regular tdm msgs or events */
 /* need to either have 2 functions, 1 for events, 1 for regural read, or a flag on this function to choose */
 /* 2 functions preferred.  Need implementation for the event function for both nix and windows that is threadsafe */
-static __inline__ int tdmv_api_readmsg_tdm(sng_fd_t fd, void *hdrbuf, int hdrlen, void *databuf, int datalen)\r
-{\r
-       /* What do we need to do here to avoid having to do all */\r
-       /* the memcpy's on windows and still maintain api compat with nix */\r
-       int rx_len=0;\r
-#if defined(__WINDOWS__)\r
-       static RX_DATA_STRUCT   rx_data;\r
-       api_header_t                    *pri;\r
-       wp_tdm_api_rx_hdr_t             *tdm_api_rx_hdr;\r
-       wp_tdm_api_rx_hdr_t             *user_buf = (wp_tdm_api_rx_hdr_t*)hdrbuf;\r
+static __inline__ int tdmv_api_readmsg_tdm(sng_fd_t fd, void *hdrbuf, int hdrlen, void *databuf, int datalen)
+{
+       /* What do we need to do here to avoid having to do all */
+       /* the memcpy's on windows and still maintain api compat with nix */
+       int rx_len=0;
+#if defined(__WINDOWS__)
+       static RX_DATA_STRUCT   rx_data;
+       api_header_t                    *pri;
+       wp_tdm_api_rx_hdr_t             *tdm_api_rx_hdr;
+       wp_tdm_api_rx_hdr_t             *user_buf = (wp_tdm_api_rx_hdr_t*)hdrbuf;
        DWORD ln;
-\r
-       if(hdrlen != sizeof(wp_tdm_api_rx_hdr_t)){\r
-               return -1;\r
-       }\r
-\r
+
+       if(hdrlen != sizeof(wp_tdm_api_rx_hdr_t)){
+               return -1;
+       }
+
        if(!DeviceIoControl(
                        fd,
                        IoctlReadCommand,
@@ -316,111 +316,111 @@ static __inline__ int tdmv_api_readmsg_tdm(sng_fd_t fd, void *hdrbuf, int hdrlen
                        sizeof(RX_DATA_STRUCT),
                        (LPDWORD)(&ln),
                        (LPOVERLAPPED)NULL
-                       )){\r
-               return -1;\r
-       }\r
-\r
-       pri = &rx_data.api_header;\r
-       tdm_api_rx_hdr = (wp_tdm_api_rx_hdr_t*)rx_data.data;\r
-\r
-       user_buf->wp_tdm_api_event_type = pri->operation_status;\r
-\r
-       switch(pri->operation_status)\r
-       {\r
-       case SANG_STATUS_RX_DATA_AVAILABLE:\r
-               if(pri->data_length > datalen){\r
-                       break;\r
-               }\r
-               memcpy(databuf, rx_data.data, pri->data_length);\r
-               rx_len = pri->data_length;\r
-               break;\r
-\r
-       default:\r
-               break;\r
-       }\r
-\r
-#else\r
-       struct msghdr msg;\r
-       struct iovec iov[2];\r
-\r
-       memset(&msg,0,sizeof(struct msghdr));\r
-\r
-       iov[0].iov_len=hdrlen;\r
-       iov[0].iov_base=hdrbuf;\r
-\r
-       iov[1].iov_len=datalen;\r
-       iov[1].iov_base=databuf;\r
-\r
-       msg.msg_iovlen=2;\r
-       msg.msg_iov=iov;\r
-\r
-       rx_len = read(fd,&msg,datalen+hdrlen);\r
-\r
-       if (rx_len <= sizeof(wp_tdm_api_rx_hdr_t)){\r
-               return -EINVAL;\r
-       }\r
-\r
-       rx_len-=sizeof(wp_tdm_api_rx_hdr_t);\r
-#endif\r
-    return rx_len;\r
-}                    \r
-
-static __inline__ int tdmv_api_writemsg_tdm(sng_fd_t fd, void *hdrbuf, int hdrlen, void *databuf, unsigned short datalen)\r
-{\r
-       /* What do we need to do here to avoid having to do all */\r
-       /* the memcpy's on windows and still maintain api compat with nix */\r
-       int bsent = 0;\r
-#if defined(__WINDOWS__)\r
-       static TX_DATA_STRUCT   local_tx_data;\r
-       api_header_t                    *pri;\r
-       DWORD ln;\r
-\r
-       /* Are these really not needed or used???  What about for nix?? */\r
-       (void)hdrbuf;\r
-       (void)hdrlen;\r
-\r
-       pri = &local_tx_data.api_header;\r
-\r
-       pri->data_length = datalen;\r
-       memcpy(local_tx_data.data, databuf, pri->data_length);\r
-\r
-       if(!DeviceIoControl(\r
-                       fd,\r
-                       IoctlWriteCommand,\r
-                       (LPVOID)&local_tx_data,\r
-                       (ULONG)sizeof(TX_DATA_STRUCT),\r
-                       (LPVOID)&local_tx_data,\r
-                       sizeof(TX_DATA_STRUCT),\r
-                       (LPDWORD)(&ln),\r
-                       (LPOVERLAPPED)NULL\r
-                       )){\r
-               return -1;\r
-       }\r
-\r
-       if (local_tx_data.api_header.operation_status == SANG_STATUS_SUCCESS) {\r
-               bsent = datalen;\r
-       }\r
-#else\r
-       struct msghdr msg;\r
-       struct iovec iov[2];\r
-\r
-       memset(&msg,0,sizeof(struct msghdr));\r
-\r
-       iov[0].iov_len=hdrlen;\r
-       iov[0].iov_base=hdrbuf;\r
-\r
-       iov[1].iov_len=datalen;\r
-       iov[1].iov_base=databuf;\r
-\r
-       msg.msg_iovlen=2;\r
-       msg.msg_iov=iov;\r
-\r
-       bsent = write(fd,&msg,datalen+hdrlen);\r
-       if (bsent > 0){\r
-               bsent-=sizeof(wp_tdm_api_tx_hdr_t);\r
-       }\r
-#endif\r
-       return bsent;\r
-}\r
+                       )){
+               return -1;
+       }
+
+       pri = &rx_data.api_header;
+       tdm_api_rx_hdr = (wp_tdm_api_rx_hdr_t*)rx_data.data;
+
+       user_buf->wp_tdm_api_event_type = pri->operation_status;
+
+       switch(pri->operation_status)
+       {
+       case SANG_STATUS_RX_DATA_AVAILABLE:
+               if(pri->data_length > datalen){
+                       break;
+               }
+               memcpy(databuf, rx_data.data, pri->data_length);
+               rx_len = pri->data_length;
+               break;
+
+       default:
+               break;
+       }
+
+#else
+       struct msghdr msg;
+       struct iovec iov[2];
+
+       memset(&msg,0,sizeof(struct msghdr));
+
+       iov[0].iov_len=hdrlen;
+       iov[0].iov_base=hdrbuf;
+
+       iov[1].iov_len=datalen;
+       iov[1].iov_base=databuf;
+
+       msg.msg_iovlen=2;
+       msg.msg_iov=iov;
+
+       rx_len = read(fd,&msg,datalen+hdrlen);
+
+       if (rx_len <= sizeof(wp_tdm_api_rx_hdr_t)){
+               return -EINVAL;
+       }
+
+       rx_len-=sizeof(wp_tdm_api_rx_hdr_t);
+#endif
+    return rx_len;
+}                    
+
+static __inline__ int tdmv_api_writemsg_tdm(sng_fd_t fd, void *hdrbuf, int hdrlen, void *databuf, unsigned short datalen)
+{
+       /* What do we need to do here to avoid having to do all */
+       /* the memcpy's on windows and still maintain api compat with nix */
+       int bsent = 0;
+#if defined(__WINDOWS__)
+       static TX_DATA_STRUCT   local_tx_data;
+       api_header_t                    *pri;
+       DWORD ln;
+
+       /* Are these really not needed or used???  What about for nix?? */
+       (void)hdrbuf;
+       (void)hdrlen;
+
+       pri = &local_tx_data.api_header;
+
+       pri->data_length = datalen;
+       memcpy(local_tx_data.data, databuf, pri->data_length);
+
+       if(!DeviceIoControl(
+                       fd,
+                       IoctlWriteCommand,
+                       (LPVOID)&local_tx_data,
+                       (ULONG)sizeof(TX_DATA_STRUCT),
+                       (LPVOID)&local_tx_data,
+                       sizeof(TX_DATA_STRUCT),
+                       (LPDWORD)(&ln),
+                       (LPOVERLAPPED)NULL
+                       )){
+               return -1;
+       }
+
+       if (local_tx_data.api_header.operation_status == SANG_STATUS_SUCCESS) {
+               bsent = datalen;
+       }
+#else
+       struct msghdr msg;
+       struct iovec iov[2];
+
+       memset(&msg,0,sizeof(struct msghdr));
+
+       iov[0].iov_len=hdrlen;
+       iov[0].iov_base=hdrbuf;
+
+       iov[1].iov_len=datalen;
+       iov[1].iov_base=databuf;
+
+       msg.msg_iovlen=2;
+       msg.msg_iov=iov;
+
+       bsent = write(fd,&msg,datalen+hdrlen);
+       if (bsent > 0){
+               bsent-=sizeof(wp_tdm_api_tx_hdr_t);
+       }
+#endif
+       return bsent;
+}
 
 #endif /* _SANGOMA_TDM_API_H */