Changeset 6a753a9c in mainline


Ignore:
Timestamp:
2024-09-25T16:47:10Z (2 weeks ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
master
Children:
09f41d3
Parents:
d3109ff
Message:

Remcons options port, no-ctl, no-rgb, multiple instances.

Location:
uspace/srv/hid/remcons
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/hid/remcons/remcons.c

    rd3109ff r6a753a9c  
    5959#define APP_SHELL "/app/bdsh"
    6060
     61#define DEF_PORT 2223
     62
    6163/** Telnet commands to force character mode
    6264 * (redundant to be on the safe side).
     
    122124
    123125static loc_srv_t *remcons_srv;
     126static bool no_ctl;
     127static bool no_rgb;
    124128
    125129static telnet_user_t *srv_to_user(con_srv_t *srv)
     
    432436        assert(user);
    433437
    434         remcons->enable_ctl = true;
     438        remcons->enable_ctl = !no_ctl;
    435439        remcons->user = user;
    436440
     
    444448            remcons_vt_putchar, remcons_vt_cputs, remcons_vt_flush);
    445449        assert(remcons->vt != NULL); // XXX
    446         remcons->vt->enable_rgb = true;
     450        remcons->vt->enable_rgb = !no_rgb;
    447451
    448452        if (remcons->enable_ctl) {
     
    504508}
    505509
     510static void print_syntax(void)
     511{
     512        fprintf(stderr, "syntax: remcons [<options>]\n");
     513        fprintf(stderr, "\t--no-ctl      Disable all terminal control sequences\n");
     514        fprintf(stderr, "\t--no-rgb      Disable RGB colors\n");
     515        fprintf(stderr, "\t--port <port> Listening port (default: %u)\n",
     516            DEF_PORT);
     517}
     518
    506519int main(int argc, char *argv[])
    507520{
     
    510523        tcp_t *tcp;
    511524        inet_ep_t ep;
     525        uint16_t port;
     526        int i;
     527
     528        port = DEF_PORT;
     529
     530        i = 1;
     531        while (i < argc) {
     532                if (argv[i][0] == '-') {
     533                        if (str_cmp(argv[i], "--no-ctl") == 0) {
     534                                no_ctl = true;
     535                        } else if (str_cmp(argv[i], "--no-rgb") == 0) {
     536                                no_rgb = true;
     537                        } else if (str_cmp(argv[i], "--port") == 0) {
     538                                ++i;
     539                                if (i >= argc) {
     540                                        fprintf(stderr, "Option argument "
     541                                            "missing.\n");
     542                                        print_syntax();
     543                                        return EINVAL;
     544                                }
     545                                rc = str_uint16_t(argv[i], NULL, 10, true, &port);
     546                                if (rc != EOK) {
     547                                        fprintf(stderr, "Invalid port number "
     548                                            "'%s'.\n", argv[i]);
     549                                        print_syntax();
     550                                        return EINVAL;
     551                                }
     552                        } else {
     553                                fprintf(stderr, "Unknown option '%s'.\n",
     554                                    argv[i]);
     555                                print_syntax();
     556                                return EINVAL;
     557                        }
     558                } else {
     559                        fprintf(stderr, "Unexpected argument.\n");
     560                        print_syntax();
     561                        return EINVAL;
     562                }
     563
     564                ++i;
     565        }
    512566
    513567        async_set_fallback_port_handler(client_connection, NULL);
     
    525579
    526580        inet_ep_init(&ep);
    527         ep.port = 2223;
     581        ep.port = port;
    528582
    529583        rc = tcp_listener_create(tcp, &ep, &listen_cb, NULL, &conn_cb, NULL,
  • uspace/srv/hid/remcons/user.c

    rd3109ff r6a753a9c  
    7373        user->id = ++telnet_user_id_counter;
    7474
    75         int rc = asprintf(&user->service_name, "%s/telnet%d", NAMESPACE, user->id);
     75        int rc = asprintf(&user->service_name, "%s/telnet%u.%d", NAMESPACE,
     76            (unsigned)task_get_id(), user->id);
    7677        if (rc < 0) {
    7778                free(user);
Note: See TracChangeset for help on using the changeset viewer.