annotate m4/lirc.m4 @ 2144:b76039eeb6f0 trunk

[svn] - added auto-enqueue option for search-in-playlist
author giacomo
date Sat, 16 Dec 2006 10:44:25 -0800
parents 9cc81c92496e
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
272
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
1 ## lirc.m4 (Macros for autoconf)
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
2 ##
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
3 ## (C) 1999 Christoph Bartelmus (lirc@bartelmus.de)
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
4 ##
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
5
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
6 #######################################################################
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
7 ##
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
8 ## Check for LIRC
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
9 ##
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
10 #######################################################################
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
11
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
12 dnl AC_PATH_LIRC([MINIMUM-VERSION])
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
13 dnl Check for LIRC and define LIRCD
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
14 dnl
275
9cc81c92496e [svn] Add quoting to make autotools happy.
chainsaw
parents: 272
diff changeset
15 AC_DEFUN([AC_PATH_LIRC],
272
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
16 [
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
17 min_lirc_version=ifelse([$1], ,0.5.5,$1)
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
18 AC_MSG_CHECKING(for LIRC>=$min_lirc_version)
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
19
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
20 AC_CACHE_VAL(ac_cv_have_lirc,[
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
21 no_lirc=no
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
22 lirc_version=none
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
23 lirc_cross_compiling=no
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
24
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
25 if test ! -S /dev/lircd; then
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
26 LIRCD=/dev/null
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
27 no_lirc=yes
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
28 else
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
29 LIRCD=/dev/lircd
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
30
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
31 rm -f conf.lirc
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
32 ac_save_cflags="${CFLAGS}"
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
33 CFLAGS="$CFLAGS -DLIRCD=\"$LIRCD\""
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
34 AC_TRY_RUN(
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
35 [
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
36 #include <stdio.h>
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
37 #include <stdlib.h>
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
38 #include <string.h>
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
39 #include <unistd.h>
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
40 #include <fcntl.h>
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
41 #include <getopt.h>
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
42 #include <sys/socket.h>
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
43 #include <sys/types.h>
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
44 #include <sys/stat.h>
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
45 #include <sys/un.h>
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
46 #include <errno.h>
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
47 #include <signal.h>
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
48 #include <limits.h>
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
49
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
50 #define PACKET_SIZE 256
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
51 /* three seconds */
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
52 #define TIMEOUT 3
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
53
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
54 int timeout=0;
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
55
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
56 void sigalrm(int sig)
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
57 {
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
58 timeout=1;
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
59 }
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
60
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
61 const char *read_string(int fd)
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
62 {
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
63 static char buffer[PACKET_SIZE+1]="";
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
64 char *end;
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
65 static int ptr=0;
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
66 ssize_t ret;
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
67
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
68 if(ptr>0)
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
69 {
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
70 memmove(buffer,buffer+ptr,strlen(buffer+ptr)+1);
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
71 ptr=strlen(buffer);
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
72 end=strchr(buffer,'\n');
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
73 }
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
74 else
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
75 {
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
76 end=NULL;
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
77 }
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
78 alarm(TIMEOUT);
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
79 while(end==NULL)
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
80 {
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
81 if(PACKET_SIZE<=ptr)
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
82 {
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
83 ptr=0;
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
84 return(NULL);
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
85 }
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
86 ret=read(fd,buffer+ptr,PACKET_SIZE-ptr);
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
87
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
88 if(ret<=0 || timeout)
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
89 {
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
90 if(!timeout)
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
91 {
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
92 alarm(0);
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
93 }
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
94 ptr=0;
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
95 return(NULL);
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
96 }
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
97 buffer[ptr+ret]=0;
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
98 ptr=strlen(buffer);
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
99 end=strchr(buffer,'\n');
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
100 }
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
101 alarm(0);timeout=0;
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
102
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
103 end[0]=0;
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
104 ptr=strlen(buffer)+1;
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
105 return(buffer);
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
106 }
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
107
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
108 enum packet_state
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
109 {
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
110 P_BEGIN,
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
111 P_MESSAGE,
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
112 P_STATUS,
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
113 P_DATA,
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
114 P_N,
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
115 P_DATA_N,
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
116 P_END
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
117 };
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
118
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
119 char *get_version(int fd,const char *packet)
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
120 {
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
121 int done,todo;
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
122 const char *string,*data;
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
123 char *endptr;
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
124 enum packet_state state;
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
125 int status,n;
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
126 unsigned long data_n;
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
127 unsigned int major,minor,micro;
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
128 static char version[100];
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
129
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
130 todo=strlen(packet);
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
131 data=packet;
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
132 while(todo>0)
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
133 {
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
134 done=write(fd,(void *) data,todo);
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
135 if(done<0)
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
136 {
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
137 return(NULL);
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
138 }
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
139 data+=done;
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
140 todo-=done;
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
141 }
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
142
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
143 /* get response */
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
144 status=0;
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
145 state=P_BEGIN;
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
146 n=0;
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
147 while(1)
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
148 {
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
149 string=read_string(fd);
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
150 if(string==NULL) return(NULL);
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
151 switch(state)
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
152 {
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
153 case P_BEGIN:
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
154 if(strcasecmp(string,"BEGIN")!=0)
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
155 {
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
156 continue;
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
157 }
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
158 state=P_MESSAGE;
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
159 break;
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
160 case P_MESSAGE:
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
161 if(strncasecmp(string,packet,strlen(string))!=0 ||
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
162 strlen(string)+1!=strlen(packet))
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
163 {
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
164 state=P_BEGIN;
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
165 continue;
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
166 }
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
167 state=P_STATUS;
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
168 break;
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
169 case P_STATUS:
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
170 if(strcasecmp(string,"SUCCESS")==0)
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
171 {
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
172 status=0;
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
173 }
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
174 else if(strcasecmp(string,"END")==0)
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
175 {
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
176 status=0;
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
177 return(NULL);
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
178 }
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
179 else if(strcasecmp(string,"ERROR")==0)
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
180 {
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
181 status=-1;
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
182 }
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
183 else
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
184 {
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
185 goto bad_packet;
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
186 }
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
187 state=P_DATA;
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
188 break;
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
189 case P_DATA:
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
190 if(strcasecmp(string,"END")==0)
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
191 {
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
192 return(NULL);
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
193 }
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
194 else if(strcasecmp(string,"DATA")==0)
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
195 {
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
196 state=P_N;
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
197 break;
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
198 }
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
199 goto bad_packet;
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
200 case P_N:
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
201 errno=0;
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
202 data_n=strtoul(string,&endptr,0);
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
203 if(!*string || *endptr)
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
204 {
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
205 goto bad_packet;
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
206 }
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
207 if(data_n==0)
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
208 {
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
209 state=P_END;
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
210 }
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
211 else
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
212 {
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
213 state=P_DATA_N;
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
214 }
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
215 break;
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
216 case P_DATA_N:
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
217 if(data_n==1 && status==0)
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
218 {
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
219 if(sscanf(string,"%u.%u.%u",
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
220 &major,&minor,&micro)==3)
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
221 {
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
222 sprintf(version,"%u.%u.%u",
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
223 major,minor,micro);
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
224 }
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
225 else
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
226 {
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
227 goto bad_packet;
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
228 }
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
229 }
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
230 n++;
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
231 if(n==data_n) state=P_END;
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
232 break;
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
233 case P_END:
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
234 if(strcasecmp(string,"END")==0)
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
235 {
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
236 return(version);
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
237 }
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
238 goto bad_packet;
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
239 break;
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
240 }
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
241 }
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
242 bad_packet:
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
243 return(NULL);
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
244 }
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
245
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
246 int main(int argc,char **argv)
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
247 {
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
248 char *version,*min_version;
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
249 unsigned int major,minor,micro,min_major,min_minor,min_micro;
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
250 struct sockaddr_un addr;
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
251 FILE *result;
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
252 int fd;
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
253 struct sigaction act;
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
254
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
255 result=fopen("conf.lirc","w");
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
256 if(result==NULL) exit(EXIT_FAILURE);
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
257
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
258 act.sa_handler=sigalrm;
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
259 sigemptyset(&act.sa_mask);
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
260 act.sa_flags=0; /* we need EINTR */
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
261 sigaction(SIGALRM,&act,NULL);
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
262
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
263 addr.sun_family=AF_UNIX;
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
264 strcpy(addr.sun_path,LIRCD);
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
265 fd=socket(AF_UNIX,SOCK_STREAM,0);
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
266 if(fd==-1)
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
267 {
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
268 fprintf(result,"unknown");
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
269 fclose(result);
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
270 close(fd);
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
271 exit(EXIT_FAILURE);
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
272 };
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
273 if(connect(fd,(struct sockaddr *)&addr,sizeof(addr))==-1)
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
274 {
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
275 fprintf(result,"unknown");
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
276 fclose(result);
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
277 close(fd);
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
278 exit(EXIT_FAILURE);
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
279 };
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
280
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
281 version=get_version(fd,"VERSION\n");
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
282 if(version==NULL)
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
283 {
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
284 fprintf(result,"<0.5.5");
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
285 fclose(result);
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
286 close(fd);
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
287 exit(EXIT_FAILURE);
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
288 }
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
289 fprintf(result,"%s",version);
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
290 fclose(result);
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
291 close(fd);
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
292
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
293 /* HP/UX 9 (%@#!) writes to sscanf strings */
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
294
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
295 min_version=strdup("$min_lirc_version");
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
296 if(min_version==NULL) exit(EXIT_FAILURE);
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
297
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
298 if(sscanf(version,"%u.%u.%u",&major,&minor,&micro)!=3 ||
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
299 sscanf(min_version,"%u.%u.%u",&min_major,&min_minor,&min_micro)!=3)
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
300 {
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
301 exit(EXIT_FAILURE);
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
302 }
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
303 if(major<min_major ||
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
304 (major==min_major && minor<min_minor) ||
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
305 (major==min_major && minor==min_minor && micro<min_micro))
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
306 {
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
307 exit(EXIT_FAILURE);
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
308 }
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
309
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
310 exit(EXIT_SUCCESS);
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
311 }
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
312 ],
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
313 if test -f conf.lirc; then
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
314 lirc_version=`cat conf.lirc`
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
315
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
316 ## lirc_major_version=`cat lirc.conf | \
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
317 ## sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
318 ## lirc_minor_version=`cat lirc.conf | \
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
319 ## sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
320 ## lirc_micro_version=`cat lirc.conf | \
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
321 ## sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
322 else
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
323 no_lirc=yes
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
324 fi,
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
325 no_lirc=yes
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
326 if test -f conf.lirc; then
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
327 lirc_version=`cat conf.lirc`
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
328 else
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
329 lirc_version=none
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
330 fi
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
331 ,lirc_cross_compiling=yes
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
332 )
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
333 ## AC_TRY_RUN()
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
334 rm -f conf.lirc
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
335 CFLAGS="$ac_save_CFLAGS"
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
336 fi
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
337 ac_cv_have_lirc="no_lirc=${no_lirc} lirc_version=\"${lirc_version}\" \
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
338 lirc_cross_compiling=${lirc_cross_compiling} \
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
339 LIRCD=${LIRCD}"
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
340 ])
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
341 ## AC_CACHE_VAL
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
342
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
343 eval "$ac_cv_have_lirc"
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
344
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
345 if test x${no_lirc} = xyes; then
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
346 if test x${lirc_version} = xunknown; then
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
347 AC_MSG_RESULT([missing (lircd not running ?)])
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
348 elif test x${lirc_version} != xnone; then
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
349 AC_MSG_RESULT([missing (found lirc-${lirc_version})])
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
350 else
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
351 AC_MSG_RESULT(missing)
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
352 fi
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
353 else
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
354 if test x${lirc_cross_compiling} = xyes; then
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
355 AC_MSG_RESULT(found)
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
356 else
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
357 AC_MSG_RESULT([found lirc-${lirc_version}])
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
358 fi
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
359 fi
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
360
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
361 AC_DEFINE_UNQUOTED(LIRCD,"${LIRCD}")
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
362 ]
1d191edcd2ec [svn] Add missing lirc.m4.
nenolod
parents:
diff changeset
363 )