kopia lustrzana https://github.com/Hamlib/Hamlib
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
rodzic
e4e17ce862
commit
9b45fce776
|
@ -135,13 +135,10 @@ static void handle_error (enum rig_debug_level_e lvl, const char *msg)
|
||||||
NULL, e,
|
NULL, e,
|
||||||
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
|
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
|
||||||
// Default language
|
// Default language
|
||||||
(LPTSTR)&lpMsgBuf, 0, NULL))
|
(LPTSTR)&lpMsgBuf, 0, NULL)) {
|
||||||
{
|
|
||||||
rig_debug (lvl, "%s: Network error %d: %s\n", msg, e, lpMsgBuf);
|
rig_debug (lvl, "%s: Network error %d: %s\n", msg, e, lpMsgBuf);
|
||||||
LocalFree(lpMsgBuf);
|
LocalFree(lpMsgBuf);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
rig_debug (lvl, "%s: Network error %d\n", msg, e);
|
rig_debug (lvl, "%s: Network error %d\n", msg, e);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
@ -332,6 +329,7 @@ int main (int argc, char *argv[])
|
||||||
}
|
}
|
||||||
|
|
||||||
retcode = set_conf(my_rig, conf_parms);
|
retcode = set_conf(my_rig, conf_parms);
|
||||||
|
|
||||||
if (retcode != RIG_OK) {
|
if (retcode != RIG_OK) {
|
||||||
fprintf(stderr, "Config parameter error: %s\n", rigerror(retcode));
|
fprintf(stderr, "Config parameter error: %s\n", rigerror(retcode));
|
||||||
exit(2);
|
exit(2);
|
||||||
|
@ -375,6 +373,7 @@ int main (int argc, char *argv[])
|
||||||
}
|
}
|
||||||
|
|
||||||
retcode = rig_open(my_rig);
|
retcode = rig_open(my_rig);
|
||||||
|
|
||||||
if (retcode != RIG_OK) {
|
if (retcode != RIG_OK) {
|
||||||
fprintf(stderr,"rig_open: error = %s \n", rigerror(retcode));
|
fprintf(stderr,"rig_open: error = %s \n", rigerror(retcode));
|
||||||
exit(2);
|
exit(2);
|
||||||
|
@ -383,6 +382,7 @@ int main (int argc, char *argv[])
|
||||||
if (verbose > 0)
|
if (verbose > 0)
|
||||||
printf("Opened rig model %d, '%s'\n", my_rig->caps->rig_model,
|
printf("Opened rig model %d, '%s'\n", my_rig->caps->rig_model,
|
||||||
my_rig->caps->model_name);
|
my_rig->caps->model_name);
|
||||||
|
|
||||||
rig_debug(RIG_DEBUG_VERBOSE, "Backend version: %s, Status: %s\n",
|
rig_debug(RIG_DEBUG_VERBOSE, "Backend version: %s, Status: %s\n",
|
||||||
my_rig->caps->version, rig_strstatus(my_rig->caps->status));
|
my_rig->caps->version, rig_strstatus(my_rig->caps->status));
|
||||||
|
|
||||||
|
@ -423,8 +423,7 @@ int main (int argc, char *argv[])
|
||||||
}
|
}
|
||||||
saved_result = result;
|
saved_result = result;
|
||||||
|
|
||||||
do
|
do {
|
||||||
{
|
|
||||||
sock_listen = socket(result->ai_family, result->ai_socktype,
|
sock_listen = socket(result->ai_family, result->ai_socktype,
|
||||||
result->ai_protocol);
|
result->ai_protocol);
|
||||||
if (sock_listen < 0) {
|
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)) {
|
if (0 == bind(sock_listen, result->ai_addr, result->ai_addrlen)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
handle_error (RIG_DEBUG_WARN, "binding failed (trying next interface)");
|
handle_error (RIG_DEBUG_WARN, "binding failed (trying next interface)");
|
||||||
#ifdef __MINGW32__
|
#ifdef __MINGW32__
|
||||||
closesocket (sock_listen);
|
closesocket (sock_listen);
|
||||||
|
@ -466,8 +466,8 @@ int main (int argc, char *argv[])
|
||||||
} while ((result = result->ai_next) != NULL);
|
} while ((result = result->ai_next) != NULL);
|
||||||
|
|
||||||
freeaddrinfo(saved_result); /* No longer needed */
|
freeaddrinfo(saved_result); /* No longer needed */
|
||||||
if (NULL == result)
|
|
||||||
{
|
if (NULL == result) {
|
||||||
rig_debug(RIG_DEBUG_ERR, "bind error - no available interface\n");
|
rig_debug(RIG_DEBUG_ERR, "bind error - no available interface\n");
|
||||||
exit (1);
|
exit (1);
|
||||||
}
|
}
|
||||||
|
@ -488,6 +488,7 @@ int main (int argc, char *argv[])
|
||||||
struct handle_data *arg;
|
struct handle_data *arg;
|
||||||
|
|
||||||
arg = malloc(sizeof(struct handle_data));
|
arg = malloc(sizeof(struct handle_data));
|
||||||
|
|
||||||
if (!arg) {
|
if (!arg) {
|
||||||
rig_debug(RIG_DEBUG_ERR, "malloc: %s\n", strerror(errno));
|
rig_debug(RIG_DEBUG_ERR, "malloc: %s\n", strerror(errno));
|
||||||
exit (1);
|
exit (1);
|
||||||
|
@ -496,24 +497,25 @@ int main (int argc, char *argv[])
|
||||||
arg->rig = my_rig;
|
arg->rig = my_rig;
|
||||||
arg->clilen = sizeof (arg->cli_addr);
|
arg->clilen = sizeof (arg->cli_addr);
|
||||||
arg->sock = accept(sock_listen, (struct sockaddr *)&arg->cli_addr, &arg->clilen);
|
arg->sock = accept(sock_listen, (struct sockaddr *)&arg->cli_addr, &arg->clilen);
|
||||||
|
|
||||||
if (arg->sock < 0) {
|
if (arg->sock < 0) {
|
||||||
handle_error (RIG_DEBUG_ERR, "accept");
|
handle_error (RIG_DEBUG_ERR, "accept");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((retcode = getnameinfo ((struct sockaddr const *)&arg->cli_addr, arg->clilen, host, sizeof (host)
|
if ((retcode = getnameinfo ((struct sockaddr const *)&arg->cli_addr, arg->clilen, host,
|
||||||
, serv, sizeof (serv), NI_NOFQDN)) < 0)
|
sizeof (host), serv, sizeof (serv), NI_NOFQDN)) < 0) {
|
||||||
{
|
|
||||||
rig_debug (RIG_DEBUG_WARN, "Peer lookup error: %s", gai_strerror (retcode));
|
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
|
#ifdef HAVE_PTHREAD
|
||||||
pthread_attr_init(&attr);
|
pthread_attr_init(&attr);
|
||||||
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
|
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
|
||||||
|
|
||||||
retcode = pthread_create(&thread, &attr, handle_socket, arg);
|
retcode = pthread_create(&thread, &attr, handle_socket, arg);
|
||||||
|
|
||||||
if (retcode != 0) {
|
if (retcode != 0) {
|
||||||
rig_debug(RIG_DEBUG_ERR, "pthread_create: %s\n", strerror(retcode));
|
rig_debug(RIG_DEBUG_ERR, "pthread_create: %s\n", strerror(retcode));
|
||||||
break;
|
break;
|
||||||
|
@ -521,8 +523,7 @@ int main (int argc, char *argv[])
|
||||||
#else
|
#else
|
||||||
handle_socket(arg);
|
handle_socket(arg);
|
||||||
#endif
|
#endif
|
||||||
}
|
} while (retcode == 0);
|
||||||
while (retcode == 0);
|
|
||||||
|
|
||||||
rig_close(my_rig); /* close port */
|
rig_close(my_rig); /* close port */
|
||||||
rig_cleanup(my_rig); /* if you care about memory */
|
rig_cleanup(my_rig); /* if you care about memory */
|
||||||
|
@ -549,6 +550,7 @@ void * handle_socket(void *arg)
|
||||||
|
|
||||||
#ifdef __MINGW32__
|
#ifdef __MINGW32__
|
||||||
int sock_osfhandle = _open_osfhandle(handle_data_arg->sock, _O_RDONLY);
|
int sock_osfhandle = _open_osfhandle(handle_data_arg->sock, _O_RDONLY);
|
||||||
|
|
||||||
if (sock_osfhandle == -1) {
|
if (sock_osfhandle == -1) {
|
||||||
rig_debug(RIG_DEBUG_ERR, "_open_osfhandle error: %s\n", strerror(errno));
|
rig_debug(RIG_DEBUG_ERR, "_open_osfhandle error: %s\n", strerror(errno));
|
||||||
goto handle_exit;
|
goto handle_exit;
|
||||||
|
@ -579,15 +581,14 @@ void * handle_socket(void *arg)
|
||||||
retcode = rigctl_parse(handle_data_arg->rig, fsockin, fsockout, NULL, 0);
|
retcode = rigctl_parse(handle_data_arg->rig, fsockin, fsockout, NULL, 0);
|
||||||
if (ferror(fsockin) || ferror(fsockout))
|
if (ferror(fsockin) || ferror(fsockout))
|
||||||
retcode = 1;
|
retcode = 1;
|
||||||
}
|
} while (retcode == 0 || retcode == 2);
|
||||||
while (retcode == 0 || retcode == 2);
|
|
||||||
|
|
||||||
if ((retcode = getnameinfo ((struct sockaddr const *)&handle_data_arg->cli_addr
|
if ((retcode = getnameinfo ((struct sockaddr const *)&handle_data_arg->cli_addr,
|
||||||
, handle_data_arg->clilen, host, sizeof (host)
|
handle_data_arg->clilen, host, sizeof (host),
|
||||||
, serv, sizeof (serv), NI_NOFQDN)) < 0)
|
serv, sizeof (serv), NI_NOFQDN)) < 0) {
|
||||||
{
|
|
||||||
rig_debug (RIG_DEBUG_WARN, "Peer lookup error: %s", gai_strerror (retcode));
|
rig_debug (RIG_DEBUG_WARN, "Peer lookup error: %s", gai_strerror (retcode));
|
||||||
}
|
}
|
||||||
|
|
||||||
rig_debug(RIG_DEBUG_VERBOSE, "Connection closed from %s:%s\n",
|
rig_debug(RIG_DEBUG_VERBOSE, "Connection closed from %s:%s\n",
|
||||||
host, serv);
|
host, serv);
|
||||||
|
|
||||||
|
|
|
@ -119,6 +119,7 @@ static void handle_error (enum rig_debug_level_e lvl, const char *msg)
|
||||||
|
|
||||||
lpMsgBuf = (LPVOID)"Unknown error";
|
lpMsgBuf = (LPVOID)"Unknown error";
|
||||||
e = WSAGetLastError();
|
e = WSAGetLastError();
|
||||||
|
|
||||||
if (FormatMessage(
|
if (FormatMessage(
|
||||||
FORMAT_MESSAGE_ALLOCATE_BUFFER |
|
FORMAT_MESSAGE_ALLOCATE_BUFFER |
|
||||||
FORMAT_MESSAGE_FROM_SYSTEM |
|
FORMAT_MESSAGE_FROM_SYSTEM |
|
||||||
|
@ -126,13 +127,10 @@ static void handle_error (enum rig_debug_level_e lvl, const char *msg)
|
||||||
NULL, e,
|
NULL, e,
|
||||||
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
|
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
|
||||||
// Default language
|
// Default language
|
||||||
(LPTSTR)&lpMsgBuf, 0, NULL))
|
(LPTSTR)&lpMsgBuf, 0, NULL)) {
|
||||||
{
|
|
||||||
rig_debug (lvl, "%s: Network error %d: %s\n", msg, e, lpMsgBuf);
|
rig_debug (lvl, "%s: Network error %d: %s\n", msg, e, lpMsgBuf);
|
||||||
LocalFree(lpMsgBuf);
|
LocalFree(lpMsgBuf);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
rig_debug (lvl, "%s: Network error %d\n", msg, e);
|
rig_debug (lvl, "%s: Network error %d\n", msg, e);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
@ -256,6 +254,7 @@ int main (int argc, char *argv[])
|
||||||
}
|
}
|
||||||
|
|
||||||
retcode = set_conf(my_rot, conf_parms);
|
retcode = set_conf(my_rot, conf_parms);
|
||||||
|
|
||||||
if (retcode != RIG_OK) {
|
if (retcode != RIG_OK) {
|
||||||
fprintf(stderr, "Config parameter error: %s\n", rigerror(retcode));
|
fprintf(stderr, "Config parameter error: %s\n", rigerror(retcode));
|
||||||
exit(2);
|
exit(2);
|
||||||
|
@ -286,6 +285,7 @@ int main (int argc, char *argv[])
|
||||||
}
|
}
|
||||||
|
|
||||||
retcode = rot_open(my_rot);
|
retcode = rot_open(my_rot);
|
||||||
|
|
||||||
if (retcode != RIG_OK) {
|
if (retcode != RIG_OK) {
|
||||||
fprintf(stderr,"rot_open: error = %s \n", rigerror(retcode));
|
fprintf(stderr,"rot_open: error = %s \n", rigerror(retcode));
|
||||||
exit(2);
|
exit(2);
|
||||||
|
@ -310,6 +310,7 @@ int main (int argc, char *argv[])
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
WSADATA wsadata;
|
WSADATA wsadata;
|
||||||
|
|
||||||
if (WSAStartup(MAKEWORD(1,1), &wsadata) == SOCKET_ERROR) {
|
if (WSAStartup(MAKEWORD(1,1), &wsadata) == SOCKET_ERROR) {
|
||||||
fprintf(stderr,"WSAStartup socket error\n");
|
fprintf(stderr,"WSAStartup socket error\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
|
@ -336,10 +337,10 @@ int main (int argc, char *argv[])
|
||||||
|
|
||||||
saved_result = result;
|
saved_result = result;
|
||||||
|
|
||||||
do
|
do {
|
||||||
{
|
|
||||||
sock_listen = socket(result->ai_family, result->ai_socktype,
|
sock_listen = socket(result->ai_family, result->ai_socktype,
|
||||||
result->ai_protocol);
|
result->ai_protocol);
|
||||||
|
|
||||||
if (sock_listen < 0) {
|
if (sock_listen < 0) {
|
||||||
handle_error (RIG_DEBUG_ERR, "socket");
|
handle_error (RIG_DEBUG_ERR, "socket");
|
||||||
freeaddrinfo(result); /* No longer needed */
|
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
|
/* allow IPv4 mapped to IPv6 clients, MS & BSD default this
|
||||||
to 1 i.e. disallowed */
|
to 1 i.e. disallowed */
|
||||||
sockopt = 0;
|
sockopt = 0;
|
||||||
|
|
||||||
if (setsockopt(sock_listen, IPPROTO_IPV6, IPV6_V6ONLY,
|
if (setsockopt(sock_listen, IPPROTO_IPV6, IPV6_V6ONLY,
|
||||||
(char *)&sockopt, sizeof(sockopt)) < 0) {
|
(char *)&sockopt, sizeof(sockopt)) < 0) {
|
||||||
handle_error (RIG_DEBUG_ERR, "setsockopt");
|
handle_error (RIG_DEBUG_ERR, "setsockopt");
|
||||||
|
@ -379,8 +381,8 @@ int main (int argc, char *argv[])
|
||||||
} while ((result = result->ai_next) != NULL);
|
} while ((result = result->ai_next) != NULL);
|
||||||
|
|
||||||
freeaddrinfo(saved_result); /* No longer needed */
|
freeaddrinfo(saved_result); /* No longer needed */
|
||||||
if (NULL == result)
|
|
||||||
{
|
if (NULL == result) {
|
||||||
rig_debug(RIG_DEBUG_ERR, "bind error - no available interface\n");
|
rig_debug(RIG_DEBUG_ERR, "bind error - no available interface\n");
|
||||||
exit (1);
|
exit (1);
|
||||||
}
|
}
|
||||||
|
@ -401,6 +403,7 @@ int main (int argc, char *argv[])
|
||||||
struct handle_data *arg;
|
struct handle_data *arg;
|
||||||
|
|
||||||
arg = malloc(sizeof(struct handle_data));
|
arg = malloc(sizeof(struct handle_data));
|
||||||
|
|
||||||
if (!arg) {
|
if (!arg) {
|
||||||
rig_debug(RIG_DEBUG_ERR, "malloc: %s\n", strerror(errno));
|
rig_debug(RIG_DEBUG_ERR, "malloc: %s\n", strerror(errno));
|
||||||
exit (1);
|
exit (1);
|
||||||
|
@ -410,16 +413,18 @@ int main (int argc, char *argv[])
|
||||||
arg->clilen = sizeof(arg->cli_addr);
|
arg->clilen = sizeof(arg->cli_addr);
|
||||||
arg->sock = accept(sock_listen, (struct sockaddr *) &arg->cli_addr,
|
arg->sock = accept(sock_listen, (struct sockaddr *) &arg->cli_addr,
|
||||||
&arg->clilen);
|
&arg->clilen);
|
||||||
|
|
||||||
if (arg->sock < 0) {
|
if (arg->sock < 0) {
|
||||||
handle_error (RIG_DEBUG_ERR, "accept");
|
handle_error (RIG_DEBUG_ERR, "accept");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((retcode = getnameinfo ((struct sockaddr const *)&arg->cli_addr, arg->clilen, host, sizeof (host)
|
if ((retcode = getnameinfo ((struct sockaddr const *)&arg->cli_addr, arg->clilen,
|
||||||
, serv, sizeof (serv), NI_NOFQDN)) < 0)
|
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_WARN, "Peer lookup error: %s", gai_strerror (retcode));
|
||||||
}
|
}
|
||||||
|
|
||||||
rig_debug(RIG_DEBUG_VERBOSE, "Connection opened from %s:%s\n",
|
rig_debug(RIG_DEBUG_VERBOSE, "Connection opened from %s:%s\n",
|
||||||
host, serv);
|
host, serv);
|
||||||
|
|
||||||
|
@ -428,6 +433,7 @@ int main (int argc, char *argv[])
|
||||||
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
|
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
|
||||||
|
|
||||||
retcode = pthread_create(&thread, &attr, handle_socket, arg);
|
retcode = pthread_create(&thread, &attr, handle_socket, arg);
|
||||||
|
|
||||||
if (retcode != 0) {
|
if (retcode != 0) {
|
||||||
rig_debug(RIG_DEBUG_ERR, "pthread_create: %s\n", strerror(retcode));
|
rig_debug(RIG_DEBUG_ERR, "pthread_create: %s\n", strerror(retcode));
|
||||||
break;
|
break;
|
||||||
|
@ -435,8 +441,7 @@ int main (int argc, char *argv[])
|
||||||
#else
|
#else
|
||||||
handle_socket(arg);
|
handle_socket(arg);
|
||||||
#endif
|
#endif
|
||||||
}
|
} while (retcode == 0);
|
||||||
while (retcode == 0);
|
|
||||||
|
|
||||||
rot_close(my_rot); /* close port */
|
rot_close(my_rot); /* close port */
|
||||||
rot_cleanup(my_rot); /* if you care about memory */
|
rot_cleanup(my_rot); /* if you care about memory */
|
||||||
|
@ -463,6 +468,7 @@ void * handle_socket(void *arg)
|
||||||
|
|
||||||
#ifdef __MINGW32__
|
#ifdef __MINGW32__
|
||||||
int sock_osfhandle = _open_osfhandle(handle_data_arg->sock, _O_RDONLY);
|
int sock_osfhandle = _open_osfhandle(handle_data_arg->sock, _O_RDONLY);
|
||||||
|
|
||||||
if (sock_osfhandle == -1) {
|
if (sock_osfhandle == -1) {
|
||||||
rig_debug(RIG_DEBUG_ERR, "_open_osfhandle error: %s\n", strerror(errno));
|
rig_debug(RIG_DEBUG_ERR, "_open_osfhandle error: %s\n", strerror(errno));
|
||||||
goto handle_exit;
|
goto handle_exit;
|
||||||
|
@ -492,15 +498,14 @@ void * handle_socket(void *arg)
|
||||||
retcode = rotctl_parse(handle_data_arg->rot, fsockin, fsockout, NULL, 0);
|
retcode = rotctl_parse(handle_data_arg->rot, fsockin, fsockout, NULL, 0);
|
||||||
if (ferror(fsockin) || ferror(fsockout))
|
if (ferror(fsockin) || ferror(fsockout))
|
||||||
retcode = 1;
|
retcode = 1;
|
||||||
}
|
} while (retcode == 0 || retcode == 2);
|
||||||
while (retcode == 0 || retcode == 2);
|
|
||||||
|
|
||||||
if ((retcode = getnameinfo ((struct sockaddr const *)&handle_data_arg->cli_addr
|
if ((retcode = getnameinfo ((struct sockaddr const *)&handle_data_arg->cli_addr,
|
||||||
, handle_data_arg->clilen, host, sizeof (host)
|
handle_data_arg->clilen, host, sizeof (host),
|
||||||
, serv, sizeof (serv), NI_NOFQDN)) < 0)
|
serv, sizeof (serv), NI_NOFQDN)) < 0) {
|
||||||
{
|
|
||||||
rig_debug (RIG_DEBUG_WARN, "Peer lookup error: %s", gai_strerror (retcode));
|
rig_debug (RIG_DEBUG_WARN, "Peer lookup error: %s", gai_strerror (retcode));
|
||||||
}
|
}
|
||||||
|
|
||||||
rig_debug(RIG_DEBUG_VERBOSE, "Connection closed from %s:%s\n",
|
rig_debug(RIG_DEBUG_VERBOSE, "Connection closed from %s:%s\n",
|
||||||
host, serv);
|
host, serv);
|
||||||
|
|
||||||
|
|
Ładowanie…
Reference in New Issue