| 1354 | ----------------------------------------------------------*/ |
| 1355 | |
| 1356 | int win32_serial_open(const char *filename, int flags, ...) |
| 1357 | { |
| 1358 | struct termios_list *index; |
| 1359 | char message[756]; |
| 1360 | char fullfilename[256]; |
| 1361 | |
| 1362 | ENTER("serial_open"); |
| 1363 | |
| 1364 | fullfilename[sizeof(fullfilename) - 1] = '\0'; |
| 1365 | |
| 1366 | /* according to http://support.microsoft.com/kb/115831 |
| 1367 | * this is necessary for COM ports larger than COM9 */ |
| 1368 | if (memcmp(filename, "\\\\.\\", 4) != 0) |
| 1369 | { |
| 1370 | SNPRINTF(fullfilename, sizeof(fullfilename) - 1, "\\\\.\\%s", filename); |
| 1371 | } |
| 1372 | else |
| 1373 | { |
| 1374 | strncpy(fullfilename, filename, sizeof(fullfilename) - 1); |
| 1375 | } |
| 1376 | |
| 1377 | if (port_opened(fullfilename)) |
| 1378 | { |
| 1379 | report("Port is already opened\n"); |
| 1380 | return (-1); |
| 1381 | } |
| 1382 | |
| 1383 | index = add_port(fullfilename); |
| 1384 | |
| 1385 | if (!index) |
| 1386 | { |
| 1387 | report("serial_open !index\n"); |
| 1388 | return (-1); |
| 1389 | } |
| 1390 | |
| 1391 | index->interrupt = 0; |
| 1392 | index->tx_happened = 0; |
| 1393 | |
| 1394 | if (open_port(index)) |
| 1395 | { |
| 1396 | SNPRINTF(message, sizeof(message), |
| 1397 | "serial_open(): Invalid Port Reference for %s\n", |
| 1398 | fullfilename); |
| 1399 | report(message); |
| 1400 | win32_serial_close(index->fd); |
| 1401 | return -1; |
| 1402 | } |
| 1403 | |
| 1404 | if (check_port_capabilities(index)) |
| 1405 | { |
| 1406 | report("check_port_capabilities!"); |
| 1407 | win32_serial_close(index->fd); |
| 1408 | return -1; |
| 1409 | } |
| 1410 | |
| 1411 | init_termios(index->ttyset); |
| 1412 | init_serial_struct(index->sstruct); |
| 1413 |
nothing calls this directly
no test coverage detected