- }
- else if (status == -1)
- {
- char errbuf[1024];
- ERROR ("ted plugin: select failed: %s",
- sstrerror (errno, errbuf, sizeof (errbuf)));
- break;
- }
-
- else
- {
-/* find out how may bytes are in the input buffer*/
- ioctl(fd, FIONREAD, &byte);
- DEBUG ("bytes in buffer %d",byte);
- if (byte <= 0)
- {
- continue;
- }
- // Read input buffer
- sResultnum = read(fd, sResult, MAX_PKT);
- DEBUG ("bytes read %d",sResultnum);
-
- //
- // packet filter loop
- //
- for (byte=0; byte< sResultnum; byte++)
- {
- sResultByte = sResult[byte];
- // was byte before escape
- if (escape_flag == 1)
- {
- escape_flag = 0;
- // escape escape = single escape
- if ((sResultByte==ESCAPE) & (package_length > 0))
- {
- package_buffer[package_length] = ESCAPE;
- package_length++;
- }
- else if (sResultByte==PKT_BEGIN)
- {
- package_length=0;
- }
- else if (sResultByte==PKT_END)
- {
- end_flag = 1;
- break;
- }
- }
- else if (sResultByte == ESCAPE)
- {
- escape_flag = 1;
- }
- // if we are in a package add byte to buffer
- // otherwise throw away
- else if (package_length >= 0)
- {
- package_buffer[package_length] = sResultByte;
- package_length++;
- }
- }
- }
+ ERROR ("ted plugin: read(2) failed: %s",
+ sstrerror (errno, errbuf, sizeof (errbuf)));
+ return (-1);