From 6110e0eeedb48c81fad0e5175aa3639f1a703bfa Mon Sep 17 00:00:00 2001
From: Jan Breuer <jan.breuer@jaybee.cz>
Date: 周一, 12 10月 2015 21:51:20 +0800
Subject: [PATCH] Format and trailing space cleanup

---
 examples/test-CVI_w_GUI/main.c           |  394 ++++++++++-----------
 libscpi/src/expression.c                 |   23 
 libscpi/src/error.c                      |   23 
 libscpi/inc/scpi/scpi.h                  |    1 
 libscpi/src/fifo.c                       |    2 
 examples/test-tcp-srq/main.c             |  121 +++---
 libscpi/inc/scpi/constants.h             |   12 
 libscpi/inc/scpi/expression.h            |    2 
 examples/common/scpi-def.c               |   30 
 libscpi/src/ieee488.c                    |   12 
 libscpi/inc/scpi/ieee488.h               |   36 +-
 libscpi/src/units.c                      |    9 
 libscpi/test/test_scpi_utils.c           |   50 +-
 libscpi/inc/scpi/parser.h                |    4 
 libscpi/test/test_parser.c               |   12 
 libscpi/src/utils.c                      |   18 
 libscpi/test/test_fifo.c                 |    2 
 libscpi/src/minimal.c                    |    2 
 libscpi/src/parser.c                     |   36 -
 libscpi/test/test_lexer_parser.c         |    6 
 libscpi/src/utils_private.h              |    8 
 examples/common/scpi-def.cpp             |   31 +
 examples/test-CVI_w_GUI/TestLibscpi.h    |   20 
 examples/test-LwIP-netconn/scpi_server.c |   46 +-
 examples/test-interactive/main.c         |   11 
 libscpi/inc/scpi/error.h                 |   21 
 libscpi/inc/scpi/types.h                 |    7 
 examples/test-parser/main.c              |    6 
 examples/test-tcp/main.c                 |   81 ++--
 29 files changed, 489 insertions(+), 537 deletions(-)

diff --git a/examples/common/scpi-def.c b/examples/common/scpi-def.c
index 91658e6..64c9d45 100644
--- a/examples/common/scpi-def.c
+++ b/examples/common/scpi-def.c
@@ -55,19 +55,18 @@
         // do something, if parameter not present
     }
 
-    
+
     SCPI_NumberToStr(context, scpi_special_numbers_def, &param1, bf, 15);
     fprintf(stderr, "\tP1=%s\r\n", bf);
 
-    
+
     SCPI_NumberToStr(context, scpi_special_numbers_def, &param2, bf, 15);
     fprintf(stderr, "\tP2=%s\r\n", bf);
 
     SCPI_ResultDouble(context, 0);
-    
+
     return SCPI_RES_OK;
 }
-
 
 static scpi_result_t DMM_MeasureVoltageAcQ(scpi_t * context) {
     scpi_number_t param1, param2;
@@ -84,16 +83,16 @@
         // do something, if parameter not present
     }
 
-    
+
     SCPI_NumberToStr(context, scpi_special_numbers_def, &param1, bf, 15);
     fprintf(stderr, "\tP1=%s\r\n", bf);
 
-    
+
     SCPI_NumberToStr(context, scpi_special_numbers_def, &param2, bf, 15);
     fprintf(stderr, "\tP2=%s\r\n", bf);
 
     SCPI_ResultDouble(context, 0);
-    
+
     return SCPI_RES_OK;
 }
 
@@ -138,19 +137,18 @@
     SCPI_CHOICE_LIST_END /* termination of option list */
 };
 
