Reformat rigctld.c and rotctld.c

Several lines in each file benefitted from formatting so just reformat
the entire files into Linux C Style.
libusb-1-0
Nate Bargmann 2016-02-12 20:46:38 -06:00
rodzic e4e17ce862
commit 9b45fce776
2 zmienionych plików z 419 dodań i 413 usunięć

Wyświetl plik

@ -135,13 +135,10 @@ static void handle_error (enum rig_debug_level_e lvl, const char *msg)
NULL, e,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
// Default language
(LPTSTR)&lpMsgBuf, 0, NULL))
{
(LPTSTR)&lpMsgBuf, 0, NULL)) {
rig_debug (lvl, "%s: Network error %d: %s\n", msg, e, lpMsgBuf);
LocalFree(lpMsgBuf);
}
else
{
} else {
rig_debug (lvl, "%s: Network error %d\n", msg, e);
}
#else
@ -332,6 +329,7 @@ int main (int argc, char *argv[])
}
retcode = set_conf(my_rig, conf_parms);
if (retcode != RIG_OK) {
fprintf(stderr, "Config parameter error: %s\n", rigerror(retcode));
exit(2);
@ -375,6 +373,7 @@ int main (int argc, char *argv[])
}
retcode = rig_open(my_rig);
if (retcode != RIG_OK) {
fprintf(stderr,"rig_open: error = %s \n", rigerror(retcode));
exit(2);
@ -383,6 +382,7 @@ int main (int argc, char *argv[])
if (verbose > 0)
printf("Opened rig model %d, '%s'\n", my_rig->caps->rig_model,
my_rig->caps->model_name);
rig_debug(RIG_DEBUG_VERBOSE, "Backend version: %s, Status: %s\n",
my_rig->caps->version, rig_strstatus(my_rig->caps->status));
@ -423,8 +423,7 @@ int main (int argc, char *argv[])
}
saved_result = result;
do
{
do {
sock_listen = socket(result->ai_family, result->ai_socktype,
result->ai_protocol);
if (sock_listen < 0) {
@ -457,6 +456,7 @@ int main (int argc, char *argv[])
if (0 == bind(sock_listen, result->ai_addr, result->ai_addrlen)) {
break;
}
handle_error (RIG_DEBUG_WARN, "binding failed (trying next interface)");
#ifdef __MINGW32__
closesocket (sock_listen);
@ -466,8 +466,8 @@ int main (int argc, char *argv[])
} while ((result = result->ai_next) != NULL);
freeaddrinfo(saved_result); /* No longer needed */
if (NULL == result)
{
if (NULL == result) {
rig_debug(RIG_DEBUG_ERR, "bind error - no available interface\n");
exit (1);
}
@ -488,6 +488,7 @@ int main (int argc, char *argv[])
struct handle_data *arg;
arg = malloc(sizeof(struct handle_data));
if (!arg) {
rig_debug(RIG_DEBUG_ERR, "malloc: %s\n", strerror(errno));
exit (1);
@ -496,24 +497,25 @@ int main (int argc, char *argv[])
arg->rig = my_rig;
arg->clilen = sizeof (arg->cli_addr);
arg->sock = accept(sock_listen, (struct sockaddr *)&arg->cli_addr, &arg->clilen);
if (arg->sock < 0) {
handle_error (RIG_DEBUG_ERR, "accept");
break;
}
if ((retcode = getnameinfo ((struct sockaddr const *)&arg->cli_addr, arg->clilen, host, sizeof (host)
, serv, sizeof (serv), NI_NOFQDN)) < 0)
{
if ((retcode = getnameinfo ((struct sockaddr const *)&arg->cli_addr, arg->clilen, host,
sizeof (host), serv, sizeof (serv), NI_NOFQDN)) < 0) {
rig_debug (RIG_DEBUG_WARN, "Peer lookup error: %s", gai_strerror (retcode));
}
rig_debug(RIG_DEBUG_VERBOSE, "Connection opened from %s:%s\n",
host, serv);
rig_debug(RIG_DEBUG_VERBOSE, "Connection opened from %s:%s\n", host, serv);
#ifdef HAVE_PTHREAD
pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
retcode = pthread_create(&thread, &attr, handle_socket, arg);
if (retcode != 0) {
rig_debug(RIG_DEBUG_ERR, "pthread_create: %s\n", strerror(retcode));
break;
@ -521,8 +523,7 @@ int main (int argc, char *argv[])
#else
handle_socket(arg);
#endif
}
while (retcode == 0);
} while (retcode == 0);
rig_close(my_rig); /* close port */
rig_cleanup(my_rig); /* if you care about memory */
@ -549,6 +550,7 @@ void * handle_socket(void *arg)
#ifdef __MINGW32__
int sock_osfhandle = _open_osfhandle(handle_data_arg->sock, _O_RDONLY);
if (sock_osfhandle == -1) {
rig_debug(RIG_DEBUG_ERR, "_open_osfhandle error: %s\n", strerror(errno));
goto handle_exit;
@ -579,15 +581,14 @@ void * handle_socket(void *arg)
retcode = rigctl_parse(handle_data_arg->rig, fsockin, fsockout, NULL, 0);
if (ferror(fsockin) || ferror(fsockout))
retcode = 1;
}
while (retcode == 0 || retcode == 2);
} while (retcode == 0 || retcode == 2);
if ((retcode = getnameinfo ((struct sockaddr const *)&handle_data_arg->cli_addr
, handle_data_arg->clilen, host, sizeof (host)
, serv, sizeof (serv), NI_NOFQDN)) < 0)
{
if ((retcode = getnameinfo ((struct sockaddr const *)&handle_data_arg->cli_addr,
handle_data_arg->clilen, host, sizeof (host),
serv, sizeof (serv), NI_NOFQDN)) < 0) {
rig_debug (RIG_DEBUG_WARN, "Peer lookup error: %s", gai_strerror (retcode));
}
rig_debug(RIG_DEBUG_VERBOSE, "Connection closed from %s:%s\n",
host, serv);

Wyświetl plik

@ -119,6 +119,7 @@ static void handle_error (enum rig_debug_level_e lvl, const char *msg)
lpMsgBuf = (LPVOID)"Unknown error";
e = WSAGetLastError();
if (FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
@ -126,13 +127,10 @@ static void handle_error (enum rig_debug_level_e lvl, const char *msg)
NULL, e,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
// Default language
(LPTSTR)&lpMsgBuf, 0, NULL))
{
(LPTSTR)&lpMsgBuf, 0, NULL)) {
rig_debug (lvl, "%s: Network error %d: %s\n", msg, e, lpMsgBuf);
LocalFree(lpMsgBuf);
}
else
{
} else {
rig_debug (lvl, "%s: Network error %d\n", msg, e);
}
#else
@ -256,6 +254,7 @@ int main (int argc, char *argv[])
}
retcode = set_conf(my_rot, conf_parms);
if (retcode != RIG_OK) {
fprintf(stderr, "Config parameter error: %s\n", rigerror(retcode));
exit(2);
@ -286,6 +285,7 @@ int main (int argc, char *argv[])
}
retcode = rot_open(my_rot);
if (retcode != RIG_OK) {
fprintf(stderr,"rot_open: error = %s \n", rigerror(retcode));
exit(2);
@ -310,6 +310,7 @@ int main (int argc, char *argv[])
# endif
WSADATA wsadata;
if (WSAStartup(MAKEWORD(1,1), &wsadata) == SOCKET_ERROR) {
fprintf(stderr,"WSAStartup socket error\n");
exit(1);
@ -336,10 +337,10 @@ int main (int argc, char *argv[])
saved_result = result;
do
{
do {
sock_listen = socket(result->ai_family, result->ai_socktype,
result->ai_protocol);
if (sock_listen < 0) {
handle_error (RIG_DEBUG_ERR, "socket");
freeaddrinfo(result); /* No longer needed */
@ -358,6 +359,7 @@ int main (int argc, char *argv[])
/* allow IPv4 mapped to IPv6 clients, MS & BSD default this
to 1 i.e. disallowed */
sockopt = 0;
if (setsockopt(sock_listen, IPPROTO_IPV6, IPV6_V6ONLY,
(char *)&sockopt, sizeof(sockopt)) < 0) {
handle_error (RIG_DEBUG_ERR, "setsockopt");
@ -379,8 +381,8 @@ int main (int argc, char *argv[])
} while ((result = result->ai_next) != NULL);
freeaddrinfo(saved_result); /* No longer needed */
if (NULL == result)
{
if (NULL == result) {
rig_debug(RIG_DEBUG_ERR, "bind error - no available interface\n");
exit (1);
}
@ -401,6 +403,7 @@ int main (int argc, char *argv[])
struct handle_data *arg;
arg = malloc(sizeof(struct handle_data));
if (!arg) {
rig_debug(RIG_DEBUG_ERR, "malloc: %s\n", strerror(errno));
exit (1);
@ -410,16 +413,18 @@ int main (int argc, char *argv[])
arg->clilen = sizeof(arg->cli_addr);
arg->sock = accept(sock_listen, (struct sockaddr *) &arg->cli_addr,
&arg->clilen);
if (arg->sock < 0) {
handle_error (RIG_DEBUG_ERR, "accept");
break;
}
if ((retcode = getnameinfo ((struct sockaddr const *)&arg->cli_addr, arg->clilen, host, sizeof (host)
, serv, sizeof (serv), NI_NOFQDN)) < 0)
{
if ((retcode = getnameinfo ((struct sockaddr const *)&arg->cli_addr, arg->clilen,
host, sizeof (host), serv, sizeof (serv),
NI_NOFQDN)) < 0) {
rig_debug (RIG_DEBUG_WARN, "Peer lookup error: %s", gai_strerror (retcode));
}
rig_debug(RIG_DEBUG_VERBOSE, "Connection opened from %s:%s\n",
host, serv);
@ -428,6 +433,7 @@ int main (int argc, char *argv[])
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
retcode = pthread_create(&thread, &attr, handle_socket, arg);
if (retcode != 0) {
rig_debug(RIG_DEBUG_ERR, "pthread_create: %s\n", strerror(retcode));
break;
@ -435,8 +441,7 @@ int main (int argc, char *argv[])
#else
handle_socket(arg);
#endif
}
while (retcode == 0);
} while (retcode == 0);
rot_close(my_rot); /* close port */
rot_cleanup(my_rot); /* if you care about memory */
@ -463,6 +468,7 @@ void * handle_socket(void *arg)
#ifdef __MINGW32__
int sock_osfhandle = _open_osfhandle(handle_data_arg->sock, _O_RDONLY);
if (sock_osfhandle == -1) {
rig_debug(RIG_DEBUG_ERR, "_open_osfhandle error: %s\n", strerror(errno));
goto handle_exit;
@ -492,15 +498,14 @@ void * handle_socket(void *arg)
retcode = rotctl_parse(handle_data_arg->rot, fsockin, fsockout, NULL, 0);
if (ferror(fsockin) || ferror(fsockout))
retcode = 1;
}
while (retcode == 0 || retcode == 2);
} while (retcode == 0 || retcode == 2);
if ((retcode = getnameinfo ((struct sockaddr const *)&handle_data_arg->cli_addr
, handle_data_arg->clilen, host, sizeof (host)
, serv, sizeof (serv), NI_NOFQDN)) < 0)
{
if ((retcode = getnameinfo ((struct sockaddr const *)&handle_data_arg->cli_addr,
handle_data_arg->clilen, host, sizeof (host),
serv, sizeof (serv), NI_NOFQDN)) < 0) {
rig_debug (RIG_DEBUG_WARN, "Peer lookup error: %s", gai_strerror (retcode));
}
rig_debug(RIG_DEBUG_VERBOSE, "Connection closed from %s:%s\n",
host, serv);