2 * Copyright (c) 2007, IRTrans GmbH
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of IRTrans GmbH nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
16 * THIS SOFTWARE IS PROVIDED BY IRTrans GmbH ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL IRTrans GmbH BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 #include <sys/timeb.h>
42 #include <sys/types.h>
43 #include <sys/socket.h>
44 #include <netinet/in.h>
46 #include <arpa/inet.h>
54 #include <sys/timeb.h>
71 void log_print (char msg
[],int level
)
84 if (logfp
) fp
= logfp
;
89 if (level
> (int)(mode_flag
& LOG_MASK
)) return;
91 if (mode_flag
& TIMESTAMP
) {
101 tmpnt
= localtime (&tv
);
103 fprintf (fp
,"%4d-%02d-%02d %02d:%02d:%02d.%03d %s",tmpnt
->tm_year
+1900,tmpnt
->tm_mon
+1,tmpnt
->tm_mday
,tmpnt
->tm_hour
,tmpnt
->tm_min
,tmpnt
->tm_sec
,ms
,msg
);
105 else fprintf (fp
,"%s",msg
);
110 void GetError (int res
,char st
[])
115 sprintf (st
,"Error opening COM/USB Port / LAN Device\n");
118 sprintf (st
,"No IR Transceiver found (Reset not possible)\n");
120 case ERR_READVERSION
:
121 sprintf (st
,"Could not get Transceiver Version\n");
124 sprintf (st
,"Wrong IR Transceiver SW Version. Minimum Version: %s\n",MINIMUM_SW_VERSION
);
127 sprintf (st
,"Timeout (Connection lost ?)\n");
130 sprintf (st
,"Error opening USB Device / Device not found\n");
132 case ERR_DBOPENINPUT
:
133 sprintf (st
,"Error opening Database file (Access rights ?)\n");
135 case ERR_REMOTENOTFOUND
:
136 sprintf (st
,"Specified Remote Control [%%s] not found\n");
138 case ERR_COMMANDNOTFOUND
:
139 sprintf (st
,"Specified Remote Command [%%s] not found\n");
141 case ERR_TIMINGNOTFOUND
:
142 sprintf (st
,"Specified Remote Timing not found\n");
145 sprintf (st
,"Could not create new Remote file (Access rights ?)\n");
148 sprintf (st
,"Could not open Remote Database (No folder 'remotes' / Access rights ?)\n");
151 sprintf (st
,"Could not record Toggle Command (No commands yet learned ?)\n");
153 case ERR_DBOPENINCLUDE
:
154 sprintf (st
,"Specified Include File not found\n");
157 sprintf (st
,"No Remote opened to learn new commands\n");
160 sprintf (st
,"Could not lock input file (USB / TTY)\n");
163 sprintf (st
,"Could not set serial parameters\n");
166 sprintf (st
,"Could not open IP socket\n");
169 sprintf (st
,"Could not bind to IP socket (Another server running ?)\n");
172 sprintf (st
,"Hotcode %%s-%%s not found\n");
175 sprintf (st
,"No timing learned for new commands\n");
177 case ERR_TEMPCOMMAND
:
178 sprintf (st
,"Illegal Temparature Command: %%s\n");
181 sprintf (st
,"Error opening translation table file\n");
184 sprintf (st
,"Specified Bus %%d does not exist\n");
187 sprintf (st
,"Cannot get the Device Data for a macro\n");
189 case ERR_DEVICEUNKNOWN
:
190 sprintf (st
,"IR Code received from unknown device: %%s\n");
193 sprintf (st
,"Cannot bind to Web Port. Another Webserver running ? Try -no_web.\n");
196 sprintf (st
,"File already exists. Overwrite ?\n");
199 sprintf (st
,"No IRTrans Device with AUX RS232 port connected\n");
202 sprintf (st
,"Error %d\n",res
);