-
 static scpi_result_t TEST_ChoiceQ(scpi_t * context) {
 
     int32_t param;
     const char * name;
-    
+
     if (!SCPI_ParamChoice(context, trigger_source, &param, TRUE)) {
         return SCPI_RES_ERR;
     }
-    
+
     SCPI_ChoiceToName(trigger_source, param, &name);
-    fprintf(stderr, "\tP1=%s (%ld)\r\n", name, (long int)param);
-    
+    fprintf(stderr, "\tP1=%s (%ld)\r\n", name, (long int) param);
+
     SCPI_ResultInt32(context, param);
 
     return SCPI_RES_OK;
@@ -170,7 +168,7 @@
     char buffer[100];
     size_t copy_len;
 
-    if (!SCPI_ParamCopyText(context, buffer, sizeof(buffer), &copy_len, FALSE)) {
+    if (!SCPI_ParamCopyText(context, buffer, sizeof (buffer), &copy_len, FALSE)) {
         buffer[0] = '\0';
     }
 
@@ -278,13 +276,15 @@
 
 scpi_t scpi_context = {
     .cmdlist = scpi_commands,
-    .buffer = {
+    .buffer =
+    {
         .length = SCPI_INPUT_BUFFER_LENGTH,
         .data = scpi_input_buffer,
     },
     .interface = &scpi_interface,
     .registers = scpi_regs,
     .units = scpi_units_def,
-    .idn = {"MANUFACTURE", "INSTR2013", NULL, "01-02"},
+    .idn =
+    {"MANUFACTURE", "INSTR2013", NULL, "01-02"},
 };
 
diff --git a/examples/common/scpi-def.cpp b/examples/common/scpi-def.cpp
index 720318e..eb7db0b 100644
--- a/examples/common/scpi-def.cpp
+++ b/examples/common/scpi-def.cpp
@@ -55,19 +55,18 @@
         // do something, if parameter not present
     }
 
-    
+
     SCPI_NumberToStr(context, scpi_special_numbers_def, &param1, bf, 15);
     fprintf(stderr, "\tP1=%s\r\n", bf);
 
-    
+
     SCPI_NumberToStr(context, scpi_special_numbers_def, &param2, bf, 15);
     fprintf(stderr, "\tP2=%s\r\n", bf);
 
     SCPI_ResultDouble(context, 0);
-    
+
     return SCPI_RES_OK;
 }
-
 
 scpi_result_t DMM_MeasureVoltageAcQ(scpi_t * context) {
     scpi_number_t param1, param2;
@@ -138,7 +137,6 @@
     SCPI_CHOICE_LIST_END /* termination of option list */
 };
 
-
 scpi_result_t TEST_ChoiceQ(scpi_t * context) {
 
     int32_t param;
@@ -149,7 +147,7 @@
     }
 
     SCPI_ChoiceToName(trigger_source, param, &name);
-    fprintf(stderr, "\tP1=%s (%ld)\r\n", name, (long int)param);
+    fprintf(stderr, "\tP1=%s (%ld)\r\n", name, (long int) param);
 
     SCPI_ResultInt32(context, param);
 
@@ -158,7 +156,7 @@
 
 scpi_result_t TEST_Numbers(scpi_t * context) {
 
-    fprintf(stderr, "RAW CMD %.*s\r\n", (int)context->param_list.cmd_raw.length, context->param_list.cmd_raw.data);
+    fprintf(stderr, "RAW CMD %.*s\r\n", (int) context->param_list.cmd_raw.length, context->param_list.cmd_raw.data);
 
     return SCPI_RES_OK;
 }
@@ -167,7 +165,7 @@
     char buffer[100];
     size_t copy_len;
 
-    if(!SCPI_ParamCopyText(context, buffer, sizeof(buffer), &copy_len, false)) {
+    if (!SCPI_ParamCopyText(context, buffer, sizeof (buffer), &copy_len, false)) {
         buffer[0] = '\0';
     }
 
@@ -277,8 +275,12 @@
 
 scpi_t scpi_context = {
     /* cmdlist */ scpi_commands,
-    /* buffer */ { /* length */ SCPI_INPUT_BUFFER_LENGTH, /* position */ 0, /* data */ scpi_input_buffer},
-    /* param_list */ { /* cmd */ NULL, /* lex_state */ {NULL, NULL, 0}, /* cmd_raw */ {0, 0, NULL}},
+    /* buffer */
+    { /* length */ SCPI_INPUT_BUFFER_LENGTH, /* position */ 0, /* data */ scpi_input_buffer},
+    /* param_list */
+    { /* cmd */ NULL, /* lex_state */
+        {NULL, NULL, 0}, /* cmd_raw */
+        {0, 0, NULL}},
     /* interface */ &scpi_interface,
     /* output_count */ 0,
     /* input_count */ 0,
@@ -287,7 +289,12 @@
     /* registers */ scpi_regs,
     /* units */ scpi_units_def,
     /* user_context */ NULL,
-    /* parser_state */ { /* programHeader */ {SCPI_TOKEN_UNKNOWN, NULL, 0}, /* programData */ {SCPI_TOKEN_UNKNOWN, NULL, 0}, /* numberOfParameters */ 0, /* termination */ SCPI_MESSAGE_TERMINATION_NONE},
-    /* idn */ {"MANUFACTURE", "INSTR2013", NULL, "01-02"},
+    /* parser_state */
+    { /* programHeader */
+        {SCPI_TOKEN_UNKNOWN, NULL, 0}, /* programData */
+        {SCPI_TOKEN_UNKNOWN, NULL, 0}, /* numberOfParameters */ 0, /* termination */ SCPI_MESSAGE_TERMINATION_NONE
+    },
+    /* idn */
+    {"MANUFACTURE", "INSTR2013", NULL, "01-02"},
 };
 
diff --git a/examples/test-CVI_w_GUI/TestLibscpi.h b/examples/test-CVI_w_GUI/TestLibscpi.h
index 0e72c01..cbe48ff 100644
--- a/examples/test-CVI_w_GUI/TestLibscpi.h
+++ b/examples/test-CVI_w_GUI/TestLibscpi.h
@@ -9,10 +9,10 @@
 #include <userint.h>
 
 #ifdef __cplusplus
-    extern "C" {
+extern "C" {
 #endif
 
-     /* Panels and Controls: */
+    /* Panels and Controls: */
 
 #define  PANEL                            1
 #define  PANEL_OUTPUTDEBUG                2       /* control type: textBox, callback function: (none) */
@@ -75,22 +75,22 @@
 #define  PANEL_LEDSRQ                     59      /* control type: LED, callback function: (none) */
 
 
-     /* Control Arrays: */
+    /* Control Arrays: */
 
-          /* (no control arrays in the resource file) */
+    /* (no control arrays in the resource file) */
 
 
-     /* Menu Bars, Menus, and Menu Items: */
+    /* Menu Bars, Menus, and Menu Items: */
 
-          /* (no menu bars in the resource file) */
+    /* (no menu bars in the resource file) */
 
 
-     /* Callback Prototypes: */
+    /* Callback Prototypes: */
 
-int  CVICALLBACK cb_quit(int panel, int control, int event, void *callbackData, int eventData1, int eventData2);
-int  CVICALLBACK cb_scpi_input(int panel, int control, int event, void *callbackData, int eventData1, int eventData2);
+    int CVICALLBACK cb_quit(int panel, int control, int event, void *callbackData, int eventData1, int eventData2);
+    int CVICALLBACK cb_scpi_input(int panel, int control, int event, void *callbackData, int eventData1, int eventData2);
 
 
 #ifdef __cplusplus
-    }
+}
 #endif
diff --git a/examples/test-CVI_w_GUI/main.c b/examples/test-CVI_w_GUI/main.c
index ef981e1..bed589c 100644
--- a/examples/test-CVI_w_GUI/main.c
+++ b/examples/test-CVI_w_GUI/main.c
@@ -69,85 +69,76 @@
 
 /* helper function to remove <LF> and <CR> from the end of a string */
 /* this is needed only here for the GUI, there is a 'insert line to a text box' function */
+
 /* that automatically adds a new line, so this prohibits double line feeds for the GUI */
-void removeTrailingEndcodes(char *buf)
-{
-   int len;
-   len = strlen(buf);
-   
-   while(len > 0)
-   {
-      len--;
-      switch(buf[len])
-      {
-         case '\n'   :
-         case '\r'   :
-                        buf[len] = '\0';
-                        break;
-         default     :
-                        len = 0;    // stop loop
-                        break;
-      }
-   }
+void removeTrailingEndcodes(char *buf) {
+    int len;
+    len = strlen(buf);
+
+    while (len > 0) {
+        len--;
+        switch (buf[len]) {
+            case '\n':
+            case '\r':
+                buf[len] = '\0';
+                break;
+            default:
+                len = 0; // stop loop
+                break;
+        }
+    }
 }
 
 /* wrapper for debugging output, collects debug output until a <LF> */
+
 /* is received, then removes the <LF> and outputs the line on the GUI */
-void debug_output(char *buf)
-{
-   static char pbuf[512];
-   static int pos = 0;
-   int len;
-   
-   len = strlen(buf);
-   if(buf[len-1] == '\n')
-   {
-      buf[len-1] == '\0';
-      len--;
-      memcpy(&pbuf[pos], buf, len);
-      pos = 0;
-      InsertTextBoxLine (panelHandle, PANEL_OUTPUTDEBUG, -1, pbuf);
-   }
-   else
-   {
-      memcpy(&pbuf[pos], buf, len);
-      pos += len;
-   }
-   
+void debug_output(char *buf) {
+    static char pbuf[512];
+    static int pos = 0;
+    int len;
+
+    len = strlen(buf);
+    if (buf[len - 1] == '\n') {
+        buf[len - 1] == '\0';
+        len--;
+        memcpy(&pbuf[pos], buf, len);
+        pos = 0;
+        InsertTextBoxLine(panelHandle, PANEL_OUTPUTDEBUG, -1, pbuf);
+    } else {
+        memcpy(&pbuf[pos], buf, len);
+        pos += len;
+    }
+
 }
 
-size_t SCPI_Write(scpi_t * context, const char * data, size_t len)
-{
-   if((SCPI_outputBuffer_idx + len) > (SCPI_OUPUT_BUFFER_SIZE-1))
-   {
-      len = (SCPI_OUPUT_BUFFER_SIZE-1) - SCPI_outputBuffer_idx;    // limit length to left over space
-      // apparently there is no mechanism to cope with buffers that are too small
-   }
-   memcpy(&SCPI_outputBuffer[SCPI_outputBuffer_idx], data, len);
-   SCPI_outputBuffer_idx += len;
-   
-   SCPI_outputBuffer[SCPI_outputBuffer_idx] = '\0';
-   // return fwrite(data, 1, len, stdout);
-   return len;
+size_t SCPI_Write(scpi_t * context, const char * data, size_t len) {
+    if ((SCPI_outputBuffer_idx + len) > (SCPI_OUPUT_BUFFER_SIZE - 1)) {
+        len = (SCPI_OUPUT_BUFFER_SIZE - 1) - SCPI_outputBuffer_idx; // limit length to left over space
+        // apparently there is no mechanism to cope with buffers that are too small
+    }
+    memcpy(&SCPI_outputBuffer[SCPI_outputBuffer_idx], data, len);
+    SCPI_outputBuffer_idx += len;
+
+    SCPI_outputBuffer[SCPI_outputBuffer_idx] = '\0';
+    // return fwrite(data, 1, len, stdout);
+    return len;
 }
 
-scpi_result_t SCPI_Flush(scpi_t * context)
-{    
-// fwrite(SCPI_outputBuffer, 1, SCPI_outputBuffer_idx, stdout);
-   removeTrailingEndcodes(SCPI_outputBuffer);
-   InsertTextBoxLine (panelHandle, PANEL_OUTPUT, -1, SCPI_outputBuffer);
-   SCPI_outputBuffer_idx = 0;
-   return SCPI_RES_OK;
+scpi_result_t SCPI_Flush(scpi_t * context) {
+    // fwrite(SCPI_outputBuffer, 1, SCPI_outputBuffer_idx, stdout);
+    removeTrailingEndcodes(SCPI_outputBuffer);
+    InsertTextBoxLine(panelHandle, PANEL_OUTPUT, -1, SCPI_outputBuffer);
+    SCPI_outputBuffer_idx = 0;
+    return SCPI_RES_OK;
 }
 
-int SCPI_Error(scpi_t * context, int_fast16_t err)
-{
-   char buf[512];
-   
-//  fprintf(stderr, "**ERROR: %d, \"%s\"\r\n", (int16_t) err, SCPI_ErrorTranslate(err));
-   sprintf(buf, "**ERROR: %d, \"%s\"", (int16_t) err, SCPI_ErrorTranslate(err));
-   InsertTextBoxLine (panelHandle, PANEL_OUTPUTERR, -1, buf);
-   return 0;
+int SCPI_Error(scpi_t * context, int_fast16_t err) {
+    char buf[512];
+
+    //  fprintf(stderr, "**ERROR: %d, \"%s\"\r\n", (int16_t) err, SCPI_ErrorTranslate(err));
+    sprintf(buf, "**ERROR: %d, \"%s\"", (int16_t) err, SCPI_ErrorTranslate(err));
+    InsertTextBoxLine(panelHandle, PANEL_OUTPUTERR, -1, buf);
+    return 0;
 }
 
 scpi_result_t SCPI_Control(scpi_t * context, scpi_ctrl_name_t ctrl, scpi_reg_val_t val) {
@@ -161,10 +152,10 @@
 }
 
 scpi_result_t SCPI_Reset(scpi_t * context) {
-   char buf[256];
-//  fprintf(stderr, "**Reset\r\n");
-   sprintf(buf, "**Reset\r\n");
-   debug_output(buf);
+    char buf[256];
+    //  fprintf(stderr, "**Reset\r\n");
+    sprintf(buf, "**Reset\r\n");
+    debug_output(buf);
     return SCPI_RES_OK;
 }
 
@@ -172,184 +163,167 @@
     return SCPI_RES_ERR;
 }
 
-
 /*
  * 
  */
-int main(int argc, char** argv)
-{
-   int result;
+int main(int argc, char** argv) {
+    int result;
 
-   SCPI_Init(&scpi_context);
+    SCPI_Init(&scpi_context);
 
-   if (InitCVIRTE (0, argv, 0) == 0)
-      return -1;  /* out of memory */
-   if ((panelHandle = LoadPanel (0, "TestLibscpi.uir", PANEL)) < 0)
-      return -1;
-   DisplayPanel (panelHandle);
+    if (InitCVIRTE(0, argv, 0) == 0)
+        return -1; /* out of memory */
+    if ((panelHandle = LoadPanel(0, "TestLibscpi.uir", PANEL)) < 0)
+        return -1;
+    DisplayPanel(panelHandle);
 
-   updateSSCPIRegister();
+    updateSSCPIRegister();
 
-   RunUserInterface ();
-   DiscardPanel (panelHandle);
+    RunUserInterface();
+    DiscardPanel(panelHandle);
 
-   return (EXIT_SUCCESS);
+    return (EXIT_SUCCESS);
 }
 
-
-void updateSSCPIRegister(void)
-{
-   updateSTB();
-   updateSRE();
-   updateESR();
-   updateESE();
+void updateSSCPIRegister(void) {
+    updateSTB();
+    updateSRE();
+    updateESR();
+    updateESE();
 }
 
-void updateSTB(void)
-{
-   scpi_reg_val_t regVal;
-   
-   regVal = SCPI_RegGet(&scpi_context, SCPI_REG_STB);
+void updateSTB(void) {
+    scpi_reg_val_t regVal;
 
-   gui_updateSTB((uint8_t)(0x00FF & regVal));
+    regVal = SCPI_RegGet(&scpi_context, SCPI_REG_STB);
+
+    gui_updateSTB((uint8_t) (0x00FF & regVal));
 }
 
-void updateESR(void)
-{
-   scpi_reg_val_t regVal;
-   
-   regVal = SCPI_RegGet(&scpi_context, SCPI_REG_ESR);
+void updateESR(void) {
+    scpi_reg_val_t regVal;
 
-   gui_updateESR((uint8_t)(0x00FF & regVal));
+    regVal = SCPI_RegGet(&scpi_context, SCPI_REG_ESR);
+
+    gui_updateESR((uint8_t) (0x00FF & regVal));
 }
 
-void updateESE(void)
-{
-   scpi_reg_val_t regVal;
-   
-   regVal = SCPI_RegGet(&scpi_context, SCPI_REG_ESE);
+void updateESE(void) {
+    scpi_reg_val_t regVal;
 
-   gui_updateESE((uint8_t)(0x00FF & regVal));
+    regVal = SCPI_RegGet(&scpi_context, SCPI_REG_ESE);
+
+    gui_updateESE((uint8_t) (0x00FF & regVal));
 }
 
-void updateSRE(void)
-{
-   scpi_reg_val_t regVal;
-   
-   regVal = SCPI_RegGet(&scpi_context, SCPI_REG_SRE);
+void updateSRE(void) {
+    scpi_reg_val_t regVal;
 
-   gui_updateSRE((uint8_t)(0x00FF & regVal));
+    regVal = SCPI_RegGet(&scpi_context, SCPI_REG_SRE);
+
+    gui_updateSRE((uint8_t) (0x00FF & regVal));
 }
-
 
 /*
  *  The CALLBACK functions below are called from the CVI runtime engine when
  *  user clicks on buttons, inputs data on the GUI etc. 
  */
-int CVICALLBACK cb_scpi_input (int panel, int control, int event,
-      void *callbackData, int eventData1, int eventData2)
-{
-   char buf[256];
-   int len;
-   
-   switch (event)
-   {
-      case EVENT_COMMIT:
-         GetCtrlVal(panel, control, buf);
-         /* we have to add a endcode to make SCPI accept the string, here a <LF> is added */
-         len = strlen(buf);
-         buf[len] = '\n';
-         len++;
-         SCPI_Input(&scpi_context, buf, len);
-         
-         updateSSCPIRegister();
-         break;
-   }
-   return 0;
+int CVICALLBACK cb_scpi_input(int panel, int control, int event,
+        void *callbackData, int eventData1, int eventData2) {
+    char buf[256];
+    int len;
+
+    switch (event) {
+        case EVENT_COMMIT:
+            GetCtrlVal(panel, control, buf);
+            /* we have to add a endcode to make SCPI accept the string, here a <LF> is added */
+            len = strlen(buf);
+            buf[len] = '\n';
+            len++;
+            SCPI_Input(&scpi_context, buf, len);
+
+            updateSSCPIRegister();
+            break;
+    }
+    return 0;
 }
 
-int CVICALLBACK cb_quit (int panel, int control, int event,
-      void *callbackData, int eventData1, int eventData2)
-{
-   switch (event)
-   {
-      case EVENT_COMMIT:
-         QuitUserInterface (0);
-         break;
-   }
-   return 0;
+int CVICALLBACK cb_quit(int panel, int control, int event,
+        void *callbackData, int eventData1, int eventData2) {
+    switch (event) {
+        case EVENT_COMMIT:
+            QuitUserInterface(0);
+            break;
+    }
+    return 0;
 }
 
 /*
  * Helper functions for GUI
  */
-void gui_updateSTB(uint8_t newSTB)
-{
-   char buf[5];
-   
-   sprintf(buf, "0x%02X", newSTB);
-   SetCtrlVal(panelHandle, PANEL_STBHEX, buf);
-   
-   SetCtrlVal(panelHandle, PANEL_STB0, (newSTB & 0x01));
-   SetCtrlVal(panelHandle, PANEL_STB1, (newSTB & 0x02));
-   SetCtrlVal(panelHandle, PANEL_STB2, (newSTB & 0x04));
-   SetCtrlVal(panelHandle, PANEL_STB3, (newSTB & 0x08));
-   SetCtrlVal(panelHandle, PANEL_STB4, (newSTB & 0x10));
-   SetCtrlVal(panelHandle, PANEL_STB5, (newSTB & 0x20));
-   SetCtrlVal(panelHandle, PANEL_STB6, (newSTB & 0x40));
-   SetCtrlVal(panelHandle, PANEL_STB7, (newSTB & 0x80));
-   
-   if(0x00 == (newSTB & 0x40))   SetCtrlVal(panelHandle, PANEL_LEDSRQ, 0);
+void gui_updateSTB(uint8_t newSTB) {
+    char buf[5];
+
+    sprintf(buf, "0x%02X", newSTB);
+    SetCtrlVal(panelHandle, PANEL_STBHEX, buf);
+
+    SetCtrlVal(panelHandle, PANEL_STB0, (newSTB & 0x01));
+    SetCtrlVal(panelHandle, PANEL_STB1, (newSTB & 0x02));
+    SetCtrlVal(panelHandle, PANEL_STB2, (newSTB & 0x04));
+    SetCtrlVal(panelHandle, PANEL_STB3, (newSTB & 0x08));
+    SetCtrlVal(panelHandle, PANEL_STB4, (newSTB & 0x10));
+    SetCtrlVal(panelHandle, PANEL_STB5, (newSTB & 0x20));
+    SetCtrlVal(panelHandle, PANEL_STB6, (newSTB & 0x40));
+    SetCtrlVal(panelHandle, PANEL_STB7, (newSTB & 0x80));
+
+    if (0x00 == (newSTB & 0x40)) SetCtrlVal(panelHandle, PANEL_LEDSRQ, 0);
 
 }
 
-void gui_updateESR(uint8_t newESR)
-{
-   char buf[5];
-   
-   sprintf(buf, "0x%02X", newESR);
-   SetCtrlVal(panelHandle, PANEL_ESRHEX, buf);
-   
-   SetCtrlVal(panelHandle, PANEL_ESR0, (newESR & 0x01));
-   SetCtrlVal(panelHandle, PANEL_ESR1, (newESR & 0x02));
-   SetCtrlVal(panelHandle, PANEL_ESR2, (newESR & 0x04));
-   SetCtrlVal(panelHandle, PANEL_ESR3, (newESR & 0x08));
-   SetCtrlVal(panelHandle, PANEL_ESR4, (newESR & 0x10));
-   SetCtrlVal(panelHandle, PANEL_ESR5, (newESR & 0x20));
-   SetCtrlVal(panelHandle, PANEL_ESR6, (newESR & 0x40));
-   SetCtrlVal(panelHandle, PANEL_ESR7, (newESR & 0x80));
+void gui_updateESR(uint8_t newESR) {
+    char buf[5];
+
+    sprintf(buf, "0x%02X", newESR);
+    SetCtrlVal(panelHandle, PANEL_ESRHEX, buf);
+
+    SetCtrlVal(panelHandle, PANEL_ESR0, (newESR & 0x01));
+    SetCtrlVal(panelHandle, PANEL_ESR1, (newESR & 0x02));
+    SetCtrlVal(panelHandle, PANEL_ESR2, (newESR & 0x04));
+    SetCtrlVal(panelHandle, PANEL_ESR3, (newESR & 0x08));
+    SetCtrlVal(panelHandle, PANEL_ESR4, (newESR & 0x10));
+    SetCtrlVal(panelHandle, PANEL_ESR5, (newESR & 0x20));
+    SetCtrlVal(panelHandle, PANEL_ESR6, (newESR & 0x40));
+    SetCtrlVal(panelHandle, PANEL_ESR7, (newESR & 0x80));
 }
 
-void gui_updateESE(uint8_t newESE)
-{
-   char buf[5];
-   
-   sprintf(buf, "0x%02X", newESE);
-   SetCtrlVal(panelHandle, PANEL_ESEHEX, buf);
-   
-   SetCtrlVal(panelHandle, PANEL_ESE0, (newESE & 0x01));
-   SetCtrlVal(panelHandle, PANEL_ESE1, (newESE & 0x02));
-   SetCtrlVal(panelHandle, PANEL_ESE2, (newESE & 0x04));
-   SetCtrlVal(panelHandle, PANEL_ESE3, (newESE & 0x08));
-   SetCtrlVal(panelHandle, PANEL_ESE4, (newESE & 0x10));
-   SetCtrlVal(panelHandle, PANEL_ESE5, (newESE & 0x20));
-   SetCtrlVal(panelHandle, PANEL_ESE6, (newESE & 0x40));
-   SetCtrlVal(panelHandle, PANEL_ESE7, (newESE & 0x80));
+void gui_updateESE(uint8_t newESE) {
+    char buf[5];
+
+    sprintf(buf, "0x%02X", newESE);
+    SetCtrlVal(panelHandle, PANEL_ESEHEX, buf);
+
+    SetCtrlVal(panelHandle, PANEL_ESE0, (newESE & 0x01));
+    SetCtrlVal(panelHandle, PANEL_ESE1, (newESE & 0x02));
+    SetCtrlVal(panelHandle, PANEL_ESE2, (newESE & 0x04));
+    SetCtrlVal(panelHandle, PANEL_ESE3, (newESE & 0x08));
+    SetCtrlVal(panelHandle, PANEL_ESE4, (newESE & 0x10));
+    SetCtrlVal(panelHandle, PANEL_ESE5, (newESE & 0x20));
+    SetCtrlVal(panelHandle, PANEL_ESE6, (newESE & 0x40));
+    SetCtrlVal(panelHandle, PANEL_ESE7, (newESE & 0x80));
 }
 
-void gui_updateSRE(uint8_t newSRE)
-{
-   char buf[5];
-   
-   sprintf(buf, "0x%02X", newSRE);
-   SetCtrlVal(panelHandle, PANEL_SREHEX, buf);
-   
-   SetCtrlVal(panelHandle, PANEL_SRE0, (newSRE & 0x01));
-   SetCtrlVal(panelHandle, PANEL_SRE1, (newSRE & 0x02));
-   SetCtrlVal(panelHandle, PANEL_SRE2, (newSRE & 0x04));
-   SetCtrlVal(panelHandle, PANEL_SRE3, (newSRE & 0x08));
-   SetCtrlVal(panelHandle, PANEL_SRE4, (newSRE & 0x10));
-   SetCtrlVal(panelHandle, PANEL_SRE5, (newSRE & 0x20));
-   SetCtrlVal(panelHandle, PANEL_SRE6, (newSRE & 0x40));
-   SetCtrlVal(panelHandle, PANEL_SRE7, (newSRE & 0x80));
+void gui_updateSRE(uint8_t newSRE) {
+    char buf[5];
+
+    sprintf(buf, "0x%02X", newSRE);
+    SetCtrlVal(panelHandle, PANEL_SREHEX, buf);
+
+    SetCtrlVal(panelHandle, PANEL_SRE0, (newSRE & 0x01));
+    SetCtrlVal(panelHandle, PANEL_SRE1, (newSRE & 0x02));
+    SetCtrlVal(panelHandle, PANEL_SRE2, (newSRE & 0x04));
+    SetCtrlVal(panelHandle, PANEL_SRE3, (newSRE & 0x08));
+    SetCtrlVal(panelHandle, PANEL_SRE4, (newSRE & 0x10));
+    SetCtrlVal(panelHandle, PANEL_SRE5, (newSRE & 0x20));
+    SetCtrlVal(panelHandle, PANEL_SRE6, (newSRE & 0x40));
+    SetCtrlVal(panelHandle, PANEL_SRE7, (newSRE & 0x80));
 }
diff --git a/examples/test-LwIP-netconn/scpi_server.c b/examples/test-LwIP-netconn/scpi_server.c
index 872d1f5..191a8e9 100644
--- a/examples/test-LwIP-netconn/scpi_server.c
+++ b/examples/test-LwIP-netconn/scpi_server.c
@@ -73,12 +73,11 @@
     //fd_set fds;
 } user_data_t;
 
-struct _queue_event_t
-{
+struct _queue_event_t {
     uint8_t cmd;
     uint8_t param1;
     int16_t param2;
-} __attribute__ ((__packed__));
+} __attribute__((__packed__));
 typedef struct _queue_event_t queue_event_t;
 
 
@@ -92,7 +91,7 @@
 
 size_t SCPI_Write(scpi_t * context, const char * data, size_t len) {
     if (context->user_context != NULL) {
-        user_data_t * u = (user_data_t *)(context->user_context);
+        user_data_t * u = (user_data_t *) (context->user_context);
         if (u->io) {
             return (netconn_write(u->io, data, len, NETCONN_NOCOPY) == ERR_OK) ? len : 0;
         }
@@ -102,7 +101,7 @@
 
 scpi_result_t SCPI_Flush(scpi_t * context) {
     if (context->user_context != NULL) {
-        user_data_t * u = (user_data_t *)(context->user_context);
+        user_data_t * u = (user_data_t *) (context->user_context);
         if (u->io) {
             /* flush not implemented */
             return SCPI_RES_OK;
@@ -116,11 +115,11 @@
     // BEEP
     iprintf("**ERROR: %ld, \"%s\"\r\n", (int32_t) err, SCPI_ErrorTranslate(err));
     if (err != 0) {
-		/* New error */
+        /* New error */
         /* Beep */
-		/* Error LED ON */
+        /* Error LED ON */
     } else {
-		/* No more errors in the queue */
+        /* No more errors in the queue */
         /* Error LED OFF */
     }
     return 0;
@@ -134,11 +133,11 @@
     } else {
         iprintf("**CTRL %02x: 0x%X (%d)\r\n", ctrl, val, val);
     }
-    
+
     if (context->user_context != NULL) {
-        user_data_t * u = (user_data_t *)(context->user_context);
+        user_data_t * u = (user_data_t *) (context->user_context);
         if (u->control_io) {
-            snprintf(b, sizeof(b), "SRQ%d\r\n", val);
+            snprintf(b, sizeof (b), "SRQ%d\r\n", val);
             return netconn_write(u->control_io, b, strlen(b), NETCONN_NOCOPY) == ERR_OK ? SCPI_RES_OK : SCPI_RES_ERR;
         }
     }
@@ -156,7 +155,6 @@
     return SCPI_RES_OK;
 }
 
-
 static void setEseReq(void) {
     SCPI_RegSetBits(&scpi_context, SCPI_REG_ESR, ESR_REQ);
 }
@@ -168,14 +166,14 @@
 void SCPI_RequestControl(void) {
     queue_event_t msg;
     msg.cmd = SCPI_MSG_SET_ESE_REQ;
-    
-	/* Avoid sending evtQueue message if ESR_REQ is already set 
-	if((SCPI_RegGet(&scpi_context, SCPI_REG_ESR) & ESR_REQ) == 0) {
-	    xQueueSend(user_data.evtQueue, &msg, 1000);
-	}
-	*/
 
-	xQueueSend(user_data.evtQueue, &msg, 1000);
+    /* Avoid sending evtQueue message if ESR_REQ is already set 
+    if((SCPI_RegGet(&scpi_context, SCPI_REG_ESR) & ESR_REQ) == 0) {
+        xQueueSend(user_data.evtQueue, &msg, 1000);
+    }
+     */
+
+    xQueueSend(user_data.evtQueue, &msg, 1000);
 }
 
 void SCPI_AddError(int16_t err) {
@@ -183,7 +181,7 @@
     msg.cmd = SCPI_MSG_SET_ERROR;
     msg.param2 = err;
 
-    xQueueSend(user_data.evtQueue, &msg, 1000); 
+    xQueueSend(user_data.evtQueue, &msg, 1000);
 }
 
 void scpi_netconn_callback(struct netconn * conn, enum netconn_evt evt, u16_t len) {
@@ -355,9 +353,9 @@
 static void scpi_server_thread(void *arg) {
     queue_event_t evt;
 
-    (void)arg;
+    (void) arg;
 
-    user_data.evtQueue = xQueueCreate(10, sizeof(queue_event_t));
+    user_data.evtQueue = xQueueCreate(10, sizeof (queue_event_t));
 
     // user_context will be pointer to socket
     scpi_context.user_context = &user_data;
@@ -367,7 +365,7 @@
     user_data.io_listen = createServer(DEVICE_PORT);
     user_data.control_io_listen = createServer(CONTROL_PORT);
 
-    while(1) {
+    while (1) {
         waitServer(&user_data, &evt);
 
         if (evt.cmd == SCPI_MSG_TIMEOUT) { // timeout
@@ -393,7 +391,7 @@
         if (evt.cmd == SCPI_MSG_SET_ESE_REQ) {
             setEseReq();
         }
-        
+
         if (evt.cmd == SCPI_MSG_SET_ERROR) {
             setError(evt.param2);
         }
diff --git a/examples/test-interactive/main.c b/examples/test-interactive/main.c
index 1742bb8..06b2fca 100644
--- a/examples/test-interactive/main.c
+++ b/examples/test-interactive/main.c
@@ -45,7 +45,7 @@
     return fwrite(data, 1, len, stdout);
 }
 
-scpi_result_t SCPI_Flush(scpi_t * context) {    
+scpi_result_t SCPI_Flush(scpi_t * context) {
     return SCPI_RES_OK;
 }
 
@@ -73,6 +73,7 @@
 scpi_result_t SCPI_SystemCommTcpipControlQ(scpi_t * context) {
     return SCPI_RES_ERR;
 }
+
 /*
  * 
  */
@@ -87,10 +88,10 @@
     printf("SCPI Interactive demo\r\n");
     char smbuffer[10];
     while (1) {
-         if (NULL == fgets(smbuffer, 10, stdin)) {
-             break;
-         }
-         SCPI_Input(&scpi_context, smbuffer, strlen(smbuffer));
+        if (NULL == fgets(smbuffer, 10, stdin)) {
+            break;
+        }
+        SCPI_Input(&scpi_context, smbuffer, strlen(smbuffer));
     }
 
 
diff --git a/examples/test-parser/main.c b/examples/test-parser/main.c
index 7c562ee..4b71ff2 100644
--- a/examples/test-parser/main.c
+++ b/examples/test-parser/main.c
@@ -45,7 +45,7 @@
     return fwrite(data, 1, len, stdout);
 }
 
-scpi_result_t SCPI_Flush(scpi_t * context) {    
+scpi_result_t SCPI_Flush(scpi_t * context) {
     return SCPI_RES_OK;
 }
 
@@ -98,8 +98,8 @@
     TEST_SCPI_INPUT("*ESE\r\n"); // cause error -109, missing parameter
     TEST_SCPI_INPUT("*ESE #H20\r\n");
 
-	TEST_SCPI_INPUT("*SRE #HFF\r\n");
-    
+    TEST_SCPI_INPUT("*SRE #HFF\r\n");
+
     TEST_SCPI_INPUT("IDN?\r\n"); // cause error -113, undefined header
 
     TEST_SCPI_INPUT("SYST:ERR?\r\n");
diff --git a/examples/test-tcp-srq/main.c b/examples/test-tcp-srq/main.c
index 6c97dfc..5cd5074 100644
--- a/examples/test-tcp-srq/main.c
+++ b/examples/test-tcp-srq/main.c
@@ -51,8 +51,6 @@
 
 #define CONTROL_PORT 5026
 
-
-
 typedef struct {
     int io;
     int io_listen;
@@ -64,7 +62,7 @@
 
 size_t SCPI_Write(scpi_t * context, const char * data, size_t len) {
     if (context->user_context != NULL) {
-        user_data_t * u = (user_data_t *)(context->user_context);
+        user_data_t * u = (user_data_t *) (context->user_context);
         if (u->fio) {
             return fwrite(data, 1, len, u->fio);
         }
@@ -72,9 +70,9 @@
     return 0;
 }
 
-scpi_result_t SCPI_Flush(scpi_t * context) {    
+scpi_result_t SCPI_Flush(scpi_t * context) {
     if (context->user_context != NULL) {
-        user_data_t * u = (user_data_t *)(context->user_context);
+        user_data_t * u = (user_data_t *) (context->user_context);
         if (u->fio) {
             return fflush(u->fio) == 0 ? SCPI_RES_OK : SCPI_RES_ERR;
         }
@@ -89,7 +87,6 @@
     return 0;
 }
 
-
 scpi_result_t SCPI_Control(scpi_t * context, scpi_ctrl_name_t ctrl, scpi_reg_val_t val) {
     char b[16];
 
@@ -98,14 +95,14 @@
     } else {
         fprintf(stderr, "**CTRL %02x: 0x%X (%d)\r\n", ctrl, val, val);
     }
-    
+
     if (context->user_context != NULL) {
-        user_data_t * u = (user_data_t *)(context->user_context);
+        user_data_t * u = (user_data_t *) (context->user_context);
         if (u->control_io >= 0) {
-            snprintf(b, sizeof(b), "SRQ%d\r\n", val);
+            snprintf(b, sizeof (b), "SRQ%d\r\n", val);
             return write(u->control_io, b, strlen(b)) > 0 ? SCPI_RES_OK : SCPI_RES_ERR;
         }
-    }    
+    }
     return SCPI_RES_OK;
 }
 
@@ -124,108 +121,102 @@
     int rc;
     int on = 1;
     struct sockaddr_in servaddr;
-        
+
     /* Configure TCP Server */
-    bzero(&servaddr, sizeof(servaddr));
+    bzero(&servaddr, sizeof (servaddr));
     servaddr.sin_family = AF_INET;
-    servaddr.sin_addr.s_addr=htonl(INADDR_ANY);
-    servaddr.sin_port=htons(port);
-    
+    servaddr.sin_addr.s_addr = htonl(INADDR_ANY);
+    servaddr.sin_port = htons(port);
+
     /* Create socket */
-    fd = socket(AF_INET,SOCK_STREAM, 0);
-    if (fd < 0)
-    {
+    fd = socket(AF_INET, SOCK_STREAM, 0);
+    if (fd < 0) {
         perror("socket() failed");
         exit(-1);
-    }    
-    
+    }
+
     /* Set address reuse enable */
-    rc = setsockopt(fd, SOL_SOCKET,  SO_REUSEADDR, (char *)&on, sizeof(on));
-    if (rc < 0)
-    {
+    rc = setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (char *) &on, sizeof (on));
+    if (rc < 0) {
         perror("setsockopt() failed");
         close(fd);
         exit(-1);
     }
-   
+
     /* Set non blocking */
-    rc = ioctl(fd, FIONBIO, (char *)&on);
-    if (rc < 0)
-    {
+    rc = ioctl(fd, FIONBIO, (char *) &on);
+    if (rc < 0) {
         perror("ioctl() failed");
         close(fd);
         exit(-1);
-    }    
-    
+    }
+
     /* Bind to socket */
-    rc = bind(fd, (struct sockaddr *)&servaddr, sizeof(servaddr));
-    if (rc < 0)
-    {
+    rc = bind(fd, (struct sockaddr *) &servaddr, sizeof (servaddr));
+    if (rc < 0) {
         perror("bind() failed");
         close(fd);
         exit(-1);
     }
-    
+
     /* Listen on socket */
     listen(fd, 1);
-    if (rc < 0)
-    {
+    if (rc < 0) {
         perror("listen() failed");
         close(fd);
         exit(-1);
     }
-    
+
     return fd;
 }
 
 static int waitServer(user_data_t * user_data) {
     struct timeval timeout;
     int rc;
-    
+
     FD_ZERO(&user_data->fds);
 
     if (user_data->io >= 0) {
         FD_SET(user_data->io, &user_data->fds);
     }
-    
+
     if (user_data->io_listen >= 0) {
         FD_SET(user_data->io_listen, &user_data->fds);
     }
-    
+
     if (user_data->control_io >= 0) {
         FD_SET(user_data->control_io, &user_data->fds);
     }
-    
+
     if (user_data->control_io_listen >= 0) {
         FD_SET(user_data->control_io_listen, &user_data->fds);
     }
-    
-    timeout.tv_sec  = 5;
+
+    timeout.tv_sec = 5;
     timeout.tv_usec = 0;
-    
+
     rc = select(FD_SETSIZE, &user_data->fds, NULL, NULL, &timeout);
-    
+
     return rc;
 }
-
 
 static int processIoListen(user_data_t * user_data) {
     struct sockaddr_in cliaddr;
     socklen_t clilen;
-    clilen = sizeof(cliaddr);
-    
-    user_data->io = accept(user_data->io_listen, (struct sockaddr *)&cliaddr, &clilen);
+    clilen = sizeof (cliaddr);
+
+    user_data->io = accept(user_data->io_listen, (struct sockaddr *) &cliaddr, &clilen);
     user_data->fio = fdopen(user_data->io, "r+");
-    
+
     printf("Connection established %s\r\n", inet_ntoa(cliaddr.sin_addr));
 }
 
 static int processSrqIoListen(user_data_t * user_data) {
     struct sockaddr_in cliaddr;
     socklen_t clilen;
-    clilen = sizeof(cliaddr);
+    clilen = sizeof (cliaddr);
 
-    user_data->control_io = accept(user_data->control_io_listen, (struct sockaddr *)&cliaddr, &clilen);    
+    user_data->control_io = accept(user_data->control_io_listen, (struct sockaddr *) &cliaddr, &clilen);
     printf("Control Connection established %s\r\n", inet_ntoa(cliaddr.sin_addr));
 }
 
@@ -243,7 +234,7 @@
 static int processIo(user_data_t * user_data) {
     int rc;
     char smbuffer[10];
-    rc = recv(user_data->io, smbuffer, sizeof(smbuffer), 0);
+    rc = recv(user_data->io, smbuffer, sizeof (smbuffer), 0);
     if (rc < 0) {
         if (errno != EWOULDBLOCK) {
             closeIo(user_data);
@@ -259,8 +250,8 @@
 
 static int processSrqIo(user_data_t * user_data) {
     int rc;
-    char smbuffer[10];  
-    rc = recv(user_data->control_io, smbuffer, sizeof(smbuffer), 0);
+    char smbuffer[10];
+    rc = recv(user_data->control_io, smbuffer, sizeof (smbuffer), 0);
     if (rc < 0) {
         if (errno != EWOULDBLOCK) {
             closeSrqIo(user_data);
@@ -281,7 +272,7 @@
     (void) argc;
     (void) argv;
     int rc;
-    
+
     user_data_t user_data = {
         .io_listen = -1,
         .io = -1,
@@ -292,24 +283,24 @@
 
     // user_context will be pointer to socket
     scpi_context.user_context = &user_data;
-    
+
     SCPI_Init(&scpi_context);
 
     user_data.io_listen = createServer(5025);
     user_data.control_io_listen = createServer(CONTROL_PORT);
-    
-    while(1) {
+
+    while (1) {
         rc = waitServer(&user_data);
-        
+
         if (rc < 0) { // failed
             perror("select failed");
             exit(-1);
         }
-        
+
         if (rc == 0) { // timeout
             SCPI_Input(&scpi_context, NULL, 0);
         }
-        
+
         if ((user_data.io_listen >= 0) && FD_ISSET(user_data.io_listen, &user_data.fds)) {
             processIoListen(&user_data);
         }
@@ -317,17 +308,17 @@
         if ((user_data.control_io_listen >= 0) && FD_ISSET(user_data.control_io_listen, &user_data.fds)) {
             processSrqIoListen(&user_data);
         }
-        
+
         if ((user_data.io >= 0) && FD_ISSET(user_data.io, &user_data.fds)) {
             processIo(&user_data);
         }
-        
+
         if ((user_data.control_io >= 0) && FD_ISSET(user_data.control_io, &user_data.fds)) {
             processSrqIo(&user_data);
         }
-        
+
     }
-    
+
     return (EXIT_SUCCESS);
 }
 
diff --git a/examples/test-tcp/main.c b/examples/test-tcp/main.c
index 3099899..594b682 100644
--- a/examples/test-tcp/main.c
+++ b/examples/test-tcp/main.c
@@ -51,13 +51,13 @@
 
 size_t SCPI_Write(scpi_t * context, const char * data, size_t len) {
     if (context->user_context != NULL) {
-        int fd = *(int *)(context->user_context);
+        int fd = *(int *) (context->user_context);
         return write(fd, data, len);
     }
     return 0;
 }
 
-scpi_result_t SCPI_Flush(scpi_t * context) {    
+scpi_result_t SCPI_Flush(scpi_t * context) {
     return SCPI_RES_OK;
 }
 
@@ -91,57 +91,52 @@
     int rc;
     int on = 1;
     struct sockaddr_in servaddr;
-        
+
     /* Configure TCP Server */
-    bzero(&servaddr, sizeof(servaddr));
+    bzero(&servaddr, sizeof (servaddr));
     servaddr.sin_family = AF_INET;
-    servaddr.sin_addr.s_addr=htonl(INADDR_ANY);
-    servaddr.sin_port=htons(port);
-    
+    servaddr.sin_addr.s_addr = htonl(INADDR_ANY);
+    servaddr.sin_port = htons(port);
+
     /* Create socket */
-    fd = socket(AF_INET,SOCK_STREAM, 0);
-    if (fd < 0)
-    {
+    fd = socket(AF_INET, SOCK_STREAM, 0);
+    if (fd < 0) {
         perror("socket() failed");
         exit(-1);
-    }    
-    
+    }
+
     /* Set address reuse enable */
-    rc = setsockopt(fd, SOL_SOCKET,  SO_REUSEADDR, (char *)&on, sizeof(on));
-    if (rc < 0)
-    {
+    rc = setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (char *) &on, sizeof (on));
+    if (rc < 0) {
         perror("setsockopt() failed");
         close(fd);
         exit(-1);
     }
-   
+
     /* Set non blocking */
-    rc = ioctl(fd, FIONBIO, (char *)&on);
-    if (rc < 0)
-    {
+    rc = ioctl(fd, FIONBIO, (char *) &on);
+    if (rc < 0) {
         perror("ioctl() failed");
         close(fd);
         exit(-1);
-    }    
-    
+    }
+
     /* Bind to socket */
-    rc = bind(fd, (struct sockaddr *)&servaddr, sizeof(servaddr));
-    if (rc < 0)
-    {
+    rc = bind(fd, (struct sockaddr *) &servaddr, sizeof (servaddr));
+    if (rc < 0) {
         perror("bind() failed");
         close(fd);
         exit(-1);
     }
-    
+
     /* Listen on socket */
     listen(fd, 1);
-    if (rc < 0)
-    {
+    if (rc < 0) {
         perror("listen() failed");
         close(fd);
         exit(-1);
     }
-    
+
     return fd;
 }
 
@@ -150,16 +145,16 @@
     struct timeval timeout;
     int rc;
     int max_fd;
-    
+
     FD_ZERO(&fds);
     max_fd = fd;
     FD_SET(fd, &fds);
-    
-    timeout.tv_sec  = 5;
+
+    timeout.tv_sec = 5;
     timeout.tv_usec = 0;
-    
+
     rc = select(max_fd + 1, &fds, NULL, NULL, &timeout);
-    
+
     return rc;
 }
 
@@ -176,26 +171,26 @@
 
     // user_context will be pointer to socket
     scpi_context.user_context = NULL;
-    
+
     SCPI_Init(&scpi_context);
 
     listenfd = createServer(5025);
-    
-    while(1) {
+
+    while (1) {
         int clifd;
         struct sockaddr_in cliaddr;
         socklen_t clilen;
 
-        clilen = sizeof(cliaddr);
-        clifd = accept(listenfd, (struct sockaddr *)&cliaddr, &clilen);
-        
+        clilen = sizeof (cliaddr);
+        clifd = accept(listenfd, (struct sockaddr *) &cliaddr, &clilen);
+
         if (clifd < 0) continue;
 
         printf("Connection established %s\r\n", inet_ntoa(cliaddr.sin_addr));
 
         scpi_context.user_context = &clifd;
 
-        while(1) {
+        while (1) {
             rc = waitServer(clifd);
             if (rc < 0) { // failed
                 perror("  recv() failed");
@@ -205,13 +200,13 @@
                 SCPI_Input(&scpi_context, NULL, 0);
             }
             if (rc > 0) { // something to read
-                rc = recv(clifd, smbuffer, sizeof(smbuffer), 0);
+                rc = recv(clifd, smbuffer, sizeof (smbuffer), 0);
                 if (rc < 0) {
                     if (errno != EWOULDBLOCK) {
                         perror("  recv() failed");
                         break;
                     }
-                } else if (rc == 0) {                
+                } else if (rc == 0) {
                     printf("Connection closed\r\n");
                     break;
                 } else {
@@ -222,7 +217,7 @@
 
         close(clifd);
     }
-    
+
     return (EXIT_SUCCESS);
 }
 
diff --git a/libscpi/inc/scpi/constants.h b/libscpi/inc/scpi/constants.h
index 6023e6d..ef39a4a 100644
--- a/libscpi/inc/scpi/constants.h
+++ b/libscpi/inc/scpi/constants.h
@@ -42,18 +42,18 @@
 #endif
 
 
-/*  4.1.3.6 *IDN? */
+    /*  4.1.3.6 *IDN? */
 
 #define SCPI_DEFAULT_1_MANUFACTURE "CTU FEE"
 #define SCPI_DEFAULT_2_MODEL "TSI3225"
 #define SCPI_DEFAULT_3 "0"
 #define SCPI_DEFAULT_4_REVISION "01-01"
 
-/* 21.21 :VERSion? 
- * YYYY.V
- * YYYY = SCPI year
- * V = SCPI revision
- */
+    /* 21.21 :VERSion? 
+     * YYYY.V
+     * YYYY = SCPI year
+     * V = SCPI revision
+     */
 #define SCPI_STD_VERSION_REVISION "1999.0"
 
 #ifdef	__cplusplus
diff --git a/libscpi/inc/scpi/error.h b/libscpi/inc/scpi/error.h
index 358e1bc..81f74fd 100644
--- a/libscpi/inc/scpi/error.h
+++ b/libscpi/inc/scpi/error.h
@@ -52,12 +52,12 @@
     const char * SCPI_ErrorTranslate(int16_t err);
 
 
-/* Using X-Macro technique to define everything once
- * http://en.wikipedia.org/wiki/X_Macro
- *
- * X macro is for minimal set of errors for library itself
- * XE macro is for full set of SCPI errors available to user application
- */
+    /* Using X-Macro technique to define everything once
+     * http://en.wikipedia.org/wiki/X_Macro
+     *
+     * X macro is for minimal set of errors for library itself
+     * XE macro is for full set of SCPI errors available to user application
+     */
 #define LIST_OF_ERRORS \
     XE(SCPI_ERROR_COMMAND,                      -100, "Command error")                                \
     X(SCPI_ERROR_INVALID_CHARACTER,             -101, "Invalid character")                            \
@@ -180,21 +180,22 @@
     XE(SCPI_ERROR_REQUEST_CONTROL,              -700, "Request control")                              \
     XE(SCPI_ERROR_OPERATION_COMPLETE,           -800, "Operation complete")                           \
 
-enum {
+
+    enum {
 #define X(def, val, str) def = val,
 #if USE_FULL_ERROR_LIST
 #define XE X
 #else
 #define XE(def, val, str)
 #endif
-LIST_OF_ERRORS
+        LIST_OF_ERRORS
 
 #if USE_USER_ERROR_LIST
-LIST_OF_USER_ERRORS
+        LIST_OF_USER_ERRORS
 #endif
 #undef X
 #undef XE
-};
+    };
 
 #ifdef __cplusplus
 }
diff --git a/libscpi/inc/scpi/expression.h b/libscpi/inc/scpi/expression.h
index 9efa505..a7bbff7 100644
--- a/libscpi/inc/scpi/expression.h
+++ b/libscpi/inc/scpi/expression.h
@@ -41,7 +41,7 @@
 #ifdef __cplusplus
 extern "C" {
 #endif
-    
+
     enum _scpi_expr_result_t {
         SCPI_EXPR_OK = 0,
         SCPI_EXPR_ERROR,
diff --git a/libscpi/inc/scpi/ieee488.h b/libscpi/inc/scpi/ieee488.h
index 98c9524..08d2752 100644
--- a/libscpi/inc/scpi/ieee488.h
+++ b/libscpi/inc/scpi/ieee488.h
@@ -43,19 +43,19 @@
 extern "C" {
 #endif
 
-scpi_result_t SCPI_CoreCls(scpi_t * context);
-scpi_result_t SCPI_CoreEse(scpi_t * context);
-scpi_result_t SCPI_CoreEseQ(scpi_t * context);
-scpi_result_t SCPI_CoreEsrQ(scpi_t * context);
-scpi_result_t SCPI_CoreIdnQ(scpi_t * context);
-scpi_result_t SCPI_CoreOpc(scpi_t * context);
-scpi_result_t SCPI_CoreOpcQ(scpi_t * context);
-scpi_result_t SCPI_CoreRst(scpi_t * context);
-scpi_result_t SCPI_CoreSre(scpi_t * context);
-scpi_result_t SCPI_CoreSreQ(scpi_t * context);
-scpi_result_t SCPI_CoreStbQ(scpi_t * context);
-scpi_result_t SCPI_CoreTstQ(scpi_t * context);
-scpi_result_t SCPI_CoreWai(scpi_t * context);
+    scpi_result_t SCPI_CoreCls(scpi_t * context);
+    scpi_result_t SCPI_CoreEse(scpi_t * context);
+    scpi_result_t SCPI_CoreEseQ(scpi_t * context);
+    scpi_result_t SCPI_CoreEsrQ(scpi_t * context);
+    scpi_result_t SCPI_CoreIdnQ(scpi_t * context);
+    scpi_result_t SCPI_CoreOpc(scpi_t * context);
+    scpi_result_t SCPI_CoreOpcQ(scpi_t * context);
+    scpi_result_t SCPI_CoreRst(scpi_t * context);
+    scpi_result_t SCPI_CoreSre(scpi_t * context);
+    scpi_result_t SCPI_CoreSreQ(scpi_t * context);
+    scpi_result_t SCPI_CoreStbQ(scpi_t * context);
+    scpi_result_t SCPI_CoreTstQ(scpi_t * context);
+    scpi_result_t SCPI_CoreWai(scpi_t * context);
 
 
 #define STB_R01 0x01    /* Not used */
@@ -78,12 +78,12 @@
 #define ESR_PON 0x80    /* Power On */
 
 
-scpi_reg_val_t SCPI_RegGet(scpi_t * context, scpi_reg_name_t name);
-void SCPI_RegSet(scpi_t * context, scpi_reg_name_t name, scpi_reg_val_t val);
-void SCPI_RegSetBits(scpi_t * context, scpi_reg_name_t name, scpi_reg_val_t bits);
-void SCPI_RegClearBits(scpi_t * context, scpi_reg_name_t name, scpi_reg_val_t bits);
+    scpi_reg_val_t SCPI_RegGet(scpi_t * context, scpi_reg_name_t name);
+    void SCPI_RegSet(scpi_t * context, scpi_reg_name_t name, scpi_reg_val_t val);
+    void SCPI_RegSetBits(scpi_t * context, scpi_reg_name_t name, scpi_reg_val_t bits);
+    void SCPI_RegClearBits(scpi_t * context, scpi_reg_name_t name, scpi_reg_val_t bits);
 
-void SCPI_EventClear(scpi_t * context);
+    void SCPI_EventClear(scpi_t * context);
 
 #ifdef  __cplusplus
 }
diff --git a/libscpi/inc/scpi/parser.h b/libscpi/inc/scpi/parser.h
index c3c98ef..539bf1b 100644
--- a/libscpi/inc/scpi/parser.h
+++ b/libscpi/inc/scpi/parser.h
@@ -48,7 +48,6 @@
     int SCPI_Input(scpi_t * context, const char * data, int len);
     int SCPI_Parse(scpi_t * context, char * data, int len);
 
-
     size_t SCPI_ResultCharacters(scpi_t * context, const char * data, size_t len);
 #define SCPI_ResultMnemonic(context, data) SCPI_ResultCharacters((context), (data), strlen(data))
     size_t SCPI_ResultUInt32Base(scpi_t * context, uint32_t val, int8_t base);
@@ -60,7 +59,6 @@
     size_t SCPI_ResultText(scpi_t * context, const char * data);
     size_t SCPI_ResultArbitraryBlock(scpi_t * context, const char * data, size_t len);
     size_t SCPI_ResultBool(scpi_t * context, scpi_bool_t val);
-   
 
     scpi_bool_t SCPI_Parameter(scpi_t * context, scpi_parameter_t * parameter, scpi_bool_t mandatory);
     scpi_bool_t SCPI_ParamIsValid(scpi_parameter_t * parameter);
@@ -74,7 +72,6 @@
     scpi_bool_t SCPI_ParamToDouble(scpi_t * context, scpi_parameter_t * parameter, double * value);
     scpi_bool_t SCPI_ParamToChoice(scpi_t * context, scpi_parameter_t * parameter, const scpi_choice_def_t * options, int32_t * value);
     scpi_bool_t SCPI_ChoiceToName(const scpi_choice_def_t * options, int32_t tag, const char ** text);
-
 
     scpi_bool_t SCPI_ParamInt32(scpi_t * context, int32_t * value, scpi_bool_t mandatory);
     scpi_bool_t SCPI_ParamUInt32(scpi_t * context, uint32_t * value, scpi_bool_t mandatory);
@@ -93,7 +90,6 @@
     int32_t SCPI_CmdTag(scpi_t * context);
     scpi_bool_t SCPI_Match(const char * pattern, const char * value, size_t len);
     scpi_bool_t SCPI_CommandNumbers(scpi_t * context, int32_t * numbers, size_t len, int32_t default_value);
-
 
     // deprecated finction, should be removed later
 #define SCPI_ResultIntBase(context, val, base) SCPI_ResultInt32Base ((context), (val), (base), TRUE)
diff --git a/libscpi/inc/scpi/scpi.h b/libscpi/inc/scpi/scpi.h
index e7fe50f..ee07b1a 100644
--- a/libscpi/inc/scpi/scpi.h
+++ b/libscpi/inc/scpi/scpi.h
@@ -46,6 +46,5 @@
 #include "scpi/utils.h"
 #include "scpi/expression.h"
 
-
 #endif	/* SCPI_H */
 
diff --git a/libscpi/inc/scpi/types.h b/libscpi/inc/scpi/types.h
index 1d7277b..fab9b37 100644
--- a/libscpi/inc/scpi/types.h
+++ b/libscpi/inc/scpi/types.h
@@ -52,14 +52,14 @@
 #endif
 
 #if !HAVE_STDBOOL
-   typedef unsigned char bool;
+    typedef unsigned char bool;
 #endif
 
 #ifndef FALSE
-    #define FALSE 0
+#define FALSE 0
 #endif
 #ifndef TRUE
-    #define TRUE (!FALSE)
+#define TRUE (!FALSE)
 #endif
 
     /* basic data types */
@@ -255,6 +255,7 @@
 
     struct _scpi_number_parameter_t {
         scpi_bool_t special;
+
         union {
             double value;
             int32_t tag;
diff --git a/libscpi/src/error.c b/libscpi/src/error.c
index 34735d2..df3db2c 100644
--- a/libscpi/src/error.c
+++ b/libscpi/src/error.c
@@ -44,7 +44,6 @@
 /* basic FIFO */
 static scpi_fifo_t local_error_queue;
 
-
 /**
  * Initialize error queue
  * @param context - scpi context
@@ -56,8 +55,8 @@
      */
 
     /* basic FIFO */
-    context->error_queue = (scpi_error_queue_t)&local_error_queue;
-    fifo_init((scpi_fifo_t *)context->error_queue);
+    context->error_queue = (scpi_error_queue_t) & local_error_queue;
+    fifo_init((scpi_fifo_t *) context->error_queue);
 }
 
 /**
@@ -98,7 +97,7 @@
      */
 
     /* basic FIFO */
-    fifo_clear((scpi_fifo_t *)context->error_queue);
+    fifo_clear((scpi_fifo_t *) context->error_queue);
 
     SCPI_ErrorEmitEmpty(context);
 }
@@ -119,7 +118,7 @@
      */
 
     /* basic FIFO */
-    fifo_remove((scpi_fifo_t *)context->error_queue, &result);
+    fifo_remove((scpi_fifo_t *) context->error_queue, &result);
 
     SCPI_ErrorEmitEmpty(context);
 
@@ -140,7 +139,7 @@
      */
 
     /* basic FIFO */
-    fifo_count((scpi_fifo_t *)context->error_queue, &result);
+    fifo_count((scpi_fifo_t *) context->error_queue, &result);
 
     return result;
 }
@@ -152,7 +151,7 @@
      */
 
     /* basic FIFO */
-    fifo_add((scpi_fifo_t *)context->error_queue, err);
+    fifo_add((scpi_fifo_t *) context->error_queue, err);
 }
 
 struct error_reg {
@@ -167,7 +166,7 @@
     {-100, -199, ESR_CER}, /* Command error (e.g. syntax error) ch 21.8.9    */
     {-200, -299, ESR_EER}, /* Execution Error (e.g. range error) ch 21.8.10  */
     {-300, -399, ESR_DER}, /* Device specific error -300, -399 ch 21.8.11    */
-    {   1,32767, ESR_DER}, /* Device designer provided specific error 1, 32767 ch 21.8.11    */
+    { 1, 32767, ESR_DER}, /* Device designer provided specific error 1, 32767 ch 21.8.11    */
     {-400, -499, ESR_QER}, /* Query error -400, -499 ch 21.8.12              */
     {-500, -599, ESR_PON}, /* Power on event -500, -599 ch 21.8.13           */
     {-600, -699, ESR_URQ}, /* User Request Event -600, -699 ch 21.8.14       */
@@ -186,7 +185,7 @@
 
     SCPI_ErrorAddInternal(context, err);
 
-    for(i = 0; i < ERROR_DEFS_N; i++) {
+    for (i = 0; i < ERROR_DEFS_N; i++) {
         if ((err <= errs[i].from) && (err >= errs[i].to)) {
             SCPI_RegSetBits(context, SCPI_REG_ESR, errs[i].bit);
         }
@@ -213,14 +212,14 @@
 #else
 #define XE(def, val, str)
 #endif
-LIST_OF_ERRORS
+            LIST_OF_ERRORS
 
 #if USE_USER_ERROR_LIST
-LIST_OF_USER_ERRORS
+                    LIST_OF_USER_ERRORS
 #endif
 #undef X
 #undef XE
-        default: return "Unknown error";
+                default: return "Unknown error";
     }
 }
 
diff --git a/libscpi/src/expression.c b/libscpi/src/expression.c
index ffbdf39..308a953 100644
--- a/libscpi/src/expression.c
+++ b/libscpi/src/expression.c
@@ -49,8 +49,7 @@
  *         SCPI_EXPR_ERROR - parser error
  *         SCPI_EXPR_NO_MORE - no more data
  */
-static scpi_expr_result_t numericRange(lex_state_t * state, scpi_bool_t * isRange, scpi_token_t * valueFrom, scpi_token_t * valueTo)
-{
+static scpi_expr_result_t numericRange(lex_state_t * state, scpi_bool_t * isRange, scpi_token_t * valueFrom, scpi_token_t * valueTo) {
     if (scpiLex_DecimalNumericProgramData(state, valueFrom)) {
         if (scpiLex_Colon(state, valueTo)) {
             *isRange = TRUE;
@@ -81,8 +80,7 @@
  *         SCPI_EXPR_NO_MORE - no more data
  * @see SCPI_ExprNumericListEntryInt, SCPI_ExprNumericListEntryDouble
  */
-scpi_expr_result_t SCPI_ExprNumericListEntry(scpi_t * context, scpi_parameter_t * param, int index, scpi_bool_t * isRange, scpi_parameter_t * valueFrom, scpi_parameter_t * valueTo)
-{
+scpi_expr_result_t SCPI_ExprNumericListEntry(scpi_t * context, scpi_parameter_t * param, int index, scpi_bool_t * isRange, scpi_parameter_t * valueFrom, scpi_parameter_t * valueTo) {
     lex_state_t lex;
     int i;
     scpi_expr_result_t res = SCPI_EXPR_OK;
@@ -133,8 +131,7 @@
  *         SCPI_EXPR_NO_MORE - no more data
  * @see SCPI_ExprNumericListEntry, SCPI_ExprNumericListEntryDouble
  */
-scpi_expr_result_t SCPI_ExprNumericListEntryInt(scpi_t * context, scpi_parameter_t * param, int index, scpi_bool_t * isRange, int32_t * valueFrom, int32_t * valueTo)
-{
+scpi_expr_result_t SCPI_ExprNumericListEntryInt(scpi_t * context, scpi_parameter_t * param, int index, scpi_bool_t * isRange, int32_t * valueFrom, int32_t * valueTo) {
     scpi_expr_result_t res;
     scpi_bool_t range = FALSE;
     scpi_parameter_t paramFrom;
@@ -165,8 +162,7 @@
  *         SCPI_EXPR_NO_MORE - no more data
  * @see SCPI_ExprNumericListEntry, SCPI_ExprNumericListEntryInt
  */
-scpi_expr_result_t SCPI_ExprNumericListEntryDouble(scpi_t * context, scpi_parameter_t * param, int index, scpi_bool_t * isRange, double * valueFrom, double * valueTo)
-{
+scpi_expr_result_t SCPI_ExprNumericListEntryDouble(scpi_t * context, scpi_parameter_t * param, int index, scpi_bool_t * isRange, double * valueFrom, double * valueTo) {
     scpi_expr_result_t res;
     scpi_bool_t range = FALSE;
     scpi_parameter_t paramFrom;
@@ -192,11 +188,10 @@
  * @param length length of values array
  * @param dimensions real number of dimensions
  */
-static scpi_expr_result_t channelSpec(scpi_t * context, lex_state_t * state, int32_t * values, size_t length, size_t * dimensions)
-{
+static scpi_expr_result_t channelSpec(scpi_t * context, lex_state_t * state, int32_t * values, size_t length, size_t * dimensions) {
     scpi_parameter_t param;
     size_t i = 0;
-    while(scpiLex_DecimalNumericProgramData(state, &param)) {
+    while (scpiLex_DecimalNumericProgramData(state, &param)) {
         if (i < length) {
             SCPI_ParamToInt(context, &param, &values[i]);
         }
@@ -227,8 +222,7 @@
  * @param length length of values arrays
  * @param dimensions real number of dimensions
  */
-static scpi_expr_result_t channelRange(scpi_t * context, lex_state_t * state, scpi_bool_t * isRange, int32_t * valuesFrom, int32_t * valuesTo, size_t length, size_t * dimensions)
-{
+static scpi_expr_result_t channelRange(scpi_t * context, lex_state_t * state, scpi_bool_t * isRange, int32_t * valuesFrom, int32_t * valuesTo, size_t length, size_t * dimensions) {
     scpi_token_t token;
     scpi_expr_result_t err;
     size_t fromDimensions;
@@ -267,8 +261,7 @@
  * @param length length of values arrays
  * @param dimensions real number of dimensions
  */
-scpi_expr_result_t SCPI_ExprChannelListEntry(scpi_t * context, scpi_parameter_t * param, int index, scpi_bool_t * isRange, int32_t * valuesFrom, int32_t * valuesTo, size_t length, size_t * dimensions)
-{
+scpi_expr_result_t SCPI_ExprChannelListEntry(scpi_t * context, scpi_parameter_t * param, int index, scpi_bool_t * isRange, int32_t * valuesFrom, int32_t * valuesTo, size_t length, size_t * dimensions) {
     lex_state_t lex;
     int i;
     scpi_expr_result_t res = SCPI_EXPR_OK;
diff --git a/libscpi/src/fifo.c b/libscpi/src/fifo.c
index 341bc8e..a69cf85 100644
--- a/libscpi/src/fifo.c
+++ b/libscpi/src/fifo.c
@@ -50,7 +50,7 @@
         return FALSE;
     }
 
-    if(value) {
+    if (value) {
         *value = fifo->data[fifo->rd];
     }
 
diff --git a/libscpi/src/ieee488.c b/libscpi/src/ieee488.c
index 5212c05..cd527e3 100644
--- a/libscpi/src/ieee488.c
+++ b/libscpi/src/ieee488.c
@@ -105,7 +105,7 @@
     if ((name >= SCPI_REG_COUNT) || (context->registers == NULL)) {
         return;
     }
-    
+
     /* store old register value */
     old_val = context->registers[name];
 
@@ -148,8 +148,8 @@
         case SCPI_REG_OPERE:
             regUpdate(context, SCPI_REG_OPER);
             break;
-            
-            
+
+
         case SCPI_REG_COUNT:
             /* nothing to do */
             break;
@@ -212,7 +212,7 @@
 scpi_result_t SCPI_CoreEse(scpi_t * context) {
     int32_t new_ESE;
     if (SCPI_ParamInt32(context, &new_ESE, TRUE)) {
-        SCPI_RegSet(context, SCPI_REG_ESE, (scpi_reg_val_t)new_ESE);
+        SCPI_RegSet(context, SCPI_REG_ESE, (scpi_reg_val_t) new_ESE);
     }
     return SCPI_RES_OK;
 }
@@ -251,7 +251,7 @@
  */
 scpi_result_t SCPI_CoreIdnQ(scpi_t * context) {
     int i;
-    for (i = 0; i<4; i++) {
+    for (i = 0; i < 4; i++) {
         if (context->idn[i]) {
             SCPI_ResultMnemonic(context, context->idn[i]);
         } else {
@@ -302,7 +302,7 @@
 scpi_result_t SCPI_CoreSre(scpi_t * context) {
     int32_t new_SRE;
     if (SCPI_ParamInt32(context, &new_SRE, TRUE)) {
-        SCPI_RegSet(context, SCPI_REG_SRE, (scpi_reg_val_t)new_SRE);
+        SCPI_RegSet(context, SCPI_REG_SRE, (scpi_reg_val_t) new_SRE);
     }
     return SCPI_RES_OK;
 }
diff --git a/libscpi/src/minimal.c b/libscpi/src/minimal.c
index fcfc500..7641311 100644
--- a/libscpi/src/minimal.c
+++ b/libscpi/src/minimal.c
@@ -131,7 +131,7 @@
 scpi_result_t SCPI_StatusQuestionableEnable(scpi_t * context) {
     int32_t new_QUESE;
     if (SCPI_ParamInt32(context, &new_QUESE, TRUE)) {
-        SCPI_RegSet(context, SCPI_REG_QUESE, (scpi_reg_val_t)new_QUESE);
+        SCPI_RegSet(context, SCPI_REG_QUESE, (scpi_reg_val_t) new_QUESE);
     }
     return SCPI_RES_OK;
 }
diff --git a/libscpi/src/parser.c b/libscpi/src/parser.c
index c996764..acb53a8 100644
--- a/libscpi/src/parser.c
+++ b/libscpi/src/parser.c
@@ -339,7 +339,7 @@
  * @return
  */
 static size_t resultUInt32BaseSign(scpi_t * context, uint32_t val, int8_t base, scpi_bool_t sign) {
-    char buffer[32+1];
+    char buffer[32 + 1];
     const char * basePrefix;
     size_t result = 0;
     size_t len;
@@ -365,7 +365,7 @@
  * @return
  */
 static size_t resultUInt64BaseSign(scpi_t * context, uint64_t val, int8_t base, scpi_bool_t sign) {
-    char buffer[64+1];
+    char buffer[64 + 1];
     const char * basePrefix;
     size_t result = 0;
     size_t len;
@@ -487,7 +487,7 @@
     SCPI_UInt32ToStrBase((uint32_t) len, block_header + 2, 10, 10);
 
     header_len = strlen(block_header + 2);
-    block_header[1] = (char)(header_len + '0');
+    block_header[1] = (char) (header_len + '0');
 
     result += writeData(context, block_header, header_len + 2);
     result += writeData(context, data, len);
@@ -623,7 +623,7 @@
         case SCPI_TOKEN_DECIMAL_NUMERIC_PROGRAM_DATA:
         case SCPI_TOKEN_DECIMAL_NUMERIC_PROGRAM_DATA_WITH_SUFFIX:
             if (sign) {
-                return strBaseToInt32(parameter->ptr, (int32_t *)value, 10) > 0 ? TRUE : FALSE;
+                return strBaseToInt32(parameter->ptr, (int32_t *) value, 10) > 0 ? TRUE : FALSE;
             } else {
                 return strBaseToUInt32(parameter->ptr, value, 10) > 0 ? TRUE : FALSE;
             }
@@ -657,7 +657,7 @@
         case SCPI_TOKEN_DECIMAL_NUMERIC_PROGRAM_DATA:
         case SCPI_TOKEN_DECIMAL_NUMERIC_PROGRAM_DATA_WITH_SUFFIX:
             if (sign) {
-                return strBaseToInt64(parameter->ptr, (int64_t *)value, 10) > 0 ? TRUE : FALSE;
+                return strBaseToInt64(parameter->ptr, (int64_t *) value, 10) > 0 ? TRUE : FALSE;
             } else {
                 return strBaseToUInt64(parameter->ptr, value, 10) > 0 ? TRUE : FALSE;
             }
@@ -674,7 +674,7 @@
  * @return TRUE if succesful
  */
 scpi_bool_t SCPI_ParamToInt32(scpi_t * context, scpi_parameter_t * parameter, int32_t * value) {
-    return ParamSignToUInt32(context, parameter, (uint32_t *)value, TRUE);
+    return ParamSignToUInt32(context, parameter, (uint32_t *) value, TRUE);
 }
 
 /**
@@ -684,7 +684,7 @@
  * @param value result
  * @return TRUE if succesful
  */
-scpi_bool_t SCPI_ParamToUInt32(scpi_t * context,  scpi_parameter_t * parameter, uint32_t * value) {
+scpi_bool_t SCPI_ParamToUInt32(scpi_t * context, scpi_parameter_t * parameter, uint32_t * value) {
     return ParamSignToUInt32(context, parameter, value, FALSE);
 }
 
@@ -696,7 +696,7 @@
  * @return TRUE if succesful
  */
 scpi_bool_t SCPI_ParamToInt64(scpi_t * context, scpi_parameter_t * parameter, int64_t * value) {
-    return ParamSignToUInt64(context, parameter, (uint64_t *)value, TRUE);
+    return ParamSignToUInt64(context, parameter, (uint64_t *) value, TRUE);
 }
 
 /**
@@ -706,7 +706,7 @@
  * @param value result
  * @return TRUE if succesful
  */
-scpi_bool_t SCPI_ParamToUInt64(scpi_t * context,  scpi_parameter_t * parameter, uint64_t * value) {
+scpi_bool_t SCPI_ParamToUInt64(scpi_t * context, scpi_parameter_t * parameter, uint64_t * value) {
     return ParamSignToUInt64(context, parameter, value, FALSE);
 }
 
@@ -910,7 +910,7 @@
  * @return
  */
 scpi_bool_t SCPI_ParamInt32(scpi_t * context, int32_t * value, scpi_bool_t mandatory) {
-    return ParamSignUInt32(context, (uint32_t *)value, mandatory, TRUE);
+    return ParamSignUInt32(context, (uint32_t *) value, mandatory, TRUE);
 }
 
 /**
@@ -932,7 +932,7 @@
  * @return
  */
 scpi_bool_t SCPI_ParamInt64(scpi_t * context, int64_t * value, scpi_bool_t mandatory) {
-    return ParamSignUInt64(context, (uint64_t *)value, mandatory, TRUE);
+    return ParamSignUInt64(context, (uint64_t *) value, mandatory, TRUE);
 }
 
 /**
@@ -965,7 +965,7 @@
 
     result = SCPI_Parameter(context, &param, mandatory);
     if (result) {
-        switch(param.type) {
+        switch (param.type) {
             case SCPI_TOKEN_SINGLE_QUOTE_PROGRAM_DATA:
             case SCPI_TOKEN_DOUBLE_QUOTE_PROGRAM_DATA:
                 *value = param.ptr + 1;
@@ -1334,7 +1334,7 @@
     }
 
     pattern = context->param_list.cmd->pattern;
-    return matchCommand (pattern, cmd, strlen (cmd), NULL, 0, 0);
+    return matchCommand(pattern, cmd, strlen(cmd), NULL, 0, 0);
 }
 
 /**
@@ -1351,11 +1351,11 @@
 }
 
 scpi_bool_t SCPI_Match(const char * pattern, const char * value, size_t len) {
-    return matchCommand (pattern, value, len, NULL, 0, 0);
+    return matchCommand(pattern, value, len, NULL, 0, 0);
 }
 
 scpi_bool_t SCPI_CommandNumbers(scpi_t * context, int32_t * numbers, size_t len, int32_t default_value) {
-    return matchCommand (context->param_list.cmd->pattern,  context->param_list.cmd_raw.data, context->param_list.cmd_raw.length, numbers, len, default_value);
+    return matchCommand(context->param_list.cmd->pattern, context->param_list.cmd_raw.data, context->param_list.cmd_raw.length, numbers, len, default_value);
 }
 
 /**
@@ -1364,8 +1364,7 @@
  * @param parameter
  * @return
  */
-scpi_bool_t SCPI_ParamIsValid(scpi_parameter_t * parameter)
-{
+scpi_bool_t SCPI_ParamIsValid(scpi_parameter_t * parameter) {
     return parameter->type == SCPI_TOKEN_UNKNOWN ? FALSE : TRUE;
 }
 
@@ -1374,7 +1373,6 @@
  * @param context
  * @return
  */
-scpi_bool_t SCPI_ParamErrorOccurred(scpi_t * context)
-{
+scpi_bool_t SCPI_ParamErrorOccurred(scpi_t * context) {
     return context->cmd_error;
 }
diff --git a/libscpi/src/units.c b/libscpi/src/units.c
index acf44fa..28a75cc 100644
--- a/libscpi/src/units.c
+++ b/libscpi/src/units.c
@@ -200,8 +200,7 @@
  * @param mandatory if the parameter is mandatory
  * @return 
  */
-scpi_bool_t SCPI_ParamNumber(scpi_t * context, const scpi_choice_def_t * special, scpi_number_t * value, scpi_bool_t mandatory)
-{
+scpi_bool_t SCPI_ParamNumber(scpi_t * context, const scpi_choice_def_t * special, scpi_number_t * value, scpi_bool_t mandatory) {
     scpi_token_t token;
     lex_state_t state;
     scpi_parameter_t param;
@@ -223,7 +222,7 @@
     state.pos = state.buffer;
     state.len = param.len;
 
-    switch(param.type) {
+    switch (param.type) {
         case SCPI_TOKEN_DECIMAL_NUMERIC_PROGRAM_DATA:
         case SCPI_TOKEN_HEXNUM:
         case SCPI_TOKEN_OCTNUM:
@@ -238,7 +237,7 @@
             break;
     }
 
-    switch(param.type) {
+    switch (param.type) {
         case SCPI_TOKEN_DECIMAL_NUMERIC_PROGRAM_DATA:
         case SCPI_TOKEN_DECIMAL_NUMERIC_PROGRAM_DATA_WITH_SUFFIX:
         case SCPI_TOKEN_PROGRAM_MNEMONIC:
@@ -257,7 +256,7 @@
             break;
     }
 
-    switch(param.type) {
+    switch (param.type) {
         case SCPI_TOKEN_DECIMAL_NUMERIC_PROGRAM_DATA:
             SCPI_ParamToDouble(context, &param, &(value->value));
             break;
diff --git a/libscpi/src/utils.c b/libscpi/src/utils.c
index fa8a7f1..3d5f8c6 100644
--- a/libscpi/src/utils.c
+++ b/libscpi/src/utils.c
@@ -4,7 +4,7 @@
  * Copyright (c) 2012 Jan Breuer
  *
  * All Rights Reserved
- * 
+ *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are
  * met:
@@ -13,7 +13,7 @@
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in the
  *    documentation and/or other materials provided with the distribution.
- * 
+ *
  * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
@@ -30,10 +30,10 @@
 /**
  * @file   scpi_utils.c
  * @date   Thu Nov 15 10:58:45 UTC 2012
- * 
+ *
  * @brief  Conversion routines and string manipulation routines
- * 
- * 
+ *
+ *
  */
 
 #include <stdio.h>
@@ -53,7 +53,7 @@
  * @param str
  * @param size
  * @param set
- * @return 
+ * @return
  */
 char * strnpbrk(const char *str, size_t size, const char *set) {
     const char *scanp;
@@ -74,7 +74,7 @@
  * @param str   converted textual representation
  * @param len   string buffer length
  * @param base  output base
- * @param sign  
+ * @param sign
  * @return number of bytes written to str (without '\0')
  */
 size_t UInt32ToStrBaseSign(uint32_t val, char * str, size_t len, int8_t base, scpi_bool_t sign) {
@@ -162,7 +162,7 @@
  * @param str   converted textual representation
  * @param len   string buffer length
  * @param base  output base
- * @param sign  
+ * @param sign
  * @return number of bytes written to str (without '\0')
  */
 size_t UInt64ToStrBaseSign(uint64_t val, char * str, size_t len, int8_t base, scpi_bool_t sign) {
@@ -475,7 +475,7 @@
  * @param pattern_len
  * @param str
  * @param str_len
- * @return 
+ * @return
  */
 scpi_bool_t matchPattern(const char * pattern, size_t pattern_len, const char * str, size_t str_len, int32_t * num) {
     int pattern_sep_pos_short;
diff --git a/libscpi/src/utils_private.h b/libscpi/src/utils_private.h
index e7909e5..f864004 100644
--- a/libscpi/src/utils_private.h
+++ b/libscpi/src/utils_private.h
@@ -46,9 +46,9 @@
 #endif
 
 #if defined(__GNUC__) && (__GNUC__ >= 4)
-    #define LOCAL __attribute__((visibility ("hidden")))
+#define LOCAL __attribute__((visibility ("hidden")))
 #else
-    #define LOCAL
+#define LOCAL
 #endif
 
     char * strnpbrk(const char *str, size_t size, const char *set) LOCAL;
@@ -78,11 +78,11 @@
 #endif
 
 #ifndef min
-    #define min(a, b)  (((a) < (b)) ? (a) : (b))
+#define min(a, b)  (((a) < (b)) ? (a) : (b))
 #endif
 
 #ifndef max
-    #define max(a, b)  (((a) > (b)) ? (a) : (b))
+#define max(a, b)  (((a) > (b)) ? (a) : (b))
 #endif
 
 #if 0
diff --git a/libscpi/test/test_fifo.c b/libscpi/test/test_fifo.c
index 4b9847b..c31cc26 100644
--- a/libscpi/test/test_fifo.c
+++ b/libscpi/test/test_fifo.c
@@ -76,7 +76,7 @@
     CU_ASSERT_TRUE(fifo_remove(&fifo, &value));
     CU_ASSERT_EQUAL(value, 5);
     TEST_FIFO_COUNT(0);
-    
+
     CU_ASSERT_FALSE(fifo_remove(&fifo, &value));
     TEST_FIFO_COUNT(0);
 }
diff --git a/libscpi/test/test_lexer_parser.c b/libscpi/test/test_lexer_parser.c
index 50470b4..6110490 100644
--- a/libscpi/test/test_lexer_parser.c
+++ b/libscpi/test/test_lexer_parser.c
@@ -101,7 +101,6 @@
     if (len != token.len) printToken(&token);   \
 } while(0)
 
-
 static void testWhiteSpace(void) {
     TEST_TOKEN("  \t MEAS", scpiLex_WhiteSpace, 0, 4, SCPI_TOKEN_WS);
     TEST_TOKEN("MEAS", scpiLex_WhiteSpace, 0, 0, SCPI_TOKEN_UNKNOWN);
@@ -206,9 +205,9 @@
     TEST_TOKEN("'ah\"oj' ", scpiParser_parseProgramData, 0, 7, SCPI_TOKEN_SINGLE_QUOTE_PROGRAM_DATA);
     TEST_TOKEN("\"ah\"\"oj\" ", scpiParser_parseProgramData, 0, 8, SCPI_TOKEN_DOUBLE_QUOTE_PROGRAM_DATA);
     TEST_TOKEN("\"\"", scpiParser_parseProgramData, 0, 2, SCPI_TOKEN_DOUBLE_QUOTE_PROGRAM_DATA);
-    
+
     TEST_TOKEN("abc_213as564 , ", scpiLex_CharacterProgramData, 0, 12, SCPI_TOKEN_PROGRAM_MNEMONIC);
-    
+
     TEST_TOKEN("1.5E12 V", scpiParser_parseProgramData, 0, 8, SCPI_TOKEN_DECIMAL_NUMERIC_PROGRAM_DATA_WITH_SUFFIX);
 }
 
@@ -234,7 +233,6 @@
     else                                        \
     if (len != token.len) printToken(&token);   \
 } while(0)
-
 
 static void testAllProgramData(void) {
     TEST_ALL_TOKEN("1.5E12 V", scpiParser_parseAllProgramData, 0, 8, SCPI_TOKEN_ALL_PROGRAM_DATA, 1);
diff --git a/libscpi/test/test_parser.c b/libscpi/test/test_parser.c
index d2f5479..f810699 100644
--- a/libscpi/test/test_parser.c
+++ b/libscpi/test/test_parser.c
@@ -99,6 +99,7 @@
 }
 
 scpi_t scpi_context;
+
 static void error_buffer_clear(void) {
     err_buffer[0] = 0;
     err_buffer_pos = 0;
@@ -112,7 +113,6 @@
     err_buffer[err_buffer_pos] = err;
     err_buffer_pos++;
 }
-
 
 static size_t SCPI_Write(scpi_t * context, const char * data, size_t len) {
     (void) context;
@@ -135,6 +135,7 @@
 }
 
 scpi_reg_val_t srq_val = 0;
+
 static scpi_result_t SCPI_Control(scpi_t * context, scpi_ctrl_name_t ctrl, scpi_reg_val_t val) {
     (void) context;
 
@@ -171,16 +172,17 @@
 
 scpi_t scpi_context = {
     .cmdlist = scpi_commands,
-    .buffer = {
+    .buffer =
+    {
         .length = SCPI_INPUT_BUFFER_LENGTH,
         .data = scpi_input_buffer,
     },
     .interface = &scpi_interface,
     .registers = scpi_regs,
     .units = scpi_units_def,
-    .idn = {"MA", "IN", NULL, "VER"},
+    .idn =
+    {"MA", "IN", NULL, "VER"},
 };
-
 
 static int init_suite(void) {
     SCPI_Init(&scpi_context);
@@ -748,7 +750,7 @@
     TEST_ChannelList("(@1,2:3)", 2, 1, FALSE, 0, (0), (0), SCPI_EXPR_NO_MORE, 0);
 
     TEST_ChannelList("(@1,2!5:3!6)", 0, 2, FALSE, 1, (1), (0), SCPI_EXPR_OK, 0);
-    TEST_ChannelList("(@1,2!5:3!6)", 1, 2, TRUE, 2, (2,5), (3,6), SCPI_EXPR_OK, 0);
+    TEST_ChannelList("(@1,2!5:3!6)", 1, 2, TRUE, 2, (2, 5), (3, 6), SCPI_EXPR_OK, 0);
     TEST_ChannelList("(@1,2!5:3!6)", 2, 2, FALSE, 0, (0), (0), SCPI_EXPR_NO_MORE, 0);
 
     TEST_ChannelList("(@1,2!5:3!6)", 0, 1, FALSE, 1, (1), (0), SCPI_EXPR_OK, 0);
diff --git a/libscpi/test/test_scpi_utils.c b/libscpi/test/test_scpi_utils.c
index ea80f09..980f260 100644
--- a/libscpi/test/test_scpi_utils.c
+++ b/libscpi/test/test_scpi_utils.c
@@ -70,16 +70,16 @@
 }
 
 static void test_Int32ToStr() {
-    const size_t max=32+1;
+    const size_t max = 32 + 1;
     int32_t val[] = {0, 1, -1, INT32_MIN, INT32_MAX, 0x01234567, 0x89abcdef};
-    int N = sizeof(val) / sizeof(int32_t);
+    int N = sizeof (val) / sizeof (int32_t);
     int i;
     char str[max];
     char ref[max];
     size_t len;
 
     // test signed conversion to decimal numbers
-    for (i=0; i<N; i++) {
+    for (i = 0; i < N; i++) {
         len = SCPI_Int32ToStr(val[i], str, max);
         snprintf(ref, max, "%"PRIi32, val[i]);
         CU_ASSERT(len == strlen(ref));
@@ -88,16 +88,16 @@
 }
 
 static void test_UInt32ToStrBase() {
-    const size_t max=32+1;
+    const size_t max = 32 + 1;
     uint32_t val[] = {0, 1, -1, INT32_MIN, INT32_MAX, 0x01234567, 0x89abcdef};
-    int N = sizeof(val) / sizeof(uint32_t);
+    int N = sizeof (val) / sizeof (uint32_t);
     int i;
     char str[max];
     char ref[max];
     size_t len;
 
     // test conversion to decimal numbers
-    for (i=0; i<N; i++) {
+    for (i = 0; i < N; i++) {
         len = SCPI_UInt32ToStrBase(val[i], str, max, 10);
         snprintf(ref, max, "%"PRIu32, val[i]);
         CU_ASSERT(len == strlen(ref));
@@ -105,7 +105,7 @@
     }
 
     // test conversion to hexadecimal numbers
-    for (i=0; i<N; i++) {
+    for (i = 0; i < N; i++) {
         len = SCPI_UInt32ToStrBase(val[i], str, max, 16);
         snprintf(ref, max, "%"PRIX32, val[i]);
         CU_ASSERT(len == strlen(ref));
@@ -113,7 +113,7 @@
     }
 
     // test conversion to octal numbers
-    for (i=0; i<N; i++) {
+    for (i = 0; i < N; i++) {
         len = SCPI_UInt32ToStrBase(val[i], str, max, 8);
         snprintf(ref, max, "%"PRIo32, val[i]);
         CU_ASSERT(len == strlen(ref));
@@ -143,16 +143,16 @@
 }
 
 static void test_Int64ToStr() {
-    const size_t max=64+1;
+    const size_t max = 64 + 1;
     int64_t val[] = {0, 1, -1, INT64_MIN, INT64_MAX, 0x0123456789abcdef, 0xfedcba9876543210};
-    int N = sizeof(val) / sizeof(int64_t);
+    int N = sizeof (val) / sizeof (int64_t);
     int i;
     char str[max];
     char ref[max];
     size_t len;
 
     // test conversion to decimal numbers
-    for (i=0; i<N; i++) {
+    for (i = 0; i < N; i++) {
         len = SCPI_Int64ToStr(val[i], str, max);
         snprintf(ref, max, "%"PRIi64, val[i]);
         CU_ASSERT(len == strlen(ref));
@@ -161,16 +161,16 @@
 }
 
 static void test_UInt64ToStrBase() {
-    const size_t max=64+1;
+    const size_t max = 64 + 1;
     uint64_t val[] = {0, 1, -1, INT64_MIN, INT64_MAX, 0x0123456789abcdef, 0xfedcba9876543210};
-    int N = sizeof(val) / sizeof(uint64_t);
+    int N = sizeof (val) / sizeof (uint64_t);
     int i;
     char str[max];
     char ref[max];
     size_t len;
 
     // test conversion to decimal numbers
-    for (i=0; i<N; i++) {
+    for (i = 0; i < N; i++) {
         len = SCPI_UInt64ToStrBase(val[i], str, max, 10);
         snprintf(ref, max, "%"PRIu64, val[i]);
         CU_ASSERT(len == strlen(ref));
@@ -178,7 +178,7 @@
     }
 
     // test conversion to hexadecimal numbers
-    for (i=0; i<N; i++) {
+    for (i = 0; i < N; i++) {
         len = SCPI_UInt64ToStrBase(val[i], str, max, 16);
         snprintf(ref, max, "%"PRIX64, val[i]);
         CU_ASSERT(len == strlen(ref));
@@ -186,7 +186,7 @@
     }
 
     // test conversion to octal numbers
-    for (i=0; i<N; i++) {
+    for (i = 0; i < N; i++) {
         len = SCPI_UInt64ToStrBase(val[i], str, max, 8);
         snprintf(ref, max, "%"PRIo64, val[i]);
         CU_ASSERT(len == strlen(ref));
@@ -216,15 +216,15 @@
 }
 
 static void test_floatToStr() {
-    const size_t max=49+1;
+    const size_t max = 49 + 1;
     float val[] = {1, -1, 1.1, -1.1, 1e3, 1e30, -1.3e30, -1.3e-30};
-    int N = sizeof(val) / sizeof(float);
+    int N = sizeof (val) / sizeof (float);
     int i;
     char str[max];
     char ref[max];
     size_t len;
 
-    for (i=0; i<N; i++) {
+    for (i = 0; i < N; i++) {
         len = SCPI_FloatToStr(val[i], str, max);
         snprintf(ref, max, "%g", val[i]);
         CU_ASSERT(len == strlen(ref));
@@ -233,15 +233,15 @@
 }
 
 static void test_doubleToStr() {
-    const size_t max=49+1;
+    const size_t max = 49 + 1;
     double val[] = {1, -1, 1.1, -1.1, 1e3, 1e30, -1.3e30, -1.3e-30};
-    int N = sizeof(val) / sizeof(double);
+    int N = sizeof (val) / sizeof (double);
     int i;
     char str[max];
     char ref[max];
     size_t len;
 
-    for (i=0; i<N; i++) {
+    for (i = 0; i < N; i++) {
         len = SCPI_DoubleToStr(val[i], str, max);
         snprintf(ref, max, "%lg", val[i]);
         CU_ASSERT(len == strlen(ref));
@@ -452,15 +452,15 @@
     scpi_bool_t result;
     int32_t values[20];
 
-    #define TEST_MATCH_COMMAND(p, s, r)                         \
+#define TEST_MATCH_COMMAND(p, s, r)                         \
     do {                                                        \
         result = matchCommand(p, s, strlen(s), NULL, 0, 0);     \
         CU_ASSERT_EQUAL(result, r);                             \
     } while(0)                                                  \
 
-    #define NOPAREN(...) __VA_ARGS__
+#define NOPAREN(...) __VA_ARGS__
 
-    #define TEST_MATCH_COMMAND2(p, s, r, v)                     \
+#define TEST_MATCH_COMMAND2(p, s, r, v)                     \
     do {                                                        \
         int32_t evalues[] = {NOPAREN v};                        \
         unsigned int cnt = (sizeof(evalues)/4);                 \

--
Gitblit v1.9.1