diff --git a/amplifiers/elecraft/kpa.c b/amplifiers/elecraft/kpa.c
index d8f02939b..0b4f10bae 100644
--- a/amplifiers/elecraft/kpa.c
+++ b/amplifiers/elecraft/kpa.c
@@ -127,7 +127,8 @@ int kpa_transaction(AMP *amp, const char *cmd, char *response, int response_len)
if (err != RIG_OK) { return err; }
- len = read_string(&rs->ampport, (unsigned char *) response, response_len, ";", 1, 0, 1);
+ len = read_string(&rs->ampport, (unsigned char *) response, response_len, ";",
+ 1, 0, 1);
if (len < 0) { return len; }
}
@@ -141,7 +142,8 @@ int kpa_transaction(AMP *amp, const char *cmd, char *response, int response_len)
if (response) // if response expected get it
{
response[0] = 0;
- len = read_string(&rs->ampport, (unsigned char *) response, response_len, ";", 1, 0, 1);
+ len = read_string(&rs->ampport, (unsigned char *) response, response_len, ";",
+ 1, 0, 1);
if (len < 0)
{
@@ -167,7 +169,8 @@ int kpa_transaction(AMP *amp, const char *cmd, char *response, int response_len)
if (err != RIG_OK) { return err; }
- len = read_string(&rs->ampport, (unsigned char *) responsebuf, KPABUFSZ, ";", 1, 0, 1);
+ len = read_string(&rs->ampport, (unsigned char *) responsebuf, KPABUFSZ, ";", 1,
+ 0, 1);
if (len < 0) { return len; }
}
@@ -370,7 +373,8 @@ int kpa_get_level(AMP *amp, setting_t level, value_t *val)
//
do
{
- retval = read_string(&rs->ampport, (unsigned char *) responsebuf, sizeof(responsebuf), ";", 1, 0,
+ retval = read_string(&rs->ampport, (unsigned char *) responsebuf,
+ sizeof(responsebuf), ";", 1, 0,
1);
if (retval != RIG_OK) { return retval; }
@@ -487,7 +491,8 @@ int kpa_get_level(AMP *amp, setting_t level, value_t *val)
}
rig_debug(RIG_DEBUG_ERR, "%s unknown fault from %s\n", __func__, responsebuf);
- SNPRINTF(priv->tmpbuf, sizeof(priv->tmpbuf), "Unknown fault code=0x%02x", fault);
+ SNPRINTF(priv->tmpbuf, sizeof(priv->tmpbuf), "Unknown fault code=0x%02x",
+ fault);
val->s = priv->tmpbuf;
return RIG_OK;
diff --git a/lib/asyncpipe.c b/lib/asyncpipe.c
index 519a7c787..417825941 100644
--- a/lib/asyncpipe.c
+++ b/lib/asyncpipe.c
@@ -6,13 +6,15 @@
static volatile long pipe_serial_nunber;
-int async_pipe_create(hamlib_async_pipe_t **pipe_out, unsigned long pipe_buffer_size, unsigned long pipe_connect_timeout_millis)
+int async_pipe_create(hamlib_async_pipe_t **pipe_out,
+ unsigned long pipe_buffer_size, unsigned long pipe_connect_timeout_millis)
{
DWORD error_code;
CHAR pipe_name[MAX_PATH];
hamlib_async_pipe_t *pipe;
pipe = calloc(1, sizeof(hamlib_async_pipe_t));
+
if (pipe == NULL)
{
return -RIG_ENOMEM;
@@ -24,20 +26,20 @@ int async_pipe_create(hamlib_async_pipe_t **pipe_out, unsigned long pipe_buffer_
}
SNPRINTF(pipe_name, sizeof(pipe_name),
- "\\\\.\\Pipe\\Hamlib.%08lx.%08lx",
- GetCurrentProcessId(),
- InterlockedIncrement(&pipe_serial_nunber)
+ "\\\\.\\Pipe\\Hamlib.%08lx.%08lx",
+ GetCurrentProcessId(),
+ InterlockedIncrement(&pipe_serial_nunber)
);
pipe->read = CreateNamedPipe(
- pipe_name,
- PIPE_ACCESS_INBOUND | FILE_FLAG_OVERLAPPED,
- PIPE_TYPE_BYTE | PIPE_WAIT,
- 1, // Number of pipes
- pipe_buffer_size, // Out buffer size
- pipe_buffer_size, // In buffer size
- pipe_connect_timeout_millis, // Timeout in ms
- NULL);
+ pipe_name,
+ PIPE_ACCESS_INBOUND | FILE_FLAG_OVERLAPPED,
+ PIPE_TYPE_BYTE | PIPE_WAIT,
+ 1, // Number of pipes
+ pipe_buffer_size, // Out buffer size
+ pipe_buffer_size, // In buffer size
+ pipe_connect_timeout_millis, // Timeout in ms
+ NULL);
if (!pipe->read)
{
@@ -45,14 +47,14 @@ int async_pipe_create(hamlib_async_pipe_t **pipe_out, unsigned long pipe_buffer_
}
pipe->write = CreateFile(
- pipe_name,
- GENERIC_WRITE,
- 0, // No sharing
- NULL,
- OPEN_EXISTING,
- FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED,
- NULL // Template file
- );
+ pipe_name,
+ GENERIC_WRITE,
+ 0, // No sharing
+ NULL,
+ OPEN_EXISTING,
+ FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED,
+ NULL // Template file
+ );
if (pipe->write == INVALID_HANDLE_VALUE)
{
@@ -64,10 +66,10 @@ int async_pipe_create(hamlib_async_pipe_t **pipe_out, unsigned long pipe_buffer_
}
pipe->read_overlapped.hEvent = CreateEvent(
- NULL, // default security attribute
- TRUE, // manual-reset event
- FALSE, // initial state = not signaled
- NULL); // unnamed event object
+ NULL, // default security attribute
+ TRUE, // manual-reset event
+ FALSE, // initial state = not signaled
+ NULL); // unnamed event object
if (pipe->read_overlapped.hEvent == NULL)
{
@@ -80,10 +82,10 @@ int async_pipe_create(hamlib_async_pipe_t **pipe_out, unsigned long pipe_buffer_
}
pipe->write_overlapped.hEvent = CreateEvent(
- NULL, // default security attribute
- TRUE, // manual-reset event
- FALSE, // initial state = not signaled
- NULL); // unnamed event object
+ NULL, // default security attribute
+ TRUE, // manual-reset event
+ FALSE, // initial state = not signaled
+ NULL); // unnamed event object
if (pipe->write_overlapped.hEvent == NULL)
{
@@ -108,6 +110,7 @@ void async_pipe_close(hamlib_async_pipe_t *pipe)
CloseHandle(pipe->read);
pipe->read = NULL;
}
+
if (pipe->write != NULL)
{
CloseHandle(pipe->write);
@@ -119,6 +122,7 @@ void async_pipe_close(hamlib_async_pipe_t *pipe)
CloseHandle(pipe->read_overlapped.hEvent);
pipe->read_overlapped.hEvent = NULL;
}
+
if (pipe->write_overlapped.hEvent != NULL)
{
CloseHandle(pipe->write_overlapped.hEvent);
@@ -128,9 +132,11 @@ void async_pipe_close(hamlib_async_pipe_t *pipe)
free(pipe);
}
-ssize_t async_pipe_read(hamlib_async_pipe_t *pipe, void *buf, size_t count, int timeout)
+ssize_t async_pipe_read(hamlib_async_pipe_t *pipe, void *buf, size_t count,
+ int timeout)
{
- HANDLE event_handles[1] = {
+ HANDLE event_handles[1] =
+ {
pipe->read_overlapped.hEvent,
};
HANDLE read_handle = pipe->read;
@@ -140,63 +146,75 @@ ssize_t async_pipe_read(hamlib_async_pipe_t *pipe, void *buf, size_t count, int
ssize_t bytes_read;
result = ReadFile(read_handle, buf, count, NULL, overlapped);
+
if (!result)
{
result = GetLastError();
+
switch (result)
{
- case ERROR_SUCCESS:
- // No error?
- break;
- case ERROR_IO_PENDING:
- wait_result = WaitForMultipleObjects(1, event_handles, FALSE, timeout);
+ case ERROR_SUCCESS:
+ // No error?
+ break;
- switch (wait_result)
+ case ERROR_IO_PENDING:
+ wait_result = WaitForMultipleObjects(1, event_handles, FALSE, timeout);
+
+ switch (wait_result)
+ {
+ case WAIT_OBJECT_0 + 0:
+ break;
+
+ case WAIT_TIMEOUT:
+ if (count == 0)
{
- case WAIT_OBJECT_0 + 0:
- break;
-
- case WAIT_TIMEOUT:
- if (count == 0)
- {
- // Zero-length reads are used to wait for incoming data,
- // so the I/O operation needs to be cancelled in case of a timeout
- CancelIo(read_handle);
- return -RIG_ETIMEOUT;
- }
- else
- {
- // Should not happen, as reads with count > 0 are used only when there is data available in the pipe
- return -RIG_EINTERNAL;
- }
-
- default:
- result = GetLastError();
- rig_debug(RIG_DEBUG_ERR, "%s: WaitForMultipleObjects() error: %d\n", __func__, result);
- return -RIG_EINTERNAL;
+ // Zero-length reads are used to wait for incoming data,
+ // so the I/O operation needs to be cancelled in case of a timeout
+ CancelIo(read_handle);
+ return -RIG_ETIMEOUT;
}
- break;
+ else
+ {
+ // Should not happen, as reads with count > 0 are used only when there is data available in the pipe
+ return -RIG_EINTERNAL;
+ }
+
default:
- rig_debug(RIG_DEBUG_ERR, "%s: ReadFile() error: %d\n", __func__, result);
- return -RIG_EIO;
+ result = GetLastError();
+ rig_debug(RIG_DEBUG_ERR, "%s: WaitForMultipleObjects() error: %d\n", __func__,
+ result);
+ return -RIG_EINTERNAL;
+ }
+
+ break;
+
+ default:
+ rig_debug(RIG_DEBUG_ERR, "%s: ReadFile() error: %d\n", __func__, result);
+ return -RIG_EIO;
}
}
- result = GetOverlappedResult(read_handle, overlapped, (LPDWORD) &bytes_read, FALSE);
+ result = GetOverlappedResult(read_handle, overlapped, (LPDWORD) &bytes_read,
+ FALSE);
+
if (!result)
{
result = GetLastError();
+
switch (result)
{
- case ERROR_SUCCESS:
- // No error?
- break;
- case ERROR_IO_PENDING:
- // Shouldn't happen?
- return -RIG_ETIMEOUT;
- default:
- rig_debug(RIG_DEBUG_ERR, "%s: GetOverlappedResult() error: %d\n", __func__, result);
- return -RIG_EIO;
+ case ERROR_SUCCESS:
+ // No error?
+ break;
+
+ case ERROR_IO_PENDING:
+ // Shouldn't happen?
+ return -RIG_ETIMEOUT;
+
+ default:
+ rig_debug(RIG_DEBUG_ERR, "%s: GetOverlappedResult() error: %d\n", __func__,
+ result);
+ return -RIG_EIO;
}
}
@@ -219,9 +237,11 @@ int async_pipe_wait_for_data(hamlib_async_pipe_t *pipe, int timeout)
return result;
}
-ssize_t async_pipe_write(hamlib_async_pipe_t *pipe, const unsigned char *buf, size_t count, int timeout)
+ssize_t async_pipe_write(hamlib_async_pipe_t *pipe, const unsigned char *buf,
+ size_t count, int timeout)
{
- HANDLE event_handles[1] = {
+ HANDLE event_handles[1] =
+ {
pipe->write_overlapped.hEvent,
};
HANDLE write_handle = pipe->write;
@@ -231,53 +251,65 @@ ssize_t async_pipe_write(hamlib_async_pipe_t *pipe, const unsigned char *buf, si
ssize_t bytes_written;
result = WriteFile(write_handle, buf, count, NULL, overlapped);
+
if (!result)
{
result = GetLastError();
+
switch (result)
{
- case ERROR_SUCCESS:
- // No error?
+ case ERROR_SUCCESS:
+ // No error?
+ break;
+
+ case ERROR_IO_PENDING:
+ wait_result = WaitForMultipleObjects(1, event_handles, FALSE, timeout);
+
+ switch (wait_result)
+ {
+ case WAIT_OBJECT_0 + 0:
break;
- case ERROR_IO_PENDING:
- wait_result = WaitForMultipleObjects(1, event_handles, FALSE, timeout);
- switch (wait_result)
- {
- case WAIT_OBJECT_0 + 0:
- break;
+ case WAIT_TIMEOUT:
+ CancelIo(write_handle);
+ return -RIG_ETIMEOUT;
- case WAIT_TIMEOUT:
- CancelIo(write_handle);
- return -RIG_ETIMEOUT;
-
- default:
- result = GetLastError();
- rig_debug(RIG_DEBUG_ERR, "%s: WaitForMultipleObjects() error: %d\n", __func__, result);
- return -RIG_EINTERNAL;
- }
- break;
default:
- rig_debug(RIG_DEBUG_ERR, "%s: WriteFile() error: %d\n", __func__, result);
- return -RIG_EIO;
+ result = GetLastError();
+ rig_debug(RIG_DEBUG_ERR, "%s: WaitForMultipleObjects() error: %d\n", __func__,
+ result);
+ return -RIG_EINTERNAL;
+ }
+
+ break;
+
+ default:
+ rig_debug(RIG_DEBUG_ERR, "%s: WriteFile() error: %d\n", __func__, result);
+ return -RIG_EIO;
}
}
- result = GetOverlappedResult(write_handle, overlapped, (LPDWORD) &bytes_written, FALSE);
+ result = GetOverlappedResult(write_handle, overlapped, (LPDWORD) &bytes_written,
+ FALSE);
+
if (!result)
{
result = GetLastError();
+
switch (result)
{
- case ERROR_SUCCESS:
- // No error?
- break;
- case ERROR_IO_PENDING:
- // Shouldn't happen?
- return -RIG_ETIMEOUT;
- default:
- rig_debug(RIG_DEBUG_ERR, "%s: GetOverlappedResult() error: %d\n", __func__, result);
- return -RIG_EIO;
+ case ERROR_SUCCESS:
+ // No error?
+ break;
+
+ case ERROR_IO_PENDING:
+ // Shouldn't happen?
+ return -RIG_ETIMEOUT;
+
+ default:
+ rig_debug(RIG_DEBUG_ERR, "%s: GetOverlappedResult() error: %d\n", __func__,
+ result);
+ return -RIG_EIO;
}
}
diff --git a/lib/cJSON.c b/lib/cJSON.c
index 011589b7e..efe23399e 100644
--- a/lib/cJSON.c
+++ b/lib/cJSON.c
@@ -86,7 +86,8 @@
#endif
#endif
-typedef struct {
+typedef struct
+{
const unsigned char *json;
size_t position;
} error;
@@ -94,10 +95,10 @@ static error global_error = { NULL, 0 };
CJSON_PUBLIC(const char *) cJSON_GetErrorPtr(void)
{
- return (const char*) (global_error.json + global_error.position);
+ return (const char *)(global_error.json + global_error.position);
}
-CJSON_PUBLIC(char *) cJSON_GetStringValue(const cJSON * const item)
+CJSON_PUBLIC(char *) cJSON_GetStringValue(const cJSON *const item)
{
if (!cJSON_IsString(item))
{
@@ -107,7 +108,7 @@ CJSON_PUBLIC(char *) cJSON_GetStringValue(const cJSON * const item)
return item->valuestring;
}
-CJSON_PUBLIC(double) cJSON_GetNumberValue(const cJSON * const item)
+CJSON_PUBLIC(double) cJSON_GetNumberValue(const cJSON *const item)
{
if (!cJSON_IsNumber(item))
{
@@ -122,16 +123,18 @@ CJSON_PUBLIC(double) cJSON_GetNumberValue(const cJSON * const item)
#error cJSON.h and cJSON.c have different versions. Make sure that both have the same.
#endif
-CJSON_PUBLIC(const char*) cJSON_Version(void)
+CJSON_PUBLIC(const char *) cJSON_Version(void)
{
static char version[15];
- SNPRINTF(version, sizeof(version), "%i.%i.%i", CJSON_VERSION_MAJOR, CJSON_VERSION_MINOR, CJSON_VERSION_PATCH);
+ SNPRINTF(version, sizeof(version), "%i.%i.%i", CJSON_VERSION_MAJOR,
+ CJSON_VERSION_MINOR, CJSON_VERSION_PATCH);
return version;
}
/* Case insensitive string comparison, doesn't consider two NULL pointers equal though */
-static int case_insensitive_strcmp(const unsigned char *string1, const unsigned char *string2)
+static int case_insensitive_strcmp(const unsigned char *string1,
+ const unsigned char *string2)
{
if ((string1 == NULL) || (string2 == NULL))
{
@@ -143,7 +146,7 @@ static int case_insensitive_strcmp(const unsigned char *string1, const unsigned
return 0;
}
- for(; tolower(*string1) == tolower(*string2); (void)string1++, string2++)
+ for (; tolower(*string1) == tolower(*string2); (void)string1++, string2++)
{
if (*string1 == '\0')
{
@@ -163,7 +166,7 @@ typedef struct internal_hooks
#if defined(_MSC_VER)
/* work around MSVC error C2322: '...' address of dllimport '...' is not static */
-static void * CJSON_CDECL internal_malloc(size_t size)
+static void *CJSON_CDECL internal_malloc(size_t size)
{
return malloc(size);
}
@@ -171,7 +174,7 @@ static void CJSON_CDECL internal_free(void *pointer)
{
free(pointer);
}
-static void * CJSON_CDECL internal_realloc(void *pointer, size_t size)
+static void *CJSON_CDECL internal_realloc(void *pointer, size_t size)
{
return realloc(pointer, size);
}
@@ -186,7 +189,8 @@ static void * CJSON_CDECL internal_realloc(void *pointer, size_t size)
static internal_hooks global_hooks = { internal_malloc, internal_free, internal_realloc };
-static unsigned char* cJSON_strdup(const unsigned char* string, const internal_hooks * const hooks)
+static unsigned char *cJSON_strdup(const unsigned char *string,
+ const internal_hooks *const hooks)
{
size_t length = 0;
unsigned char *copy = NULL;
@@ -196,52 +200,58 @@ static unsigned char* cJSON_strdup(const unsigned char* string, const internal_h
return NULL;
}
- length = strlen((const char*)string) + sizeof("");
- copy = (unsigned char*)hooks->allocate(length);
+ length = strlen((const char *)string) + sizeof("");
+ copy = (unsigned char *)hooks->allocate(length);
+
if (copy == NULL)
{
return NULL;
}
+
memcpy(copy, string, length);
return copy;
}
-CJSON_PUBLIC(void) cJSON_InitHooks(cJSON_Hooks* hooks)
+CJSON_PUBLIC(void) cJSON_InitHooks(cJSON_Hooks *hooks)
{
-if (hooks == NULL)
-{
-/* Reset hooks */
-global_hooks.allocate = malloc;
-global_hooks.deallocate = free;
-global_hooks.reallocate = realloc;
-return;
-}
+ if (hooks == NULL)
+ {
+ /* Reset hooks */
+ global_hooks.allocate = malloc;
+ global_hooks.deallocate = free;
+ global_hooks.reallocate = realloc;
+ return;
+ }
-global_hooks.allocate = malloc;
-if (hooks->malloc_fn != NULL)
-{
-global_hooks.allocate = hooks->malloc_fn;
-}
+ global_hooks.allocate = malloc;
-global_hooks.deallocate = free;
-if (hooks->free_fn != NULL)
-{
-global_hooks.deallocate = hooks->free_fn;
-}
+ if (hooks->malloc_fn != NULL)
+ {
+ global_hooks.allocate = hooks->malloc_fn;
+ }
-/* use realloc only if both free and malloc are used */
-global_hooks.reallocate = NULL;
-if ((global_hooks.allocate == malloc) && (global_hooks.deallocate == free))
-{
-global_hooks.reallocate = realloc;
-}
+ global_hooks.deallocate = free;
+
+ if (hooks->free_fn != NULL)
+ {
+ global_hooks.deallocate = hooks->free_fn;
+ }
+
+ /* use realloc only if both free and malloc are used */
+ global_hooks.reallocate = NULL;
+
+ if ((global_hooks.allocate == malloc) && (global_hooks.deallocate == free))
+ {
+ global_hooks.reallocate = realloc;
+ }
}
/* Internal constructor. */
-static cJSON *cJSON_New_Item(const internal_hooks * const hooks)
+static cJSON *cJSON_New_Item(const internal_hooks *const hooks)
{
- cJSON* node = (cJSON*)hooks->allocate(sizeof(cJSON));
+ cJSON *node = (cJSON *)hooks->allocate(sizeof(cJSON));
+
if (node)
{
memset(node, '\0', sizeof(cJSON));
@@ -253,25 +263,30 @@ static cJSON *cJSON_New_Item(const internal_hooks * const hooks)
/* Delete a cJSON structure. */
CJSON_PUBLIC(void) cJSON_Delete(cJSON *item)
{
-cJSON *next = NULL;
-while (item != NULL)
-{
-next = item->next;
-if (!(item->type & cJSON_IsReference) && (item->child != NULL))
-{
-cJSON_Delete(item->child);
-}
-if (!(item->type & cJSON_IsReference) && (item->valuestring != NULL))
-{
-global_hooks.deallocate(item->valuestring);
-}
-if (!(item->type & cJSON_StringIsConst) && (item->string != NULL))
-{
-global_hooks.deallocate(item->string);
-}
-global_hooks.deallocate(item);
-item = next;
-}
+ cJSON *next = NULL;
+
+ while (item != NULL)
+ {
+ next = item->next;
+
+ if (!(item->type & cJSON_IsReference) && (item->child != NULL))
+ {
+ cJSON_Delete(item->child);
+ }
+
+ if (!(item->type & cJSON_IsReference) && (item->valuestring != NULL))
+ {
+ global_hooks.deallocate(item->valuestring);
+ }
+
+ if (!(item->type & cJSON_StringIsConst) && (item->string != NULL))
+ {
+ global_hooks.deallocate(item->string);
+ }
+
+ global_hooks.deallocate(item);
+ item = next;
+ }
}
/* get the decimal point character of the current locale */
@@ -303,7 +318,8 @@ typedef struct
#define buffer_at_offset(buffer) ((buffer)->content + (buffer)->offset)
/* Parse the input text to generate a number, and populate the result into item. */
-static cJSON_bool parse_number(cJSON * const item, parse_buffer * const input_buffer, int input_buffer_len)
+static cJSON_bool parse_number(cJSON *const item,
+ parse_buffer *const input_buffer, int input_buffer_len)
{
double number = 0;
unsigned char *after_end = NULL;
@@ -319,39 +335,42 @@ static cJSON_bool parse_number(cJSON * const item, parse_buffer * const input_bu
/* copy the number into a temporary buffer and replace '.' with the decimal point
* of the current locale (for strtod)
* This also takes care of '\0' not necessarily being available for marking the end of the input */
- for (i = 0; (i < (sizeof(number_c_string) - 1)) && can_access_at_index(input_buffer, i); i++)
+ for (i = 0; (i < (sizeof(number_c_string) - 1))
+ && can_access_at_index(input_buffer, i); i++)
{
switch (buffer_at_offset(input_buffer)[i])
{
- case '0':
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- case '8':
- case '9':
- case '+':
- case '-':
- case 'e':
- case 'E':
- number_c_string[i] = buffer_at_offset(input_buffer)[i];
- break;
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9':
+ case '+':
+ case '-':
+ case 'e':
+ case 'E':
+ number_c_string[i] = buffer_at_offset(input_buffer)[i];
+ break;
- case '.':
- number_c_string[i] = decimal_point;
- break;
+ case '.':
+ number_c_string[i] = decimal_point;
+ break;
- default:
- goto loop_end;
+ default:
+ goto loop_end;
}
}
- loop_end:
+
+loop_end:
number_c_string[i] = '\0';
- number = strtod((const char*)number_c_string, (char**)&after_end);
+ number = strtod((const char *)number_c_string, (char **)&after_end);
+
if (number_c_string == after_end)
{
return false; /* parse_error */
@@ -382,47 +401,54 @@ static cJSON_bool parse_number(cJSON * const item, parse_buffer * const input_bu
/* don't ask me, but the original cJSON_SetNumberValue returns an integer or double */
CJSON_PUBLIC(double) cJSON_SetNumberHelper(cJSON *object, double number)
{
-if (number >= INT_MAX)
-{
-object->valueint = INT_MAX;
-}
-else if (number <= (double)INT_MIN)
-{
-object->valueint = INT_MIN;
-}
-else
-{
-object->valueint = (int)number;
+ if (number >= INT_MAX)
+ {
+ object->valueint = INT_MAX;
+ }
+ else if (number <= (double)INT_MIN)
+ {
+ object->valueint = INT_MIN;
+ }
+ else
+ {
+ object->valueint = (int)number;
+ }
+
+ return object->valuedouble = number;
}
-return object->valuedouble = number;
-}
+CJSON_PUBLIC(char *) cJSON_SetValuestring(cJSON *object,
+ const char *valuestring)
+{
+ char *copy = NULL;
-CJSON_PUBLIC(char*) cJSON_SetValuestring(cJSON *object, const char *valuestring)
-{
-char *copy = NULL;
-/* if object's type is not cJSON_String or is cJSON_IsReference, it should not set valuestring */
-if (!(object->type & cJSON_String) || (object->type & cJSON_IsReference))
-{
-return NULL;
-}
-if (strlen(valuestring) <= strlen(object->valuestring))
-{
-strcpy(object->valuestring, valuestring);
-return object->valuestring;
-}
-copy = (char*) cJSON_strdup((const unsigned char*)valuestring, &global_hooks);
-if (copy == NULL)
-{
-return NULL;
-}
-if (object->valuestring != NULL)
-{
-cJSON_free(object->valuestring);
-}
-object->valuestring = copy;
+ /* if object's type is not cJSON_String or is cJSON_IsReference, it should not set valuestring */
+ if (!(object->type & cJSON_String) || (object->type & cJSON_IsReference))
+ {
+ return NULL;
+ }
-return copy;
+ if (strlen(valuestring) <= strlen(object->valuestring))
+ {
+ strcpy(object->valuestring, valuestring);
+ return object->valuestring;
+ }
+
+ copy = (char *) cJSON_strdup((const unsigned char *)valuestring, &global_hooks);
+
+ if (copy == NULL)
+ {
+ return NULL;
+ }
+
+ if (object->valuestring != NULL)
+ {
+ cJSON_free(object->valuestring);
+ }
+
+ object->valuestring = copy;
+
+ return copy;
}
typedef struct
@@ -437,7 +463,7 @@ typedef struct
} printbuffer;
/* realloc printbuffer if necessary to have at least "needed" bytes more */
-static unsigned char* ensure(printbuffer * const p, size_t needed)
+static unsigned char *ensure(printbuffer *const p, size_t needed)
{
unsigned char *newbuffer = NULL;
size_t newsize = 0;
@@ -460,12 +486,14 @@ static unsigned char* ensure(printbuffer * const p, size_t needed)
}
needed += p->offset + 1;
+
if (needed <= p->length)
{
return p->buffer + p->offset;
}
- if (p->noalloc) {
+ if (p->noalloc)
+ {
return NULL;
}
@@ -490,7 +518,8 @@ static unsigned char* ensure(printbuffer * const p, size_t needed)
if (p->hooks.reallocate != NULL)
{
/* reallocate with realloc if available */
- newbuffer = (unsigned char*)p->hooks.reallocate(p->buffer, newsize);
+ newbuffer = (unsigned char *)p->hooks.reallocate(p->buffer, newsize);
+
if (newbuffer == NULL)
{
p->hooks.deallocate(p->buffer);
@@ -503,7 +532,8 @@ static unsigned char* ensure(printbuffer * const p, size_t needed)
else
{
/* otherwise reallocate manually */
- newbuffer = (unsigned char*)p->hooks.allocate(newsize);
+ newbuffer = (unsigned char *)p->hooks.allocate(newsize);
+
if (!newbuffer)
{
p->hooks.deallocate(p->buffer);
@@ -516,6 +546,7 @@ static unsigned char* ensure(printbuffer * const p, size_t needed)
memcpy(newbuffer, p->buffer, p->offset + 1);
p->hooks.deallocate(p->buffer);
}
+
p->length = newsize;
p->buffer = newbuffer;
@@ -523,16 +554,18 @@ static unsigned char* ensure(printbuffer * const p, size_t needed)
}
/* calculate the new length of the string in a printbuffer and update the offset */
-static void update_offset(printbuffer * const buffer)
+static void update_offset(printbuffer *const buffer)
{
const unsigned char *buffer_pointer = NULL;
+
if ((buffer == NULL) || (buffer->buffer == NULL))
{
return;
}
+
buffer_pointer = buffer->buffer + buffer->offset;
- buffer->offset += strlen((const char*)buffer_pointer);
+ buffer->offset += strlen((const char *)buffer_pointer);
}
/* securely comparison of floating-point variables */
@@ -543,7 +576,8 @@ static cJSON_bool compare_double(double a, double b)
}
/* Render the number nicely from the given item into a string. */
-static cJSON_bool print_number(const cJSON * const item, printbuffer * const output_buffer)
+static cJSON_bool print_number(const cJSON *const item,
+ printbuffer *const output_buffer)
{
unsigned char *output_pointer = NULL;
double d = item->valuedouble;
@@ -561,21 +595,22 @@ static cJSON_bool print_number(const cJSON * const item, printbuffer * const out
/* This checks for NaN and Infinity */
if (isnan(d) || isinf(d))
{
- SNPRINTF((char*)number_buffer, sizeof(number_buffer), "null");
- length = strlen((char*)number_buffer);
+ SNPRINTF((char *)number_buffer, sizeof(number_buffer), "null");
+ length = strlen((char *)number_buffer);
}
else
{
/* Try 15 decimal places of precision to avoid nonsignificant nonzero digits */
- SNPRINTF((char*)number_buffer, sizeof(number_buffer), "%1.15g", d);
- length = strlen((char*)number_buffer);
+ SNPRINTF((char *)number_buffer, sizeof(number_buffer), "%1.15g", d);
+ length = strlen((char *)number_buffer);
/* Check whether the original double can be recovered */
- if ((sscanf((char*)number_buffer, "%lg", &test) != 1) || !compare_double((double)test, d))
+ if ((sscanf((char *)number_buffer, "%lg", &test) != 1)
+ || !compare_double((double)test, d))
{
/* If not, print with 17 decimal places of precision */
- SNPRINTF((char*)number_buffer, sizeof(number_buffer), "%1.17g", d);
- length = strlen((char*)number_buffer);
+ SNPRINTF((char *)number_buffer, sizeof(number_buffer), "%1.17g", d);
+ length = strlen((char *)number_buffer);
}
}
@@ -587,6 +622,7 @@ static cJSON_bool print_number(const cJSON * const item, printbuffer * const out
/* reserve appropriate space in the output */
output_pointer = ensure(output_buffer, (size_t)length + sizeof(""));
+
if (output_pointer == NULL)
{
return false;
@@ -604,6 +640,7 @@ static cJSON_bool print_number(const cJSON * const item, printbuffer * const out
output_pointer[i] = number_buffer[i];
}
+
output_pointer[i] = '\0';
output_buffer->offset += (size_t)length;
@@ -612,7 +649,7 @@ static cJSON_bool print_number(const cJSON * const item, printbuffer * const out
}
/* parse 4 digit hexadecimal number */
-static unsigned parse_hex4(const unsigned char * const input)
+static unsigned parse_hex4(const unsigned char *const input)
{
unsigned int h = 0;
size_t i = 0;
@@ -649,7 +686,9 @@ static unsigned parse_hex4(const unsigned char * const input)
/* converts a UTF-16 literal to UTF-8
* A literal can be one or two sequences of the form \uXXXX */
-static unsigned char utf16_literal_to_utf8(const unsigned char * const input_pointer, const unsigned char * const input_end, unsigned char **output_pointer)
+static unsigned char utf16_literal_to_utf8(const unsigned char *const
+ input_pointer, const unsigned char *const input_end,
+ unsigned char **output_pointer)
{
long unsigned int codepoint = 0;
unsigned int first_code = 0;
@@ -695,6 +734,7 @@ static unsigned char utf16_literal_to_utf8(const unsigned char * const input_poi
/* get the second utf16 sequence */
second_code = parse_hex4(second_sequence + 2);
+
/* check that the code is valid */
if ((second_code < 0xDC00) || (second_code > 0xDFFF))
{
@@ -745,12 +785,14 @@ static unsigned char utf16_literal_to_utf8(const unsigned char * const input_poi
}
/* encode as utf8 */
- for (utf8_position = (unsigned char)(utf8_length - 1); utf8_position > 0; utf8_position--)
+ for (utf8_position = (unsigned char)(utf8_length - 1); utf8_position > 0;
+ utf8_position--)
{
/* 10xxxxxx */
(*output_pointer)[utf8_position] = (unsigned char)((codepoint | 0x80) & 0xBF);
codepoint >>= 6;
}
+
/* encode first byte */
if (utf8_length > 1)
{
@@ -765,12 +807,13 @@ static unsigned char utf16_literal_to_utf8(const unsigned char * const input_poi
return sequence_length;
- fail:
+fail:
return 0;
}
/* Parse the input text into an unescaped cinput, and populate item. */
-static cJSON_bool parse_string(cJSON * const item, parse_buffer * const input_buffer, int input_buffer_len)
+static cJSON_bool parse_string(cJSON *const item,
+ parse_buffer *const input_buffer, int input_buffer_len)
{
const unsigned char *input_pointer = buffer_at_offset(input_buffer) + 1;
const unsigned char *input_end = buffer_at_offset(input_buffer) + 1;
@@ -787,7 +830,9 @@ static cJSON_bool parse_string(cJSON * const item, parse_buffer * const input_bu
/* calculate approximate size of the output (overestimate) */
size_t allocation_length = 0;
size_t skipped_bytes = 0;
- while (((size_t)(input_end - input_buffer->content) < input_buffer->length) && (*input_end != '\"'))
+
+ while (((size_t)(input_end - input_buffer->content) < input_buffer->length)
+ && (*input_end != '\"'))
{
/* is escape sequence */
if (input_end[0] == '\\')
@@ -797,19 +842,26 @@ static cJSON_bool parse_string(cJSON * const item, parse_buffer * const input_bu
/* prevent buffer overflow when last input character is a backslash */
goto fail;
}
+
skipped_bytes++;
input_end++;
}
+
input_end++;
}
- if (((size_t)(input_end - input_buffer->content) >= input_buffer->length) || (*input_end != '\"'))
+
+ if (((size_t)(input_end - input_buffer->content) >= input_buffer->length)
+ || (*input_end != '\"'))
{
goto fail; /* string ended unexpectedly */
}
/* This is at most how much we need for the output */
- allocation_length = (size_t) (input_end - buffer_at_offset(input_buffer)) - skipped_bytes;
- output = (unsigned char*)input_buffer->hooks.allocate(allocation_length + sizeof(""));
+ allocation_length = (size_t)(input_end - buffer_at_offset(
+ input_buffer)) - skipped_bytes;
+ output = (unsigned char *)input_buffer->hooks.allocate(allocation_length +
+ sizeof(""));
+
if (output == NULL)
{
goto fail; /* allocation failure */
@@ -817,6 +869,7 @@ static cJSON_bool parse_string(cJSON * const item, parse_buffer * const input_bu
}
output_pointer = output;
+
/* loop through the string literal */
while (input_pointer < input_end)
{
@@ -824,10 +877,11 @@ static cJSON_bool parse_string(cJSON * const item, parse_buffer * const input_bu
{
*output_pointer++ = *input_pointer++;
}
- /* escape sequence */
+ /* escape sequence */
else
{
unsigned char sequence_length = 2;
+
if ((input_end - input_pointer) < 1)
{
goto fail;
@@ -835,40 +889,49 @@ static cJSON_bool parse_string(cJSON * const item, parse_buffer * const input_bu
switch (input_pointer[1])
{
- case 'b':
- *output_pointer++ = '\b';
- break;
- case 'f':
- *output_pointer++ = '\f';
- break;
- case 'n':
- *output_pointer++ = '\n';
- break;
- case 'r':
- *output_pointer++ = '\r';
- break;
- case 't':
- *output_pointer++ = '\t';
- break;
- case '\"':
- case '\\':
- case '/':
- *output_pointer++ = input_pointer[1];
- break;
+ case 'b':
+ *output_pointer++ = '\b';
+ break;
- /* UTF-16 literal */
- case 'u':
- sequence_length = utf16_literal_to_utf8(input_pointer, input_end, &output_pointer);
- if (sequence_length == 0)
- {
- /* failed to convert UTF16-literal to UTF-8 */
- goto fail;
- }
- break;
+ case 'f':
+ *output_pointer++ = '\f';
+ break;
- default:
+ case 'n':
+ *output_pointer++ = '\n';
+ break;
+
+ case 'r':
+ *output_pointer++ = '\r';
+ break;
+
+ case 't':
+ *output_pointer++ = '\t';
+ break;
+
+ case '\"':
+ case '\\':
+ case '/':
+ *output_pointer++ = input_pointer[1];
+ break;
+
+ /* UTF-16 literal */
+ case 'u':
+ sequence_length = utf16_literal_to_utf8(input_pointer, input_end,
+ &output_pointer);
+
+ if (sequence_length == 0)
+ {
+ /* failed to convert UTF16-literal to UTF-8 */
goto fail;
+ }
+
+ break;
+
+ default:
+ goto fail;
}
+
input_pointer += sequence_length;
}
}
@@ -877,14 +940,15 @@ static cJSON_bool parse_string(cJSON * const item, parse_buffer * const input_bu
*output_pointer = '\0';
item->type = cJSON_String;
- item->valuestring = (char*)output;
+ item->valuestring = (char *)output;
- input_buffer->offset = (size_t) (input_end - input_buffer->content);
+ input_buffer->offset = (size_t)(input_end - input_buffer->content);
input_buffer->offset++;
return true;
- fail:
+fail:
+
if (output != NULL)
{
input_buffer->hooks.deallocate(output);
@@ -899,7 +963,8 @@ static cJSON_bool parse_string(cJSON * const item, parse_buffer * const input_bu
}
/* Render the cstring provided to an escaped version that can be printed. */
-static cJSON_bool print_string_ptr(const unsigned char * const input, printbuffer * const output_buffer, int output_buffer_len)
+static cJSON_bool print_string_ptr(const unsigned char *const input,
+ printbuffer *const output_buffer, int output_buffer_len)
{
const unsigned char *input_pointer = NULL;
unsigned char *output = NULL;
@@ -917,11 +982,13 @@ static cJSON_bool print_string_ptr(const unsigned char * const input, printbuffe
if (input == NULL)
{
output = ensure(output_buffer, sizeof("\"\""));
+
if (output == NULL)
{
return false;
}
- strcpy((char*)output, "\"\"");
+
+ strcpy((char *)output, "\"\"");
return true;
}
@@ -931,28 +998,32 @@ static cJSON_bool print_string_ptr(const unsigned char * const input, printbuffe
{
switch (*input_pointer)
{
- case '\"':
- case '\\':
- case '\b':
- case '\f':
- case '\n':
- case '\r':
- case '\t':
- /* one character escape sequence */
- escape_characters++;
- break;
- default:
- if (*input_pointer < 32)
- {
- /* UTF-16 escape sequence uXXXX */
- escape_characters += 5;
- }
- break;
+ case '\"':
+ case '\\':
+ case '\b':
+ case '\f':
+ case '\n':
+ case '\r':
+ case '\t':
+ /* one character escape sequence */
+ escape_characters++;
+ break;
+
+ default:
+ if (*input_pointer < 32)
+ {
+ /* UTF-16 escape sequence uXXXX */
+ escape_characters += 5;
+ }
+
+ break;
}
}
+
output_length = (size_t)(input_pointer - input) + escape_characters;
output = ensure(output_buffer, output_length + sizeof("\"\""));
+
if (output == NULL)
{
return false;
@@ -971,10 +1042,13 @@ static cJSON_bool print_string_ptr(const unsigned char * const input, printbuffe
output[0] = '\"';
output_pointer = output + 1;
+
/* copy the string */
- for (input_pointer = input; *input_pointer != '\0'; (void)input_pointer++, output_pointer++)
+ for (input_pointer = input; *input_pointer != '\0';
+ (void)input_pointer++, output_pointer++)
{
- if ((*input_pointer > 31) && (*input_pointer != '\"') && (*input_pointer != '\\'))
+ if ((*input_pointer > 31) && (*input_pointer != '\"')
+ && (*input_pointer != '\\'))
{
/* normal character, copy */
*output_pointer = *input_pointer;
@@ -983,37 +1057,46 @@ static cJSON_bool print_string_ptr(const unsigned char * const input, printbuffe
{
/* character needs to be escaped */
*output_pointer++ = '\\';
+
switch (*input_pointer)
{
- case '\\':
- *output_pointer = '\\';
- break;
- case '\"':
- *output_pointer = '\"';
- break;
- case '\b':
- *output_pointer = 'b';
- break;
- case '\f':
- *output_pointer = 'f';
- break;
- case '\n':
- *output_pointer = 'n';
- break;
- case '\r':
- *output_pointer = 'r';
- break;
- case '\t':
- *output_pointer = 't';
- break;
- default:
- /* escape and print as unicode codepoint */
- sprintf((char*)output_pointer, "u%04x", *input_pointer);
- output_pointer += 4;
- break;
+ case '\\':
+ *output_pointer = '\\';
+ break;
+
+ case '\"':
+ *output_pointer = '\"';
+ break;
+
+ case '\b':
+ *output_pointer = 'b';
+ break;
+
+ case '\f':
+ *output_pointer = 'f';
+ break;
+
+ case '\n':
+ *output_pointer = 'n';
+ break;
+
+ case '\r':
+ *output_pointer = 'r';
+ break;
+
+ case '\t':
+ *output_pointer = 't';
+ break;
+
+ default:
+ /* escape and print as unicode codepoint */
+ sprintf((char *)output_pointer, "u%04x", *input_pointer);
+ output_pointer += 4;
+ break;
}
}
}
+
output[output_length + 1] = '\"';
output[output_length + 2] = '\0';
@@ -1021,21 +1104,28 @@ static cJSON_bool print_string_ptr(const unsigned char * const input, printbuffe
}
/* Invoke print_string_ptr (which is useful) on an item. */
-static cJSON_bool print_string(const cJSON * const item, printbuffer * const p, int p_len)
+static cJSON_bool print_string(const cJSON *const item, printbuffer *const p,
+ int p_len)
{
- return print_string_ptr((unsigned char*)item->valuestring, p, p_len);
+ return print_string_ptr((unsigned char *)item->valuestring, p, p_len);
}
/* Predeclare these prototypes. */
-static cJSON_bool parse_value(cJSON * const item, parse_buffer * const input_buffer, int output_buffer_len);
-static cJSON_bool print_value(const cJSON * const item, printbuffer * const output_buffer, int output_buffer_len);
-static cJSON_bool parse_array(cJSON * const item, parse_buffer * const input_buffer, int output_buffer_len);
-static cJSON_bool print_array(const cJSON * const item, printbuffer * const output_buffer, int output_buffer_len);
-static cJSON_bool parse_object(cJSON * const item, parse_buffer * const input_buffer, int output_buffer_len);
-static cJSON_bool print_object(const cJSON * const item, printbuffer * const output_buffer, int output_buffer_len);
+static cJSON_bool parse_value(cJSON *const item,
+ parse_buffer *const input_buffer, int output_buffer_len);
+static cJSON_bool print_value(const cJSON *const item,
+ printbuffer *const output_buffer, int output_buffer_len);
+static cJSON_bool parse_array(cJSON *const item,
+ parse_buffer *const input_buffer, int output_buffer_len);
+static cJSON_bool print_array(const cJSON *const item,
+ printbuffer *const output_buffer, int output_buffer_len);
+static cJSON_bool parse_object(cJSON *const item,
+ parse_buffer *const input_buffer, int output_buffer_len);
+static cJSON_bool print_object(const cJSON *const item,
+ printbuffer *const output_buffer, int output_buffer_len);
/* Utility to jump whitespace and cr/lf */
-static parse_buffer *buffer_skip_whitespace(parse_buffer * const buffer)
+static parse_buffer *buffer_skip_whitespace(parse_buffer *const buffer)
{
if ((buffer == NULL) || (buffer->content == NULL))
{
@@ -1061,14 +1151,15 @@ static parse_buffer *buffer_skip_whitespace(parse_buffer * const buffer)
}
/* skip the UTF-8 BOM (byte order mark) if it is at the beginning of a buffer */
-static parse_buffer *skip_utf8_bom(parse_buffer * const buffer)
+static parse_buffer *skip_utf8_bom(parse_buffer *const buffer)
{
if ((buffer == NULL) || (buffer->content == NULL) || (buffer->offset != 0))
{
return NULL;
}
- if (can_access_at_index(buffer, 4) && (strncmp((const char*)buffer_at_offset(buffer), "\xEF\xBB\xBF", 3) == 0))
+ if (can_access_at_index(buffer, 4)
+ && (strncmp((const char *)buffer_at_offset(buffer), "\xEF\xBB\xBF", 3) == 0))
{
buffer->offset += 3;
}
@@ -1076,7 +1167,8 @@ static parse_buffer *skip_utf8_bom(parse_buffer * const buffer)
return buffer;
}
-CJSON_PUBLIC(cJSON *) cJSON_ParseWithOpts(const char *value, const char **return_parse_end, cJSON_bool require_null_terminated)
+CJSON_PUBLIC(cJSON *) cJSON_ParseWithOpts(const char *value,
+ const char **return_parse_end, cJSON_bool require_null_terminated)
{
size_t buffer_length;
@@ -1088,11 +1180,14 @@ CJSON_PUBLIC(cJSON *) cJSON_ParseWithOpts(const char *value, const char **return
/* Adding null character size due to require_null_terminated. */
buffer_length = strlen(value) + sizeof("");
- return cJSON_ParseWithLengthOpts(value, buffer_length, return_parse_end, require_null_terminated);
+ return cJSON_ParseWithLengthOpts(value, buffer_length, return_parse_end,
+ require_null_terminated);
}
/* Parse an object - create a new root, and populate. */
-CJSON_PUBLIC(cJSON *) cJSON_ParseWithLengthOpts(const char *value, size_t buffer_length, const char **return_parse_end, cJSON_bool require_null_terminated)
+CJSON_PUBLIC(cJSON *) cJSON_ParseWithLengthOpts(const char *value,
+ size_t buffer_length, const char **return_parse_end,
+ cJSON_bool require_null_terminated)
{
parse_buffer buffer = { 0, 0, 0, 0, { 0, 0, 0 } };
cJSON *item = NULL;
@@ -1106,18 +1201,20 @@ CJSON_PUBLIC(cJSON *) cJSON_ParseWithLengthOpts(const char *value, size_t buffer
goto fail;
}
- buffer.content = (const unsigned char*)value;
+ buffer.content = (const unsigned char *)value;
buffer.length = buffer_length;
buffer.offset = 0;
buffer.hooks = global_hooks;
item = cJSON_New_Item(&global_hooks);
+
if (item == NULL) /* memory fail */
{
goto fail;
}
- if (!parse_value(item, buffer_skip_whitespace(skip_utf8_bom(&buffer)), sizeof(buffer)))
+ if (!parse_value(item, buffer_skip_whitespace(skip_utf8_bom(&buffer)),
+ sizeof(buffer)))
{
/* parse failure. ep is set. */
goto fail;
@@ -1127,19 +1224,22 @@ CJSON_PUBLIC(cJSON *) cJSON_ParseWithLengthOpts(const char *value, size_t buffer
if (require_null_terminated)
{
buffer_skip_whitespace(&buffer);
+
if ((buffer.offset >= buffer.length) || buffer_at_offset(&buffer)[0] != '\0')
{
goto fail;
}
}
+
if (return_parse_end)
{
- *return_parse_end = (const char*)buffer_at_offset(&buffer);
+ *return_parse_end = (const char *)buffer_at_offset(&buffer);
}
return item;
- fail:
+fail:
+
if (item != NULL)
{
cJSON_Delete(item);
@@ -1148,7 +1248,7 @@ CJSON_PUBLIC(cJSON *) cJSON_ParseWithLengthOpts(const char *value, size_t buffer
if (value != NULL)
{
error local_error;
- local_error.json = (const unsigned char*)value;
+ local_error.json = (const unsigned char *)value;
local_error.position = 0;
if (buffer.offset < buffer.length)
@@ -1162,7 +1262,7 @@ CJSON_PUBLIC(cJSON *) cJSON_ParseWithLengthOpts(const char *value, size_t buffer
if (return_parse_end != NULL)
{
- *return_parse_end = (const char*)local_error.json + local_error.position;
+ *return_parse_end = (const char *)local_error.json + local_error.position;
}
global_error = local_error;
@@ -1177,14 +1277,16 @@ CJSON_PUBLIC(cJSON *) cJSON_Parse(const char *value)
return cJSON_ParseWithOpts(value, 0, 0);
}
-CJSON_PUBLIC(cJSON *) cJSON_ParseWithLength(const char *value, size_t buffer_length)
+CJSON_PUBLIC(cJSON *) cJSON_ParseWithLength(const char *value,
+ size_t buffer_length)
{
return cJSON_ParseWithLengthOpts(value, buffer_length, 0, 0);
}
#define cjson_min(a, b) (((a) < (b)) ? (a) : (b))
-static unsigned char *print(const cJSON * const item, cJSON_bool format, const internal_hooks * const hooks)
+static unsigned char *print(const cJSON *const item, cJSON_bool format,
+ const internal_hooks *const hooks)
{
static const size_t default_buffer_size = 256;
printbuffer buffer[16];
@@ -1193,10 +1295,11 @@ static unsigned char *print(const cJSON * const item, cJSON_bool format, const i
memset(buffer, 0, sizeof(buffer));
/* create buffer */
- buffer->buffer = (unsigned char*) hooks->allocate(default_buffer_size);
+ buffer->buffer = (unsigned char *) hooks->allocate(default_buffer_size);
buffer->length = default_buffer_size;
buffer->format = format;
buffer->hooks = *hooks;
+
if (buffer->buffer == NULL)
{
goto fail;
@@ -1207,24 +1310,31 @@ static unsigned char *print(const cJSON * const item, cJSON_bool format, const i
{
goto fail;
}
+
update_offset(buffer);
/* check if reallocate is available */
if (hooks->reallocate != NULL)
{
- printed = (unsigned char*) hooks->reallocate(buffer->buffer, buffer->offset + 1);
- if (printed == NULL) {
- goto fail;
- }
- buffer->buffer = NULL;
- }
- else /* otherwise copy the JSON over to a new buffer */
- {
- printed = (unsigned char*) hooks->allocate(buffer->offset + 1);
+ printed = (unsigned char *) hooks->reallocate(buffer->buffer,
+ buffer->offset + 1);
+
if (printed == NULL)
{
goto fail;
}
+
+ buffer->buffer = NULL;
+ }
+ else /* otherwise copy the JSON over to a new buffer */
+ {
+ printed = (unsigned char *) hooks->allocate(buffer->offset + 1);
+
+ if (printed == NULL)
+ {
+ goto fail;
+ }
+
memcpy(printed, buffer->buffer, cjson_min(buffer->length, buffer->offset + 1));
printed[buffer->offset] = '\0'; /* just to be sure */
@@ -1234,7 +1344,8 @@ static unsigned char *print(const cJSON * const item, cJSON_bool format, const i
return printed;
- fail:
+fail:
+
if (buffer->buffer != NULL)
{
hooks->deallocate(buffer->buffer);
@@ -1251,15 +1362,16 @@ static unsigned char *print(const cJSON * const item, cJSON_bool format, const i
/* Render a cJSON item/entity/structure to text. */
CJSON_PUBLIC(char *) cJSON_Print(const cJSON *item)
{
- return (char*)print(item, true, &global_hooks);
+ return (char *)print(item, true, &global_hooks);
}
CJSON_PUBLIC(char *) cJSON_PrintUnformatted(const cJSON *item)
{
- return (char*)print(item, false, &global_hooks);
+ return (char *)print(item, false, &global_hooks);
}
-CJSON_PUBLIC(char *) cJSON_PrintBuffered(const cJSON *item, int prebuffer, cJSON_bool fmt)
+CJSON_PUBLIC(char *) cJSON_PrintBuffered(const cJSON *item, int prebuffer,
+ cJSON_bool fmt)
{
printbuffer p = { 0, 0, 0, 0, 0, 0, { 0, 0, 0 } };
@@ -1268,7 +1380,8 @@ CJSON_PUBLIC(char *) cJSON_PrintBuffered(const cJSON *item, int prebuffer, cJSON
return NULL;
}
- p.buffer = (unsigned char*)global_hooks.allocate((size_t)prebuffer);
+ p.buffer = (unsigned char *)global_hooks.allocate((size_t)prebuffer);
+
if (!p.buffer)
{
return NULL;
@@ -1286,30 +1399,32 @@ CJSON_PUBLIC(char *) cJSON_PrintBuffered(const cJSON *item, int prebuffer, cJSON
return NULL;
}
- return (char*)p.buffer;
+ return (char *)p.buffer;
}
-CJSON_PUBLIC(cJSON_bool) cJSON_PrintPreallocated(cJSON *item, char *buffer, const int length, const cJSON_bool format)
+CJSON_PUBLIC(cJSON_bool) cJSON_PrintPreallocated(cJSON *item, char *buffer,
+ const int length, const cJSON_bool format)
{
-printbuffer p = { 0, 0, 0, 0, 0, 0, { 0, 0, 0 } };
+ printbuffer p = { 0, 0, 0, 0, 0, 0, { 0, 0, 0 } };
-if ((length < 0) || (buffer == NULL))
-{
-return false;
-}
+ if ((length < 0) || (buffer == NULL))
+ {
+ return false;
+ }
-p.buffer = (unsigned char*)buffer;
-p.length = (size_t)length;
-p.offset = 0;
-p.noalloc = true;
-p.format = format;
-p.hooks = global_hooks;
+ p.buffer = (unsigned char *)buffer;
+ p.length = (size_t)length;
+ p.offset = 0;
+ p.noalloc = true;
+ p.format = format;
+ p.hooks = global_hooks;
-return print_value(item, &p, sizeof(p));
+ return print_value(item, &p, sizeof(p));
}
/* Parser core - when encountering text, process appropriately. */
-static cJSON_bool parse_value(cJSON * const item, parse_buffer * const input_buffer, int input_buffer_len)
+static cJSON_bool parse_value(cJSON *const item,
+ parse_buffer *const input_buffer, int input_buffer_len)
{
if ((input_buffer == NULL) || (input_buffer->content == NULL))
{
@@ -1318,44 +1433,59 @@ static cJSON_bool parse_value(cJSON * const item, parse_buffer * const input_buf
/* parse the different types of values */
/* null */
- if (can_read(input_buffer, 4) && (strncmp((const char*)buffer_at_offset(input_buffer), "null", 4) == 0))
+ if (can_read(input_buffer, 4)
+ && (strncmp((const char *)buffer_at_offset(input_buffer), "null", 4) == 0))
{
item->type = cJSON_NULL;
input_buffer->offset += 4;
return true;
}
+
/* false */
- if (can_read(input_buffer, 5) && (strncmp((const char*)buffer_at_offset(input_buffer), "false", 5) == 0))
+ if (can_read(input_buffer, 5)
+ && (strncmp((const char *)buffer_at_offset(input_buffer), "false", 5) == 0))
{
item->type = cJSON_False;
input_buffer->offset += 5;
return true;
}
+
/* true */
- if (can_read(input_buffer, 4) && (strncmp((const char*)buffer_at_offset(input_buffer), "true", 4) == 0))
+ if (can_read(input_buffer, 4)
+ && (strncmp((const char *)buffer_at_offset(input_buffer), "true", 4) == 0))
{
item->type = cJSON_True;
item->valueint = 1;
input_buffer->offset += 4;
return true;
}
+
/* string */
- if (can_access_at_index(input_buffer, 0) && (buffer_at_offset(input_buffer)[0] == '\"'))
+ if (can_access_at_index(input_buffer, 0)
+ && (buffer_at_offset(input_buffer)[0] == '\"'))
{
return parse_string(item, input_buffer, input_buffer_len);
}
+
/* number */
- if (can_access_at_index(input_buffer, 0) && ((buffer_at_offset(input_buffer)[0] == '-') || ((buffer_at_offset(input_buffer)[0] >= '0') && (buffer_at_offset(input_buffer)[0] <= '9'))))
+ if (can_access_at_index(input_buffer, 0)
+ && ((buffer_at_offset(input_buffer)[0] == '-')
+ || ((buffer_at_offset(input_buffer)[0] >= '0')
+ && (buffer_at_offset(input_buffer)[0] <= '9'))))
{
return parse_number(item, input_buffer, input_buffer_len);
}
+
/* array */
- if (can_access_at_index(input_buffer, 0) && (buffer_at_offset(input_buffer)[0] == '['))
+ if (can_access_at_index(input_buffer, 0)
+ && (buffer_at_offset(input_buffer)[0] == '['))
{
return parse_array(item, input_buffer, input_buffer_len);
}
+
/* object */
- if (can_access_at_index(input_buffer, 0) && (buffer_at_offset(input_buffer)[0] == '{'))
+ if (can_access_at_index(input_buffer, 0)
+ && (buffer_at_offset(input_buffer)[0] == '{'))
{
return parse_object(item, input_buffer, input_buffer_len);
}
@@ -1364,7 +1494,8 @@ static cJSON_bool parse_value(cJSON * const item, parse_buffer * const input_buf
}
/* Render a value to text. */
-static cJSON_bool print_value(const cJSON * const item, printbuffer * const output_buffer, int output_buffer_len)
+static cJSON_bool print_value(const cJSON *const item,
+ printbuffer *const output_buffer, int output_buffer_len)
{
unsigned char *output = NULL;
@@ -1375,70 +1506,80 @@ static cJSON_bool print_value(const cJSON * const item, printbuffer * const outp
switch ((item->type) & 0xFF)
{
- case cJSON_NULL:
- output = ensure(output_buffer, 5);
- if (output == NULL)
- {
- return false;
- }
- strcpy((char*)output, "null");
- return true;
+ case cJSON_NULL:
+ output = ensure(output_buffer, 5);
- case cJSON_False:
- output = ensure(output_buffer, 6);
- if (output == NULL)
- {
- return false;
- }
- strcpy((char*)output, "false");
- return true;
-
- case cJSON_True:
- output = ensure(output_buffer, 5);
- if (output == NULL)
- {
- return false;
- }
- strcpy((char*)output, "true");
- return true;
-
- case cJSON_Number:
- return print_number(item, output_buffer);
-
- case cJSON_Raw:
+ if (output == NULL)
{
- size_t raw_length = 0;
- if (item->valuestring == NULL)
- {
- return false;
- }
-
- raw_length = strlen(item->valuestring) + sizeof("");
- output = ensure(output_buffer, raw_length);
- if (output == NULL)
- {
- return false;
- }
- memcpy(output, item->valuestring, raw_length);
- return true;
+ return false;
}
- case cJSON_String:
- return print_string(item, output_buffer, output_buffer_len);
+ strcpy((char *)output, "null");
+ return true;
- case cJSON_Array:
- return print_array(item, output_buffer, output_buffer_len);
+ case cJSON_False:
+ output = ensure(output_buffer, 6);
- case cJSON_Object:
- return print_object(item, output_buffer, output_buffer_len);
-
- default:
+ if (output == NULL)
+ {
return false;
+ }
+
+ strcpy((char *)output, "false");
+ return true;
+
+ case cJSON_True:
+ output = ensure(output_buffer, 5);
+
+ if (output == NULL)
+ {
+ return false;
+ }
+
+ strcpy((char *)output, "true");
+ return true;
+
+ case cJSON_Number:
+ return print_number(item, output_buffer);
+
+ case cJSON_Raw:
+ {
+ size_t raw_length = 0;
+
+ if (item->valuestring == NULL)
+ {
+ return false;
+ }
+
+ raw_length = strlen(item->valuestring) + sizeof("");
+ output = ensure(output_buffer, raw_length);
+
+ if (output == NULL)
+ {
+ return false;
+ }
+
+ memcpy(output, item->valuestring, raw_length);
+ return true;
+ }
+
+ case cJSON_String:
+ return print_string(item, output_buffer, output_buffer_len);
+
+ case cJSON_Array:
+ return print_array(item, output_buffer, output_buffer_len);
+
+ case cJSON_Object:
+ return print_object(item, output_buffer, output_buffer_len);
+
+ default:
+ return false;
}
}
/* Build an array from input text. */
-static cJSON_bool parse_array(cJSON * const item, parse_buffer * const input_buffer, int input_buffer_len)
+static cJSON_bool parse_array(cJSON *const item,
+ parse_buffer *const input_buffer, int input_buffer_len)
{
cJSON *head = NULL; /* head of the linked list */
cJSON *current_item = NULL;
@@ -1447,6 +1588,7 @@ static cJSON_bool parse_array(cJSON * const item, parse_buffer * const input_buf
{
return false; /* to deeply nested */
}
+
input_buffer->depth++;
if (buffer_at_offset(input_buffer)[0] != '[')
@@ -1457,7 +1599,9 @@ static cJSON_bool parse_array(cJSON * const item, parse_buffer * const input_buf
input_buffer->offset++;
buffer_skip_whitespace(input_buffer);
- if (can_access_at_index(input_buffer, 0) && (buffer_at_offset(input_buffer)[0] == ']'))
+
+ if (can_access_at_index(input_buffer, 0)
+ && (buffer_at_offset(input_buffer)[0] == ']'))
{
/* empty array */
goto success;
@@ -1472,11 +1616,13 @@ static cJSON_bool parse_array(cJSON * const item, parse_buffer * const input_buf
/* step back to character in front of the first element */
input_buffer->offset--;
+
/* loop through the comma separated array elements */
do
{
/* allocate next item */
cJSON *new_item = cJSON_New_Item(&(input_buffer->hooks));
+
if (new_item == NULL)
{
goto fail; /* allocation failure */
@@ -1499,23 +1645,28 @@ static cJSON_bool parse_array(cJSON * const item, parse_buffer * const input_buf
/* parse next value */
input_buffer->offset++;
buffer_skip_whitespace(input_buffer);
+
if (!parse_value(current_item, input_buffer, input_buffer_len))
{
goto fail; /* failed to parse value */
}
+
buffer_skip_whitespace(input_buffer);
}
- while (can_access_at_index(input_buffer, 0) && (buffer_at_offset(input_buffer)[0] == ','));
+ while (can_access_at_index(input_buffer, 0)
+ && (buffer_at_offset(input_buffer)[0] == ','));
- if (cannot_access_at_index(input_buffer, 0) || buffer_at_offset(input_buffer)[0] != ']')
+ if (cannot_access_at_index(input_buffer, 0)
+ || buffer_at_offset(input_buffer)[0] != ']')
{
goto fail; /* expected end of array */
}
- success:
+success:
input_buffer->depth--;
- if (head != NULL) {
+ if (head != NULL)
+ {
head->prev = current_item;
}
@@ -1526,7 +1677,8 @@ static cJSON_bool parse_array(cJSON * const item, parse_buffer * const input_buf
return true;
- fail:
+fail:
+
if (head != NULL)
{
cJSON_Delete(head);
@@ -1536,7 +1688,8 @@ static cJSON_bool parse_array(cJSON * const item, parse_buffer * const input_buf
}
/* Render an array to text */
-static cJSON_bool print_array(const cJSON * const item, printbuffer * const output_buffer, int output_buffer_len)
+static cJSON_bool print_array(const cJSON *const item,
+ printbuffer *const output_buffer, int output_buffer_len)
{
unsigned char *output_pointer = NULL;
size_t length = 0;
@@ -1550,6 +1703,7 @@ static cJSON_bool print_array(const cJSON * const item, printbuffer * const outp
/* Compose the output array. */
/* opening square bracket */
output_pointer = ensure(output_buffer, 1);
+
if (output_pointer == NULL)
{
return false;
@@ -1565,31 +1719,40 @@ static cJSON_bool print_array(const cJSON * const item, printbuffer * const outp
{
return false;
}
+
update_offset(output_buffer);
+
if (current_element->next)
{
- length = (size_t) (output_buffer->format ? 2 : 1);
+ length = (size_t)(output_buffer->format ? 2 : 1);
output_pointer = ensure(output_buffer, length + 1);
+
if (output_pointer == NULL)
{
return false;
}
+
*output_pointer++ = ',';
- if(output_buffer->format)
+
+ if (output_buffer->format)
{
*output_pointer++ = ' ';
}
+
*output_pointer = '\0';
output_buffer->offset += length;
}
+
current_element = current_element->next;
}
output_pointer = ensure(output_buffer, 2);
+
if (output_pointer == NULL)
{
return false;
}
+
*output_pointer++ = ']';
*output_pointer = '\0';
output_buffer->depth--;
@@ -1598,7 +1761,8 @@ static cJSON_bool print_array(const cJSON * const item, printbuffer * const outp
}
/* Build an object from the text. */
-static cJSON_bool parse_object(cJSON * const item, parse_buffer * const input_buffer, int input_buffer_len)
+static cJSON_bool parse_object(cJSON *const item,
+ parse_buffer *const input_buffer, int input_buffer_len)
{
cJSON *head = NULL; /* linked list head */
cJSON *current_item = NULL;
@@ -1607,16 +1771,20 @@ static cJSON_bool parse_object(cJSON * const item, parse_buffer * const input_bu
{
return false; /* to deeply nested */
}
+
input_buffer->depth++;
- if (cannot_access_at_index(input_buffer, 0) || (buffer_at_offset(input_buffer)[0] != '{'))
+ if (cannot_access_at_index(input_buffer, 0)
+ || (buffer_at_offset(input_buffer)[0] != '{'))
{
goto fail; /* not an object */
}
input_buffer->offset++;
buffer_skip_whitespace(input_buffer);
- if (can_access_at_index(input_buffer, 0) && (buffer_at_offset(input_buffer)[0] == '}'))
+
+ if (can_access_at_index(input_buffer, 0)
+ && (buffer_at_offset(input_buffer)[0] == '}'))
{
goto success; /* empty object */
}
@@ -1630,11 +1798,13 @@ static cJSON_bool parse_object(cJSON * const item, parse_buffer * const input_bu
/* step back to character in front of the first element */
input_buffer->offset--;
+
/* loop through the comma separated array elements */
do
{
/* allocate next item */
cJSON *new_item = cJSON_New_Item(&(input_buffer->hooks));
+
if (new_item == NULL)
{
goto fail; /* allocation failure */
@@ -1657,17 +1827,20 @@ static cJSON_bool parse_object(cJSON * const item, parse_buffer * const input_bu
/* parse the name of the child */
input_buffer->offset++;
buffer_skip_whitespace(input_buffer);
+
if (!parse_string(current_item, input_buffer, input_buffer_len))
{
goto fail; /* failed to parse name */
}
+
buffer_skip_whitespace(input_buffer);
/* swap valuestring and string, because we parsed the name */
current_item->string = current_item->valuestring;
current_item->valuestring = NULL;
- if (cannot_access_at_index(input_buffer, 0) || (buffer_at_offset(input_buffer)[0] != ':'))
+ if (cannot_access_at_index(input_buffer, 0)
+ || (buffer_at_offset(input_buffer)[0] != ':'))
{
goto fail; /* invalid object */
}
@@ -1675,23 +1848,28 @@ static cJSON_bool parse_object(cJSON * const item, parse_buffer * const input_bu
/* parse the value */
input_buffer->offset++;
buffer_skip_whitespace(input_buffer);
+
if (!parse_value(current_item, input_buffer, input_buffer_len))
{
goto fail; /* failed to parse value */
}
+
buffer_skip_whitespace(input_buffer);
}
- while (can_access_at_index(input_buffer, 0) && (buffer_at_offset(input_buffer)[0] == ','));
+ while (can_access_at_index(input_buffer, 0)
+ && (buffer_at_offset(input_buffer)[0] == ','));
- if (cannot_access_at_index(input_buffer, 0) || (buffer_at_offset(input_buffer)[0] != '}'))
+ if (cannot_access_at_index(input_buffer, 0)
+ || (buffer_at_offset(input_buffer)[0] != '}'))
{
goto fail; /* expected end of object */
}
- success:
+success:
input_buffer->depth--;
- if (head != NULL) {
+ if (head != NULL)
+ {
head->prev = current_item;
}
@@ -1701,7 +1879,8 @@ static cJSON_bool parse_object(cJSON * const item, parse_buffer * const input_bu
input_buffer->offset++;
return true;
- fail:
+fail:
+
if (head != NULL)
{
cJSON_Delete(head);
@@ -1711,7 +1890,8 @@ static cJSON_bool parse_object(cJSON * const item, parse_buffer * const input_bu
}
/* Render an object to text. */
-static cJSON_bool print_object(const cJSON * const item, printbuffer * const output_buffer, int output_buffer_len)
+static cJSON_bool print_object(const cJSON *const item,
+ printbuffer *const output_buffer, int output_buffer_len)
{
unsigned char *output_pointer = NULL;
size_t length = 0;
@@ -1723,8 +1903,9 @@ static cJSON_bool print_object(const cJSON * const item, printbuffer * const out
}
/* Compose the output: */
- length = (size_t) (output_buffer->format ? 2 : 1); /* fmt: {\n */
+ length = (size_t)(output_buffer->format ? 2 : 1); /* fmt: {\n */
output_pointer = ensure(output_buffer, length + 1);
+
if (output_pointer == NULL)
{
return false;
@@ -1732,10 +1913,12 @@ static cJSON_bool print_object(const cJSON * const item, printbuffer * const out
*output_pointer++ = '{';
output_buffer->depth++;
+
if (output_buffer->format)
{
*output_pointer++ = '\n';
}
+
output_buffer->offset += length;
while (current_item)
@@ -1744,35 +1927,44 @@ static cJSON_bool print_object(const cJSON * const item, printbuffer * const out
{
size_t i;
output_pointer = ensure(output_buffer, output_buffer->depth);
+
if (output_pointer == NULL)
{
return false;
}
+
for (i = 0; i < output_buffer->depth; i++)
{
*output_pointer++ = '\t';
}
+
output_buffer->offset += output_buffer->depth;
}
/* print key */
- if (!print_string_ptr((unsigned char*)current_item->string, output_buffer, output_buffer_len))
+ if (!print_string_ptr((unsigned char *)current_item->string, output_buffer,
+ output_buffer_len))
{
return false;
}
+
update_offset(output_buffer);
- length = (size_t) (output_buffer->format ? 2 : 1);
+ length = (size_t)(output_buffer->format ? 2 : 1);
output_pointer = ensure(output_buffer, length);
+
if (output_pointer == NULL)
{
return false;
}
+
*output_pointer++ = ':';
+
if (output_buffer->format)
{
*output_pointer++ = '\t';
}
+
output_buffer->offset += length;
/* print value */
@@ -1780,15 +1972,19 @@ static cJSON_bool print_object(const cJSON * const item, printbuffer * const out
{
return false;
}
+
update_offset(output_buffer);
/* print comma if not last */
- length = ((size_t)(output_buffer->format ? 1 : 0) + (size_t)(current_item->next ? 1 : 0));
+ length = ((size_t)(output_buffer->format ? 1 : 0) + (size_t)(
+ current_item->next ? 1 : 0));
output_pointer = ensure(output_buffer, length + 1);
+
if (output_pointer == NULL)
{
return false;
}
+
if (current_item->next)
{
*output_pointer++ = ',';
@@ -1798,25 +1994,31 @@ static cJSON_bool print_object(const cJSON * const item, printbuffer * const out
{
*output_pointer++ = '\n';
}
+
*output_pointer = '\0';
output_buffer->offset += length;
current_item = current_item->next;
}
- output_pointer = ensure(output_buffer, output_buffer->format ? (output_buffer->depth + 1) : 2);
+ output_pointer = ensure(output_buffer,
+ output_buffer->format ? (output_buffer->depth + 1) : 2);
+
if (output_pointer == NULL)
{
return false;
}
+
if (output_buffer->format)
{
size_t i;
+
for (i = 0; i < (output_buffer->depth - 1); i++)
{
*output_pointer++ = '\t';
}
}
+
*output_pointer++ = '}';
*output_pointer = '\0';
output_buffer->depth--;
@@ -1837,7 +2039,7 @@ CJSON_PUBLIC(int) cJSON_GetArraySize(const cJSON *array)
child = array->child;
- while(child != NULL)
+ while (child != NULL)
{
size++;
child = child->next;
@@ -1848,7 +2050,7 @@ CJSON_PUBLIC(int) cJSON_GetArraySize(const cJSON *array)
return (int)size;
}
-static cJSON* get_array_item(const cJSON *array, size_t index)
+static cJSON *get_array_item(const cJSON *array, size_t index)
{
cJSON *current_child = NULL;
@@ -1858,6 +2060,7 @@ static cJSON* get_array_item(const cJSON *array, size_t index)
}
current_child = array->child;
+
while ((current_child != NULL) && (index > 0))
{
index--;
@@ -1877,7 +2080,8 @@ CJSON_PUBLIC(cJSON *) cJSON_GetArrayItem(const cJSON *array, int index)
return get_array_item(array, (size_t)index);
}
-static cJSON *get_object_item(const cJSON * const object, const char * const name, const cJSON_bool case_sensitive)
+static cJSON *get_object_item(const cJSON *const object, const char *const name,
+ const cJSON_bool case_sensitive)
{
cJSON *current_element = NULL;
@@ -1887,39 +2091,47 @@ static cJSON *get_object_item(const cJSON * const object, const char * const nam
}
current_element = object->child;
+
if (case_sensitive)
{
- while ((current_element != NULL) && (current_element->string != NULL) && (strcmp(name, current_element->string) != 0))
+ while ((current_element != NULL) && (current_element->string != NULL)
+ && (strcmp(name, current_element->string) != 0))
{
current_element = current_element->next;
}
}
else
{
- while ((current_element != NULL) && (case_insensitive_strcmp((const unsigned char*)name, (const unsigned char*)(current_element->string)) != 0))
+ while ((current_element != NULL)
+ && (case_insensitive_strcmp((const unsigned char *)name,
+ (const unsigned char *)(current_element->string)) != 0))
{
current_element = current_element->next;
}
}
- if ((current_element == NULL) || (current_element->string == NULL)) {
+ if ((current_element == NULL) || (current_element->string == NULL))
+ {
return NULL;
}
return current_element;
}
-CJSON_PUBLIC(cJSON *) cJSON_GetObjectItem(const cJSON * const object, const char * const string)
+CJSON_PUBLIC(cJSON *) cJSON_GetObjectItem(const cJSON *const object,
+ const char *const string)
{
return get_object_item(object, string, false);
}
-CJSON_PUBLIC(cJSON *) cJSON_GetObjectItemCaseSensitive(const cJSON * const object, const char * const string)
+CJSON_PUBLIC(cJSON *) cJSON_GetObjectItemCaseSensitive(const cJSON *const
+ object, const char *const string)
{
return get_object_item(object, string, true);
}
-CJSON_PUBLIC(cJSON_bool) cJSON_HasObjectItem(const cJSON *object, const char *string)
+CJSON_PUBLIC(cJSON_bool) cJSON_HasObjectItem(const cJSON *object,
+ const char *string)
{
return cJSON_GetObjectItem(object, string) ? 1 : 0;
}
@@ -1932,15 +2144,18 @@ static void suffix_object(cJSON *prev, cJSON *item)
}
/* Utility for handling references. */
-static cJSON *create_reference(const cJSON *item, const internal_hooks * const hooks)
+static cJSON *create_reference(const cJSON *item,
+ const internal_hooks *const hooks)
{
cJSON *reference = NULL;
+
if (item == NULL)
{
return NULL;
}
reference = cJSON_New_Item(hooks);
+
if (reference == NULL)
{
return NULL;
@@ -1963,6 +2178,7 @@ static cJSON_bool add_item_to_array(cJSON *array, cJSON *item)
}
child = array->child;
+
/*
* To find the last item in array quickly, we use prev in array
*/
@@ -1989,7 +2205,7 @@ static cJSON_bool add_item_to_array(cJSON *array, cJSON *item)
/* Add item to array/object. */
CJSON_PUBLIC(cJSON_bool) cJSON_AddItemToArray(cJSON *array, cJSON *item)
{
-return add_item_to_array(array, item);
+ return add_item_to_array(array, item);
}
#if defined(__clang__) || (defined(__GNUC__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ > 5))))
@@ -1999,16 +2215,18 @@ return add_item_to_array(array, item);
#pragma GCC diagnostic ignored "-Wcast-qual"
#endif
/* helper function to cast away const */
-static void* cast_away_const(const void* string)
+static void *cast_away_const(const void *string)
{
- return (void*)string;
+ return (void *)string;
}
#if defined(__clang__) || (defined(__GNUC__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ > 5))))
#pragma GCC diagnostic pop
#endif
-static cJSON_bool add_item_to_object(cJSON * const object, const char * const string, cJSON * const item, const internal_hooks * const hooks, const cJSON_bool constant_key)
+static cJSON_bool add_item_to_object(cJSON *const object,
+ const char *const string, cJSON *const item, const internal_hooks *const hooks,
+ const cJSON_bool constant_key)
{
char *new_key = NULL;
int new_type = cJSON_Invalid;
@@ -2020,12 +2238,13 @@ static cJSON_bool add_item_to_object(cJSON * const object, const char * const st
if (constant_key)
{
- new_key = (char*)cast_away_const(string);
+ new_key = (char *)cast_away_const(string);
new_type = item->type | cJSON_StringIsConst;
}
else
{
- new_key = (char*)cJSON_strdup((const unsigned char*)string, hooks);
+ new_key = (char *)cJSON_strdup((const unsigned char *)string, hooks);
+
if (new_key == NULL)
{
return false;
@@ -2045,310 +2264,350 @@ static cJSON_bool add_item_to_object(cJSON * const object, const char * const st
return add_item_to_array(object, item);
}
-CJSON_PUBLIC(cJSON_bool) cJSON_AddItemToObject(cJSON *object, const char *string, cJSON *item)
+CJSON_PUBLIC(cJSON_bool) cJSON_AddItemToObject(cJSON *object,
+ const char *string, cJSON *item)
{
-return add_item_to_object(object, string, item, &global_hooks, false);
+ return add_item_to_object(object, string, item, &global_hooks, false);
}
/* Add an item to an object with constant string as key */
-CJSON_PUBLIC(cJSON_bool) cJSON_AddItemToObjectCS(cJSON *object, const char *string, cJSON *item)
+CJSON_PUBLIC(cJSON_bool) cJSON_AddItemToObjectCS(cJSON *object,
+ const char *string, cJSON *item)
{
-return add_item_to_object(object, string, item, &global_hooks, true);
+ return add_item_to_object(object, string, item, &global_hooks, true);
}
-CJSON_PUBLIC(cJSON_bool) cJSON_AddItemReferenceToArray(cJSON *array, cJSON *item)
+CJSON_PUBLIC(cJSON_bool) cJSON_AddItemReferenceToArray(cJSON *array,
+ cJSON *item)
{
-if (array == NULL)
-{
-return false;
+ if (array == NULL)
+ {
+ return false;
+ }
+
+ return add_item_to_array(array, create_reference(item, &global_hooks));
}
-return add_item_to_array(array, create_reference(item, &global_hooks));
+CJSON_PUBLIC(cJSON_bool) cJSON_AddItemReferenceToObject(cJSON *object,
+ const char *string, cJSON *item)
+{
+ if ((object == NULL) || (string == NULL))
+ {
+ return false;
+ }
+
+ return add_item_to_object(object, string, create_reference(item, &global_hooks),
+ &global_hooks, false);
}
-CJSON_PUBLIC(cJSON_bool) cJSON_AddItemReferenceToObject(cJSON *object, const char *string, cJSON *item)
+CJSON_PUBLIC(cJSON *) cJSON_AddNullToObject(cJSON *const object,
+ const char *const name)
{
-if ((object == NULL) || (string == NULL))
-{
-return false;
+ cJSON *null = cJSON_CreateNull();
+
+ if (add_item_to_object(object, name, null, &global_hooks, false))
+ {
+ return null;
+ }
+
+ cJSON_Delete(null);
+ return NULL;
}
-return add_item_to_object(object, string, create_reference(item, &global_hooks), &global_hooks, false);
+CJSON_PUBLIC(cJSON *) cJSON_AddTrueToObject(cJSON *const object,
+ const char *const name)
+{
+ cJSON *true_item = cJSON_CreateTrue();
+
+ if (add_item_to_object(object, name, true_item, &global_hooks, false))
+ {
+ return true_item;
+ }
+
+ cJSON_Delete(true_item);
+ return NULL;
}
-CJSON_PUBLIC(cJSON*) cJSON_AddNullToObject(cJSON * const object, const char * const name)
+CJSON_PUBLIC(cJSON *) cJSON_AddFalseToObject(cJSON *const object,
+ const char *const name)
{
-cJSON *null = cJSON_CreateNull();
-if (add_item_to_object(object, name, null, &global_hooks, false))
-{
-return null;
+ cJSON *false_item = cJSON_CreateFalse();
+
+ if (add_item_to_object(object, name, false_item, &global_hooks, false))
+ {
+ return false_item;
+ }
+
+ cJSON_Delete(false_item);
+ return NULL;
}
-cJSON_Delete(null);
-return NULL;
+CJSON_PUBLIC(cJSON *) cJSON_AddBoolToObject(cJSON *const object,
+ const char *const name, const cJSON_bool boolean)
+{
+ cJSON *bool_item = cJSON_CreateBool(boolean);
+
+ if (add_item_to_object(object, name, bool_item, &global_hooks, false))
+ {
+ return bool_item;
+ }
+
+ cJSON_Delete(bool_item);
+ return NULL;
}
-CJSON_PUBLIC(cJSON*) cJSON_AddTrueToObject(cJSON * const object, const char * const name)
+CJSON_PUBLIC(cJSON *) cJSON_AddNumberToObject(cJSON *const object,
+ const char *const name, const double number)
{
-cJSON *true_item = cJSON_CreateTrue();
-if (add_item_to_object(object, name, true_item, &global_hooks, false))
-{
-return true_item;
+ cJSON *number_item = cJSON_CreateNumber(number);
+
+ if (add_item_to_object(object, name, number_item, &global_hooks, false))
+ {
+ return number_item;
+ }
+
+ cJSON_Delete(number_item);
+ return NULL;
}
-cJSON_Delete(true_item);
-return NULL;
+CJSON_PUBLIC(cJSON *) cJSON_AddStringToObject(cJSON *const object,
+ const char *const name, const char *const string)
+{
+ cJSON *string_item = cJSON_CreateString(string);
+
+ if (add_item_to_object(object, name, string_item, &global_hooks, false))
+ {
+ return string_item;
+ }
+
+ cJSON_Delete(string_item);
+ return NULL;
}
-CJSON_PUBLIC(cJSON*) cJSON_AddFalseToObject(cJSON * const object, const char * const name)
+CJSON_PUBLIC(cJSON *) cJSON_AddRawToObject(cJSON *const object,
+ const char *const name, const char *const raw)
{
-cJSON *false_item = cJSON_CreateFalse();
-if (add_item_to_object(object, name, false_item, &global_hooks, false))
-{
-return false_item;
+ cJSON *raw_item = cJSON_CreateRaw(raw);
+
+ if (add_item_to_object(object, name, raw_item, &global_hooks, false))
+ {
+ return raw_item;
+ }
+
+ cJSON_Delete(raw_item);
+ return NULL;
}
-cJSON_Delete(false_item);
-return NULL;
+CJSON_PUBLIC(cJSON *) cJSON_AddObjectToObject(cJSON *const object,
+ const char *const name)
+{
+ cJSON *object_item = cJSON_CreateObject();
+
+ if (add_item_to_object(object, name, object_item, &global_hooks, false))
+ {
+ return object_item;
+ }
+
+ cJSON_Delete(object_item);
+ return NULL;
}
-CJSON_PUBLIC(cJSON*) cJSON_AddBoolToObject(cJSON * const object, const char * const name, const cJSON_bool boolean)
+CJSON_PUBLIC(cJSON *) cJSON_AddArrayToObject(cJSON *const object,
+ const char *const name)
{
-cJSON *bool_item = cJSON_CreateBool(boolean);
-if (add_item_to_object(object, name, bool_item, &global_hooks, false))
-{
-return bool_item;
+ cJSON *array = cJSON_CreateArray();
+
+ if (add_item_to_object(object, name, array, &global_hooks, false))
+ {
+ return array;
+ }
+
+ cJSON_Delete(array);
+ return NULL;
}
-cJSON_Delete(bool_item);
-return NULL;
-}
+CJSON_PUBLIC(cJSON *) cJSON_DetachItemViaPointer(cJSON *parent,
+ cJSON *const item)
+{
+ if ((parent == NULL) || (item == NULL))
+ {
+ return NULL;
+ }
-CJSON_PUBLIC(cJSON*) cJSON_AddNumberToObject(cJSON * const object, const char * const name, const double number)
-{
-cJSON *number_item = cJSON_CreateNumber(number);
-if (add_item_to_object(object, name, number_item, &global_hooks, false))
-{
-return number_item;
-}
+ if (item != parent->child)
+ {
+ /* not the first element */
+ item->prev->next = item->next;
+ }
-cJSON_Delete(number_item);
-return NULL;
-}
+ if (item->next != NULL)
+ {
+ /* not the last element */
+ item->next->prev = item->prev;
+ }
-CJSON_PUBLIC(cJSON*) cJSON_AddStringToObject(cJSON * const object, const char * const name, const char * const string)
-{
-cJSON *string_item = cJSON_CreateString(string);
-if (add_item_to_object(object, name, string_item, &global_hooks, false))
-{
-return string_item;
-}
+ if (item == parent->child)
+ {
+ /* first element */
+ parent->child = item->next;
+ }
+ else if (item->next == NULL)
+ {
+ /* last element */
+ parent->child->prev = item->prev;
+ }
-cJSON_Delete(string_item);
-return NULL;
-}
+ /* make sure the detached item doesn't point anywhere anymore */
+ item->prev = NULL;
+ item->next = NULL;
-CJSON_PUBLIC(cJSON*) cJSON_AddRawToObject(cJSON * const object, const char * const name, const char * const raw)
-{
-cJSON *raw_item = cJSON_CreateRaw(raw);
-if (add_item_to_object(object, name, raw_item, &global_hooks, false))
-{
-return raw_item;
-}
-
-cJSON_Delete(raw_item);
-return NULL;
-}
-
-CJSON_PUBLIC(cJSON*) cJSON_AddObjectToObject(cJSON * const object, const char * const name)
-{
-cJSON *object_item = cJSON_CreateObject();
-if (add_item_to_object(object, name, object_item, &global_hooks, false))
-{
-return object_item;
-}
-
-cJSON_Delete(object_item);
-return NULL;
-}
-
-CJSON_PUBLIC(cJSON*) cJSON_AddArrayToObject(cJSON * const object, const char * const name)
-{
-cJSON *array = cJSON_CreateArray();
-if (add_item_to_object(object, name, array, &global_hooks, false))
-{
-return array;
-}
-
-cJSON_Delete(array);
-return NULL;
-}
-
-CJSON_PUBLIC(cJSON *) cJSON_DetachItemViaPointer(cJSON *parent, cJSON * const item)
-{
-if ((parent == NULL) || (item == NULL))
-{
-return NULL;
-}
-
-if (item != parent->child)
-{
-/* not the first element */
-item->prev->next = item->next;
-}
-if (item->next != NULL)
-{
-/* not the last element */
-item->next->prev = item->prev;
-}
-
-if (item == parent->child)
-{
-/* first element */
-parent->child = item->next;
-}
-else if (item->next == NULL)
-{
-/* last element */
-parent->child->prev = item->prev;
-}
-
-/* make sure the detached item doesn't point anywhere anymore */
-item->prev = NULL;
-item->next = NULL;
-
-return item;
+ return item;
}
CJSON_PUBLIC(cJSON *) cJSON_DetachItemFromArray(cJSON *array, int which)
{
-if (which < 0)
-{
-return NULL;
-}
+ if (which < 0)
+ {
+ return NULL;
+ }
-return cJSON_DetachItemViaPointer(array, get_array_item(array, (size_t)which));
+ return cJSON_DetachItemViaPointer(array, get_array_item(array, (size_t)which));
}
CJSON_PUBLIC(void) cJSON_DeleteItemFromArray(cJSON *array, int which)
{
-cJSON_Delete(cJSON_DetachItemFromArray(array, which));
+ cJSON_Delete(cJSON_DetachItemFromArray(array, which));
}
-CJSON_PUBLIC(cJSON *) cJSON_DetachItemFromObject(cJSON *object, const char *string)
+CJSON_PUBLIC(cJSON *) cJSON_DetachItemFromObject(cJSON *object,
+ const char *string)
{
-cJSON *to_detach = cJSON_GetObjectItem(object, string);
+ cJSON *to_detach = cJSON_GetObjectItem(object, string);
-return cJSON_DetachItemViaPointer(object, to_detach);
+ return cJSON_DetachItemViaPointer(object, to_detach);
}
-CJSON_PUBLIC(cJSON *) cJSON_DetachItemFromObjectCaseSensitive(cJSON *object, const char *string)
+CJSON_PUBLIC(cJSON *) cJSON_DetachItemFromObjectCaseSensitive(cJSON *object,
+ const char *string)
{
-cJSON *to_detach = cJSON_GetObjectItemCaseSensitive(object, string);
+ cJSON *to_detach = cJSON_GetObjectItemCaseSensitive(object, string);
-return cJSON_DetachItemViaPointer(object, to_detach);
+ return cJSON_DetachItemViaPointer(object, to_detach);
}
CJSON_PUBLIC(void) cJSON_DeleteItemFromObject(cJSON *object, const char *string)
{
-cJSON_Delete(cJSON_DetachItemFromObject(object, string));
+ cJSON_Delete(cJSON_DetachItemFromObject(object, string));
}
-CJSON_PUBLIC(void) cJSON_DeleteItemFromObjectCaseSensitive(cJSON *object, const char *string)
+CJSON_PUBLIC(void) cJSON_DeleteItemFromObjectCaseSensitive(cJSON *object,
+ const char *string)
{
-cJSON_Delete(cJSON_DetachItemFromObjectCaseSensitive(object, string));
+ cJSON_Delete(cJSON_DetachItemFromObjectCaseSensitive(object, string));
}
/* Replace array/object items with new ones. */
-CJSON_PUBLIC(cJSON_bool) cJSON_InsertItemInArray(cJSON *array, int which, cJSON *newitem)
+CJSON_PUBLIC(cJSON_bool) cJSON_InsertItemInArray(cJSON *array, int which,
+ cJSON *newitem)
{
-cJSON *after_inserted = NULL;
+ cJSON *after_inserted = NULL;
-if (which < 0)
-{
-return false;
+ if (which < 0)
+ {
+ return false;
+ }
+
+ after_inserted = get_array_item(array, (size_t)which);
+
+ if (after_inserted == NULL)
+ {
+ return add_item_to_array(array, newitem);
+ }
+
+ newitem->next = after_inserted;
+ newitem->prev = after_inserted->prev;
+ after_inserted->prev = newitem;
+
+ if (after_inserted == array->child)
+ {
+ array->child = newitem;
+ }
+ else
+ {
+ newitem->prev->next = newitem;
+ }
+
+ return true;
}
-after_inserted = get_array_item(array, (size_t)which);
-if (after_inserted == NULL)
+CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemViaPointer(cJSON *const parent,
+ cJSON *const item, cJSON *replacement)
{
-return add_item_to_array(array, newitem);
+ if ((parent == NULL) || (replacement == NULL) || (item == NULL))
+ {
+ return false;
+ }
+
+ if (replacement == item)
+ {
+ return true;
+ }
+
+ replacement->next = item->next;
+ replacement->prev = item->prev;
+
+ if (replacement->next != NULL)
+ {
+ replacement->next->prev = replacement;
+ }
+
+ if (parent->child == item)
+ {
+ if (parent->child->prev == parent->child)
+ {
+ replacement->prev = replacement;
+ }
+
+ parent->child = replacement;
+ }
+ else
+ {
+ /*
+ * To find the last item in array quickly, we use prev in array.
+ * We can't modify the last item's next pointer where this item was the parent's child
+ */
+ if (replacement->prev != NULL)
+ {
+ replacement->prev->next = replacement;
+ }
+
+ if (replacement->next == NULL)
+ {
+ parent->child->prev = replacement;
+ }
+ }
+
+ item->next = NULL;
+ item->prev = NULL;
+ cJSON_Delete(item);
+
+ return true;
}
-newitem->next = after_inserted;
-newitem->prev = after_inserted->prev;
-after_inserted->prev = newitem;
-if (after_inserted == array->child)
+CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemInArray(cJSON *array, int which,
+ cJSON *newitem)
{
-array->child = newitem;
-}
-else
-{
-newitem->prev->next = newitem;
-}
-return true;
+ if (which < 0)
+ {
+ return false;
+ }
+
+ return cJSON_ReplaceItemViaPointer(array, get_array_item(array, (size_t)which),
+ newitem);
}
-CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemViaPointer(cJSON * const parent, cJSON * const item, cJSON * replacement)
-{
-if ((parent == NULL) || (replacement == NULL) || (item == NULL))
-{
-return false;
-}
-
-if (replacement == item)
-{
-return true;
-}
-
-replacement->next = item->next;
-replacement->prev = item->prev;
-
-if (replacement->next != NULL)
-{
-replacement->next->prev = replacement;
-}
-if (parent->child == item)
-{
-if (parent->child->prev == parent->child)
-{
-replacement->prev = replacement;
-}
-parent->child = replacement;
-}
-else
-{ /*
- * To find the last item in array quickly, we use prev in array.
- * We can't modify the last item's next pointer where this item was the parent's child
- */
-if (replacement->prev != NULL)
-{
-replacement->prev->next = replacement;
-}
-if (replacement->next == NULL)
-{
-parent->child->prev = replacement;
-}
-}
-
-item->next = NULL;
-item->prev = NULL;
-cJSON_Delete(item);
-
-return true;
-}
-
-CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemInArray(cJSON *array, int which, cJSON *newitem)
-{
-if (which < 0)
-{
-return false;
-}
-
-return cJSON_ReplaceItemViaPointer(array, get_array_item(array, (size_t)which), newitem);
-}
-
-static cJSON_bool replace_item_in_object(cJSON *object, const char *string, cJSON *replacement, cJSON_bool case_sensitive)
+static cJSON_bool replace_item_in_object(cJSON *object, const char *string,
+ cJSON *replacement, cJSON_bool case_sensitive)
{
if ((replacement == NULL) || (string == NULL))
{
@@ -2360,27 +2619,33 @@ static cJSON_bool replace_item_in_object(cJSON *object, const char *string, cJSO
{
cJSON_free(replacement->string);
}
- replacement->string = (char*)cJSON_strdup((const unsigned char*)string, &global_hooks);
+
+ replacement->string = (char *)cJSON_strdup((const unsigned char *)string,
+ &global_hooks);
replacement->type &= ~cJSON_StringIsConst;
- return cJSON_ReplaceItemViaPointer(object, get_object_item(object, string, case_sensitive), replacement);
+ return cJSON_ReplaceItemViaPointer(object, get_object_item(object, string,
+ case_sensitive), replacement);
}
-CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemInObject(cJSON *object, const char *string, cJSON *newitem)
+CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemInObject(cJSON *object,
+ const char *string, cJSON *newitem)
{
-return replace_item_in_object(object, string, newitem, false);
+ return replace_item_in_object(object, string, newitem, false);
}
-CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemInObjectCaseSensitive(cJSON *object, const char *string, cJSON *newitem)
+CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemInObjectCaseSensitive(cJSON *object,
+ const char *string, cJSON *newitem)
{
-return replace_item_in_object(object, string, newitem, true);
+ return replace_item_in_object(object, string, newitem, true);
}
/* Create basic types: */
CJSON_PUBLIC(cJSON *) cJSON_CreateNull(void)
{
cJSON *item = cJSON_New_Item(&global_hooks);
- if(item)
+
+ if (item)
{
item->type = cJSON_NULL;
}
@@ -2391,7 +2656,8 @@ CJSON_PUBLIC(cJSON *) cJSON_CreateNull(void)
CJSON_PUBLIC(cJSON *) cJSON_CreateTrue(void)
{
cJSON *item = cJSON_New_Item(&global_hooks);
- if(item)
+
+ if (item)
{
item->type = cJSON_True;
}
@@ -2402,7 +2668,8 @@ CJSON_PUBLIC(cJSON *) cJSON_CreateTrue(void)
CJSON_PUBLIC(cJSON *) cJSON_CreateFalse(void)
{
cJSON *item = cJSON_New_Item(&global_hooks);
- if(item)
+
+ if (item)
{
item->type = cJSON_False;
}
@@ -2412,19 +2679,21 @@ CJSON_PUBLIC(cJSON *) cJSON_CreateFalse(void)
CJSON_PUBLIC(cJSON *) cJSON_CreateBool(cJSON_bool boolean)
{
-cJSON *item = cJSON_New_Item(&global_hooks);
-if(item)
-{
-item->type = boolean ? cJSON_True : cJSON_False;
-}
+ cJSON *item = cJSON_New_Item(&global_hooks);
-return item;
+ if (item)
+ {
+ item->type = boolean ? cJSON_True : cJSON_False;
+ }
+
+ return item;
}
CJSON_PUBLIC(cJSON *) cJSON_CreateNumber(double num)
{
cJSON *item = cJSON_New_Item(&global_hooks);
- if(item)
+
+ if (item)
{
item->type = cJSON_Number;
item->valuedouble = num;
@@ -2450,11 +2719,14 @@ CJSON_PUBLIC(cJSON *) cJSON_CreateNumber(double num)
CJSON_PUBLIC(cJSON *) cJSON_CreateString(const char *string)
{
cJSON *item = cJSON_New_Item(&global_hooks);
- if(item)
+
+ if (item)
{
item->type = cJSON_String;
- item->valuestring = (char*)cJSON_strdup((const unsigned char*)string, &global_hooks);
- if(!item->valuestring)
+ item->valuestring = (char *)cJSON_strdup((const unsigned char *)string,
+ &global_hooks);
+
+ if (!item->valuestring)
{
cJSON_Delete(item);
return NULL;
@@ -2467,10 +2739,11 @@ CJSON_PUBLIC(cJSON *) cJSON_CreateString(const char *string)
CJSON_PUBLIC(cJSON *) cJSON_CreateStringReference(const char *string)
{
cJSON *item = cJSON_New_Item(&global_hooks);
+
if (item != NULL)
{
item->type = cJSON_String | cJSON_IsReference;
- item->valuestring = (char*)cast_away_const(string);
+ item->valuestring = (char *)cast_away_const(string);
}
return item;
@@ -2479,19 +2752,24 @@ CJSON_PUBLIC(cJSON *) cJSON_CreateStringReference(const char *string)
CJSON_PUBLIC(cJSON *) cJSON_CreateObjectReference(const cJSON *child)
{
cJSON *item = cJSON_New_Item(&global_hooks);
- if (item != NULL) {
+
+ if (item != NULL)
+ {
item->type = cJSON_Object | cJSON_IsReference;
- item->child = (cJSON*)cast_away_const(child);
+ item->child = (cJSON *)cast_away_const(child);
}
return item;
}
-CJSON_PUBLIC(cJSON *) cJSON_CreateArrayReference(const cJSON *child) {
+CJSON_PUBLIC(cJSON *) cJSON_CreateArrayReference(const cJSON *child)
+{
cJSON *item = cJSON_New_Item(&global_hooks);
- if (item != NULL) {
+
+ if (item != NULL)
+ {
item->type = cJSON_Array | cJSON_IsReference;
- item->child = (cJSON*)cast_away_const(child);
+ item->child = (cJSON *)cast_away_const(child);
}
return item;
@@ -2500,11 +2778,14 @@ CJSON_PUBLIC(cJSON *) cJSON_CreateArrayReference(const cJSON *child) {
CJSON_PUBLIC(cJSON *) cJSON_CreateRaw(const char *raw)
{
cJSON *item = cJSON_New_Item(&global_hooks);
- if(item)
+
+ if (item)
{
item->type = cJSON_Raw;
- item->valuestring = (char*)cJSON_strdup((const unsigned char*)raw, &global_hooks);
- if(!item->valuestring)
+ item->valuestring = (char *)cJSON_strdup((const unsigned char *)raw,
+ &global_hooks);
+
+ if (!item->valuestring)
{
cJSON_Delete(item);
return NULL;
@@ -2517,9 +2798,10 @@ CJSON_PUBLIC(cJSON *) cJSON_CreateRaw(const char *raw)
CJSON_PUBLIC(cJSON *) cJSON_CreateArray(void)
{
cJSON *item = cJSON_New_Item(&global_hooks);
- if(item)
+
+ if (item)
{
- item->type=cJSON_Array;
+ item->type = cJSON_Array;
}
return item;
@@ -2528,6 +2810,7 @@ CJSON_PUBLIC(cJSON *) cJSON_CreateArray(void)
CJSON_PUBLIC(cJSON *) cJSON_CreateObject(void)
{
cJSON *item = cJSON_New_Item(&global_hooks);
+
if (item)
{
item->type = cJSON_Object;
@@ -2551,15 +2834,17 @@ CJSON_PUBLIC(cJSON *) cJSON_CreateIntArray(const int *numbers, int count)
a = cJSON_CreateArray();
- for(i = 0; a && (i < (size_t)count); i++)
+ for (i = 0; a && (i < (size_t)count); i++)
{
n = cJSON_CreateNumber(numbers[i]);
+
if (!n)
{
cJSON_Delete(a);
return NULL;
}
- if(!i)
+
+ if (!i)
{
a->child = n;
}
@@ -2567,10 +2852,12 @@ CJSON_PUBLIC(cJSON *) cJSON_CreateIntArray(const int *numbers, int count)
{
suffix_object(p, n);
}
+
p = n;
}
- if (a && a->child) {
+ if (a && a->child)
+ {
a->child->prev = n;
}
@@ -2591,15 +2878,17 @@ CJSON_PUBLIC(cJSON *) cJSON_CreateFloatArray(const float *numbers, int count)
a = cJSON_CreateArray();
- for(i = 0; a && (i < (size_t)count); i++)
+ for (i = 0; a && (i < (size_t)count); i++)
{
n = cJSON_CreateNumber((double)numbers[i]);
- if(!n)
+
+ if (!n)
{
cJSON_Delete(a);
return NULL;
}
- if(!i)
+
+ if (!i)
{
a->child = n;
}
@@ -2607,10 +2896,12 @@ CJSON_PUBLIC(cJSON *) cJSON_CreateFloatArray(const float *numbers, int count)
{
suffix_object(p, n);
}
+
p = n;
}
- if (a && a->child) {
+ if (a && a->child)
+ {
a->child->prev = n;
}
@@ -2631,15 +2922,17 @@ CJSON_PUBLIC(cJSON *) cJSON_CreateDoubleArray(const double *numbers, int count)
a = cJSON_CreateArray();
- for(i = 0; a && (i < (size_t)count); i++)
+ for (i = 0; a && (i < (size_t)count); i++)
{
n = cJSON_CreateNumber(numbers[i]);
- if(!n)
+
+ if (!n)
{
cJSON_Delete(a);
return NULL;
}
- if(!i)
+
+ if (!i)
{
a->child = n;
}
@@ -2647,17 +2940,20 @@ CJSON_PUBLIC(cJSON *) cJSON_CreateDoubleArray(const double *numbers, int count)
{
suffix_object(p, n);
}
+
p = n;
}
- if (a && a->child) {
+ if (a && a->child)
+ {
a->child->prev = n;
}
return a;
}
-CJSON_PUBLIC(cJSON *) cJSON_CreateStringArray(const char *const *strings, int count)
+CJSON_PUBLIC(cJSON *) cJSON_CreateStringArray(const char *const *strings,
+ int count)
{
size_t i = 0;
cJSON *n = NULL;
@@ -2674,23 +2970,27 @@ CJSON_PUBLIC(cJSON *) cJSON_CreateStringArray(const char *const *strings, int co
for (i = 0; a && (i < (size_t)count); i++)
{
n = cJSON_CreateString(strings[i]);
- if(!n)
+
+ if (!n)
{
cJSON_Delete(a);
return NULL;
}
- if(!i)
+
+ if (!i)
{
a->child = n;
}
else
{
- suffix_object(p,n);
+ suffix_object(p, n);
}
+
p = n;
}
- if (a && a->child) {
+ if (a && a->child)
+ {
a->child->prev = n;
}
@@ -2710,46 +3010,61 @@ CJSON_PUBLIC(cJSON *) cJSON_Duplicate(const cJSON *item, cJSON_bool recurse)
{
goto fail;
}
+
/* Create new item */
newitem = cJSON_New_Item(&global_hooks);
+
if (!newitem)
{
goto fail;
}
+
/* Copy over all vars */
newitem->type = item->type & (~cJSON_IsReference);
newitem->valueint = item->valueint;
newitem->valuedouble = item->valuedouble;
+
if (item->valuestring)
{
- newitem->valuestring = (char*)cJSON_strdup((unsigned char*)item->valuestring, &global_hooks);
+ newitem->valuestring = (char *)cJSON_strdup((unsigned char *)item->valuestring,
+ &global_hooks);
+
if (!newitem->valuestring)
{
goto fail;
}
}
+
if (item->string)
{
- newitem->string = (item->type&cJSON_StringIsConst) ? item->string : (char*)cJSON_strdup((unsigned char*)item->string, &global_hooks);
+ newitem->string = (item->type & cJSON_StringIsConst) ? item->string :
+ (char *)cJSON_strdup((unsigned char *)item->string, &global_hooks);
+
if (!newitem->string)
{
goto fail;
}
}
+
/* If non-recursive, then we're done! */
if (!recurse)
{
return newitem;
}
+
/* Walk the ->next chain for the child. */
child = item->child;
+
while (child != NULL)
{
- newchild = cJSON_Duplicate(child, true); /* Duplicate (with recurse) each item in the ->next chain */
+ newchild = cJSON_Duplicate(child,
+ true); /* Duplicate (with recurse) each item in the ->next chain */
+
if (!newchild)
{
goto fail;
}
+
if (next != NULL)
{
/* If newitem->child already set, then crosswire ->prev and ->next and move on */
@@ -2763,8 +3078,10 @@ CJSON_PUBLIC(cJSON *) cJSON_Duplicate(const cJSON *item, cJSON_bool recurse)
newitem->child = newchild;
next = newchild;
}
+
child = child->next;
}
+
if (newitem && newitem->child)
{
newitem->child->prev = newchild;
@@ -2772,7 +3089,8 @@ CJSON_PUBLIC(cJSON *) cJSON_Duplicate(const cJSON *item, cJSON_bool recurse)
return newitem;
- fail:
+fail:
+
if (newitem != NULL)
{
cJSON_Delete(newitem);
@@ -2787,7 +3105,8 @@ static void skip_oneline_comment(char **input)
for (; (*input)[0] != '\0'; ++(*input))
{
- if ((*input)[0] == '\n') {
+ if ((*input)[0] == '\n')
+ {
*input += static_strlen("\n");
return;
}
@@ -2808,21 +3127,26 @@ static void skip_multiline_comment(char **input)
}
}
-static void minify_string(char **input, char **output) {
+static void minify_string(char **input, char **output)
+{
(*output)[0] = (*input)[0];
*input += static_strlen("\"");
*output += static_strlen("\"");
- for (; (*input)[0] != '\0'; (void)++(*input), ++(*output)) {
+ for (; (*input)[0] != '\0'; (void)++(*input), ++(*output))
+ {
(*output)[0] = (*input)[0];
- if ((*input)[0] == '\"') {
+ if ((*input)[0] == '\"')
+ {
(*output)[0] = '\"';
*input += static_strlen("\"");
*output += static_strlen("\"");
return;
- } else if (((*input)[0] == '\\') && ((*input)[1] == '\"')) {
+ }
+ else if (((*input)[0] == '\\') && ((*input)[1] == '\"'))
+ {
(*output)[1] = (*input)[1];
*input += static_strlen("\"");
*output += static_strlen("\"");
@@ -2843,34 +3167,37 @@ CJSON_PUBLIC(void) cJSON_Minify(char *json)
{
switch (json[0])
{
- case ' ':
- case '\t':
- case '\r':
- case '\n':
+ case ' ':
+ case '\t':
+ case '\r':
+ case '\n':
+ json++;
+ break;
+
+ case '/':
+ if (json[1] == '/')
+ {
+ skip_oneline_comment(&json);
+ }
+ else if (json[1] == '*')
+ {
+ skip_multiline_comment(&json);
+ }
+ else
+ {
json++;
- break;
+ }
- case '/':
- if (json[1] == '/')
- {
- skip_oneline_comment(&json);
- }
- else if (json[1] == '*')
- {
- skip_multiline_comment(&json);
- } else {
- json++;
- }
- break;
+ break;
- case '\"':
- minify_string(&json, (char**)&into);
- break;
+ case '\"':
+ minify_string(&json, (char **)&into);
+ break;
- default:
- into[0] = json[0];
- json++;
- into++;
+ default:
+ into[0] = json[0];
+ json++;
+ into++;
}
}
@@ -2878,7 +3205,7 @@ CJSON_PUBLIC(void) cJSON_Minify(char *json)
*into = '\0';
}
-CJSON_PUBLIC(cJSON_bool) cJSON_IsInvalid(const cJSON * const item)
+CJSON_PUBLIC(cJSON_bool) cJSON_IsInvalid(const cJSON *const item)
{
if (item == NULL)
{
@@ -2888,7 +3215,7 @@ CJSON_PUBLIC(cJSON_bool) cJSON_IsInvalid(const cJSON * const item)
return (item->type & 0xFF) == cJSON_Invalid;
}
-CJSON_PUBLIC(cJSON_bool) cJSON_IsFalse(const cJSON * const item)
+CJSON_PUBLIC(cJSON_bool) cJSON_IsFalse(const cJSON *const item)
{
if (item == NULL)
{
@@ -2898,7 +3225,7 @@ CJSON_PUBLIC(cJSON_bool) cJSON_IsFalse(const cJSON * const item)
return (item->type & 0xFF) == cJSON_False;
}
-CJSON_PUBLIC(cJSON_bool) cJSON_IsTrue(const cJSON * const item)
+CJSON_PUBLIC(cJSON_bool) cJSON_IsTrue(const cJSON *const item)
{
if (item == NULL)
{
@@ -2909,7 +3236,7 @@ CJSON_PUBLIC(cJSON_bool) cJSON_IsTrue(const cJSON * const item)
}
-CJSON_PUBLIC(cJSON_bool) cJSON_IsBool(const cJSON * const item)
+CJSON_PUBLIC(cJSON_bool) cJSON_IsBool(const cJSON *const item)
{
if (item == NULL)
{
@@ -2918,7 +3245,7 @@ CJSON_PUBLIC(cJSON_bool) cJSON_IsBool(const cJSON * const item)
return (item->type & (cJSON_True | cJSON_False)) != 0;
}
-CJSON_PUBLIC(cJSON_bool) cJSON_IsNull(const cJSON * const item)
+CJSON_PUBLIC(cJSON_bool) cJSON_IsNull(const cJSON *const item)
{
if (item == NULL)
{
@@ -2928,7 +3255,7 @@ CJSON_PUBLIC(cJSON_bool) cJSON_IsNull(const cJSON * const item)
return (item->type & 0xFF) == cJSON_NULL;
}
-CJSON_PUBLIC(cJSON_bool) cJSON_IsNumber(const cJSON * const item)
+CJSON_PUBLIC(cJSON_bool) cJSON_IsNumber(const cJSON *const item)
{
if (item == NULL)
{
@@ -2938,7 +3265,7 @@ CJSON_PUBLIC(cJSON_bool) cJSON_IsNumber(const cJSON * const item)
return (item->type & 0xFF) == cJSON_Number;
}
-CJSON_PUBLIC(cJSON_bool) cJSON_IsString(const cJSON * const item)
+CJSON_PUBLIC(cJSON_bool) cJSON_IsString(const cJSON *const item)
{
if (item == NULL)
{
@@ -2948,7 +3275,7 @@ CJSON_PUBLIC(cJSON_bool) cJSON_IsString(const cJSON * const item)
return (item->type & 0xFF) == cJSON_String;
}
-CJSON_PUBLIC(cJSON_bool) cJSON_IsArray(const cJSON * const item)
+CJSON_PUBLIC(cJSON_bool) cJSON_IsArray(const cJSON *const item)
{
if (item == NULL)
{
@@ -2958,7 +3285,7 @@ CJSON_PUBLIC(cJSON_bool) cJSON_IsArray(const cJSON * const item)
return (item->type & 0xFF) == cJSON_Array;
}
-CJSON_PUBLIC(cJSON_bool) cJSON_IsObject(const cJSON * const item)
+CJSON_PUBLIC(cJSON_bool) cJSON_IsObject(const cJSON *const item)
{
if (item == NULL)
{
@@ -2968,7 +3295,7 @@ CJSON_PUBLIC(cJSON_bool) cJSON_IsObject(const cJSON * const item)
return (item->type & 0xFF) == cJSON_Object;
}
-CJSON_PUBLIC(cJSON_bool) cJSON_IsRaw(const cJSON * const item)
+CJSON_PUBLIC(cJSON_bool) cJSON_IsRaw(const cJSON *const item)
{
if (item == NULL)
{
@@ -2978,7 +3305,8 @@ CJSON_PUBLIC(cJSON_bool) cJSON_IsRaw(const cJSON * const item)
return (item->type & 0xFF) == cJSON_Raw;
}
-CJSON_PUBLIC(cJSON_bool) cJSON_Compare(const cJSON * const a, const cJSON * const b, const cJSON_bool case_sensitive)
+CJSON_PUBLIC(cJSON_bool) cJSON_Compare(const cJSON *const a,
+ const cJSON *const b, const cJSON_bool case_sensitive)
{
if ((a == NULL) || (b == NULL) || ((a->type & 0xFF) != (b->type & 0xFF)))
{
@@ -2988,18 +3316,18 @@ CJSON_PUBLIC(cJSON_bool) cJSON_Compare(const cJSON * const a, const cJSON * cons
/* check if type is valid */
switch (a->type & 0xFF)
{
- case cJSON_False:
- case cJSON_True:
- case cJSON_NULL:
- case cJSON_Number:
- case cJSON_String:
- case cJSON_Raw:
- case cJSON_Array:
- case cJSON_Object:
- break;
+ case cJSON_False:
+ case cJSON_True:
+ case cJSON_NULL:
+ case cJSON_Number:
+ case cJSON_String:
+ case cJSON_Raw:
+ case cJSON_Array:
+ case cJSON_Object:
+ break;
- default:
- return false;
+ default:
+ return false;
}
/* identical objects are equal */
@@ -3010,96 +3338,101 @@ CJSON_PUBLIC(cJSON_bool) cJSON_Compare(const cJSON * const a, const cJSON * cons
switch (a->type & 0xFF)
{
- /* in these cases and equal type is enough */
- case cJSON_False:
- case cJSON_True:
- case cJSON_NULL:
- return true;
+ /* in these cases and equal type is enough */
+ case cJSON_False:
+ case cJSON_True:
+ case cJSON_NULL:
+ return true;
- case cJSON_Number:
- if (compare_double(a->valuedouble, b->valuedouble))
- {
- return true;
- }
- return false;
-
- case cJSON_String:
- case cJSON_Raw:
- if ((a->valuestring == NULL) || (b->valuestring == NULL))
- {
- return false;
- }
- if (strcmp(a->valuestring, b->valuestring) == 0)
- {
- return true;
- }
-
- return false;
-
- case cJSON_Array:
+ case cJSON_Number:
+ if (compare_double(a->valuedouble, b->valuedouble))
{
- cJSON *a_element = a->child;
- cJSON *b_element = b->child;
-
- for (; (a_element != NULL) && (b_element != NULL);)
- {
- if (!cJSON_Compare(a_element, b_element, case_sensitive))
- {
- return false;
- }
-
- a_element = a_element->next;
- b_element = b_element->next;
- }
-
- /* one of the arrays is longer than the other */
- if (a_element != b_element) {
- return false;
- }
-
return true;
}
- case cJSON_Object:
+ return false;
+
+ case cJSON_String:
+ case cJSON_Raw:
+ if ((a->valuestring == NULL) || (b->valuestring == NULL))
{
- cJSON *a_element = NULL;
- cJSON *b_element = NULL;
- cJSON_ArrayForEach(a_element, a)
- {
- /* TODO This has O(n^2) runtime, which is horrible! */
- b_element = get_object_item(b, a_element->string, case_sensitive);
- if (b_element == NULL)
- {
- return false;
- }
-
- if (!cJSON_Compare(a_element, b_element, case_sensitive))
- {
- return false;
- }
- }
-
- /* doing this twice, once on a and b to prevent true comparison if a subset of b
- * TODO: Do this the proper way, this is just a fix for now */
- cJSON_ArrayForEach(b_element, b)
- {
- a_element = get_object_item(a, b_element->string, case_sensitive);
- if (a_element == NULL)
- {
- return false;
- }
-
- if (!cJSON_Compare(b_element, a_element, case_sensitive))
- {
- return false;
- }
- }
+ return false;
+ }
+ if (strcmp(a->valuestring, b->valuestring) == 0)
+ {
return true;
}
- default:
+ return false;
+
+ case cJSON_Array:
+ {
+ cJSON *a_element = a->child;
+ cJSON *b_element = b->child;
+
+ for (; (a_element != NULL) && (b_element != NULL);)
+ {
+ if (!cJSON_Compare(a_element, b_element, case_sensitive))
+ {
+ return false;
+ }
+
+ a_element = a_element->next;
+ b_element = b_element->next;
+ }
+
+ /* one of the arrays is longer than the other */
+ if (a_element != b_element)
+ {
return false;
+ }
+
+ return true;
+ }
+
+ case cJSON_Object:
+ {
+ cJSON *a_element = NULL;
+ cJSON *b_element = NULL;
+ cJSON_ArrayForEach(a_element, a)
+ {
+ /* TODO This has O(n^2) runtime, which is horrible! */
+ b_element = get_object_item(b, a_element->string, case_sensitive);
+
+ if (b_element == NULL)
+ {
+ return false;
+ }
+
+ if (!cJSON_Compare(a_element, b_element, case_sensitive))
+ {
+ return false;
+ }
+ }
+
+ /* doing this twice, once on a and b to prevent true comparison if a subset of b
+ * TODO: Do this the proper way, this is just a fix for now */
+ cJSON_ArrayForEach(b_element, b)
+ {
+ a_element = get_object_item(a, b_element->string, case_sensitive);
+
+ if (a_element == NULL)
+ {
+ return false;
+ }
+
+ if (!cJSON_Compare(b_element, a_element, case_sensitive))
+ {
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ default:
+ return false;
}
}
diff --git a/lib/termios.c b/lib/termios.c
index 0739cce9f..91c8b11b6 100644
--- a/lib/termios.c
+++ b/lib/termios.c
@@ -1335,21 +1335,21 @@ static int check_port_capabilities(struct termios_list *index)
if (!(cp.dwProvCapabilities & PCF_DTRDSR))
{
SNPRINTF(message, sizeof(message),
- "%s: no DTR & DSR support\n", __func__);
+ "%s: no DTR & DSR support\n", __func__);
report(message);
}
if (!(cp.dwProvCapabilities & PCF_RLSD))
{
SNPRINTF(message, sizeof(message), "%s: no carrier detect (RLSD) support\n",
- __func__);
+ __func__);
report(message);
}
if (!(cp.dwProvCapabilities & PCF_RTSCTS))
{
SNPRINTF(message, sizeof(message),
- "%s: no RTS & CTS support\n", __func__);
+ "%s: no RTS & CTS support\n", __func__);
report(message);
}
@@ -1422,8 +1422,9 @@ int win32_serial_open(const char *filename, int flags, ...)
if (open_port(index))
{
- SNPRINTF(message, sizeof(message), "serial_open(): Invalid Port Reference for %s\n",
- fullfilename);
+ SNPRINTF(message, sizeof(message),
+ "serial_open(): Invalid Port Reference for %s\n",
+ fullfilename);
report(message);
win32_serial_close(index->fd);
return -1;
@@ -1456,7 +1457,7 @@ int win32_serial_open(const char *filename, int flags, ...)
if (!first_tl->hComm)
{
SNPRINTF(message, sizeof(message), "open(): Invalid Port Reference for %s\n",
- index->filename);
+ index->filename);
report(message);
}
@@ -1678,7 +1679,7 @@ int win32_serial_read(int fd, void *vb, int size)
#ifdef DEBUG_VERBOSE
/* warning Roy Rogers! */
SNPRINTF(message, sizeof(message), " ========== ReadFile = %i 0x%x\n",
- (int) nBytes, *((char *) dest + total));
+ (int) nBytes, *((char *) dest + total));
report(message);
#endif /* DEBUG_VERBOSE */
@@ -1725,7 +1726,7 @@ int win32_serial_read(int fd, void *vb, int size)
{
now = GetTickCount();
SNPRINTF(message, sizeof(message), "size > 0: spent=%ld have=%d\n", now - start,
- index->ttyset->c_cc[VTIME] * 100);
+ index->ttyset->c_cc[VTIME] * 100);
report(message);
/* we should use -1 for disabled
@@ -1880,7 +1881,7 @@ int win32_serial_read(int fd, void *vb, int size)
#ifdef DEBUG_VERBOSE
/* warning Roy Rogers! */
SNPRINTF(message, sizeof(message), " ========== ReadFile = %i %s\n",
- (int) nBytes, (char *) dest + total);
+ (int) nBytes, (char *) dest + total);
report(message);
#endif /* DEBUG_VERBOSE */
@@ -1927,7 +1928,7 @@ int win32_serial_read(int fd, void *vb, int size)
{
now = GetTickCount();
SNPRINTF(message, sizeof(message), "size > 0: spent=%ld have=%d\n", now - start,
- index->ttyset->c_cc[VTIME] * 100);
+ index->ttyset->c_cc[VTIME] * 100);
report(message);
/* we should use -1 for disabled
@@ -2350,7 +2351,7 @@ static void show_DCB(DCB myDCB)
default:
SNPRINTF(message, sizeof(message),
- "unknown Parity (%#x ):", myDCB.Parity);
+ "unknown Parity (%#x ):", myDCB.Parity);
report(message);
break;
}
@@ -2597,8 +2598,8 @@ int tcgetattr(int fd, struct termios *s_termios)
#ifdef DEBUG_VERBOSE
SNPRINTF(message, sizeof(message),
- "tcgetattr: VTIME:%d, VMIN:%d\n", s_termios->c_cc[VTIME],
- s_termios->c_cc[VMIN]);
+ "tcgetattr: VTIME:%d, VMIN:%d\n", s_termios->c_cc[VTIME],
+ s_termios->c_cc[VMIN]);
report(message);
#endif /* DEBUG_VERBOSE */
@@ -2788,8 +2789,9 @@ int tcsetattr(int fd, int when, struct termios *s_termios)
#ifdef DEBUG_VERBOSE
{
char message[32];
- SNPRINTF(message, sizeof(message), "VTIME:%d, VMIN:%d\n", s_termios->c_cc[VTIME],
- s_termios->c_cc[VMIN]);
+ SNPRINTF(message, sizeof(message), "VTIME:%d, VMIN:%d\n",
+ s_termios->c_cc[VTIME],
+ s_termios->c_cc[VMIN]);
report(message);
}
#endif /* DEBUG_VERBOSE */
@@ -2818,19 +2820,19 @@ int tcsetattr(int fd, int when, struct termios *s_termios)
{
char message[64];
SNPRINTF(message, sizeof(message), "ReadIntervalTimeout=%ld\n",
- timeouts.ReadIntervalTimeout);
+ timeouts.ReadIntervalTimeout);
report(message);
SNPRINTF(message, sizeof(message), "c_cc[VTIME] = %d, c_cc[VMIN] = %d\n",
- s_termios->c_cc[VTIME], s_termios->c_cc[VMIN]);
+ s_termios->c_cc[VTIME], s_termios->c_cc[VMIN]);
report(message);
SNPRINTF(message, sizeof(message), "ReadTotalTimeoutConstant: %ld\n",
- timeouts.ReadTotalTimeoutConstant);
+ timeouts.ReadTotalTimeoutConstant);
report(message);
SNPRINTF(message, sizeof(message), "ReadIntervalTimeout : %ld\n",
- timeouts.ReadIntervalTimeout);
+ timeouts.ReadIntervalTimeout);
report(message);
SNPRINTF(message, sizeof(message), "ReadTotalTimeoutMultiplier: %ld\n",
- timeouts.ReadTotalTimeoutMultiplier);
+ timeouts.ReadTotalTimeoutMultiplier);
report(message);
}
#endif /* DEBUG_VERBOSE */
@@ -2938,7 +2940,7 @@ int tcdrain(int fd)
0.
*/
SNPRINTF(message, sizeof(message), "FlushFileBuffers() %i\n",
- (int) GetLastError());
+ (int) GetLastError());
report(message);
if (GetLastError() == 0)
@@ -3352,7 +3354,8 @@ int win32_serial_ioctl(int fd, int request, ...)
report("DTR is unchanged\n");
}
- SNPRINTF(message, sizeof(message), "DTR %i %i\n", *arg & TIOCM_DTR, index->MSR & TIOCM_DTR);
+ SNPRINTF(message, sizeof(message), "DTR %i %i\n", *arg & TIOCM_DTR,
+ index->MSR & TIOCM_DTR);
report(message);
if (*arg & TIOCM_DTR)
@@ -3380,7 +3383,8 @@ int win32_serial_ioctl(int fd, int request, ...)
report("RTS is unchanged\n");
}
- SNPRINTF(message, sizeof(message), "RTS %i %i\n", *arg & TIOCM_RTS, index->MSR & TIOCM_RTS);
+ SNPRINTF(message, sizeof(message), "RTS %i %i\n", *arg & TIOCM_RTS,
+ index->MSR & TIOCM_RTS);
report(message);
if (*arg & TIOCM_RTS)
@@ -3579,7 +3583,7 @@ int win32_serial_ioctl(int fd, int request, ...)
*arg = (int) Stat.cbInQue;
#ifdef DEBUG_VERBOSE
SNPRINTF(message, sizeof(message), "FIONREAD: %i bytes available\n",
- (int) Stat.cbInQue);
+ (int) Stat.cbInQue);
report(message);
if (*arg)
@@ -3600,8 +3604,8 @@ int win32_serial_ioctl(int fd, int request, ...)
default:
SNPRINTF(message, sizeof(message),
- "FIXME: ioctl: unknown request: %#x\n",
- request);
+ "FIXME: ioctl: unknown request: %#x\n",
+ request);
report(message);
va_end(ap);
return -ENOIOCTLCMD;
@@ -3791,7 +3795,8 @@ int win32_serial_select(int n, fd_set *readfds, fd_set *writefds,
while (timeout_usec > 0)
{
- SNPRINTF(message, sizeof(message), "wait for data in read buffer%d\n", (int)Stat.cbInQue);
+ SNPRINTF(message, sizeof(message), "wait for data in read buffer%d\n",
+ (int)Stat.cbInQue);
report(message);
if (Stat.cbInQue != 0)
@@ -3938,7 +3943,8 @@ int win32_serial_select(int n, fd_set *readfds, fd_set *writefds,
if (GetLastError() != ERROR_IO_PENDING)
{
- SNPRINTF(message, sizeof(message), "WaitCommEvent filename = %s\n", index->filename);
+ SNPRINTF(message, sizeof(message), "WaitCommEvent filename = %s\n",
+ index->filename);
report(message);
return (1);
/*
diff --git a/rigs/adat/adat.c b/rigs/adat/adat.c
index 621a721a7..b6d5b3c58 100644
--- a/rigs/adat/adat.c
+++ b/rigs/adat/adat.c
@@ -1264,7 +1264,8 @@ int adat_send(RIG *pRig,
rig_flush(&pRigState->rigport);
- nRC = write_block(&pRigState->rigport, (unsigned char *) pcData, strlen(pcData));
+ nRC = write_block(&pRigState->rigport, (unsigned char *) pcData,
+ strlen(pcData));
rig_debug(RIG_DEBUG_TRACE,
"*** ADAT: %d %s (%s:%d): EXIT. Return Code = %d\n",
@@ -1293,7 +1294,7 @@ int adat_receive(RIG *pRig,
gFnLevel, __func__, __FILE__, __LINE__, pRig);
nRC = read_string(&pRigState->rigport, (unsigned char *) pcData, ADAT_RESPSZ,
- ADAT_EOL, 1, 0, 1);
+ ADAT_EOL, 1, 0, 1);
if (nRC > 0)
{
@@ -3723,10 +3724,10 @@ DECLARE_PROBERIG_BACKEND(adat)
memset(acBuf, 0, ADAT_RESPSZ + 1);
nRC = write_block(port,
- (unsigned char *)ADAT_CMD_DEF_STRING_GET_ID_CODE,
+ (unsigned char *)ADAT_CMD_DEF_STRING_GET_ID_CODE,
strlen(ADAT_CMD_DEF_STRING_GET_ID_CODE));
nRead = read_string(port, (unsigned char *) acBuf, ADAT_RESPSZ,
- ADAT_EOM, 1, 0, 1);
+ ADAT_EOM, 1, 0, 1);
close(port->fd);
if ((nRC != RIG_OK || nRead < 0))
diff --git a/rigs/alinco/dx77.c b/rigs/alinco/dx77.c
index b185b26bc..62256582f 100644
--- a/rigs/alinco/dx77.c
+++ b/rigs/alinco/dx77.c
@@ -320,7 +320,7 @@ int dx77_transaction(RIG *rig,
* TODO: check whether cmd and echobuf match (optional)
*/
retval = read_string(&rs->rigport, (unsigned char *) echobuf, BUFSZ,
- LF, strlen(LF), 0, 1);
+ LF, strlen(LF), 0, 1);
if (retval < 0)
{
@@ -337,7 +337,7 @@ int dx77_transaction(RIG *rig,
if (data == NULL)
{
retval = read_string(&rs->rigport, (unsigned char *) echobuf, BUFSZ,
- LF, strlen(LF), 0, 1);
+ LF, strlen(LF), 0, 1);
if (retval < 0)
{
@@ -359,7 +359,7 @@ int dx77_transaction(RIG *rig,
}
retval = read_string(&rs->rigport, (unsigned char *) data, BUFSZ,
- LF, strlen(LF), 0, 1);
+ LF, strlen(LF), 0, 1);
if (retval < 0)
{
@@ -683,8 +683,8 @@ int dx77_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, vfo_t tx_vfo)
char cmdbuf[BUFSZ];
SNPRINTF(cmdbuf, sizeof(cmdbuf),
- AL CMD_SPLT "%d" EOM,
- split == RIG_SPLIT_ON ? 1 : 0);
+ AL CMD_SPLT "%d" EOM,
+ split == RIG_SPLIT_ON ? 1 : 0);
return dx77_transaction(rig, cmdbuf, strlen(cmdbuf), NULL, NULL);
}
@@ -759,7 +759,8 @@ int dx77_set_split_freq(RIG *rig, vfo_t vfo, freq_t tx_freq)
}
/* at least 6 digits */
- SNPRINTF(freqbuf, sizeof(freqbuf), AL CMD_TXFREQ "%06"PRIll EOM, (int64_t)tx_freq);
+ SNPRINTF(freqbuf, sizeof(freqbuf), AL CMD_TXFREQ "%06"PRIll EOM,
+ (int64_t)tx_freq);
retval = dx77_transaction(rig, freqbuf, strlen(freqbuf), NULL, NULL);
@@ -1274,7 +1275,8 @@ int dx77_set_ctcss_tone(RIG *rig, vfo_t vfo, tone_t tone)
SNPRINTF((char *) tonebuf, sizeof(tonebuf), AL CMD_CTCSS "%02d" EOM, i + 1);
- return dx77_transaction(rig, (char *) tonebuf, strlen((char*)tonebuf), NULL, NULL);
+ return dx77_transaction(rig, (char *) tonebuf, strlen((char *)tonebuf), NULL,
+ NULL);
}
diff --git a/rigs/alinco/dxsr8.c b/rigs/alinco/dxsr8.c
index 57409ab05..6864050fd 100644
--- a/rigs/alinco/dxsr8.c
+++ b/rigs/alinco/dxsr8.c
@@ -263,7 +263,7 @@ int dxsr8_transaction(RIG *rig,
* TODO: check whether cmd and echobuf match (optional)
*/
retval = read_string(&rs->rigport, (unsigned char *) replybuf, BUFSZ,
- LF, strlen(LF), 0, 1);
+ LF, strlen(LF), 0, 1);
if (retval < 0)
{
@@ -272,7 +272,7 @@ int dxsr8_transaction(RIG *rig,
retval = read_string(&rs->rigport, (unsigned char *) replybuf, BUFSZ,
- LF, strlen(LF), 0, 1);
+ LF, strlen(LF), 0, 1);
if (retval < 0)
{
diff --git a/rigs/aor/aor.c b/rigs/aor/aor.c
index 8380134ae..349a9f4bd 100644
--- a/rigs/aor/aor.c
+++ b/rigs/aor/aor.c
@@ -101,7 +101,7 @@ static int aor_transaction(RIG *rig, const char *cmd, int cmd_len, char *data,
* Do wait for a reply
*/
retval = read_string(&rs->rigport, (unsigned char *) data, BUFSZ, EOM,
- strlen(EOM), 0, 1);
+ strlen(EOM), 0, 1);
if (retval < 0)
{
@@ -353,7 +353,8 @@ int aor_get_vfo(RIG *rig, vfo_t *vfo)
return RIG_OK;
}
-int format8k_mode(RIG *rig, char *buf, int buf_len, rmode_t mode, pbwidth_t width)
+int format8k_mode(RIG *rig, char *buf, int buf_len, rmode_t mode,
+ pbwidth_t width)
{
int aormode;
@@ -965,7 +966,7 @@ int aor_set_mem(RIG *rig, vfo_t vfo, int ch)
}
SNPRINTF(membuf, sizeof(membuf), "MR%c%02d" EOM,
- bank_base + ch / 100, mem_num);
+ bank_base + ch / 100, mem_num);
return aor_transaction(rig, membuf, strlen(membuf), NULL, NULL);
}
@@ -1021,7 +1022,7 @@ int aor_set_bank(RIG *rig, vfo_t vfo, int bank)
char membuf[BUFSZ];
SNPRINTF(membuf, sizeof(membuf), "MR%c" EOM, (bank % 10) + (bank < 10 ?
- priv->bank_base1 : priv->bank_base2));
+ priv->bank_base1 : priv->bank_base2));
return aor_transaction(rig, membuf, strlen(membuf), NULL, NULL);
}
@@ -1034,7 +1035,7 @@ int aor_set_channel(RIG *rig, vfo_t vfo, const channel_t *chan)
int cmd_len;
SNPRINTF(aorcmd, sizeof(aorcmd), "MX%c%02d ",
- chan->bank_num, chan->channel_num % 100);
+ chan->bank_num, chan->channel_num % 100);
cmd_len = strlen(aorcmd);
cmd_len += format_freq(aorcmd + cmd_len, sizeof(aorcmd) - cmd_len, chan->freq);
@@ -1043,12 +1044,14 @@ int aor_set_channel(RIG *rig, vfo_t vfo, const channel_t *chan)
* FIXME: automode
*/
cmd_len += snprintf(aorcmd + cmd_len, sizeof(aorcmd) - cmd_len, " AU%d ST%06d ",
- 0, (int)chan->tuning_step);
+ 0, (int)chan->tuning_step);
- cmd_len += priv->format_mode(rig, aorcmd + cmd_len, sizeof(aorcmd) - cmd_len, chan->mode, chan->width);
+ cmd_len += priv->format_mode(rig, aorcmd + cmd_len, sizeof(aorcmd) - cmd_len,
+ chan->mode, chan->width);
- cmd_len += snprintf(aorcmd + cmd_len, sizeof(aorcmd) - cmd_len, " AT%d TM%12s%s",
- chan->levels[LVL_ATT].i ? 1 : 0, chan->channel_desc, EOM);
+ cmd_len += snprintf(aorcmd + cmd_len, sizeof(aorcmd) - cmd_len,
+ " AT%d TM%12s%s",
+ chan->levels[LVL_ATT].i ? 1 : 0, chan->channel_desc, EOM);
return aor_transaction(rig, aorcmd, cmd_len, NULL, NULL);
}
@@ -1303,7 +1306,7 @@ int aor_get_channel(RIG *rig, vfo_t vfo, channel_t *chan, int read_only)
}
SNPRINTF(aorcmd, sizeof(aorcmd), "MR%c%02d" EOM,
- bank_base + channel_num / 100, mem_num);
+ bank_base + channel_num / 100, mem_num);
retval = aor_transaction(rig, aorcmd, strlen(aorcmd), chanbuf, &chan_len);
/* is the channel empty? */
@@ -1379,7 +1382,7 @@ int aor_get_chan_all_cb(RIG *rig, vfo_t vfo, chan_cb_t chan_cb, rig_ptr_t arg)
}
SNPRINTF(aorcmd, sizeof(aorcmd), "MA%c" EOM,
- priv->bank_base1);
+ priv->bank_base1);
for (i = 0; i < chan_count / LINES_PER_MA; i++)
{
@@ -1427,7 +1430,7 @@ int aor_get_chan_all_cb(RIG *rig, vfo_t vfo, chan_cb_t chan_cb, rig_ptr_t arg)
* get next line
*/
retval = read_string(&rig->state.rigport, (unsigned char *) chanbuf, BUFSZ,
- EOM, strlen(EOM), 0,1);
+ EOM, strlen(EOM), 0, 1);
if (retval < 0)
{
diff --git a/rigs/aor/ar2700.c b/rigs/aor/ar2700.c
index ddc6136bb..52dc7d42c 100644
--- a/rigs/aor/ar2700.c
+++ b/rigs/aor/ar2700.c
@@ -58,7 +58,8 @@
.funcs = RIG_FUNC_ABM, \
}
-static int format2700_mode(RIG *rig, char *buf, int buf_len, rmode_t mode, pbwidth_t width);
+static int format2700_mode(RIG *rig, char *buf, int buf_len, rmode_t mode,
+ pbwidth_t width);
static int parse2700_aor_mode(RIG *rig, char aormode, char aorwidth,
rmode_t *mode, pbwidth_t *width);
@@ -210,7 +211,8 @@ const struct rig_caps ar2700_caps =
#define AR2700_NFM '1'
#define AR2700_AM '2'
-int format2700_mode(RIG *rig, char *buf, int buf_len, rmode_t mode, pbwidth_t width)
+int format2700_mode(RIG *rig, char *buf, int buf_len, rmode_t mode,
+ pbwidth_t width)
{
int aormode;
diff --git a/rigs/aor/ar3000.c b/rigs/aor/ar3000.c
index ea08828bb..152ea39fc 100644
--- a/rigs/aor/ar3000.c
+++ b/rigs/aor/ar3000.c
@@ -210,7 +210,7 @@ static int ar3k_transaction(RIG *rig, const char *cmd, int cmd_len, char *data,
}
retval = read_string(&rs->rigport, (unsigned char *) data, BUFSZ,
- EOM, strlen(EOM), 0, 1);
+ EOM, strlen(EOM), 0, 1);
if (retval == -RIG_ETIMEOUT)
{
diff --git a/rigs/aor/ar3030.c b/rigs/aor/ar3030.c
index 3c7854414..6b6464a20 100644
--- a/rigs/aor/ar3030.c
+++ b/rigs/aor/ar3030.c
@@ -246,7 +246,7 @@ static int ar3030_transaction(RIG *rig, const char *cmd, int cmd_len,
{
/* expecting 0x0d0x0a on all commands so wait for the 0x0a */
retval = read_string(&rs->rigport, (unsigned char *) data, BUFSZ,
- "\x0a", 1, 0, 1);
+ "\x0a", 1, 0, 1);
if (retval == -RIG_ETIMEOUT)
{
@@ -482,8 +482,8 @@ int ar3030_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
else
{
SNPRINTF(mdbuf, sizeof(mdbuf), "%dB%c" CR,
- width < rig_passband_normal(rig, mode) ? 1 : 0,
- aormode);
+ width < rig_passband_normal(rig, mode) ? 1 : 0,
+ aormode);
}
retval = ar3030_transaction(rig, mdbuf, strlen(mdbuf), NULL, NULL);
diff --git a/rigs/aor/ar5000.c b/rigs/aor/ar5000.c
index 70e817140..2911d7849 100644
--- a/rigs/aor/ar5000.c
+++ b/rigs/aor/ar5000.c
@@ -79,7 +79,8 @@
}
-static int format5k_mode(RIG *rig, char *buf, int buf_len, rmode_t mode, pbwidth_t width);
+static int format5k_mode(RIG *rig, char *buf, int buf_len, rmode_t mode,
+ pbwidth_t width);
static int parse5k_aor_mode(RIG *rig, char aormode, char aorwidth,
rmode_t *mode, pbwidth_t *width);
@@ -398,7 +399,8 @@ const struct rig_caps ar5000a_caps =
#define AR5K_SAL '6'
#define AR5K_SAH '7'
-int format5k_mode(RIG *rig, char *buf, int buf_len, rmode_t mode, pbwidth_t width)
+int format5k_mode(RIG *rig, char *buf, int buf_len, rmode_t mode,
+ pbwidth_t width)
{
int aormode;
diff --git a/rigs/aor/sr2200.c b/rigs/aor/sr2200.c
index d39444b2b..b9f6acf40 100644
--- a/rigs/aor/sr2200.c
+++ b/rigs/aor/sr2200.c
@@ -305,7 +305,8 @@ static int sr2200_transaction(RIG *rig, const char *cmd, int cmd_len,
/*
* Do wait for a reply
*/
- retval = read_string(&rs->rigport, (unsigned char *) data, BUFSZ, EOM, strlen(EOM), 0, 1);
+ retval = read_string(&rs->rigport, (unsigned char *) data, BUFSZ, EOM,
+ strlen(EOM), 0, 1);
if (retval < 0)
{
diff --git a/rigs/barrett/950.c b/rigs/barrett/950.c
index c19d38593..1e9887cd0 100644
--- a/rigs/barrett/950.c
+++ b/rigs/barrett/950.c
@@ -200,7 +200,7 @@ int barrett950_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
return retval;
}
- if (strstr(response,"E5"))
+ if (strstr(response, "E5"))
{
freq_rx = freq_tx = 0;
rig_debug(RIG_DEBUG_VERBOSE, "%s: new channel being programmed\n", __func__);
@@ -224,7 +224,8 @@ int barrett950_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
// New freq so let's update the channel
// We do not support split mode -- too many writes to EEPROM to support it
- SNPRINTF((char *) cmd_buf, sizeof(cmd_buf), "PC%04dR%08.0lfT%08.0lf", chan, freq, freq);
+ SNPRINTF((char *) cmd_buf, sizeof(cmd_buf), "PC%04dR%08.0lfT%08.0lf", chan,
+ freq, freq);
retval = barrett_transaction(rig, cmd_buf, 0, &response);
if (retval != RIG_OK || strncmp(response, "OK", 2) != 0)
diff --git a/rigs/barrett/barrett.c b/rigs/barrett/barrett.c
index 17a04bd48..e31872118 100644
--- a/rigs/barrett/barrett.c
+++ b/rigs/barrett/barrett.c
@@ -273,16 +273,20 @@ int barrett_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
rig_strvfo(vfo), freq);
retval = rig_get_freq(rig, vfo, &tfreq);
+
if (retval != RIG_OK)
{
- rig_debug(RIG_DEBUG_VERBOSE, "%s: get_freq failed: %s\n", __func__, strerror(retval));
+ rig_debug(RIG_DEBUG_VERBOSE, "%s: get_freq failed: %s\n", __func__,
+ strerror(retval));
return retval;
}
+
if (tfreq == freq)
{
rig_debug(RIG_DEBUG_VERBOSE, "%s: freq not changing\n", __func__);
return RIG_OK;
}
+
// If we are not explicitly asking for VFO_B then we'll set the receive side also
if (vfo != RIG_VFO_B)
{
@@ -423,11 +427,14 @@ int barrett_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
if (retval != RIG_OK)
{
- rig_debug(RIG_DEBUG_ERR, "%s: get_mode failed %s\n", __func__, strerror(retval));
+ rig_debug(RIG_DEBUG_ERR, "%s: get_mode failed %s\n", __func__,
+ strerror(retval));
}
+
if (tmode == mode)
{
- rig_debug(RIG_DEBUG_VERBOSE, "%s: already mode %s so not changing\n", __func__, rig_strrmode(mode));
+ rig_debug(RIG_DEBUG_VERBOSE, "%s: already mode %s so not changing\n", __func__,
+ rig_strrmode(mode));
return RIG_OK;
}
diff --git a/rigs/codan/codan.c b/rigs/codan/codan.c
index c7443f099..08eb8ee06 100644
--- a/rigs/codan/codan.c
+++ b/rigs/codan/codan.c
@@ -302,7 +302,8 @@ int codan_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
rig_strvfo(vfo), freq);
// Purportedly can't do split so we just set VFOB=VFOA
- SNPRINTF(cmd_buf, sizeof(cmd_buf), "connect tcvr rf %.0f %.0f\rfreq", freq, freq);
+ SNPRINTF(cmd_buf, sizeof(cmd_buf), "connect tcvr rf %.0f %.0f\rfreq", freq,
+ freq);
char *response = NULL;
retval = codan_transaction(rig, cmd_buf, 0, &response);
@@ -395,7 +396,8 @@ int codan_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt)
rig_debug(RIG_DEBUG_VERBOSE, "%s: ptt=%d\n", __func__, ptt);
- SNPRINTF(cmd_buf, sizeof(cmd_buf), "connect tcvr rf ptt %s\rptt", ptt == 0 ? "off" : "on");
+ SNPRINTF(cmd_buf, sizeof(cmd_buf), "connect tcvr rf ptt %s\rptt",
+ ptt == 0 ? "off" : "on");
response = NULL;
retval = codan_transaction(rig, cmd_buf, 0, &response);
diff --git a/rigs/drake/drake.c b/rigs/drake/drake.c
index 9a2f28738..593876433 100644
--- a/rigs/drake/drake.c
+++ b/rigs/drake/drake.c
@@ -83,7 +83,7 @@ int drake_transaction(RIG *rig, const char *cmd, int cmd_len, char *data,
}
retval = read_string(&rs->rigport, (unsigned char *) data, BUFSZ,
- LF, 1, 0, 1);
+ LF, 1, 0, 1);
if (retval == -RIG_ETIMEOUT)
{
@@ -139,8 +139,10 @@ int drake_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
* 10Hz resolution
* TODO: round nearest?
*/
- SNPRINTF((char *) freqbuf, sizeof(freqbuf), "F%07u" EOM, (unsigned int)freq / 10);
- retval = drake_transaction(rig, (char *) freqbuf, strlen((char*)freqbuf), (char *) ackbuf,
+ SNPRINTF((char *) freqbuf, sizeof(freqbuf), "F%07u" EOM,
+ (unsigned int)freq / 10);
+ retval = drake_transaction(rig, (char *) freqbuf, strlen((char *)freqbuf),
+ (char *) ackbuf,
&ack_len);
return retval;
@@ -226,7 +228,8 @@ int drake_set_vfo(RIG *rig, vfo_t vfo)
SNPRINTF((char *) cmdbuf, sizeof(cmdbuf), "%c" EOM, vfo_function);
}
- retval = drake_transaction(rig, (char *) cmdbuf, strlen((char*)cmdbuf), (char *) ackbuf,
+ retval = drake_transaction(rig, (char *) cmdbuf, strlen((char *)cmdbuf),
+ (char *) ackbuf,
&ack_len);
return retval;
}
@@ -313,7 +316,8 @@ int drake_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
}
SNPRINTF((char *) mdbuf, sizeof(mdbuf), "M%c" EOM, mode_sel);
- retval = drake_transaction(rig, (char *) mdbuf, strlen((char*)mdbuf), (char *) ackbuf,
+ retval = drake_transaction(rig, (char *) mdbuf, strlen((char *)mdbuf),
+ (char *) ackbuf,
&ack_len);
if (retval != RIG_OK)
@@ -354,7 +358,8 @@ int drake_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
}
SNPRINTF((char *) mdbuf, sizeof(mdbuf), "W%c" EOM, width_sel);
- retval = drake_transaction(rig, (char *) mdbuf, strlen((char*)mdbuf), (char *) ackbuf,
+ retval = drake_transaction(rig, (char *) mdbuf, strlen((char *)mdbuf),
+ (char *) ackbuf,
&ack_len);
}
}
@@ -364,10 +369,11 @@ int drake_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
(mode == RIG_MODE_AM) || (mode == RIG_MODE_USB) || (mode == RIG_MODE_LSB))
{
SNPRINTF((char *) mdbuf, sizeof(mdbuf), "S%c" EOM,
- ((mode == RIG_MODE_AMS) || (mode == RIG_MODE_ECSSUSB)
- || (mode == RIG_MODE_ECSSLSB))
- ? 'O' : 'F');
- retval = drake_transaction(rig, (char *) mdbuf, strlen((char*)mdbuf), (char *) ackbuf,
+ ((mode == RIG_MODE_AMS) || (mode == RIG_MODE_ECSSUSB)
+ || (mode == RIG_MODE_ECSSLSB))
+ ? 'O' : 'F');
+ retval = drake_transaction(rig, (char *) mdbuf, strlen((char *)mdbuf),
+ (char *) ackbuf,
&ack_len);
}
@@ -491,9 +497,10 @@ int drake_set_ant(RIG *rig, vfo_t vfo, ant_t ant, value_t option)
int ack_len, retval;
SNPRINTF((char *) buf, sizeof(buf), "A%c" EOM,
- ant == RIG_ANT_1 ? '1' : (ant == RIG_ANT_2 ? '2' : 'C'));
+ ant == RIG_ANT_1 ? '1' : (ant == RIG_ANT_2 ? '2' : 'C'));
- retval = drake_transaction(rig, (char *) buf, strlen((char*)buf), (char *) ackbuf, &ack_len);
+ retval = drake_transaction(rig, (char *) buf, strlen((char *)buf),
+ (char *) ackbuf, &ack_len);
return retval;
}
@@ -913,6 +920,7 @@ int drake_vfo_op(RIG *rig, vfo_t vfo, vfo_op_t op)
default:
return -RIG_EINVAL;
}
+
len = strlen(buf);
retval = drake_transaction(rig, buf, len, buf[len - 1] == 0x0d ? ackbuf : NULL,
&ack_len);
@@ -1019,8 +1027,8 @@ int drake_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
case RIG_LEVEL_AGC:
SNPRINTF(buf, sizeof(buf), "A%c" EOM,
- val.i == RIG_AGC_OFF ? 'O' :
- (val.i == RIG_AGC_FAST ? 'F' : 'S'));
+ val.i == RIG_AGC_OFF ? 'O' :
+ (val.i == RIG_AGC_FAST ? 'F' : 'S'));
break;
default:
diff --git a/rigs/dummy/netampctl.c b/rigs/dummy/netampctl.c
index fc351bb03..35f6afc16 100644
--- a/rigs/dummy/netampctl.c
+++ b/rigs/dummy/netampctl.c
@@ -50,7 +50,8 @@ static int netampctl_transaction(AMP *amp, char *cmd, int len, char *buf)
return ret;
}
- ret = read_string(&->state.ampport, (unsigned char *) buf, BUF_MAX, "\n", sizeof("\n"), 0, 1);
+ ret = read_string(&->state.ampport, (unsigned char *) buf, BUF_MAX, "\n",
+ sizeof("\n"), 0, 1);
if (ret < 0)
{
@@ -93,7 +94,8 @@ static int netampctl_open(AMP *amp)
return -RIG_EPROTO;
}
- ret = read_string(&->state.ampport, (unsigned char *) buf, BUF_MAX, "\n", sizeof("\n"), 0, 1);
+ ret = read_string(&->state.ampport, (unsigned char *) buf, BUF_MAX, "\n",
+ sizeof("\n"), 0, 1);
if (ret <= 0)
{
@@ -102,7 +104,8 @@ static int netampctl_open(AMP *amp)
do
{
- ret = read_string(&->state.ampport, (unsigned char *) buf, BUF_MAX, "\n", sizeof("\n"), 0, 1);
+ ret = read_string(&->state.ampport, (unsigned char *) buf, BUF_MAX, "\n",
+ sizeof("\n"), 0, 1);
if (ret > 0)
{
diff --git a/rigs/dummy/netrigctl.c b/rigs/dummy/netrigctl.c
index d45e54296..9f667ceeb 100644
--- a/rigs/dummy/netrigctl.c
+++ b/rigs/dummy/netrigctl.c
@@ -77,7 +77,8 @@ static int netrigctl_transaction(RIG *rig, char *cmd, int len, char *buf)
return ret;
}
- ret = read_string(&rig->state.rigport, (unsigned char *) buf, BUF_MAX, "\n", 1, 0, 1);
+ ret = read_string(&rig->state.rigport, (unsigned char *) buf, BUF_MAX, "\n", 1,
+ 0, 1);
if (ret < 0)
{
@@ -308,14 +309,16 @@ static int netrigctl_open(RIG *rig)
return -RIG_EPROTO;
}
- ret = read_string(&rig->state.rigport, (unsigned char *) buf, BUF_MAX, "\n", 1, 0, 1);
+ ret = read_string(&rig->state.rigport, (unsigned char *) buf, BUF_MAX, "\n", 1,
+ 0, 1);
if (ret <= 0)
{
return (ret < 0) ? ret : -RIG_EPROTO;
}
- ret = read_string(&rig->state.rigport, (unsigned char *) buf, BUF_MAX, "\n", 1, 0, 1);
+ ret = read_string(&rig->state.rigport, (unsigned char *) buf, BUF_MAX, "\n", 1,
+ 0, 1);
if (ret <= 0)
{
@@ -326,7 +329,8 @@ static int netrigctl_open(RIG *rig)
for (i = 0; i < HAMLIB_FRQRANGESIZ; i++)
{
- ret = read_string(&rig->state.rigport, (unsigned char *) buf, BUF_MAX, "\n", 1, 0, 1);
+ ret = read_string(&rig->state.rigport, (unsigned char *) buf, BUF_MAX, "\n", 1,
+ 0, 1);
if (ret <= 0)
{
@@ -356,7 +360,8 @@ static int netrigctl_open(RIG *rig)
for (i = 0; i < HAMLIB_FRQRANGESIZ; i++)
{
- ret = read_string(&rig->state.rigport, (unsigned char *) buf, BUF_MAX, "\n", 1, 0, 1);
+ ret = read_string(&rig->state.rigport, (unsigned char *) buf, BUF_MAX, "\n", 1,
+ 0, 1);
if (ret <= 0)
{
@@ -398,7 +403,8 @@ static int netrigctl_open(RIG *rig)
for (i = 0; i < HAMLIB_TSLSTSIZ; i++)
{
- ret = read_string(&rig->state.rigport, (unsigned char *) buf, BUF_MAX, "\n", 1, 0, 1);
+ ret = read_string(&rig->state.rigport, (unsigned char *) buf, BUF_MAX, "\n", 1,
+ 0, 1);
if (ret <= 0)
{
@@ -422,7 +428,8 @@ static int netrigctl_open(RIG *rig)
for (i = 0; i < HAMLIB_FLTLSTSIZ; i++)
{
- ret = read_string(&rig->state.rigport, (unsigned char *) buf, BUF_MAX, "\n", 1, 0, 1);
+ ret = read_string(&rig->state.rigport, (unsigned char *) buf, BUF_MAX, "\n", 1,
+ 0, 1);
if (ret <= 0)
{
@@ -449,7 +456,8 @@ static int netrigctl_open(RIG *rig)
chan_t chan_list[HAMLIB_CHANLSTSIZ]; /*!< Channel list, zero ended */
#endif
- ret = read_string(&rig->state.rigport, (unsigned char *) buf, BUF_MAX, "\n", 1, 0, 1);
+ ret = read_string(&rig->state.rigport, (unsigned char *) buf, BUF_MAX, "\n", 1,
+ 0, 1);
if (ret <= 0)
{
@@ -458,7 +466,8 @@ static int netrigctl_open(RIG *rig)
rig->caps->max_rit = rs->max_rit = atol(buf);
- ret = read_string(&rig->state.rigport, (unsigned char *) buf, BUF_MAX, "\n", 1, 0, 1);
+ ret = read_string(&rig->state.rigport, (unsigned char *) buf, BUF_MAX, "\n", 1,
+ 0, 1);
if (ret <= 0)
{
@@ -467,7 +476,8 @@ static int netrigctl_open(RIG *rig)
rig->caps->max_xit = rs->max_xit = atol(buf);
- ret = read_string(&rig->state.rigport, (unsigned char *) buf, BUF_MAX, "\n", 1, 0, 1);
+ ret = read_string(&rig->state.rigport, (unsigned char *) buf, BUF_MAX, "\n", 1,
+ 0, 1);
if (ret <= 0)
{
@@ -476,7 +486,8 @@ static int netrigctl_open(RIG *rig)
rig->caps->max_ifshift = rs->max_ifshift = atol(buf);
- ret = read_string(&rig->state.rigport, (unsigned char *) buf, BUF_MAX, "\n", 1, 0, 1);
+ ret = read_string(&rig->state.rigport, (unsigned char *) buf, BUF_MAX, "\n", 1,
+ 0, 1);
if (ret <= 0)
{
@@ -485,7 +496,8 @@ static int netrigctl_open(RIG *rig)
rs->announces = atoi(buf);
- ret = read_string(&rig->state.rigport, (unsigned char *) buf, BUF_MAX, "\n", 1, 0, 1);
+ ret = read_string(&rig->state.rigport, (unsigned char *) buf, BUF_MAX, "\n", 1,
+ 0, 1);
if (ret <= 0)
{
@@ -512,7 +524,8 @@ static int netrigctl_open(RIG *rig)
rig->caps->preamp[ret] = rs->preamp[ret] = RIG_DBLST_END;
- ret = read_string(&rig->state.rigport, (unsigned char *) buf, BUF_MAX, "\n", 1, 0, 1);
+ ret = read_string(&rig->state.rigport, (unsigned char *) buf, BUF_MAX, "\n", 1,
+ 0, 1);
if (ret <= 0)
{
@@ -539,7 +552,8 @@ static int netrigctl_open(RIG *rig)
rig->caps->attenuator[ret] = rs->attenuator[ret] = RIG_DBLST_END;
- ret = read_string(&rig->state.rigport, (unsigned char *) buf, BUF_MAX, "\n", 1, 0, 1);
+ ret = read_string(&rig->state.rigport, (unsigned char *) buf, BUF_MAX, "\n", 1,
+ 0, 1);
if (ret <= 0)
{
@@ -548,7 +562,8 @@ static int netrigctl_open(RIG *rig)
rig->caps->has_get_func = rs->has_get_func = strtoll(buf, NULL, 0);
- ret = read_string(&rig->state.rigport, (unsigned char *) buf, BUF_MAX, "\n", 1, 0, 1);
+ ret = read_string(&rig->state.rigport, (unsigned char *) buf, BUF_MAX, "\n", 1,
+ 0, 1);
if (ret <= 0)
{
@@ -557,7 +572,8 @@ static int netrigctl_open(RIG *rig)
rig->caps->has_set_func = rs->has_set_func = strtoll(buf, NULL, 0);
- ret = read_string(&rig->state.rigport, (unsigned char *) buf, BUF_MAX, "\n", 1, 0, 1);
+ ret = read_string(&rig->state.rigport, (unsigned char *) buf, BUF_MAX, "\n", 1,
+ 0, 1);
if (ret <= 0)
{
@@ -579,7 +595,8 @@ static int netrigctl_open(RIG *rig)
#endif
- ret = read_string(&rig->state.rigport, (unsigned char *) buf, BUF_MAX, "\n", 1, 0, 1);
+ ret = read_string(&rig->state.rigport, (unsigned char *) buf, BUF_MAX, "\n", 1,
+ 0, 1);
if (ret <= 0)
{
@@ -588,7 +605,8 @@ static int netrigctl_open(RIG *rig)
rig->caps->has_set_level = rs->has_set_level = strtoll(buf, NULL, 0);
- ret = read_string(&rig->state.rigport, (unsigned char *) buf, BUF_MAX, "\n", 1, 0, 1);
+ ret = read_string(&rig->state.rigport, (unsigned char *) buf, BUF_MAX, "\n", 1,
+ 0, 1);
if (ret <= 0)
{
@@ -597,7 +615,8 @@ static int netrigctl_open(RIG *rig)
rs->has_get_parm = strtoll(buf, NULL, 0);
- ret = read_string(&rig->state.rigport, (unsigned char *) buf, BUF_MAX, "\n", 1, 0, 1);
+ ret = read_string(&rig->state.rigport, (unsigned char *) buf, BUF_MAX, "\n", 1,
+ 0, 1);
if (ret <= 0)
{
@@ -640,7 +659,8 @@ static int netrigctl_open(RIG *rig)
do
{
char setting[32], value[1024];
- ret = read_string(&rig->state.rigport, (unsigned char *) buf, BUF_MAX, "\n", 1, 0, 1);
+ ret = read_string(&rig->state.rigport, (unsigned char *) buf, BUF_MAX, "\n", 1,
+ 0, 1);
strtok(buf, "\r\n"); // chop the EOL
if (ret <= 0)
@@ -928,7 +948,7 @@ static int netrigctl_set_mode(RIG *rig, vfo_t vfo, rmode_t mode,
if (ret != RIG_OK) { return ret; }
SNPRINTF(cmd, sizeof(cmd), "M%s %s %li\n",
- vfostr, rig_strrmode(mode), width);
+ vfostr, rig_strrmode(mode), width);
ret = netrigctl_transaction(rig, cmd, strlen(cmd), buf);
@@ -970,7 +990,8 @@ static int netrigctl_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode,
*mode = rig_parse_mode(buf);
- ret = read_string(&rig->state.rigport, (unsigned char *) buf, BUF_MAX, "\n", 1, 0, 1);
+ ret = read_string(&rig->state.rigport, (unsigned char *) buf, BUF_MAX, "\n", 1,
+ 0, 1);
if (ret <= 0)
{
@@ -1542,7 +1563,7 @@ static int netrigctl_set_split_mode(RIG *rig, vfo_t vfo, rmode_t tx_mode,
if (ret != RIG_OK) { return ret; }
SNPRINTF(cmd, sizeof(cmd), "X%s %s %li\n",
- vfostr, rig_strrmode(tx_mode), tx_width);
+ vfostr, rig_strrmode(tx_mode), tx_width);
ret = netrigctl_transaction(rig, cmd, strlen(cmd), buf);
@@ -1583,7 +1604,8 @@ static int netrigctl_get_split_mode(RIG *rig, vfo_t vfo, rmode_t *tx_mode,
*tx_mode = rig_parse_mode(buf);
- ret = read_string(&rig->state.rigport, (unsigned char *) buf, BUF_MAX, "\n", 1, 0, 1);
+ ret = read_string(&rig->state.rigport, (unsigned char *) buf, BUF_MAX, "\n", 1,
+ 0, 1);
if (ret <= 0)
{
@@ -1650,7 +1672,8 @@ static int netrigctl_get_split_vfo(RIG *rig, vfo_t vfo, split_t *split,
*split = atoi(buf);
- ret = read_string(&rig->state.rigport, (unsigned char *) buf, BUF_MAX, "\n", 1, 0, 1);
+ ret = read_string(&rig->state.rigport, (unsigned char *) buf, BUF_MAX, "\n", 1,
+ 0, 1);
if (ret <= 0)
{
@@ -1914,7 +1937,7 @@ static int netrigctl_set_level(RIG *rig, vfo_t vfo, setting_t level,
if (ret != RIG_OK) { return ret; }
SNPRINTF(cmd, sizeof(cmd), "L%s %s %s\n", vfostr, rig_strlevel(level),
- lstr);
+ lstr);
ret = netrigctl_transaction(rig, cmd, strlen(cmd), buf);
@@ -2172,7 +2195,8 @@ static int netrigctl_get_ant(RIG *rig, vfo_t vfo, ant_t ant, value_t *option,
ret);
}
- ret = read_string(&rig->state.rigport, (unsigned char *) buf, BUF_MAX, "\n", 1, 0, 1);
+ ret = read_string(&rig->state.rigport, (unsigned char *) buf, BUF_MAX, "\n", 1,
+ 0, 1);
if (ret <= 0)
{
@@ -2567,7 +2591,8 @@ static int netrigctl_mW2power(RIG *rig, float *power, unsigned int mwpower,
ENTERFUNC;
- SNPRINTF(cmdbuf, sizeof(cmdbuf), "\\mW2power %u %.0f %s\n", mwpower, freq, rig_strrmode(mode));
+ SNPRINTF(cmdbuf, sizeof(cmdbuf), "\\mW2power %u %.0f %s\n", mwpower, freq,
+ rig_strrmode(mode));
ret = netrigctl_transaction(rig, cmdbuf, strlen(cmdbuf), buf);
if (ret <= 0)
diff --git a/rigs/dummy/netrotctl.c b/rigs/dummy/netrotctl.c
index 08e900b01..fe066cc5c 100644
--- a/rigs/dummy/netrotctl.c
+++ b/rigs/dummy/netrotctl.c
@@ -55,7 +55,8 @@ static int netrotctl_transaction(ROT *rot, char *cmd, int len, char *buf)
return ret;
}
- ret = read_string(&rot->state.rotport, (unsigned char *) buf, BUF_MAX, "\n", sizeof("\n"), 0, 1);
+ ret = read_string(&rot->state.rotport, (unsigned char *) buf, BUF_MAX, "\n",
+ sizeof("\n"), 0, 1);
if (ret < 0)
{
@@ -98,14 +99,16 @@ static int netrotctl_open(ROT *rot)
return -RIG_EPROTO;
}
- ret = read_string(&rot->state.rotport, (unsigned char *) buf, BUF_MAX, "\n", sizeof("\n"), 0, 1);
+ ret = read_string(&rot->state.rotport, (unsigned char *) buf, BUF_MAX, "\n",
+ sizeof("\n"), 0, 1);
if (ret <= 0)
{
return (ret < 0) ? ret : -RIG_EPROTO;
}
- ret = read_string(&rot->state.rotport, (unsigned char *) buf, BUF_MAX, "\n", sizeof("\n"), 0, 1);
+ ret = read_string(&rot->state.rotport, (unsigned char *) buf, BUF_MAX, "\n",
+ sizeof("\n"), 0, 1);
if (ret <= 0)
{
@@ -114,7 +117,8 @@ static int netrotctl_open(ROT *rot)
rs->min_az = atof(buf);
- ret = read_string(&rot->state.rotport, (unsigned char *) buf, BUF_MAX, "\n", sizeof("\n"), 0, 1);
+ ret = read_string(&rot->state.rotport, (unsigned char *) buf, BUF_MAX, "\n",
+ sizeof("\n"), 0, 1);
if (ret <= 0)
{
@@ -123,7 +127,8 @@ static int netrotctl_open(ROT *rot)
rs->max_az = atof(buf);
- ret = read_string(&rot->state.rotport, (unsigned char *) buf, BUF_MAX, "\n", sizeof("\n"), 0, 1);
+ ret = read_string(&rot->state.rotport, (unsigned char *) buf, BUF_MAX, "\n",
+ sizeof("\n"), 0, 1);
if (ret <= 0)
{
@@ -132,7 +137,8 @@ static int netrotctl_open(ROT *rot)
rs->min_el = atof(buf);
- ret = read_string(&rot->state.rotport, (unsigned char *) buf, BUF_MAX, "\n", sizeof("\n"), 0, 1);
+ ret = read_string(&rot->state.rotport, (unsigned char *) buf, BUF_MAX, "\n",
+ sizeof("\n"), 0, 1);
if (ret <= 0)
{
@@ -196,7 +202,8 @@ static int netrotctl_get_position(ROT *rot, azimuth_t *az, elevation_t *el)
*az = atof(buf);
- ret = read_string(&rot->state.rotport, (unsigned char *) buf, BUF_MAX, "\n", sizeof("\n"), 0, 1);
+ ret = read_string(&rot->state.rotport, (unsigned char *) buf, BUF_MAX, "\n",
+ sizeof("\n"), 0, 1);
if (ret <= 0)
{
diff --git a/rigs/dummy/tci1x.c b/rigs/dummy/tci1x.c
index 10ab84f23..048cf935a 100644
--- a/rigs/dummy/tci1x.c
+++ b/rigs/dummy/tci1x.c
@@ -261,10 +261,10 @@ static int check_vfo(vfo_t vfo)
break; // will default to A in which_vfo
default:
- return(FALSE);
+ return (FALSE);
}
- return(TRUE);
+ return (TRUE);
}
/*
@@ -509,7 +509,7 @@ static const char *modeMapGetTCI(rmode_t modeHamlib)
static rmode_t modeMapGetHamlib(const char *modeTCI)
{
int i;
- char modeTCICheck[MAXBUFLEN+2];
+ char modeTCICheck[MAXBUFLEN + 2];
SNPRINTF(modeTCICheck, sizeof(modeTCICheck), "|%s|", modeTCI);
@@ -521,13 +521,13 @@ static rmode_t modeMapGetHamlib(const char *modeTCI)
if (modeMap[i].mode_tci1x
&& strcmp(modeMap[i].mode_tci1x, modeTCICheck) == 0)
{
- return(modeMap[i].mode_hamlib);
+ return (modeMap[i].mode_hamlib);
}
}
rig_debug(RIG_DEBUG_TRACE, "%s: mode requested: %s, not in modeMap\n", __func__,
modeTCI);
- return(RIG_MODE_NONE);
+ return (RIG_MODE_NONE);
}
@@ -940,7 +940,7 @@ static int tci1x_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
}
SNPRINTF(cmd_arg, sizeof(cmd_arg),
- "%.0f", freq);
+ "%.0f", freq);
value_t val;
rig_get_ext_parm(rig, TOK_TCI1X_VERIFY_FREQ, &val);
@@ -997,8 +997,8 @@ static int tci1x_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt)
}
SNPRINTF(cmd_arg, sizeof(cmd_arg),
- "%d",
- ptt);
+ "%d",
+ ptt);
value_t val;
char *cmd = "rig.set_ptt";
@@ -1196,7 +1196,8 @@ static int tci1x_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
if (p) { *p = 0; } // remove any other pipe
- SNPRINTF(cmd_arg, sizeof(cmd_arg), "%s", pttmode);
+ SNPRINTF(cmd_arg, sizeof(cmd_arg),
+ "%s", pttmode);
free(ttmode);
if (!priv->has_get_modeA)
@@ -1252,8 +1253,9 @@ static int tci1x_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
// Need to update the bandwidth
if (width > 0 && needBW)
{
- SNPRINTF(cmd_arg, sizeof(cmd_arg), "%ld",
- width);
+ SNPRINTF(cmd_arg, sizeof(cmd_arg),
+ "%ld",
+ width);
retval = tci1x_transaction(rig, "rig.set_bandwidth", cmd_arg, NULL, 0);
@@ -1489,8 +1491,9 @@ static int tci1x_set_vfo(RIG *rig, vfo_t vfo)
vfo = rig->state.current_vfo;
}
- SNPRINTF(cmd_arg, sizeof(cmd_arg), "%s",
- vfo == RIG_VFO_A ? "A" : "B");
+ SNPRINTF(cmd_arg, sizeof(cmd_arg),
+ "%s",
+ vfo == RIG_VFO_A ? "A" : "B");
retval = tci1x_transaction(rig, "rig.set_AB", cmd_arg, NULL, 0);
if (retval != RIG_OK)
@@ -1507,8 +1510,9 @@ static int tci1x_set_vfo(RIG *rig, vfo_t vfo)
/* so if we are in split and asked for A we have to turn split back on */
if (priv->split && vfo == RIG_VFO_A)
{
- SNPRINTF(cmd_arg, sizeof(cmd_arg), "%d",
- priv->split);
+ SNPRINTF(cmd_arg, sizeof(cmd_arg),
+ "%d",
+ priv->split);
retval = tci1x_transaction(rig, "rig.set_split", cmd_arg, NULL, 0);
if (retval < 0)
@@ -1601,8 +1605,8 @@ static int tci1x_set_split_freq(RIG *rig, vfo_t vfo, freq_t tx_freq)
if (tx_freq == qtx_freq) { RETURNFUNC(RIG_OK); }
SNPRINTF(cmd_arg, sizeof(cmd_arg),
- "%.6f",
- tx_freq);
+ "%.6f",
+ tx_freq);
retval = tci1x_transaction(rig, "rig.set_vfoB", cmd_arg, NULL, 0);
if (retval < 0)
@@ -1661,8 +1665,9 @@ static int tci1x_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, vfo_t tx_vfo)
RETURNFUNC(RIG_OK); // just return OK and ignore this
}
- SNPRINTF(cmd_arg, sizeof(cmd_arg), "%d",
- split);
+ SNPRINTF(cmd_arg, sizeof(cmd_arg),
+ "%d",
+ split);
retval = tci1x_transaction(rig, "rig.set_split", cmd_arg, NULL, 0);
if (retval < 0)
@@ -1813,8 +1818,8 @@ static int tci1x_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
}
SNPRINTF(cmd_arg, sizeof(cmd_arg),
- "<%s>%d%s>",
- param_type, (int)val.f, param_type);
+ "<%s>%d%s>",
+ param_type, (int)val.f, param_type);
retval = tci1x_transaction(rig, cmd, cmd_arg, NULL, 0);
diff --git a/rigs/dummy/trxmanager.c b/rigs/dummy/trxmanager.c
index 3a5fe7eb0..e9efc3e20 100644
--- a/rigs/dummy/trxmanager.c
+++ b/rigs/dummy/trxmanager.c
@@ -241,7 +241,8 @@ static int read_transaction(RIG *rig, char *response, int response_len)
rig_debug(RIG_DEBUG_TRACE, "%s\n", __func__);
- len = read_string(&rs->rigport, (unsigned char *) response, response_len, delims,
+ len = read_string(&rs->rigport, (unsigned char *) response, response_len,
+ delims,
strlen(delims), 0, 1);
if (len <= 0)
diff --git a/rigs/elad/elad.c b/rigs/elad/elad.c
index 599ef081b..08ad79ec1 100644
--- a/rigs/elad/elad.c
+++ b/rigs/elad/elad.c
@@ -241,7 +241,7 @@ transaction_write:
gives a reply so we can read any error replies from the actual
command being sent without blocking */
if (RIG_OK != (retval = write_block(&rs->rigport,
- (unsigned char *) priv->verify_cmd, strlen(priv->verify_cmd))))
+ (unsigned char *) priv->verify_cmd, strlen(priv->verify_cmd))))
{
goto transaction_quit;
}
@@ -252,7 +252,7 @@ transaction_read:
len = min(datasize ? datasize + 1 : strlen(priv->verify_cmd) + 13,
ELAD_MAX_BUF_LEN);
retval = read_string(&rs->rigport, (unsigned char *) buffer, len,
- cmdtrm, strlen(cmdtrm), 0, 1);
+ cmdtrm, strlen(cmdtrm), 0, 1);
if (retval < 0)
{
diff --git a/rigs/icmarine/icmarine.c b/rigs/icmarine/icmarine.c
index 692a44cd3..29348513c 100644
--- a/rigs/icmarine/icmarine.c
+++ b/rigs/icmarine/icmarine.c
@@ -263,9 +263,9 @@ int icmarine_transaction(RIG *rig, const char *cmd, const char *param,
/* command formatting */
SNPRINTF(cmdbuf, BUFSZ, "$PICOA,%02d,%02u,%s",
- CONTROLLER_ID,
- priv->remote_id,
- cmd);
+ CONTROLLER_ID,
+ priv->remote_id,
+ cmd);
cmd_len = strlen(cmdbuf);
if (param)
@@ -292,7 +292,8 @@ int icmarine_transaction(RIG *rig, const char *cmd, const char *param,
/*
* Transceiver sends an echo of cmd followed by a CR/LF
*/
- retval = read_string(&rs->rigport, (unsigned char *) respbuf, BUFSZ, LF, strlen(LF), 0, 1);
+ retval = read_string(&rs->rigport, (unsigned char *) respbuf, BUFSZ, LF,
+ strlen(LF), 0, 1);
if (retval < 0)
{
diff --git a/rigs/icom/frame.c b/rigs/icom/frame.c
index f231d5e5a..5081bd7ec 100644
--- a/rigs/icom/frame.c
+++ b/rigs/icom/frame.c
@@ -44,7 +44,8 @@
* NB: the frame array must be big enough to hold the frame.
* The smallest frame is 6 bytes, the biggest is at least 13 bytes.
*/
-int make_cmd_frame(unsigned char frame[], unsigned char re_id, unsigned char ctrl_id,
+int make_cmd_frame(unsigned char frame[], unsigned char re_id,
+ unsigned char ctrl_id,
unsigned char cmd, int subcmd,
const unsigned char *data, int data_len)
{
@@ -83,7 +84,7 @@ int make_cmd_frame(unsigned char frame[], unsigned char re_id, unsigned char ctr
frame[i++] = FI; /* EOM code */
- return(i);
+ return (i);
}
int icom_frame_fix_preamble(int frame_len, unsigned char *frame)
@@ -101,7 +102,7 @@ int icom_frame_fix_preamble(int frame_len, unsigned char *frame)
{
rig_debug(RIG_DEBUG_WARN, "%s: invalid Icom CI-V frame, no preamble found\n",
__func__);
- return(-RIG_EPROTO);
+ return (-RIG_EPROTO);
}
return frame_len;
@@ -196,16 +197,22 @@ int icom_one_transaction(RIG *rig, unsigned char cmd, int subcmd,
set_transaction_inactive(rig);
RETURNFUNC(-RIG_EPROTO);
}
+
// we might have 0xfe string during rig wakeup
- rig_debug(RIG_DEBUG_TRACE, "%s: DEBUG retval=%d, frm_len=%d, cmd=0x%02x\n", __func__, retval, frm_len, cmd);
+ rig_debug(RIG_DEBUG_TRACE, "%s: DEBUG retval=%d, frm_len=%d, cmd=0x%02x\n",
+ __func__, retval, frm_len, cmd);
+
if (retval != frm_len && cmd == C_SET_PWR)
{
- rig_debug(RIG_DEBUG_TRACE, "%s: removing 0xfe power up echo, len=%d", __func__, frm_len);
- while(buf[2] == 0xfe)
+ rig_debug(RIG_DEBUG_TRACE, "%s: removing 0xfe power up echo, len=%d", __func__,
+ frm_len);
+
+ while (buf[2] == 0xfe)
{
- memmove(buf,&buf[1],frm_len--);
+ memmove(buf, &buf[1], frm_len--);
}
- dump_hex(buf,frm_len);
+
+ dump_hex(buf, frm_len);
}
switch (buf[retval - 1])
@@ -458,7 +465,8 @@ static const char icom_block_end[2] = { FI, COL};
* TODO: strips padding/collisions
* FIXME: check return codes/bytes read
*/
-static int read_icom_frame_generic(hamlib_port_t *p, const unsigned char rxbuffer[],
+static int read_icom_frame_generic(hamlib_port_t *p,
+ const unsigned char rxbuffer[],
size_t rxbuffer_len, int direct)
{
int read = 0;
@@ -476,27 +484,28 @@ static int read_icom_frame_generic(hamlib_port_t *p, const unsigned char rxbuffe
do
{
int i;
+
if (direct)
{
i = read_string_direct(p, rx_ptr, MAXFRAMELEN - read,
- icom_block_end, icom_block_end_length, 0, 1);
+ icom_block_end, icom_block_end_length, 0, 1);
}
else
{
i = read_string(p, rx_ptr, MAXFRAMELEN - read,
- icom_block_end, icom_block_end_length, 0, 1);
+ icom_block_end, icom_block_end_length, 0, 1);
}
if (i < 0 && i != RIG_BUSBUSY) /* die on errors */
{
- return(i);
+ return (i);
}
if (i == 0) /* nothing read?*/
{
if (--retries <= 0) /* Tried enough times? */
{
- return(read);
+ return (read);
}
}
@@ -510,7 +519,7 @@ static int read_icom_frame_generic(hamlib_port_t *p, const unsigned char rxbuffe
while ((read < rxbuffer_len) && (rxbuffer[read - 1] != FI)
&& (rxbuffer[read - 1] != COL));
- return(read);
+ return (read);
}
int read_icom_frame(hamlib_port_t *p, const unsigned char rxbuffer[],
diff --git a/rigs/icom/ic92d.c b/rigs/icom/ic92d.c
index 69e3687ab..76d273bbe 100644
--- a/rigs/icom/ic92d.c
+++ b/rigs/icom/ic92d.c
@@ -248,7 +248,8 @@ const char *ic92d_get_info(RIG *rig)
return NULL;
}
- SNPRINTF(info, sizeof(info), "ID %02x%02x%02x\n", ackbuf[1], ackbuf[2], ackbuf[3]);
+ SNPRINTF(info, sizeof(info), "ID %02x%02x%02x\n", ackbuf[1], ackbuf[2],
+ ackbuf[3]);
return info;
}
diff --git a/rigs/icom/icom.c b/rigs/icom/icom.c
index d457e38ad..452fda621 100644
--- a/rigs/icom/icom.c
+++ b/rigs/icom/icom.c
@@ -754,8 +754,10 @@ int icom_get_usb_echo_off(RIG *rig)
// we should have a freq response so we'll read it and don't really care
// flushing doesn't always work as it depends on timing
retval = read_icom_frame(&rs->rigport, buf, sizeof(buf));
- rig_debug(RIG_DEBUG_VERBOSE, "%s: USB echo on detected, get freq retval=%d\n", __func__, retval);
- if (retval <= 0) RETURNFUNC(-RIG_ETIMEOUT);
+ rig_debug(RIG_DEBUG_VERBOSE, "%s: USB echo on detected, get freq retval=%d\n",
+ __func__, retval);
+
+ if (retval <= 0) { RETURNFUNC(-RIG_ETIMEOUT); }
}
else
{
@@ -940,7 +942,8 @@ icom_rig_open(RIG *rig)
retry_open:
retval_echo = icom_get_usb_echo_off(rig);
- rig_debug(RIG_DEBUG_TRACE, "%s: echo status result=%d\n", __func__, retval_echo);
+ rig_debug(RIG_DEBUG_TRACE, "%s: echo status result=%d\n", __func__,
+ retval_echo);
if (retval_echo == 0 || retval_echo == 1)
{
@@ -953,17 +956,19 @@ retry_open:
if (retval == RIG_OK) // then we know our echo status
{
- rig_debug(RIG_DEBUG_TRACE, "%s: echo status known, getting frequency\n", __func__);
+ rig_debug(RIG_DEBUG_TRACE, "%s: echo status known, getting frequency\n",
+ __func__);
rs->rigport.retry = 0;
rig->state.current_vfo = icom_current_vfo(rig);
// some rigs like the IC7100 still echo when in standby
// so asking for freq now should timeout if such a rig
freq_t tfreq;
retval = rig_get_freq(rig, RIG_VFO_CURR, &tfreq);
+
if (retval != RIG_OK)
{
rig_debug(RIG_DEBUG_ERR, "%s: rig error getting frequency retry=%d, err=%s\n",
- __func__, retry_flag, rigerror(retval));
+ __func__, retry_flag, rigerror(retval));
}
}
else
@@ -984,11 +989,12 @@ retry_open:
rs->rigport.retry = retry_save;
rig_debug(RIG_DEBUG_ERR, "%s: rig_set_powerstat failed: %s\n", __func__,
- rigerror(retval));
+ rigerror(retval));
if (retval == RIG_ENIMPL || retval == RIG_ENAVAIL)
{
- rig_debug(RIG_DEBUG_ERR, "%s: rig_set_powerstat not implemented for rig\n", __func__);
+ rig_debug(RIG_DEBUG_ERR, "%s: rig_set_powerstat not implemented for rig\n",
+ __func__);
RETURNFUNC(-RIG_ECONF);
}
@@ -2527,7 +2533,9 @@ int icom_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width)
else
{
priv_data->filter = 0;
- if (mode_len == 2) priv_data->filter = modebuf[2];
+
+ if (mode_len == 2) { priv_data->filter = modebuf[2]; }
+
rig_debug(RIG_DEBUG_TRACE,
"%s: modebuf[0]=0x%02x, modebuf[1]=0x%02x, mode_len=%d\n", __func__, modebuf[0],
modebuf[1], mode_len);
@@ -6932,7 +6940,7 @@ int icom_set_func(RIG *rig, vfo_t vfo, setting_t func, int status)
case RIG_FUNC_DUAL_WATCH:
if ((rig->caps->rig_model == RIG_MODEL_IC9100) ||
- (rig->caps->rig_model == RIG_MODEL_IC9700))
+ (rig->caps->rig_model == RIG_MODEL_IC9700))
{
fct_cn = C_CTL_FUNC;
fct_sc = S_MEM_DUALMODE;
@@ -7171,7 +7179,7 @@ int icom_get_func(RIG *rig, vfo_t vfo, setting_t func, int *status)
case RIG_FUNC_DUAL_WATCH:
if ((rig->caps->rig_model == RIG_MODEL_IC9100) ||
- (rig->caps->rig_model == RIG_MODEL_IC9700))
+ (rig->caps->rig_model == RIG_MODEL_IC9700))
{
fct_cn = C_CTL_FUNC;
fct_sc = S_MEM_DUALMODE;
@@ -7181,6 +7189,7 @@ int icom_get_func(RIG *rig, vfo_t vfo, setting_t func, int *status)
fct_cn = C_SET_VFO;
fct_sc = S_DUAL;
}
+
break;
case RIG_FUNC_SATMODE:
@@ -8735,7 +8744,8 @@ static int icom_parse_spectrum_frame(RIG *rig, size_t length,
RETURNFUNC(RIG_OK);
}
-int icom_is_async_frame(RIG *rig, size_t frame_length, const unsigned char *frame)
+int icom_is_async_frame(RIG *rig, size_t frame_length,
+ const unsigned char *frame)
{
if (frame_length < ACKFRMLEN)
{
@@ -8767,7 +8777,8 @@ int icom_process_async_frame(RIG *rig, size_t frame_length,
*/
switch (frame[4])
{
- case C_SND_FREQ: {
+ case C_SND_FREQ:
+ {
// TODO: The freq length might be less than 4 or 5 bytes on older rigs!
// TODO: Disable cache timeout for frequency after first transceive packet once we figure out how to get active VFO reliably with transceive updates
// TODO: rig_set_cache_timeout_ms(rig, HAMLIB_CACHE_FREQ, HAMLIB_CACHE_ALWAYS);
@@ -8790,6 +8801,7 @@ int icom_process_async_frame(RIG *rig, size_t frame_length,
{
icom_parse_spectrum_frame(rig, frame_length - (6 + 1), frame + 6);
}
+
break;
default:
@@ -8873,7 +8885,8 @@ int icom_decode_event(RIG *rig)
RETURNFUNC(icom_process_async_frame(rig, frm_len, buf));
}
-int icom_read_frame_direct(RIG *rig, size_t buffer_length, const unsigned char *buffer)
+int icom_read_frame_direct(RIG *rig, size_t buffer_length,
+ const unsigned char *buffer)
{
return read_icom_frame_direct(&rig->state.rigport, buffer, buffer_length);
}
@@ -9302,12 +9315,12 @@ DECLARE_PROBERIG_BACKEND(icom)
if (!port)
{
- return(RIG_MODEL_NONE);
+ return (RIG_MODEL_NONE);
}
if (port->type.rig != RIG_PORT_SERIAL)
{
- return(RIG_MODEL_NONE);
+ return (RIG_MODEL_NONE);
}
port->write_delay = port->post_write_delay = 0;
@@ -9326,7 +9339,7 @@ DECLARE_PROBERIG_BACKEND(icom)
if (retval != RIG_OK)
{
- return(RIG_MODEL_NONE);
+ return (RIG_MODEL_NONE);
}
/*
@@ -9365,7 +9378,7 @@ DECLARE_PROBERIG_BACKEND(icom)
* is this a CI-V device?
*/
close(port->fd);
- return(RIG_MODEL_NONE);
+ return (RIG_MODEL_NONE);
}
else if (buf[4] == NAK)
{
@@ -9476,11 +9489,11 @@ DECLARE_PROBERIG_BACKEND(icom)
*/
if (model != RIG_MODEL_NONE)
{
- return(model);
+ return (model);
}
}
- return(model);
+ return (model);
}
/*
@@ -9578,5 +9591,5 @@ DECLARE_INITRIG_BACKEND(icom)
rig_register(&x6100_caps);
rig_register(&g90_caps);
- return(RIG_OK);
+ return (RIG_OK);
}
diff --git a/rigs/icom/optoscan.c b/rigs/icom/optoscan.c
index 3990b79bc..a955b84b1 100644
--- a/rigs/icom/optoscan.c
+++ b/rigs/icom/optoscan.c
@@ -165,10 +165,10 @@ const char *optoscan_get_info(RIG *rig)
}
SNPRINTF(info, sizeof(info), "OptoScan%c%c%c, software version %d.%d, "
- "interface version %d.%d\n",
- ackbuf[2], ackbuf[3], ackbuf[4],
- ackbuf[5] >> 4, ackbuf[5] & 0xf,
- ackbuf[6] >> 4, ackbuf[6] & 0xf);
+ "interface version %d.%d\n",
+ ackbuf[2], ackbuf[3], ackbuf[4],
+ ackbuf[5] >> 4, ackbuf[5] & 0xf,
+ ackbuf[6] >> 4, ackbuf[6] & 0xf);
return info;
}
diff --git a/rigs/icom/xiegu.c b/rigs/icom/xiegu.c
index 845ec8f65..78af2db92 100644
--- a/rigs/icom/xiegu.c
+++ b/rigs/icom/xiegu.c
@@ -123,9 +123,11 @@ static int x108g_rig_open(RIG *rig)
int retval;
retval = icom_rig_open(rig);
+
if (retval != RIG_OK)
{
- rig_debug(RIG_DEBUG_ERR, "%s: rig_open failed with %s\n", __func__, rigerror(retval));
+ rig_debug(RIG_DEBUG_ERR, "%s: rig_open failed with %s\n", __func__,
+ rigerror(retval));
RETURNFUNC(retval);
}
diff --git a/rigs/jrc/jrc.c b/rigs/jrc/jrc.c
index 9854e25ec..ca23190f7 100644
--- a/rigs/jrc/jrc.c
+++ b/rigs/jrc/jrc.c
@@ -65,7 +65,8 @@
* Otherwise, you'll get a nice seg fault. You've been warned!
* TODO: error case handling
*/
-int jrc_transaction(RIG *rig, const char *cmd, int cmd_len, char *data, int *data_len)
+int jrc_transaction(RIG *rig, const char *cmd, int cmd_len, char *data,
+ int *data_len)
{
int retval;
struct rig_state *rs;
@@ -90,7 +91,8 @@ int jrc_transaction(RIG *rig, const char *cmd, int cmd_len, char *data, int *dat
return 0;
}
- retval = read_string(&rs->rigport, (unsigned char *) data, BUFSZ, EOM, strlen(EOM), 0, 1);
+ retval = read_string(&rs->rigport, (unsigned char *) data, BUFSZ, EOM,
+ strlen(EOM), 0, 1);
set_transaction_inactive(rig);
@@ -295,7 +297,8 @@ int jrc_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
// cppcheck-suppress *
// suppressing bogus cppcheck error in ver 1.90
- SNPRINTF(freqbuf, sizeof(freqbuf), "F%0*"PRIll EOM, priv->max_freq_len, (int64_t)freq);
+ SNPRINTF(freqbuf, sizeof(freqbuf), "F%0*"PRIll EOM, priv->max_freq_len,
+ (int64_t)freq);
return jrc_transaction(rig, freqbuf, strlen(freqbuf), NULL, NULL);
}
@@ -378,7 +381,8 @@ int jrc_set_vfo(RIG *rig, vfo_t vfo)
SNPRINTF((char *) cmdbuf, sizeof(cmdbuf), "%c" EOM, vfo_function);
- retval = jrc_transaction(rig, (char *) cmdbuf, strlen((char*)cmdbuf), NULL, NULL);
+ retval = jrc_transaction(rig, (char *) cmdbuf, strlen((char *)cmdbuf), NULL,
+ NULL);
return retval;
}
@@ -476,7 +480,7 @@ int jrc_set_func(RIG *rig, vfo_t vfo, setting_t func, int status)
{
case RIG_FUNC_FAGC:
/* FIXME: FAGC levels */
- SNPRINTF(cmdbuf, sizeof(cmdbuf), "G%d" EOM, status ? 1 : 2);
+ SNPRINTF(cmdbuf, sizeof(cmdbuf), "G%d" EOM, status ? 1 : 2);
return jrc_transaction(rig, cmdbuf, strlen(cmdbuf), NULL, NULL);
@@ -734,8 +738,8 @@ int jrc_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
if (val.i < 10)
{
SNPRINTF(cmdbuf, sizeof(cmdbuf), "G%d" EOM,
- val.i == RIG_AGC_SLOW ? 0 :
- val.i == RIG_AGC_FAST ? 1 : 2);
+ val.i == RIG_AGC_SLOW ? 0 :
+ val.i == RIG_AGC_FAST ? 1 : 2);
}
else
{
@@ -1041,7 +1045,7 @@ int jrc_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
case RIG_LEVEL_CWPITCH:
SNPRINTF(cwbuf, sizeof(cwbuf), "%s" EOM, priv->cw_pitch);
cw_len = strlen(cwbuf);
-
+
retval = jrc_transaction(rig, cwbuf, strlen(cwbuf), lvlbuf, &lvl_len);
if (retval != RIG_OK)
@@ -1118,14 +1122,14 @@ int jrc_set_parm(RIG *rig, setting_t parm, value_t val)
case RIG_PARM_BEEP:
SNPRINTF(cmdbuf, sizeof(cmdbuf), "U%0*d" EOM, priv->beep_len,
- (priv->beep + val.i) ? 1 : 0);
+ (priv->beep + val.i) ? 1 : 0);
return jrc_transaction(rig, cmdbuf, strlen(cmdbuf), NULL, NULL);
case RIG_PARM_TIME:
minutes = val.i / 60;
SNPRINTF(cmdbuf, sizeof(cmdbuf), "R1%02d%02d" EOM,
- minutes / 60, minutes % 60);
+ minutes / 60, minutes % 60);
return jrc_transaction(rig, cmdbuf, strlen(cmdbuf), NULL, NULL);
@@ -1430,7 +1434,8 @@ int jrc_set_chan(RIG *rig, vfo_t vfo, const channel_t *chan)
return retval;
}
- SNPRINTF(cmdbuf + 7, sizeof(cmdbuf)-7, "%0*"PRIll, priv->max_freq_len, (int64_t)chan->freq);
+ SNPRINTF(cmdbuf + 7, sizeof(cmdbuf) - 7, "%0*"PRIll, priv->max_freq_len,
+ (int64_t)chan->freq);
if (priv->mem_len == 17)
{
@@ -1447,8 +1452,9 @@ int jrc_set_chan(RIG *rig, vfo_t vfo, const channel_t *chan)
}
else
{
- SNPRINTF(cmdbuf + priv->mem_len - 4, sizeof(cmdbuf)-(priv->mem_len - 4), "%03d",
- chan->levels[rig_setting2idx(RIG_LEVEL_AGC)].i);
+ SNPRINTF(cmdbuf + priv->mem_len - 4, sizeof(cmdbuf) - (priv->mem_len - 4),
+ "%03d",
+ chan->levels[rig_setting2idx(RIG_LEVEL_AGC)].i);
}
return jrc_transaction(rig, cmdbuf, strlen(cmdbuf), NULL, NULL);
@@ -1491,7 +1497,7 @@ int jrc_get_chan(RIG *rig, vfo_t vfo, channel_t *chan, int read_only)
strcpy(chan->channel_desc, "");
SNPRINTF(cmdbuf, sizeof(cmdbuf), "L%03d%03d" EOM, chan->channel_num,
- chan->channel_num);
+ chan->channel_num);
retval = jrc_transaction(rig, cmdbuf, strlen(cmdbuf), membuf, &mem_len);
if (retval != RIG_OK)
@@ -1625,7 +1631,8 @@ int jrc_decode_event(RIG *rig)
//#define SETUP_STATUS_LEN 17
//count = read_string(&rs->rigport, buf, SETUP_STATUS_LEN, "", 0);
- count = read_string(&rs->rigport, (unsigned char *) buf, priv->info_len, "", 0, 0, 1);
+ count = read_string(&rs->rigport, (unsigned char *) buf, priv->info_len, "", 0,
+ 0, 1);
if (count < 0)
{
diff --git a/rigs/jrc/jst145.c b/rigs/jrc/jst145.c
index ab06bf744..176244999 100644
--- a/rigs/jrc/jst145.c
+++ b/rigs/jrc/jst145.c
@@ -387,7 +387,8 @@ static int jst145_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
priv->freqA = freq;
}
- retval = write_block(&rig->state.rigport, (unsigned char *) freqbuf, strlen(freqbuf));
+ retval = write_block(&rig->state.rigport, (unsigned char *) freqbuf,
+ strlen(freqbuf));
if (retval != RIG_OK)
{
@@ -471,7 +472,8 @@ static int jst145_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
return -RIG_EINVAL;
}
- retval = write_block(&rig->state.rigport, (unsigned char *) modestr, strlen(modestr));
+ retval = write_block(&rig->state.rigport, (unsigned char *) modestr,
+ strlen(modestr));
if (retval != RIG_OK)
{
@@ -533,8 +535,10 @@ static int jst145_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
switch (level)
{
- case RIG_LEVEL_AGC: {
- char *cmd = val.i == RIG_AGC_SLOW ? "G0\r" : (val.i == RIG_AGC_FAST ? "G1\r" : "G2\r");
+ case RIG_LEVEL_AGC:
+ {
+ char *cmd = val.i == RIG_AGC_SLOW ? "G0\r" : (val.i == RIG_AGC_FAST ? "G1\r" :
+ "G2\r");
return write_block(&rig->state.rigport, (unsigned char *) cmd, 3);
}
@@ -551,7 +555,8 @@ static int jst145_set_mem(RIG *rig, vfo_t vfo, int ch)
SNPRINTF(membuf, sizeof(membuf), "C%03d\r", ch);
- return write_block(&rig->state.rigport, (unsigned char *) membuf, strlen(membuf));
+ return write_block(&rig->state.rigport, (unsigned char *) membuf,
+ strlen(membuf));
}
static int jst145_vfo_op(RIG *rig, vfo_t vfo, vfo_op_t op)
diff --git a/rigs/jrc/nrd525.c b/rigs/jrc/nrd525.c
index 139b9f3b0..4e3249708 100644
--- a/rigs/jrc/nrd525.c
+++ b/rigs/jrc/nrd525.c
@@ -167,7 +167,8 @@ static int nrd525_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
SNPRINTF(freqbuf, sizeof(freqbuf), "F%08u", (unsigned)(freq / 10));
- return write_block(&rig->state.rigport, (unsigned char *) freqbuf, strlen(freqbuf));
+ return write_block(&rig->state.rigport, (unsigned char *) freqbuf,
+ strlen(freqbuf));
}
static int nrd525_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
@@ -195,7 +196,8 @@ static int nrd525_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
return -RIG_EINVAL;
}
- retval = write_block(&rig->state.rigport, (unsigned char *) modestr, strlen(modestr));
+ retval = write_block(&rig->state.rigport, (unsigned char *) modestr,
+ strlen(modestr));
if (retval != RIG_OK)
{
@@ -219,12 +221,13 @@ static int nrd525_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
switch (level)
{
case RIG_LEVEL_ATT:
- return write_block(&rig->state.rigport, (unsigned char *) (val.i != 0 ? "A1" : "A0"), 2);
+ return write_block(&rig->state.rigport,
+ (unsigned char *)(val.i != 0 ? "A1" : "A0"), 2);
case RIG_LEVEL_AGC:
return write_block(&rig->state.rigport,
- (unsigned char *) (val.i == RIG_AGC_SLOW ? "G0" :
- (val.i == RIG_AGC_FAST ? "G1" : "G2")), 2);
+ (unsigned char *)(val.i == RIG_AGC_SLOW ? "G0" :
+ (val.i == RIG_AGC_FAST ? "G1" : "G2")), 2);
default:
return -RIG_EINVAL;
@@ -237,7 +240,8 @@ static int nrd525_set_mem(RIG *rig, vfo_t vfo, int ch)
SNPRINTF(membuf, sizeof(membuf), "C%03d", ch);
- return write_block(&rig->state.rigport, (unsigned char *) membuf, strlen(membuf));
+ return write_block(&rig->state.rigport, (unsigned char *) membuf,
+ strlen(membuf));
}
static int nrd525_vfo_op(RIG *rig, vfo_t vfo, vfo_op_t op)
diff --git a/rigs/kenwood/elecraft.c b/rigs/kenwood/elecraft.c
index 58524463f..b5b24479d 100644
--- a/rigs/kenwood/elecraft.c
+++ b/rigs/kenwood/elecraft.c
@@ -136,7 +136,7 @@ int elecraft_open(RIG *rig)
}
err = read_string(&rs->rigport, (unsigned char *) buf, sizeof(buf),
- ";", 1, 0, 1);
+ ";", 1, 0, 1);
if (err < 0)
{
diff --git a/rigs/kenwood/ic10.c b/rigs/kenwood/ic10.c
index 259c2dd3a..0fd0f6ef9 100644
--- a/rigs/kenwood/ic10.c
+++ b/rigs/kenwood/ic10.c
@@ -101,13 +101,15 @@ transaction:
char buffer[50];
struct kenwood_priv_data *priv = rig->state.priv;
- if (RIG_OK != (retval = write_block(&rs->rigport, (unsigned char *) priv->verify_cmd, strlen(priv->verify_cmd))))
+ if (RIG_OK != (retval = write_block(&rs->rigport,
+ (unsigned char *) priv->verify_cmd, strlen(priv->verify_cmd))))
{
return retval;
}
// this should be the ID response
- retval = read_string(&rs->rigport, (unsigned char *) buffer, sizeof(buffer), ";", 1, 0, 1);
+ retval = read_string(&rs->rigport, (unsigned char *) buffer, sizeof(buffer),
+ ";", 1, 0, 1);
// might be ?; too
if (buffer[0] == '?' && retry_cmd++ < rs->rigport.retry)
@@ -468,7 +470,8 @@ int ic10_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
}
// cppcheck-suppress *
- SNPRINTF(freqbuf, sizeof(freqbuf), "F%c%011"PRIll";", vfo_letter, (int64_t)freq);
+ SNPRINTF(freqbuf, sizeof(freqbuf), "F%c%011"PRIll";", vfo_letter,
+ (int64_t)freq);
retval = ic10_transaction(rig, freqbuf, strlen(freqbuf), NULL, 0);
return retval;
@@ -766,10 +769,10 @@ int ic10_set_channel(RIG *rig, vfo_t vfo, const channel_t *chan)
/* MWnxrrggmmmkkkhhhdzxxxx; */
SNPRINTF(membuf, sizeof(membuf), "MW0 %02d%011"PRIll"%c0 ;",
- chan->channel_num,
- freq,
- md
- );
+ chan->channel_num,
+ freq,
+ md
+ );
retval = ic10_transaction(rig, membuf, strlen(membuf), NULL, 0);
if (retval != RIG_OK)
@@ -806,10 +809,10 @@ int ic10_set_channel(RIG *rig, vfo_t vfo, const channel_t *chan)
{
/* MWnxrrggmmmkkkhhhdzxxxx; */
SNPRINTF(membuf, sizeof(membuf), "MW1 %02d%011"PRIll"%c0 ;",
- chan->channel_num,
- freq,
- md
- );
+ chan->channel_num,
+ freq,
+ md
+ );
retval = ic10_transaction(rig, membuf, strlen(membuf), NULL, 0);
// I assume we need to check the retval here -- W9MDB
diff --git a/rigs/kenwood/kenwood.c b/rigs/kenwood/kenwood.c
index 82bca3ad5..716e5d30a 100644
--- a/rigs/kenwood/kenwood.c
+++ b/rigs/kenwood/kenwood.c
@@ -357,7 +357,8 @@ transaction_write:
/* no reply expected so we need to write a command that always
gives a reply so we can read any error replies from the actual
command being sent without blocking */
- if (RIG_OK != (retval = write_block(&rs->rigport, (unsigned char *) priv->verify_cmd, strlen(priv->verify_cmd))))
+ if (RIG_OK != (retval = write_block(&rs->rigport,
+ (unsigned char *) priv->verify_cmd, strlen(priv->verify_cmd))))
{
goto transaction_quit;
}
@@ -368,7 +369,7 @@ transaction_read:
len = min(datasize ? datasize + 1 : strlen(priv->verify_cmd) + 48,
KENWOOD_MAX_BUF_LEN);
retval = read_string(&rs->rigport, (unsigned char *) buffer, len,
- cmdtrm_str, strlen(cmdtrm_str), 0, 1);
+ cmdtrm_str, strlen(cmdtrm_str), 0, 1);
rig_debug(RIG_DEBUG_TRACE, "%s: read_string(len=%d)='%s'\n", __func__,
(int)strlen(buffer), buffer);
@@ -659,10 +660,10 @@ rmode_t kenwood2rmode(unsigned char mode, const rmode_t mode_table[])
if (mode >= KENWOOD_MODE_TABLE_MAX)
{
- return(RIG_MODE_NONE);
+ return (RIG_MODE_NONE);
}
- return(mode_table[mode]);
+ return (mode_table[mode]);
}
char rmode2kenwood(rmode_t mode, const rmode_t mode_table[])
@@ -679,12 +680,12 @@ char rmode2kenwood(rmode_t mode, const rmode_t mode_table[])
if (mode_table[i] == mode)
{
rig_debug(RIG_DEBUG_VERBOSE, "%s: returning %d\n", __func__, i);
- return(i);
+ return (i);
}
}
}
- return(-1);
+ return (-1);
}
int kenwood_init(RIG *rig)
@@ -1317,7 +1318,7 @@ int kenwood_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, vfo_t txvfo)
if (vfo == RIG_VFO_CURR) { vfo = rig->state.current_vfo; }
- if (vfo == RIG_VFO_TX || vfo == RIG_VFO_RX) vfo = vfo_fixup(rig, vfo, split);
+ if (vfo == RIG_VFO_TX || vfo == RIG_VFO_RX) { vfo = vfo_fixup(rig, vfo, split); }
switch (vfo)
{
@@ -1666,7 +1667,8 @@ int kenwood_get_vfo_if(RIG *rig, vfo_t *vfo)
switch (priv->info[30])
{
case '0':
- *vfo = rig->state.rx_vfo = rig->state.tx_vfo = priv->tx_vfo = split_and_transmitting ? RIG_VFO_B : RIG_VFO_A;
+ *vfo = rig->state.rx_vfo = rig->state.tx_vfo = priv->tx_vfo =
+ split_and_transmitting ? RIG_VFO_B : RIG_VFO_A;
if (priv->info[32] == '1') { priv->tx_vfo = RIG_VFO_B; }
@@ -2467,7 +2469,8 @@ static int kenwood_get_filter_width(RIG *rig, rmode_t mode, pbwidth_t *width)
}
}
}
- if (filter_value >=50) // then it's probably a custom filter width
+
+ if (filter_value >= 50) // then it's probably a custom filter width
{
*width = filter_value;
return (RIG_OK);
@@ -2699,7 +2702,8 @@ static int kenwood_get_micgain_minmax(RIG *rig, int *micgain_now,
if (retval != RIG_OK) { RETURNFUNC(retval); }
- retval = read_string(&rs->rigport, (unsigned char *) levelbuf, sizeof(levelbuf), NULL, 0, 0, 1);
+ retval = read_string(&rs->rigport, (unsigned char *) levelbuf, sizeof(levelbuf),
+ NULL, 0, 0, 1);
rig_debug(RIG_DEBUG_TRACE, "%s: retval=%d\n", __func__, retval);
@@ -2798,7 +2802,8 @@ static int kenwood_get_power_minmax(RIG *rig, int *power_now, int *power_min,
if (retval != RIG_OK) { RETURNFUNC(retval); }
- retval = read_string(&rs->rigport, (unsigned char *) levelbuf, sizeof(levelbuf), NULL, 0, 0, 1);
+ retval = read_string(&rs->rigport, (unsigned char *) levelbuf, sizeof(levelbuf),
+ NULL, 0, 0, 1);
rig_debug(RIG_DEBUG_TRACE, "%s: retval=%d\n", __func__, retval);
@@ -5432,12 +5437,12 @@ DECLARE_PROBERIG_BACKEND(kenwood)
if (!port)
{
- return(RIG_MODEL_NONE);
+ return (RIG_MODEL_NONE);
}
if (port->type.rig != RIG_PORT_SERIAL)
{
- return(RIG_MODEL_NONE);
+ return (RIG_MODEL_NONE);
}
port->write_delay = port->post_write_delay = 0;
@@ -5458,7 +5463,7 @@ DECLARE_PROBERIG_BACKEND(kenwood)
{
port->write_delay = write_delay;
port->retry = retry;
- return(RIG_MODEL_NONE);
+ return (RIG_MODEL_NONE);
}
retval = write_block(port, (unsigned char *) "ID;", 3);
@@ -5475,7 +5480,7 @@ DECLARE_PROBERIG_BACKEND(kenwood)
{
port->write_delay = write_delay;
port->retry = retry;
- return(RIG_MODEL_NONE);
+ return (RIG_MODEL_NONE);
}
/*
@@ -5489,7 +5494,7 @@ DECLARE_PROBERIG_BACKEND(kenwood)
6, id_len, idbuf);
port->write_delay = write_delay;
port->retry = retry;
- return(RIG_MODEL_NONE);
+ return (RIG_MODEL_NONE);
}
@@ -5508,7 +5513,7 @@ DECLARE_PROBERIG_BACKEND(kenwood)
port->write_delay = write_delay;
port->retry = retry;
- return(kenwood_id_string_list[i].model);
+ return (kenwood_id_string_list[i].model);
}
}
@@ -5525,7 +5530,7 @@ DECLARE_PROBERIG_BACKEND(kenwood)
if (retval != RIG_OK)
{
- return(RIG_MODEL_NONE);
+ return (RIG_MODEL_NONE);
}
retval = write_block(port, (unsigned char *) "K2;", 3);
@@ -5534,7 +5539,7 @@ DECLARE_PROBERIG_BACKEND(kenwood)
if (retval != RIG_OK)
{
- return(RIG_MODEL_NONE);
+ return (RIG_MODEL_NONE);
}
/*
@@ -5549,7 +5554,7 @@ DECLARE_PROBERIG_BACKEND(kenwood)
(*cfunc)(port, RIG_MODEL_K2, data);
}
- return(RIG_MODEL_K2);
+ return (RIG_MODEL_K2);
}
}
@@ -5565,7 +5570,7 @@ DECLARE_PROBERIG_BACKEND(kenwood)
(*cfunc)(port, kenwood_id_list[i].model, data);
}
- return(kenwood_id_list[i].model);
+ return (kenwood_id_list[i].model);
}
}
@@ -5579,7 +5584,7 @@ DECLARE_PROBERIG_BACKEND(kenwood)
rig_debug(RIG_DEBUG_TRACE, "%s: post_write_delay=%d\n", __func__,
port->post_write_delay);
- return(RIG_MODEL_NONE);
+ return (RIG_MODEL_NONE);
}
@@ -5645,5 +5650,5 @@ DECLARE_INITRIG_BACKEND(kenwood)
rig_register(&malachite_caps);
rig_register(&tx500_caps);
- return(RIG_OK);
+ return (RIG_OK);
}
diff --git a/rigs/kenwood/pihpsdr.c b/rigs/kenwood/pihpsdr.c
index 72d5b0c5d..dbaf0d85b 100644
--- a/rigs/kenwood/pihpsdr.c
+++ b/rigs/kenwood/pihpsdr.c
@@ -734,21 +734,21 @@ int pihspdr_set_channel(RIG *rig, vfo_t vfo, const channel_t *chan)
/* P-number 2-3 4 5 6 7 8 9 101112 13 141516 */
SNPRINTF(buf, sizeof(buf), "MW0%03d%011u%c%c%c%02d%02d%03d%c%c%09d0%c%c%s;",
- chan->channel_num,
- (unsigned) chan->freq, /* 4 - frequency */
- '0' + mode, /* 5 - mode */
- (chan->flags & RIG_CHFLAG_SKIP) ? '1' : '0', /* 6 - lockout status */
- sqltype, /* 7 - squelch and tone type */
- tone + 1, /* 8 - tone code */
- code + 1, /* 9 - CTCSS code */
- dcscode, /* 10 - DCS code */
- (chan->funcs & RIG_FUNC_REV) ? '1' : '0', /* 11 - Reverse status */
- shift, /* 12 - shift type */
- (int) chan->rptr_offs, /* 13 - offset frequency */
- tstep + '0', /* 14 - Step size */
- chan->scan_group + '0', /* 15 - Memory group no */
- chan->channel_desc /* 16 - description */
- );
+ chan->channel_num,
+ (unsigned) chan->freq, /* 4 - frequency */
+ '0' + mode, /* 5 - mode */
+ (chan->flags & RIG_CHFLAG_SKIP) ? '1' : '0', /* 6 - lockout status */
+ sqltype, /* 7 - squelch and tone type */
+ tone + 1, /* 8 - tone code */
+ code + 1, /* 9 - CTCSS code */
+ dcscode, /* 10 - DCS code */
+ (chan->funcs & RIG_FUNC_REV) ? '1' : '0', /* 11 - Reverse status */
+ shift, /* 12 - shift type */
+ (int) chan->rptr_offs, /* 13 - offset frequency */
+ tstep + '0', /* 14 - Step size */
+ chan->scan_group + '0', /* 15 - Memory group no */
+ chan->channel_desc /* 16 - description */
+ );
rig_debug(RIG_DEBUG_VERBOSE, "The command will be: %s\n", buf);
err = kenwood_transaction(rig, buf, NULL, 0);
diff --git a/rigs/kenwood/th.c b/rigs/kenwood/th.c
index c9ff5fc07..d9c2bab5b 100644
--- a/rigs/kenwood/th.c
+++ b/rigs/kenwood/th.c
@@ -1344,17 +1344,17 @@ int th_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
case RIG_LEVEL_RFPOWER :
SNPRINTF(buf, sizeof(buf), "PC %c,%01d", vch,
- (int)(val.f * (rig->caps->level_gran[LVL_RFPOWER].max.i -
- rig->caps->level_gran[LVL_RFPOWER].min.i))
- + rig->caps->level_gran[LVL_RFPOWER].min.i);
+ (int)(val.f * (rig->caps->level_gran[LVL_RFPOWER].max.i -
+ rig->caps->level_gran[LVL_RFPOWER].min.i))
+ + rig->caps->level_gran[LVL_RFPOWER].min.i);
return kenwood_transaction(rig, buf, NULL, 0);
case RIG_LEVEL_SQL :
SNPRINTF(buf, sizeof(buf), "SQ %c,%02x", vch,
- (int)(val.f * (rig->caps->level_gran[LVL_SQL].max.i -
- rig->caps->level_gran[LVL_SQL].min.i))
- + rig->caps->level_gran[LVL_SQL].min.i);
+ (int)(val.f * (rig->caps->level_gran[LVL_SQL].max.i -
+ rig->caps->level_gran[LVL_SQL].min.i))
+ + rig->caps->level_gran[LVL_SQL].min.i);
return kenwood_transaction(rig, buf, NULL, 0);
case RIG_LEVEL_AF :
@@ -1979,7 +1979,8 @@ int th_get_channel(RIG *rig, vfo_t vfo, channel_t *chan, int read_only)
else
{
SNPRINTF(req, sizeof(req), "MR %s0,PR%01d", mr_extra, channel_num + 1);
- SNPRINTF(chan->channel_desc, sizeof(chan->channel_desc), "Pr%01d", channel_num + 1);
+ SNPRINTF(chan->channel_desc, sizeof(chan->channel_desc), "Pr%01d",
+ channel_num + 1);
}
break;
@@ -1995,7 +1996,8 @@ int th_get_channel(RIG *rig, vfo_t vfo, channel_t *chan, int read_only)
case RIG_MTYPE_BAND:
SNPRINTF(req, sizeof(req), "VR %01X", channel_num);
- SNPRINTF(chan->channel_desc, sizeof(chan->channel_desc), "BAND %01X", channel_num);
+ SNPRINTF(chan->channel_desc, sizeof(chan->channel_desc), "BAND %01X",
+ channel_num);
break;
default:
@@ -2433,11 +2435,12 @@ int th_set_channel(RIG *rig, vfo_t vfo, const channel_t *chan)
{
/* Without DCS,mode */
- SNPRINTF(membuf, sizeof(membuf), "%s,%011"PRIll",%X,%d,%d,%d,%d,,%02d,,%02d,%09"PRIll"%s",
- req, (int64_t)chan->freq, step, shift, rev, tone,
- ctcss, tonefq, ctcssfq,
- (int64_t)labs((long)(chan->rptr_offs)), lockoutstr
- );
+ SNPRINTF(membuf, sizeof(membuf),
+ "%s,%011"PRIll",%X,%d,%d,%d,%d,,%02d,,%02d,%09"PRIll"%s",
+ req, (int64_t)chan->freq, step, shift, rev, tone,
+ ctcss, tonefq, ctcssfq,
+ (int64_t)labs((long)(chan->rptr_offs)), lockoutstr
+ );
}
retval = kenwood_transaction(rig, membuf, membuf, sizeof(membuf));
@@ -2455,7 +2458,8 @@ int th_set_channel(RIG *rig, vfo_t vfo, const channel_t *chan)
req[3 + strlen(mr_extra)] = '1';
- SNPRINTF(membuf, sizeof(membuf), "%s,%011"PRIll",%X", req, (int64_t)chan->tx_freq, step);
+ SNPRINTF(membuf, sizeof(membuf), "%s,%011"PRIll",%X", req,
+ (int64_t)chan->tx_freq, step);
retval = kenwood_transaction(rig, membuf, membuf, sizeof(membuf));
if (retval != RIG_OK)
@@ -2470,11 +2474,13 @@ int th_set_channel(RIG *rig, vfo_t vfo, const channel_t *chan)
/* TODO: check strlen(channel_desc) < rig->caps->chan_desc_sz */
if (chan_caps[1].type == RIG_MTYPE_PRIO)
{
- SNPRINTF(membuf, sizeof(membuf), "MNA %sI-%01d,%s", mr_extra, channel_num, channel_desc);
+ SNPRINTF(membuf, sizeof(membuf), "MNA %sI-%01d,%s", mr_extra, channel_num,
+ channel_desc);
}
else
{
- SNPRINTF(membuf, sizeof(membuf), "MNA %s%03d,%s", mr_extra, channel_num, channel_desc);
+ SNPRINTF(membuf, sizeof(membuf), "MNA %s%03d,%s", mr_extra, channel_num,
+ channel_desc);
}
retval = kenwood_transaction(rig, membuf, membuf, sizeof(membuf));
diff --git a/rigs/kenwood/thd74.c b/rigs/kenwood/thd74.c
index 4351c5d13..7ec2bbe5b 100644
--- a/rigs/kenwood/thd74.c
+++ b/rigs/kenwood/thd74.c
@@ -645,7 +645,7 @@ static int thd74_set_ts(RIG *rig, vfo_t vfo, shortfreq_t ts)
return RIG_OK;
}
}
-
+
for (tsinx = 0; tsinx < 10; tsinx++)
{
diff --git a/rigs/kenwood/tmv7.c b/rigs/kenwood/tmv7.c
index 3f20973ac..c99befe7a 100644
--- a/rigs/kenwood/tmv7.c
+++ b/rigs/kenwood/tmv7.c
@@ -420,7 +420,7 @@ int tmv7_set_vfo(RIG *rig, vfo_t vfo)
break;
case RIG_VFO_B:
- SNPRINTF(vfobuf, sizeof(vfobuf),"BC 1,1");
+ SNPRINTF(vfobuf, sizeof(vfobuf), "BC 1,1");
break;
case RIG_VFO_MEM:
@@ -515,22 +515,26 @@ int tmv7_get_channel(RIG *rig, vfo_t vfo, channel_t *chan, int read_only)
else if (chan->channel_num < 204)
{
SNPRINTF(req, sizeof(req), "MR 0,0,L%01d", chan->channel_num - 200);
- SNPRINTF(chan->channel_desc, sizeof(chan->channel_desc), "L%01d/V", chan->channel_num - 200);
+ SNPRINTF(chan->channel_desc, sizeof(chan->channel_desc), "L%01d/V",
+ chan->channel_num - 200);
}
else if (chan->channel_num < 211)
{
SNPRINTF(req, sizeof(req), "MR 1,0,L%01d", chan->channel_num - 203);
- SNPRINTF(chan->channel_desc, sizeof(chan->channel_desc), "L%01d/U", chan->channel_num - 203);
+ SNPRINTF(chan->channel_desc, sizeof(chan->channel_desc), "L%01d/U",
+ chan->channel_num - 203);
}
else if (chan->channel_num < 214)
{
SNPRINTF(req, sizeof(req), "MR 0,0,U%01d", chan->channel_num - 210);
- SNPRINTF(chan->channel_desc, sizeof(chan->channel_desc), "U%01d/V", chan->channel_num - 210);
+ SNPRINTF(chan->channel_desc, sizeof(chan->channel_desc), "U%01d/V",
+ chan->channel_num - 210);
}
else if (chan->channel_num < 220)
{
SNPRINTF(req, sizeof(req), "MR 1,0,U%01d", chan->channel_num - 213);
- SNPRINTF(chan->channel_desc, sizeof(chan->channel_desc), "U%01d/U", chan->channel_num - 213);
+ SNPRINTF(chan->channel_desc, sizeof(chan->channel_desc), "U%01d/U",
+ chan->channel_num - 213);
}
else if (chan->channel_num < 223)
{
@@ -775,15 +779,17 @@ int tmv7_set_channel(RIG *rig, vfo_t vfo, const channel_t *chan)
if (chan->channel_num < 221)
{
- SNPRINTF(membuf, sizeof(membuf), "%s,%011ld,%01d,%01d,0,%01d,%01d,0,%02d,000,%02d,0,0",
- req, (long)freq, step, shift, tone,
- ctcss, tonefq, ctcssfq);
+ SNPRINTF(membuf, sizeof(membuf),
+ "%s,%011ld,%01d,%01d,0,%01d,%01d,0,%02d,000,%02d,0,0",
+ req, (long)freq, step, shift, tone,
+ ctcss, tonefq, ctcssfq);
}
else
{
- SNPRINTF(membuf, sizeof(membuf), "%s,%011ld,%01d,%01d,0,%01d,%01d,0,%02d,000,%02d,",
- req, (long)freq, step, shift, tone,
- ctcss, tonefq, ctcssfq);
+ SNPRINTF(membuf, sizeof(membuf),
+ "%s,%011ld,%01d,%01d,0,%01d,%01d,0,%02d,000,%02d,",
+ req, (long)freq, step, shift, tone,
+ ctcss, tonefq, ctcssfq);
}
retval = kenwood_transaction(rig, membuf, NULL, 0);
@@ -797,7 +803,8 @@ int tmv7_set_channel(RIG *rig, vfo_t vfo, const channel_t *chan)
{
req[5] = '1';
// cppcheck-suppress *
- SNPRINTF(membuf, sizeof(membuf), "%s,%011"PRIll",%01d", req, (int64_t)chan->tx_freq, step);
+ SNPRINTF(membuf, sizeof(membuf), "%s,%011"PRIll",%01d", req,
+ (int64_t)chan->tx_freq, step);
retval = kenwood_transaction(rig, membuf, NULL, 0);
if (retval != RIG_OK)
@@ -810,11 +817,13 @@ int tmv7_set_channel(RIG *rig, vfo_t vfo, const channel_t *chan)
{
if (chan->channel_num < 100)
{
- SNPRINTF(membuf, sizeof(membuf), "MNA 0,%03d,%s", chan->channel_num, chan->channel_desc);
+ SNPRINTF(membuf, sizeof(membuf), "MNA 0,%03d,%s", chan->channel_num,
+ chan->channel_desc);
}
else
{
- SNPRINTF(membuf, sizeof(membuf), "MNA 1,%03d,%s", chan->channel_num - 100, chan->channel_desc);
+ SNPRINTF(membuf, sizeof(membuf), "MNA 1,%03d,%s", chan->channel_num - 100,
+ chan->channel_desc);
}
retval = kenwood_transaction(rig, membuf, NULL, 0);
diff --git a/rigs/kenwood/ts140.c b/rigs/kenwood/ts140.c
index 2310904e0..c227fb68c 100644
--- a/rigs/kenwood/ts140.c
+++ b/rigs/kenwood/ts140.c
@@ -70,7 +70,7 @@ static int ts140_set_vfo(RIG *rig, vfo_t vfo)
}
SNPRINTF(cmdbuf, sizeof(cmdbuf), "FN%c",
- vfo_function); /* The 680 and 140 need this to set the VFO on the radio */
+ vfo_function); /* The 680 and 140 need this to set the VFO on the radio */
return kenwood_transaction(rig, cmdbuf, NULL, 0);
}
diff --git a/rigs/kenwood/ts2000.c b/rigs/kenwood/ts2000.c
index 6f1809f7d..0d78e164e 100644
--- a/rigs/kenwood/ts2000.c
+++ b/rigs/kenwood/ts2000.c
@@ -788,21 +788,21 @@ int ts2000_set_channel(RIG *rig, vfo_t vfo, const channel_t *chan)
if (chan->split == RIG_SPLIT_ON)
{
SNPRINTF(buf, sizeof(buf), "MW1%03d%011u%c%c%c%02d%02d%03d%c%c%09d0%c%c%s;\n",
- chan->channel_num,
- (unsigned) chan->tx_freq, /* 4 - frequency */
- '0' + tx_mode, /* 5 - mode */
- (chan->flags & RIG_CHFLAG_SKIP) ? '1' : '0', /* 6 - lockout status */
- sqltype, /* 7 - squelch and tone type */
- tone + 1, /* 8 - tone code */
- code + 1, /* 9 - CTCSS code */
- dcscode + 1, /* 10 - DCS code */
- (chan->funcs & RIG_FUNC_REV) ? '1' : '0', /* 11 - Reverse status */
- shift, /* 12 - shift type */
- (int) chan->rptr_offs, /* 13 - offset frequency */
- tstep + '0', /* 14 - Step size */
- chan->scan_group + '0', /* Memory group no */
- chan->channel_desc /* 16 - description */
- );
+ chan->channel_num,
+ (unsigned) chan->tx_freq, /* 4 - frequency */
+ '0' + tx_mode, /* 5 - mode */
+ (chan->flags & RIG_CHFLAG_SKIP) ? '1' : '0', /* 6 - lockout status */
+ sqltype, /* 7 - squelch and tone type */
+ tone + 1, /* 8 - tone code */
+ code + 1, /* 9 - CTCSS code */
+ dcscode + 1, /* 10 - DCS code */
+ (chan->funcs & RIG_FUNC_REV) ? '1' : '0', /* 11 - Reverse status */
+ shift, /* 12 - shift type */
+ (int) chan->rptr_offs, /* 13 - offset frequency */
+ tstep + '0', /* 14 - Step size */
+ chan->scan_group + '0', /* Memory group no */
+ chan->channel_desc /* 16 - description */
+ );
rig_debug(RIG_DEBUG_VERBOSE, "Split, the command will be: %s\n", buf);
err = kenwood_transaction(rig, buf, NULL, 0);
diff --git a/rigs/kenwood/ts480.c b/rigs/kenwood/ts480.c
index 173e7237e..08c1eea47 100644
--- a/rigs/kenwood/ts480.c
+++ b/rigs/kenwood/ts480.c
@@ -440,7 +440,8 @@ static int ts480_read_meters(RIG *rig, int *swr, int *comp, int *alc)
// TS-480 returns values for all meters at the same time, for example: RM10000;RM20000;RM30000;
- retval = read_string(&rs->rigport, (unsigned char *) ackbuf, expected_len + 1, NULL, 0, 0, 1);
+ retval = read_string(&rs->rigport, (unsigned char *) ackbuf, expected_len + 1,
+ NULL, 0, 0, 1);
rig_debug(RIG_DEBUG_TRACE, "%s: read_string retval=%d\n", __func__, retval);
diff --git a/rigs/kenwood/ts570.c b/rigs/kenwood/ts570.c
index 1437b0451..fe5020342 100644
--- a/rigs/kenwood/ts570.c
+++ b/rigs/kenwood/ts570.c
@@ -712,7 +712,7 @@ int ts570_set_channel(RIG *rig, vfo_t vfo, const channel_t *chan)
}
SNPRINTF(cmdbuf, sizeof(cmdbuf), "MW0 %02d%011d%c0%c%02d ",
- num, freq, mode, tones, tone);
+ num, freq, mode, tones, tone);
retval = kenwood_transaction(rig, cmdbuf, NULL, 0);
@@ -722,7 +722,7 @@ int ts570_set_channel(RIG *rig, vfo_t vfo, const channel_t *chan)
}
SNPRINTF(cmdbuf, sizeof(cmdbuf), "MW1 %02d%011d%c0%c%02d ",
- num, tx_freq, tx_mode, tones, tone);
+ num, tx_freq, tx_mode, tones, tone);
retval = kenwood_transaction(rig, cmdbuf, NULL, 0);
diff --git a/rigs/kenwood/ts590.c b/rigs/kenwood/ts590.c
index 003623347..37530759c 100644
--- a/rigs/kenwood/ts590.c
+++ b/rigs/kenwood/ts590.c
@@ -592,6 +592,7 @@ int ts590_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
__func__, lvlbuf[2]);
RETURNFUNC(-RIG_EPROTO);
}
+
return retval;
case RIG_LEVEL_ATT:
@@ -617,6 +618,7 @@ int ts590_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
__func__, lvlbuf[2]);
RETURNFUNC(-RIG_EPROTO);
}
+
return retval;
case RIG_LEVEL_RAWSTR:
diff --git a/rigs/kenwood/ts680.c b/rigs/kenwood/ts680.c
index 84a38eebc..0d4bbe020 100644
--- a/rigs/kenwood/ts680.c
+++ b/rigs/kenwood/ts680.c
@@ -70,7 +70,7 @@ static int ts680_set_vfo(RIG *rig, vfo_t vfo)
}
SNPRINTF(cmdbuf, sizeof(cmdbuf), "FN%c",
- vfo_function); /* The 680 and 140 need this to set the VFO on the radio */
+ vfo_function); /* The 680 and 140 need this to set the VFO on the radio */
return kenwood_transaction(rig, cmdbuf, NULL, 0);
}
diff --git a/rigs/kenwood/ts850.c b/rigs/kenwood/ts850.c
index 2f0b4b6a4..264fddfe2 100644
--- a/rigs/kenwood/ts850.c
+++ b/rigs/kenwood/ts850.c
@@ -552,7 +552,7 @@ int ts850_set_channel(RIG *rig, vfo_t vfo, const channel_t *chan)
}
SNPRINTF(cmdbuf, sizeof(cmdbuf), "MW0 %02d%011d%c0%c%02d ",
- num, freq, mode, tones, tone);
+ num, freq, mode, tones, tone);
retval = kenwood_transaction(rig, cmdbuf, NULL, 0);
if (retval != RIG_OK)
@@ -561,7 +561,7 @@ int ts850_set_channel(RIG *rig, vfo_t vfo, const channel_t *chan)
}
SNPRINTF(cmdbuf, sizeof(cmdbuf), "MW1 %02d%011d%c0%c%02d ",
- num, tx_freq, tx_mode, tones, tone);
+ num, tx_freq, tx_mode, tones, tone);
retval = kenwood_transaction(rig, cmdbuf, NULL, 0);
if (retval != RIG_OK)
diff --git a/rigs/kenwood/tx500.c b/rigs/kenwood/tx500.c
index 25f0e2ccf..2991e993d 100644
--- a/rigs/kenwood/tx500.c
+++ b/rigs/kenwood/tx500.c
@@ -787,21 +787,21 @@ int ts2000_set_channel(RIG *rig, vfo_t vfo, const channel_t *chan)
if (chan->split == RIG_SPLIT_ON)
{
SNPRINTF(buf, sizeof(buf), "MW1%03d%011u%c%c%c%02d%02d%03d%c%c%09d0%c%c%s;\n",
- chan->channel_num,
- (unsigned) chan->tx_freq, /* 4 - frequency */
- '0' + tx_mode, /* 5 - mode */
- (chan->flags & RIG_CHFLAG_SKIP) ? '1' : '0', /* 6 - lockout status */
- sqltype, /* 7 - squelch and tone type */
- tone + 1, /* 8 - tone code */
- code + 1, /* 9 - CTCSS code */
- dcscode + 1, /* 10 - DCS code */
- (chan->funcs & RIG_FUNC_REV) ? '1' : '0', /* 11 - Reverse status */
- shift, /* 12 - shift type */
- (int) chan->rptr_offs, /* 13 - offset frequency */
- tstep + '0', /* 14 - Step size */
- chan->scan_group + '0', /* Memory group no */
- chan->channel_desc /* 16 - description */
- );
+ chan->channel_num,
+ (unsigned) chan->tx_freq, /* 4 - frequency */
+ '0' + tx_mode, /* 5 - mode */
+ (chan->flags & RIG_CHFLAG_SKIP) ? '1' : '0', /* 6 - lockout status */
+ sqltype, /* 7 - squelch and tone type */
+ tone + 1, /* 8 - tone code */
+ code + 1, /* 9 - CTCSS code */
+ dcscode + 1, /* 10 - DCS code */
+ (chan->funcs & RIG_FUNC_REV) ? '1' : '0', /* 11 - Reverse status */
+ shift, /* 12 - shift type */
+ (int) chan->rptr_offs, /* 13 - offset frequency */
+ tstep + '0', /* 14 - Step size */
+ chan->scan_group + '0', /* Memory group no */
+ chan->channel_desc /* 16 - description */
+ );
rig_debug(RIG_DEBUG_VERBOSE, "Split, the command will be: %s\n", buf);
err = kenwood_transaction(rig, buf, NULL, 0);
diff --git a/rigs/kenwood/xg3.c b/rigs/kenwood/xg3.c
index 0368d94dc..4e0cc75ea 100644
--- a/rigs/kenwood/xg3.c
+++ b/rigs/kenwood/xg3.c
@@ -284,7 +284,7 @@ int xg3_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
}
retval = read_string(&rs->rigport, (unsigned char *) replybuf, replysize,
- ";", 1, 0, 1);
+ ";", 1, 0, 1);
if (retval < 0)
{
@@ -462,7 +462,7 @@ int xg3_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
}
retval = read_string(&rs->rigport, (unsigned char *) freqbuf, freqsize,
- ";", 1, 0, 1);
+ ";", 1, 0, 1);
if (retval < 0)
{
@@ -515,7 +515,7 @@ int xg3_get_powerstat(RIG *rig, powerstat_t *status)
{
char reply[32];
retval = read_string(&rs->rigport, (unsigned char *) reply, sizeof(reply),
- ";", 1, 0, 1);
+ ";", 1, 0, 1);
*status = RIG_POWER_ON;
priv->powerstat = RIG_POWER_ON;
}
@@ -580,7 +580,7 @@ int xg3_get_mem(RIG *rig, vfo_t vfo, int *ch)
}
retval = read_string(&rs->rigport, (unsigned char *) reply, sizeof(reply),
- ";", 1, 0, 1);
+ ";", 1, 0, 1);
if (retval < 0)
{
diff --git a/rigs/kit/hiqsdr.c b/rigs/kit/hiqsdr.c
index 5d52c2fad..2c654e490 100644
--- a/rigs/kit/hiqsdr.c
+++ b/rigs/kit/hiqsdr.c
@@ -196,14 +196,17 @@ static int send_command(RIG *rig)
struct hiqsdr_priv_data *priv = (struct hiqsdr_priv_data *)rig->state.priv;
int ret;
- ret = write_block(&rig->state.rigport, (unsigned char *) priv->control_frame, CTRL_FRAME_LEN);
+ ret = write_block(&rig->state.rigport, (unsigned char *) priv->control_frame,
+ CTRL_FRAME_LEN);
#if 0
- ret = read_block(&rig->state.rigport, (unsigned char *) priv->control_frame, CTRL_FRAME_LEN);
+ ret = read_block(&rig->state.rigport, (unsigned char *) priv->control_frame,
+ CTRL_FRAME_LEN);
if (ret != CTRL_FRAME_LEN)
{
ret = ret < 0 ? ret : -RIG_EPROTO;
}
+
#endif
return ret;
diff --git a/rigs/kit/miniVNA.c b/rigs/kit/miniVNA.c
index d4a32a084..2de5fd0f7 100644
--- a/rigs/kit/miniVNA.c
+++ b/rigs/kit/miniVNA.c
@@ -46,9 +46,11 @@ static int miniVNA_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
rig_flush(&rig->state.rigport);
- SNPRINTF(cmdstr, sizeof(cmdstr), "0\r%lu\r1\r0\r", (unsigned long int)(freq * DDS_RATIO));
+ SNPRINTF(cmdstr, sizeof(cmdstr), "0\r%lu\r1\r0\r",
+ (unsigned long int)(freq * DDS_RATIO));
- retval = write_block(&rig->state.rigport, (unsigned char *) cmdstr, strlen(cmdstr));
+ retval = write_block(&rig->state.rigport, (unsigned char *) cmdstr,
+ strlen(cmdstr));
if (retval != RIG_OK)
{
diff --git a/rigs/kit/rs_hfiq.c b/rigs/kit/rs_hfiq.c
index ed75b8166..b0799cb61 100644
--- a/rigs/kit/rs_hfiq.c
+++ b/rigs/kit/rs_hfiq.c
@@ -93,7 +93,8 @@ static int rshfiq_open(RIG *rig)
rig_flush(&rig->state.rigport);
SNPRINTF(versionstr, sizeof(versionstr), "*w\r");
rig_debug(RIG_DEBUG_TRACE, "%s: cmdstr = %s\n", __func__, versionstr);
- retval = write_block(&rig->state.rigport, (unsigned char *) versionstr, strlen(versionstr));
+ retval = write_block(&rig->state.rigport, (unsigned char *) versionstr,
+ strlen(versionstr));
if (retval != RIG_OK)
{
@@ -101,7 +102,7 @@ static int rshfiq_open(RIG *rig)
}
retval = read_string(&rig->state.rigport, (unsigned char *) versionstr, 20,
- stopset, 2, 0, 1);
+ stopset, 2, 0, 1);
}
if (retval <= 0)
@@ -160,7 +161,8 @@ static int rshfiq_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
SNPRINTF(cmdstr, sizeof(cmdstr), "*f%lu\r", (unsigned long int)(freq));
- retval = write_block(&rig->state.rigport, (unsigned char *) cmdstr, strlen(cmdstr));
+ retval = write_block(&rig->state.rigport, (unsigned char *) cmdstr,
+ strlen(cmdstr));
if (retval != RIG_OK)
{
@@ -183,7 +185,8 @@ static int rshfiq_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
rig_debug(RIG_DEBUG_TRACE, "%s: cmdstr = %s\n", __func__, cmdstr);
- retval = write_block(&rig->state.rigport, (unsigned char *) cmdstr, strlen(cmdstr));
+ retval = write_block(&rig->state.rigport, (unsigned char *) cmdstr,
+ strlen(cmdstr));
if (retval != RIG_OK)
{
@@ -191,7 +194,7 @@ static int rshfiq_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
}
retval = read_string(&rig->state.rigport, (unsigned char *) cmdstr, 9,
- stopset, 2, 0, 1);
+ stopset, 2, 0, 1);
if (retval <= 0)
{
@@ -232,7 +235,8 @@ static int rshfiq_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt)
rig_debug(RIG_DEBUG_TRACE, "%s: cmdstr = %s\n", __func__, cmdstr);
- retval = write_block(&rig->state.rigport, (unsigned char *) cmdstr, strlen(cmdstr));
+ retval = write_block(&rig->state.rigport, (unsigned char *) cmdstr,
+ strlen(cmdstr));
return retval;
}
@@ -266,7 +270,8 @@ static int rshfiq_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
rig_debug(RIG_DEBUG_TRACE, "RIG_LEVEL_RFPOWER_METER command=%s\n", cmdstr);
- retval = write_block(&rig->state.rigport, (unsigned char *) cmdstr, strlen(cmdstr));
+ retval = write_block(&rig->state.rigport, (unsigned char *) cmdstr,
+ strlen(cmdstr));
if (retval != RIG_OK)
{
@@ -277,7 +282,7 @@ static int rshfiq_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
stopset[1] = '\n';
retval = read_string(&rig->state.rigport, (unsigned char *) cmdstr, 9,
- stopset, 2, 0, 1);
+ stopset, 2, 0, 1);
rig_debug(RIG_DEBUG_TRACE, "RIG_LEVEL_RFPOWER_METER reply=%s\n", cmdstr);
@@ -305,7 +310,8 @@ static int rshfiq_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
rig_debug(RIG_DEBUG_TRACE, "RIG_LEVEL_TEMP_METER command=%s\n", cmdstr);
- retval = write_block(&rig->state.rigport, (unsigned char *) cmdstr, strlen(cmdstr));
+ retval = write_block(&rig->state.rigport, (unsigned char *) cmdstr,
+ strlen(cmdstr));
if (retval != RIG_OK)
{
@@ -316,7 +322,7 @@ static int rshfiq_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
stopset[1] = '\n';
retval = read_string(&rig->state.rigport, (unsigned char *) cmdstr, 9,
- stopset, 2, 0, 1);
+ stopset, 2, 0, 1);
rig_debug(RIG_DEBUG_TRACE, "RIG_LEVEL_TEMP_METER reply=%s\n", cmdstr);
diff --git a/rigs/kit/si570avrusb.c b/rigs/kit/si570avrusb.c
index 82e918b09..f83ac5270 100644
--- a/rigs/kit/si570avrusb.c
+++ b/rigs/kit/si570avrusb.c
@@ -1102,8 +1102,9 @@ const char *si570xxxusb_get_info(RIG *rig)
/* always succeeds since libusb-1.0.16 */
libusb_get_device_descriptor(libusb_get_device(udh), &desc);
- SNPRINTF(buf, sizeof(buf), "USB dev %04d, version: %d.%d", desc.bcdDevice, buffer[1],
- buffer[0]);
+ SNPRINTF(buf, sizeof(buf), "USB dev %04d, version: %d.%d", desc.bcdDevice,
+ buffer[1],
+ buffer[0]);
return buf;
}
diff --git a/rigs/pcr/pcr.c b/rigs/pcr/pcr.c
index 83ee60598..7b79ce9af 100644
--- a/rigs/pcr/pcr.c
+++ b/rigs/pcr/pcr.c
@@ -760,9 +760,9 @@ pcr_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
// cppcheck-suppress *
SNPRINTF((char *) buf, sizeof(buf), "K%c%010" PRIll "0%c0%c00",
- is_sub_rcvr(rig, vfo) ? '1' : '0',
- (int64_t) freq,
- rcvr->last_mode, rcvr->last_filter);
+ is_sub_rcvr(rig, vfo) ? '1' : '0',
+ (int64_t) freq,
+ rcvr->last_mode, rcvr->last_filter);
err = pcr_transaction(rig, (char *) buf);
@@ -901,8 +901,8 @@ pcr_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
__func__, (int)width, pcrfilter);
SNPRINTF((char *) buf, sizeof(buf), "K%c%010" PRIll "0%c0%c00",
- is_sub_rcvr(rig, vfo) ? '1' : '0',
- (int64_t) rcvr->last_freq, pcrmode, pcrfilter);
+ is_sub_rcvr(rig, vfo) ? '1' : '0',
+ (int64_t) rcvr->last_freq, pcrmode, pcrfilter);
err = pcr_transaction(rig, (char *) buf);
@@ -916,8 +916,8 @@ pcr_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
else
{
SNPRINTF((char *) buf, sizeof(buf), "K%c%010" PRIll "0%c0%c00",
- is_sub_rcvr(rig, vfo) ? '1' : '0',
- (int64_t) rcvr->last_freq, pcrmode, rcvr->last_filter);
+ is_sub_rcvr(rig, vfo) ? '1' : '0',
+ (int64_t) rcvr->last_freq, pcrmode, rcvr->last_filter);
err = pcr_transaction(rig, (char *) buf);
@@ -1059,13 +1059,13 @@ pcr_get_info(RIG *rig)
}
SNPRINTF(priv->info, sizeof(priv->info), "Firmware v%d.%d, Protocol v%d.%d, "
- "Optional devices:%s%s%s, Country: %s",
- priv->firmware / 10, priv->firmware % 10,
- priv->protocol / 10, priv->protocol % 10,
- (priv->options & OPT_UT106) ? " DSP" : "",
- (priv->options & OPT_UT107) ? " DARC" : "",
- priv->options ? "" : " none",
- country);
+ "Optional devices:%s%s%s, Country: %s",
+ priv->firmware / 10, priv->firmware % 10,
+ priv->protocol / 10, priv->protocol % 10,
+ (priv->options & OPT_UT106) ? " DSP" : "",
+ (priv->options & OPT_UT107) ? " DARC" : "",
+ priv->options ? "" : " none",
+ country);
rig_debug(RIG_DEBUG_VERBOSE, "%s: Firmware v%d.%d, Protocol v%d.%d, "
"Optional devices:%s%s%s, Country: %s\n",
diff --git a/rigs/prm80/prm80.c b/rigs/prm80/prm80.c
index 5a81c5cd3..c1f9858de 100644
--- a/rigs/prm80/prm80.c
+++ b/rigs/prm80/prm80.c
@@ -168,7 +168,8 @@ static int read_prompt_and_send(hamlib_port_t *rigport,
buflen = (data_len == NULL) ? sizeof(buf) : *data_len;
- retval = read_string(rigport, (unsigned char *) data, buflen, delimiter, 1, 0, 1);
+ retval = read_string(rigport, (unsigned char *) data, buflen, delimiter, 1, 0,
+ 1);
if (retval < 0)
{
@@ -384,9 +385,9 @@ int prm80_set_rx_tx_freq(RIG *rig, freq_t rx_freq, freq_t tx_freq)
// for RX, compute the PLL word without the IF
SNPRINTF(rx_freq_buf, sizeof(rx_freq_buf), "%04X",
- rx_freq_to_pll_value(rx_freq));
+ rx_freq_to_pll_value(rx_freq));
SNPRINTF(tx_freq_buf, sizeof(tx_freq_buf), "%04X",
- (unsigned)(tx_freq / FREQ_DIV));
+ (unsigned)(tx_freq / FREQ_DIV));
// The protocol is like this :
// "RX frequency : " XXXX
@@ -644,7 +645,7 @@ static int prm80_do_read_system_state(hamlib_port_t *rigport, char *statebuf)
if (ret < 0)
{
- return(ret);
+ return (ret);
}
// The response length is fixed
@@ -664,7 +665,7 @@ static int prm80_do_read_system_state(hamlib_port_t *rigport, char *statebuf)
{
rig_debug(RIG_DEBUG_ERR, "%s: len=%d < %d, statebuf='%s'\n", __func__,
ret, CMD_E_RSP_LEN, statebuf);
- return(-RIG_EPROTO);
+ return (-RIG_EPROTO);
}
p = strchr(statebuf, '>');
@@ -673,7 +674,8 @@ static int prm80_do_read_system_state(hamlib_port_t *rigport, char *statebuf)
{
int left_to_read = (p - statebuf) + 1;
memmove(statebuf, p + 1, CMD_E_RSP_LEN - left_to_read);
- ret = read_block(rigport, (unsigned char *) statebuf + CMD_E_RSP_LEN - left_to_read,
+ ret = read_block(rigport,
+ (unsigned char *) statebuf + CMD_E_RSP_LEN - left_to_read,
left_to_read);
if (ret < 0)
@@ -908,7 +910,8 @@ int prm80_set_channel(RIG *rig, vfo_t vfo, const channel_t *chan)
if (ret == 3 && buf[2] == 'T')
{
// Read the question
- ret = read_string(&rs->rigport, (unsigned char *) buf, sizeof(buf), "?", 1, 0, 1);
+ ret = read_string(&rs->rigport, (unsigned char *) buf, sizeof(buf), "?", 1, 0,
+ 1);
if (ret < 0)
{
diff --git a/rigs/racal/ra37xx.c b/rigs/racal/ra37xx.c
index 9ddc5b151..f5d2628c3 100644
--- a/rigs/racal/ra37xx.c
+++ b/rigs/racal/ra37xx.c
@@ -119,7 +119,8 @@ static int ra37xx_one_transaction(RIG *rig, const char *cmd, char *data,
do
{
- retval = read_string(&rs->rigport, (unsigned char *) respbuf, BUFSZ, EOM, strlen(EOM), 0, 1);
+ retval = read_string(&rs->rigport, (unsigned char *) respbuf, BUFSZ, EOM,
+ strlen(EOM), 0, 1);
if (retval < 0)
{
@@ -578,7 +579,8 @@ int ra37xx_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
default: return -RIG_EINVAL;
}
- SNPRINTF(cmdbuf, sizeof(cmdbuf), "AGC%d,%d", val.i == RIG_AGC_USER ? 1 : 0, agc);
+ SNPRINTF(cmdbuf, sizeof(cmdbuf), "AGC%d,%d", val.i == RIG_AGC_USER ? 1 : 0,
+ agc);
break;
default:
diff --git a/rigs/racal/racal.c b/rigs/racal/racal.c
index 1983a4201..e453475e2 100644
--- a/rigs/racal/racal.c
+++ b/rigs/racal/racal.c
@@ -97,7 +97,8 @@ static int racal_transaction(RIG *rig, const char *cmd, char *data,
return retval;
}
- retval = read_string(&rs->rigport, (unsigned char *) data, BUFSZ, EOM, strlen(EOM), 0, 1);
+ retval = read_string(&rs->rigport, (unsigned char *) data, BUFSZ, EOM,
+ strlen(EOM), 0, 1);
if (retval <= 0)
{
@@ -561,7 +562,7 @@ const char *racal_get_info(RIG *rig)
}
SNPRINTF(infobuf, sizeof(infobuf), "BITE errors: %s, Filters: %s\n",
- bitebuf + 1, filterbuf);
+ bitebuf + 1, filterbuf);
return infobuf;
}
diff --git a/rigs/rs/gp2000.c b/rigs/rs/gp2000.c
index a29f51289..3f48e4457 100644
--- a/rigs/rs/gp2000.c
+++ b/rigs/rs/gp2000.c
@@ -88,7 +88,7 @@ gp2000_transaction(RIG *rig, const char *cmd, int cmd_len, char *data,
}
retval = read_string(&rs->rigport, (unsigned char *) data, RESPSZ,
- CR, 1, 0, 1);
+ CR, 1, 0, 1);
if (retval < 0)
{
diff --git a/rigs/skanti/skanti.c b/rigs/skanti/skanti.c
index 90d8bf901..bd776ec4d 100644
--- a/rigs/skanti/skanti.c
+++ b/rigs/skanti/skanti.c
@@ -86,7 +86,8 @@ static int skanti_transaction(RIG *rig, const char *cmd, int cmd_len,
* Transceiver sends back ">"
*/
char retbuf[BUFSZ + 1];
- retval = read_string(&rs->rigport, (unsigned char *) retbuf, BUFSZ, PROMPT, strlen(PROMPT), 0, 1);
+ retval = read_string(&rs->rigport, (unsigned char *) retbuf, BUFSZ, PROMPT,
+ strlen(PROMPT), 0, 1);
if (retval < 0)
{
@@ -105,7 +106,8 @@ static int skanti_transaction(RIG *rig, const char *cmd, int cmd_len,
}
}
- retval = read_string(&rs->rigport, (unsigned char *) data, BUFSZ, LF, strlen(LF), 0, 1);
+ retval = read_string(&rs->rigport, (unsigned char *) data, BUFSZ, LF,
+ strlen(LF), 0, 1);
if (retval == -RIG_ETIMEOUT)
{
@@ -274,7 +276,7 @@ int skanti_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
case RIG_LEVEL_RFPOWER:
SNPRINTF(cmdbuf, sizeof(cmdbuf), "M%cO" EOM,
- val.f < 0.33 ? 'L' : (val.f < 0.66 ? 'M' : 'F'));
+ val.f < 0.33 ? 'L' : (val.f < 0.66 ? 'M' : 'F'));
return skanti_transaction(rig, cmdbuf, strlen(cmdbuf), NULL, NULL);
diff --git a/rigs/skanti/trp8255.c b/rigs/skanti/trp8255.c
index 45e733aa3..9f9f740d3 100644
--- a/rigs/skanti/trp8255.c
+++ b/rigs/skanti/trp8255.c
@@ -438,8 +438,8 @@ int cu_set_ts(RIG *rig, vfo_t vfo, shortfreq_t ts)
char cmdbuf[16];
SNPRINTF(cmdbuf, sizeof(cmdbuf), "w%c"CR,
- ts >= s_kHz(1) ? '2' :
- ts >= s_Hz(100) ? '1' : '0');
+ ts >= s_kHz(1) ? '2' :
+ ts >= s_Hz(100) ? '1' : '0');
return cu_transaction(rig, cmdbuf, strlen(cmdbuf));
}
@@ -447,13 +447,14 @@ int cu_set_ts(RIG *rig, vfo_t vfo, shortfreq_t ts)
int cu_set_parm(RIG *rig, setting_t parm, value_t val)
{
char cmdbuf[16];
+
switch (parm)
{
case RIG_PARM_TIME:
/* zap seconds */
val.i /= 60;
SNPRINTF(cmdbuf, sizeof(cmdbuf), "f%02d%02d"CR,
- val.i / 60, val.i % 60);
+ val.i / 60, val.i % 60);
break;
case RIG_PARM_BACKLIGHT:
diff --git a/rigs/tentec/jupiter.c b/rigs/tentec/jupiter.c
index 7ebad2179..1addf36ac 100644
--- a/rigs/tentec/jupiter.c
+++ b/rigs/tentec/jupiter.c
@@ -402,7 +402,8 @@ int tt538_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
SNPRINTF((char *) cmdbuf, sizeof(cmdbuf), "?%c" EOM, which_vfo(rig, vfo));
resp_len = 7;
- retval = tt538_transaction(rig, (char *) cmdbuf, strlen((char*)cmdbuf), (char *) respbuf,
+ retval = tt538_transaction(rig, (char *) cmdbuf, strlen((char *)cmdbuf),
+ (char *) respbuf,
&resp_len);
if (retval != RIG_OK)
@@ -452,10 +453,11 @@ int tt538_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
bytes[0] = (int) freq & 0xff;
SNPRINTF((char *) cmdbuf, sizeof(cmdbuf), "*%c%c%c%c%c" EOM,
- which_vfo(rig, vfo),
- bytes[3], bytes[2], bytes[1], bytes[0]);
+ which_vfo(rig, vfo),
+ bytes[3], bytes[2], bytes[1], bytes[0]);
- return tt538_transaction(rig, (char *) cmdbuf, strlen((char*)cmdbuf), NULL, NULL);
+ return tt538_transaction(rig, (char *) cmdbuf, strlen((char *)cmdbuf), NULL,
+ NULL);
}
/*
@@ -521,7 +523,8 @@ int tt538_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width)
/* Query mode */
SNPRINTF((char *) cmdbuf, sizeof(cmdbuf), "?M" EOM);
resp_len = 5;
- retval = tt538_transaction(rig, (char *) cmdbuf, strlen((char*)cmdbuf), (char *) respbuf,
+ retval = tt538_transaction(rig, (char *) cmdbuf, strlen((char *)cmdbuf),
+ (char *) respbuf,
&resp_len);
if (retval != RIG_OK)
@@ -574,7 +577,8 @@ int tt538_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width)
/* Query passband width (filter) */
SNPRINTF((char *) cmdbuf, sizeof(cmdbuf), "?W" EOM);
resp_len = 4;
- retval = tt538_transaction(rig, (char *) cmdbuf, strlen((char*)cmdbuf), (char *) respbuf,
+ retval = tt538_transaction(rig, (char *) cmdbuf, strlen((char *)cmdbuf),
+ (char *) respbuf,
&resp_len);
if (retval != RIG_OK)
@@ -636,7 +640,8 @@ int tt538_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
/* Query mode for both VFOs. */
SNPRINTF((char *) cmdbuf, sizeof(cmdbuf), "?M" EOM);
resp_len = 5;
- retval = tt538_transaction(rig, (char *) cmdbuf, strlen((char*)cmdbuf), (char *) respbuf,
+ retval = tt538_transaction(rig, (char *) cmdbuf, strlen((char *)cmdbuf),
+ (char *) respbuf,
&resp_len);
if (retval != RIG_OK)
@@ -691,7 +696,8 @@ int tt538_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
return -RIG_EINVAL;
}
- retval = tt538_transaction(rig, (char *) cmdbuf, strlen((char*)cmdbuf), NULL, NULL);
+ retval = tt538_transaction(rig, (char *) cmdbuf, strlen((char *)cmdbuf), NULL,
+ NULL);
if (retval != RIG_OK)
{
@@ -709,7 +715,8 @@ int tt538_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
width = tt538_filter_number((int) width);
SNPRINTF((char *) cmdbuf, sizeof(cmdbuf), "*W%c" EOM, (unsigned char) width);
- return tt538_transaction(rig, (char *) cmdbuf, strlen((char*)cmdbuf), NULL, NULL);
+ return tt538_transaction(rig, (char *) cmdbuf, strlen((char *)cmdbuf), NULL,
+ NULL);
return RIG_OK;
}
@@ -831,7 +838,8 @@ int tt538_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
/* Read rig's AGC level setting. */
SNPRINTF((char *) cmdbuf, sizeof(cmdbuf), "?G" EOM);
lvl_len = 4;
- retval = tt538_transaction(rig, (char *) cmdbuf, strlen((char*)cmdbuf), (char *) lvlbuf,
+ retval = tt538_transaction(rig, (char *) cmdbuf, strlen((char *)cmdbuf),
+ (char *) lvlbuf,
&lvl_len);
if (retval != RIG_OK)
@@ -866,7 +874,8 @@ int tt538_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
/* Volume returned as single byte. */
SNPRINTF((char *) cmdbuf, sizeof(cmdbuf), "?U" EOM);
lvl_len = 4;
- retval = tt538_transaction(rig, (char *) cmdbuf, strlen((char*)cmdbuf), (char *) lvlbuf,
+ retval = tt538_transaction(rig, (char *) cmdbuf, strlen((char *)cmdbuf),
+ (char *) lvlbuf,
&lvl_len);
if (retval != RIG_OK)
@@ -888,7 +897,8 @@ int tt538_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
SNPRINTF((char *) cmdbuf, sizeof(cmdbuf), "?I" EOM);
lvl_len = 4;
- retval = tt538_transaction(rig, (char *) cmdbuf, strlen((char*)cmdbuf), (char *) lvlbuf,
+ retval = tt538_transaction(rig, (char *) cmdbuf, strlen((char *)cmdbuf),
+ (char *) lvlbuf,
&lvl_len);
if (retval != RIG_OK)
@@ -913,7 +923,8 @@ int tt538_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
SNPRINTF((char *) cmdbuf, sizeof(cmdbuf), "?P" EOM);
lvl_len = 5;
- retval = tt538_transaction(rig, (char *) cmdbuf, strlen((char*)cmdbuf), (char *) lvlbuf,
+ retval = tt538_transaction(rig, (char *) cmdbuf, strlen((char *)cmdbuf),
+ (char *) lvlbuf,
& lvl_len);
if (retval != RIG_OK)
@@ -935,7 +946,8 @@ int tt538_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
SNPRINTF((char *) cmdbuf, sizeof(cmdbuf), "?J" EOM);
lvl_len = 4;
- retval = tt538_transaction(rig, (char *) cmdbuf, strlen((char*)cmdbuf), (char *) lvlbuf,
+ retval = tt538_transaction(rig, (char *) cmdbuf, strlen((char *)cmdbuf),
+ (char *) lvlbuf,
&lvl_len);
if (retval != RIG_OK)
@@ -957,7 +969,8 @@ int tt538_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
SNPRINTF((char *) cmdbuf, sizeof(cmdbuf), "?H" EOM);
lvl_len = 4;
- retval = tt538_transaction(rig, (char *) cmdbuf, strlen((char *)cmdbuf), (char *) lvlbuf,
+ retval = tt538_transaction(rig, (char *) cmdbuf, strlen((char *)cmdbuf),
+ (char *) lvlbuf,
&lvl_len);
if (retval != RIG_OK)
@@ -1048,7 +1061,7 @@ int tt538_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
return -RIG_EINVAL;
}
- retval = tt538_transaction(rig, cmdbuf, strlen((char*)cmdbuf), NULL, NULL);
+ retval = tt538_transaction(rig, cmdbuf, strlen((char *)cmdbuf), NULL, NULL);
if (retval != RIG_OK)
{
diff --git a/rigs/tentec/omnivii.c b/rigs/tentec/omnivii.c
index fddae5fec..6576cce9f 100644
--- a/rigs/tentec/omnivii.c
+++ b/rigs/tentec/omnivii.c
@@ -286,7 +286,8 @@ static int tt588_transaction(RIG *rig, const char *cmd, int cmd_len, char *data,
if (data)
{
- retval = read_string(&rs->rigport, (unsigned char *) data, (*data_len) + 1, term, strlen(term), 0,
+ retval = read_string(&rs->rigport, (unsigned char *) data, (*data_len) + 1,
+ term, strlen(term), 0,
1);
if (retval != -RIG_ETIMEOUT)
@@ -475,7 +476,8 @@ int tt588_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
SNPRINTF((char *) cmdbuf, sizeof(cmdbuf), "?%c" EOM, which_vfo(rig, vfo));
resp_len = 6;
- retval = tt588_transaction(rig, (char *) cmdbuf, strlen((char*)cmdbuf), (char *) respbuf,
+ retval = tt588_transaction(rig, (char *) cmdbuf, strlen((char *)cmdbuf),
+ (char *) respbuf,
&resp_len);
if (retval != RIG_OK)
@@ -544,10 +546,11 @@ int tt588_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
bytes[0] = (int) freq & 0xff;
SNPRINTF((char *) cmdbuf, sizeof(cmdbuf), "*%c%c%c%c%c" EOM,
- which_vfo(rig, vfo),
- bytes[3], bytes[2], bytes[1], bytes[0]);
+ which_vfo(rig, vfo),
+ bytes[3], bytes[2], bytes[1], bytes[0]);
- return tt588_transaction(rig, (char *) cmdbuf, strlen((char*)cmdbuf), NULL, NULL);
+ return tt588_transaction(rig, (char *) cmdbuf, strlen((char *)cmdbuf), NULL,
+ NULL);
}
/*
@@ -619,7 +622,8 @@ int tt588_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width)
// Query mode
SNPRINTF((char *) cmdbuf, sizeof(cmdbuf), "?M" EOM);
resp_len = 4;
- retval = tt588_transaction(rig, (char *) cmdbuf, strlen((char*)cmdbuf), (char *) respbuf,
+ retval = tt588_transaction(rig, (char *) cmdbuf, strlen((char *)cmdbuf),
+ (char *) respbuf,
&resp_len);
if (resp_len > 4)
@@ -677,7 +681,8 @@ int tt588_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width)
/* Query passband width (filter) */
SNPRINTF((char *) cmdbuf, sizeof(cmdbuf), "?W" EOM);
resp_len = 3;
- retval = tt588_transaction(rig, (char *) cmdbuf, strlen((char*)cmdbuf), (char *) respbuf,
+ retval = tt588_transaction(rig, (char *) cmdbuf, strlen((char *)cmdbuf),
+ (char *) respbuf,
&resp_len);
if (retval != RIG_OK)
@@ -819,7 +824,8 @@ int tt588_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
/* Query mode for both VFOs. */
SNPRINTF((char *) cmdbuf, sizeof(cmdbuf), "?M" EOM);
resp_len = 4;
- retval = tt588_transaction(rig, (char *) cmdbuf, strlen((char*)cmdbuf), (char *) respbuf,
+ retval = tt588_transaction(rig, (char *) cmdbuf, strlen((char *)cmdbuf),
+ (char *) respbuf,
&resp_len);
if (retval != RIG_OK)
@@ -874,7 +880,8 @@ int tt588_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
return -RIG_EINVAL;
}
- retval = tt588_transaction(rig, (char *) cmdbuf, strlen((char*)cmdbuf), NULL, NULL);
+ retval = tt588_transaction(rig, (char *) cmdbuf, strlen((char *)cmdbuf), NULL,
+ NULL);
if (retval != RIG_OK)
{
@@ -891,7 +898,8 @@ int tt588_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
width = tt588_filter_number((int) width);
SNPRINTF((char *) cmdbuf, sizeof(cmdbuf), "*W%c" EOM, (unsigned char) width);
- return tt588_transaction(rig, (char *) cmdbuf, strlen((char*)cmdbuf), NULL, NULL);
+ return tt588_transaction(rig, (char *) cmdbuf, strlen((char *)cmdbuf), NULL,
+ NULL);
}
/*
@@ -1009,7 +1017,8 @@ int tt588_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
/* Read rig's AGC level setting. */
SNPRINTF((char *) cmdbuf, sizeof(cmdbuf), "?G" EOM);
lvl_len = 3;
- retval = tt588_transaction(rig, (char *) cmdbuf, strlen((char*)cmdbuf), (char *) lvlbuf,
+ retval = tt588_transaction(rig, (char *) cmdbuf, strlen((char *)cmdbuf),
+ (char *) lvlbuf,
&lvl_len);
if (retval != RIG_OK)
@@ -1043,7 +1052,8 @@ int tt588_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
/* Volume returned as single byte. */
SNPRINTF((char *) cmdbuf, sizeof(cmdbuf), "?U" EOM);
lvl_len = 3;
- retval = tt588_transaction(rig, (char *) cmdbuf, strlen((char*)cmdbuf), (char *) lvlbuf,
+ retval = tt588_transaction(rig, (char *) cmdbuf, strlen((char *)cmdbuf),
+ (char *) lvlbuf,
&lvl_len);
if (retval != RIG_OK)
@@ -1069,7 +1079,8 @@ int tt588_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
case RIG_LEVEL_RF:
SNPRINTF((char *) cmdbuf, sizeof(cmdbuf), "?I" EOM);
lvl_len = 3;
- retval = tt588_transaction(rig, (char *) cmdbuf, strlen((char*)cmdbuf), (char *) lvlbuf,
+ retval = tt588_transaction(rig, (char *) cmdbuf, strlen((char *)cmdbuf),
+ (char *) lvlbuf,
&lvl_len);
if (retval != RIG_OK)
@@ -1090,7 +1101,8 @@ int tt588_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
SNPRINTF((char *) cmdbuf, sizeof(cmdbuf), "?J" EOM);
lvl_len = 33;
- retval = tt588_transaction(rig, (char *) cmdbuf, strlen((char*)cmdbuf), (char *) lvlbuf,
+ retval = tt588_transaction(rig, (char *) cmdbuf, strlen((char *)cmdbuf),
+ (char *) lvlbuf,
&lvl_len);
if (retval != RIG_OK)
@@ -1119,7 +1131,8 @@ int tt588_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
SNPRINTF((char *) cmdbuf, sizeof(cmdbuf), "?H" EOM);
lvl_len = 3;
- retval = tt588_transaction(rig, (char *) cmdbuf, strlen((char*)cmdbuf), (char *) lvlbuf,
+ retval = tt588_transaction(rig, (char *) cmdbuf, strlen((char *)cmdbuf),
+ (char *) lvlbuf,
&lvl_len);
if (retval != RIG_OK)
@@ -1188,7 +1201,8 @@ int tt588_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
/* Volume */
SNPRINTF((char *) cmdbuf, sizeof(cmdbuf), "*U%c" EOM, (char)(val.f * 127));
- retval = tt588_transaction(rig, (char *) cmdbuf, strlen((char*)cmdbuf), NULL, NULL);
+ retval = tt588_transaction(rig, (char *) cmdbuf, strlen((char *)cmdbuf), NULL,
+ NULL);
if (retval != RIG_OK)
{
@@ -1200,8 +1214,10 @@ int tt588_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
case RIG_LEVEL_RF:
/* RF gain. Omni-VII expects value 0 for full gain, and 127 for lowest gain */
- SNPRINTF((char *) cmdbuf, sizeof(cmdbuf), "*I%c" EOM, 127 - (char)(val.f * 127));
- retval = tt588_transaction(rig, (char *) cmdbuf, strlen((char*)cmdbuf), NULL, NULL);
+ SNPRINTF((char *) cmdbuf, sizeof(cmdbuf), "*I%c" EOM,
+ 127 - (char)(val.f * 127));
+ retval = tt588_transaction(rig, (char *) cmdbuf, strlen((char *)cmdbuf), NULL,
+ NULL);
if (retval != RIG_OK)
{
@@ -1227,7 +1243,8 @@ int tt588_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
SNPRINTF((char *) cmdbuf, sizeof(cmdbuf), "*Gx" EOM);
cmdbuf[2] = agcmode;
- retval = tt588_transaction(rig, (char *) cmdbuf, strlen((char*)cmdbuf), NULL, NULL);
+ retval = tt588_transaction(rig, (char *) cmdbuf, strlen((char *)cmdbuf), NULL,
+ NULL);
if (retval != RIG_OK)
{
@@ -1246,7 +1263,8 @@ int tt588_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
}
SNPRINTF((char *) cmdbuf, sizeof(cmdbuf), "*J%c" EOM, ii + '0');
- retval = tt588_transaction(rig, (char *) cmdbuf, strlen((char*)cmdbuf), NULL, NULL);
+ retval = tt588_transaction(rig, (char *) cmdbuf, strlen((char *)cmdbuf), NULL,
+ NULL);
if (retval != RIG_OK)
{
@@ -1258,7 +1276,8 @@ int tt588_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
case RIG_LEVEL_SQL:
/* Squelch level, float 0.0 - 1.0 */
SNPRINTF((char *) cmdbuf, sizeof(cmdbuf), "*H%c" EOM, (int)(val.f * 127));
- retval = tt588_transaction(rig, (char *) cmdbuf, strlen((char*)cmdbuf), NULL, NULL);
+ retval = tt588_transaction(rig, (char *) cmdbuf, strlen((char *)cmdbuf), NULL,
+ NULL);
if (retval != RIG_OK)
{
@@ -1413,7 +1432,8 @@ int tt588_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt)
cmdbuf[2] = 0;
}
- retval = tt588_transaction(rig, cmdbuf, strlen(cmdbuf), NULL, 0); // no response
+ retval = tt588_transaction(rig, cmdbuf, strlen(cmdbuf), NULL,
+ 0); // no response
if (retval != RIG_OK)
{
@@ -1436,7 +1456,8 @@ const char *tt588_get_info(RIG *rig)
SNPRINTF(cmdbuf, sizeof(cmdbuf), "?V" EOM);
memset(firmware, 0, sizeof(firmware));
rig_debug(RIG_DEBUG_VERBOSE, "%s: firmware_len=%d\n", __func__, firmware_len);
- retval = tt588_transaction(rig, cmdbuf, strlen(cmdbuf), firmware, &firmware_len);
+ retval = tt588_transaction(rig, cmdbuf, strlen(cmdbuf), firmware,
+ &firmware_len);
// Response should be "VER 1010-588 " plus "RADIO x\r" or "REMOTEx\r"
// if x=blank ham band transmit only
@@ -1519,7 +1540,8 @@ static int set_rit_xit(RIG *rig, vfo_t vfo, shortfreq_t rit, int which)
cmdbuf[2] = which; // set xit bit. 0=off,1=rit, 2=xit, 3=both
cmdbuf[3] = rit >> 8;
cmdbuf[4] = rit & 0xff;
- retval = tt588_transaction(rig, cmdbuf, strlen(cmdbuf), NULL, 0); // no response
+ retval = tt588_transaction(rig, cmdbuf, strlen(cmdbuf), NULL,
+ 0); // no response
if (retval != RIG_OK)
{
@@ -1617,7 +1639,8 @@ int tt588_set_ant(RIG *rig, vfo_t vfo, ant_t ant)
// 3 = RX=RXAUC, TX=ANT2
cmdbuf[4] = ant;
// this should be the only line needing change for remote operation
- retval = tt588_transaction(rig, cmdbuf, strlen(cmdbuf), NULL, 0); // no response
+ retval = tt588_transaction(rig, cmdbuf, strlen(cmdbuf), NULL,
+ 0); // no response
if (retval != RIG_OK)
{
diff --git a/rigs/tentec/orion.c b/rigs/tentec/orion.c
index 81f64ba38..21c026146 100644
--- a/rigs/tentec/orion.c
+++ b/rigs/tentec/orion.c
@@ -401,8 +401,8 @@ int tt565_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
/* Use ASCII mode to set frequencies */
// cppcheck-suppress *
SNPRINTF(cmdbuf, sizeof(cmdbuf), "*%cF%"PRIll EOM,
- which_vfo(rig, vfo),
- (int64_t)freq);
+ which_vfo(rig, vfo),
+ (int64_t)freq);
#else
/* Use binary mode */
/* Set frequency using Orion's binary mode (short) sequence.
@@ -442,11 +442,11 @@ int tt565_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
#ifdef TT565_ASCII_FREQ
/* use ASCII mode */
SNPRINTF(cmdbuf, sizeof(cmdbuf), "?%cF" EOM,
- which_vfo(rig, vfo));
+ which_vfo(rig, vfo));
#else
/* Get freq with Orion binary mode short sequence. */
SNPRINTF(cmdbuf, sizeof(cmdbuf), "?%c" EOM,
- which_vfo(rig, vfo));
+ which_vfo(rig, vfo));
#endif
resp_len = sizeof(respbuf);
retval = tt565_transaction(rig, cmdbuf, strlen(cmdbuf), respbuf, &resp_len);
@@ -500,7 +500,7 @@ int tt565_set_vfo(RIG *rig, vfo_t vfo)
char vfobuf[TT565_BUFSIZE];
/* Select Sub or Main RX */
SNPRINTF(vfobuf, sizeof(vfobuf), "*K%c" EOM,
- vfo == RIG_VFO_SUB ? 'S' : 'M');
+ vfo == RIG_VFO_SUB ? 'S' : 'M');
return tt565_transaction(rig, vfobuf, strlen(vfobuf), NULL, NULL);
}
@@ -541,9 +541,9 @@ int tt565_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, vfo_t tx_vfo)
char cmdbuf[TT565_BUFSIZE];
SNPRINTF(cmdbuf, sizeof(cmdbuf), "*KV%c%c%c" EOM,
- which_vfo(rig, vfo),
- 'N', /* FIXME */
- which_vfo(rig, RIG_SPLIT_ON == split ? tx_vfo : vfo));
+ which_vfo(rig, vfo),
+ 'N', /* FIXME */
+ which_vfo(rig, RIG_SPLIT_ON == split ? tx_vfo : vfo));
retval = tt565_transaction(rig, cmdbuf, strlen(cmdbuf), NULL, NULL);
@@ -659,11 +659,11 @@ int tt565_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
ttreceiver = which_receiver(rig, vfo);
SNPRINTF(mdbuf, sizeof(mdbuf), "*R%cM%c" EOM "*R%cF%d" EOM,
- ttreceiver,
- ttmode,
- ttreceiver,
- (int)width
- );
+ ttreceiver,
+ ttmode,
+ ttreceiver,
+ (int)width
+ );
retval = write_block(&rs->rigport, (unsigned char *) mdbuf, strlen(mdbuf));
@@ -766,8 +766,8 @@ int tt565_set_ts(RIG *rig, vfo_t vfo, shortfreq_t ts)
char cmdbuf[TT565_BUFSIZE];
SNPRINTF(cmdbuf, sizeof(cmdbuf), "*R%cI%d" EOM,
- which_receiver(rig, vfo),
- (int)ts);
+ which_receiver(rig, vfo),
+ (int)ts);
retval = tt565_transaction(rig, cmdbuf, strlen(cmdbuf), NULL, NULL);
@@ -787,7 +787,7 @@ int tt565_get_ts(RIG *rig, vfo_t vfo, shortfreq_t *ts)
char cmdbuf[TT565_BUFSIZE], respbuf[TT565_BUFSIZE];
SNPRINTF(cmdbuf, sizeof(cmdbuf), "?R%cI" EOM,
- which_receiver(rig, vfo));
+ which_receiver(rig, vfo));
resp_len = sizeof(respbuf);
retval = tt565_transaction(rig, cmdbuf, strlen(cmdbuf), respbuf, &resp_len);
@@ -823,8 +823,8 @@ int tt565_set_rit(RIG *rig, vfo_t vfo, shortfreq_t rit)
char cmdbuf[TT565_BUFSIZE];
SNPRINTF(cmdbuf, sizeof(cmdbuf), "*R%cR%d" EOM,
- which_receiver(rig, vfo),
- (int)rit);
+ which_receiver(rig, vfo),
+ (int)rit);
retval = tt565_transaction(rig, cmdbuf, strlen(cmdbuf), NULL, NULL);
@@ -844,7 +844,7 @@ int tt565_get_rit(RIG *rig, vfo_t vfo, shortfreq_t *rit)
char cmdbuf[TT565_BUFSIZE], respbuf[TT565_BUFSIZE];
SNPRINTF(cmdbuf, sizeof(cmdbuf), "?R%cR" EOM,
- which_receiver(rig, vfo));
+ which_receiver(rig, vfo));
resp_len = sizeof(respbuf);
retval = tt565_transaction(rig, cmdbuf, strlen(cmdbuf), respbuf, &resp_len);
@@ -882,8 +882,8 @@ int tt565_set_xit(RIG *rig, vfo_t vfo, shortfreq_t xit)
/* Sub receiver does not contain an XIT setting */
SNPRINTF(cmdbuf, sizeof(cmdbuf), "*R%cX%d" EOM,
- 'M',
- (int)xit);
+ 'M',
+ (int)xit);
retval = tt565_transaction(rig, cmdbuf, strlen(cmdbuf), NULL, NULL);
@@ -903,7 +903,7 @@ int tt565_get_xit(RIG *rig, vfo_t vfo, shortfreq_t *xit)
char cmdbuf[TT565_BUFSIZE], respbuf[TT565_BUFSIZE];
SNPRINTF(cmdbuf, sizeof(cmdbuf), "?R%cX" EOM,
- 'M');
+ 'M');
resp_len = sizeof(respbuf);
retval = tt565_transaction(rig, cmdbuf, strlen(cmdbuf), respbuf, &resp_len);
@@ -937,7 +937,7 @@ int tt565_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt)
struct rig_state *rs = &rig->state;
return write_block(&rs->rigport,
- (unsigned char *) (ptt == RIG_PTT_ON ? "*TK" EOM : "*TU" EOM), 4);
+ (unsigned char *)(ptt == RIG_PTT_ON ? "*TK" EOM : "*TU" EOM), 4);
}
/**
@@ -1076,7 +1076,7 @@ int tt565_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
{
case RIG_LEVEL_RFPOWER:
SNPRINTF(cmdbuf, sizeof(cmdbuf), "*TP%d" EOM,
- (int)(val.f * 100));
+ (int)(val.f * 100));
break;
case RIG_LEVEL_AGC:
@@ -1096,29 +1096,29 @@ int tt565_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
}
SNPRINTF(cmdbuf, sizeof(cmdbuf), "*R%cA%c" EOM,
- which_receiver(rig, vfo),
- cc);
+ which_receiver(rig, vfo),
+ cc);
break;
case RIG_LEVEL_AF:
/* AF Gain, float 0.0 - 1.0 */
SNPRINTF(cmdbuf, sizeof(cmdbuf), "*U%c%d" EOM,
- which_receiver(rig, vfo),
- (int)(val.f * 255));
+ which_receiver(rig, vfo),
+ (int)(val.f * 255));
break;
case RIG_LEVEL_IF:
/* This is passband tuning int Hz */
SNPRINTF(cmdbuf, sizeof(cmdbuf), "*R%cP%d" EOM,
- which_receiver(rig, vfo),
- val.i);
+ which_receiver(rig, vfo),
+ val.i);
break;
case RIG_LEVEL_RF:
/* This is IF Gain, float 0.0 - 1.0 */
SNPRINTF(cmdbuf, sizeof(cmdbuf), "*R%cG%d" EOM,
- which_receiver(rig, vfo),
- (int)(val.f * 100));
+ which_receiver(rig, vfo),
+ (int)(val.f * 100));
break;
case RIG_LEVEL_ATT:
@@ -1131,8 +1131,8 @@ int tt565_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
}
SNPRINTF(cmdbuf, sizeof(cmdbuf), "*R%cT%d" EOM,
- which_receiver(rig, vfo),
- ii);
+ which_receiver(rig, vfo),
+ ii);
break;
case RIG_LEVEL_PREAMP:
@@ -1145,26 +1145,26 @@ int tt565_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
/* RF Preamp (main Rx), int 0 or 1 */
SNPRINTF(cmdbuf, sizeof(cmdbuf), "*RME%d" EOM,
- val.i == 0 ? 0 : 1);
+ val.i == 0 ? 0 : 1);
break;
case RIG_LEVEL_SQL:
/* Squelch level, float 0.0 - 1.0 */
SNPRINTF(cmdbuf, sizeof(cmdbuf), "*R%cS%d" EOM,
- which_receiver(rig, vfo),
- (int)((val.f * 127) - 127));
+ which_receiver(rig, vfo),
+ (int)((val.f * 127) - 127));
break;
case RIG_LEVEL_MICGAIN:
/* Mic gain, float 0.0 - 1.0 */
SNPRINTF(cmdbuf, sizeof(cmdbuf), "*TM%d" EOM,
- (int)(val.f * 100));
+ (int)(val.f * 100));
break;
case RIG_LEVEL_COMP:
/* Speech Processor, float 0.0 - 1.0 */
SNPRINTF(cmdbuf, sizeof(cmdbuf), "*TS%d" EOM,
- (int)(val.f * 9));
+ (int)(val.f * 9));
break;
case RIG_LEVEL_CWPITCH:
@@ -1177,7 +1177,7 @@ int tt565_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
else if (val.i < TT565_TONE_MIN) { val.i = TT565_TONE_MIN; }
SNPRINTF(cmdbuf, sizeof(cmdbuf), "*CT%d" EOM,
- val.i);
+ val.i);
break;
case RIG_LEVEL_KEYSPD:
@@ -1190,7 +1190,7 @@ int tt565_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
else if (val.i < TT565_CW_MIN) { val.i = TT565_CW_MIN; }
SNPRINTF(cmdbuf, sizeof(cmdbuf), "*CS%d" EOM,
- val.i);
+ val.i);
break;
case RIG_LEVEL_NR:
@@ -1200,8 +1200,8 @@ int tt565_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
FOR NOW -- RIG_LEVEL_NR controls the Orion NB setting
*/
SNPRINTF(cmdbuf, sizeof(cmdbuf), "*R%cNB%d" EOM,
- which_receiver(rig, vfo),
- (int)(val.f * 9));
+ which_receiver(rig, vfo),
+ (int)(val.f * 9));
break;
case RIG_LEVEL_VOXDELAY:
@@ -1367,7 +1367,7 @@ int tt565_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
case RIG_LEVEL_AGC:
SNPRINTF(cmdbuf, sizeof(cmdbuf), "?R%cA" EOM,
- which_receiver(rig, vfo));
+ which_receiver(rig, vfo));
lvl_len = sizeof(lvlbuf);
retval = tt565_transaction(rig, cmdbuf, strlen(cmdbuf), lvlbuf, &lvl_len);
@@ -1404,7 +1404,7 @@ int tt565_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
case RIG_LEVEL_AF:
SNPRINTF(cmdbuf, sizeof(cmdbuf), "?U%c" EOM,
- which_receiver(rig, vfo));
+ which_receiver(rig, vfo));
lvl_len = sizeof(lvlbuf);
retval = tt565_transaction(rig, cmdbuf, strlen(cmdbuf), lvlbuf, &lvl_len);
@@ -1426,7 +1426,7 @@ int tt565_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
case RIG_LEVEL_IF:
SNPRINTF(cmdbuf, sizeof(cmdbuf), "?R%cP" EOM, /* passband tuning */
- which_receiver(rig, vfo));
+ which_receiver(rig, vfo));
lvl_len = sizeof(lvlbuf);
retval = tt565_transaction(rig, cmdbuf, strlen(cmdbuf), lvlbuf, &lvl_len);
@@ -1448,7 +1448,7 @@ int tt565_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
case RIG_LEVEL_RF:
SNPRINTF(cmdbuf, sizeof(cmdbuf), "?R%cG" EOM,
- which_receiver(rig, vfo));
+ which_receiver(rig, vfo));
lvl_len = sizeof(lvlbuf);
retval = tt565_transaction(rig, cmdbuf, strlen(cmdbuf), lvlbuf, &lvl_len);
@@ -1470,7 +1470,7 @@ int tt565_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
case RIG_LEVEL_ATT:
SNPRINTF(cmdbuf, sizeof(cmdbuf), "?R%cT" EOM,
- which_receiver(rig, vfo));
+ which_receiver(rig, vfo));
lvl_len = sizeof(lvlbuf);
retval = tt565_transaction(rig, cmdbuf, strlen(cmdbuf), lvlbuf, &lvl_len);
@@ -1527,7 +1527,7 @@ int tt565_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
case RIG_LEVEL_SQL:
SNPRINTF(cmdbuf, sizeof(cmdbuf), "?R%cS" EOM,
- which_receiver(rig, vfo));
+ which_receiver(rig, vfo));
lvl_len = sizeof(lvlbuf);
retval = tt565_transaction(rig, cmdbuf, strlen(cmdbuf), lvlbuf, &lvl_len);
@@ -1626,7 +1626,7 @@ int tt565_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
case RIG_LEVEL_NR:
/* RIG_LEVEL_NR controls Orion NB setting - TEMP */
SNPRINTF(cmdbuf, sizeof(cmdbuf), "?R%cNB" EOM,
- which_receiver(rig, vfo));
+ which_receiver(rig, vfo));
lvl_len = sizeof(lvlbuf);
retval = tt565_transaction(rig, cmdbuf, strlen(cmdbuf), lvlbuf, &lvl_len);
@@ -1770,9 +1770,9 @@ int tt565_vfo_op(RIG *rig, vfo_t vfo, vfo_op_t op)
case RIG_OP_TO_VFO:
case RIG_OP_FROM_VFO:
SNPRINTF(cmdbuf, sizeof(cmdbuf), "*K%c%c%d" EOM,
- op == RIG_OP_TO_VFO ? 'R' : 'W',
- which_vfo(rig, vfo),
- priv->ch);
+ op == RIG_OP_TO_VFO ? 'R' : 'W',
+ which_vfo(rig, vfo),
+ priv->ch);
break;
case RIG_OP_TUNE:
@@ -1782,8 +1782,8 @@ int tt565_vfo_op(RIG *rig, vfo_t vfo, vfo_op_t op)
case RIG_OP_UP:
case RIG_OP_DOWN:
SNPRINTF(cmdbuf, sizeof(cmdbuf), "*%cS%c1" EOM,
- which_vfo(rig, vfo),
- op == RIG_OP_UP ? '+' : '-');
+ which_vfo(rig, vfo),
+ op == RIG_OP_UP ? '+' : '-');
break;
default:
@@ -1891,8 +1891,8 @@ int tt565_set_func(RIG *rig, vfo_t vfo, setting_t func, int status)
case RIG_FUNC_LOCK:
SNPRINTF(fcmdbuf, sizeof(fcmdbuf), "*%c%c" EOM,
- which_vfo(rig, vfo),
- !status ? 'U' : 'L');
+ which_vfo(rig, vfo),
+ !status ? 'U' : 'L');
break;
case RIG_FUNC_NB:
@@ -1901,8 +1901,8 @@ int tt565_set_func(RIG *rig, vfo_t vfo, setting_t func, int status)
limitation.
*/
SNPRINTF(fcmdbuf, sizeof(fcmdbuf), "*R%cNB%c" EOM,
- which_receiver(rig, vfo),
- !status ? '0' : '4');
+ which_receiver(rig, vfo),
+ !status ? '0' : '4');
break;
default:
@@ -1952,7 +1952,7 @@ int tt565_get_func(RIG *rig, vfo_t vfo, setting_t func, int *status)
case RIG_FUNC_LOCK:
SNPRINTF(fcmdbuf, sizeof(fcmdbuf), "?%cU" EOM,
- which_vfo(rig, vfo));
+ which_vfo(rig, vfo));
/* needs special treatment */
fresplen = sizeof(frespbuf);
retval = tt565_transaction(rig, fcmdbuf, strlen(fcmdbuf),
@@ -1972,7 +1972,7 @@ int tt565_get_func(RIG *rig, vfo_t vfo, setting_t func, int *status)
available through LEVEL_NR
*/
SNPRINTF(fcmdbuf, sizeof(fcmdbuf), "?R%cNB" EOM,
- which_receiver(rig, vfo));
+ which_receiver(rig, vfo));
/* needs special treatment */
fresplen = sizeof(frespbuf);
retval = tt565_transaction(rig, fcmdbuf, strlen(fcmdbuf),
diff --git a/rigs/tentec/paragon.c b/rigs/tentec/paragon.c
index 3630fd59b..cbe84fc6d 100644
--- a/rigs/tentec/paragon.c
+++ b/rigs/tentec/paragon.c
@@ -589,7 +589,7 @@ int tt585_get_status_data(RIG *rig)
return ret;
}
- ret = read_block(rigport, (unsigned char *) (char *) priv->status_data,
+ ret = read_block(rigport, (unsigned char *)(char *) priv->status_data,
sizeof(priv->status_data));
if (ret < 0)
diff --git a/rigs/tentec/rx331.c b/rigs/tentec/rx331.c
index f192ce04f..fb5c60669 100644
--- a/rigs/tentec/rx331.c
+++ b/rigs/tentec/rx331.c
@@ -274,7 +274,7 @@ static int rx331_transaction(RIG *rig, const char *cmd, int cmd_len, char *data,
return retval;
}
- SNPRINTF(fmt, sizeof(fmt)-1, "%%i%%%ds", BUFSZ);
+ SNPRINTF(fmt, sizeof(fmt) - 1, "%%i%%%ds", BUFSZ);
sscanf(data + 1, fmt, &rig_id, data);
if (rig_id != priv->receiver_id)
@@ -402,7 +402,7 @@ int rx331_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
char freqbuf[16];
freq_len = num_snprintf(freqbuf, sizeof(freqbuf), "$%uF%.6f" EOM,
- priv->receiver_id, freq / 1e6);
+ priv->receiver_id, freq / 1e6);
retval = write_block(&rs->rigport, (unsigned char *) freqbuf, freq_len);
@@ -483,15 +483,17 @@ int rx331_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
/*
* Set DETECTION MODE and IF FILTER
*/
- mdbuf_len = num_snprintf(mdbuf, sizeof(mdbuf), "$%uD%cI%.02f" EOM, priv->receiver_id,
- dmode, (float)width / 1e3);
+ mdbuf_len = num_snprintf(mdbuf, sizeof(mdbuf), "$%uD%cI%.02f" EOM,
+ priv->receiver_id,
+ dmode, (float)width / 1e3);
}
else
{
/*
* Set DETECTION MODE
*/
- mdbuf_len = num_snprintf(mdbuf, sizeof(mdbuf), "$%uD%c" EOM, priv->receiver_id, dmode);
+ mdbuf_len = num_snprintf(mdbuf, sizeof(mdbuf), "$%uD%c" EOM, priv->receiver_id,
+ dmode);
}
retval = write_block(&rs->rigport, (unsigned char *) mdbuf, mdbuf_len);
@@ -573,14 +575,14 @@ int rx331_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
{
case RIG_LEVEL_ATT:
SNPRINTF(cmdbuf, sizeof(cmdbuf), "$%uK%i" EOM,
- priv->receiver_id,
- val.i ? RX331_ATT_ON : RX331_ATT_OFF);
+ priv->receiver_id,
+ val.i ? RX331_ATT_ON : RX331_ATT_OFF);
break;
case RIG_LEVEL_PREAMP:
SNPRINTF(cmdbuf, sizeof(cmdbuf), "$%uK%i" EOM,
- priv->receiver_id,
- val.i ? RX331_PREAMP_ON : RX331_PREAMP_OFF);
+ priv->receiver_id,
+ val.i ? RX331_PREAMP_ON : RX331_PREAMP_OFF);
break;
case RIG_LEVEL_AGC:
@@ -602,33 +604,33 @@ int rx331_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
}
SNPRINTF(cmdbuf, sizeof(cmdbuf), "$%uM%i" EOM,
- priv->receiver_id, val.i);
+ priv->receiver_id, val.i);
break;
case RIG_LEVEL_RF:
SNPRINTF(cmdbuf, sizeof(cmdbuf), "$%uA%d" EOM, priv->receiver_id,
- 120 - (int)(val.f * 120));
+ 120 - (int)(val.f * 120));
break;
case RIG_LEVEL_SQL:
SNPRINTF(cmdbuf, sizeof(cmdbuf), "$%uQ%d" EOM, priv->receiver_id,
- 120 - (int)(val.f * 120));
+ 120 - (int)(val.f * 120));
break;
case RIG_LEVEL_NOTCHF:
num_snprintf(cmdbuf, sizeof(cmdbuf), "$%uN%f" EOM, priv->receiver_id,
- ((float)val.i) / 1e3);
+ ((float)val.i) / 1e3);
break;
case RIG_LEVEL_IF:
num_snprintf(cmdbuf, sizeof(cmdbuf), "$%uP%f" EOM, priv->receiver_id,
- ((float)val.i) / 1e3);
+ ((float)val.i) / 1e3);
break;
case RIG_LEVEL_CWPITCH:
/* only in CW mode */
num_snprintf(cmdbuf, sizeof(cmdbuf), "$%uB%f" EOM, priv->receiver_id,
- ((float)val.i) / 1e3);
+ ((float)val.i) / 1e3);
break;
default:
diff --git a/rigs/tentec/rx340.c b/rigs/tentec/rx340.c
index 54dcdfd69..ecbf71cdf 100644
--- a/rigs/tentec/rx340.c
+++ b/rigs/tentec/rx340.c
@@ -280,7 +280,8 @@ int rx340_open(RIG *rig)
struct rig_state *rs = &rig->state;
#define REMOTE_CMD "*R1"EOM
- return write_block(&rs->rigport, (unsigned char *) REMOTE_CMD, strlen(REMOTE_CMD));
+ return write_block(&rs->rigport, (unsigned char *) REMOTE_CMD,
+ strlen(REMOTE_CMD));
}
int rx340_close(RIG *rig)
@@ -288,7 +289,8 @@ int rx340_close(RIG *rig)
struct rig_state *rs = &rig->state;
#define LOCAL_CMD "*R0"EOM
- return write_block(&rs->rigport, (unsigned char *) LOCAL_CMD, strlen(LOCAL_CMD));
+ return write_block(&rs->rigport, (unsigned char *) LOCAL_CMD,
+ strlen(LOCAL_CMD));
}
/*
@@ -382,7 +384,7 @@ int rx340_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
* Set DETECTION MODE and IF FILTER
*/
SNPRINTF(mdbuf, sizeof(mdbuf), "D%cI%.02f" EOM,
- dmode, (float)width / 1e3);
+ dmode, (float)width / 1e3);
}
else
{
@@ -481,8 +483,8 @@ int rx340_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
case RIG_LEVEL_AGC:
/* default to MEDIUM */
SNPRINTF(cmdbuf, sizeof(cmdbuf), "M%c" EOM,
- val.i == RIG_AGC_SLOW ? '3' : (
- val.i == RIG_AGC_FAST ? '1' : '2'));
+ val.i == RIG_AGC_SLOW ? '3' : (
+ val.i == RIG_AGC_FAST ? '1' : '2'));
break;
case RIG_LEVEL_RF:
diff --git a/rigs/tentec/tentec.c b/rigs/tentec/tentec.c
index 66f7b1a18..b4d5c1141 100644
--- a/rigs/tentec/tentec.c
+++ b/rigs/tentec/tentec.c
@@ -83,7 +83,8 @@ int tentec_transaction(RIG *rig, const char *cmd, int cmd_len, char *data,
return 0;
}
- retval = read_string(&rs->rigport, (unsigned char *) data, *data_len, NULL, 0, 0, 1);
+ retval = read_string(&rs->rigport, (unsigned char *) data, *data_len, NULL, 0,
+ 0, 1);
if (retval == -RIG_ETIMEOUT)
{
@@ -245,9 +246,9 @@ int tentec_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
tentec_tuning_factor_calc(rig);
SNPRINTF(freqbuf, sizeof(freqbuf), "N%c%c%c%c%c%c" EOM,
- priv->ctf >> 8, priv->ctf & 0xff,
- priv->ftf >> 8, priv->ftf & 0xff,
- priv->btf >> 8, priv->btf & 0xff);
+ priv->ctf >> 8, priv->ctf & 0xff,
+ priv->ftf >> 8, priv->ftf & 0xff,
+ priv->btf >> 8, priv->btf & 0xff);
retval = write_block(&rs->rigport, (unsigned char *) freqbuf, strlen(freqbuf));
@@ -343,13 +344,13 @@ int tentec_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
if (width != RIG_PASSBAND_NOCHANGE)
{
SNPRINTF(mdbuf, sizeof(mdbuf), "W%c" EOM
- "N%c%c%c%c%c%c" EOM
- "M%c" EOM,
- ttfilter,
- priv->ctf >> 8, priv->ctf & 0xff,
- priv->ftf >> 8, priv->ftf & 0xff,
- priv->btf >> 8, priv->btf & 0xff,
- ttmode);
+ "N%c%c%c%c%c%c" EOM
+ "M%c" EOM,
+ ttfilter,
+ priv->ctf >> 8, priv->ctf & 0xff,
+ priv->ftf >> 8, priv->ftf & 0xff,
+ priv->btf >> 8, priv->btf & 0xff,
+ ttmode);
retval = write_block(&rs->rigport, (unsigned char *) mdbuf, strlen(mdbuf));
if (retval != RIG_OK)
@@ -362,12 +363,12 @@ int tentec_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
else
{
SNPRINTF(mdbuf, sizeof(mdbuf),
- "N%c%c%c%c%c%c" EOM
- "M%c" EOM,
- priv->ctf >> 8, priv->ctf & 0xff,
- priv->ftf >> 8, priv->ftf & 0xff,
- priv->btf >> 8, priv->btf & 0xff,
- ttmode);
+ "N%c%c%c%c%c%c" EOM
+ "M%c" EOM,
+ priv->ctf >> 8, priv->ctf & 0xff,
+ priv->ftf >> 8, priv->ftf & 0xff,
+ priv->btf >> 8, priv->btf & 0xff,
+ ttmode);
retval = write_block(&rs->rigport, (unsigned char *) mdbuf, strlen(mdbuf));
if (retval != RIG_OK)
@@ -415,8 +416,8 @@ int tentec_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
case RIG_LEVEL_AGC:
/* default to MEDIUM */
SNPRINTF(cmdbuf, sizeof(cmdbuf), "G%c" EOM,
- val.i == RIG_AGC_SLOW ? '1' : (
- val.i == RIG_AGC_FAST ? '3' : '2'));
+ val.i == RIG_AGC_SLOW ? '1' : (
+ val.i == RIG_AGC_FAST ? '3' : '2'));
retval = write_block(&rs->rigport, (unsigned char *) cmdbuf, strlen(cmdbuf));
if (retval == RIG_OK)
diff --git a/rigs/tentec/tt550.c b/rigs/tentec/tt550.c
index 60c22def8..31ce98169 100644
--- a/rigs/tentec/tt550.c
+++ b/rigs/tentec/tt550.c
@@ -101,7 +101,8 @@ tt550_transaction(RIG *rig, const char *cmd, int cmd_len, char *data,
return 0;
}
- retval = read_string(&rs->rigport, (unsigned char *) data, *data_len, NULL, 0, 0, 1);
+ retval = read_string(&rs->rigport, (unsigned char *) data, *data_len, NULL, 0,
+ 0, 1);
if (retval == -RIG_ETIMEOUT)
{
@@ -614,8 +615,8 @@ tt550_set_rx_freq(RIG *rig, vfo_t vfo, freq_t freq)
tt550_tuning_factor_calc(rig, RECEIVE);
SNPRINTF(freqbuf, sizeof(freqbuf), "N%c%c%c%c%c%c" EOM,
- priv->ctf >> 8, priv->ctf & 0xff, priv->ftf >> 8,
- priv->ftf & 0xff, priv->btf >> 8, priv->btf & 0xff);
+ priv->ctf >> 8, priv->ctf & 0xff, priv->ftf >> 8,
+ priv->ftf & 0xff, priv->btf >> 8, priv->btf & 0xff);
retval = write_block(&rs->rigport, (unsigned char *) freqbuf, strlen(freqbuf));
@@ -648,8 +649,8 @@ tt550_set_tx_freq(RIG *rig, vfo_t vfo, freq_t freq)
tt550_tuning_factor_calc(rig, TRANSMIT);
SNPRINTF(freqbuf, sizeof(freqbuf), "T%c%c%c%c%c%c" EOM,
- priv->ctf >> 8, priv->ctf & 0xff, priv->ftf >> 8,
- priv->ftf & 0xff, priv->btf >> 8, priv->btf & 0xff);
+ priv->ctf >> 8, priv->ctf & 0xff, priv->ftf >> 8,
+ priv->ftf & 0xff, priv->btf >> 8, priv->btf & 0xff);
retval = write_block(&rs->rigport, (unsigned char *) freqbuf, strlen(freqbuf));
@@ -773,10 +774,10 @@ tt550_set_rx_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
if (width != RIG_PASSBAND_NOCHANGE)
{
SNPRINTF(mdbuf, sizeof(mdbuf), "W%c" EOM
- "N%c%c%c%c%c%c" EOM,
- ttfilter,
- priv->ctf >> 8, priv->ctf & 0xff, priv->ftf >> 8,
- priv->ftf & 0xff, priv->btf >> 8, priv->btf & 0xff);
+ "N%c%c%c%c%c%c" EOM,
+ ttfilter,
+ priv->ctf >> 8, priv->ctf & 0xff, priv->ftf >> 8,
+ priv->ftf & 0xff, priv->btf >> 8, priv->btf & 0xff);
retval = write_block(&rs->rigport, (unsigned char *) mdbuf, strlen(mdbuf));
if (retval != RIG_OK)
@@ -906,10 +907,10 @@ tt550_set_tx_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
if (width != RIG_PASSBAND_NOCHANGE)
{
SNPRINTF(mdbuf, sizeof(mdbuf), "C%c" EOM
- "T%c%c%c%c%c%c" EOM,
- ttfilter,
- priv->ctf >> 8, priv->ctf & 0xff, priv->ftf >> 8,
- priv->ftf & 0xff, priv->btf >> 8, priv->btf & 0xff);
+ "T%c%c%c%c%c%c" EOM,
+ ttfilter,
+ priv->ctf >> 8, priv->ctf & 0xff, priv->ftf >> 8,
+ priv->ftf & 0xff, priv->btf >> 8, priv->btf & 0xff);
retval = write_block(&rs->rigport, (unsigned char *) mdbuf, strlen(mdbuf));
if (retval != RIG_OK)
@@ -1007,7 +1008,7 @@ tt550_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
{
case RIG_LEVEL_AGC:
SNPRINTF(cmdbuf, sizeof(cmdbuf), "G%c" EOM,
- val.i >= 3 ? '3' : (val.i < 2 ? '1' : '2'));
+ val.i >= 3 ? '3' : (val.i < 2 ? '1' : '2'));
retval = write_block(&rs->rigport, (unsigned char *) cmdbuf, strlen(cmdbuf));
if (retval == RIG_OK)
@@ -1095,9 +1096,9 @@ tt550_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
dahfactor = ditfactor * 3;
SNPRINTF(cmdbuf, sizeof(cmdbuf), "E%c%c%c%c%c%c" EOM,
- ditfactor >> 8, ditfactor & 0xff, dahfactor >> 8,
- dahfactor & 0xff, spcfactor >> 8,
- spcfactor & 0xff);
+ ditfactor >> 8, ditfactor & 0xff, dahfactor >> 8,
+ dahfactor & 0xff, spcfactor >> 8,
+ spcfactor & 0xff);
retval = write_block(&rs->rigport, (unsigned char *) cmdbuf, strlen(cmdbuf));
if (retval == RIG_OK)
@@ -1457,19 +1458,20 @@ tt550_set_func(RIG *rig, vfo_t vfo, setting_t func, int status)
case RIG_FUNC_VOX:
SNPRINTF((char *) fctbuf, sizeof(fctbuf), "U%c" EOM, status == 0 ? '0' : '1');
priv->vox = status;
- return write_block(&rs->rigport, fctbuf, strlen((char*)fctbuf));
+ return write_block(&rs->rigport, fctbuf, strlen((char *)fctbuf));
case RIG_FUNC_NR:
SNPRINTF((char *) fctbuf, sizeof(fctbuf), "K%c%c" EOM, status == 0 ? '0' : '1',
- priv->anf == 0 ? '0' : '1');
+ priv->anf == 0 ? '0' : '1');
priv->en_nr = status;
- return write_block(&rs->rigport, fctbuf, strlen((char*)fctbuf));
+ return write_block(&rs->rigport, fctbuf, strlen((char *)fctbuf));
case RIG_FUNC_ANF:
- SNPRINTF((char *) fctbuf, sizeof(fctbuf), "K%c%c" EOM, priv->en_nr == 0 ? '0' : '1',
- status == 0 ? '0' : '1');
+ SNPRINTF((char *) fctbuf, sizeof(fctbuf), "K%c%c" EOM,
+ priv->en_nr == 0 ? '0' : '1',
+ status == 0 ? '0' : '1');
priv->anf = status;
- return write_block(&rs->rigport, fctbuf, strlen((char*)fctbuf));
+ return write_block(&rs->rigport, fctbuf, strlen((char *)fctbuf));
case RIG_FUNC_TUNER:
diff --git a/rigs/uniden/uniden.c b/rigs/uniden/uniden.c
index 36e68b3fe..5321bffe0 100644
--- a/rigs/uniden/uniden.c
+++ b/rigs/uniden/uniden.c
@@ -154,7 +154,8 @@ transaction_write:
}
memset(data, 0, *datasize);
- retval = read_string(&rs->rigport, (unsigned char *) data, *datasize, EOM, strlen(EOM), 0, 1);
+ retval = read_string(&rs->rigport, (unsigned char *) data, *datasize, EOM,
+ strlen(EOM), 0, 1);
if (retval < 0)
{
@@ -437,7 +438,7 @@ int uniden_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
}
SNPRINTF(levelbuf, sizeof(levelbuf), "AT%c"EOM,
- val.i != 0 ? 'N' : 'F');
+ val.i != 0 ? 'N' : 'F');
break;
default:
@@ -701,11 +702,11 @@ int uniden_set_channel(RIG *rig, vfo_t vfo, const channel_t *chan)
/* PM089T08511625 */
SNPRINTF(cmdbuf, sizeof(cmdbuf), "PM%03d%c%08u" EOM, chan->channel_num,
#if 0
- trunked ? 'T' : ' ',
+ trunked ? 'T' : ' ',
#else
- ' ',
+ ' ',
#endif
- (unsigned)(chan->freq / 100));
+ (unsigned)(chan->freq / 100));
ret = uniden_transaction(rig, cmdbuf, strlen(cmdbuf), NULL, membuf, &mem_len);
@@ -718,7 +719,7 @@ int uniden_set_channel(RIG *rig, vfo_t vfo, const channel_t *chan)
{
/* only BC780 BC250 BC785 */
SNPRINTF(cmdbuf, sizeof(cmdbuf), "TA C %03d %s" EOM,
- chan->channel_num, chan->channel_desc);
+ chan->channel_num, chan->channel_desc);
ret = uniden_transaction(rig, cmdbuf, strlen(cmdbuf), NULL, NULL, NULL);
diff --git a/rigs/uniden/uniden_digital.c b/rigs/uniden/uniden_digital.c
index ab1d7c9a1..a6b7695a9 100644
--- a/rigs/uniden/uniden_digital.c
+++ b/rigs/uniden/uniden_digital.c
@@ -136,7 +136,8 @@ transaction_write:
}
memset(data, 0, *datasize);
- retval = read_string(&rs->rigport, (unsigned char *) data, *datasize, EOM, strlen(EOM), 0, 1);
+ retval = read_string(&rs->rigport, (unsigned char *) data, *datasize, EOM,
+ strlen(EOM), 0, 1);
if (retval < 0)
{
diff --git a/rigs/yaesu/ft100.c b/rigs/yaesu/ft100.c
index 2856528de..549f26a3c 100644
--- a/rigs/yaesu/ft100.c
+++ b/rigs/yaesu/ft100.c
@@ -548,7 +548,8 @@ static int ft100_read_status(RIG *rig)
return ret;
}
- ret = read_block(&rig->state.rigport, (unsigned char *) &priv->status, sizeof(FT100_STATUS_INFO));
+ ret = read_block(&rig->state.rigport, (unsigned char *) &priv->status,
+ sizeof(FT100_STATUS_INFO));
rig_debug(RIG_DEBUG_VERBOSE, "%s: read status=%i \n", __func__, ret);
if (ret < 0)
@@ -575,7 +576,8 @@ static int ft100_read_flags(RIG *rig)
return ret;
}
- ret = read_block(&rig->state.rigport, (unsigned char *) &priv->flags, sizeof(FT100_FLAG_INFO));
+ ret = read_block(&rig->state.rigport, (unsigned char *) &priv->flags,
+ sizeof(FT100_FLAG_INFO));
rig_debug(RIG_DEBUG_VERBOSE, "%s: read flags=%i \n", __func__, ret);
if (ret < 0)
@@ -635,10 +637,10 @@ int ft100_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
/* now convert it .... */
SNPRINTF(freq_str, sizeof(freq_str), "%02X%02X%02X%02X",
- priv->status.freq[0],
- priv->status.freq[1],
- priv->status.freq[2],
- priv->status.freq[3]);
+ priv->status.freq[0],
+ priv->status.freq[1],
+ priv->status.freq[2],
+ priv->status.freq[3]);
d1 = strtol(freq_str, NULL, 16);
d2 = (d1 * 1.25); /* fixed 10Hz bug by OH2MMY */
@@ -989,7 +991,8 @@ int ft100_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
return ret;
}
- ret = read_block(&rig->state.rigport, (unsigned char *) &ft100_meter, sizeof(FT100_METER_INFO));
+ ret = read_block(&rig->state.rigport, (unsigned char *) &ft100_meter,
+ sizeof(FT100_METER_INFO));
rig_debug(RIG_DEBUG_VERBOSE, "%s: read meters=%d\n", __func__, ret);
if (ret < 0)
diff --git a/rigs/yaesu/ft1000d.c b/rigs/yaesu/ft1000d.c
index 176e999ba..77ebe8469 100644
--- a/rigs/yaesu/ft1000d.c
+++ b/rigs/yaesu/ft1000d.c
@@ -2490,7 +2490,7 @@ static int ft1000d_get_level(RIG *rig, vfo_t vfo, setting_t level,
return err;
}
- err = read_block(&rig->state.rigport, mdata,FT1000D_READ_METER_LENGTH);
+ err = read_block(&rig->state.rigport, mdata, FT1000D_READ_METER_LENGTH);
if (err < 0)
{
@@ -3494,7 +3494,8 @@ static int ft1000d_send_dynamic_cmd(RIG *rig, unsigned char ci,
priv->p_cmd[1] = p3;
priv->p_cmd[0] = p4;
- err = write_block(&rig->state.rigport, (unsigned char *) &priv->p_cmd, YAESU_CMD_LENGTH);
+ err = write_block(&rig->state.rigport, (unsigned char *) &priv->p_cmd,
+ YAESU_CMD_LENGTH);
if (err != RIG_OK)
{
@@ -3552,7 +3553,8 @@ static int ft1000d_send_dial_freq(RIG *rig, unsigned char ci, freq_t freq)
rig_debug(RIG_DEBUG_TRACE, fmt, __func__, (int64_t)from_bcd(priv->p_cmd,
FT1000D_BCD_DIAL) * 10);
- err = write_block(&rig->state.rigport, (unsigned char *) &priv->p_cmd, YAESU_CMD_LENGTH);
+ err = write_block(&rig->state.rigport, (unsigned char *) &priv->p_cmd,
+ YAESU_CMD_LENGTH);
if (err != RIG_OK)
{
@@ -3617,7 +3619,8 @@ static int ft1000d_send_rit_freq(RIG *rig, unsigned char ci, shortfreq_t rit)
// Store bcd format into privat command storage area
to_bcd(priv->p_cmd, labs(rit) / 10, FT1000D_BCD_RIT);
- err = write_block(&rig->state.rigport, (unsigned char *) &priv->p_cmd, YAESU_CMD_LENGTH);
+ err = write_block(&rig->state.rigport, (unsigned char *) &priv->p_cmd,
+ YAESU_CMD_LENGTH);
if (err != RIG_OK)
{
diff --git a/rigs/yaesu/ft3000.c b/rigs/yaesu/ft3000.c
index c3c00424c..ff50faf28 100644
--- a/rigs/yaesu/ft3000.c
+++ b/rigs/yaesu/ft3000.c
@@ -259,7 +259,7 @@ const struct rig_caps ftdx3000_caps =
.serial_handshake = RIG_HANDSHAKE_HARDWARE,
// write_delay 5ms or less was causing VS1;VS; to answer with VS0 instead of VS1 even though change did occur
// see https://github.com/Hamlib/Hamlib/issues/906
- .write_delay = 0,
+ .write_delay = 0,
.post_write_delay = FTDX5000_POST_WRITE_DELAY,
.timeout = 2000,
.retry = 3,
diff --git a/rigs/yaesu/ft600.c b/rigs/yaesu/ft600.c
index 9f5096a85..561b056b1 100644
--- a/rigs/yaesu/ft600.c
+++ b/rigs/yaesu/ft600.c
@@ -396,7 +396,8 @@ static int ft600_send_priv_cmd(RIG *rig, unsigned char cmd_index)
if (!rig) { return -RIG_EINVAL; }
- return write_block(&rig->state.rigport, (unsigned char *) &ncmd[cmd_index].nseq, YAESU_CMD_LENGTH);
+ return write_block(&rig->state.rigport, (unsigned char *) &ncmd[cmd_index].nseq,
+ YAESU_CMD_LENGTH);
}
static int ft600_read_status(RIG *rig)
@@ -419,7 +420,7 @@ static int ft600_read_status(RIG *rig)
ret = read_block(&rig->state.rigport,
- (unsigned char *) &priv->status, FT600_STATUS_UPDATE_DATA_LENGTH);
+ (unsigned char *) &priv->status, FT600_STATUS_UPDATE_DATA_LENGTH);
rig_debug(RIG_DEBUG_VERBOSE, "%s: read status=%i \n", __func__, ret);
diff --git a/rigs/yaesu/ft840.c b/rigs/yaesu/ft840.c
index 01c5efeba..cdc1f9245 100644
--- a/rigs/yaesu/ft840.c
+++ b/rigs/yaesu/ft840.c
@@ -1848,7 +1848,8 @@ static int ft840_send_dynamic_cmd(RIG *rig, unsigned char ci,
priv->p_cmd[P3] = p3;
priv->p_cmd[P4] = p4;
- err = write_block(&rig->state.rigport, (unsigned char *) &priv->p_cmd, YAESU_CMD_LENGTH);
+ err = write_block(&rig->state.rigport, (unsigned char *) &priv->p_cmd,
+ YAESU_CMD_LENGTH);
if (err != RIG_OK)
{
@@ -1908,7 +1909,8 @@ static int ft840_send_dial_freq(RIG *rig, unsigned char ci, freq_t freq)
rig_debug(RIG_DEBUG_TRACE, fmt, __func__, (int64_t)from_bcd(priv->p_cmd,
FT840_BCD_DIAL) * 10);
- err = write_block(&rig->state.rigport, (unsigned char *) &priv->p_cmd, YAESU_CMD_LENGTH);
+ err = write_block(&rig->state.rigport, (unsigned char *) &priv->p_cmd,
+ YAESU_CMD_LENGTH);
if (err != RIG_OK)
{
diff --git a/rigs/yaesu/ft890.c b/rigs/yaesu/ft890.c
index d3508ca5b..2779a5342 100644
--- a/rigs/yaesu/ft890.c
+++ b/rigs/yaesu/ft890.c
@@ -2000,7 +2000,8 @@ static int ft890_send_dynamic_cmd(RIG *rig, unsigned char ci,
priv->p_cmd[P3] = p3;
priv->p_cmd[P4] = p4;
- err = write_block(&rig->state.rigport, (unsigned char *) &priv->p_cmd, YAESU_CMD_LENGTH);
+ err = write_block(&rig->state.rigport, (unsigned char *) &priv->p_cmd,
+ YAESU_CMD_LENGTH);
if (err != RIG_OK)
{
@@ -2060,7 +2061,8 @@ static int ft890_send_dial_freq(RIG *rig, unsigned char ci, freq_t freq)
rig_debug(RIG_DEBUG_TRACE, fmt, __func__, (int64_t)from_bcd(priv->p_cmd,
FT890_BCD_DIAL) * 10);
- err = write_block(&rig->state.rigport, (unsigned char *) &priv->p_cmd, YAESU_CMD_LENGTH);
+ err = write_block(&rig->state.rigport, (unsigned char *) &priv->p_cmd,
+ YAESU_CMD_LENGTH);
if (err != RIG_OK)
{
@@ -2140,7 +2142,8 @@ static int ft890_send_rit_freq(RIG *rig, unsigned char ci, shortfreq_t rit)
priv->p_cmd[P1] = p1; /* ick */
priv->p_cmd[P2] = p2;
- err = write_block(&rig->state.rigport, (unsigned char *) &priv->p_cmd, YAESU_CMD_LENGTH);
+ err = write_block(&rig->state.rigport, (unsigned char *) &priv->p_cmd,
+ YAESU_CMD_LENGTH);
if (err != RIG_OK)
{
diff --git a/rigs/yaesu/ft891.c b/rigs/yaesu/ft891.c
index 818b90757..6f3e39f6d 100644
--- a/rigs/yaesu/ft891.c
+++ b/rigs/yaesu/ft891.c
@@ -386,7 +386,8 @@ static int ft891_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, vfo_t tx_vfo)
SNPRINTF(priv->cmd_str, sizeof(priv->cmd_str), "ST%c;", ci);
- if (RIG_OK != (err = write_block(&state->rigport, (unsigned char *) priv->cmd_str, strlen(priv->cmd_str))))
+ if (RIG_OK != (err = write_block(&state->rigport,
+ (unsigned char *) priv->cmd_str, strlen(priv->cmd_str))))
{
rig_debug(RIG_DEBUG_ERR, "%s: write_block err = %d\n", __func__, err);
return err;
@@ -557,7 +558,8 @@ static int ft891_set_split_mode(RIG *rig, vfo_t vfo, rmode_t tx_mode,
// Copy A to B
SNPRINTF(priv->cmd_str, sizeof(priv->cmd_str), "AB;");
- if (RIG_OK != (err = write_block(&state->rigport, (unsigned char *) priv->cmd_str, strlen(priv->cmd_str))))
+ if (RIG_OK != (err = write_block(&state->rigport,
+ (unsigned char *) priv->cmd_str, strlen(priv->cmd_str))))
{
rig_debug(RIG_DEBUG_VERBOSE, "%s:%d write_block err = %d\n", __func__, __LINE__,
err);
diff --git a/rigs/yaesu/ft920.c b/rigs/yaesu/ft920.c
index bc2f05068..628c7ab61 100644
--- a/rigs/yaesu/ft920.c
+++ b/rigs/yaesu/ft920.c
@@ -2740,7 +2740,8 @@ static int ft920_send_dynamic_cmd(RIG *rig, unsigned char ci,
priv->p_cmd[P3] = p3;
priv->p_cmd[P4] = p4;
- err = write_block(&rig->state.rigport, (unsigned char *) &priv->p_cmd, YAESU_CMD_LENGTH);
+ err = write_block(&rig->state.rigport, (unsigned char *) &priv->p_cmd,
+ YAESU_CMD_LENGTH);
if (err != RIG_OK)
{
@@ -2804,7 +2805,8 @@ static int ft920_send_dial_freq(RIG *rig, unsigned char ci, freq_t freq)
rig_debug(RIG_DEBUG_TRACE, fmt, __func__, (int64_t)from_bcd(priv->p_cmd,
FT920_BCD_DIAL) * 10);
- err = write_block(&rig->state.rigport, (unsigned char *) &priv->p_cmd, YAESU_CMD_LENGTH);
+ err = write_block(&rig->state.rigport, (unsigned char *) &priv->p_cmd,
+ YAESU_CMD_LENGTH);
if (err != RIG_OK)
{
@@ -2887,7 +2889,8 @@ static int ft920_send_rit_freq(RIG *rig, unsigned char ci, shortfreq_t rit)
priv->p_cmd[P1] = p1; /* ick */
priv->p_cmd[P2] = p2;
- err = write_block(&rig->state.rigport, (unsigned char *) &priv->p_cmd, YAESU_CMD_LENGTH);
+ err = write_block(&rig->state.rigport, (unsigned char *) &priv->p_cmd,
+ YAESU_CMD_LENGTH);
if (err != RIG_OK)
{
diff --git a/rigs/yaesu/ft980.c b/rigs/yaesu/ft980.c
index d3edd3cf5..76215d4ca 100644
--- a/rigs/yaesu/ft980.c
+++ b/rigs/yaesu/ft980.c
@@ -585,7 +585,8 @@ int ft980_transaction(RIG *rig, const unsigned char *cmd, unsigned char *data,
return retval;
}
- if (retval != YAESU_CMD_LENGTH || (memcmp(echo_back, cmd, YAESU_CMD_LENGTH) != 0))
+ if (retval != YAESU_CMD_LENGTH
+ || (memcmp(echo_back, cmd, YAESU_CMD_LENGTH) != 0))
{
return -RIG_EPROTO;
}
diff --git a/rigs/yaesu/ft990.c b/rigs/yaesu/ft990.c
index 526f51929..5761c0a28 100644
--- a/rigs/yaesu/ft990.c
+++ b/rigs/yaesu/ft990.c
@@ -565,15 +565,15 @@ int ft990_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
return err;
}
- if (vfo != vfo_save)
- {
- err = ft990_set_vfo(rig, vfo_save);
+ if (vfo != vfo_save)
+ {
+ err = ft990_set_vfo(rig, vfo_save);
- if (err != RIG_OK)
- {
- return err;
- }
+ if (err != RIG_OK)
+ {
+ return err;
}
+ }
return RIG_OK;
}
@@ -3396,7 +3396,8 @@ int ft990_send_dynamic_cmd(RIG *rig, unsigned char ci,
priv->p_cmd[1] = p3;
priv->p_cmd[0] = p4;
- err = write_block(&rig->state.rigport, (unsigned char *) &priv->p_cmd, YAESU_CMD_LENGTH);
+ err = write_block(&rig->state.rigport, (unsigned char *) &priv->p_cmd,
+ YAESU_CMD_LENGTH);
if (err != RIG_OK)
{
@@ -3454,7 +3455,8 @@ int ft990_send_dial_freq(RIG *rig, unsigned char ci, freq_t freq)
rig_debug(RIG_DEBUG_TRACE, fmt, __func__, (int64_t)from_bcd(priv->p_cmd,
FT990_BCD_DIAL) * 10);
- err = write_block(&rig->state.rigport, (unsigned char *) &priv->p_cmd, YAESU_CMD_LENGTH);
+ err = write_block(&rig->state.rigport, (unsigned char *) &priv->p_cmd,
+ YAESU_CMD_LENGTH);
if (err != RIG_OK)
{
@@ -3518,7 +3520,8 @@ int ft990_send_rit_freq(RIG *rig, unsigned char ci, shortfreq_t rit)
// Store bcd format into privat command storage area
to_bcd(priv->p_cmd, labs(rit) / 10, FT990_BCD_RIT);
- err = write_block(&rig->state.rigport, (unsigned char *) &priv->p_cmd, YAESU_CMD_LENGTH);
+ err = write_block(&rig->state.rigport, (unsigned char *) &priv->p_cmd,
+ YAESU_CMD_LENGTH);
if (err != RIG_OK)
{
diff --git a/rigs/yaesu/newcat.c b/rigs/yaesu/newcat.c
index f5cd52777..e8b282c91 100644
--- a/rigs/yaesu/newcat.c
+++ b/rigs/yaesu/newcat.c
@@ -437,7 +437,7 @@ static int newcat_band_index(freq_t freq)
else if (freq >= MHz(0.5) && freq < MHz(1.705)) { band = 12; } // MW Medium Wave
rig_debug(RIG_DEBUG_TRACE, "%s: freq=%g, band=%d\n", __func__, freq, band);
- return(band);
+ return (band);
}
/*
@@ -514,7 +514,7 @@ int newcat_open(RIG *rig)
{
struct newcat_priv_data *priv = rig->state.priv;
struct rig_state *rig_s = &rig->state;
- const char *handshake[3] = {"None","Xon/Xoff", "Hardware"};
+ const char *handshake[3] = {"None", "Xon/Xoff", "Hardware"};
ENTERFUNC;
@@ -590,6 +590,7 @@ int newcat_open(RIG *rig)
rig->state.disable_yaesu_bandselect = 1;
rig_debug(RIG_DEBUG_VERBOSE, "%s: disabling FTDX3000 band select\n", __func__);
}
+
RETURNFUNC(RIG_OK);
}
@@ -773,7 +774,8 @@ int newcat_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
// disabled to check 2019 firmware on FTDX5000 and FT450 behavior
//special_60m = newcat_is_rig(rig, RIG_MODEL_FTDX5000);
//special_60m |= newcat_is_rig(rig, RIG_MODEL_FT450);
- rig_debug(RIG_DEBUG_TRACE, "%s: special_60m=%d, 60m freq=%d, is_ftdx3000=%d,is_ftdx3000dm=%d\n",
+ rig_debug(RIG_DEBUG_TRACE,
+ "%s: special_60m=%d, 60m freq=%d, is_ftdx3000=%d,is_ftdx3000dm=%d\n",
__func__, special_60m, freq >= 5300000
&& freq <= 5410000, is_ftdx3000, is_ftdx3000dm);
@@ -2311,8 +2313,9 @@ int newcat_set_split_mode(RIG *rig, vfo_t vfo, rmode_t tx_mode,
{
RETURNFUNC(err);
}
-
- if (tmp_mode == tx_mode && (tmp_width == tx_width || tmp_width == RIG_PASSBAND_NOCHANGE))
+
+ if (tmp_mode == tx_mode && (tmp_width == tx_width
+ || tmp_width == RIG_PASSBAND_NOCHANGE))
{
RETURNFUNC(RIG_OK);
}
@@ -2342,7 +2345,7 @@ int newcat_get_split_mode(RIG *rig, vfo_t vfo, rmode_t *tx_mode,
{
RETURNFUNC(err);
}
-
+
RETURNFUNC(RIG_OK);
}
@@ -3262,7 +3265,8 @@ int newcat_set_powerstat(RIG *rig, powerstat_t status)
SNPRINTF(priv->cmd_str, sizeof(priv->cmd_str), "PS%c%c", ps, cat_term);
- retval = write_block(&state->rigport, (unsigned char *) priv->cmd_str, strlen(priv->cmd_str));
+ retval = write_block(&state->rigport, (unsigned char *) priv->cmd_str,
+ strlen(priv->cmd_str));
retry_save = rig->state.rigport.retry;
rig->state.rigport.retry = 0;
@@ -3282,7 +3286,8 @@ int newcat_set_powerstat(RIG *rig, powerstat_t status)
}
rig_debug(RIG_DEBUG_TRACE, "%s: Wait #%d for power up\n", __func__, i + 1);
- retval = write_block(&state->rigport, (unsigned char *) priv->cmd_str, strlen(priv->cmd_str));
+ retval = write_block(&state->rigport, (unsigned char *) priv->cmd_str,
+ strlen(priv->cmd_str));
if (retval != RIG_OK) { RETURNFUNC(retval); }
}
@@ -3519,32 +3524,50 @@ int newcat_get_ant(RIG *rig, vfo_t vfo, ant_t dummy, value_t *option,
RETURNFUNC(RIG_OK);
}
-static int band2rig (hamlib_band_t band)
+static int band2rig(hamlib_band_t band)
{
int retval = 0;
- switch(band)
+
+ switch (band)
{
- case RIG_BAND_160M: retval = 0;break;
- case RIG_BAND_80M: retval = 1;break;
- case RIG_BAND_60M: retval = 2;break;
- case RIG_BAND_40M: retval = 3;break;
- case RIG_BAND_30M: retval = 4;break;
- case RIG_BAND_20M: retval = 5;break;
- case RIG_BAND_17M: retval = 6;break;
- case RIG_BAND_15M: retval = 7;break;
- case RIG_BAND_12M: retval = 8;break;
- case RIG_BAND_10M: retval = 9;break;
- case RIG_BAND_6M: retval = 10;break;
- case RIG_BAND_GEN: retval = 11;break;
- case RIG_BAND_MW: retval = 12;break;
- case RIG_BAND_AIR: retval = 14;break;
- case RIG_BAND_144MHZ: retval = 15;break;
- case RIG_BAND_430MHZ: retval = 16;break;
- default:
- rig_debug(RIG_DEBUG_ERR, "%s: unknown band index=%d\n", __func__, band);
- retval = -RIG_EINVAL;
- break;
+ case RIG_BAND_160M: retval = 0; break;
+
+ case RIG_BAND_80M: retval = 1; break;
+
+ case RIG_BAND_60M: retval = 2; break;
+
+ case RIG_BAND_40M: retval = 3; break;
+
+ case RIG_BAND_30M: retval = 4; break;
+
+ case RIG_BAND_20M: retval = 5; break;
+
+ case RIG_BAND_17M: retval = 6; break;
+
+ case RIG_BAND_15M: retval = 7; break;
+
+ case RIG_BAND_12M: retval = 8; break;
+
+ case RIG_BAND_10M: retval = 9; break;
+
+ case RIG_BAND_6M: retval = 10; break;
+
+ case RIG_BAND_GEN: retval = 11; break;
+
+ case RIG_BAND_MW: retval = 12; break;
+
+ case RIG_BAND_AIR: retval = 14; break;
+
+ case RIG_BAND_144MHZ: retval = 15; break;
+
+ case RIG_BAND_430MHZ: retval = 16; break;
+
+ default:
+ rig_debug(RIG_DEBUG_ERR, "%s: unknown band index=%d\n", __func__, band);
+ retval = -RIG_EINVAL;
+ break;
}
+
return retval;
}
@@ -3602,7 +3625,8 @@ int newcat_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
fpf = newcat_scale_float(scale, val.f);
- if (is_ft950 || is_ft891 || is_ft991 || is_ftdx3000 || is_ftdx3000dm || is_ftdx101d
+ if (is_ft950 || is_ft891 || is_ft991 || is_ftdx3000 || is_ftdx3000dm
+ || is_ftdx101d
|| is_ftdx101mp || is_ftdx10)
{
// Minimum is 5 watts on these rigs
@@ -3677,7 +3701,8 @@ int newcat_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
RETURNFUNC(-RIG_ENAVAIL);
}
- if (is_ft991 || is_ftdx3000 || is_ftdx3000dm || is_ftdx5000 || is_ftdx101d || is_ftdx101mp)
+ if (is_ft991 || is_ftdx3000 || is_ftdx3000dm || is_ftdx5000 || is_ftdx101d
+ || is_ftdx101mp)
{
newcat_get_mode(rig, vfo, &mode, &width);
}
@@ -3719,7 +3744,8 @@ int newcat_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
}
// Some Yaesu rigs reject this command in AM/FM modes
- if (is_ft991 || is_ftdx3000 || is_ftdx3000dm || is_ftdx5000 || is_ftdx101d || is_ftdx101mp)
+ if (is_ft991 || is_ftdx3000 || is_ftdx3000dm || is_ftdx5000 || is_ftdx101d
+ || is_ftdx101mp)
{
if (mode & RIG_MODE_AM || mode & RIG_MODE_FM || mode & RIG_MODE_AMN
|| mode & RIG_MODE_FMN)
@@ -3787,14 +3813,16 @@ int newcat_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
RETURNFUNC(-RIG_ENAVAIL);
}
- if (is_ft991 || is_ftdx3000 || is_ftdx3000dm || is_ftdx5000 || is_ftdx101d || is_ftdx101mp)
+ if (is_ft991 || is_ftdx3000 || is_ftdx3000dm || is_ftdx5000 || is_ftdx101d
+ || is_ftdx101mp)
{
newcat_get_mode(rig, vfo, &mode, &width);
}
if (val.f > 1.0) { RETURNFUNC(-RIG_EINVAL); }
- if (is_ftdx1200 || is_ftdx3000 || is_ftdx3000dm || is_ft891 || is_ft991 || is_ftdx101d
+ if (is_ftdx1200 || is_ftdx3000 || is_ftdx3000dm || is_ft891 || is_ft991
+ || is_ftdx101d
|| is_ftdx101mp
|| is_ftdx10)
{
@@ -3808,7 +3836,8 @@ int newcat_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
SNPRINTF(priv->cmd_str, sizeof(priv->cmd_str), "MG%03d%c", fpf, cat_term);
// Some Yaesu rigs reject this command in RTTY modes
- if (is_ft991 || is_ftdx3000 || is_ftdx3000dm || is_ftdx5000 || is_ftdx101d || is_ftdx101mp)
+ if (is_ft991 || is_ftdx3000 || is_ftdx3000dm || is_ftdx5000 || is_ftdx101d
+ || is_ftdx101mp)
{
if (mode & RIG_MODE_RTTY || mode & RIG_MODE_RTTYR)
{
@@ -4355,7 +4384,8 @@ int newcat_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
if (val.f > 1.0) { RETURNFUNC(-RIG_EINVAL); }
- if (is_ftdx1200 || is_ftdx3000 || is_ftdx3000dm || is_ft891 || is_ft991 || is_ftdx101d
+ if (is_ftdx1200 || is_ftdx3000 || is_ftdx3000dm || is_ft891 || is_ft991
+ || is_ftdx101d
|| is_ftdx101mp
|| is_ftdx10)
{
@@ -4381,12 +4411,15 @@ int newcat_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
if (newcat_valid_command(rig, "BS"))
{
int band = band2rig((hamlib_band_t)val.i);
+
if (band < 0)
{
RETURNFUNC(-RIG_EINVAL);
}
+
SNPRINTF(priv->cmd_str, sizeof(priv->cmd_str), "BS%02d%c", band, cat_term);
}
+
break;
case RIG_LEVEL_NB:
@@ -4507,7 +4540,8 @@ int newcat_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
RETURNFUNC(-RIG_ENAVAIL);
}
- if (is_ft991 || is_ftdx3000 || is_ftdx3000dm || is_ftdx5000 || is_ftdx101d || is_ftdx101mp)
+ if (is_ft991 || is_ftdx3000 || is_ftdx3000dm || is_ftdx5000 || is_ftdx101d
+ || is_ftdx101mp)
{
newcat_get_mode(rig, vfo, &mode, &width);
}
@@ -4521,7 +4555,8 @@ int newcat_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
}
// Some Yaesu rigs reject this command in AM/FM modes
- if (is_ft991 || is_ftdx3000 || is_ftdx3000dm || is_ftdx5000 || is_ftdx101d || is_ftdx101mp)
+ if (is_ft991 || is_ftdx3000 || is_ftdx3000dm || is_ftdx5000 || is_ftdx101d
+ || is_ftdx101mp)
{
if (mode & RIG_MODE_AM || mode & RIG_MODE_FM || mode & RIG_MODE_AMN
|| mode & RIG_MODE_FMN)
@@ -4561,7 +4596,8 @@ int newcat_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
RETURNFUNC(-RIG_ENAVAIL);
}
- if (is_ft991 || is_ftdx3000 || is_ftdx3000dm || is_ftdx5000 || is_ftdx101d || is_ftdx101mp)
+ if (is_ft991 || is_ftdx3000 || is_ftdx3000dm || is_ftdx5000 || is_ftdx101d
+ || is_ftdx101mp)
{
newcat_get_mode(rig, vfo, &mode, &width);
}
@@ -4569,7 +4605,8 @@ int newcat_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
SNPRINTF(priv->cmd_str, sizeof(priv->cmd_str), "MG%c", cat_term);
// Some Yaesu rigs reject this command in RTTY modes
- if (is_ft991 || is_ftdx3000 || is_ftdx3000dm || is_ftdx5000 || is_ftdx101d || is_ftdx101mp)
+ if (is_ft991 || is_ftdx3000 || is_ftdx3000dm || is_ftdx5000 || is_ftdx101d
+ || is_ftdx101mp)
{
if (mode & RIG_MODE_RTTY || mode & RIG_MODE_RTTYR)
{
@@ -4940,7 +4977,8 @@ int newcat_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
switch (level)
{
case RIG_LEVEL_RFPOWER:
- if (is_ft950 || is_ftdx1200 || is_ftdx3000 || is_ftdx3000dm || is_ft891 || is_ft991
+ if (is_ft950 || is_ftdx1200 || is_ftdx3000 || is_ftdx3000dm || is_ft891
+ || is_ft991
|| is_ftdx101d || is_ftdx101mp || is_ftdx10)
{
scale = 100.;
@@ -5111,7 +5149,8 @@ int newcat_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
break;
case RIG_LEVEL_MICGAIN:
- if (is_ftdx1200 || is_ftdx3000 || is_ftdx3000dm || is_ft891 || is_ft991 || is_ftdx101d
+ if (is_ftdx1200 || is_ftdx3000 || is_ftdx3000dm || is_ft891 || is_ft991
+ || is_ftdx101d
|| is_ftdx101mp
|| is_ftdx10)
{
@@ -5208,7 +5247,8 @@ int newcat_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
break;
}
- if (is_ftdx1200 || is_ftdx3000 || is_ftdx3000dm || is_ftdx5000 || is_ft891 || is_ft991
+ if (is_ftdx1200 || is_ftdx3000 || is_ftdx3000dm || is_ftdx5000 || is_ft891
+ || is_ft991
|| is_ftdx101d || is_ftdx101mp || is_ftdx10)
{
val->i = round(rig_raw2val(atoi(retlvl), &yaesu_default_str_cal));
@@ -5434,7 +5474,8 @@ int newcat_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
break;
case RIG_LEVEL_MONITOR_GAIN:
- if (is_ftdx1200 || is_ftdx3000 || is_ftdx3000dm || is_ft891 || is_ft991 || is_ftdx101d
+ if (is_ftdx1200 || is_ftdx3000 || is_ftdx3000dm || is_ft891 || is_ft991
+ || is_ftdx101d
|| is_ftdx101mp)
{
scale = 100.;
@@ -5492,7 +5533,8 @@ int newcat_set_func(RIG *rig, vfo_t vfo, setting_t func, int status)
RETURNFUNC(-RIG_ENAVAIL);
}
- if (is_ft991 || is_ftdx3000 || is_ftdx3000dm || is_ftdx5000 || is_ftdx101d || is_ftdx101mp)
+ if (is_ft991 || is_ftdx3000 || is_ftdx3000dm || is_ftdx5000 || is_ftdx101d
+ || is_ftdx101mp)
{
err = newcat_get_mode(rig, vfo, &mode, &width);
}
@@ -5506,7 +5548,8 @@ int newcat_set_func(RIG *rig, vfo_t vfo, setting_t func, int status)
}
// Some Yaesu rigs reject this command in FM mode
- if (is_ft991 || is_ftdx3000 || is_ftdx3000dm || is_ftdx5000 || is_ftdx101d || is_ftdx101mp)
+ if (is_ft991 || is_ftdx3000 || is_ftdx3000dm || is_ftdx5000 || is_ftdx101d
+ || is_ftdx101mp)
{
if (mode & RIG_MODE_FM || mode & RIG_MODE_FMN)
{
@@ -5527,7 +5570,8 @@ int newcat_set_func(RIG *rig, vfo_t vfo, setting_t func, int status)
RETURNFUNC(-RIG_ENAVAIL);
}
- if (is_ft991 || is_ftdx3000 || is_ftdx3000dm || is_ftdx5000 || is_ftdx101d || is_ftdx101mp)
+ if (is_ft991 || is_ftdx3000 || is_ftdx3000dm || is_ftdx5000 || is_ftdx101d
+ || is_ftdx101mp)
{
newcat_get_mode(rig, vfo, &mode, &width);
}
@@ -5541,7 +5585,8 @@ int newcat_set_func(RIG *rig, vfo_t vfo, setting_t func, int status)
}
// Some Yaesu rigs reject this command in FM mode
- if (is_ft991 || is_ftdx3000 || is_ftdx3000dm || is_ftdx5000 || is_ftdx101d || is_ftdx101mp)
+ if (is_ft991 || is_ftdx3000 || is_ftdx3000dm || is_ftdx5000 || is_ftdx101d
+ || is_ftdx101mp)
{
if (mode & RIG_MODE_FM || mode & RIG_MODE_FMN)
{
@@ -5600,7 +5645,8 @@ int newcat_set_func(RIG *rig, vfo_t vfo, setting_t func, int status)
RETURNFUNC(-RIG_ENAVAIL);
}
- if (is_ftdx1200 || is_ftdx3000 || is_ftdx3000dm || is_ftdx5000 || is_ftdx101d || is_ftdx101mp)
+ if (is_ftdx1200 || is_ftdx3000 || is_ftdx3000dm || is_ftdx5000 || is_ftdx101d
+ || is_ftdx101mp)
{
// These rigs can lock Main/Sub VFO dials individually
SNPRINTF(priv->cmd_str, sizeof(priv->cmd_str), "LK%d%c", status ? 7 : 4,
@@ -5650,7 +5696,8 @@ int newcat_set_func(RIG *rig, vfo_t vfo, setting_t func, int status)
RETURNFUNC(-RIG_ENAVAIL);
}
- if (is_ft991 || is_ftdx3000 || is_ftdx3000dm || is_ftdx5000 || is_ftdx101d || is_ftdx101mp)
+ if (is_ft991 || is_ftdx3000 || is_ftdx3000dm || is_ftdx5000 || is_ftdx101d
+ || is_ftdx101mp)
{
newcat_get_mode(rig, vfo, &mode, &width);
}
@@ -5664,7 +5711,8 @@ int newcat_set_func(RIG *rig, vfo_t vfo, setting_t func, int status)
}
// Some Yaesu rigs reject this command in FM mode
- if (is_ft991 || is_ftdx3000 || is_ftdx3000dm || is_ftdx5000 || is_ftdx101d || is_ftdx101mp)
+ if (is_ft991 || is_ftdx3000 || is_ftdx3000dm || is_ftdx5000 || is_ftdx101d
+ || is_ftdx101mp)
{
if (mode & RIG_MODE_FM || mode & RIG_MODE_FMN)
{
@@ -5685,12 +5733,14 @@ int newcat_set_func(RIG *rig, vfo_t vfo, setting_t func, int status)
RETURNFUNC(-RIG_ENAVAIL);
}
- if (is_ft991 || is_ftdx3000 || is_ftdx3000dm || is_ftdx5000 || is_ftdx101d || is_ftdx101mp)
+ if (is_ft991 || is_ftdx3000 || is_ftdx3000dm || is_ftdx5000 || is_ftdx101d
+ || is_ftdx101mp)
{
newcat_get_mode(rig, vfo, &mode, &width);
}
- if (is_ft891 || is_ft991 || is_ftdx1200 || is_ftdx3000 || is_ftdx3000dm || is_ftdx101d
+ if (is_ft891 || is_ft991 || is_ftdx1200 || is_ftdx3000 || is_ftdx3000dm
+ || is_ftdx101d
|| is_ftdx101mp)
{
// There seems to be an error in the manuals for some of these rigs stating that values should be 1 = OFF and 2 = ON, but they are 0 = OFF and 1 = ON instead
@@ -5704,7 +5754,8 @@ int newcat_set_func(RIG *rig, vfo_t vfo, setting_t func, int status)
}
// Some Yaesu rigs reject this command in AM/FM/RTTY modes
- if (is_ft991 || is_ftdx3000 || is_ftdx3000dm || is_ftdx5000 || is_ftdx101d || is_ftdx101mp)
+ if (is_ft991 || is_ftdx3000 || is_ftdx3000dm || is_ftdx5000 || is_ftdx101d
+ || is_ftdx101mp)
{
if (mode & RIG_MODE_AM || mode & RIG_MODE_FM || mode & RIG_MODE_AMN
|| mode & RIG_MODE_FMN ||
@@ -5833,7 +5884,8 @@ int newcat_get_func(RIG *rig, vfo_t vfo, setting_t func, int *status)
RETURNFUNC(-RIG_ENAVAIL);
}
- if (is_ft991 || is_ftdx3000 || is_ftdx3000dm || is_ftdx5000 || is_ftdx101d || is_ftdx101mp)
+ if (is_ft991 || is_ftdx3000 || is_ftdx3000dm || is_ftdx5000 || is_ftdx101d
+ || is_ftdx101mp)
{
err = newcat_get_mode(rig, vfo, &mode, &width);
}
@@ -5846,7 +5898,8 @@ int newcat_get_func(RIG *rig, vfo_t vfo, setting_t func, int *status)
}
// Some Yaesu rigs reject this command in FM mode
- if (is_ft991 || is_ftdx3000 || is_ftdx3000dm || is_ftdx5000 || is_ftdx101d || is_ftdx101mp)
+ if (is_ft991 || is_ftdx3000 || is_ftdx3000dm || is_ftdx5000 || is_ftdx101d
+ || is_ftdx101mp)
{
if (mode & RIG_MODE_FM || mode & RIG_MODE_FMN)
{
@@ -5965,7 +6018,8 @@ int newcat_get_func(RIG *rig, vfo_t vfo, setting_t func, int *status)
RETURNFUNC(-RIG_ENAVAIL);
}
- if (is_ftdx1200 || is_ftdx3000 || is_ftdx3000dm || is_ft891 || is_ft991 || is_ftdx101d
+ if (is_ftdx1200 || is_ftdx3000 || is_ftdx3000dm || is_ft891 || is_ft991
+ || is_ftdx101d
|| is_ftdx101mp)
{
SNPRINTF(priv->cmd_str, sizeof(priv->cmd_str), "PR0%c", cat_term);
@@ -6085,7 +6139,8 @@ int newcat_get_func(RIG *rig, vfo_t vfo, setting_t func, int *status)
break;
case RIG_FUNC_LOCK:
- if (is_ftdx1200 || is_ftdx3000 || is_ftdx3000dm || is_ftdx5000 || is_ftdx101d || is_ftdx101mp)
+ if (is_ftdx1200 || is_ftdx3000 || is_ftdx3000dm || is_ftdx5000 || is_ftdx101d
+ || is_ftdx101mp)
{
// These rigs can lock Main/Sub VFO dials individually
*status = (retfunc[0] == '0' || retfunc[0] == '4') ? 0 : 1;
@@ -7405,16 +7460,21 @@ int newcat_set_vfo_from_alias(RIG *rig, vfo_t *vfo)
ENTERFUNC;
rig_debug(RIG_DEBUG_TRACE, "%s: alias vfo = %s\n", __func__, rig_strvfo(*vfo));
- if (*vfo == RIG_VFO_NONE)
+ if (*vfo == RIG_VFO_NONE)
{
int rc = rig_get_vfo(rig, vfo);
+
if (rc != RIG_OK)
{
- rig_debug(RIG_DEBUG_ERR, "%s: rig_get_vfo failed: %s\n", __func__, rig_strvfo(*vfo));
+ rig_debug(RIG_DEBUG_ERR, "%s: rig_get_vfo failed: %s\n", __func__,
+ rig_strvfo(*vfo));
RETURNFUNC(rc);
}
- rig_debug(RIG_DEBUG_TRACE, "%s: vfo==None so get vfo=%s\n", __func__, rig_strvfo(*vfo));
+
+ rig_debug(RIG_DEBUG_TRACE, "%s: vfo==None so get vfo=%s\n", __func__,
+ rig_strvfo(*vfo));
}
+
switch (*vfo)
{
case RIG_VFO_A:
@@ -9840,8 +9900,9 @@ int newcat_get_rigid(RIG *rig)
s += 2; /* ID0310, jump past ID */
priv->rig_id = atoi(s);
}
+
rig_debug(RIG_DEBUG_TRACE, "rig_id = %d, idstr = %s\n", priv->rig_id,
- s == NULL ? "NULL" : s);
+ s == NULL ? "NULL" : s);
}
else
{
@@ -10065,7 +10126,8 @@ int newcat_get_cmd(RIG *rig)
/* send the command */
rig_debug(RIG_DEBUG_TRACE, "cmd_str = %s\n", priv->cmd_str);
- if (RIG_OK != (rc = write_block(&state->rigport, (unsigned char *) priv->cmd_str,
+ if (RIG_OK != (rc = write_block(&state->rigport,
+ (unsigned char *) priv->cmd_str,
strlen(priv->cmd_str))))
{
RETURNFUNC(rc);
@@ -10073,7 +10135,8 @@ int newcat_get_cmd(RIG *rig)
}
/* read the reply */
- if ((rc = read_string(&state->rigport, (unsigned char *) priv->ret_data, sizeof(priv->ret_data),
+ if ((rc = read_string(&state->rigport, (unsigned char *) priv->ret_data,
+ sizeof(priv->ret_data),
&cat_term, sizeof(cat_term), 0, 1)) <= 0)
{
continue; /* usually a timeout - retry */
@@ -10215,18 +10278,20 @@ int newcat_set_cmd_validate(RIG *rig)
// a verifcation of frequency and retries if it doesn't match
if ((strncmp(priv->cmd_str, "FA", 2) == 0) && (strlen(priv->cmd_str) > 3))
{
- strcpy(valcmd, "FA;");
+ strcpy(valcmd, "FA;");
+
if (priv->rig_id == NC_RIGID_FTDX3000)
{
- strcpy(valcmd, "");
+ strcpy(valcmd, "");
}
}
else if ((strncmp(priv->cmd_str, "FB", 2) == 0) && (strlen(priv->cmd_str) > 3))
{
- strcpy(valcmd, "FB;");
+ strcpy(valcmd, "FB;");
+
if (priv->rig_id == NC_RIGID_FTDX3000)
{
- strcpy(valcmd, "");
+ strcpy(valcmd, "");
}
}
else if ((strncmp(priv->cmd_str, "MD", 2) == 0) && (strlen(priv->cmd_str) > 3))
@@ -10250,10 +10315,11 @@ int newcat_set_cmd_validate(RIG *rig)
else if ((strncmp(priv->cmd_str, "VS", 2) == 0) && (strlen(priv->cmd_str) > 3))
{
strcpy(valcmd, "VS;");
+
// Some models treat the 2nd VS as a mute request
if (is_ftdx3000 || is_ftdx9000)
{
- strcpy(valcmd, "");
+ strcpy(valcmd, "");
}
}
else if (strncmp(priv->cmd_str, "SV", 2) == 0)
@@ -10294,7 +10360,8 @@ int newcat_set_cmd_validate(RIG *rig)
if (strlen(valcmd) == 0) { RETURNFUNC(RIG_OK); }
- bytes = read_string(&state->rigport, (unsigned char *) priv->ret_data, sizeof(priv->ret_data),
+ bytes = read_string(&state->rigport, (unsigned char *) priv->ret_data,
+ sizeof(priv->ret_data),
&cat_term, sizeof(cat_term), 0, 1);
// FA and FB success is now verified in rig.c with a followup query
@@ -10384,7 +10451,8 @@ int newcat_set_cmd(RIG *rig)
rig_debug(RIG_DEBUG_TRACE,
"%s: newcat_set_cmd_validate not implemented...continuing\n", __func__);
- if (RIG_OK != (rc = write_block(&state->rigport, (unsigned char *) priv->cmd_str,
+ if (RIG_OK != (rc = write_block(&state->rigport,
+ (unsigned char *) priv->cmd_str,
strlen(priv->cmd_str))))
{
RETURNFUNC(rc);
@@ -10422,7 +10490,8 @@ int newcat_set_cmd(RIG *rig)
}
/* read the reply */
- if ((rc = read_string(&state->rigport, (unsigned char *) priv->ret_data, sizeof(priv->ret_data),
+ if ((rc = read_string(&state->rigport, (unsigned char *) priv->ret_data,
+ sizeof(priv->ret_data),
&cat_term, sizeof(cat_term), 0, 1)) <= 0)
{
continue; /* usually a timeout - retry */
@@ -10492,7 +10561,8 @@ int newcat_set_cmd(RIG *rig)
priv->cmd_str);
/* read/flush the verify command reply which should still be there */
- if ((rc = read_string(&state->rigport, (unsigned char *) priv->ret_data, sizeof(priv->ret_data),
+ if ((rc = read_string(&state->rigport, (unsigned char *) priv->ret_data,
+ sizeof(priv->ret_data),
&cat_term, sizeof(cat_term), 0, 1)) > 0)
{
rig_debug(RIG_DEBUG_TRACE, "%s: read count = %d, ret_data = %s\n",
@@ -10557,11 +10627,11 @@ rmode_t newcat_rmode(char mode)
{
rig_debug(RIG_DEBUG_TRACE, "%s: %s for %c\n", __func__,
rig_strrmode(newcat_mode_conv[i].mode), mode);
- return(newcat_mode_conv[i].mode);
+ return (newcat_mode_conv[i].mode);
}
}
- return(RIG_MODE_NONE);
+ return (RIG_MODE_NONE);
}
char newcat_modechar(rmode_t rmode)
@@ -10574,11 +10644,11 @@ char newcat_modechar(rmode_t rmode)
{
rig_debug(RIG_DEBUG_TRACE, "%s: return %c for %s\n", __func__,
newcat_mode_conv[i].modechar, rig_strrmode(rmode));
- return(newcat_mode_conv[i].modechar);
+ return (newcat_mode_conv[i].modechar);
}
}
- return('0');
+ return ('0');
}
rmode_t newcat_rmode_width(RIG *rig, vfo_t vfo, char mode, pbwidth_t *width)
diff --git a/rotators/celestron/celestron.c b/rotators/celestron/celestron.c
index 03c068c8b..88669c7a1 100644
--- a/rotators/celestron/celestron.c
+++ b/rotators/celestron/celestron.c
@@ -91,7 +91,7 @@ transaction_write:
/* the answer */
memset(data, 0, data_len);
retval = read_string(&rs->rotport, (unsigned char *) data, data_len,
- ACK, strlen(ACK), 0, 1);
+ ACK, strlen(ACK), 0, 1);
if (retval < 0)
{
@@ -135,8 +135,8 @@ celestron_set_position(ROT *rot, azimuth_t az, elevation_t el)
*/
SNPRINTF(cmdstr, sizeof(cmdstr), "B%04X,%04X",
- (unsigned)((az / 360.) * 65535),
- (unsigned)((el / 360.) * 65535));
+ (unsigned)((az / 360.) * 65535),
+ (unsigned)((el / 360.) * 65535));
retval = celestron_transaction(rot, cmdstr, NULL, 0);
diff --git a/rotators/cnctrk/cnctrk.c b/rotators/cnctrk/cnctrk.c
index 49920f873..bdcacdd5e 100644
--- a/rotators/cnctrk/cnctrk.c
+++ b/rotators/cnctrk/cnctrk.c
@@ -48,7 +48,8 @@ cnctrk_set_position(ROT *rot, azimuth_t az, elevation_t el)
return retval;
}
- SNPRINTF(axcmd, sizeof(axcmd), "/usr/bin/axis-remote --mdi 'G00 X %6.2f Y %6.2f' \n", az, el);
+ SNPRINTF(axcmd, sizeof(axcmd),
+ "/usr/bin/axis-remote --mdi 'G00 X %6.2f Y %6.2f' \n", az, el);
return system(axcmd);
}
diff --git a/rotators/easycomm/easycomm.c b/rotators/easycomm/easycomm.c
index c3e6bd421..cef88155f 100644
--- a/rotators/easycomm/easycomm.c
+++ b/rotators/easycomm/easycomm.c
@@ -78,7 +78,7 @@ easycomm_transaction(ROT *rot, const char *cmdstr, char *data, size_t data_len)
}
retval = read_string(&rs->rotport, (unsigned char *) data, data_len,
- "\n", 1, 0, 1);
+ "\n", 1, 0, 1);
if (retval < 0)
{
diff --git a/rotators/ether6/ether6.c b/rotators/ether6/ether6.c
index 70dfd3d01..86c0e8035 100644
--- a/rotators/ether6/ether6.c
+++ b/rotators/ether6/ether6.c
@@ -59,7 +59,7 @@ static int ether_transaction(ROT *rot, char *cmd, int len, char *buf)
}
ret = read_string(&rot->state.rotport, (unsigned char *) buf, BUF_MAX,
- "\n", sizeof("\n"), 0, 1);
+ "\n", sizeof("\n"), 0, 1);
rig_debug(RIG_DEBUG_VERBOSE, "function %s(2): ret=%d || receive=%s\n", __func__,
ret, buf);
diff --git a/rotators/gs232a/gs232.c b/rotators/gs232a/gs232.c
index 9198240ef..0278df218 100644
--- a/rotators/gs232a/gs232.c
+++ b/rotators/gs232a/gs232.c
@@ -92,7 +92,7 @@ transaction_write:
memset(data, 0, data_len);
retval = read_string(&rs->rotport, (unsigned char *) data, data_len,
- REPLY_EOM, strlen(REPLY_EOM), 0, 1);
+ REPLY_EOM, strlen(REPLY_EOM), 0, 1);
if (retval < 0)
{
@@ -146,7 +146,8 @@ static int
gs232_wo_transaction(ROT *rot, const char *cmdstr,
char *data, size_t data_len)
{
- return write_block(&rot->state.rotport, (unsigned char *) cmdstr, strlen(cmdstr));
+ return write_block(&rot->state.rotport, (unsigned char *) cmdstr,
+ strlen(cmdstr));
}
diff --git a/rotators/gs232a/gs232a.c b/rotators/gs232a/gs232a.c
index 67fa1e8a4..4aa2c7fdf 100644
--- a/rotators/gs232a/gs232a.c
+++ b/rotators/gs232a/gs232a.c
@@ -102,7 +102,7 @@ transaction_write:
{
memset(data, 0, data_len);
retval = read_string(&rs->rotport, (unsigned char *) data, data_len,
- REPLY_EOM, strlen(REPLY_EOM), 0, 1);
+ REPLY_EOM, strlen(REPLY_EOM), 0, 1);
if (strncmp(data, "\r\n", 2) == 0
|| strchr(data, '>'))
diff --git a/rotators/gs232a/gs232b.c b/rotators/gs232a/gs232b.c
index 682ffb04d..f693d9120 100644
--- a/rotators/gs232a/gs232b.c
+++ b/rotators/gs232a/gs232b.c
@@ -102,7 +102,7 @@ transaction_write:
memset(data, 0, data_len);
retval = read_string(&rs->rotport, (unsigned char *) data, data_len,
- REPLY_EOM, strlen(REPLY_EOM), 0, 1);
+ REPLY_EOM, strlen(REPLY_EOM), 0, 1);
if (strncmp(data, "\r\n", 2) == 0 || strchr(data, '>'))
{
diff --git a/rotators/ioptron/rot_ioptron.c b/rotators/ioptron/rot_ioptron.c
index cde53ebab..a4bf723f2 100644
--- a/rotators/ioptron/rot_ioptron.c
+++ b/rotators/ioptron/rot_ioptron.c
@@ -106,7 +106,8 @@ transaction_write:
/** the answer */
memset(data, 0, data_len);
- retval = read_string(&rs->rotport, (unsigned char *) data, data_len, ACK, strlen(ACK), 0, 1);
+ retval = read_string(&rs->rotport, (unsigned char *) data, data_len, ACK,
+ strlen(ACK), 0, 1);
if (retval < 0)
{
diff --git a/rotators/m2/rc2800.c b/rotators/m2/rc2800.c
index 968e76344..8008dc00b 100644
--- a/rotators/m2/rc2800.c
+++ b/rotators/m2/rc2800.c
@@ -202,13 +202,15 @@ transaction_write:
/* then comes the answer */
memset(data, 0, data_len);
- retval = read_string(&rs->rotport, (unsigned char *) data, data_len, CR, strlen(CR), 0, 1);
+ retval = read_string(&rs->rotport, (unsigned char *) data, data_len, CR,
+ strlen(CR), 0, 1);
// some models seem to echo -- so we'll check and read again if echoed
if (cmdstr && strcmp(data, cmdstr) == 0)
{
memset(data, 0, data_len);
- retval = read_string(&rs->rotport, (unsigned char *) data, data_len, CR, strlen(CR), 0, 1);
+ retval = read_string(&rs->rotport, (unsigned char *) data, data_len, CR,
+ strlen(CR), 0, 1);
}
if (retval < 0)
diff --git a/rotators/meade/meade.c b/rotators/meade/meade.c
index 704d60e65..5e3873115 100644
--- a/rotators/meade/meade.c
+++ b/rotators/meade/meade.c
@@ -113,7 +113,8 @@ transaction:
if (cmdstr)
{
- return_value = write_block(&rs->rotport, (unsigned char *) cmdstr, strlen(cmdstr));
+ return_value = write_block(&rs->rotport, (unsigned char *) cmdstr,
+ strlen(cmdstr));
if (return_value != RIG_OK)
{
@@ -126,7 +127,8 @@ transaction:
return value is expected, Strings end with '#' */
if (data != NULL)
{
- return_value = read_string(&rs->rotport, (unsigned char *) data, expected_return_length + 1,
+ return_value = read_string(&rs->rotport, (unsigned char *) data,
+ expected_return_length + 1,
"\r\n", strlen("\r\n"), 0, 1);
if (return_value > 0)
@@ -444,8 +446,9 @@ static const char *meade_get_info(ROT *rot)
struct meade_priv_data *priv = (struct meade_priv_data *)rot->state.priv;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
- SNPRINTF(buf, sizeof(buf), "Meade telescope rotator with LX200 protocol.\nModel: %s",
- priv->product_name);
+ SNPRINTF(buf, sizeof(buf),
+ "Meade telescope rotator with LX200 protocol.\nModel: %s",
+ priv->product_name);
return buf;
}
diff --git a/rotators/prosistel/prosistel.c b/rotators/prosistel/prosistel.c
index 3955d49d3..511cde4ae 100644
--- a/rotators/prosistel/prosistel.c
+++ b/rotators/prosistel/prosistel.c
@@ -96,7 +96,8 @@ transaction_write:
}
// Remember to check for STXA,G,R or STXA,?,XXX,R 10 bytes
- retval = read_string(&rs->rotport, (unsigned char *) data, 20, CR, strlen(CR), 0, 1);
+ retval = read_string(&rs->rotport, (unsigned char *) data, 20, CR, strlen(CR),
+ 0, 1);
if (retval < 0)
{
diff --git a/rotators/radant/radant.c b/rotators/radant/radant.c
index ba3ae53d6..c8cfc2315 100644
--- a/rotators/radant/radant.c
+++ b/rotators/radant/radant.c
@@ -77,7 +77,8 @@ radant_transaction(ROT *rot, const char *cmdstr, char *data, size_t data_len)
return RIG_OK; /* don't want a reply */
}
- retval = read_string(&rs->rotport, (unsigned char *) data, data_len, "\n", 1, 0, 1);
+ retval = read_string(&rs->rotport, (unsigned char *) data, data_len, "\n", 1, 0,
+ 1);
if (retval < 0)
{
diff --git a/rotators/rotorez/rotorez.c b/rotators/rotorez/rotorez.c
index efade0edb..a69d9ccf0 100644
--- a/rotators/rotorez/rotorez.c
+++ b/rotators/rotorez/rotorez.c
@@ -434,7 +434,8 @@ static int rotorez_rot_set_position(ROT *rot, azimuth_t azimuth,
azimuth = 0;
}
- SNPRINTF(cmdstr, sizeof(cmdstr), "AP1%03.0f;", azimuth); /* Target bearing */
+ SNPRINTF(cmdstr, sizeof(cmdstr), "AP1%03.0f;",
+ azimuth); /* Target bearing */
err = rotorez_send_priv_cmd(rot, cmdstr);
if (err != RIG_OK)
@@ -479,7 +480,8 @@ static int rt21_rot_set_position(ROT *rot, azimuth_t azimuth,
return -RIG_EINVAL;
}
- SNPRINTF(cmdstr, sizeof(cmdstr), "AP1%05.1f\r;", azimuth); /* Total field width of 5 chars */
+ SNPRINTF(cmdstr, sizeof(cmdstr), "AP1%05.1f\r;",
+ azimuth); /* Total field width of 5 chars */
err = rotorez_send_priv_cmd(rot, cmdstr);
if (err != RIG_OK)
@@ -490,7 +492,7 @@ static int rt21_rot_set_position(ROT *rot, azimuth_t azimuth,
if (rot->state.rotport2.pathname[0] != 0)
{
SNPRINTF(cmdstr, sizeof(cmdstr), "AP1%05.1f\r;",
- elevation); /* Total field width of 5 chars */
+ elevation); /* Total field width of 5 chars */
err = rotorez_send_priv_cmd2(rot, cmdstr);
@@ -499,6 +501,7 @@ static int rt21_rot_set_position(ROT *rot, azimuth_t azimuth,
return err;
}
}
+
return RIG_OK;
}
@@ -760,7 +763,8 @@ static int rt21_rot_get_position(ROT *rot, azimuth_t *azimuth,
rs = &rot->state;
- err = read_string(&rs->rotport, (unsigned char *) az, RT21_AZ_LEN + 1, ";", strlen(";"), 0, 1);
+ err = read_string(&rs->rotport, (unsigned char *) az, RT21_AZ_LEN + 1, ";",
+ strlen(";"), 0, 1);
if (err < 0) /* read_string returns negative on error. */
{
diff --git a/rotators/sartek/sartek.c b/rotators/sartek/sartek.c
index e89f450b3..349740a4b 100644
--- a/rotators/sartek/sartek.c
+++ b/rotators/sartek/sartek.c
@@ -127,7 +127,8 @@ static int sartek_rot_set_position(ROT *rot, azimuth_t azimuth,
SNPRINTF(cmdstr, sizeof(cmdstr), "P%c", (int)((azimuth * 255) / 360));
- err = write_block(&rot->state.rotport, (unsigned char *) cmdstr, strlen(cmdstr));
+ err = write_block(&rot->state.rotport, (unsigned char *) cmdstr,
+ strlen(cmdstr));
if (err != RIG_OK)
{
diff --git a/rotators/satel/satel.c b/rotators/satel/satel.c
index 3336c89a9..0faeeec06 100644
--- a/rotators/satel/satel.c
+++ b/rotators/satel/satel.c
@@ -161,7 +161,8 @@ static int satel_read_status(ROT *rot, satel_stat_t *stat)
// read motion state
- ret = read_string(&rs->rotport, (unsigned char *) resbuf, BUF_SIZE, "\n", 1, 0, 1);
+ ret = read_string(&rs->rotport, (unsigned char *) resbuf, BUF_SIZE, "\n", 1, 0,
+ 1);
if (ret < 0)
{
@@ -171,7 +172,8 @@ static int satel_read_status(ROT *rot, satel_stat_t *stat)
stat->motion_enabled = strcmp(resbuf, "Motion ENABLED") == 0 ? true : false;
// XXX skip mode
- ret = read_string(&rs->rotport, (unsigned char *) resbuf, BUF_SIZE, "\n", 1, 0, 1);
+ ret = read_string(&rs->rotport, (unsigned char *) resbuf, BUF_SIZE, "\n", 1, 0,
+ 1);
if (ret < 0)
{
@@ -179,7 +181,8 @@ static int satel_read_status(ROT *rot, satel_stat_t *stat)
}
// XXX skip time
- ret = read_string(&rs->rotport, (unsigned char *) resbuf, BUF_SIZE, "\n", 1, 0, 1);
+ ret = read_string(&rs->rotport, (unsigned char *) resbuf, BUF_SIZE, "\n", 1, 0,
+ 1);
if (ret < 0)
{
@@ -187,7 +190,8 @@ static int satel_read_status(ROT *rot, satel_stat_t *stat)
}
// read azimuth line
- ret = read_string(&rs->rotport, (unsigned char *) resbuf, BUF_SIZE, "\n", 1, 0, 1);
+ ret = read_string(&rs->rotport, (unsigned char *) resbuf, BUF_SIZE, "\n", 1, 0,
+ 1);
if (ret < 0)
{
@@ -199,7 +203,8 @@ static int satel_read_status(ROT *rot, satel_stat_t *stat)
stat->az = (int)strtof(p, NULL);
// read elevation line
- ret = read_string(&rs->rotport, (unsigned char *) resbuf, BUF_SIZE, "\n", 1, 0, 1);
+ ret = read_string(&rs->rotport, (unsigned char *) resbuf, BUF_SIZE, "\n", 1, 0,
+ 1);
if (ret < 0)
{
@@ -211,7 +216,8 @@ static int satel_read_status(ROT *rot, satel_stat_t *stat)
stat->el = (int)strtof(p, NULL);
// skip blank line
- ret = read_string(&rs->rotport, (unsigned char *) resbuf, BUF_SIZE, "\n", 1, 0, 1);
+ ret = read_string(&rs->rotport, (unsigned char *) resbuf, BUF_SIZE, "\n", 1, 0,
+ 1);
if (ret < 0)
{
@@ -219,7 +225,8 @@ static int satel_read_status(ROT *rot, satel_stat_t *stat)
}
// XXX skip stored position count
- ret = read_string(&rs->rotport, (unsigned char *) resbuf, BUF_SIZE, "\n", 1, 0, 1);
+ ret = read_string(&rs->rotport, (unsigned char *) resbuf, BUF_SIZE, "\n", 1, 0,
+ 1);
if (ret < 0)
{
diff --git a/rotators/spid/spid.c b/rotators/spid/spid.c
index 8a80faad0..b7ff5e9ea 100644
--- a/rotators/spid/spid.c
+++ b/rotators/spid/spid.c
@@ -213,7 +213,7 @@ static int spid_rot2prog_rot_set_position(ROT *rot, azimuth_t az,
do
{
retval = write_block(&rs->rotport,
- (unsigned char *) "\x57\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x1F\x20", 13);
+ (unsigned char *) "\x57\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x1F\x20", 13);
if (retval != RIG_OK)
{
@@ -288,7 +288,7 @@ static int spid_rot_get_position(ROT *rot, azimuth_t *az, elevation_t *el)
do
{
retval = write_block(&rs->rotport,
- (unsigned char *) "\x57\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x1F\x20", 13);
+ (unsigned char *) "\x57\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x1F\x20", 13);
if (retval != RIG_OK)
{
@@ -360,7 +360,7 @@ static int spid_rot_stop(ROT *rot)
do
{
retval = write_block(&rs->rotport,
- (unsigned char *) "\x57\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0F\x20", 13);
+ (unsigned char *) "\x57\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0F\x20", 13);
if (retval != RIG_OK)
{
diff --git a/simulators/simicom.c b/simulators/simicom.c
index e06177fe5..d99d65b81 100644
--- a/simulators/simicom.c
+++ b/simulators/simicom.c
@@ -185,33 +185,41 @@ void frameParse(int fd, unsigned char *frame, int len)
break;
case 0x14:
- switch(frame[5])
+ switch (frame[5])
{
static int power_level = 0;
- case 0x0a:
- printf("Using power level %d\n", power_level);
- power_level += 10;
- if (power_level > 250) power_level = 0;
- to_bcd(&frame[6], (long long)power_level, 2);
- frame[8] = 0xfd;
- write(fd, frame, 9);
- break;
+
+ case 0x0a:
+ printf("Using power level %d\n", power_level);
+ power_level += 10;
+
+ if (power_level > 250) { power_level = 0; }
+
+ to_bcd(&frame[6], (long long)power_level, 2);
+ frame[8] = 0xfd;
+ write(fd, frame, 9);
+ break;
}
+
break;
case 0x15:
- switch(frame[5])
+ switch (frame[5])
{
static int meter_level = 0;
- case 0x11:
- printf("Using meter level %d\n", meter_level);
- meter_level += 10;
- if (meter_level > 250) meter_level = 0;
- to_bcd(&frame[6], (long long)meter_level, 2);
- frame[8] = 0xfd;
- write(fd, frame, 9);
- break;
+
+ case 0x11:
+ printf("Using meter level %d\n", meter_level);
+ meter_level += 10;
+
+ if (meter_level > 250) { meter_level = 0; }
+
+ to_bcd(&frame[6], (long long)meter_level, 2);
+ frame[8] = 0xfd;
+ write(fd, frame, 9);
+ break;
}
+
break;
case 0x1a: // miscellaneous things
diff --git a/simulators/simkenwood.c b/simulators/simkenwood.c
index 620429d54..8070309f7 100644
--- a/simulators/simkenwood.c
+++ b/simulators/simkenwood.c
@@ -219,7 +219,8 @@ int main(int argc, char *argv[])
}
else if (strncmp(buf, "MD;", 3) == 0)
{
- SNPRINTF(buf, sizeof(buf), "MD%d;", modeA); // not worried about modeB yet for simulator
+ SNPRINTF(buf, sizeof(buf), "MD%d;",
+ modeA); // not worried about modeB yet for simulator
write(fd, buf, strlen(buf));
}
else if (strncmp(buf, "MD", 2) == 0)
diff --git a/simulators/simyaesu.c b/simulators/simyaesu.c
index e68a223cf..1818784ea 100644
--- a/simulators/simyaesu.c
+++ b/simulators/simyaesu.c
@@ -197,9 +197,9 @@ int main(int argc, char *argv[])
}
#endif
- else if (strcmp(buf, "VS") == 0 && strlen(buf)>3)
+ else if (strcmp(buf, "VS") == 0 && strlen(buf) > 3)
{
- curr_vfo = buf[3] == '1'?RIG_VFO_B:RIG_VFO_A;
+ curr_vfo = buf[3] == '1' ? RIG_VFO_B : RIG_VFO_A;
usleep(50 * 1000);
}
else if (strcmp(buf, "VS;") == 0)
@@ -207,7 +207,9 @@ int main(int argc, char *argv[])
printf("%s\n", buf);
usleep(50 * 1000);
pbuf = "VS0;";
- if (curr_vfo == RIG_VFO_B || curr_vfo == RIG_VFO_SUB) pbuf[2] = '1';
+
+ if (curr_vfo == RIG_VFO_B || curr_vfo == RIG_VFO_SUB) { pbuf[2] = '1'; }
+
n = write(fd, pbuf, strlen(pbuf));
printf("n=%d\n", n);
diff --git a/src/amp_conf.c b/src/amp_conf.c
index 738f3089a..5a9acf643 100644
--- a/src/amp_conf.c
+++ b/src/amp_conf.c
@@ -350,7 +350,7 @@ int frontamp_get_conf2(AMP *amp, token_t token, char *val, int val_len)
switch (token)
{
case TOK_PATHNAME:
- strncpy(val, rs->ampport.pathname, val_len-1);
+ strncpy(val, rs->ampport.pathname, val_len - 1);
break;
case TOK_WRITE_DELAY:
@@ -428,7 +428,7 @@ int frontamp_get_conf2(AMP *amp, token_t token, char *val, int val_len)
return -RIG_EINVAL;
}
- strncpy(val, s, val_len-1);
+ strncpy(val, s, val_len - 1);
break;
case TOK_HANDSHAKE:
diff --git a/src/amplifier.c b/src/amplifier.c
index 0203c55dd..e9ed4c3a8 100644
--- a/src/amplifier.c
+++ b/src/amplifier.c
@@ -275,10 +275,12 @@ AMP *HAMLIB_API amp_init(amp_model_t amp_model)
return NULL;
}
}
+
// Now we have to copy our new rig state hamlib_port structure to the deprecated one
// Clients built on older 4.X versions will use the old structure
// Clients built on newer 4.5 versions will use the new structure
- memcpy(&->state.ampport_deprecated, &->state.ampport, sizeof(amp->state.ampport_deprecated));
+ memcpy(&->state.ampport_deprecated, &->state.ampport,
+ sizeof(amp->state.ampport_deprecated));
return amp;
}
diff --git a/src/cache.c b/src/cache.c
index 64a899194..0f2bf9c88 100644
--- a/src/cache.c
+++ b/src/cache.c
@@ -49,51 +49,51 @@ int rig_set_cache_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
switch (vfo)
{
- case RIG_VFO_ALL: // we'll use NONE to reset all VFO caches
- elapsed_ms(&rig->state.cache.time_modeMainA, HAMLIB_ELAPSED_INVALIDATE);
- elapsed_ms(&rig->state.cache.time_modeMainB, HAMLIB_ELAPSED_INVALIDATE);
- elapsed_ms(&rig->state.cache.time_modeMainC, HAMLIB_ELAPSED_INVALIDATE);
- elapsed_ms(&rig->state.cache.time_widthMainA, HAMLIB_ELAPSED_INVALIDATE);
- elapsed_ms(&rig->state.cache.time_widthMainB, HAMLIB_ELAPSED_INVALIDATE);
- elapsed_ms(&rig->state.cache.time_widthMainC, HAMLIB_ELAPSED_INVALIDATE);
- break;
+ case RIG_VFO_ALL: // we'll use NONE to reset all VFO caches
+ elapsed_ms(&rig->state.cache.time_modeMainA, HAMLIB_ELAPSED_INVALIDATE);
+ elapsed_ms(&rig->state.cache.time_modeMainB, HAMLIB_ELAPSED_INVALIDATE);
+ elapsed_ms(&rig->state.cache.time_modeMainC, HAMLIB_ELAPSED_INVALIDATE);
+ elapsed_ms(&rig->state.cache.time_widthMainA, HAMLIB_ELAPSED_INVALIDATE);
+ elapsed_ms(&rig->state.cache.time_widthMainB, HAMLIB_ELAPSED_INVALIDATE);
+ elapsed_ms(&rig->state.cache.time_widthMainC, HAMLIB_ELAPSED_INVALIDATE);
+ break;
- case RIG_VFO_A:
- case RIG_VFO_VFO:
- case RIG_VFO_MAIN:
- case RIG_VFO_MAIN_A:
- rig->state.cache.modeMainA = mode;
+ case RIG_VFO_A:
+ case RIG_VFO_VFO:
+ case RIG_VFO_MAIN:
+ case RIG_VFO_MAIN_A:
+ rig->state.cache.modeMainA = mode;
- if (width > 0) { rig->state.cache.widthMainA = width; }
+ if (width > 0) { rig->state.cache.widthMainA = width; }
- elapsed_ms(&rig->state.cache.time_modeMainA, HAMLIB_ELAPSED_SET);
- elapsed_ms(&rig->state.cache.time_widthMainA, HAMLIB_ELAPSED_SET);
- break;
+ elapsed_ms(&rig->state.cache.time_modeMainA, HAMLIB_ELAPSED_SET);
+ elapsed_ms(&rig->state.cache.time_widthMainA, HAMLIB_ELAPSED_SET);
+ break;
- case RIG_VFO_B:
- case RIG_VFO_SUB:
- case RIG_VFO_MAIN_B:
- rig->state.cache.modeMainB = mode;
+ case RIG_VFO_B:
+ case RIG_VFO_SUB:
+ case RIG_VFO_MAIN_B:
+ rig->state.cache.modeMainB = mode;
- if (width > 0) { rig->state.cache.widthMainB = width; }
+ if (width > 0) { rig->state.cache.widthMainB = width; }
- elapsed_ms(&rig->state.cache.time_modeMainB, HAMLIB_ELAPSED_SET);
- elapsed_ms(&rig->state.cache.time_widthMainB, HAMLIB_ELAPSED_SET);
- break;
+ elapsed_ms(&rig->state.cache.time_modeMainB, HAMLIB_ELAPSED_SET);
+ elapsed_ms(&rig->state.cache.time_widthMainB, HAMLIB_ELAPSED_SET);
+ break;
- case RIG_VFO_C:
- case RIG_VFO_MAIN_C:
- rig->state.cache.modeMainC = mode;
+ case RIG_VFO_C:
+ case RIG_VFO_MAIN_C:
+ rig->state.cache.modeMainC = mode;
- if (width > 0) { rig->state.cache.widthMainC = width; }
+ if (width > 0) { rig->state.cache.widthMainC = width; }
- elapsed_ms(&rig->state.cache.time_modeMainC, HAMLIB_ELAPSED_SET);
- elapsed_ms(&rig->state.cache.time_widthMainC, HAMLIB_ELAPSED_SET);
- break;
+ elapsed_ms(&rig->state.cache.time_modeMainC, HAMLIB_ELAPSED_SET);
+ elapsed_ms(&rig->state.cache.time_widthMainC, HAMLIB_ELAPSED_SET);
+ break;
- default:
- rig_debug(RIG_DEBUG_ERR, "%s: unknown vfo=%s\n", __func__, rig_strvfo(vfo));
- RETURNFUNC(-RIG_EINTERNAL);
+ default:
+ rig_debug(RIG_DEBUG_ERR, "%s: unknown vfo=%s\n", __func__, rig_strvfo(vfo));
+ RETURNFUNC(-RIG_EINTERNAL);
}
rig_cache_show(rig, __func__, __LINE__);
@@ -110,7 +110,7 @@ int rig_set_cache_freq(RIG *rig, vfo_t vfo, freq_t freq)
}
rig_debug(RIG_DEBUG_CACHE, "%s: vfo=%s, current_vfo=%s\n", __func__,
- rig_strvfo(vfo), rig_strvfo(rig->state.current_vfo));
+ rig_strvfo(vfo), rig_strvfo(rig->state.current_vfo));
if (vfo == RIG_VFO_CURR)
{
@@ -129,84 +129,84 @@ int rig_set_cache_freq(RIG *rig, vfo_t vfo, freq_t freq)
if (rig_need_debug(RIG_DEBUG_CACHE))
{
rig_debug(RIG_DEBUG_CACHE, "%s: set vfo=%s to freq=%.0f\n", __func__,
- rig_strvfo(vfo), freq);
+ rig_strvfo(vfo), freq);
}
switch (vfo)
{
- case RIG_VFO_ALL: // we'll use NONE to reset all VFO caches
- elapsed_ms(&rig->state.cache.time_freqMainA, HAMLIB_ELAPSED_INVALIDATE);
- elapsed_ms(&rig->state.cache.time_freqMainB, HAMLIB_ELAPSED_INVALIDATE);
- elapsed_ms(&rig->state.cache.time_freqMainC, HAMLIB_ELAPSED_INVALIDATE);
- elapsed_ms(&rig->state.cache.time_freqSubA, HAMLIB_ELAPSED_INVALIDATE);
- elapsed_ms(&rig->state.cache.time_freqSubB, HAMLIB_ELAPSED_INVALIDATE);
- elapsed_ms(&rig->state.cache.time_freqSubC, HAMLIB_ELAPSED_INVALIDATE);
- elapsed_ms(&rig->state.cache.time_freqMem, HAMLIB_ELAPSED_INVALIDATE);
- elapsed_ms(&rig->state.cache.time_vfo, HAMLIB_ELAPSED_INVALIDATE);
- elapsed_ms(&rig->state.cache.time_modeMainA, HAMLIB_ELAPSED_INVALIDATE);
- elapsed_ms(&rig->state.cache.time_modeMainB, HAMLIB_ELAPSED_INVALIDATE);
- elapsed_ms(&rig->state.cache.time_modeMainC, HAMLIB_ELAPSED_INVALIDATE);
- elapsed_ms(&rig->state.cache.time_widthMainA, HAMLIB_ELAPSED_INVALIDATE);
- elapsed_ms(&rig->state.cache.time_widthMainB, HAMLIB_ELAPSED_INVALIDATE);
- elapsed_ms(&rig->state.cache.time_widthMainC, HAMLIB_ELAPSED_INVALIDATE);
- elapsed_ms(&rig->state.cache.time_ptt, HAMLIB_ELAPSED_INVALIDATE);
- elapsed_ms(&rig->state.cache.time_split, HAMLIB_ELAPSED_INVALIDATE);
- break;
+ case RIG_VFO_ALL: // we'll use NONE to reset all VFO caches
+ elapsed_ms(&rig->state.cache.time_freqMainA, HAMLIB_ELAPSED_INVALIDATE);
+ elapsed_ms(&rig->state.cache.time_freqMainB, HAMLIB_ELAPSED_INVALIDATE);
+ elapsed_ms(&rig->state.cache.time_freqMainC, HAMLIB_ELAPSED_INVALIDATE);
+ elapsed_ms(&rig->state.cache.time_freqSubA, HAMLIB_ELAPSED_INVALIDATE);
+ elapsed_ms(&rig->state.cache.time_freqSubB, HAMLIB_ELAPSED_INVALIDATE);
+ elapsed_ms(&rig->state.cache.time_freqSubC, HAMLIB_ELAPSED_INVALIDATE);
+ elapsed_ms(&rig->state.cache.time_freqMem, HAMLIB_ELAPSED_INVALIDATE);
+ elapsed_ms(&rig->state.cache.time_vfo, HAMLIB_ELAPSED_INVALIDATE);
+ elapsed_ms(&rig->state.cache.time_modeMainA, HAMLIB_ELAPSED_INVALIDATE);
+ elapsed_ms(&rig->state.cache.time_modeMainB, HAMLIB_ELAPSED_INVALIDATE);
+ elapsed_ms(&rig->state.cache.time_modeMainC, HAMLIB_ELAPSED_INVALIDATE);
+ elapsed_ms(&rig->state.cache.time_widthMainA, HAMLIB_ELAPSED_INVALIDATE);
+ elapsed_ms(&rig->state.cache.time_widthMainB, HAMLIB_ELAPSED_INVALIDATE);
+ elapsed_ms(&rig->state.cache.time_widthMainC, HAMLIB_ELAPSED_INVALIDATE);
+ elapsed_ms(&rig->state.cache.time_ptt, HAMLIB_ELAPSED_INVALIDATE);
+ elapsed_ms(&rig->state.cache.time_split, HAMLIB_ELAPSED_INVALIDATE);
+ break;
- case RIG_VFO_A:
- case RIG_VFO_VFO:
- case RIG_VFO_MAIN:
- case RIG_VFO_MAIN_A:
- rig->state.cache.freqMainA = freq;
- elapsed_ms(&rig->state.cache.time_freqMainA, flag);
- break;
+ case RIG_VFO_A:
+ case RIG_VFO_VFO:
+ case RIG_VFO_MAIN:
+ case RIG_VFO_MAIN_A:
+ rig->state.cache.freqMainA = freq;
+ elapsed_ms(&rig->state.cache.time_freqMainA, flag);
+ break;
- case RIG_VFO_B:
- case RIG_VFO_MAIN_B:
- case RIG_VFO_SUB:
- rig->state.cache.freqMainB = freq;
- elapsed_ms(&rig->state.cache.time_freqMainB, flag);
- break;
+ case RIG_VFO_B:
+ case RIG_VFO_MAIN_B:
+ case RIG_VFO_SUB:
+ rig->state.cache.freqMainB = freq;
+ elapsed_ms(&rig->state.cache.time_freqMainB, flag);
+ break;
- case RIG_VFO_C:
- case RIG_VFO_MAIN_C:
- rig->state.cache.freqMainC = freq;
- elapsed_ms(&rig->state.cache.time_freqMainC, flag);
- break;
+ case RIG_VFO_C:
+ case RIG_VFO_MAIN_C:
+ rig->state.cache.freqMainC = freq;
+ elapsed_ms(&rig->state.cache.time_freqMainC, flag);
+ break;
- case RIG_VFO_SUB_A:
- rig->state.cache.freqSubA = freq;
- elapsed_ms(&rig->state.cache.time_freqSubA, flag);
- break;
+ case RIG_VFO_SUB_A:
+ rig->state.cache.freqSubA = freq;
+ elapsed_ms(&rig->state.cache.time_freqSubA, flag);
+ break;
- case RIG_VFO_SUB_B:
- rig->state.cache.freqSubB = freq;
- elapsed_ms(&rig->state.cache.time_freqSubB, flag);
- break;
+ case RIG_VFO_SUB_B:
+ rig->state.cache.freqSubB = freq;
+ elapsed_ms(&rig->state.cache.time_freqSubB, flag);
+ break;
- case RIG_VFO_SUB_C:
- rig->state.cache.freqSubC = freq;
- elapsed_ms(&rig->state.cache.time_freqSubC, flag);
- break;
+ case RIG_VFO_SUB_C:
+ rig->state.cache.freqSubC = freq;
+ elapsed_ms(&rig->state.cache.time_freqSubC, flag);
+ break;
- case RIG_VFO_MEM:
- rig->state.cache.freqMem = freq;
- elapsed_ms(&rig->state.cache.time_freqMem, flag);
- break;
+ case RIG_VFO_MEM:
+ rig->state.cache.freqMem = freq;
+ elapsed_ms(&rig->state.cache.time_freqMem, flag);
+ break;
- default:
- rig_debug(RIG_DEBUG_ERR, "%s: unknown vfo?, vfo=%s\n", __func__,
- rig_strvfo(vfo));
- return(-RIG_EINVAL);
+ default:
+ rig_debug(RIG_DEBUG_ERR, "%s: unknown vfo?, vfo=%s\n", __func__,
+ rig_strvfo(vfo));
+ return (-RIG_EINVAL);
}
if (rig_need_debug(RIG_DEBUG_CACHE))
{
rig_cache_show(rig, __func__, __LINE__);
- return(RIG_OK);
+ return (RIG_OK);
}
- return(RIG_OK);
+ return (RIG_OK);
}
/**
@@ -231,10 +231,10 @@ int rig_set_cache_freq(RIG *rig, vfo_t vfo, freq_t freq)
*
*/
int rig_get_cache(RIG *rig, vfo_t vfo, freq_t *freq, int *cache_ms_freq,
- rmode_t *mode, int *cache_ms_mode, pbwidth_t *width, int *cache_ms_width)
+ rmode_t *mode, int *cache_ms_mode, pbwidth_t *width, int *cache_ms_width)
{
if (CHECK_RIG_ARG(rig) || !freq || !cache_ms_freq ||
- !mode || !cache_ms_mode || !width || !cache_ms_width)
+ !mode || !cache_ms_mode || !width || !cache_ms_width)
{
RETURNFUNC(-RIG_EINVAL);
}
@@ -245,7 +245,7 @@ int rig_get_cache(RIG *rig, vfo_t vfo, freq_t *freq, int *cache_ms_freq,
}
rig_debug(RIG_DEBUG_CACHE, "%s: vfo=%s, current_vfo=%s\n", __func__,
- rig_strvfo(vfo), rig_strvfo(rig->state.current_vfo));
+ rig_strvfo(vfo), rig_strvfo(rig->state.current_vfo));
if (vfo == RIG_VFO_CURR)
{
@@ -255,40 +255,40 @@ int rig_get_cache(RIG *rig, vfo_t vfo, freq_t *freq, int *cache_ms_freq,
{
switch (rig->state.current_vfo)
{
- case RIG_VFO_OTHER:
- vfo = RIG_VFO_OTHER;
- break;
+ case RIG_VFO_OTHER:
+ vfo = RIG_VFO_OTHER;
+ break;
- case RIG_VFO_A:
- vfo = RIG_VFO_B;
- break;
+ case RIG_VFO_A:
+ vfo = RIG_VFO_B;
+ break;
- case RIG_VFO_MAIN_A:
- vfo = RIG_VFO_MAIN_B;
- break;
+ case RIG_VFO_MAIN_A:
+ vfo = RIG_VFO_MAIN_B;
+ break;
- case RIG_VFO_MAIN:
- vfo = RIG_VFO_SUB;
- break;
+ case RIG_VFO_MAIN:
+ vfo = RIG_VFO_SUB;
+ break;
- case RIG_VFO_B:
- vfo = RIG_VFO_A;
- break;
+ case RIG_VFO_B:
+ vfo = RIG_VFO_A;
+ break;
- case RIG_VFO_MAIN_B:
- vfo = RIG_VFO_MAIN_A;
- break;
+ case RIG_VFO_MAIN_B:
+ vfo = RIG_VFO_MAIN_A;
+ break;
- case RIG_VFO_SUB_A:
- vfo = RIG_VFO_SUB_B;
- break;
+ case RIG_VFO_SUB_A:
+ vfo = RIG_VFO_SUB_B;
+ break;
- case RIG_VFO_SUB_B:
- vfo = RIG_VFO_SUB_A;
- break;
+ case RIG_VFO_SUB_B:
+ vfo = RIG_VFO_SUB_A;
+ break;
- default:
- rig_debug(RIG_DEBUG_ERR, "%s: unknown vfo=%s\n", __func__, rig_strvfo(vfo));
+ default:
+ rig_debug(RIG_DEBUG_ERR, "%s: unknown vfo=%s\n", __func__, rig_strvfo(vfo));
}
}
@@ -300,127 +300,127 @@ int rig_get_cache(RIG *rig, vfo_t vfo, freq_t *freq, int *cache_ms_freq,
switch (vfo)
{
- case RIG_VFO_CURR:
- *freq = rig->state.cache.freqCurr;
- *mode = rig->state.cache.modeCurr;
- *width = rig->state.cache.widthCurr;
- *cache_ms_freq = elapsed_ms(&rig->state.cache.time_freqCurr,
- HAMLIB_ELAPSED_GET);
- *cache_ms_mode = elapsed_ms(&rig->state.cache.time_modeCurr,
- HAMLIB_ELAPSED_GET);
- *cache_ms_width = elapsed_ms(&rig->state.cache.time_widthCurr,
- HAMLIB_ELAPSED_GET);
- break;
+ case RIG_VFO_CURR:
+ *freq = rig->state.cache.freqCurr;
+ *mode = rig->state.cache.modeCurr;
+ *width = rig->state.cache.widthCurr;
+ *cache_ms_freq = elapsed_ms(&rig->state.cache.time_freqCurr,
+ HAMLIB_ELAPSED_GET);
+ *cache_ms_mode = elapsed_ms(&rig->state.cache.time_modeCurr,
+ HAMLIB_ELAPSED_GET);
+ *cache_ms_width = elapsed_ms(&rig->state.cache.time_widthCurr,
+ HAMLIB_ELAPSED_GET);
+ break;
- case RIG_VFO_OTHER:
- *freq = rig->state.cache.freqOther;
- *mode = rig->state.cache.modeOther;
- *width = rig->state.cache.widthOther;
- *cache_ms_freq = elapsed_ms(&rig->state.cache.time_freqOther,
- HAMLIB_ELAPSED_GET);
- *cache_ms_mode = elapsed_ms(&rig->state.cache.time_modeOther,
- HAMLIB_ELAPSED_GET);
- *cache_ms_width = elapsed_ms(&rig->state.cache.time_widthOther,
- HAMLIB_ELAPSED_GET);
- break;
+ case RIG_VFO_OTHER:
+ *freq = rig->state.cache.freqOther;
+ *mode = rig->state.cache.modeOther;
+ *width = rig->state.cache.widthOther;
+ *cache_ms_freq = elapsed_ms(&rig->state.cache.time_freqOther,
+ HAMLIB_ELAPSED_GET);
+ *cache_ms_mode = elapsed_ms(&rig->state.cache.time_modeOther,
+ HAMLIB_ELAPSED_GET);
+ *cache_ms_width = elapsed_ms(&rig->state.cache.time_widthOther,
+ HAMLIB_ELAPSED_GET);
+ break;
- case RIG_VFO_A:
- case RIG_VFO_VFO:
- case RIG_VFO_MAIN:
- case RIG_VFO_MAIN_A:
- *freq = rig->state.cache.freqMainA;
- *mode = rig->state.cache.modeMainA;
- *width = rig->state.cache.widthMainA;
- *cache_ms_freq = elapsed_ms(&rig->state.cache.time_freqMainA,
- HAMLIB_ELAPSED_GET);
- *cache_ms_mode = elapsed_ms(&rig->state.cache.time_modeMainA,
- HAMLIB_ELAPSED_GET);
- *cache_ms_width = elapsed_ms(&rig->state.cache.time_widthMainA,
- HAMLIB_ELAPSED_GET);
- break;
+ case RIG_VFO_A:
+ case RIG_VFO_VFO:
+ case RIG_VFO_MAIN:
+ case RIG_VFO_MAIN_A:
+ *freq = rig->state.cache.freqMainA;
+ *mode = rig->state.cache.modeMainA;
+ *width = rig->state.cache.widthMainA;
+ *cache_ms_freq = elapsed_ms(&rig->state.cache.time_freqMainA,
+ HAMLIB_ELAPSED_GET);
+ *cache_ms_mode = elapsed_ms(&rig->state.cache.time_modeMainA,
+ HAMLIB_ELAPSED_GET);
+ *cache_ms_width = elapsed_ms(&rig->state.cache.time_widthMainA,
+ HAMLIB_ELAPSED_GET);
+ break;
- case RIG_VFO_B:
- case RIG_VFO_SUB:
- case RIG_VFO_MAIN_B:
- *freq = rig->state.cache.freqMainB;
- *mode = rig->state.cache.modeMainB;
- *width = rig->state.cache.widthMainB;
- *cache_ms_freq = elapsed_ms(&rig->state.cache.time_freqMainB,
- HAMLIB_ELAPSED_GET);
- *cache_ms_mode = elapsed_ms(&rig->state.cache.time_modeMainB,
- HAMLIB_ELAPSED_GET);
- *cache_ms_width = elapsed_ms(&rig->state.cache.time_widthMainB,
- HAMLIB_ELAPSED_GET);
- break;
+ case RIG_VFO_B:
+ case RIG_VFO_SUB:
+ case RIG_VFO_MAIN_B:
+ *freq = rig->state.cache.freqMainB;
+ *mode = rig->state.cache.modeMainB;
+ *width = rig->state.cache.widthMainB;
+ *cache_ms_freq = elapsed_ms(&rig->state.cache.time_freqMainB,
+ HAMLIB_ELAPSED_GET);
+ *cache_ms_mode = elapsed_ms(&rig->state.cache.time_modeMainB,
+ HAMLIB_ELAPSED_GET);
+ *cache_ms_width = elapsed_ms(&rig->state.cache.time_widthMainB,
+ HAMLIB_ELAPSED_GET);
+ break;
- case RIG_VFO_SUB_A:
- *freq = rig->state.cache.freqSubA;
- *mode = rig->state.cache.modeSubA;
- *width = rig->state.cache.widthSubA;
- *cache_ms_freq = elapsed_ms(&rig->state.cache.time_freqSubA,
- HAMLIB_ELAPSED_GET);
- *cache_ms_mode = elapsed_ms(&rig->state.cache.time_modeSubA,
- HAMLIB_ELAPSED_GET);
- *cache_ms_width = elapsed_ms(&rig->state.cache.time_widthSubA,
- HAMLIB_ELAPSED_GET);
- break;
+ case RIG_VFO_SUB_A:
+ *freq = rig->state.cache.freqSubA;
+ *mode = rig->state.cache.modeSubA;
+ *width = rig->state.cache.widthSubA;
+ *cache_ms_freq = elapsed_ms(&rig->state.cache.time_freqSubA,
+ HAMLIB_ELAPSED_GET);
+ *cache_ms_mode = elapsed_ms(&rig->state.cache.time_modeSubA,
+ HAMLIB_ELAPSED_GET);
+ *cache_ms_width = elapsed_ms(&rig->state.cache.time_widthSubA,
+ HAMLIB_ELAPSED_GET);
+ break;
- case RIG_VFO_SUB_B:
- *freq = rig->state.cache.freqSubB;
- *mode = rig->state.cache.modeSubB;
- *width = rig->state.cache.widthSubB;
- *cache_ms_freq = elapsed_ms(&rig->state.cache.time_freqSubB,
- HAMLIB_ELAPSED_GET);
- *cache_ms_mode = elapsed_ms(&rig->state.cache.time_modeSubB,
- HAMLIB_ELAPSED_GET);
- *cache_ms_width = elapsed_ms(&rig->state.cache.time_widthSubB,
- HAMLIB_ELAPSED_GET);
- break;
+ case RIG_VFO_SUB_B:
+ *freq = rig->state.cache.freqSubB;
+ *mode = rig->state.cache.modeSubB;
+ *width = rig->state.cache.widthSubB;
+ *cache_ms_freq = elapsed_ms(&rig->state.cache.time_freqSubB,
+ HAMLIB_ELAPSED_GET);
+ *cache_ms_mode = elapsed_ms(&rig->state.cache.time_modeSubB,
+ HAMLIB_ELAPSED_GET);
+ *cache_ms_width = elapsed_ms(&rig->state.cache.time_widthSubB,
+ HAMLIB_ELAPSED_GET);
+ break;
- case RIG_VFO_C:
- //case RIG_VFO_MAINC: // not used by any rig yet
- *freq = rig->state.cache.freqMainC;
- *mode = rig->state.cache.modeMainC;
- *width = rig->state.cache.widthMainC;
- *cache_ms_freq = elapsed_ms(&rig->state.cache.time_freqMainC,
- HAMLIB_ELAPSED_GET);
- *cache_ms_mode = elapsed_ms(&rig->state.cache.time_modeMainC,
- HAMLIB_ELAPSED_GET);
- *cache_ms_width = elapsed_ms(&rig->state.cache.time_widthMainC,
- HAMLIB_ELAPSED_GET);
- break;
+ case RIG_VFO_C:
+ //case RIG_VFO_MAINC: // not used by any rig yet
+ *freq = rig->state.cache.freqMainC;
+ *mode = rig->state.cache.modeMainC;
+ *width = rig->state.cache.widthMainC;
+ *cache_ms_freq = elapsed_ms(&rig->state.cache.time_freqMainC,
+ HAMLIB_ELAPSED_GET);
+ *cache_ms_mode = elapsed_ms(&rig->state.cache.time_modeMainC,
+ HAMLIB_ELAPSED_GET);
+ *cache_ms_width = elapsed_ms(&rig->state.cache.time_widthMainC,
+ HAMLIB_ELAPSED_GET);
+ break;
- case RIG_VFO_SUB_C:
- *freq = rig->state.cache.freqSubC;
- *mode = rig->state.cache.modeSubC;
- *width = rig->state.cache.widthSubC;
- *cache_ms_freq = elapsed_ms(&rig->state.cache.time_freqSubC,
- HAMLIB_ELAPSED_GET);
- *cache_ms_mode = elapsed_ms(&rig->state.cache.time_modeSubC,
- HAMLIB_ELAPSED_GET);
- *cache_ms_width = elapsed_ms(&rig->state.cache.time_widthSubC,
- HAMLIB_ELAPSED_GET);
- break;
+ case RIG_VFO_SUB_C:
+ *freq = rig->state.cache.freqSubC;
+ *mode = rig->state.cache.modeSubC;
+ *width = rig->state.cache.widthSubC;
+ *cache_ms_freq = elapsed_ms(&rig->state.cache.time_freqSubC,
+ HAMLIB_ELAPSED_GET);
+ *cache_ms_mode = elapsed_ms(&rig->state.cache.time_modeSubC,
+ HAMLIB_ELAPSED_GET);
+ *cache_ms_width = elapsed_ms(&rig->state.cache.time_widthSubC,
+ HAMLIB_ELAPSED_GET);
+ break;
- case RIG_VFO_MEM:
- *freq = rig->state.cache.freqMem;
- *mode = rig->state.cache.modeMem;
- *width = rig->state.cache.widthMem;
- *cache_ms_freq = elapsed_ms(&rig->state.cache.time_freqMem, HAMLIB_ELAPSED_GET);
- *cache_ms_mode = elapsed_ms(&rig->state.cache.time_modeMem, HAMLIB_ELAPSED_GET);
- *cache_ms_width = elapsed_ms(&rig->state.cache.time_widthMem,
- HAMLIB_ELAPSED_GET);
- break;
+ case RIG_VFO_MEM:
+ *freq = rig->state.cache.freqMem;
+ *mode = rig->state.cache.modeMem;
+ *width = rig->state.cache.widthMem;
+ *cache_ms_freq = elapsed_ms(&rig->state.cache.time_freqMem, HAMLIB_ELAPSED_GET);
+ *cache_ms_mode = elapsed_ms(&rig->state.cache.time_modeMem, HAMLIB_ELAPSED_GET);
+ *cache_ms_width = elapsed_ms(&rig->state.cache.time_widthMem,
+ HAMLIB_ELAPSED_GET);
+ break;
- default:
- rig_debug(RIG_DEBUG_ERR, "%s: unknown vfo?, vfo=%s\n", __func__,
- rig_strvfo(vfo));
- RETURNFUNC(-RIG_EINVAL);
+ default:
+ rig_debug(RIG_DEBUG_ERR, "%s: unknown vfo?, vfo=%s\n", __func__,
+ rig_strvfo(vfo));
+ RETURNFUNC(-RIG_EINVAL);
}
rig_debug(RIG_DEBUG_CACHE, "%s: vfo=%s, freq=%.0f, mode=%s, width=%d\n",
- __func__, rig_strvfo(vfo),
- (double)*freq, rig_strrmode(*mode), (int)*width);
+ __func__, rig_strvfo(vfo),
+ (double)*freq, rig_strrmode(*mode), (int)*width);
if (rig_need_debug(RIG_DEBUG_CACHE))
{
@@ -433,24 +433,24 @@ int rig_get_cache(RIG *rig, vfo_t vfo, freq_t *freq, int *cache_ms_freq,
void rig_cache_show(RIG *rig, const char *func, int line)
{
rig_debug(RIG_DEBUG_CACHE,
- "%s(%d): freqMainA=%.0f, modeMainA=%s, widthMainA=%d\n", func, line,
- rig->state.cache.freqMainA, rig_strrmode(rig->state.cache.modeMainA),
- (int)rig->state.cache.widthMainA);
+ "%s(%d): freqMainA=%.0f, modeMainA=%s, widthMainA=%d\n", func, line,
+ rig->state.cache.freqMainA, rig_strrmode(rig->state.cache.modeMainA),
+ (int)rig->state.cache.widthMainA);
rig_debug(RIG_DEBUG_CACHE,
- "%s(%d): freqMainB=%.0f, modeMainB=%s, widthMainB=%d\n", func, line,
- rig->state.cache.freqMainB, rig_strrmode(rig->state.cache.modeMainB),
- (int)rig->state.cache.widthMainB);
+ "%s(%d): freqMainB=%.0f, modeMainB=%s, widthMainB=%d\n", func, line,
+ rig->state.cache.freqMainB, rig_strrmode(rig->state.cache.modeMainB),
+ (int)rig->state.cache.widthMainB);
if (rig->state.vfo_list & RIG_VFO_SUB_A)
{
rig_debug(RIG_DEBUG_CACHE,
- "%s(%d): freqSubA=%.0f, modeSubA=%s, widthSubA=%d\n", func, line,
- rig->state.cache.freqSubA, rig_strrmode(rig->state.cache.modeSubA),
- (int)rig->state.cache.widthSubA);
+ "%s(%d): freqSubA=%.0f, modeSubA=%s, widthSubA=%d\n", func, line,
+ rig->state.cache.freqSubA, rig_strrmode(rig->state.cache.modeSubA),
+ (int)rig->state.cache.widthSubA);
rig_debug(RIG_DEBUG_CACHE,
- "%s(%d): freqSubB=%.0f, modeSubB=%s, widthSubB=%d\n", func, line,
- rig->state.cache.freqSubB, rig_strrmode(rig->state.cache.modeSubB),
- (int)rig->state.cache.widthSubB);
+ "%s(%d): freqSubB=%.0f, modeSubB=%s, widthSubB=%d\n", func, line,
+ rig->state.cache.freqSubB, rig_strrmode(rig->state.cache.modeSubB),
+ (int)rig->state.cache.widthSubB);
}
}
diff --git a/src/conf.c b/src/conf.c
index 3c9e19aa1..e55c1eac7 100644
--- a/src/conf.c
+++ b/src/conf.c
@@ -536,6 +536,7 @@ static int frontend_set_conf(RIG *rig, token_t token, const char *val)
{
return -RIG_EINVAL;
}
+
// JTDX and WSJTX currently use state.pttport to check for PTT_NONE
rig->state.pttport.type.ptt = rs->pttport.type.ptt;
rs->pttport_deprecated.type.ptt = rs->pttport.type.ptt;
@@ -760,7 +761,7 @@ static int frontend_get_conf2(RIG *rig, token_t token, char *val, int val_len)
case TOK_ITU_REGION:
SNPRINTF(val, val_len, "%d",
- rs->itu_region == 1 ? RIG_ITU_REGION1 : RIG_ITU_REGION2);
+ rs->itu_region == 1 ? RIG_ITU_REGION1 : RIG_ITU_REGION2);
break;
#endif
@@ -1067,7 +1068,7 @@ static int frontend_get_conf2(RIG *rig, token_t token, char *val, int val_len)
return -RIG_EINVAL;
}
- memcpy(&rs->rigport_deprecated,&rs->rigport,sizeof(hamlib_port_t_deprecated));
+ memcpy(&rs->rigport_deprecated, &rs->rigport, sizeof(hamlib_port_t_deprecated));
return RIG_OK;
}
@@ -1299,7 +1300,7 @@ int HAMLIB_API rig_get_conf2(RIG *rig, token_t token, char *val, int val_len)
{
return frontend_get_conf2(rig, token, val, val_len);
}
-
+
if (rig->caps->get_conf2)
{
return rig->caps->get_conf2(rig, token, val, val_len);
diff --git a/src/event.c b/src/event.c
index 795027ce3..0c904c38f 100644
--- a/src/event.c
+++ b/src/event.c
@@ -78,10 +78,12 @@ void *rig_poll_routine(void *arg)
freq_t freq_main = 0, freq_sub = 0, freq_main_prev = 0, freq_sub_prev = 0;
rmode_t mode_main = RIG_MODE_NONE, mode_sub = RIG_MODE_NONE,
mode_main_prev = RIG_MODE_NONE, mode_sub_prev = RIG_MODE_NONE;
- pbwidth_t width_main = 0, width_sub = 0, width_main_prev = 0, width_sub_prev = 0;
+ pbwidth_t width_main = 0, width_sub = 0, width_main_prev = 0,
+ width_sub_prev = 0;
split_t split, split_prev = -1;
- rig_debug(RIG_DEBUG_VERBOSE, "%s(%d): Starting rig poll routine thread\n", __FILE__, __LINE__);
+ rig_debug(RIG_DEBUG_VERBOSE, "%s(%d): Starting rig poll routine thread\n",
+ __FILE__, __LINE__);
// Rig cache time should be equal to rig poll interval (should be set automatically by rigctld at least)
rig_set_cache_timeout_ms(rig, HAMLIB_CACHE_ALL, rs->poll_interval);
@@ -93,9 +95,11 @@ void *rig_poll_routine(void *arg)
if (rig->caps->get_vfo)
{
result = rig_get_vfo(rig, &vfo);
+
if (result != RIG_OK)
{
- rig_debug(RIG_DEBUG_ERR, "%s(%d): rig_get_vfo error %s\n", __FILE__, __LINE__, rigerror(result));
+ rig_debug(RIG_DEBUG_ERR, "%s(%d): rig_get_vfo error %s\n", __FILE__, __LINE__,
+ rigerror(result));
}
if (vfo != vfo_prev)
@@ -106,8 +110,8 @@ void *rig_poll_routine(void *arg)
if (vfo != vfo_prev)
{
rig_debug(RIG_DEBUG_CACHE,
- "%s(%d) vfo=%s was %s\n", __FILE__, __LINE__,
- rig_strvfo(vfo), rig_strvfo(vfo_prev));
+ "%s(%d) vfo=%s was %s\n", __FILE__, __LINE__,
+ rig_strvfo(vfo), rig_strvfo(vfo_prev));
update_occurred = 1;
vfo_prev = vfo;
}
@@ -119,20 +123,23 @@ void *rig_poll_routine(void *arg)
if (result != RIG_OK)
{
- rig_debug(RIG_DEBUG_ERR, "%s(%d): rig_get_freqA error %s\n", __FILE__, __LINE__, rigerror(result));
+ rig_debug(RIG_DEBUG_ERR, "%s(%d): rig_get_freqA error %s\n", __FILE__, __LINE__,
+ rigerror(result));
}
result = rig_get_freq(rig, RIG_VFO_B, &freq_sub);
if (result != RIG_OK)
{
- rig_debug(RIG_DEBUG_ERR, "%s(%d): rig_get_freqB error %s\n", __FILE__, __LINE__, rigerror(result));
+ rig_debug(RIG_DEBUG_ERR, "%s(%d): rig_get_freqB error %s\n", __FILE__, __LINE__,
+ rigerror(result));
}
if (freq_main != freq_main_prev)
{
rig_fire_freq_event(rig, RIG_VFO_A, freq_main);
}
+
if (freq_sub != freq_sub_prev)
{
rig_fire_freq_event(rig, RIG_VFO_B, freq_sub);
@@ -141,8 +148,8 @@ void *rig_poll_routine(void *arg)
if (freq_main != freq_main_prev || freq_sub != freq_sub_prev)
{
rig_debug(RIG_DEBUG_CACHE,
- "%s(%d) freq_main=%.0f was %.0f, freq_sub=%.0f was %.0f\n", __FILE__, __LINE__,
- freq_main, freq_main_prev, freq_sub, freq_sub_prev);
+ "%s(%d) freq_main=%.0f was %.0f, freq_sub=%.0f was %.0f\n", __FILE__, __LINE__,
+ freq_main, freq_main_prev, freq_sub, freq_sub_prev);
update_occurred = 1;
freq_main_prev = freq_main;
freq_sub_prev = freq_sub;
@@ -155,20 +162,23 @@ void *rig_poll_routine(void *arg)
if (result != RIG_OK)
{
- rig_debug(RIG_DEBUG_ERR, "%s(%d): rig_get_modeA error %s\n", __FILE__, __LINE__, rigerror(result));
+ rig_debug(RIG_DEBUG_ERR, "%s(%d): rig_get_modeA error %s\n", __FILE__, __LINE__,
+ rigerror(result));
}
result = rig_get_mode(rig, RIG_VFO_B, &mode_sub, &width_sub);
if (result != RIG_OK)
{
- rig_debug(RIG_DEBUG_ERR, "%s(%d): rig_get_modeB error %s\n", __FILE__, __LINE__, rigerror(result));
+ rig_debug(RIG_DEBUG_ERR, "%s(%d): rig_get_modeB error %s\n", __FILE__, __LINE__,
+ rigerror(result));
}
if (mode_main != mode_main_prev || width_main != width_main_prev)
{
rig_fire_mode_event(rig, RIG_VFO_A, mode_main, width_main);
}
+
if (mode_sub != mode_sub_prev || width_sub != width_sub_prev)
{
rig_fire_mode_event(rig, RIG_VFO_B, mode_sub, width_sub);
@@ -177,8 +187,8 @@ void *rig_poll_routine(void *arg)
if (mode_main != mode_main_prev || mode_sub != mode_sub_prev)
{
rig_debug(RIG_DEBUG_CACHE, "%s(%d) mode_main=%s was %s, mode_sub=%s was %s\n",
- __FILE__, __LINE__, rig_strrmode(mode_main), rig_strrmode(mode_main_prev),
- rig_strrmode(mode_sub), rig_strrmode(mode_sub_prev));
+ __FILE__, __LINE__, rig_strrmode(mode_main), rig_strrmode(mode_main_prev),
+ rig_strrmode(mode_sub), rig_strrmode(mode_sub_prev));
update_occurred = 1;
mode_main_prev = mode_main;
mode_sub_prev = mode_sub;
@@ -187,8 +197,8 @@ void *rig_poll_routine(void *arg)
if (width_main != width_main_prev || width_sub != width_sub_prev)
{
rig_debug(RIG_DEBUG_CACHE,
- "%s(%d) width_main=%ld was %ld, width_sub=%ld was %ld\n", __FILE__, __LINE__,
- width_main, width_main_prev, width_sub, width_sub_prev);
+ "%s(%d) width_main=%ld was %ld, width_sub=%ld was %ld\n", __FILE__, __LINE__,
+ width_main, width_main_prev, width_sub, width_sub_prev);
update_occurred = 1;
width_main_prev = width_main;
width_sub_prev = width_sub;
@@ -202,13 +212,15 @@ void *rig_poll_routine(void *arg)
if (result != RIG_OK)
{
- rig_debug(RIG_DEBUG_ERR, "%s(%d): rig_get_modeA error %s\n", __FILE__, __LINE__, rigerror(result));
+ rig_debug(RIG_DEBUG_ERR, "%s(%d): rig_get_modeA error %s\n", __FILE__, __LINE__,
+ rigerror(result));
}
if (split != split_prev)
{
- rig_debug(RIG_DEBUG_CACHE, "%s(%d) split=%d was %d\n", __FILE__, __LINE__, split,
- split_prev);
+ rig_debug(RIG_DEBUG_CACHE, "%s(%d) split=%d was %d\n", __FILE__, __LINE__,
+ split,
+ split_prev);
update_occurred = 1;
split_prev = split;
}
@@ -222,8 +234,9 @@ void *rig_poll_routine(void *arg)
hl_usleep(rs->poll_interval * 1000);
}
- rig_debug(RIG_DEBUG_VERBOSE, "%s(%d): Stopping rig poll routine thread\n", __FILE__,
- __LINE__);
+ rig_debug(RIG_DEBUG_VERBOSE, "%s(%d): Stopping rig poll routine thread\n",
+ __FILE__,
+ __LINE__);
return NULL;
}
@@ -244,20 +257,22 @@ int rig_poll_routine_start(RIG *rig)
if (rs->poll_interval < 1)
{
- rig_debug(RIG_DEBUG_ERR, "%s(%d): rig poll routine disabled, poll interval set to zero\n", __FILE__,
- __LINE__);
+ rig_debug(RIG_DEBUG_ERR,
+ "%s(%d): rig poll routine disabled, poll interval set to zero\n", __FILE__,
+ __LINE__);
RETURNFUNC(RIG_OK);
}
if (rs->poll_routine_priv_data != NULL)
{
rig_debug(RIG_DEBUG_ERR, "%s(%d): rig poll routine already running\n", __FILE__,
- __LINE__);
+ __LINE__);
RETURNFUNC(-RIG_EINVAL);
}
rs->poll_routine_thread_run = 1;
rs->poll_routine_priv_data = calloc(1, sizeof(rig_poll_routine_priv_data));
+
if (rs->poll_routine_priv_data == NULL)
{
RETURNFUNC(-RIG_ENOMEM);
@@ -266,12 +281,13 @@ int rig_poll_routine_start(RIG *rig)
poll_routine_priv = (rig_poll_routine_priv_data *) rs->poll_routine_priv_data;
poll_routine_priv->args.rig = rig;
int err = pthread_create(&poll_routine_priv->thread_id, NULL,
- rig_poll_routine, &poll_routine_priv->args);
+ rig_poll_routine, &poll_routine_priv->args);
if (err)
{
- rig_debug(RIG_DEBUG_ERR, "%s(%d) pthread_create error: %s\n", __FILE__, __LINE__,
- strerror(errno));
+ rig_debug(RIG_DEBUG_ERR, "%s(%d) pthread_create error: %s\n", __FILE__,
+ __LINE__,
+ strerror(errno));
RETURNFUNC(-RIG_EINTERNAL);
}
@@ -313,7 +329,7 @@ int rig_poll_routine_stop(RIG *rig)
if (err)
{
rig_debug(RIG_DEBUG_ERR, "%s(%d): pthread_join error %s\n", __FILE__, __LINE__,
- strerror(errno));
+ strerror(errno));
// just ignore it
}
@@ -578,7 +594,7 @@ int rig_fire_freq_event(RIG *rig, vfo_t vfo, freq_t freq)
ENTERFUNC;
rig_debug(RIG_DEBUG_TRACE, "Event: freq changed to %"PRIll"Hz on %s\n",
- (int64_t)freq, rig_strvfo(vfo));
+ (int64_t)freq, rig_strvfo(vfo));
rig_set_cache_freq(rig, vfo, freq);
@@ -598,7 +614,7 @@ int rig_fire_mode_event(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
ENTERFUNC;
rig_debug(RIG_DEBUG_TRACE, "Event: mode changed to %s, width %liHz on %s\n",
- rig_strrmode(mode), width, rig_strvfo(vfo));
+ rig_strrmode(mode), width, rig_strvfo(vfo));
rig_set_cache_mode(rig, vfo, mode, width);
@@ -637,7 +653,8 @@ int rig_fire_ptt_event(RIG *rig, vfo_t vfo, ptt_t ptt)
{
ENTERFUNC;
- rig_debug(RIG_DEBUG_TRACE, "Event: PTT changed to %i on %s\n", ptt, rig_strvfo(vfo));
+ rig_debug(RIG_DEBUG_TRACE, "Event: PTT changed to %i on %s\n", ptt,
+ rig_strvfo(vfo));
rig->state.cache.ptt = ptt;
elapsed_ms(&rig->state.cache.time_ptt, HAMLIB_ELAPSED_SET);
@@ -657,7 +674,8 @@ int rig_fire_dcd_event(RIG *rig, vfo_t vfo, dcd_t dcd)
{
ENTERFUNC;
- rig_debug(RIG_DEBUG_TRACE, "Event: DCD changed to %i on %s\n", dcd, rig_strvfo(vfo));
+ rig_debug(RIG_DEBUG_TRACE, "Event: DCD changed to %i on %s\n", dcd,
+ rig_strvfo(vfo));
network_publish_rig_transceive_data(rig);
@@ -670,11 +688,13 @@ int rig_fire_dcd_event(RIG *rig, vfo_t vfo, dcd_t dcd)
}
-int rig_fire_pltune_event(RIG *rig, vfo_t vfo, freq_t *freq, rmode_t *mode, pbwidth_t *width)
+int rig_fire_pltune_event(RIG *rig, vfo_t vfo, freq_t *freq, rmode_t *mode,
+ pbwidth_t *width)
{
ENTERFUNC;
- rig_debug(RIG_DEBUG_TRACE, "Event: Pipelined tuning event, vfo=%s\n", rig_strvfo(vfo));
+ rig_debug(RIG_DEBUG_TRACE, "Event: Pipelined tuning event, vfo=%s\n",
+ rig_strvfo(vfo));
network_publish_rig_transceive_data(rig);
@@ -688,7 +708,7 @@ int rig_fire_pltune_event(RIG *rig, vfo_t vfo, freq_t *freq, rmode_t *mode, pbwi
static int print_spectrum_line(char *str, size_t length,
- struct rig_spectrum_line *line)
+ struct rig_spectrum_line *line)
{
int data_level_max = line->data_level_max / 2;
int aggregate_count = line->spectrum_data_length / 120;
@@ -755,7 +775,7 @@ int rig_fire_spectrum_event(RIG *rig, struct rig_spectrum_line *line)
char spectrum_debug[line->spectrum_data_length * 4];
print_spectrum_line(spectrum_debug, sizeof(spectrum_debug), line);
rig_debug(RIG_DEBUG_TRACE, "%s: ASCII Spectrum Scope: %s\n", __func__,
- spectrum_debug);
+ spectrum_debug);
}
network_publish_rig_spectrum_data(rig, line);
diff --git a/src/iofunc.c b/src/iofunc.c
index f9c8ef02e..5b82f3f7b 100644
--- a/src/iofunc.c
+++ b/src/iofunc.c
@@ -83,23 +83,28 @@ static int create_sync_data_pipe(hamlib_port_t *p)
{
int status;
- status = async_pipe_create(&p->sync_data_pipe, PIPE_BUFFER_SIZE_DEFAULT, p->timeout);
+ status = async_pipe_create(&p->sync_data_pipe, PIPE_BUFFER_SIZE_DEFAULT,
+ p->timeout);
+
if (status < 0)
{
close_sync_data_pipe(p);
- return(-RIG_EINTERNAL);
+ return (-RIG_EINTERNAL);
}
- status = async_pipe_create(&p->sync_data_error_pipe, PIPE_BUFFER_SIZE_DEFAULT, p->timeout);
+ status = async_pipe_create(&p->sync_data_error_pipe, PIPE_BUFFER_SIZE_DEFAULT,
+ p->timeout);
+
if (status < 0)
{
close_sync_data_pipe(p);
- return(-RIG_EINTERNAL);
+ return (-RIG_EINTERNAL);
}
- rig_debug(RIG_DEBUG_VERBOSE, "%s: created data pipe for synchronous transactions\n", __func__);
+ rig_debug(RIG_DEBUG_VERBOSE,
+ "%s: created data pipe for synchronous transactions\n", __func__);
- return(RIG_OK);
+ return (RIG_OK);
}
#else
@@ -114,21 +119,27 @@ static void init_sync_data_pipe(hamlib_port_t *p)
static void close_sync_data_pipe(hamlib_port_t *p)
{
- if (p->fd_sync_read != -1) {
+ if (p->fd_sync_read != -1)
+ {
close(p->fd_sync_read);
p->fd_sync_read = -1;
}
- if (p->fd_sync_write != -1) {
+
+ if (p->fd_sync_write != -1)
+ {
close(p->fd_sync_write);
p->fd_sync_write = -1;
}
- if (p->fd_sync_error_read != -1) {
+ if (p->fd_sync_error_read != -1)
+ {
close(p->fd_sync_error_read);
p->fd_sync_error_read = -1;
}
- if (p->fd_sync_error_write != -1) {
+
+ if (p->fd_sync_error_write != -1)
+ {
close(p->fd_sync_error_write);
p->fd_sync_error_write = -1;
}
@@ -143,22 +154,29 @@ static int create_sync_data_pipe(hamlib_port_t *p)
status = pipe(sync_pipe_fds);
flags = fcntl(sync_pipe_fds[0], F_GETFL);
flags |= O_NONBLOCK;
+
if (fcntl(sync_pipe_fds[0], F_SETFL, flags))
{
- rig_debug(RIG_DEBUG_ERR, "%s: error setting O_NONBLOCK on sync_read=%s\n", __func__, strerror(errno));
+ rig_debug(RIG_DEBUG_ERR, "%s: error setting O_NONBLOCK on sync_read=%s\n",
+ __func__, strerror(errno));
}
+
flags = fcntl(sync_pipe_fds[1], F_GETFL);
flags |= O_NONBLOCK;
+
if (fcntl(sync_pipe_fds[1], F_SETFL, flags))
{
- rig_debug(RIG_DEBUG_ERR, "%s: error setting O_NONBLOCK on sync_write=%s\n", __func__, strerror(errno));
+ rig_debug(RIG_DEBUG_ERR, "%s: error setting O_NONBLOCK on sync_write=%s\n",
+ __func__, strerror(errno));
}
+
if (status != 0)
{
- rig_debug(RIG_DEBUG_ERR, "%s: synchronous data pipe open status=%d, err=%s\n", __func__,
- status, strerror(errno));
+ rig_debug(RIG_DEBUG_ERR, "%s: synchronous data pipe open status=%d, err=%s\n",
+ __func__,
+ status, strerror(errno));
close_sync_data_pipe(p);
- return(-RIG_EINTERNAL);
+ return (-RIG_EINTERNAL);
}
p->fd_sync_read = sync_pipe_fds[0];
@@ -167,30 +185,38 @@ static int create_sync_data_pipe(hamlib_port_t *p)
status = pipe(sync_pipe_fds);
flags = fcntl(sync_pipe_fds[0], F_GETFL);
flags |= O_NONBLOCK;
+
if (fcntl(sync_pipe_fds[0], F_SETFL, flags))
{
- rig_debug(RIG_DEBUG_ERR, "%s: error setting O_NONBLOCK on error_read=%s\n", __func__, strerror(errno));
+ rig_debug(RIG_DEBUG_ERR, "%s: error setting O_NONBLOCK on error_read=%s\n",
+ __func__, strerror(errno));
}
+
flags = fcntl(sync_pipe_fds[1], F_GETFL);
flags |= O_NONBLOCK;
+
if (fcntl(sync_pipe_fds[1], F_SETFL, flags))
{
- rig_debug(RIG_DEBUG_ERR, "%s: error setting O_NONBLOCK on error_write=%s\n", __func__, strerror(errno));
+ rig_debug(RIG_DEBUG_ERR, "%s: error setting O_NONBLOCK on error_write=%s\n",
+ __func__, strerror(errno));
}
+
if (status != 0)
{
- rig_debug(RIG_DEBUG_ERR, "%s: synchronous data error code pipe open status=%d, err=%s\n", __func__,
- status, strerror(errno));
+ rig_debug(RIG_DEBUG_ERR,
+ "%s: synchronous data error code pipe open status=%d, err=%s\n", __func__,
+ status, strerror(errno));
close_sync_data_pipe(p);
- return(-RIG_EINTERNAL);
+ return (-RIG_EINTERNAL);
}
p->fd_sync_error_read = sync_pipe_fds[0];
p->fd_sync_error_write = sync_pipe_fds[1];
- rig_debug(RIG_DEBUG_VERBOSE, "%s: created data pipe for synchronous transactions\n", __func__);
+ rig_debug(RIG_DEBUG_VERBOSE,
+ "%s: created data pipe for synchronous transactions\n", __func__);
- return(RIG_OK);
+ return (RIG_OK);
}
#endif
@@ -211,9 +237,10 @@ int HAMLIB_API port_open(hamlib_port_t *p)
if (p->asyncio)
{
status = create_sync_data_pipe(p);
+
if (status < 0)
{
- return(status);
+ return (status);
}
}
@@ -227,7 +254,7 @@ int HAMLIB_API port_open(hamlib_port_t *p)
rig_debug(RIG_DEBUG_ERR, "%s: serial_open(%s) status=%d, err=%s\n", __func__,
p->pathname, status, strerror(errno));
close_sync_data_pipe(p);
- return(status);
+ return (status);
}
if (p->parm.serial.rts_state != RIG_SIGNAL_UNSET
@@ -241,7 +268,7 @@ int HAMLIB_API port_open(hamlib_port_t *p)
if (status != 0)
{
close_sync_data_pipe(p);
- return(status);
+ return (status);
}
if (p->parm.serial.dtr_state != RIG_SIGNAL_UNSET)
@@ -255,7 +282,7 @@ int HAMLIB_API port_open(hamlib_port_t *p)
{
rig_debug(RIG_DEBUG_ERR, "%s: set_dtr status=%d\n", __func__, status);
close_sync_data_pipe(p);
- return(status);
+ return (status);
}
/*
@@ -275,7 +302,7 @@ int HAMLIB_API port_open(hamlib_port_t *p)
if (status < 0)
{
close_sync_data_pipe(p);
- return(status);
+ return (status);
}
break;
@@ -286,7 +313,7 @@ int HAMLIB_API port_open(hamlib_port_t *p)
if (status < 0)
{
close_sync_data_pipe(p);
- return(status);
+ return (status);
}
break;
@@ -297,7 +324,7 @@ int HAMLIB_API port_open(hamlib_port_t *p)
if (status < 0)
{
close_sync_data_pipe(p);
- return(-RIG_EIO);
+ return (-RIG_EIO);
}
p->fd = status;
@@ -311,7 +338,7 @@ int HAMLIB_API port_open(hamlib_port_t *p)
if (status < 0)
{
close_sync_data_pipe(p);
- return(status);
+ return (status);
}
break;
@@ -329,17 +356,17 @@ int HAMLIB_API port_open(hamlib_port_t *p)
if (status < 0)
{
close_sync_data_pipe(p);
- return(status);
+ return (status);
}
break;
default:
close_sync_data_pipe(p);
- return(-RIG_EINVAL);
+ return (-RIG_EINVAL);
}
- return(RIG_OK);
+ return (RIG_OK);
}
@@ -387,7 +414,7 @@ int HAMLIB_API port_close(hamlib_port_t *p, rig_port_t port_type)
close_sync_data_pipe(p);
- return(ret);
+ return (ret);
}
@@ -402,9 +429,11 @@ static int port_read_sync_data_error_code(hamlib_port_t *p)
signed char data;
int result;
- do {
+ do
+ {
// Wait for data using a zero-length read
result = async_pipe_read(p->sync_data_error_pipe, &data, 0, p->timeout);
+
if (result < 0)
{
if (result == -RIG_ETIMEOUT)
@@ -419,6 +448,7 @@ static int port_read_sync_data_error_code(hamlib_port_t *p)
}
result = async_pipe_read(p->sync_data_error_pipe, &data, 1, p->timeout);
+
if (result < 0)
{
if (result == -RIG_ETIMEOUT)
@@ -433,7 +463,8 @@ static int port_read_sync_data_error_code(hamlib_port_t *p)
}
total_bytes_read += result;
- } while (result > 0);
+ }
+ while (result > 0);
return data;
}
@@ -441,7 +472,8 @@ static int port_read_sync_data_error_code(hamlib_port_t *p)
static int port_read_sync_data(hamlib_port_t *p, void *buf, size_t count)
{
// Wait for data in both the response data pipe and the error code pipe to detect errors occurred during read
- HANDLE event_handles[2] = {
+ HANDLE event_handles[2] =
+ {
p->sync_data_pipe->read_overlapped.hEvent,
p->sync_data_error_pipe->read_overlapped.hEvent,
};
@@ -452,64 +484,76 @@ static int port_read_sync_data(hamlib_port_t *p, void *buf, size_t count)
ssize_t bytes_read;
result = ReadFile(p->sync_data_pipe->read, buf, count, NULL, overlapped);
+
if (!result)
{
result = GetLastError();
+
switch (result)
{
- case ERROR_SUCCESS:
- // No error?
- break;
- case ERROR_IO_PENDING:
- wait_result = WaitForMultipleObjects(2, event_handles, FALSE, p->timeout);
+ case ERROR_SUCCESS:
+ // No error?
+ break;
- switch (wait_result)
+ case ERROR_IO_PENDING:
+ wait_result = WaitForMultipleObjects(2, event_handles, FALSE, p->timeout);
+
+ switch (wait_result)
+ {
+ case WAIT_OBJECT_0 + 0:
+ break;
+
+ case WAIT_OBJECT_0 + 1:
+ return port_read_sync_data_error_code(p);
+
+ case WAIT_TIMEOUT:
+ if (count == 0)
{
- case WAIT_OBJECT_0 + 0:
- break;
-
- case WAIT_OBJECT_0 + 1:
- return port_read_sync_data_error_code(p);
-
- case WAIT_TIMEOUT:
- if (count == 0)
- {
- CancelIo(read_handle);
- return -RIG_ETIMEOUT;
- }
- else
- {
- // Should not happen
- return -RIG_EINTERNAL;
- }
-
- default:
- result = GetLastError();
- rig_debug(RIG_DEBUG_ERR, "%s(): WaitForMultipleObjects() error: %d\n", __func__, result);
- return -RIG_EINTERNAL;
+ CancelIo(read_handle);
+ return -RIG_ETIMEOUT;
}
- break;
+ else
+ {
+ // Should not happen
+ return -RIG_EINTERNAL;
+ }
+
default:
- rig_debug(RIG_DEBUG_ERR, "%s(): ReadFile() error: %d\n", __func__, result);
- return -RIG_EIO;
+ result = GetLastError();
+ rig_debug(RIG_DEBUG_ERR, "%s(): WaitForMultipleObjects() error: %d\n", __func__,
+ result);
+ return -RIG_EINTERNAL;
+ }
+
+ break;
+
+ default:
+ rig_debug(RIG_DEBUG_ERR, "%s(): ReadFile() error: %d\n", __func__, result);
+ return -RIG_EIO;
}
}
- result = GetOverlappedResult(read_handle, overlapped, (LPDWORD) &bytes_read, FALSE);
+ result = GetOverlappedResult(read_handle, overlapped, (LPDWORD) &bytes_read,
+ FALSE);
+
if (!result)
{
result = GetLastError();
+
switch (result)
{
- case ERROR_SUCCESS:
- // No error?
- break;
- case ERROR_IO_PENDING:
- // Shouldn't happen?
- return -RIG_ETIMEOUT;
- default:
- rig_debug(RIG_DEBUG_ERR, "%s(): GetOverlappedResult() error: %d\n", __func__, result);
- return -RIG_EIO;
+ case ERROR_SUCCESS:
+ // No error?
+ break;
+
+ case ERROR_IO_PENDING:
+ // Shouldn't happen?
+ return -RIG_ETIMEOUT;
+
+ default:
+ rig_debug(RIG_DEBUG_ERR, "%s(): GetOverlappedResult() error: %d\n", __func__,
+ result);
+ return -RIG_EIO;
}
}
@@ -532,7 +576,8 @@ static int port_wait_for_data_sync_pipe(hamlib_port_t *p)
return result;
}
-static ssize_t port_read_sync_data_pipe(hamlib_port_t *p, void *buf, size_t count)
+static ssize_t port_read_sync_data_pipe(hamlib_port_t *p, void *buf,
+ size_t count)
{
return port_read_sync_data(p, buf, count);
}
@@ -540,7 +585,8 @@ static ssize_t port_read_sync_data_pipe(hamlib_port_t *p, void *buf, size_t coun
/* On MinGW32/MSVC/.. the appropriate accessor must be used
* depending on the port type, sigh.
*/
-static ssize_t port_read_generic(hamlib_port_t *p, void *buf, size_t count, int direct)
+static ssize_t port_read_generic(hamlib_port_t *p, void *buf, size_t count,
+ int direct)
{
int fd = p->fd;
int i;
@@ -690,9 +736,9 @@ static int port_wait_for_data_direct(hamlib_port_t *p)
else if (result < 0)
{
rig_debug(RIG_DEBUG_ERR,
- "%s(): select() error: %s\n",
- __func__,
- strerror(errno));
+ "%s(): select() error: %s\n",
+ __func__,
+ strerror(errno));
return -RIG_EIO;
}
@@ -711,15 +757,18 @@ static int port_wait_for_data(hamlib_port_t *p, int direct)
{
return port_wait_for_data_direct(p);
}
+
return port_wait_for_data_sync_pipe(p);
}
-int HAMLIB_API write_block_sync(hamlib_port_t *p, const unsigned char *txbuffer, size_t count)
+int HAMLIB_API write_block_sync(hamlib_port_t *p, const unsigned char *txbuffer,
+ size_t count)
{
return async_pipe_write(p->sync_data_pipe, txbuffer, count, p->timeout);
}
-int HAMLIB_API write_block_sync_error(hamlib_port_t *p, const unsigned char *txbuffer, size_t count)
+int HAMLIB_API write_block_sync_error(hamlib_port_t *p,
+ const unsigned char *txbuffer, size_t count)
{
return async_pipe_write(p->sync_data_error_pipe, txbuffer, count, p->timeout);
}
@@ -728,7 +777,8 @@ int HAMLIB_API write_block_sync_error(hamlib_port_t *p, const unsigned char *txb
/* POSIX */
-static ssize_t port_read_generic(hamlib_port_t *p, void *buf, size_t count, int direct)
+static ssize_t port_read_generic(hamlib_port_t *p, void *buf, size_t count,
+ int direct)
{
int fd = direct ? p->fd : p->fd_sync_read;
@@ -768,7 +818,8 @@ static int port_read_sync_data_error_code(hamlib_port_t *p, int fd, int direct)
int result;
signed char data;
- do {
+ do
+ {
tv_timeout.tv_sec = 0;
tv_timeout.tv_usec = 0;
@@ -777,15 +828,20 @@ static int port_read_sync_data_error_code(hamlib_port_t *p, int fd, int direct)
efds = rfds;
result = port_select(p, fd + 1, &rfds, NULL, &efds, &tv_timeout, direct);
+
if (result < 0)
{
- rig_debug(RIG_DEBUG_VERBOSE, "%s(): select() timeout, direct=%d\n", __func__, direct);
+ rig_debug(RIG_DEBUG_VERBOSE, "%s(): select() timeout, direct=%d\n", __func__,
+ direct);
return -RIG_ETIMEOUT;
}
+
if (result == 0)
{
- if (total_bytes_read > 0) {
- rig_debug(RIG_DEBUG_VERBOSE, "%s(): returning error code %d, direct=%d\n", __func__, (int) data, direct);
+ if (total_bytes_read > 0)
+ {
+ rig_debug(RIG_DEBUG_VERBOSE, "%s(): returning error code %d, direct=%d\n",
+ __func__, (int) data, direct);
return data;
}
@@ -801,7 +857,8 @@ static int port_read_sync_data_error_code(hamlib_port_t *p, int fd, int direct)
bytes_read = read(fd, &data, 1);
total_bytes_read += bytes_read;
- } while (bytes_read > 0);
+ }
+ while (bytes_read > 0);
rig_debug(RIG_DEBUG_VERBOSE, "%s(): returning error code %d\n", __func__, data);
@@ -826,10 +883,12 @@ static int port_wait_for_data(hamlib_port_t *p, int direct)
FD_ZERO(&rfds);
FD_SET(fd, &rfds);
+
if (!direct)
{
FD_SET(errorfd, &rfds);
}
+
efds = rfds;
result = port_select(p, maxfd + 1, &rfds, NULL, &efds, &tv, direct);
@@ -841,10 +900,10 @@ static int port_wait_for_data(hamlib_port_t *p, int direct)
else if (result < 0)
{
rig_debug(RIG_DEBUG_ERR,
- "%s(): select() error, direct=%d: %s\n",
- __func__,
- direct,
- strerror(errno));
+ "%s(): select() error, direct=%d: %s\n",
+ __func__,
+ direct,
+ strerror(errno));
return -RIG_EIO;
}
@@ -853,17 +912,20 @@ static int port_wait_for_data(hamlib_port_t *p, int direct)
rig_debug(RIG_DEBUG_ERR, "%s(): fd error, direct=%d\n", __func__, direct);
return -RIG_EIO;
}
+
if (!direct)
{
if (FD_ISSET(errorfd, &efds))
{
- rig_debug(RIG_DEBUG_ERR, "%s(): fd error from sync error pipe, direct=%d\n", __func__, direct);
+ rig_debug(RIG_DEBUG_ERR, "%s(): fd error from sync error pipe, direct=%d\n",
+ __func__, direct);
return -RIG_EIO;
}
if (FD_ISSET(errorfd, &rfds))
{
- rig_debug(RIG_DEBUG_VERBOSE, "%s(): attempting to read error code, direct=%d\n", __func__, direct);
+ rig_debug(RIG_DEBUG_VERBOSE, "%s(): attempting to read error code, direct=%d\n",
+ __func__, direct);
return port_read_sync_data_error_code(p, errorfd, 0);
}
}
@@ -871,7 +933,8 @@ static int port_wait_for_data(hamlib_port_t *p, int direct)
return RIG_OK;
}
-int HAMLIB_API write_block_sync(hamlib_port_t *p, const unsigned char *txbuffer, size_t count)
+int HAMLIB_API write_block_sync(hamlib_port_t *p, const unsigned char *txbuffer,
+ size_t count)
{
if (!p->asyncio)
@@ -882,7 +945,8 @@ int HAMLIB_API write_block_sync(hamlib_port_t *p, const unsigned char *txbuffer,
return (int) write(p->fd_sync_write, txbuffer, count);
}
-int HAMLIB_API write_block_sync_error(hamlib_port_t *p, const unsigned char *txbuffer, size_t count)
+int HAMLIB_API write_block_sync_error(hamlib_port_t *p,
+ const unsigned char *txbuffer, size_t count)
{
if (!p->asyncio)
{
@@ -923,16 +987,18 @@ int HAMLIB_API write_block_sync_error(hamlib_port_t *p, const unsigned char *txb
* it could work very well also with any file handle, like a socket.
*/
-int HAMLIB_API write_block(hamlib_port_t *p, const unsigned char *txbuffer, size_t count)
+int HAMLIB_API write_block(hamlib_port_t *p, const unsigned char *txbuffer,
+ size_t count)
{
int ret;
- int method=0;
+ int method = 0;
if (p->fd < 0)
{
rig_debug(RIG_DEBUG_ERR, "%s: port not open\n", __func__);
- return(-RIG_EIO);
+ return (-RIG_EIO);
}
+
#ifdef WANT_NON_ACTIVE_POST_WRITE_DELAY
if (p->post_write_date.tv_sec != 0)
@@ -1001,7 +1067,8 @@ int HAMLIB_API write_block(hamlib_port_t *p, const unsigned char *txbuffer, size
}
}
- rig_debug(RIG_DEBUG_TRACE, "%s(): TX %d bytes, method=%d\n", __func__, (int)count, method);
+ rig_debug(RIG_DEBUG_TRACE, "%s(): TX %d bytes, method=%d\n", __func__,
+ (int)count, method);
dump_hex((unsigned char *) txbuffer, count);
if (p->post_write_delay > 0)
@@ -1028,7 +1095,8 @@ int HAMLIB_API write_block(hamlib_port_t *p, const unsigned char *txbuffer, size
return RIG_OK;
}
-static int read_block_generic(hamlib_port_t *p, unsigned char *rxbuffer, size_t count, int direct)
+static int read_block_generic(hamlib_port_t *p, unsigned char *rxbuffer,
+ size_t count, int direct)
{
struct timeval start_time, end_time, elapsed_time;
int total_count = 0;
@@ -1078,7 +1146,9 @@ static int read_block_generic(hamlib_port_t *p, unsigned char *rxbuffer, size_t
{
dump_hex((unsigned char *) rxbuffer, total_count);
}
- rig_debug(RIG_DEBUG_ERR, "%s(): I/O error after %d chars, direct=%d: %d\n", __func__, total_count, direct, result);
+
+ rig_debug(RIG_DEBUG_ERR, "%s(): I/O error after %d chars, direct=%d: %d\n",
+ __func__, total_count, direct, result);
return result;
}
@@ -1090,7 +1160,8 @@ static int read_block_generic(hamlib_port_t *p, unsigned char *rxbuffer, size_t
if (rd_count < 0)
{
- rig_debug(RIG_DEBUG_ERR, "%s(): read failed, direct=%d - %s\n", __func__, direct, strerror(errno));
+ rig_debug(RIG_DEBUG_ERR, "%s(): read failed, direct=%d - %s\n", __func__,
+ direct, strerror(errno));
return -RIG_EIO;
}
@@ -1100,7 +1171,8 @@ static int read_block_generic(hamlib_port_t *p, unsigned char *rxbuffer, size_t
if (direct)
{
- rig_debug(RIG_DEBUG_TRACE, "%s(): RX %d bytes, direct=%d\n", __func__, total_count, direct);
+ rig_debug(RIG_DEBUG_TRACE, "%s(): RX %d bytes, direct=%d\n", __func__,
+ total_count, direct);
dump_hex((unsigned char *) rxbuffer, total_count);
}
@@ -1126,7 +1198,8 @@ static int read_block_generic(hamlib_port_t *p, unsigned char *rxbuffer, size_t
* it could work very well also with any file handle, like a socket.
*/
-int HAMLIB_API read_block(hamlib_port_t *p, unsigned char *rxbuffer, size_t count)
+int HAMLIB_API read_block(hamlib_port_t *p, unsigned char *rxbuffer,
+ size_t count)
{
return read_block_generic(p, rxbuffer, count, !p->asyncio);
}
@@ -1149,7 +1222,8 @@ int HAMLIB_API read_block(hamlib_port_t *p, unsigned char *rxbuffer, size_t coun
* it could work very well also with any file handle, like a socket.
*/
-int HAMLIB_API read_block_direct(hamlib_port_t *p, unsigned char *rxbuffer, size_t count)
+int HAMLIB_API read_block_direct(hamlib_port_t *p, unsigned char *rxbuffer,
+ size_t count)
{
return read_block_generic(p, rxbuffer, count, 1);
}
@@ -1173,7 +1247,8 @@ static int read_string_generic(hamlib_port_t *p,
return -RIG_EINTERNAL;
}
- rig_debug(RIG_DEBUG_TRACE, "%s called, rxmax=%d direct=%d\n", __func__, (int)rxmax, direct);
+ rig_debug(RIG_DEBUG_TRACE, "%s called, rxmax=%d direct=%d\n", __func__,
+ (int)rxmax, direct);
if (!p || !rxbuffer)
{
@@ -1213,15 +1288,16 @@ static int read_string_generic(hamlib_port_t *p,
{
dump_hex((unsigned char *) rxbuffer, total_count);
}
+
if (!flush_flag)
{
rig_debug(RIG_DEBUG_WARN,
- "%s(): Timed out %d.%03d seconds after %d chars, direct=%d\n",
- __func__,
- (int)elapsed_time.tv_sec,
- (int)elapsed_time.tv_usec / 1000,
- total_count,
- direct);
+ "%s(): Timed out %d.%03d seconds after %d chars, direct=%d\n",
+ __func__,
+ (int)elapsed_time.tv_sec,
+ (int)elapsed_time.tv_usec / 1000,
+ total_count,
+ direct);
}
return -RIG_ETIMEOUT;
@@ -1236,7 +1312,9 @@ static int read_string_generic(hamlib_port_t *p,
{
dump_hex(rxbuffer, total_count);
}
- rig_debug(RIG_DEBUG_ERR, "%s(): I/O error after %d chars, direct=%d: %d\n", __func__, total_count, direct, result);
+
+ rig_debug(RIG_DEBUG_ERR, "%s(): I/O error after %d chars, direct=%d: %d\n",
+ __func__, total_count, direct, result);
return result;
}
@@ -1246,12 +1324,15 @@ static int read_string_generic(hamlib_port_t *p,
*/
do
{
- rd_count = port_read_generic(p, &rxbuffer[total_count], expected_len == 1 ? 1 : minlen, direct);
+ rd_count = port_read_generic(p, &rxbuffer[total_count],
+ expected_len == 1 ? 1 : minlen, direct);
minlen -= rd_count;
+
if (errno == EAGAIN)
{
hl_usleep(5 * 1000);
- rig_debug(RIG_DEBUG_WARN, "%s: port_read is busy? direct=%d\n", __func__, direct);
+ rig_debug(RIG_DEBUG_WARN, "%s: port_read is busy? direct=%d\n", __func__,
+ direct);
}
}
while (++i < 10 && errno == EBUSY); // 50ms should be enough
@@ -1263,7 +1344,9 @@ static int read_string_generic(hamlib_port_t *p,
{
dump_hex((unsigned char *) rxbuffer, total_count);
}
- rig_debug(RIG_DEBUG_ERR, "%s(): read failed, direct=%d - %s\n", __func__, direct, strerror(errno));
+
+ rig_debug(RIG_DEBUG_ERR, "%s(): read failed, direct=%d - %s\n", __func__,
+ direct, strerror(errno));
return -RIG_EIO;
}
@@ -1296,10 +1379,10 @@ static int read_string_generic(hamlib_port_t *p,
if (direct)
{
rig_debug(RIG_DEBUG_TRACE,
- "%s(): RX %d characters, direct=%d\n",
- __func__,
- total_count,
- direct);
+ "%s(): RX %d characters, direct=%d\n",
+ __func__,
+ total_count,
+ direct);
dump_hex((unsigned char *) rxbuffer, total_count);
}
@@ -1333,14 +1416,15 @@ static int read_string_generic(hamlib_port_t *p,
*/
int HAMLIB_API read_string(hamlib_port_t *p,
- unsigned char *rxbuffer,
- size_t rxmax,
- const char *stopset,
- int stopset_len,
- int flush_flag,
- int expected_len)
+ unsigned char *rxbuffer,
+ size_t rxmax,
+ const char *stopset,
+ int stopset_len,
+ int flush_flag,
+ int expected_len)
{
- return read_string_generic(p, rxbuffer, rxmax, stopset, stopset_len, flush_flag, expected_len, !p->asyncio);
+ return read_string_generic(p, rxbuffer, rxmax, stopset, stopset_len, flush_flag,
+ expected_len, !p->asyncio);
}
@@ -1378,7 +1462,8 @@ int HAMLIB_API read_string_direct(hamlib_port_t *p,
int flush_flag,
int expected_len)
{
- return read_string_generic(p, rxbuffer, rxmax, stopset, stopset_len, flush_flag, expected_len, 1);
+ return read_string_generic(p, rxbuffer, rxmax, stopset, stopset_len, flush_flag,
+ expected_len, 1);
}
/** @} */
diff --git a/src/mem.c b/src/mem.c
index 362417f5c..4ffca47e9 100644
--- a/src/mem.c
+++ b/src/mem.c
@@ -1179,7 +1179,7 @@ int HAMLIB_API rig_set_chan_all(RIG *rig, vfo_t vfo, const channel_t chans[])
}
rc = rig->caps;
- memset(&map_arg,0,sizeof(map_arg));
+ memset(&map_arg, 0, sizeof(map_arg));
map_arg.chans = (channel_t *) chans;
if (rc->set_chan_all_cb)
@@ -1222,7 +1222,7 @@ int HAMLIB_API rig_get_chan_all(RIG *rig, vfo_t vfo, channel_t chans[])
}
rc = rig->caps;
- memset(&map_arg,0,sizeof(map_arg));
+ memset(&map_arg, 0, sizeof(map_arg));
map_arg.chans = chans;
if (rc->get_chan_all_cb)
diff --git a/src/misc.c b/src/misc.c
index dc3a4842b..9d438f3f7 100644
--- a/src/misc.c
+++ b/src/misc.c
@@ -313,7 +313,7 @@ size_t HAMLIB_API to_hex(size_t source_length, const unsigned char *source_data,
for (i = 0; i < length; i++)
{
- SNPRINTF(dest, dest_length - 2*i, "%02X", source[0]);
+ SNPRINTF(dest, dest_length - 2 * i, "%02X", source[0]);
source++;
dest += 2;
}
@@ -1867,7 +1867,8 @@ vfo_t HAMLIB_API vfo_fixup(RIG *rig, vfo_t vfo, split_t split)
__func__, funcname, linenum,
rig_strvfo(vfo), rig_strvfo(rig->state.current_vfo), split);
- if (vfo == RIG_VFO_NONE) vfo = RIG_VFO_A;
+ if (vfo == RIG_VFO_NONE) { vfo = RIG_VFO_A; }
+
if (vfo == RIG_VFO_CURR || vfo == RIG_VFO_VFO)
{
rig_debug(RIG_DEBUG_TRACE, "%s: Leaving currVFO alone\n", __func__);
@@ -1962,7 +1963,8 @@ vfo_t HAMLIB_API vfo_fixup(RIG *rig, vfo_t vfo, split_t split)
return vfo;
}
-int HAMLIB_API parse_hoststr(char *hoststr, int hoststr_len, char host[256], char port[6])
+int HAMLIB_API parse_hoststr(char *hoststr, int hoststr_len, char host[256],
+ char port[6])
{
unsigned int net1, net2, net3, net4, net5, net6, net7, net8;
char dummy[6], link[32], *p;
@@ -2467,7 +2469,7 @@ long long HAMLIB_API rig_get_caps_int(rig_model_t rig_model,
default:
//rig_debug(RIG_DEBUG_ERR, "%s: Unknown rig_caps value=%lld\n", __func__, rig_caps);
- return(-RIG_EINVAL);
+ return (-RIG_EINVAL);
}
}
diff --git a/src/network.c b/src/network.c
index af62f4bdc..712048189 100644
--- a/src/network.c
+++ b/src/network.c
@@ -179,7 +179,7 @@ int network_init()
{
rig_debug(RIG_DEBUG_ERR, "%s: error creating socket, WSAStartup ret=%d\n",
__func__, ret);
- return(-RIG_EIO);
+ return (-RIG_EIO);
}
}
@@ -209,13 +209,13 @@ int network_open(hamlib_port_t *rp, int default_port)
#ifdef __MINGW32__
status = network_init();
- if (status != RIG_OK) { return(status); }
+ if (status != RIG_OK) { return (status); }
#endif
if (!rp)
{
- return(-RIG_EINVAL);
+ return (-RIG_EINVAL);
}
memset(&hints, 0, sizeof(hints));
@@ -241,7 +241,7 @@ int network_open(hamlib_port_t *rp, int default_port)
{
status = parse_hoststr(rp->pathname, sizeof(rp->pathname), hoststr, portstr);
- if (status != RIG_OK) { return(status); }
+ if (status != RIG_OK) { return (status); }
rig_debug(RIG_DEBUG_TRACE, "%s: hoststr=%s, portstr=%s\n", __func__, hoststr,
portstr);
@@ -287,7 +287,7 @@ int network_open(hamlib_port_t *rp, int default_port)
__func__,
rp->pathname,
gai_strerror(status));
- return(-RIG_ECONF);
+ return (-RIG_ECONF);
}
saved_res = res;
@@ -306,7 +306,7 @@ int network_open(hamlib_port_t *rp, int default_port)
{
handle_error(RIG_DEBUG_ERR, "socket");
freeaddrinfo(saved_res);
- return(-RIG_EIO);
+ return (-RIG_EIO);
}
if (connect(fd, res->ai_addr, res->ai_addrlen) == 0)
@@ -334,7 +334,7 @@ int network_open(hamlib_port_t *rp, int default_port)
"%s: failed to connect to %s\n",
__func__,
rp->pathname);
- return(-RIG_EIO);
+ return (-RIG_EIO);
}
rp->fd = fd;
@@ -344,7 +344,7 @@ int network_open(hamlib_port_t *rp, int default_port)
rig_debug(RIG_DEBUG_TRACE, "%s: client port=%d\n", __func__, client.sin_port);
rp->client_port = client.sin_port;
- return(RIG_OK);
+ return (RIG_OK);
}
@@ -437,7 +437,7 @@ int network_close(hamlib_port_t *rp)
}
#endif
- return(ret);
+ return (ret);
}
//! @endcond
@@ -450,146 +450,186 @@ extern void sync_callback(int lock);
#if defined(WIN32) && defined(HAVE_WINDOWS_H)
-static int multicast_publisher_create_data_pipe(multicast_publisher_priv_data *mcast_publisher_priv)
+static int multicast_publisher_create_data_pipe(multicast_publisher_priv_data
+ *mcast_publisher_priv)
{
int status;
- status = async_pipe_create(&mcast_publisher_priv->args.data_pipe, PIPE_BUFFER_SIZE_DEFAULT, MULTICAST_DATA_PIPE_TIMEOUT_MILLIS);
+ status = async_pipe_create(&mcast_publisher_priv->args.data_pipe,
+ PIPE_BUFFER_SIZE_DEFAULT, MULTICAST_DATA_PIPE_TIMEOUT_MILLIS);
+
if (status != 0)
{
- rig_debug(RIG_DEBUG_ERR, "%s: multicast publisher data pipe creation failed with status=%d, err=%s\n", __func__,
- status, strerror(errno));
- return(-RIG_EINTERNAL);
+ rig_debug(RIG_DEBUG_ERR,
+ "%s: multicast publisher data pipe creation failed with status=%d, err=%s\n",
+ __func__,
+ status, strerror(errno));
+ return (-RIG_EINTERNAL);
}
- return(RIG_OK);
+ return (RIG_OK);
}
-static void multicast_publisher_close_data_pipe(multicast_publisher_priv_data *mcast_publisher_priv)
+static void multicast_publisher_close_data_pipe(multicast_publisher_priv_data
+ *mcast_publisher_priv)
{
- if (mcast_publisher_priv->args.data_pipe != NULL) {
+ if (mcast_publisher_priv->args.data_pipe != NULL)
+ {
async_pipe_close(mcast_publisher_priv->args.data_pipe);
mcast_publisher_priv->args.data_pipe = NULL;
}
}
-static int multicast_publisher_write_data(multicast_publisher_args *mcast_publisher_args, size_t length, const unsigned char *data)
+static int multicast_publisher_write_data(multicast_publisher_args
+ *mcast_publisher_args, size_t length, const unsigned char *data)
{
ssize_t result;
- result = async_pipe_write(mcast_publisher_args->data_pipe, data, length, MULTICAST_DATA_PIPE_TIMEOUT_MILLIS);
+ result = async_pipe_write(mcast_publisher_args->data_pipe, data, length,
+ MULTICAST_DATA_PIPE_TIMEOUT_MILLIS);
+
if (result < 0)
{
- rig_debug(RIG_DEBUG_ERR, "%s: error writing to multicast publisher data pipe, result=%d\n", __func__, (int)result);
- return(-RIG_EIO);
+ rig_debug(RIG_DEBUG_ERR,
+ "%s: error writing to multicast publisher data pipe, result=%d\n", __func__,
+ (int)result);
+ return (-RIG_EIO);
}
if (result != length)
{
- rig_debug(RIG_DEBUG_ERR, "%s: could not write to multicast publisher data pipe, expected %d bytes, wrote %d bytes\n",
- __func__, (int)length, (int)result);
- return(-RIG_EIO);
+ rig_debug(RIG_DEBUG_ERR,
+ "%s: could not write to multicast publisher data pipe, expected %d bytes, wrote %d bytes\n",
+ __func__, (int)length, (int)result);
+ return (-RIG_EIO);
}
- return(RIG_OK);
+ return (RIG_OK);
}
-static int multicast_publisher_read_data(multicast_publisher_args *mcast_publisher_args, size_t length, unsigned char *data)
+static int multicast_publisher_read_data(multicast_publisher_args
+ *mcast_publisher_args, size_t length, unsigned char *data)
{
ssize_t result;
- result = async_pipe_wait_for_data(mcast_publisher_args->data_pipe, MULTICAST_DATA_PIPE_TIMEOUT_MILLIS);
+ result = async_pipe_wait_for_data(mcast_publisher_args->data_pipe,
+ MULTICAST_DATA_PIPE_TIMEOUT_MILLIS);
+
if (result < 0)
{
// Timeout is expected when there is no data
if (result != -RIG_ETIMEOUT)
{
- rig_debug(RIG_DEBUG_ERR, "%s: error waiting for multicast publisher data, result=%ld\n", __func__, (long) result);
+ rig_debug(RIG_DEBUG_ERR,
+ "%s: error waiting for multicast publisher data, result=%ld\n", __func__,
+ (long) result);
}
- return(result);
+
+ return (result);
}
- result = async_pipe_read(mcast_publisher_args->data_pipe, data, length, MULTICAST_DATA_PIPE_TIMEOUT_MILLIS);
+ result = async_pipe_read(mcast_publisher_args->data_pipe, data, length,
+ MULTICAST_DATA_PIPE_TIMEOUT_MILLIS);
+
if (result < 0)
{
- rig_debug(RIG_DEBUG_ERR, "%s: error reading multicast publisher data, result=%ld\n", __func__, (long) result);
- return(-RIG_EIO);
+ rig_debug(RIG_DEBUG_ERR,
+ "%s: error reading multicast publisher data, result=%ld\n", __func__,
+ (long) result);
+ return (-RIG_EIO);
}
if (result != length)
{
- rig_debug(RIG_DEBUG_ERR, "%s: could not read from multicast publisher data pipe, expected %ld bytes, read %ld bytes\n",
- __func__, (long) length, (long) result);
- return(-RIG_EIO);
+ rig_debug(RIG_DEBUG_ERR,
+ "%s: could not read from multicast publisher data pipe, expected %ld bytes, read %ld bytes\n",
+ __func__, (long) length, (long) result);
+ return (-RIG_EIO);
}
- return(RIG_OK);
+ return (RIG_OK);
}
#else
-static int multicast_publisher_create_data_pipe(multicast_publisher_priv_data *mcast_publisher_priv)
+static int multicast_publisher_create_data_pipe(multicast_publisher_priv_data
+ *mcast_publisher_priv)
{
int data_pipe_fds[2];
int status;
status = pipe(data_pipe_fds);
+
if (status != 0)
{
- rig_debug(RIG_DEBUG_ERR, "%s: multicast publisher data pipe creation failed with status=%d, err=%s\n", __func__,
- status, strerror(errno));
- return(-RIG_EINTERNAL);
+ rig_debug(RIG_DEBUG_ERR,
+ "%s: multicast publisher data pipe creation failed with status=%d, err=%s\n",
+ __func__,
+ status, strerror(errno));
+ return (-RIG_EINTERNAL);
}
int flags = fcntl(data_pipe_fds[0], F_GETFD);
flags |= O_NONBLOCK;
+
if (fcntl(data_pipe_fds[0], F_SETFD, flags))
{
- rig_debug(RIG_DEBUG_ERR, "%s: error setting O_NONBLOCK on pipe=%s\n", __func__, strerror(errno));
+ rig_debug(RIG_DEBUG_ERR, "%s: error setting O_NONBLOCK on pipe=%s\n", __func__,
+ strerror(errno));
}
mcast_publisher_priv->args.data_read_fd = data_pipe_fds[0];
mcast_publisher_priv->args.data_write_fd = data_pipe_fds[1];
- return(RIG_OK);
+ return (RIG_OK);
}
-static void multicast_publisher_close_data_pipe(multicast_publisher_priv_data *mcast_publisher_priv)
+static void multicast_publisher_close_data_pipe(multicast_publisher_priv_data
+ *mcast_publisher_priv)
{
- if (mcast_publisher_priv->args.data_read_fd != -1) {
+ if (mcast_publisher_priv->args.data_read_fd != -1)
+ {
close(mcast_publisher_priv->args.data_read_fd);
mcast_publisher_priv->args.data_read_fd = -1;
}
- if (mcast_publisher_priv->args.data_write_fd != -1) {
+
+ if (mcast_publisher_priv->args.data_write_fd != -1)
+ {
close(mcast_publisher_priv->args.data_write_fd);
mcast_publisher_priv->args.data_write_fd = -1;
}
}
-static int multicast_publisher_write_data(multicast_publisher_args *mcast_publisher_args, size_t length, const unsigned char *data)
+static int multicast_publisher_write_data(multicast_publisher_args
+ *mcast_publisher_args, size_t length, const unsigned char *data)
{
int fd = mcast_publisher_args->data_write_fd;
ssize_t result;
result = write(fd, data, length);
+
if (result < 0)
{
- rig_debug(RIG_DEBUG_ERR, "%s: error writing to multicast publisher data pipe, result=%d, err=%s\n", __func__,
- (int)result, strerror(errno));
- return(-RIG_EIO);
+ rig_debug(RIG_DEBUG_ERR,
+ "%s: error writing to multicast publisher data pipe, result=%d, err=%s\n",
+ __func__,
+ (int)result, strerror(errno));
+ return (-RIG_EIO);
}
if (result != length)
{
- rig_debug(RIG_DEBUG_ERR, "%s: could not write to multicast publisher data pipe, expected %ld bytes, wrote %ld bytes\n",
- __func__, (long) length, (long) result);
- return(-RIG_EIO);
+ rig_debug(RIG_DEBUG_ERR,
+ "%s: could not write to multicast publisher data pipe, expected %ld bytes, wrote %ld bytes\n",
+ __func__, (long) length, (long) result);
+ return (-RIG_EIO);
}
- return(RIG_OK);
+ return (RIG_OK);
}
-static int multicast_publisher_read_data(multicast_publisher_args *mcast_publisher_args, size_t length, unsigned char *data)
+static int multicast_publisher_read_data(multicast_publisher_args
+ *mcast_publisher_args, size_t length, unsigned char *data)
{
int fd = mcast_publisher_args->data_read_fd;
fd_set rfds, efds;
@@ -605,52 +645,58 @@ static int multicast_publisher_read_data(multicast_publisher_args *mcast_publish
efds = rfds;
retval = select(fd + 1, &rfds, NULL, &efds, &timeout);
+
if (retval == 0)
{
- return(-RIG_ETIMEOUT);
+ return (-RIG_ETIMEOUT);
}
if (retval < 0)
{
rig_debug(RIG_DEBUG_ERR,
- "%s(): select() failed when reading multicast publisher data: %s\n",
- __func__,
- strerror(errno));
+ "%s(): select() failed when reading multicast publisher data: %s\n",
+ __func__,
+ strerror(errno));
return -RIG_EIO;
}
if (FD_ISSET(fd, &efds))
{
- rig_debug(RIG_DEBUG_ERR, "%s(): fd error when reading multicast publisher data\n", __func__);
+ rig_debug(RIG_DEBUG_ERR,
+ "%s(): fd error when reading multicast publisher data\n", __func__);
return -RIG_EIO;
}
result = read(fd, data, length);
+
if (result < 0)
{
if (errno == EAGAIN)
{
- return(-RIG_ETIMEOUT);
+ return (-RIG_ETIMEOUT);
}
- rig_debug(RIG_DEBUG_ERR, "%s: error reading multicast publisher data: %s\n", __func__, strerror(errno));
- return(-RIG_EIO);
+ rig_debug(RIG_DEBUG_ERR, "%s: error reading multicast publisher data: %s\n",
+ __func__, strerror(errno));
+ return (-RIG_EIO);
}
if (result != length)
{
- rig_debug(RIG_DEBUG_ERR, "%s: could not read from multicast publisher data pipe, expected %ld bytes, read %ld bytes\n",
- __func__, (long) length, (long) result);
- return(-RIG_EIO);
+ rig_debug(RIG_DEBUG_ERR,
+ "%s: could not read from multicast publisher data pipe, expected %ld bytes, read %ld bytes\n",
+ __func__, (long) length, (long) result);
+ return (-RIG_EIO);
}
- return(RIG_OK);
+ return (RIG_OK);
}
#endif
-static int multicast_publisher_write_packet_header(RIG *rig, multicast_publisher_data_packet *packet)
+static int multicast_publisher_write_packet_header(RIG *rig,
+ multicast_publisher_data_packet *packet)
{
struct rig_state *rs = &rig->state;
multicast_publisher_priv_data *mcast_publisher_priv;
@@ -663,11 +709,14 @@ static int multicast_publisher_write_packet_header(RIG *rig, multicast_publisher
RETURNFUNC(RIG_OK);
}
- mcast_publisher_priv = (multicast_publisher_priv_data *) rs->multicast_publisher_priv_data;
+ mcast_publisher_priv = (multicast_publisher_priv_data *)
+ rs->multicast_publisher_priv_data;
mcast_publisher_args = &mcast_publisher_priv->args;
result = multicast_publisher_write_data(
- mcast_publisher_args, sizeof(multicast_publisher_data_packet), (unsigned char *) packet);
+ mcast_publisher_args, sizeof(multicast_publisher_data_packet),
+ (unsigned char *) packet);
+
if (result != RIG_OK)
{
RETURNFUNC(result);
@@ -679,7 +728,8 @@ static int multicast_publisher_write_packet_header(RIG *rig, multicast_publisher
int network_publish_rig_poll_data(RIG *rig)
{
struct rig_state *rs = &rig->state;
- multicast_publisher_data_packet packet = {
+ multicast_publisher_data_packet packet =
+ {
.type = MULTICAST_PUBLISHER_DATA_PACKET_TYPE_POLL,
.padding = 0,
.data_length = 0,
@@ -697,10 +747,11 @@ int network_publish_rig_poll_data(RIG *rig)
int network_publish_rig_transceive_data(RIG *rig)
{
struct rig_state *rs = &rig->state;
- multicast_publisher_data_packet packet = {
- .type = MULTICAST_PUBLISHER_DATA_PACKET_TYPE_TRANSCEIVE,
- .padding = 0,
- .data_length = 0,
+ multicast_publisher_data_packet packet =
+ {
+ .type = MULTICAST_PUBLISHER_DATA_PACKET_TYPE_TRANSCEIVE,
+ .padding = 0,
+ .data_length = 0,
};
if (rs->multicast_publisher_priv_data == NULL)
@@ -718,10 +769,11 @@ int network_publish_rig_spectrum_data(RIG *rig, struct rig_spectrum_line *line)
struct rig_state *rs = &rig->state;
multicast_publisher_priv_data *mcast_publisher_priv;
multicast_publisher_args *mcast_publisher_args;
- multicast_publisher_data_packet packet = {
- .type = MULTICAST_PUBLISHER_DATA_PACKET_TYPE_SPECTRUM,
- .padding = 0,
- .data_length = sizeof(struct rig_spectrum_line) + line->spectrum_data_length,
+ multicast_publisher_data_packet packet =
+ {
+ .type = MULTICAST_PUBLISHER_DATA_PACKET_TYPE_SPECTRUM,
+ .padding = 0,
+ .data_length = sizeof(struct rig_spectrum_line) + line->spectrum_data_length,
};
if (rs->multicast_publisher_priv_data == NULL)
@@ -731,23 +783,27 @@ int network_publish_rig_spectrum_data(RIG *rig, struct rig_spectrum_line *line)
}
result = multicast_publisher_write_packet_header(rig, &packet);
+
if (result != RIG_OK)
{
RETURNFUNC(result);
}
- mcast_publisher_priv = (multicast_publisher_priv_data *) rs->multicast_publisher_priv_data;
+ mcast_publisher_priv = (multicast_publisher_priv_data *)
+ rs->multicast_publisher_priv_data;
mcast_publisher_args = &mcast_publisher_priv->args;
result = multicast_publisher_write_data(
- mcast_publisher_args, sizeof(struct rig_spectrum_line), (unsigned char *) line);
+ mcast_publisher_args, sizeof(struct rig_spectrum_line), (unsigned char *) line);
+
if (result != RIG_OK)
{
RETURNFUNC(result);
}
result = multicast_publisher_write_data(
- mcast_publisher_args, line->spectrum_data_length, line->spectrum_data);
+ mcast_publisher_args, line->spectrum_data_length, line->spectrum_data);
+
if (result != RIG_OK)
{
RETURNFUNC(result);
@@ -756,54 +812,70 @@ int network_publish_rig_spectrum_data(RIG *rig, struct rig_spectrum_line *line)
RETURNFUNC(RIG_OK);
}
-static int multicast_publisher_read_packet(multicast_publisher_args *mcast_publisher_args,
- uint8_t *type, struct rig_spectrum_line *spectrum_line, unsigned char *spectrum_data)
+static int multicast_publisher_read_packet(multicast_publisher_args
+ *mcast_publisher_args,
+ uint8_t *type, struct rig_spectrum_line *spectrum_line,
+ unsigned char *spectrum_data)
{
int result;
multicast_publisher_data_packet packet;
- result = multicast_publisher_read_data(mcast_publisher_args, sizeof(packet), (unsigned char *) &packet);
+ result = multicast_publisher_read_data(mcast_publisher_args, sizeof(packet),
+ (unsigned char *) &packet);
+
if (result < 0)
{
- return(result);
+ return (result);
}
switch (packet.type)
{
- case MULTICAST_PUBLISHER_DATA_PACKET_TYPE_POLL:
- case MULTICAST_PUBLISHER_DATA_PACKET_TYPE_TRANSCEIVE:
- break;
- case MULTICAST_PUBLISHER_DATA_PACKET_TYPE_SPECTRUM:
- result = multicast_publisher_read_data(
- mcast_publisher_args, sizeof(struct rig_spectrum_line), (unsigned char *) spectrum_line);
- if (result < 0)
- {
- return(result);
- }
+ case MULTICAST_PUBLISHER_DATA_PACKET_TYPE_POLL:
+ case MULTICAST_PUBLISHER_DATA_PACKET_TYPE_TRANSCEIVE:
+ break;
- if (packet.data_length - sizeof(struct rig_spectrum_line) != spectrum_line->spectrum_data_length)
- {
- rig_debug(RIG_DEBUG_ERR, "%s: multicast publisher data error, expected %d bytes of spectrum data, got %d bytes\n",
- __func__, (int)spectrum_line->spectrum_data_length, (int)(packet.data_length - sizeof(struct rig_spectrum_line)));
- return(-RIG_EPROTO);
- }
+ case MULTICAST_PUBLISHER_DATA_PACKET_TYPE_SPECTRUM:
+ result = multicast_publisher_read_data(
+ mcast_publisher_args, sizeof(struct rig_spectrum_line),
+ (unsigned char *) spectrum_line);
- spectrum_line->spectrum_data = spectrum_data;
+ if (result < 0)
+ {
+ return (result);
+ }
- result = multicast_publisher_read_data(mcast_publisher_args, spectrum_line->spectrum_data_length, spectrum_data);
- if (result < 0)
- {
- return(result);
- }
- break;
- default:
- rig_debug(RIG_DEBUG_ERR, "%s: unexpected multicast publisher data packet type: %d\n", __func__, packet.type);
- return(-RIG_EPROTO);
+ if (packet.data_length - sizeof(struct rig_spectrum_line) !=
+ spectrum_line->spectrum_data_length)
+ {
+ rig_debug(RIG_DEBUG_ERR,
+ "%s: multicast publisher data error, expected %d bytes of spectrum data, got %d bytes\n",
+ __func__, (int)spectrum_line->spectrum_data_length,
+ (int)(packet.data_length - sizeof(struct rig_spectrum_line)));
+ return (-RIG_EPROTO);
+ }
+
+ spectrum_line->spectrum_data = spectrum_data;
+
+ result = multicast_publisher_read_data(mcast_publisher_args,
+ spectrum_line->spectrum_data_length, spectrum_data);
+
+ if (result < 0)
+ {
+ return (result);
+ }
+
+ break;
+
+ default:
+ rig_debug(RIG_DEBUG_ERR,
+ "%s: unexpected multicast publisher data packet type: %d\n", __func__,
+ packet.type);
+ return (-RIG_EPROTO);
}
*type = packet.type;
- return(RIG_OK);
+ return (RIG_OK);
}
void *multicast_publisher(void *arg)
@@ -811,7 +883,8 @@ void *multicast_publisher(void *arg)
unsigned char spectrum_data[HAMLIB_MAX_SPECTRUM_DATA];
char snapshot_buffer[HAMLIB_MAX_SNAPSHOT_PACKET_SIZE];
- struct multicast_publisher_args_s *args = (struct multicast_publisher_args_s *)arg;
+ struct multicast_publisher_args_s *args = (struct multicast_publisher_args_s *)
+ arg;
RIG *rig = args->rig;
struct rig_state *rs = &rig->state;
struct rig_spectrum_line spectrum_line;
@@ -822,7 +895,8 @@ void *multicast_publisher(void *arg)
int result;
ssize_t send_result;
- rig_debug(RIG_DEBUG_VERBOSE, "%s(%d): Starting multicast publisher\n", __FILE__, __LINE__);
+ rig_debug(RIG_DEBUG_VERBOSE, "%s(%d): Starting multicast publisher\n", __FILE__,
+ __LINE__);
memset(&dest_addr, 0, sizeof(dest_addr));
dest_addr.sin_family = AF_INET;
@@ -831,7 +905,9 @@ void *multicast_publisher(void *arg)
while (rs->multicast_publisher_run)
{
- result = multicast_publisher_read_packet(args, &packet_type, &spectrum_line, spectrum_data);
+ result = multicast_publisher_read_packet(args, &packet_type, &spectrum_line,
+ spectrum_data);
+
if (result != RIG_OK)
{
if (result == -RIG_ETIMEOUT)
@@ -846,25 +922,32 @@ void *multicast_publisher(void *arg)
}
result = snapshot_serialize(sizeof(snapshot_buffer), snapshot_buffer, rig,
- packet_type == MULTICAST_PUBLISHER_DATA_PACKET_TYPE_SPECTRUM ? &spectrum_line : NULL);
+ packet_type == MULTICAST_PUBLISHER_DATA_PACKET_TYPE_SPECTRUM ? &spectrum_line :
+ NULL);
+
if (result != RIG_OK)
{
- rig_debug(RIG_DEBUG_ERR, "%s: error serializing rig snapshot data, result=%d\n", __func__, result);
+ rig_debug(RIG_DEBUG_ERR, "%s: error serializing rig snapshot data, result=%d\n",
+ __func__, result);
continue;
}
- rig_debug(RIG_DEBUG_TRACE, "%s: sending rig snapshot data: %s\n", __func__, snapshot_buffer);
+ rig_debug(RIG_DEBUG_TRACE, "%s: sending rig snapshot data: %s\n", __func__,
+ snapshot_buffer);
send_result = sendto(
- socket_fd,
- snapshot_buffer,
- strlen(snapshot_buffer),
- 0,
- (struct sockaddr *) &dest_addr,
- sizeof(dest_addr)
- );
- if (send_result < 0) {
- rig_debug(RIG_DEBUG_ERR, "%s: error sending UDP packet: %s\n", __func__, strerror(errno));
+ socket_fd,
+ snapshot_buffer,
+ strlen(snapshot_buffer),
+ 0,
+ (struct sockaddr *) &dest_addr,
+ sizeof(dest_addr)
+ );
+
+ if (send_result < 0)
+ {
+ rig_debug(RIG_DEBUG_ERR, "%s: error sending UDP packet: %s\n", __func__,
+ strerror(errno));
}
}
@@ -895,17 +978,19 @@ int network_multicast_publisher_start(RIG *rig, const char *multicast_addr,
ENTERFUNC;
rig_debug(RIG_DEBUG_VERBOSE, "%s(%d):address=%s, port=%d\n", __FILE__, __LINE__,
- multicast_addr, multicast_port);
+ multicast_addr, multicast_port);
if (strcmp(multicast_addr, "0.0.0.0") == 0)
{
- rig_debug(RIG_DEBUG_TRACE, "%s(%d): not starting multicast publisher\n", __FILE__, __LINE__);
+ rig_debug(RIG_DEBUG_TRACE, "%s(%d): not starting multicast publisher\n",
+ __FILE__, __LINE__);
return RIG_OK;
}
if (rs->multicast_publisher_priv_data != NULL)
{
- rig_debug(RIG_DEBUG_ERR, "%s(%d): multicast publisher already running\n", __FILE__,
+ rig_debug(RIG_DEBUG_ERR, "%s(%d): multicast publisher already running\n",
+ __FILE__,
__LINE__);
RETURNFUNC(-RIG_EINVAL);
}
@@ -918,53 +1003,65 @@ int network_multicast_publisher_start(RIG *rig, const char *multicast_addr,
}
socket_fd = socket(AF_INET, SOCK_DGRAM, 0);
- if (socket_fd < 0) {
- rig_debug(RIG_DEBUG_ERR, "%s: error opening new UDP socket: %s", __func__, strerror(errno));
+
+ if (socket_fd < 0)
+ {
+ rig_debug(RIG_DEBUG_ERR, "%s: error opening new UDP socket: %s", __func__,
+ strerror(errno));
RETURNFUNC(-RIG_EIO);
}
if (items & RIG_MULTICAST_TRANSCEIVE)
{
- rig_debug(RIG_DEBUG_VERBOSE, "%s(%d) MULTICAST_TRANSCEIVE enabled\n", __FILE__, __LINE__);
+ rig_debug(RIG_DEBUG_VERBOSE, "%s(%d) MULTICAST_TRANSCEIVE enabled\n", __FILE__,
+ __LINE__);
}
if (items & RIG_MULTICAST_SPECTRUM)
{
- rig_debug(RIG_DEBUG_VERBOSE, "%s(%d) MULTICAST_SPECTRUM enabled\n", __FILE__, __LINE__);
+ rig_debug(RIG_DEBUG_VERBOSE, "%s(%d) MULTICAST_SPECTRUM enabled\n", __FILE__,
+ __LINE__);
}
else
{
rig_debug(RIG_DEBUG_ERR, "%s(%d) unknown MULTICAST item requested=0x%x\n",
- __FILE__, __LINE__, items);
+ __FILE__, __LINE__, items);
}
rs->snapshot_packet_sequence_number = 0;
rs->multicast_publisher_run = 1;
- rs->multicast_publisher_priv_data = calloc(1, sizeof(multicast_publisher_priv_data));
+ rs->multicast_publisher_priv_data = calloc(1,
+ sizeof(multicast_publisher_priv_data));
+
if (rs->multicast_publisher_priv_data == NULL)
{
close(socket_fd);
RETURNFUNC(-RIG_ENOMEM);
}
- mcast_publisher_priv = (multicast_publisher_priv_data *) rs->multicast_publisher_priv_data;
+ mcast_publisher_priv = (multicast_publisher_priv_data *)
+ rs->multicast_publisher_priv_data;
mcast_publisher_priv->args.socket_fd = socket_fd;
mcast_publisher_priv->args.multicast_addr = multicast_addr;
mcast_publisher_priv->args.multicast_port = multicast_port;
mcast_publisher_priv->args.rig = rig;
status = multicast_publisher_create_data_pipe(mcast_publisher_priv);
+
if (status < 0)
{
free(rs->multicast_publisher_priv_data);
rs->multicast_publisher_priv_data = NULL;
close(socket_fd);
- rig_debug(RIG_DEBUG_ERR, "%s: multicast publisher data pipe creation failed, result=%d\n", __func__, status);
+ rig_debug(RIG_DEBUG_ERR,
+ "%s: multicast publisher data pipe creation failed, result=%d\n", __func__,
+ status);
RETURNFUNC(-RIG_EINTERNAL);
}
- int err = pthread_create(&mcast_publisher_priv->thread_id, NULL, multicast_publisher,
- &mcast_publisher_priv->args);
+ int err = pthread_create(&mcast_publisher_priv->thread_id, NULL,
+ multicast_publisher,
+ &mcast_publisher_priv->args);
if (err)
{
@@ -996,7 +1093,9 @@ int network_multicast_publisher_stop(RIG *rig)
rs->multicast_publisher_run = 0;
- mcast_publisher_priv = (multicast_publisher_priv_data *) rs->multicast_publisher_priv_data;
+ mcast_publisher_priv = (multicast_publisher_priv_data *)
+ rs->multicast_publisher_priv_data;
+
if (mcast_publisher_priv == NULL)
{
RETURNFUNC(RIG_OK);
@@ -1009,7 +1108,7 @@ int network_multicast_publisher_stop(RIG *rig)
if (err)
{
rig_debug(RIG_DEBUG_ERR, "%s(%d): pthread_join error %s\n", __FILE__, __LINE__,
- strerror(errno));
+ strerror(errno));
// just ignore it
}
diff --git a/src/rig.c b/src/rig.c
index 6aca5eeb7..27651bff2 100644
--- a/src/rig.c
+++ b/src/rig.c
@@ -259,13 +259,13 @@ static int remove_opened_rig(RIG *rig)
}
free(p);
- return(RIG_OK);
+ return (RIG_OK);
}
q = p;
}
- return(-RIG_EINVAL); /* Not found in list ! */
+ return (-RIG_EINVAL); /* Not found in list ! */
}
@@ -295,11 +295,11 @@ int foreach_opened_rig(int (*cfunc)(RIG *, rig_ptr_t), rig_ptr_t data)
{
if ((*cfunc)(p->rig, data) == 0)
{
- return(RIG_OK);
+ return (RIG_OK);
}
}
- return(RIG_OK);
+ return (RIG_OK);
}
#endif /* !DOC_HIDDEN */
@@ -371,7 +371,7 @@ static int rig_check_rig_caps()
&caps_test.macro_name);
}
- return(rc);
+ return (rc);
}
/**
@@ -455,7 +455,8 @@ RIG *HAMLIB_API rig_init(rig_model_t rig_model)
rs->rigport.fd = -1;
rs->pttport.fd = -1;
rs->comm_state = 0;
- rig_debug(RIG_DEBUG_VERBOSE, "%s(%d): %p rs->comm_state==0?=%d\n", __func__, __LINE__, &rs->comm_state,
+ rig_debug(RIG_DEBUG_VERBOSE, "%s(%d): %p rs->comm_state==0?=%d\n", __func__,
+ __LINE__, &rs->comm_state,
rs->comm_state);
rs->rigport.type.rig = caps->port_type; /* default from caps */
#if defined(HAVE_PTHREAD)
@@ -673,12 +674,16 @@ RIG *HAMLIB_API rig_init(rig_model_t rig_model)
return (NULL);
}
}
+
// Now we have to copy our new rig state hamlib_port structure to the deprecated one
// Clients built on older 4.X versions will use the old structure
// Clients built on newer 4.5 versions will use the new structure
- memcpy(&rig->state.rigport_deprecated, &rig->state.rigport, sizeof(rig->state.rigport_deprecated));
- memcpy(&rig->state.pttport_deprecated, &rig->state.pttport, sizeof(rig->state.pttport_deprecated));
- memcpy(&rig->state.dcdport_deprecated, &rig->state.dcdport, sizeof(rig->state.dcdport_deprecated));
+ memcpy(&rig->state.rigport_deprecated, &rig->state.rigport,
+ sizeof(rig->state.rigport_deprecated));
+ memcpy(&rig->state.pttport_deprecated, &rig->state.pttport,
+ sizeof(rig->state.pttport_deprecated));
+ memcpy(&rig->state.dcdport_deprecated, &rig->state.dcdport,
+ sizeof(rig->state.dcdport_deprecated));
return (rig);
}
@@ -727,7 +732,8 @@ int HAMLIB_API rig_open(RIG *rig)
if (strlen(rs->rigport.pathname) > 0)
{
char hoststr[256], portstr[6];
- status = parse_hoststr(rs->rigport.pathname, sizeof(rs->rigport.pathname), hoststr, portstr);
+ status = parse_hoststr(rs->rigport.pathname, sizeof(rs->rigport.pathname),
+ hoststr, portstr);
if (status == RIG_OK) { is_network = 1; }
}
@@ -775,7 +781,8 @@ int HAMLIB_API rig_open(RIG *rig)
if (rs->comm_state)
{
- rig_debug(RIG_DEBUG_VERBOSE, "%s(%d): %p rs->comm_state==1?=%d\n", __func__, __LINE__, &rs->comm_state,
+ rig_debug(RIG_DEBUG_VERBOSE, "%s(%d): %p rs->comm_state==1?=%d\n", __func__,
+ __LINE__, &rs->comm_state,
rs->comm_state);
port_close(&rs->rigport, rs->rigport.type.rig);
rs->comm_state = 0;
@@ -1057,7 +1064,8 @@ int HAMLIB_API rig_open(RIG *rig)
add_opened_rig(rig);
rs->comm_state = 1;
- rig_debug(RIG_DEBUG_VERBOSE, "%s: %p rs->comm_state==1?=%d\n", __func__, &rs->comm_state,
+ rig_debug(RIG_DEBUG_VERBOSE, "%s: %p rs->comm_state==1?=%d\n", __func__,
+ &rs->comm_state,
rs->comm_state);
/*
@@ -1073,7 +1081,7 @@ int HAMLIB_API rig_open(RIG *rig)
remove_opened_rig(rig);
async_data_handler_stop(rig);
port_close(&rs->rigport, rs->rigport.type.rig);
- memcpy(&rs->rigport_deprecated,&rs->rigport,sizeof(hamlib_port_t_deprecated));
+ memcpy(&rs->rigport_deprecated, &rs->rigport, sizeof(hamlib_port_t_deprecated));
rs->comm_state = 0;
RETURNFUNC(status);
}
@@ -1139,9 +1147,9 @@ int HAMLIB_API rig_open(RIG *rig)
// if (caps->get_freq) rig_get_freq(rig, RIG_VFO_A, &freq);
// if (caps->get_freq) rig_get_freq(rig, RIG_VFO_B, &freq);
- memcpy(&rs->rigport_deprecated,&rs->rigport,sizeof(hamlib_port_t_deprecated));
- memcpy(&rs->pttport_deprecated,&rs->pttport,sizeof(hamlib_port_t_deprecated));
- memcpy(&rs->dcdport_deprecated,&rs->dcdport,sizeof(hamlib_port_t_deprecated));
+ memcpy(&rs->rigport_deprecated, &rs->rigport, sizeof(hamlib_port_t_deprecated));
+ memcpy(&rs->pttport_deprecated, &rs->pttport, sizeof(hamlib_port_t_deprecated));
+ memcpy(&rs->dcdport_deprecated, &rs->dcdport, sizeof(hamlib_port_t_deprecated));
RETURNFUNC(RIG_OK);
}
@@ -1211,7 +1219,7 @@ int HAMLIB_API rig_close(RIG *rig)
if (rs->pttport.fd != rs->rigport.fd)
{
port_close(&rs->pttport, RIG_PORT_SERIAL);
- memcpy(&rs->rigport_deprecated,&rs->rigport,sizeof(hamlib_port_t_deprecated));
+ memcpy(&rs->rigport_deprecated, &rs->rigport, sizeof(hamlib_port_t_deprecated));
}
}
@@ -1227,7 +1235,7 @@ int HAMLIB_API rig_close(RIG *rig)
if (rs->pttport.fd != rs->rigport.fd)
{
port_close(&rs->pttport, RIG_PORT_SERIAL);
- memcpy(&rs->rigport_deprecated,&rs->rigport,sizeof(hamlib_port_t_deprecated));
+ memcpy(&rs->rigport_deprecated, &rs->rigport, sizeof(hamlib_port_t_deprecated));
}
}
@@ -1268,7 +1276,7 @@ int HAMLIB_API rig_close(RIG *rig)
if (rs->dcdport.fd != rs->rigport.fd)
{
port_close(&rs->dcdport, RIG_PORT_SERIAL);
- memcpy(&rs->rigport_deprecated,&rs->rigport,sizeof(hamlib_port_t_deprecated));
+ memcpy(&rs->rigport_deprecated, &rs->rigport, sizeof(hamlib_port_t_deprecated));
}
break;
@@ -1296,7 +1304,8 @@ int HAMLIB_API rig_close(RIG *rig)
remove_opened_rig(rig);
rs->comm_state = 0;
- rig_debug(RIG_DEBUG_VERBOSE, "%s(%d): %p rs->comm_state==0?=%d\n", __func__, __LINE__, &rs->comm_state,
+ rig_debug(RIG_DEBUG_VERBOSE, "%s(%d): %p rs->comm_state==0?=%d\n", __func__,
+ __LINE__, &rs->comm_state,
rs->comm_state);
RETURNFUNC(RIG_OK);
@@ -1320,7 +1329,7 @@ int HAMLIB_API rig_cleanup(RIG *rig)
{
if (!rig || !rig->caps)
{
- return(-RIG_EINVAL);
+ return (-RIG_EINVAL);
}
/*
@@ -1341,7 +1350,7 @@ int HAMLIB_API rig_cleanup(RIG *rig)
free(rig);
- return(RIG_OK);
+ return (RIG_OK);
}
/**
@@ -1501,7 +1510,8 @@ int HAMLIB_API rig_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
ELAPSED1;
#if BUILTINFUNC
- rig_debug(RIG_DEBUG_VERBOSE, "%s called vfo=%s, freq=%.0f, called from %s\n", __func__,
+ rig_debug(RIG_DEBUG_VERBOSE, "%s called vfo=%s, freq=%.0f, called from %s\n",
+ __func__,
rig_strvfo(vfo), freq, func);
#else
rig_debug(RIG_DEBUG_VERBOSE, "%s called vfo=%s, freq=%.0f\n", __func__,
@@ -1725,14 +1735,15 @@ int HAMLIB_API rig_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
if (CHECK_RIG_ARG(rig))
{
- return(-RIG_EINVAL);
+ return (-RIG_EINVAL);
}
ELAPSED1;
+
if (!freq)
{
rig_debug(RIG_DEBUG_TRACE, "%s: freq ptr invalid\n", __func__);
- return(-RIG_EINVAL);
+ return (-RIG_EINVAL);
}
rig_debug(RIG_DEBUG_VERBOSE, "%s(%d) called vfo=%s\n", __func__, __LINE__,
@@ -1763,7 +1774,7 @@ int HAMLIB_API rig_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
rig_get_cache(rig, vfo, freq, &cache_ms_freq, &mode, &cache_ms_mode, &width,
&cache_ms_width);
ELAPSED2;
- return(RIG_OK);
+ return (RIG_OK);
}
rig_cache_show(rig, __func__, __LINE__);
@@ -1782,7 +1793,7 @@ int HAMLIB_API rig_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
if (retcode != RIG_OK)
{
- return(retcode);
+ return (retcode);
}
if (ptt)
@@ -1791,7 +1802,7 @@ int HAMLIB_API rig_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
"%s: split is on so returning VFOA last known freq\n",
__func__);
*freq = rig->state.cache.freqMainA;
- return(RIG_OK);
+ return (RIG_OK);
}
}
@@ -1803,12 +1814,13 @@ int HAMLIB_API rig_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
rig_cache_show(rig, __func__, __LINE__);
if (*freq != 0 && (cache_ms_freq < rig->state.cache.timeout_ms
- || (rig->state.cache.timeout_ms == HAMLIB_CACHE_ALWAYS || rig->state.use_cached_freq)))
+ || (rig->state.cache.timeout_ms == HAMLIB_CACHE_ALWAYS
+ || rig->state.use_cached_freq)))
{
rig_debug(RIG_DEBUG_TRACE, "%s: %s cache hit age=%dms, freq=%.0f\n", __func__,
rig_strvfo(vfo), cache_ms_freq, *freq);
ELAPSED2;
- return(RIG_OK);
+ return (RIG_OK);
}
else
{
@@ -1822,7 +1834,7 @@ int HAMLIB_API rig_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
if (caps->get_freq == NULL)
{
- return(-RIG_ENAVAIL);
+ return (-RIG_ENAVAIL);
}
rig_debug(RIG_DEBUG_VERBOSE, "%s(%d): vfo_opt=%d, model=%d\n", __func__,
@@ -1865,7 +1877,7 @@ int HAMLIB_API rig_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
if (!caps->set_vfo)
{
- return(-RIG_ENAVAIL);
+ return (-RIG_ENAVAIL);
}
TRACE;
@@ -1873,7 +1885,7 @@ int HAMLIB_API rig_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
if (retcode != RIG_OK)
{
- return(retcode);
+ return (retcode);
}
rig_cache_show(rig, __func__, __LINE__);
@@ -1920,7 +1932,7 @@ int HAMLIB_API rig_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
rig_cache_show(rig, __func__, __LINE__);
ELAPSED2;
- return(retcode);
+ return (retcode);
}
/**
@@ -1943,7 +1955,7 @@ int HAMLIB_API rig_get_freqs(RIG *rig, freq_t *freqA, freq_t freqB)
{
// we will attempt to avoid vfo swapping in this routine
- return(-RIG_ENIMPL);
+ return (-RIG_ENIMPL);
}
@@ -2021,7 +2033,7 @@ int HAMLIB_API rig_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
{
rig_debug(RIG_DEBUG_TRACE, "%s: VFOB mode not changing so ignoring\n",
__func__);
- RETURNFUNC2 (RIG_OK);
+ RETURNFUNC2(RIG_OK);
}
rig_debug(RIG_DEBUG_TRACE, "%s: not targetable need vfo swap\n", __func__);
@@ -2122,7 +2134,8 @@ int HAMLIB_API rig_get_mode(RIG *rig,
rig_cache_show(rig, __func__, __LINE__);
- if (rig->state.cache.timeout_ms == HAMLIB_CACHE_ALWAYS || rig->state.use_cached_mode)
+ if (rig->state.cache.timeout_ms == HAMLIB_CACHE_ALWAYS
+ || rig->state.use_cached_mode)
{
rig_debug(RIG_DEBUG_TRACE, "%s: cache hit age mode=%dms, width=%dms\n",
__func__, cache_ms_mode, cache_ms_width);
@@ -2249,7 +2262,8 @@ pbwidth_t HAMLIB_API rig_passband_normal(RIG *rig, rmode_t mode)
{
if (rs->filters[i].modes & mode)
{
- rig_debug(RIG_DEBUG_VERBOSE, "%.*s%d:%s: return filter#%d, width=%d\n", rig->state.depth, spaces(), rig->state.depth, __func__, i,
+ rig_debug(RIG_DEBUG_VERBOSE, "%.*s%d:%s: return filter#%d, width=%d\n",
+ rig->state.depth, spaces(), rig->state.depth, __func__, i,
(int)rs->filters[i].width);
RETURNFUNC(rs->filters[i].width);
}
@@ -2418,10 +2432,13 @@ int HAMLIB_API rig_set_vfo(RIG *rig, vfo_t vfo)
if (vfo == RIG_VFO_CURR) { RETURNFUNC(RIG_OK); }
retcode = rig_get_vfo(rig, &curr_vfo);
+
if (retcode != RIG_OK)
{
- rig_debug(RIG_DEBUG_WARN, "%s: rig_get_vfo error=%s\n", __func__, rigerror(retcode));
+ rig_debug(RIG_DEBUG_WARN, "%s: rig_get_vfo error=%s\n", __func__,
+ rigerror(retcode));
}
+
if (curr_vfo == vfo) { RETURNFUNC(RIG_OK); }
#if 0 // removing this check 20210801 -- should be mapped already
@@ -2456,7 +2473,8 @@ int HAMLIB_API rig_set_vfo(RIG *rig, vfo_t vfo)
{
rig_debug(RIG_DEBUG_TRACE, "%s: Ignoring set_vfo due to VFO twiddling\n",
__func__);
- RETURNFUNC(RIG_OK); // would be better as error but other software won't handle errors
+ RETURNFUNC(
+ RIG_OK); // would be better as error but other software won't handle errors
}
TRACE;
@@ -2887,7 +2905,8 @@ int HAMLIB_API rig_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt)
if (retcode != RIG_OK) { rig_debug(RIG_DEBUG_ERR, "%s: return code=%d\n", __func__, retcode); }
- memcpy(&rig->state.pttport_deprecated, &rig->state.pttport, sizeof(rig->state.pttport_deprecated));
+ memcpy(&rig->state.pttport_deprecated, &rig->state.pttport,
+ sizeof(rig->state.pttport_deprecated));
ELAPSED2;
RETURNFUNC(retcode);
@@ -3258,32 +3277,37 @@ int HAMLIB_API rig_get_dcd(RIG *rig, vfo_t vfo, dcd_t *dcd)
case RIG_DCD_SERIAL_CTS:
retcode = ser_get_cts(&rig->state.dcdport, &status);
- memcpy(&rig->state.dcdport_deprecated, &rig->state.dcdport, sizeof(rig->state.dcdport_deprecated));
+ memcpy(&rig->state.dcdport_deprecated, &rig->state.dcdport,
+ sizeof(rig->state.dcdport_deprecated));
*dcd = status ? RIG_DCD_ON : RIG_DCD_OFF;
RETURNFUNC(retcode);
case RIG_DCD_SERIAL_DSR:
retcode = ser_get_dsr(&rig->state.dcdport, &status);
- memcpy(&rig->state.dcdport_deprecated, &rig->state.dcdport, sizeof(rig->state.dcdport_deprecated));
+ memcpy(&rig->state.dcdport_deprecated, &rig->state.dcdport,
+ sizeof(rig->state.dcdport_deprecated));
*dcd = status ? RIG_DCD_ON : RIG_DCD_OFF;
RETURNFUNC(retcode);
case RIG_DCD_SERIAL_CAR:
retcode = ser_get_car(&rig->state.dcdport, &status);
- memcpy(&rig->state.dcdport_deprecated, &rig->state.dcdport, sizeof(rig->state.dcdport_deprecated));
+ memcpy(&rig->state.dcdport_deprecated, &rig->state.dcdport,
+ sizeof(rig->state.dcdport_deprecated));
*dcd = status ? RIG_DCD_ON : RIG_DCD_OFF;
RETURNFUNC(retcode);
case RIG_DCD_PARALLEL:
retcode = par_dcd_get(&rig->state.dcdport, dcd);
- memcpy(&rig->state.dcdport_deprecated, &rig->state.dcdport, sizeof(rig->state.dcdport_deprecated));
+ memcpy(&rig->state.dcdport_deprecated, &rig->state.dcdport,
+ sizeof(rig->state.dcdport_deprecated));
RETURNFUNC(retcode);
case RIG_DCD_GPIO:
case RIG_DCD_GPION:
retcode = gpio_dcd_get(&rig->state.dcdport, dcd);
- memcpy(&rig->state.dcdport_deprecated, &rig->state.dcdport, sizeof(rig->state.dcdport_deprecated));
+ memcpy(&rig->state.dcdport_deprecated, &rig->state.dcdport,
+ sizeof(rig->state.dcdport_deprecated));
RETURNFUNC(retcode);
case RIG_DCD_NONE:
@@ -3618,7 +3642,8 @@ int HAMLIB_API rig_set_split_freq(RIG *rig, vfo_t vfo, freq_t tx_freq)
}
- rig_debug(RIG_DEBUG_VERBOSE, "%s called vfo=%s, curr_vfo=%s, tx_freq=%.0f\n", __func__,
+ rig_debug(RIG_DEBUG_VERBOSE, "%s called vfo=%s, curr_vfo=%s, tx_freq=%.0f\n",
+ __func__,
rig_strvfo(vfo), rig_strvfo(rig->state.current_vfo), tx_freq);
caps = rig->caps;
@@ -5614,7 +5639,7 @@ rig_model_t HAMLIB_API rig_probe(hamlib_port_t *port)
{
if (!port)
{
- return(RIG_MODEL_NONE);
+ return (RIG_MODEL_NONE);
}
return rig_probe_first(port);
@@ -5644,7 +5669,7 @@ int HAMLIB_API rig_probe_all(hamlib_port_t *port,
{
if (!port)
{
- return(-RIG_EINVAL);
+ return (-RIG_EINVAL);
}
return rig_probe_all_backends(port, cfunc, data);
@@ -6525,15 +6550,15 @@ int HAMLIB_API rig_get_rig_info(RIG *rig, char *response, int max_response_len)
txa = split == 0;
rxb = !rxa;
txb = split == 1;
- SNPRINTF(response, max_response_len-strlen("CRC=0x00000000\n"),
+ SNPRINTF(response, max_response_len - strlen("CRC=0x00000000\n"),
"VFO=%s Freq=%.0f Mode=%s Width=%d RX=%d TX=%d\nVFO=%s Freq=%.0f Mode=%s Width=%d RX=%d TX=%d\nSplit=%d SatMode=%d\nRig=%s\nApp=Hamlib\nVersion=20210506 1.0.0\n",
rig_strvfo(vfoA), freqA, modeAstr, (int)widthA, rxa, txa, rig_strvfo(vfoB),
freqB, modeBstr, (int)widthB, rxb, txb, split, satmode, rig->caps->model_name);
unsigned long crc = gen_crc((unsigned char *)response, strlen(response));
char tmpstr[32];
SNPRINTF(tmpstr, sizeof(tmpstr), "CRC=0x%08lx\n", crc);
- strcat(response,tmpstr);
-
+ strcat(response, tmpstr);
+
if (strlen(response) >= max_response_len - 1)
{
@@ -6657,7 +6682,7 @@ int HAMLIB_API rig_set_clock(RIG *rig, int year, int month, int day, int hour,
}
RETURNFUNC2(rig->caps->set_clock(rig, year, month, day, hour, min, sec,
- msec, utc_offset));
+ msec, utc_offset));
}
/**
@@ -6926,7 +6951,8 @@ static int async_data_handler_start(RIG *rig)
if (err)
{
- rig_debug(RIG_DEBUG_ERR, "%s: pthread_create error: %s\n", __func__, strerror(errno));
+ rig_debug(RIG_DEBUG_ERR, "%s: pthread_create error: %s\n", __func__,
+ strerror(errno));
RETURNFUNC(-RIG_EINTERNAL);
}
@@ -6956,7 +6982,8 @@ static int async_data_handler_stop(RIG *rig)
if (err)
{
- rig_debug(RIG_DEBUG_ERR, "%s: pthread_join error: %s\n", __func__, strerror(errno));
+ rig_debug(RIG_DEBUG_ERR, "%s: pthread_join error: %s\n", __func__,
+ strerror(errno));
// just ignore the error
}
@@ -6981,7 +7008,8 @@ void *async_data_handler(void *arg)
struct rig_state *rs = &rig->state;
int result;
- rig_debug(RIG_DEBUG_VERBOSE, "%s: Starting async data handler thread\n", __func__);
+ rig_debug(RIG_DEBUG_VERBOSE, "%s: Starting async data handler thread\n",
+ __func__);
// TODO: check how to enable "transceive" on recent Kenwood/Yaesu rigs
// TODO: add initial support for async in Kenwood kenwood_transaction (+one) functions -> add transaction_active flag usage
@@ -7049,7 +7077,8 @@ void *async_data_handler(void *arg)
}
- rig_debug(RIG_DEBUG_VERBOSE, "%s: Stopping async data handler thread\n", __func__);
+ rig_debug(RIG_DEBUG_VERBOSE, "%s: Stopping async data handler thread\n",
+ __func__);
return NULL;
}
diff --git a/src/rot_conf.c b/src/rot_conf.c
index 507b8382e..3fb2e6500 100644
--- a/src/rot_conf.c
+++ b/src/rot_conf.c
@@ -391,7 +391,7 @@ int frontrot_get_conf(ROT *rot, token_t token, char *val, int val_len)
switch (token)
{
case TOK_PATHNAME:
- strncpy(val, rs->rotport.pathname, val_len-1);
+ strncpy(val, rs->rotport.pathname, val_len - 1);
break;
case TOK_WRITE_DELAY:
@@ -798,6 +798,7 @@ int HAMLIB_API rot_get_conf2(ROT *rot, token_t token, char *val, int val_len)
{
return rot->caps->get_conf2(rot, token, val, val_len);
}
+
if (rot->caps->get_conf == NULL)
{
return -RIG_ENAVAIL;
diff --git a/src/rotator.c b/src/rotator.c
index 6e94f3b69..5e17bb730 100644
--- a/src/rotator.c
+++ b/src/rotator.c
@@ -328,10 +328,12 @@ ROT *HAMLIB_API rot_init(rot_model_t rot_model)
return NULL;
}
}
+
// Now we have to copy our new rig state hamlib_port structure to the deprecated one
// Clients built on older 4.X versions will use the old structure
// Clients built on newer 4.5 versions will use the new structure
- memcpy(&rot->state.rotport_deprecated, &rot->state.rotport, sizeof(rot->state.rotport_deprecated));
+ memcpy(&rot->state.rotport_deprecated, &rot->state.rotport,
+ sizeof(rot->state.rotport_deprecated));
return rot;
}
@@ -468,7 +470,8 @@ int HAMLIB_API rot_open(ROT *rot)
return -RIG_EINVAL;
}
- memcpy(&rot->state.rotport_deprecated, &rot->state.rotport, sizeof(rot->state.rotport_deprecated));
+ memcpy(&rot->state.rotport_deprecated, &rot->state.rotport,
+ sizeof(rot->state.rotport_deprecated));
add_opened_rot(rot);
@@ -567,11 +570,13 @@ int HAMLIB_API rot_close(ROT *rot)
rs->rotport.fd = -1;
}
+
remove_opened_rot(rot);
rs->comm_state = 0;
- memcpy(&rot->state.rotport_deprecated, &rot->state.rotport, sizeof(rot->state.rotport_deprecated));
+ memcpy(&rot->state.rotport_deprecated, &rot->state.rotport,
+ sizeof(rot->state.rotport_deprecated));
return RIG_OK;
}
diff --git a/src/serial.c b/src/serial.c
index aa743153c..efd89039c 100644
--- a/src/serial.c
+++ b/src/serial.c
@@ -141,7 +141,7 @@ int HAMLIB_API serial_open(hamlib_port_t *rp)
if (!rp)
{
- return(-RIG_EINVAL);
+ return (-RIG_EINVAL);
}
@@ -157,13 +157,13 @@ int HAMLIB_API serial_open(hamlib_port_t *rp)
*/
if (rp->parm.serial.parity != RIG_PARITY_NONE)
{
- return(-RIG_EIO);
+ return (-RIG_EIO);
}
if ((rp->parm.serial.handshake != RIG_HANDSHAKE_HARDWARE) &&
(rp->parm.serial.handshake != RIG_HANDSHAKE_NONE))
{
- return(-RIG_EIO);
+ return (-RIG_EIO);
}
/*
@@ -178,7 +178,7 @@ int HAMLIB_API serial_open(hamlib_port_t *rp)
if (fd == -1)
{
- return(-RIG_EIO);
+ return (-RIG_EIO);
}
rp->fd = fd;
@@ -214,7 +214,7 @@ int HAMLIB_API serial_open(hamlib_port_t *rp)
* from the transceiver will be returned to both applications.
*/
uh_radio_fd = fd;
- return(RIG_OK);
+ return (RIG_OK);
}
/*
@@ -243,7 +243,7 @@ int HAMLIB_API serial_open(hamlib_port_t *rp)
__func__,
rp->pathname,
strerror(errno));
- return(-RIG_EIO);
+ return (-RIG_EIO);
}
rp->fd = fd;
@@ -253,13 +253,13 @@ int HAMLIB_API serial_open(hamlib_port_t *rp)
if (err != RIG_OK)
{
CLOSE(fd);
- return(err);
+ return (err);
}
serial_flush(rp); // ensure nothing is there when we open
hl_usleep(50 * 1000); // give a little time for MicroKeyer to finish
- return(RIG_OK);
+ return (RIG_OK);
}
@@ -286,7 +286,7 @@ int HAMLIB_API serial_setup(hamlib_port_t *rp)
if (!rp)
{
- return(-RIG_EINVAL);
+ return (-RIG_EINVAL);
}
fd = rp->fd;
@@ -377,7 +377,7 @@ int HAMLIB_API serial_setup(hamlib_port_t *rp)
rp->parm.serial.rate);
CLOSE(fd);
- return(-RIG_ECONF);
+ return (-RIG_ECONF);
}
/* TODO */
@@ -424,7 +424,7 @@ int HAMLIB_API serial_setup(hamlib_port_t *rp)
rp->parm.serial.data_bits);
CLOSE(fd);
- return(-RIG_ECONF);
+ return (-RIG_ECONF);
break;
}
@@ -449,7 +449,7 @@ int HAMLIB_API serial_setup(hamlib_port_t *rp)
rp->parm.serial.stop_bits);
CLOSE(fd);
- return(-RIG_ECONF);
+ return (-RIG_ECONF);
break;
}
@@ -495,7 +495,7 @@ int HAMLIB_API serial_setup(hamlib_port_t *rp)
rp->parm.serial.parity);
CLOSE(fd);
- return(-RIG_ECONF);
+ return (-RIG_ECONF);
break;
}
@@ -531,7 +531,7 @@ int HAMLIB_API serial_setup(hamlib_port_t *rp)
rp->parm.serial.handshake);
CLOSE(fd);
- return(-RIG_ECONF);
+ return (-RIG_ECONF);
break;
}
@@ -576,7 +576,7 @@ int HAMLIB_API serial_setup(hamlib_port_t *rp)
strerror(errno));
CLOSE(fd);
- return(-RIG_ECONF); /* arg, so close! */
+ return (-RIG_ECONF); /* arg, so close! */
}
#elif defined(HAVE_TERMIO_H)
@@ -591,7 +591,7 @@ int HAMLIB_API serial_setup(hamlib_port_t *rp)
strerror(errno));
CLOSE(fd);
- return(-RIG_ECONF); /* arg, so close! */
+ return (-RIG_ECONF); /* arg, so close! */
}
#else
@@ -607,7 +607,7 @@ int HAMLIB_API serial_setup(hamlib_port_t *rp)
strerror(errno));
CLOSE(fd);
- return(-RIG_ECONF); /* arg, so close! */
+ return (-RIG_ECONF); /* arg, so close! */
}
#endif
@@ -625,7 +625,7 @@ int HAMLIB_API serial_setup(hamlib_port_t *rp)
term_backup->next = term_options_backup_head;
term_options_backup_head = term_backup;
- return(RIG_OK);
+ return (RIG_OK);
}
@@ -664,7 +664,7 @@ int HAMLIB_API serial_flush(hamlib_port_t *p)
rig_debug(RIG_DEBUG_TRACE, "read flushed %d bytes\n", nbytes);
- return(RIG_OK);
+ return (RIG_OK);
}
timeout_save = p->timeout;
@@ -691,7 +691,7 @@ int HAMLIB_API serial_flush(hamlib_port_t *p)
int bytes = len * 3 + 1;
char *hbuf = calloc(bytes, 1);
- for (i = 0; i < len; ++i) { SNPRINTF(&hbuf[i * 3], bytes - (i*3), "%02X ", buf[i]); }
+ for (i = 0; i < len; ++i) { SNPRINTF(&hbuf[i * 3], bytes - (i * 3), "%02X ", buf[i]); }
rig_debug(RIG_DEBUG_WARN, "%s: flush hex:%s\n", __func__, hbuf);
free(hbuf);
@@ -707,7 +707,7 @@ int HAMLIB_API serial_flush(hamlib_port_t *p)
p->timeout = timeout_save;
//rig_debug(RIG_DEBUG_VERBOSE, "tcflush%s\n", "");
//tcflush(p->fd, TCIFLUSH);
- return(RIG_OK);
+ return (RIG_OK);
}
@@ -768,7 +768,7 @@ int ser_open(hamlib_port_t *p)
}
p->fd = ret;
- return(ret);
+ return (ret);
}
@@ -795,7 +795,7 @@ int ser_close(hamlib_port_t *p)
uh_close_ptt();
uh_ptt_fd = -1;
p->fd = -1;
- return(0);
+ return (0);
}
if (p->fd == uh_radio_fd)
@@ -803,7 +803,7 @@ int ser_close(hamlib_port_t *p)
uh_close_radio();
uh_radio_fd = -1;
p->fd = -1;
- return(0);
+ return (0);
}
// Find backup termios options to restore before closing
@@ -877,7 +877,7 @@ int ser_close(hamlib_port_t *p)
rc = CLOSE(p->fd);
p->fd = -1;
- return(rc);
+ return (rc);
}
@@ -897,7 +897,7 @@ int HAMLIB_API ser_set_rts(hamlib_port_t *p, int state)
// ignore this for microHam ports
if (p->fd == uh_ptt_fd || p->fd == uh_radio_fd)
{
- return(RIG_OK);
+ return (RIG_OK);
}
#if defined(TIOCMBIS) && defined(TIOCMBIC)
@@ -927,10 +927,10 @@ int HAMLIB_API ser_set_rts(hamlib_port_t *p, int state)
"%s: Cannot change RTS - %s\n",
__func__,
strerror(errno));
- return(-RIG_EIO);
+ return (-RIG_EIO);
}
- return(RIG_OK);
+ return (RIG_OK);
}
@@ -974,13 +974,13 @@ int HAMLIB_API ser_set_dtr(hamlib_port_t *p, int state)
// but (un)set ptt on microHam PTT channel.
if (p->fd == uh_radio_fd)
{
- return(RIG_OK);
+ return (RIG_OK);
}
if (p->fd == uh_ptt_fd)
{
uh_set_ptt(state);
- return(RIG_OK);
+ return (RIG_OK);
}
#if defined(TIOCMBIS) && defined(TIOCMBIC)
@@ -1010,10 +1010,10 @@ int HAMLIB_API ser_set_dtr(hamlib_port_t *p, int state)
"%s: Cannot change DTR - %s\n",
__func__,
strerror(errno));
- return(-RIG_EIO);
+ return (-RIG_EIO);
}
- return(RIG_OK);
+ return (RIG_OK);
}
diff --git a/src/snapshot_data.c b/src/snapshot_data.c
index 7332ded21..35e0e79d4 100644
--- a/src/snapshot_data.c
+++ b/src/snapshot_data.c
@@ -18,43 +18,55 @@ static int snapshot_serialize_rig(cJSON *rig_node, RIG *rig)
// TODO: need to assign rig an ID, e.g. from command line
node = cJSON_AddStringToObject(rig_node, "id", "rig_id");
+
if (node == NULL)
{
goto error;
}
// TODO: what kind of status should this reflect?
- node = cJSON_AddStringToObject(rig_node, "status", rig->state.comm_state ? "OK" : "CLOSED");
+ node = cJSON_AddStringToObject(rig_node, "status",
+ rig->state.comm_state ? "OK" : "CLOSED");
+
if (node == NULL)
{
goto error;
}
+
// TODO: need to store last error code
node = cJSON_AddStringToObject(rig_node, "errorMsg", "");
+
if (node == NULL)
{
goto error;
}
node = cJSON_AddStringToObject(rig_node, "name", rig->caps->model_name);
+
if (node == NULL)
{
goto error;
}
- node = cJSON_AddBoolToObject(rig_node, "split", rig->state.cache.split == RIG_SPLIT_ON ? 1 : 0);
+ node = cJSON_AddBoolToObject(rig_node, "split",
+ rig->state.cache.split == RIG_SPLIT_ON ? 1 : 0);
+
if (node == NULL)
{
goto error;
}
- node = cJSON_AddStringToObject(rig_node, "splitVfo", rig_strvfo(rig->state.cache.split_vfo));
+ node = cJSON_AddStringToObject(rig_node, "splitVfo",
+ rig_strvfo(rig->state.cache.split_vfo));
+
if (node == NULL)
{
goto error;
}
- node = cJSON_AddBoolToObject(rig_node, "satMode", rig->state.cache.satmode ? 1 : 0);
+ node = cJSON_AddBoolToObject(rig_node, "satMode",
+ rig->state.cache.satmode ? 1 : 0);
+
if (node == NULL)
{
goto error;
@@ -62,7 +74,7 @@ static int snapshot_serialize_rig(cJSON *rig_node, RIG *rig)
RETURNFUNC(RIG_OK);
- error:
+error:
RETURNFUNC(-RIG_EINTERNAL);
}
@@ -82,25 +94,33 @@ static int snapshot_serialize_vfo(cJSON *vfo_node, RIG *rig, vfo_t vfo)
// TODO: This data should match rig_get_info command response
node = cJSON_AddStringToObject(vfo_node, "name", rig_strvfo(vfo));
+
if (node == NULL)
{
goto error;
}
- result = rig_get_cache(rig, vfo, &freq, &freq_ms, &mode, &mode_ms, &width, &width_ms);
+ result = rig_get_cache(rig, vfo, &freq, &freq_ms, &mode, &mode_ms, &width,
+ &width_ms);
+
if (result == RIG_OK)
{
node = cJSON_AddNumberToObject(vfo_node, "freq", freq);
+
if (node == NULL)
{
goto error;
}
+
node = cJSON_AddStringToObject(vfo_node, "mode", rig_strrmode(mode));
+
if (node == NULL)
{
goto error;
}
+
node = cJSON_AddNumberToObject(vfo_node, "width", (double) width);
+
if (node == NULL)
{
goto error;
@@ -109,6 +129,7 @@ static int snapshot_serialize_vfo(cJSON *vfo_node, RIG *rig, vfo_t vfo)
ptt = rig->state.cache.ptt;
node = cJSON_AddBoolToObject(vfo_node, "ptt", ptt == RIG_PTT_OFF ? 0 : 1);
+
if (node == NULL)
{
goto error;
@@ -117,15 +138,19 @@ static int snapshot_serialize_vfo(cJSON *vfo_node, RIG *rig, vfo_t vfo)
split = rig->state.cache.split;
split_vfo = rig->state.cache.split_vfo;
- is_rx = (split == RIG_SPLIT_OFF && vfo == rig->state.current_vfo) || (split == RIG_SPLIT_ON && vfo != split_vfo);
+ is_rx = (split == RIG_SPLIT_OFF && vfo == rig->state.current_vfo)
+ || (split == RIG_SPLIT_ON && vfo != split_vfo);
node = cJSON_AddBoolToObject(vfo_node, "rx", is_rx);
+
if (node == NULL)
{
goto error;
}
- is_tx = (split == RIG_SPLIT_OFF && vfo == rig->state.current_vfo) || (split == RIG_SPLIT_ON && vfo == split_vfo);
+ is_tx = (split == RIG_SPLIT_OFF && vfo == rig->state.current_vfo)
+ || (split == RIG_SPLIT_ON && vfo == split_vfo);
node = cJSON_AddBoolToObject(vfo_node, "tx", is_tx);
+
if (node == NULL)
{
goto error;
@@ -133,11 +158,12 @@ static int snapshot_serialize_vfo(cJSON *vfo_node, RIG *rig, vfo_t vfo)
RETURNFUNC(RIG_OK);
- error:
+error:
RETURNFUNC(-RIG_EINTERNAL);
}
-static int snapshot_serialize_spectrum(cJSON *spectrum_node, RIG *rig, struct rig_spectrum_line *spectrum_line)
+static int snapshot_serialize_spectrum(cJSON *spectrum_node, RIG *rig,
+ struct rig_spectrum_line *spectrum_line)
{
// Spectrum data is represented as a hexadecimal ASCII string where each data byte is represented as 2 ASCII letters
char spectrum_data_string[HAMLIB_MAX_SPECTRUM_DATA * 2];
@@ -155,82 +181,103 @@ static int snapshot_serialize_spectrum(cJSON *spectrum_node, RIG *rig, struct ri
}
node = cJSON_AddNumberToObject(spectrum_node, "id", spectrum_line->id);
+
if (node == NULL)
{
goto error;
}
node = cJSON_AddStringToObject(spectrum_node, "name", name);
+
if (node == NULL)
{
goto error;
}
node = cJSON_AddStringToObject(spectrum_node, "type",
- spectrum_line->spectrum_mode == RIG_SPECTRUM_MODE_CENTER ?
- SPECTRUM_MODE_CENTER : SPECTRUM_MODE_FIXED);
+ spectrum_line->spectrum_mode == RIG_SPECTRUM_MODE_CENTER ?
+ SPECTRUM_MODE_CENTER : SPECTRUM_MODE_FIXED);
+
if (node == NULL)
{
goto error;
}
- node = cJSON_AddNumberToObject(spectrum_node, "minLevel", spectrum_line->data_level_min);
+ node = cJSON_AddNumberToObject(spectrum_node, "minLevel",
+ spectrum_line->data_level_min);
+
if (node == NULL)
{
goto error;
}
- node = cJSON_AddNumberToObject(spectrum_node, "maxLevel", spectrum_line->data_level_max);
+ node = cJSON_AddNumberToObject(spectrum_node, "maxLevel",
+ spectrum_line->data_level_max);
+
if (node == NULL)
{
goto error;
}
- node = cJSON_AddNumberToObject(spectrum_node, "minStrength", spectrum_line->signal_strength_min);
+ node = cJSON_AddNumberToObject(spectrum_node, "minStrength",
+ spectrum_line->signal_strength_min);
+
if (node == NULL)
{
goto error;
}
- node = cJSON_AddNumberToObject(spectrum_node, "maxStrength", spectrum_line->signal_strength_max);
+ node = cJSON_AddNumberToObject(spectrum_node, "maxStrength",
+ spectrum_line->signal_strength_max);
+
if (node == NULL)
{
goto error;
}
- node = cJSON_AddNumberToObject(spectrum_node, "centerFreq", spectrum_line->center_freq);
+ node = cJSON_AddNumberToObject(spectrum_node, "centerFreq",
+ spectrum_line->center_freq);
+
if (node == NULL)
{
goto error;
}
node = cJSON_AddNumberToObject(spectrum_node, "span", spectrum_line->span_freq);
+
if (node == NULL)
{
goto error;
}
- node = cJSON_AddNumberToObject(spectrum_node, "lowFreq", spectrum_line->low_edge_freq);
+ node = cJSON_AddNumberToObject(spectrum_node, "lowFreq",
+ spectrum_line->low_edge_freq);
+
if (node == NULL)
{
goto error;
}
- node = cJSON_AddNumberToObject(spectrum_node, "highFreq", spectrum_line->high_edge_freq);
+ node = cJSON_AddNumberToObject(spectrum_node, "highFreq",
+ spectrum_line->high_edge_freq);
+
if (node == NULL)
{
goto error;
}
- node = cJSON_AddNumberToObject(spectrum_node, "length", (double) spectrum_line->spectrum_data_length);
+ node = cJSON_AddNumberToObject(spectrum_node, "length",
+ (double) spectrum_line->spectrum_data_length);
+
if (node == NULL)
{
goto error;
}
to_hex(spectrum_line->spectrum_data_length, spectrum_line->spectrum_data,
- sizeof(spectrum_data_string), spectrum_data_string);
+ sizeof(spectrum_data_string), spectrum_data_string);
node = cJSON_AddStringToObject(spectrum_node, "data", spectrum_data_string);
+
if (node == NULL)
{
goto error;
@@ -238,11 +285,12 @@ static int snapshot_serialize_spectrum(cJSON *spectrum_node, RIG *rig, struct ri
RETURNFUNC(RIG_OK);
- error:
+error:
RETURNFUNC(-RIG_EINTERNAL);
}
-int snapshot_serialize(size_t buffer_length, char *buffer, RIG *rig, struct rig_spectrum_line *spectrum_line)
+int snapshot_serialize(size_t buffer_length, char *buffer, RIG *rig,
+ struct rig_spectrum_line *spectrum_line)
{
cJSON *root_node;
cJSON *rig_node, *vfos_array, *vfo_node, *spectra_array, *spectrum_node;
@@ -258,22 +306,30 @@ int snapshot_serialize(size_t buffer_length, char *buffer, RIG *rig, struct rig_
vfos[1] = RIG_VFO_B;
root_node = cJSON_CreateObject();
+
if (root_node == NULL)
{
RETURNFUNC(-RIG_EINTERNAL);
}
node = cJSON_AddStringToObject(root_node, "app", PACKAGE_NAME);
+
if (node == NULL)
{
goto error;
}
- node = cJSON_AddStringToObject(root_node, "version", PACKAGE_VERSION " " HAMLIBDATETIME);
+
+ node = cJSON_AddStringToObject(root_node, "version",
+ PACKAGE_VERSION " " HAMLIBDATETIME);
+
if (node == NULL)
{
goto error;
}
- node = cJSON_AddNumberToObject(root_node, "seq", rig->state.snapshot_packet_sequence_number);
+
+ node = cJSON_AddNumberToObject(root_node, "seq",
+ rig->state.snapshot_packet_sequence_number);
+
if (node == NULL)
{
goto error;
@@ -281,18 +337,21 @@ int snapshot_serialize(size_t buffer_length, char *buffer, RIG *rig, struct rig_
// TODO: Calculate 32-bit CRC of the entire JSON record replacing the CRC value with 0
node = cJSON_AddNumberToObject(root_node, "crc", 0);
+
if (node == NULL)
{
goto error;
}
rig_node = cJSON_CreateObject();
+
if (rig_node == NULL)
{
goto error;
}
result = snapshot_serialize_rig(rig_node, rig);
+
if (result != RIG_OK)
{
cJSON_Delete(rig_node);
@@ -302,6 +361,7 @@ int snapshot_serialize(size_t buffer_length, char *buffer, RIG *rig, struct rig_
cJSON_AddItemToObject(root_node, "rig", rig_node);
vfos_array = cJSON_CreateArray();
+
if (vfos_array == NULL)
{
goto error;
@@ -311,6 +371,7 @@ int snapshot_serialize(size_t buffer_length, char *buffer, RIG *rig, struct rig_
{
vfo_node = cJSON_CreateObject();
result = snapshot_serialize_vfo(vfo_node, rig, vfos[i]);
+
if (result != RIG_OK)
{
cJSON_Delete(vfo_node);
@@ -325,6 +386,7 @@ int snapshot_serialize(size_t buffer_length, char *buffer, RIG *rig, struct rig_
if (spectrum_line != NULL)
{
spectra_array = cJSON_CreateArray();
+
if (spectra_array == NULL)
{
goto error;
@@ -332,6 +394,7 @@ int snapshot_serialize(size_t buffer_length, char *buffer, RIG *rig, struct rig_
spectrum_node = cJSON_CreateObject();
result = snapshot_serialize_spectrum(spectrum_node, rig, spectrum_line);
+
if (result != RIG_OK)
{
cJSON_Delete(spectrum_node);
@@ -343,7 +406,8 @@ int snapshot_serialize(size_t buffer_length, char *buffer, RIG *rig, struct rig_
cJSON_AddItemToObject(root_node, "spectra", spectra_array);
}
- bool_result = cJSON_PrintPreallocated(root_node, buffer, (int) buffer_length, 0);
+ bool_result = cJSON_PrintPreallocated(root_node, buffer, (int) buffer_length,
+ 0);
cJSON_Delete(root_node);
diff --git a/src/sprintflst.c b/src/sprintflst.c
index 1907a1f51..bac0831e8 100644
--- a/src/sprintflst.c
+++ b/src/sprintflst.c
@@ -339,6 +339,7 @@ int sprintf_level_ext(char *str, int nlen, const struct confparams *extlevels)
/* ignore case RIG_CONF_BUTTON */
break;
}
+
check_buffer_overflow(str, len, nlen);
}
@@ -397,6 +398,7 @@ int rig_sprintf_level_gran(char *str, int nlen, setting_t level,
gran[i].max.i,
gran[i].step.i);
}
+
check_buffer_overflow(str, len, nlen);
}
@@ -455,6 +457,7 @@ int rot_sprintf_level_gran(char *str, int nlen, setting_t level,
gran[i].max.i,
gran[i].step.i);
}
+
check_buffer_overflow(str, len, nlen);
}
@@ -573,6 +576,7 @@ int rig_sprintf_parm_gran(char *str, int nlen, setting_t parm,
gran[i].max.i,
gran[i].step.i);
}
+
check_buffer_overflow(str, len, nlen);
}
@@ -631,6 +635,7 @@ int rot_sprintf_parm_gran(char *str, int nlen, setting_t parm,
gran[i].max.i,
gran[i].step.i);
}
+
check_buffer_overflow(str, len, nlen);
}
@@ -720,6 +725,7 @@ int rot_sprintf_status(char *str, int nlen, rot_status_t status)
{
len += sprintf(str + len, "%s ", sv);
}
+
check_buffer_overflow(str, len, nlen);
}
diff --git a/tests/rigctl_parse.c b/tests/rigctl_parse.c
index 7d4d771e7..14abfe8b8 100644
--- a/tests/rigctl_parse.c
+++ b/tests/rigctl_parse.c
@@ -677,7 +677,7 @@ int rigctl_parse(RIG *my_rig, FILE *fin, FILE *fout, char *argv[], int argc,
{
rig_debug(RIG_DEBUG_WARN, "%s: nothing to scan#1? retcode=%d\n", __func__,
retcode);
- return(RIGCTL_PARSE_ERROR);
+ return (RIGCTL_PARSE_ERROR);
}
if (cmd != 0xa && cmd != 0xd)
@@ -696,12 +696,12 @@ int rigctl_parse(RIG *my_rig, FILE *fin, FILE *fout, char *argv[], int argc,
if (scanfc(fin, "%c", &cmd) < 1)
{
rig_debug(RIG_DEBUG_WARN, "%s: nothing to scan#2?\n", __func__);
- return(RIGCTL_PARSE_ERROR);
+ return (RIGCTL_PARSE_ERROR);
}
}
else if (cmd == '+' && prompt)
{
- return(RIG_OK);
+ return (RIG_OK);
}
if (cmd != '\\'
@@ -719,7 +719,7 @@ int rigctl_parse(RIG *my_rig, FILE *fin, FILE *fout, char *argv[], int argc,
if (scanfc(fin, "%c", &cmd) < 1)
{
rig_debug(RIG_DEBUG_WARN, "%s: nothing to scan#3?\n", __func__);
- return(RIGCTL_PARSE_ERROR);
+ return (RIGCTL_PARSE_ERROR);
}
}
else if (cmd != '\\'
@@ -732,7 +732,7 @@ int rigctl_parse(RIG *my_rig, FILE *fin, FILE *fout, char *argv[], int argc,
&& prompt)
{
- return(RIG_OK);
+ return (RIG_OK);
}
/* command by name */
@@ -743,7 +743,7 @@ int rigctl_parse(RIG *my_rig, FILE *fin, FILE *fout, char *argv[], int argc,
if (scanfc(fin, "%c", pcmd) < 1)
{
rig_debug(RIG_DEBUG_WARN, "%s: nothing to scan#4?\n", __func__);
- return(RIGCTL_PARSE_ERROR);
+ return (RIGCTL_PARSE_ERROR);
}
retcode = fscanf(fin, "%s", ++pcmd);
@@ -770,7 +770,7 @@ int rigctl_parse(RIG *my_rig, FILE *fin, FILE *fout, char *argv[], int argc,
fprintf_flush(fout, "\nRig command: ");
}
- return(RIG_OK);
+ return (RIG_OK);
}
last_was_ret = 1;
@@ -788,11 +788,11 @@ int rigctl_parse(RIG *my_rig, FILE *fin, FILE *fout, char *argv[], int argc,
if (scanfc(fin, "%c", &cmd) < 1)
{
rig_debug(RIG_DEBUG_WARN, "%s: nothing to scan#6?\n", __func__);
- return(RIGCTL_PARSE_ERROR);
+ return (RIGCTL_PARSE_ERROR);
}
}
- return(RIG_OK);
+ return (RIG_OK);
}
my_rig->state.vfo_opt = *vfo_opt;
@@ -804,14 +804,14 @@ int rigctl_parse(RIG *my_rig, FILE *fin, FILE *fout, char *argv[], int argc,
if (interactive && !prompt) { fprintf(fout, "%s0\n", NETRIGCTL_RET); }
fflush(fout);
- return(RIGCTL_PARSE_END);
+ return (RIGCTL_PARSE_END);
}
if (cmd == '?')
{
usage_rig(fout);
fflush(fout);
- return(RIG_OK);
+ return (RIG_OK);
}
}
else
@@ -821,11 +821,11 @@ int rigctl_parse(RIG *my_rig, FILE *fin, FILE *fout, char *argv[], int argc,
if (EOF == retcode)
{
- return(RIGCTL_PARSE_END);
+ return (RIGCTL_PARSE_END);
}
else if (retcode < 0)
{
- return(RIGCTL_PARSE_ERROR);
+ return (RIGCTL_PARSE_ERROR);
}
else if ('\0' == command[1])
{
@@ -846,7 +846,7 @@ int rigctl_parse(RIG *my_rig, FILE *fin, FILE *fout, char *argv[], int argc,
fprintf(stderr, "Command '%c' not found!\n", cmd);
}
- return(RIG_OK);
+ return (RIG_OK);
}
if (!(cmd_entry->flags & ARG_NOVFO) && *vfo_opt)
@@ -864,7 +864,7 @@ int rigctl_parse(RIG *my_rig, FILE *fin, FILE *fout, char *argv[], int argc,
if (scanfc(fin, "%s", arg1) < 1)
{
rig_debug(RIG_DEBUG_WARN, "%s: nothing to scan#7?\n", __func__);
- return(RIGCTL_PARSE_ERROR);
+ return (RIGCTL_PARSE_ERROR);
}
vfo = rig_parse_vfo(arg1);
@@ -880,7 +880,7 @@ int rigctl_parse(RIG *my_rig, FILE *fin, FILE *fout, char *argv[], int argc,
}
else if (retcode < 0)
{
- return(RIGCTL_PARSE_ERROR);
+ return (RIGCTL_PARSE_ERROR);
}
vfo = rig_parse_vfo(arg1);
@@ -904,7 +904,7 @@ int rigctl_parse(RIG *my_rig, FILE *fin, FILE *fout, char *argv[], int argc,
if (fgets(arg1, MAXARGSZ, fin) == NULL)
{
- return(RIGCTL_PARSE_ERROR);
+ return (RIGCTL_PARSE_ERROR);
}
if (arg1[0] == 0xa)
@@ -918,7 +918,7 @@ int rigctl_parse(RIG *my_rig, FILE *fin, FILE *fout, char *argv[], int argc,
if (fgets(arg1, MAXARGSZ, fin) == NULL)
{
- return(RIGCTL_PARSE_ERROR);
+ return (RIGCTL_PARSE_ERROR);
}
}
@@ -946,11 +946,11 @@ int rigctl_parse(RIG *my_rig, FILE *fin, FILE *fout, char *argv[], int argc,
{
fprintf(stderr, "Invalid arg for command '%s'\n",
cmd_entry->name);
- return(RIGCTL_PARSE_END);
+ return (RIGCTL_PARSE_END);
}
else if (retcode < 0)
{
- return(RIGCTL_PARSE_ERROR);
+ return (RIGCTL_PARSE_ERROR);
}
p1 = arg1;
@@ -975,7 +975,7 @@ int rigctl_parse(RIG *my_rig, FILE *fin, FILE *fout, char *argv[], int argc,
if (scanfc(fin, "%s", arg1) < 1)
{
rig_debug(RIG_DEBUG_WARN, "%s: nothing to scan#8?\n", __func__);
- return(RIGCTL_PARSE_ERROR);
+ return (RIGCTL_PARSE_ERROR);
}
p1 = arg1;
@@ -988,11 +988,11 @@ int rigctl_parse(RIG *my_rig, FILE *fin, FILE *fout, char *argv[], int argc,
{
fprintf(stderr, "Invalid arg for command '%s'\n",
cmd_entry->name);
- return(1);
+ return (1);
}
else if (retcode < 0)
{
- return(RIGCTL_PARSE_ERROR);
+ return (RIGCTL_PARSE_ERROR);
}
p1 = arg1;
@@ -1025,7 +1025,7 @@ int rigctl_parse(RIG *my_rig, FILE *fin, FILE *fout, char *argv[], int argc,
if (scanfc(fin, "%s", arg2) < 1)
{
rig_debug(RIG_DEBUG_WARN, "%s: nothing to scan#9?\n", __func__);
- return(RIGCTL_PARSE_ERROR);
+ return (RIGCTL_PARSE_ERROR);
}
p2 = arg2;
@@ -1040,11 +1040,11 @@ int rigctl_parse(RIG *my_rig, FILE *fin, FILE *fout, char *argv[], int argc,
{
fprintf(stderr, "Invalid arg for command '%s'\n",
cmd_entry->name);
- return(RIGCTL_PARSE_END);
+ return (RIGCTL_PARSE_END);
}
else if (retcode < 0)
{
- return(RIGCTL_PARSE_ERROR);
+ return (RIGCTL_PARSE_ERROR);
}
p2 = arg2;
@@ -1074,7 +1074,7 @@ int rigctl_parse(RIG *my_rig, FILE *fin, FILE *fout, char *argv[], int argc,
if (scanfc(fin, "%s", arg3) < 1)
{
rig_debug(RIG_DEBUG_WARN, "%s: nothing to scan#10?\n", __func__);
- return(RIGCTL_PARSE_ERROR);
+ return (RIGCTL_PARSE_ERROR);
}
p3 = arg3;
@@ -1090,11 +1090,11 @@ int rigctl_parse(RIG *my_rig, FILE *fin, FILE *fout, char *argv[], int argc,
fprintf(stderr,
"Invalid arg for command '%s'\n",
cmd_entry->name);
- return(RIGCTL_PARSE_END);
+ return (RIGCTL_PARSE_END);
}
else if (retcode < 0)
{
- return(RIGCTL_PARSE_ERROR);
+ return (RIGCTL_PARSE_ERROR);
}
p3 = arg3;
@@ -1121,13 +1121,13 @@ int rigctl_parse(RIG *my_rig, FILE *fin, FILE *fout, char *argv[], int argc,
if (!input_line)
{
fprintf_flush(fout, "\n");
- return(RIGCTL_PARSE_END);
+ return (RIGCTL_PARSE_END);
}
/* Q or q to quit */
if (!(strncasecmp(input_line, "q", 1)))
{
- return(RIGCTL_PARSE_END);
+ return (RIGCTL_PARSE_END);
}
/* '?' for help */
@@ -1135,13 +1135,13 @@ int rigctl_parse(RIG *my_rig, FILE *fin, FILE *fout, char *argv[], int argc,
{
usage_rig(fout);
fflush(fout);
- return(RIG_OK);
+ return (RIG_OK);
}
/* '#' for comment */
if (!(strncmp(input_line, "#", 1)))
{
- return(RIG_OK);
+ return (RIG_OK);
}
/* Blank line entered */
@@ -1149,7 +1149,7 @@ int rigctl_parse(RIG *my_rig, FILE *fin, FILE *fout, char *argv[], int argc,
{
fprintf(fout, "? for help, q to quit.\n");
fflush(fout);
- return(RIG_OK);
+ return (RIG_OK);
}
rig_debug(RIG_DEBUG_TRACE, "%s: input_line: %s\n", __func__, input_line);
@@ -1173,7 +1173,7 @@ readline_repeat:
{
/* Oops! Invoke GDB!! */
fprintf_flush(fout, "\n");
- return(RIGCTL_PARSE_END);
+ return (RIGCTL_PARSE_END);
}
/* At this point parsed_input contains the typed text of the command
@@ -1232,7 +1232,7 @@ readline_repeat:
{
fprintf(stderr,
"Valid multiple character command names contain alphanumeric characters plus '_'\n");
- return(RIG_OK);
+ return (RIG_OK);
}
}
@@ -1241,13 +1241,13 @@ readline_repeat:
/* Single '\' entered, prompt again */
else if ((*parsed_input[0] == '\\') && (strlen(parsed_input[0]) == 1))
{
- return(RIG_OK);
+ return (RIG_OK);
}
/* Multiple characters but no leading '\' */
else
{
fprintf(stderr, "Precede multiple character command names with '\\'\n");
- return(RIG_OK);
+ return (RIG_OK);
}
cmd_entry = find_cmd_entry(cmd);
@@ -1263,7 +1263,7 @@ readline_repeat:
fprintf(stderr, "Command '%c' not found!\n", cmd);
}
- return(RIG_OK);
+ return (RIG_OK);
}
/* If vfo_opt is enabled (-o|--vfo) check if already given
@@ -1288,7 +1288,7 @@ readline_repeat:
if (!input_line)
{
fprintf_flush(fout, "\n");
- return(RIGCTL_PARSE_END);
+ return (RIGCTL_PARSE_END);
}
/* Blank line entered */
@@ -1296,7 +1296,7 @@ readline_repeat:
{
fprintf(fout, "? for help, q to quit.\n");
fflush(fout);
- return(RIG_OK);
+ return (RIG_OK);
}
/* Get the first token of input, the rest, if any, will be
@@ -1311,7 +1311,7 @@ readline_repeat:
else
{
fprintf_flush(fout, "\n");
- return(RIGCTL_PARSE_END);
+ return (RIGCTL_PARSE_END);
}
}
@@ -1390,7 +1390,7 @@ readline_repeat:
{
fprintf(fout, "? for help, q to quit.\n");
fflush(fout);
- return(RIG_OK);
+ return (RIG_OK);
}
if (input_line)
@@ -1400,7 +1400,7 @@ readline_repeat:
else
{
fprintf_flush(fout, "\n");
- return(RIGCTL_PARSE_END);
+ return (RIGCTL_PARSE_END);
}
}
@@ -1452,7 +1452,7 @@ readline_repeat:
{
fprintf(fout, "? for help, q to quit.\n");
fflush(fout);
- return(RIG_OK);
+ return (RIG_OK);
}
result = strtok(input_line, " ");
@@ -1464,7 +1464,7 @@ readline_repeat:
else
{
fprintf_flush(fout, "\n");
- return(RIGCTL_PARSE_END);
+ return (RIGCTL_PARSE_END);
}
}
@@ -1518,7 +1518,7 @@ readline_repeat:
{
fprintf(fout, "? for help, q to quit.\n");
fflush(fout);
- return(RIG_OK);
+ return (RIG_OK);
}
result = strtok(input_line, " ");
@@ -1530,7 +1530,7 @@ readline_repeat:
else
{
fprintf_flush(fout, "\n");
- return(RIGCTL_PARSE_END);
+ return (RIGCTL_PARSE_END);
}
}
@@ -1584,7 +1584,7 @@ readline_repeat:
{
fprintf(fout, "? for help, q to quit.\n");
fflush(fout);
- return(RIG_OK);
+ return (RIG_OK);
}
result = strtok(input_line, " ");
@@ -1596,7 +1596,7 @@ readline_repeat:
else
{
fprintf_flush(fout, "\n");
- return(RIGCTL_PARSE_END);
+ return (RIGCTL_PARSE_END);
}
}
@@ -1679,7 +1679,8 @@ readline_repeat:
if (my_rig->state.comm_state == 0)
{
- rig_debug(RIG_DEBUG_WARN, "%s: %p rig not open...trying to reopen\n", __func__, &my_rig->state.comm_state);
+ rig_debug(RIG_DEBUG_WARN, "%s: %p rig not open...trying to reopen\n", __func__,
+ &my_rig->state.comm_state);
rig_open(my_rig);
}
@@ -1705,7 +1706,7 @@ readline_repeat:
if (sync_cb) { sync_cb(0); } /* unlock if necessary */
- return(retcode);
+ return (retcode);
}
if (retcode != RIG_OK)
@@ -1761,7 +1762,7 @@ readline_repeat:
if (sync_cb) { sync_cb(0); } /* unlock if necessary */
- return(retcode);
+ return (retcode);
}
@@ -1945,7 +1946,7 @@ int set_conf(RIG *my_rig, char *conf_parms)
if (!q)
{
- return(-RIG_EINVAL);
+ return (-RIG_EINVAL);
}
*q++ = '\0';
@@ -1960,13 +1961,13 @@ int set_conf(RIG *my_rig, char *conf_parms)
if (ret != RIG_OK)
{
- return(ret);
+ return (ret);
}
p = n;
}
- return(RIG_OK);
+ return (RIG_OK);
}
@@ -4622,7 +4623,7 @@ static int hasbinary(char *s, int len)
for (i = 0; i < len; ++i)
{
- if (!isascii(s[i])) { return(1); }
+ if (!isascii(s[i])) { return (1); }
}
return 0;
@@ -4888,7 +4889,7 @@ declare_proto_rig(halt)
/* a bit rough, TODO: clean daemon shutdown */
exit(0);
- return(RIG_OK);
+ return (RIG_OK);
}
@@ -4900,7 +4901,7 @@ declare_proto_rig(pause)
CHKSCN1ARG(sscanf(arg1, "%u", &seconds));
sleep(seconds);
- return(RIG_OK);
+ return (RIG_OK);
}
char rig_passwd[256];
@@ -4930,7 +4931,7 @@ declare_proto_rig(set_password)
strncpy(rig_passwd, passwd, sizeof(passwd) - 1);
rig_debug(RIG_DEBUG_ERR, "%s: set_password %s\n", __func__, rig_passwd);
fprintf(fout, "set_password %s\n", rig_passwd);
- return(RIG_OK);
+ return (RIG_OK);
}
/* '0x8d' */
diff --git a/tests/rigctlcom.c b/tests/rigctlcom.c
index 91bd2a4f2..0c3f38ce2 100644
--- a/tests/rigctlcom.c
+++ b/tests/rigctlcom.c
@@ -888,7 +888,7 @@ static int handle_ts2000(void *arg)
if (strcmp(arg, "SA;") == 0)
{
// should we silently fail with RIG_OK instead? TBD
- return(-RIG_ENIMPL);
+ return (-RIG_ENIMPL);
}
if (strlen(arg) > 3 && ((char *)arg)[2] == '1')
@@ -901,7 +901,7 @@ static int handle_ts2000(void *arg)
}
else
{
- return(-RIG_ENAVAIL);
+ return (-RIG_ENAVAIL);
}
}
diff --git a/tests/rigctld.c b/tests/rigctld.c
index 15e337e16..3ef0ae54a 100644
--- a/tests/rigctld.c
+++ b/tests/rigctld.c
@@ -567,11 +567,13 @@ int main(int argc, char *argv[])
}
multicast_port = atoi(optarg);
+
if (multicast_port == 0)
{
fprintf(stderr, "Invalid multicast port: %s\n", optarg);
exit(1);
}
+
break;
default:
@@ -773,8 +775,10 @@ int main(int argc, char *argv[])
saved_result = result;
- enum multicast_item_e items = RIG_MULTICAST_POLL | RIG_MULTICAST_TRANSCEIVE | RIG_MULTICAST_SPECTRUM;
- retcode = network_multicast_publisher_start(my_rig, multicast_addr, multicast_port, items);
+ enum multicast_item_e items = RIG_MULTICAST_POLL | RIG_MULTICAST_TRANSCEIVE |
+ RIG_MULTICAST_SPECTRUM;
+ retcode = network_multicast_publisher_start(my_rig, multicast_addr,
+ multicast_port, items);
if (retcode != RIG_OK)
{
@@ -1134,6 +1138,7 @@ void *handle_socket(void *arg)
do
{
mutex_rigctld(1);
+
if (!rig_opened)
{
retcode = rig_open(my_rig);
@@ -1141,6 +1146,7 @@ void *handle_socket(void *arg)
rig_debug(RIG_DEBUG_ERR, "%s: rig_open reopened retcode=%d\n", __func__,
retcode);
}
+
mutex_rigctld(0);
if (rig_opened) // only do this if rig is open
@@ -1176,12 +1182,15 @@ void *handle_socket(void *arg)
hl_usleep(1000 * 1000);
mutex_rigctld(1);
- if (!rig_opened) {
+
+ if (!rig_opened)
+ {
retcode = rig_open(my_rig);
rig_opened = retcode == RIG_OK ? 1 : 0;
rig_debug(RIG_DEBUG_ERR, "%s: rig_open retcode=%d, opened=%d\n", __func__,
- retcode, rig_opened);
+ retcode, rig_opened);
}
+
mutex_rigctld(0);
}
while (!ctrl_c && !rig_opened && retry-- > 0 && retcode != RIG_OK);
diff --git a/tests/rigmatrix.c b/tests/rigmatrix.c
index a382b0902..d1dbdab83 100644
--- a/tests/rigmatrix.c
+++ b/tests/rigmatrix.c
@@ -631,7 +631,7 @@ int main(int argc, char *argv[])
{
time_t gentime;
int set_or_get;
- int i,nbytes,nbytes_total=0;
+ int i, nbytes, nbytes_total = 0;
char *pbuf, prntbuf[4096];
rig_load_all_backends();
@@ -709,7 +709,8 @@ int main(int argc, char *argv[])
bitmap_func |= func;
nbytes = strlen("
| ") + strlen(s) + 1;
nbytes_total += nbytes;
- pbuf += snprintf(pbuf, sizeof(pbuf)-nbytes_total, "%s | ", s);
+ pbuf += snprintf(pbuf, sizeof(pbuf) - nbytes_total, "%s | ", s);
+
if (strlen(pbuf) > sizeof(pbuf) + nbytes)
{
printf("Buffer overflow in %s\n", __func__);
@@ -751,7 +752,8 @@ int main(int argc, char *argv[])
bitmap_level |= level;
nbytes = strlen(" | ") + strlen(s) + 1;
nbytes_total += nbytes;
- pbuf += snprintf(pbuf, sizeof(pbuf)-nbytes_total, "%s | ", s);
+ pbuf += snprintf(pbuf, sizeof(pbuf) - nbytes_total, "%s | ", s);
+
if (strlen(pbuf) > sizeof(pbuf) + nbytes)
{
printf("Buffer overflow in %s\n", __func__);
@@ -793,7 +795,8 @@ int main(int argc, char *argv[])
bitmap_parm |= parm;
nbytes = strlen(" | ") + strlen(s) + 1;
nbytes_total += nbytes;
- pbuf += snprintf(pbuf, sizeof(pbuf)-nbytes_total, "%s | ", s);
+ pbuf += snprintf(pbuf, sizeof(pbuf) - nbytes_total, "%s | ", s);
+
if (strlen(pbuf) > sizeof(pbuf) + nbytes)
{
printf("Buffer overflow in %s\n", __func__);
diff --git a/tests/testcookie.c b/tests/testcookie.c
index 1d50d85b7..5108e1792 100644
--- a/tests/testcookie.c
+++ b/tests/testcookie.c
@@ -36,6 +36,7 @@ static int test1()
if (retcode == RIG_OK) { printf("Test#1d OK\n"); }
else {printf("Test#1d Failed\n"); return 1;}
+
#endif
retcode = rig_cookie(NULL, RIG_COOKIE_RELEASE, cookie2, sizeof(cookie2));
@@ -88,16 +89,17 @@ static int test3_invalid_input()
{
int retcode;
char cookie[HAMLIB_COOKIE_SIZE];
- int n=0;
+ int n = 0;
/* Make sure any value smaller then HAMLIB_COOKIE_SIZE is rejected */
for (unsigned int i = 0; i < HAMLIB_COOKIE_SIZE; i++)
{
retcode = rig_cookie(NULL, RIG_COOKIE_GET, cookie, i);
- if (retcode != -RIG_EINVAL) { n++;printf("Test#3a failed at %d bytes\n", i); }
+ if (retcode != -RIG_EINVAL) { n++; printf("Test#3a failed at %d bytes\n", i); }
}
- if (n==0) printf("Test#3a OK\n");
+
+ if (n == 0) { printf("Test#3a OK\n"); }
/* Make sure a NULL cookie is ignored */
retcode = rig_cookie(NULL, RIG_COOKIE_GET, NULL, sizeof(cookie));
diff --git a/tests/testrigcaps.c b/tests/testrigcaps.c
index b9c6bb338..ce996512a 100644
--- a/tests/testrigcaps.c
+++ b/tests/testrigcaps.c
@@ -10,7 +10,9 @@ int main()
RIG *rig;
rig_set_debug_level(RIG_DEBUG_ERR);
rig = rig_init(1);
- if (rig == NULL) return 1;
+
+ if (rig == NULL) { return 1; }
+
printf("Offsets are OK (i.e. have not changed)\n");
return 0;
}