]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
make code style consistent with the rest of the lib.
authorMichael Jerris <mike@jerris.com>
Sun, 3 Jun 2007 03:07:08 +0000 (03:07 +0000)
committerMichael Jerris <mike@jerris.com>
Sun, 3 Jun 2007 03:07:08 +0000 (03:07 +0000)
git-svn-id: http://svn.openzap.org/svn/openzap/trunk@201 a93c3328-9c30-0410-af19-c9cd2b2d52af

libs/openzap/src/dsp/uart.c
libs/openzap/src/dsp/uart.h

index c6e2105fccc2290eee28806fe23a2a148fbde9f0..05a80753ecc60762d7c64b497980f81eec9bc1b0 100644 (file)
@@ -60,35 +60,33 @@ void dsp_uart_attr_init (dsp_uart_attr_t *attr)
  *     zero == ok, -1 == fail.
 */
 
-bytehandler_func_t dsp_uart_attr_get_bytehandler (dsp_uart_attr_t *attr, void **bytehandler_arg)
+bytehandler_func_t dsp_uart_attr_get_bytehandler(dsp_uart_attr_t *attr, void **bytehandler_arg)
 {
-       *bytehandler_arg = attr -> bytehandler_arg;
-       return (attr -> bytehandler);
+       *bytehandler_arg = attr->bytehandler_arg;
+       return attr->bytehandler;
 }
 
-void dsp_uart_attr_set_bytehandler (dsp_uart_attr_t *attr, bytehandler_func_t bytehandler, void *bytehandler_arg)
+void dsp_uart_attr_set_bytehandler(dsp_uart_attr_t *attr, bytehandler_func_t bytehandler, void *bytehandler_arg)
 {
-       attr -> bytehandler = bytehandler;
-       attr -> bytehandler_arg = bytehandler_arg;
+       attr->bytehandler = bytehandler;
+       attr->bytehandler_arg = bytehandler_arg;
 }
 
-dsp_uart_handle_t *dsp_uart_create (dsp_uart_attr_t *attr)
+dsp_uart_handle_t *dsp_uart_create(dsp_uart_attr_t *attr)
 {
-       dsp_uart_handle_t       *handle;
+       dsp_uart_handle_t *handle;
 
-       handle = malloc (sizeof (*handle));
-       if (handle == NULL) {
-               return (handle);
-       }
-       memset (handle, 0, sizeof (handle));
-
-       /* fill the attributes member */
-       memcpy (&handle -> attr, attr, sizeof (*attr));
+       handle = malloc(sizeof (*handle));
+       if (handle) {
+               memset(handle, 0, sizeof (handle));
 
-       return (handle);
+               /* fill the attributes member */
+               memcpy(&handle->attr, attr, sizeof (*attr));
+       }
+       return handle;
 }
 
-void dsp_uart_destroy (dsp_uart_handle_t **handle)
+void dsp_uart_destroy(dsp_uart_handle_t **handle)
 {
        if (*handle) {
                free(*handle);
@@ -97,41 +95,30 @@ void dsp_uart_destroy (dsp_uart_handle_t **handle)
 }
 
 
-void dsp_uart_bit_handler (void *x, int bit)
+void dsp_uart_bit_handler(void *x, int bit)
 {
        dsp_uart_handle_t *handle = (dsp_uart_handle_t *) x;
 
-       if (!handle -> have_start) {
+       if (!handle->have_start) {
                if (bit) {
                        return;         /* waiting for start bit (0) */
                }
-               handle -> have_start = 1;
-               handle -> data = 0;
-               handle -> nbits = 0;
+               handle->have_start = 1;
+               handle->data = 0;
+               handle->nbits = 0;
                return;
        }
 
-       handle -> data >>= 1;
-       handle -> data |= 0x80 * !!bit;
+       handle->data >>= 1;
+       handle->data |= 0x80 * !!bit;
        
-       handle -> nbits++;
-       if (handle -> nbits == 8) {
-               (*handle -> attr.bytehandler) (handle -> attr.bytehandler_arg, handle -> data);
-               handle -> nbits = 0;
-               handle -> data = 0;
-               handle -> have_start = 0;
-
-/* might consider handling errors in the future... */
-#if 0
-       } else if (handle -> nbits > 8) {
-               if (!bit) {
-                       /* framing error; expected stop bit (mark, 1) */
-                       printf ("FRAME"); fflush (stdout);
-               } else {
-                       handle -> have_start = 0;
-                       handle -> nbits = 0;
-               }
-#endif
+       handle->nbits++;
+       if (handle->nbits == 8) {
+               handle->attr.bytehandler(handle->attr.bytehandler_arg, handle->data);
+               handle->nbits = 0;
+               handle->data = 0;
+               handle->have_start = 0;
        }
+/* might consider handling errors in the future... */
 }
 
index 9989ab935da28b787d70ef16af605c96b928dd32..91b2bd08805279655d92bd38154387cba6595de9 100644 (file)
@@ -61,15 +61,15 @@ typedef struct
  *             d) feed bits through dsp_uart_bit_handler
 */
 
-void                                   dsp_uart_attr_init (dsp_uart_attr_t *attributes);
+void                                   dsp_uart_attr_init(dsp_uart_attr_t *attributes);
 
-bytehandler_func_t             dsp_uart_attr_get_bytehandler (dsp_uart_attr_t *attributes, void **bytehandler_arg);
-void                                   dsp_uart_attr_set_bytehandler (dsp_uart_attr_t *attributes, bytehandler_func_t bytehandler, void *bytehandler_arg);
+bytehandler_func_t             dsp_uart_attr_get_bytehandler(dsp_uart_attr_t *attributes, void **bytehandler_arg);
+void                                   dsp_uart_attr_set_bytehandler(dsp_uart_attr_t *attributes, bytehandler_func_t bytehandler, void *bytehandler_arg);
 
-dsp_uart_handle_t *            dsp_uart_create (dsp_uart_attr_t *attributes);
-void                                   dsp_uart_destroy (dsp_uart_handle_t **handle);
+dsp_uart_handle_t *            dsp_uart_create(dsp_uart_attr_t *attributes);
+void                                   dsp_uart_destroy(dsp_uart_handle_t **handle);
 
-void                                   dsp_uart_bit_handler (void *handle, int bit);
+void                                   dsp_uart_bit_handler(void *handle, int bit);
 
 #endif // __UART_H__