Import Upstream version 1.9.5.2
This commit is contained in:
1 parent
9602397440
commit
18176a4efe
51 files changed
+46043
-361
No files matched your search
@@ -15,9 +15,9 @@
|
||||
along with g15daemon; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
(c) 2006 Mike Lampard, Philip Lawatsch, and others
|
||||
(c) 2006-2008 Mike Lampard, Philip Lawatsch, and others
|
||||
|
||||
$Revision: 322 $ - $Date: 2007-11-29 01:04:29 +0100 (Thu, 29 Nov 2007) $ $Author: mlampard $
|
||||
$Revision: 451 $ - $Date: 2008-01-25 15:15:04 +1030 (Fri, 25 Jan 2008) $ $Author: mlampard $
|
||||
|
||||
This daemon listens on localhost port 15550 for client connections,
|
||||
and arbitrates LCD display. Allows for multiple simultaneous clients.
|
||||
@@ -25,6 +25,7 @@
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/wait.h>
|
||||
@@ -33,6 +34,7 @@
|
||||
#include <unistd.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <config.h>
|
||||
|
||||
@@ -51,14 +53,61 @@ const char *g15daemon_version () {
|
||||
return VERSION;
|
||||
}
|
||||
|
||||
#ifdef HAVE_BACKTRACE
|
||||
|
||||
#include <signal.h>
|
||||
#ifdef HAVE_EXECINFO_H
|
||||
#include <execinfo.h>
|
||||
#endif
|
||||
#define BACKTRACE_LEN 100
|
||||
_Bool segv_init = 0;
|
||||
|
||||
/* sighandler function to print backtrace on segfault */
|
||||
|
||||
void g15_sighandler(int sig) {
|
||||
int i,nptrs;
|
||||
void *buf[BACKTRACE_LEN];
|
||||
char **btfuncs;
|
||||
|
||||
switch (sig) {
|
||||
case SIGSEGV:
|
||||
#ifdef HAVE_EXECINFO_H
|
||||
fprintf(stderr, "The application (or it's libraries) caught a Segmentation Fault. Backtrace follows:\n");
|
||||
nptrs = backtrace(buf,BACKTRACE_LEN);
|
||||
|
||||
btfuncs = backtrace_symbols(buf,nptrs);
|
||||
if(btfuncs == NULL)
|
||||
return;
|
||||
|
||||
for(i=0;i<nptrs;i++)
|
||||
fprintf(stderr,"Backtrace: %s\n",btfuncs[i]);
|
||||
fprintf(stderr,"End of Backtrace.\n");
|
||||
free(btfuncs);
|
||||
exit(1);
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
int new_g15_screen(int screentype)
|
||||
{
|
||||
struct sigaction new_sigaction;
|
||||
int g15screen_fd;
|
||||
struct sockaddr_in serv_addr;
|
||||
static int sighandler_init=0;
|
||||
/* raise the priority of our packets */
|
||||
int tos = 0x6;
|
||||
|
||||
char buffer[256];
|
||||
if(sighandler_init==0) {
|
||||
#ifdef HAVE_BACKTRACE
|
||||
new_sigaction.sa_handler = g15_sighandler;
|
||||
new_sigaction.sa_flags = 0;
|
||||
sigaction(SIGSEGV,&new_sigaction,NULL);
|
||||
#endif
|
||||
sighandler_init=1;
|
||||
}
|
||||
|
||||
g15screen_fd = socket(AF_INET, SOCK_STREAM, 0);
|
||||
if (g15screen_fd < 0)
|
||||
@@ -217,6 +266,10 @@ unsigned long g15_send_cmd (int sock, unsigned char command, unsigned char value
|
||||
packet[0] = (unsigned char)command;
|
||||
retval = send( sock, packet, 1, MSG_OOB );
|
||||
break;
|
||||
case G15DAEMON_NEVER_SELECT:
|
||||
packet[0] = (unsigned char)command;
|
||||
retval = send( sock, packet, 1, MSG_OOB );
|
||||
break;
|
||||
case G15DAEMON_GET_KEYSTATE:{
|
||||
retval = 0;
|
||||
unsigned long keystate = 0;
|
||||
@@ -233,12 +286,12 @@ unsigned long g15_send_cmd (int sock, unsigned char command, unsigned char value
|
||||
case G15DAEMON_IS_USER_SELECTED:{
|
||||
packet[0] = (unsigned char)command;
|
||||
send( sock, packet, 1, MSG_OOB );
|
||||
retval = g15_recv_oob_answer(sock) - 48;
|
||||
retval = g15_recv_oob_answer(sock);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
|
||||
usleep(1000);
|
||||
return retval;
|
||||
}
|
||||
Reference in new issue
Block a user