source: mainline/uspace/srv/hid/remcons/user.h@ 09ab0a9a

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 09ab0a9a was b7fd2a0, checked in by Jiří Zárevúcky <zarevucky.jiri@…>, 8 years ago

Use errno_t in all uspace and kernel code.

Change type of every variable, parameter and return value that holds an
<errno.h> constant to either errno_t (the usual case), or sys_errno_t
(some places in kernel). This is for the purpose of self-documentation,
as well as for type-checking with a bit of type definition hackery.

Although this is a massive commit, it is a simple text replacement, and thus
is very easy to verify. Simply do the following:

`
git checkout <this commit's hash>
git reset HEAD
git add .
tools/srepl '\berrno_t\b' int
git add .
tools/srepl '\bsys_errno_t\b' sysarg_t
git reset
git diff
`

While this doesn't ensure that the replacements are correct, it does ensure
that the commit doesn't do anything except those replacements. Since errno_t
is typedef'd to int in the usual case (and sys_errno_t to sysarg_t), even if
incorrect, this commit cannot change behavior.

  • Property mode set to 100644
File size: 3.6 KB
Line 
1/*
2 * Copyright (c) 2012 Vojtech Horky
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * - Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * - Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * - The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29/** @addtogroup remcons
30 * @{
31 */
32/** @file
33 */
34
35#ifndef TELNET_USER_H_
36#define TELNET_USER_H_
37
38#include <adt/prodcons.h>
39#include <fibril_synch.h>
40#include <inet/tcp.h>
41#include <inttypes.h>
42#include <io/con_srv.h>
43#include "remcons.h"
44
45#define BUFFER_SIZE 32
46
47/** Representation of a connected (human) user. */
48typedef struct {
49 /** Mutex guarding the whole structure. */
50 fibril_mutex_t guard;
51
52 /** Internal id, used for creating locfs entries. */
53 int id;
54 /** Associated connection. */
55 tcp_conn_t *conn;
56 /** Location service id assigned to the virtual terminal. */
57 service_id_t service_id;
58 /** Path name of the service. */
59 char *service_name;
60 /** Console service setup */
61 con_srvs_t srvs;
62
63 /** Producer-consumer of kbd_event_t. */
64 prodcons_t in_events;
65 link_t link;
66 char socket_buffer[BUFFER_SIZE];
67 size_t socket_buffer_len;
68 size_t socket_buffer_pos;
69
70 /** Task id of the launched application. */
71 task_id_t task_id;
72
73 /* Reference counting. */
74 fibril_condvar_t refcount_cv;
75 bool task_finished;
76 int locsrv_connection_count;
77 bool socket_closed;
78
79 /** X position of the cursor. */
80 int cursor_x;
81} telnet_user_t;
82
83extern telnet_user_t *telnet_user_create(tcp_conn_t *);
84extern void telnet_user_add(telnet_user_t *);
85extern void telnet_user_destroy(telnet_user_t *);
86extern telnet_user_t *telnet_user_get_for_client_connection(service_id_t);
87extern bool telnet_user_is_zombie(telnet_user_t *);
88extern void telnet_user_notify_client_disconnected(telnet_user_t *);
89extern errno_t telnet_user_get_next_keyboard_event(telnet_user_t *, kbd_event_t *);
90extern errno_t telnet_user_send_data(telnet_user_t *, uint8_t *, size_t);
91extern void telnet_user_update_cursor_x(telnet_user_t *, int);
92
93/** Print informational message about connected user. */
94#ifdef CONFIG_DEBUG
95#define telnet_user_log(user, fmt, ...) \
96 printf(NAME " [console %d (%d)]: " fmt "\n", \
97 user->id, (int) user->service_id, ##__VA_ARGS__)
98#else
99#define telnet_user_log(user, fmt, ...) ((void) 0)
100#endif
101
102/** Print error message associated with connected user. */
103#define telnet_user_error(user, fmt, ...) \
104 fprintf(stderr, NAME " [console %d (%d)]: ERROR: " fmt "\n", \
105 user->id, (int) user->service_id, ##__VA_ARGS__)
106
107#endif
108
109/**
110 * @}
111 */
Note: See TracBrowser for help on using the repository browser.