139 |
139 |
140 memcpy(buffer, &(buf->inbuf[buf->pos]), bytes_in_buffer); |
140 memcpy(buffer, &(buf->inbuf[buf->pos]), bytes_in_buffer); |
141 |
141 |
142 buf->pos += bytes_in_buffer; |
142 buf->pos += bytes_in_buffer; |
143 return bytes_in_buffer; |
143 return bytes_in_buffer; |
|
144 } else if(buf->pos >= buf->maxsize) { |
|
145 return NETBUF_EOF; |
144 } |
146 } |
145 } |
147 } |
146 |
148 |
|
149 if(!buf->sd) { |
|
150 return NETBUF_EOF; |
|
151 } |
|
152 |
147 /* The netbuf is empty. Read data directly into the caller's buffer */ |
153 /* The netbuf is empty. Read data directly into the caller's buffer */ |
148 bytes = net_read(buf->sd, buffer, size); |
154 bytes = net_read(buf->sd, buffer, size); |
149 if (bytes == 0) |
155 if (bytes == 0) |
150 return NETBUF_EOF; |
156 return NETBUF_EOF; |
151 if (bytes < 0) { |
157 if (bytes < 0) { |