From: Karl B. <ka...@tu...> - 2003-04-02 06:10:31
|
Heres a patch to add a SEND_RELAY command to inject commands. The program to send IR commands(rc/irsend) can be used like this: irsend SEND_RELAY 0000000012345678 "00 volup sharp" You need the quotes for now so irsend/rc sees 3 parameters. diff -urN lirc-4-01-03/daemons/lircd.c lirc-4-01-03-relay/daemons/lircd.c --- lirc-4-01-03/daemons/lircd.c Sun Mar 30 06:22:11 2003 +++ lirc-4-01-03-relay/daemons/lircd.c Tue Apr 1 23:56:15 2003 @@ -103,6 +103,7 @@ {"SEND_START",send_start}, {"SEND_STOP",send_stop}, {"VERSION",version}, + {"SEND_RELAY",send_relay}, {NULL,NULL} /* {"DEBUG",debug}, @@ -1216,6 +1217,38 @@ return(send_core(fd,message,arguments,0)); } =20 +int send_relay(int fd,char *message,char *arguments) +{ + int length; + int i; + + /* pass up "SEND_RELAY ", send rest of string */ + while ((*message !=3D 0) && (*message !=3D ' ')) + ++message; + if (*message =3D=3D ' ') + ++message; + length =3D strlen(message); + + if(length) + { + LOGPRINTF(1,"relaying message: \"%s\"",message); + for(i=3D0;i<clin;i++) + { + /* don't relay messages to remote clients */ + if(cli_type[i]=3D=3DCT_REMOTE) + continue; + LOGPRINTF(1,"writing to client %d",i); + if(write_socket(clis[i],message,length)<length) + { + remove_client(clis[i]); + i--; + } + } + } + /* return close client(to close rc/irsend without timeout/pause */ + return(0); +} + int send_core(int fd,char *message,char *arguments,int once) { struct ir_remote *remote; diff -urN lirc-4-01-03/daemons/lircd.h lirc-4-01-03-relay/daemons/lircd.h --- lirc-4-01-03/daemons/lircd.h Sat Feb 15 03:00:58 2003 +++ lirc-4-01-03-relay/daemons/lircd.h Tue Apr 1 23:33:44 2003 @@ -76,6 +76,7 @@ int send_once(int fd,char *message,char *arguments); int send_start(int fd,char *message,char *arguments); int send_stop(int fd,char *message,char *arguments); +int send_relay(int fd,char *message,char *arguments); int send_core(int fd,char *message,char *arguments,int once); int version(int fd,char *message,char *arguments); int get_pid(int fd,char *message,char *arguments); |