1 //
2 // anyRemote
3 // a wi-fi or bluetooth remote for your PC.
4 //
5 // Copyright (C) 2006-2016 Mikhail Fedotov <anyremote@mail.ru>
6 //
7 // This program is free software; you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License as published by
9 // the Free Software Foundation; either version 3 of the License, or
10 // (at your option) any later version.
11 //
12 // This program is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 // GNU General Public License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
20 //
21 
22 #ifndef _COMMON_H_
23 #define _COMMON_H_
24 
25 #define EXIT_EXACT  -3
26 #define EXIT_NOK     0
27 #define EXIT_OK      1
28 #define EXIT_DISCON  2
29 #define EXIT_ABORT   3
30 #define EXIT_STOP    4
31 #define EXIT_INITOK  5
32 
33 #define MAXMAXLEN    	2048
34 #define MAXLEN          512
35 #define MAXCKPDLEN    	100
36 #define MTEXTLEN    	30
37 
38 #define IS_OK(answer) (strstr(answer, "OK") != NULL)
39 
40 //#define DEFAULT_DEVICE  "/dev/rfcomm0"	seems JSR-82 phones is more usable now
41 //#define DEFAULT_DEVICE  "bluetooth"
42 
43 #ifdef USE_AVAHI
44   #if defined USE_BLUEZ || defined USE_BT_FBSD
45     #define DEFAULT_DEVICE  "bluetooth,tcp:5197,web:5080,avahi"
46   #else
47     #define DEFAULT_DEVICE  "tcp:5197,web:5080,avahi"
48   #endif
49 #else
50   #if defined USE_BLUEZ || defined USE_BT_FBSD
51     #define DEFAULT_DEVICE  "bluetooth:19,tcp:5197,web:5080"
52   #else
53     #define DEFAULT_DEVICE  "tcp:5197,web:5080"
54   #endif
55 #endif
56 
57 #define RFCOMM_DEVICE   "rfcomm"
58 #define AT_DEVICE   	"at:"
59 #define INET_SOCKET   	"socket:"
60 #define PEER_TCP   	    "tcp:"
61 #define BT_SOCKET   	"bluetooth"
62 #define BT_SPP   	    "btspp"
63 #define L2CAP_SOCKET   	"l2cap"  	// not yet used
64 #define UNIX_SOCKET   	"local:"
65 #define ILIRC_SOCKET   	"ilirc:"
66 #define STDIN_STREAM   	"stdin"
67 #define WEB_SOCKET   	"web:"
68 #define CMXML_SOCKET   	"cmxml:"
69 #define AVAHI_USE   	"avahi"
70 
71 #define PROTO_AT        1
72 #define PROTO_ANYREMOTE 2
73 #define PROTO_BEMUSED   3
74 #define PROTO_IVIEWER   4
75 
76 #define PEER_ANY        0
77 
78 enum ProtocolMode {
79     CLIENT_RFCOMM = 0,	 // AT protocol over bluetooth
80     CLIENT_AT,	         // AT protocol over IR or cable
81     SERVER_TCP,	         // anyRemote protocol over TCP/IP
82     SERVER_BT,	         // anyRemote protocol over btspp
83     CLIENT_ILIRC,	     // inputLirc protocol
84     CLIENT_NOAT,	     // anyRemote protocol over IR (or any AF_UNIX socket) - as client
85     SERVER_STDIN,	     // anyRemote protocol, read command from stdin
86     SERVER_WEB,	         // anyRemote protocol, built-in web server
87     SERVER_CMXML,	     // anyRemote protocol, built-in XML server
88     #ifdef USE_L2CAP
89     SERVER_L2CAP,	     // TODO: anyRemote protocol over l2cap
90     #endif
91     SERVER_UX ,  	     // NOT USED: anyRemote protocol over IR (or any AF_UNIX socket) - as server
92     FRONT_END ,  	     // Used to communicate with frontend
93     SERVER_MAX
94 };
95 
96 #define DEFAULT_BT_CHANNEL 1
97 #define BT_ADDR_LEN        17   // 00:12:EF:32:21:1A
98 #define DEFAULT_L2CAP_PORT 5019
99 
100 #ifndef SOCK_CLOEXEC
101 #define SOCK_CLOEXEC 0
102 #endif
103 
104 #define VAR_AUTOCONN   	  "AutoConnect"
105 #define VAR_AUTOREPEAT	  "AutoRepeat"
106 #define VAR_CFGDIR    	  "CfgDir"
107 #define VAR_CHARSET    	  "CharSet"
108 #define VAR_TO_ENCODING   "ToEncoding"
109 #define VAR_FROM_ENCODING "FromEncoding"
110 #define VAR_LOGGING       "Logging"
111 #define VAR_IVIEWER       "IViewer"
112 #define VAR_BEMUSED       "Bemused"
113 #define VAR_WAITEXEC      "WaitSeconds"
114 #define VAR_ALLOWED_ONLY  "AllowedOnly"
115 
116 #define CMD_STR_DISCONNECT  "Set(disconnect);"
117 #define CMD_STR_GETCOVERSZ  "Get(cover_size);"
118 #define CMD_STR_GETSCREENSZ "Get(screen_size);"
119 
120 // TODO: Support L2CAP under FreeBSD
121 //#ifdef USE_BLUEZ
122 //#define USE_L2CAP 1
123 //#endif
124 
125 enum RC_Code {
126     RC_NOK = 0,
127     RC_OK,
128 };
129 
130 #endif
131