Changeset 8565a42 in mainline for uspace/lib/http/src/receive-buffer.c
- Timestamp:
- 2018-03-02T20:34:50Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- a1a81f69, d5e5fd1
- Parents:
- 3061bc1 (diff), 34e1206 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - git-author:
- Jiří Zárevúcky <zarevucky.jiri@…> (2018-03-02 20:34:50)
- git-committer:
- GitHub <noreply@…> (2018-03-02 20:34:50)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/http/src/receive-buffer.c
r3061bc1 r8565a42 48 48 rb->receive = receive; 49 49 rb->client_data = client_data; 50 50 51 51 rb->in = 0; 52 52 rb->out = 0; 53 53 rb->size = buffer_size; 54 54 55 55 list_initialize(&rb->marks); 56 56 57 57 rb->buffer = malloc(buffer_size); 58 58 if (rb->buffer == NULL) … … 73 73 if (rc != EOK) 74 74 return rc; 75 75 76 76 memcpy(rb->buffer, buf, size); 77 77 rb->in = size; … … 111 111 if (a->offset > b->offset) 112 112 return EINVAL; 113 113 114 114 size_t size = b->offset - a->offset; 115 115 void *buf = malloc(size); 116 116 if (buf == NULL) 117 117 return ENOMEM; 118 118 119 119 memcpy(buf, rb->buffer + a->offset, size); 120 120 *out_buf = buf; … … 127 127 if (a->offset > b->offset) 128 128 return EINVAL; 129 129 130 130 size_t size = b->offset - a->offset; 131 131 char *buf = malloc(size + 1); 132 132 if (buf == NULL) 133 133 return ENOMEM; 134 134 135 135 memcpy(buf, rb->buffer + a->offset, size); 136 136 buf[size] = 0; … … 156 156 min_mark = min(min_mark, mark->offset); 157 157 } 158 158 159 159 if (min_mark == 0) 160 160 return ELIMIT; 161 161 162 162 size_t new_in = rb->in - min_mark; 163 163 memmove(rb->buffer, rb->buffer + min_mark, new_in); … … 168 168 } 169 169 } 170 170 171 171 size_t nrecv; 172 172 errno_t rc = rb->receive(rb->client_data, rb->buffer + rb->in, free, &nrecv); 173 173 if (rc != EOK) 174 174 return rc; 175 175 176 176 rb->in = nrecv; 177 177 } 178 178 179 179 *c = rb->buffer[rb->out]; 180 180 if (consume) … … 194 194 return EOK; 195 195 } 196 196 197 197 return rb->receive(rb->client_data, buf, buf_size, nrecv); 198 198 } … … 248 248 if (rc != EOK) 249 249 return rc; 250 250 251 251 if (!class(c)) 252 252 break; 253 253 254 254 rc = recv_char(rb, &c, true); 255 255 if (rc != EOK) 256 256 return rc; 257 257 } 258 258 259 259 return EOK; 260 260 } … … 272 272 if (rc != EOK) 273 273 return rc; 274 274 275 275 if (c != '\r' && c != '\n') { 276 276 *nrecv = 0; 277 277 return EOK; 278 278 } 279 279 280 280 rc = recv_char(rb, &c, true); 281 281 if (rc != EOK) 282 282 return rc; 283 283 284 284 size_t nr; 285 285 rc = recv_discard(rb, (c == '\r' ? '\n' : '\r'), &nr); 286 286 if (rc != EOK) 287 287 return rc; 288 288 289 289 *nrecv = 1 + nr; 290 290 return EOK; … … 296 296 size_t written = 0; 297 297 size_t nr; 298 298 299 299 while (written < size) { 300 300 char c = 0; … … 321 321 line[written++] = c; 322 322 } 323 323 324 324 return ELIMIT; 325 325 }
Note:
See TracChangeset
for help on using the changeset viewer.