add util files

This commit is contained in:
Gerolf Ziegenhain 2016-10-04 18:36:58 +02:00
parent 6163a138ce
commit e01c86a248
3 changed files with 12 additions and 10 deletions

View File

@ -47,16 +47,6 @@ int translate = 1;
int audio_status = 1; int audio_status = 1;
/* get sockaddr, IPv4 or IPv6: */
void *get_in_addr(struct sockaddr *sa)
{
if (sa->sa_family == AF_INET) {
return &(((struct sockaddr_in*)sa)->sin_addr);
}
return &(((struct sockaddr_in6*)sa)->sin6_addr);
}
// disconnect from the server // disconnect from the server
void inthandler(int sig) void inthandler(int sig)

View File

@ -44,3 +44,14 @@ int kbhit (void)
return FD_ISSET(STDIN_FILENO, &rdfs); return FD_ISSET(STDIN_FILENO, &rdfs);
} }
/* get sockaddr, IPv4 or IPv6: */
void *get_in_addr(struct sockaddr *sa)
{
if (sa->sa_family == AF_INET) {
return &(((struct sockaddr_in*)sa)->sin_addr);
}
return &(((struct sockaddr_in6*)sa)->sin6_addr);
}

View File

@ -26,4 +26,5 @@
void current_utc_time(struct timespec *ts); void current_utc_time(struct timespec *ts);
long fastclock(void); long fastclock(void);
int kbhit (void); int kbhit (void);
void *get_in_addr(struct sockaddr *sa);