add util files

This commit is contained in:
Gerolf Ziegenhain 2016-10-04 18:35:56 +02:00
parent 5dad7c3f64
commit 6163a138ce
3 changed files with 30 additions and 14 deletions

View File

@ -45,20 +45,6 @@ char last_sender[16];
/* settings */ /* settings */
int translate = 1; int translate = 1;
int audio_status = 1; int audio_status = 1;
int kbhit (void)
{
struct timeval tv;
fd_set rdfs;
tv.tv_sec = 0;
tv.tv_usec = 0;
FD_ZERO(&rdfs);
FD_SET (STDIN_FILENO, &rdfs);
select (STDIN_FILENO+1, &rdfs, NULL, NULL, &tv);
return FD_ISSET(STDIN_FILENO, &rdfs);
}
/* get sockaddr, IPv4 or IPv6: */ /* get sockaddr, IPv4 or IPv6: */

View File

@ -29,4 +29,18 @@ long fastclock(void)
return r; return r;
} }
int kbhit (void)
{
struct timeval tv;
fd_set rdfs;
tv.tv_sec = 0;
tv.tv_usec = 0;
FD_ZERO(&rdfs);
FD_SET (STDIN_FILENO, &rdfs);
select (STDIN_FILENO+1, &rdfs, NULL, NULL, &tv);
return FD_ISSET(STDIN_FILENO, &rdfs);
}

View File

@ -1,5 +1,20 @@
#include <time.h> #include <time.h>
#include <sys/time.h> #include <sys/time.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
#include <netdb.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <math.h>
#include <fcntl.h>
#include <pthread.h>
#include <signal.h>
#include <arpa/inet.h>
#ifdef __MACH__ #ifdef __MACH__
@ -10,4 +25,5 @@
void current_utc_time(struct timespec *ts); void current_utc_time(struct timespec *ts);
long fastclock(void); long fastclock(void);
int kbhit (void);