FreeBASIC
0.91.0
Main Page
Data Structures
Files
File List
Globals
dev_com_test.c
Go to the documentation of this file.
1
/* COMx device */
2
3
#include "
fb.h
"
4
5
int
fb_DevComTestProtocolEx
6
(
7
FB_FILE
*
handle
,
8
const
char
*
filename
,
9
size_t
filename_len,
10
size_t
*pPort
11
)
12
{
13
char
ch;
14
size_t
i, port;
15
16
if
( pPort ) {
17
*pPort = 0;
18
}
19
20
if
( strncasecmp(filename,
"SER:"
, 4)==0 ) {
21
if
( pPort )
22
*pPort = 1;
23
return
TRUE
;
24
}
25
26
if
( filename_len < 4 )
27
return
FALSE
;
28
29
if
( strncasecmp(filename,
"COM"
, 3) != 0 )
30
return
strchr( filename,
':'
) !=
NULL
;
31
32
port = 0;
33
i = 3;
34
ch = filename[i];
35
while
( ch>=
'0'
&& ch<=
'9'
) {
36
port = port * 10 + (ch -
'0'
);
37
ch = filename[++i];
38
}
39
40
/* removed to allow for open com "COM:"
41
if( port==0 )
42
return FALSE;
43
*/
44
if
( ch!=
':'
)
45
return
FALSE
;
46
47
if
( pPort )
48
*pPort = port;
49
50
return
TRUE
;
51
}
52
53
int
fb_DevComTestProtocol
54
(
55
FB_FILE
*handle,
56
const
char
*filename,
57
size_t
filename_len
58
)
59
{
60
return
fb_DevComTestProtocolEx
( handle, filename, filename_len,
NULL
);
61
}
rtlib
dev_com_test.c
Generated on Thu Jan 23 2014 19:40:08 for FreeBASIC by
1.8.4