{"action":"closed","issue":{"url":"https://api.github.com/repos/crayzeewulf/libserial/issues/16","labels_url":"https://api.github.com/repos/crayzeewulf/libserial/issues/16/labels{/name}","comments_url":"https://api.github.com/repos/crayzeewulf/libserial/issues/16/comments","events_url":"https://api.github.com/repos/crayzeewulf/libserial/issues/16/events","html_url":"https://github.com/crayzeewulf/libserial/issues/16","id":84774223,"number":16,"title":"[Patch] showmanyc method to allow non-blocking read [sf#1]","user":{"login":"crayzeewulf","id":2294944,"avatar_url":"https://avatars.githubusercontent.com/u/2294944?v=3","gravatar_id":"","url":"https://api.github.com/users/crayzeewulf","html_url":"https://github.com/crayzeewulf","followers_url":"https://api.github.com/users/crayzeewulf/followers","following_url":"https://api.github.com/users/crayzeewulf/following{/other_user}","gists_url":"https://api.github.com/users/crayzeewulf/gists{/gist_id}","starred_url":"https://api.github.com/users/crayzeewulf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/crayzeewulf/subscriptions","organizations_url":"https://api.github.com/users/crayzeewulf/orgs","repos_url":"https://api.github.com/users/crayzeewulf/repos","events_url":"https://api.github.com/users/crayzeewulf/events{/privacy}","received_events_url":"https://api.github.com/users/crayzeewulf/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-06-03T21:16:24Z","updated_at":"2015-06-03T21:17:16Z","closed_at":"2015-06-03T21:17:16Z","body":"**Reported by wedesoft on 2005-07-30 14:52 UTC**\nOne would be able to check for availability of input\r\nusing 's.rdbuf\\(\\)-&gt;in\\_avail\\(\\) &gt; 0', if the method\r\n'SerialStreamBuf::showmanyc\\(\\)' is implemented:\r\n\\----------------\r\nstd::streamsize SerialStreamBuf::showmanyc\\(\\) \\{\r\n\r\nint retval = -1;\r\n\r\nif \\( -1 == mFileDescriptor \\) \\{\r\nreturn -1;\r\n\\};\r\n\r\nif \\( mPutbackAvailable \\) \\{\r\n\r\n// We still have a character left in the buffer.\r\nretval = 1;\r\n\r\n\\} else \\{\r\n\r\n// Switch to non-blocking read.\r\nint flags = fcntl\\(this-&gt;mFileDescriptor, F\\_GETFL, 0\\) ;\r\nif\\( -1 == fcntl\\( this-&gt;mFileDescriptor, \r\nF\\_SETFL, \r\nflags | O\\_NONBLOCK \\) \\) \\{\r\nreturn -1;\r\n\\}\r\n\r\n// Try to read a character.\r\nretval = read\\(mFileDescriptor, &mPutbackChar, 1\\);\r\n\r\nif \\( retval == 1 \\) \\{\r\nmPutbackAvailable = true;\r\n\\} else\r\nretval = 0;\r\n\r\n// Switch back to blocking read.\r\nif\\( -1 == fcntl\\( this-&gt;mFileDescriptor, \r\nF\\_SETFL, \r\nflags \\) \\) \\{\r\nreturn -1;\r\n\\}\r\n\\};\r\nreturn retval;    \r\n\r\n\\}\r\n\\------------------\r\nThe patch furthermore fixes the missing\r\nreturn-statement in 'SerialStreamBuf::open'."}}