Changeset c23a1fe in mainline for uspace/srv/hid/remcons/user.c
- Timestamp:
- 2024-09-26T22:24:43Z (9 months ago)
- Branches:
- master
- Children:
- 89e5c0c7
- Parents:
- 09f41d3
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/hid/remcons/user.c
r09f41d3 rc23a1fe 38 38 #include <adt/prodcons.h> 39 39 #include <errno.h> 40 #include <macros.h> 40 41 #include <mem.h> 41 42 #include <str_error.h> … … 86 87 user->socket_buffer_len = 0; 87 88 user->socket_buffer_pos = 0; 89 user->send_buf_used = 0; 88 90 89 91 fibril_condvar_initialize(&user->refcount_cv); … … 370 372 } 371 373 374 static errno_t telnet_user_send_raw(telnet_user_t *user, 375 const void *data, size_t size) 376 { 377 size_t remain; 378 size_t now; 379 errno_t rc; 380 381 remain = sizeof(user->send_buf) - user->send_buf_used; 382 while (size > 0) { 383 if (remain == 0) { 384 rc = tcp_conn_send(user->conn, user->send_buf, 385 sizeof(user->send_buf)); 386 if (rc != EOK) 387 return rc; 388 389 user->send_buf_used = 0; 390 remain = sizeof(user->send_buf); 391 } 392 393 now = min(remain, size); 394 memcpy(user->send_buf + user->send_buf_used, data, now); 395 user->send_buf_used += now; 396 remain -= now; 397 data += now; 398 size -= now; 399 } 400 401 return EOK; 402 } 403 372 404 /** Send data (convert them first) to the socket, no locking. 373 405 * … … 389 421 converted[converted_size++] = 10; 390 422 user->cursor_x = 0; 391 if (user->cursor_y < user->rows - 1)423 if (user->cursor_y < (int)user->rows - 1) 392 424 ++user->cursor_y; 393 425 } else { … … 401 433 } 402 434 403 errno_t rc = t cp_conn_send(user->conn, converted, converted_size);435 errno_t rc = telnet_user_send_raw(user, converted, converted_size); 404 436 free(converted); 405 437 … … 423 455 424 456 return rc; 457 } 458 459 errno_t telnet_user_flush(telnet_user_t *user) 460 { 461 errno_t rc; 462 463 fibril_mutex_lock(&user->guard); 464 rc = tcp_conn_send(user->conn, user->send_buf, user->send_buf_used); 465 466 if (rc != EOK) { 467 fibril_mutex_unlock(&user->guard); 468 return rc; 469 } 470 471 user->send_buf_used = 0; 472 fibril_mutex_unlock(&user->guard); 473 return EOK; 425 474 } 426 475
Note:
See TracChangeset
for help on using the changeset viewer.