Changeset 192565b in mainline for uspace/app


Ignore:
Timestamp:
2013-05-27T13:18:13Z (13 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
f2c19b0
Parents:
d120133 (diff), c90aed4 (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.
Message:

Merge mainline changes.

Location:
uspace/app
Files:
5 added
31 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/bdsh/cmds/modules/cat/cat.c

    rd120133 r192565b  
    117117static void waitkey()
    118118{
    119         kbd_event_t ev;
     119        cons_event_t ev;
     120        kbd_event_t *kev;
    120121       
    121122        while (true) {
    122                 if (!console_get_kbd_event(console, &ev)) {
     123                if (!console_get_event(console, &ev)) {
    123124                        return;
    124125                }
    125                 if (ev.type == KEY_PRESS) {
    126                         if (ev.key == KC_ESCAPE || ev.key == KC_Q) {
     126                if (ev.type == CEV_KEY && ev.ev.key.type == KEY_PRESS) {
     127                        kev = &ev.ev.key;
     128                       
     129                        if (kev->key == KC_ESCAPE || kev->key == KC_Q) {
    127130                                should_quit = true;
    128131                                return;
    129132                        }
    130                         if (ev.key == KC_C) {
     133                        if (kev->key == KC_C) {
    131134                                paging_enabled = false;
    132135                                return;
    133136                        }
    134                         if (ev.key == KC_ENTER || ev.key == KC_SPACE ||
    135                             ev.key == KC_PAGE_DOWN) {
     137                        if (kev->key == KC_ENTER || kev->key == KC_SPACE ||
     138                            kev->key == KC_PAGE_DOWN) {
    136139                                return;
    137140                        }
  • uspace/app/bdsh/cmds/modules/cmp/cmp.c

    rd120133 r192565b  
    107107
    108108                if (offset[0] != offset[1] ||
    109                     bcmp(buffer[0], buffer[1], offset[0])) {
     109                    memcmp(buffer[0], buffer[1], offset[0]) != 0) {
    110110                        rc = 1;
    111111                        goto end;
  • uspace/app/bdsh/cmds/modules/cp/cp.c

    rd120133 r192565b  
    152152
    153153        while (true) {
    154                 kbd_event_t ev;
     154                cons_event_t ev;
    155155                console_flush(con);
    156                 console_get_kbd_event(con, &ev);
    157                 if ((ev.type != KEY_PRESS)
    158                     || (ev.mods & (KM_CTRL | KM_ALT)) != 0) {
     156                console_get_event(con, &ev);
     157                if (ev.type != CEV_KEY || ev.ev.key.type != KEY_PRESS ||
     158                    (ev.ev.key.mods & (KM_CTRL | KM_ALT)) != 0) {
    159159                        continue;
    160160                }
    161161
    162                 switch(ev.key) {
     162                switch(ev.ev.key.key) {
    163163                case KC_Y:
    164164                        printf("y\n");
  • uspace/app/bdsh/cmds/modules/ls/ls.c

    rd120133 r192565b  
    315315{
    316316        if (stat(path, &de->s)) {
    317                 cli_error(CL_ENOENT, path);
     317                cli_error(CL_ENOENT, "%s", path);
    318318                return LS_BOGUS;
    319319        }
  • uspace/app/bdsh/cmds/modules/sleep/sleep.c

    rd120133 r192565b  
    114114        int ret;
    115115        unsigned int argc;
    116         useconds_t duration;
     116        useconds_t duration = 0;
    117117
    118118        /* Count the arguments */
  • uspace/app/bnchmark/bnchmark.c

    rd120133 r192565b  
    142142{
    143143        int rc;
    144         umseconds_t milliseconds_taken;
     144        umseconds_t milliseconds_taken = 0;
    145145        char *path = NULL;
    146146        measure_func_t fn = NULL;
  • uspace/app/edit/edit.c

    rd120133 r192565b  
    8080        tag_t sel_start;
    8181
     82        /** Active keyboard modifiers */
     83        keymod_t keymod;
     84
    8285        /**
    8386         * Ideal column where the caret should try to get. This is used
     
    119122static void cursor_setvis(bool visible);
    120123
     124static void key_handle_press(kbd_event_t *ev);
    121125static void key_handle_unmod(kbd_event_t const *ev);
    122126static void key_handle_ctrl(kbd_event_t const *ev);
     
    124128static void key_handle_shift_ctrl(kbd_event_t const *ev);
    125129static void key_handle_movement(unsigned int key, bool shift);
     130
     131static void pos_handle(pos_event_t *ev);
    126132
    127133static int file_save(char const *fname);
     
    182188int main(int argc, char *argv[])
    183189{
    184         kbd_event_t ev;
     190        cons_event_t ev;
    185191        bool new_file;
    186192        int rc;
     
    245251
    246252        while (!done) {
    247                 console_get_kbd_event(con, &ev);
     253                console_get_event(con, &ev);
    248254                pane.rflags = 0;
    249255
    250                 if (ev.type == KEY_PRESS) {
    251                         /* Handle key press. */
    252                         if (((ev.mods & KM_ALT) == 0) &&
    253                             ((ev.mods & KM_SHIFT) == 0) &&
    254                              (ev.mods & KM_CTRL) != 0) {
    255                                 key_handle_ctrl(&ev);
    256                         } else if (((ev.mods & KM_ALT) == 0) &&
    257                             ((ev.mods & KM_CTRL) == 0) &&
    258                              (ev.mods & KM_SHIFT) != 0) {
    259                                 key_handle_shift(&ev);
    260                         } else if (((ev.mods & KM_ALT) == 0) &&
    261                             ((ev.mods & KM_CTRL) != 0) &&
    262                              (ev.mods & KM_SHIFT) != 0) {
    263                                 key_handle_shift_ctrl(&ev);
    264                         } else if ((ev.mods & (KM_CTRL | KM_ALT | KM_SHIFT)) == 0) {
    265                                 key_handle_unmod(&ev);
    266                         }
     256                switch (ev.type) {
     257                case CEV_KEY:
     258                        pane.keymod = ev.ev.key.mods;
     259                        if (ev.ev.key.type == KEY_PRESS)
     260                                key_handle_press(&ev.ev.key);
     261                        break;
     262                case CEV_POS:
     263                        pos_handle(&ev.ev.pos);
     264                        break;
    267265                }
    268266
     
    286284
    287285        return 0;
     286}
     287
     288/* Handle key press. */
     289static void key_handle_press(kbd_event_t *ev)
     290{
     291        if (((ev->mods & KM_ALT) == 0) &&
     292            ((ev->mods & KM_SHIFT) == 0) &&
     293             (ev->mods & KM_CTRL) != 0) {
     294                key_handle_ctrl(ev);
     295        } else if (((ev->mods & KM_ALT) == 0) &&
     296            ((ev->mods & KM_CTRL) == 0) &&
     297             (ev->mods & KM_SHIFT) != 0) {
     298                key_handle_shift(ev);
     299        } else if (((ev->mods & KM_ALT) == 0) &&
     300            ((ev->mods & KM_CTRL) != 0) &&
     301             (ev->mods & KM_SHIFT) != 0) {
     302                key_handle_shift_ctrl(ev);
     303        } else if ((ev->mods & (KM_CTRL | KM_ALT | KM_SHIFT)) == 0) {
     304                key_handle_unmod(ev);
     305        }
    288306}
    289307
     
    462480}
    463481
     482static void pos_handle(pos_event_t *ev)
     483{
     484        coord_t bc;
     485        spt_t pt;
     486        bool select;
     487
     488        if (ev->type == POS_PRESS && ev->vpos < (unsigned)pane.rows) {
     489                bc.row = pane.sh_row + ev->vpos;
     490                bc.column = pane.sh_column + ev->hpos;
     491                sheet_get_cell_pt(doc.sh, &bc, dir_before, &pt);
     492
     493                select = (pane.keymod & KM_SHIFT) != 0;
     494
     495                caret_move(pt, select, true);
     496        }
     497}
     498
    464499/** Move caret while preserving or resetting selection. */
    465500static void caret_move(spt_t new_caret_pt, bool select, bool update_ideal_column)
     
    592627static char *prompt(char const *prompt, char const *init_value)
    593628{
    594         kbd_event_t ev;
     629        cons_event_t ev;
     630        kbd_event_t *kev;
    595631        char *str;
    596632        wchar_t buffer[INFNAME_MAX_LEN + 1];
     
    612648
    613649        while (!done) {
    614                 console_get_kbd_event(con, &ev);
    615 
    616                 if (ev.type == KEY_PRESS) {
     650                console_get_event(con, &ev);
     651
     652                if (ev.type == CEV_KEY && ev.ev.key.type == KEY_PRESS) {
     653                        kev = &ev.ev.key;
     654
    617655                        /* Handle key press. */
    618                         if (((ev.mods & KM_ALT) == 0) &&
    619                              (ev.mods & KM_CTRL) != 0) {
     656                        if (((kev->mods & KM_ALT) == 0) &&
     657                             (kev->mods & KM_CTRL) != 0) {
    620658                                ;
    621                         } else if ((ev.mods & (KM_CTRL | KM_ALT)) == 0) {
    622                                 switch (ev.key) {
     659                        } else if ((kev->mods & (KM_CTRL | KM_ALT)) == 0) {
     660                                switch (kev->key) {
    623661                                case KC_ESCAPE:
    624662                                        return NULL;
     
    634672                                        break;
    635673                                default:
    636                                         if (ev.c >= 32 && nc < max_len) {
    637                                                 putchar(ev.c);
     674                                        if (kev->c >= 32 && nc < max_len) {
     675                                                putchar(kev->c);
    638676                                                console_flush(con);
    639                                                 buffer[nc++] = ev.c;
     677                                                buffer[nc++] = kev->c;
    640678                                        }
    641679                                        break;
  • uspace/app/inet/inet.c

    rd120133 r192565b  
    11/*
    2  * Copyright (c) 2012 Jiri Svoboda
     2 * Copyright (c) 2013 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    3636
    3737#include <errno.h>
     38#include <inet/addr.h>
    3839#include <inet/inetcfg.h>
    3940#include <loc.h>
     
    5455}
    5556
    56 static int naddr_parse(const char *text, inet_naddr_t *naddr)
    57 {
    58         unsigned long a[4], bits;
    59         char *cp = (char *)text;
    60         int i;
    61 
    62         for (i = 0; i < 3; i++) {
    63                 a[i] = strtoul(cp, &cp, 10);
    64                 if (*cp != '.')
    65                         return EINVAL;
    66                 ++cp;
    67         }
    68 
    69         a[3] = strtoul(cp, &cp, 10);
    70         if (*cp != '/')
    71                 return EINVAL;
    72         ++cp;
    73 
    74         bits = strtoul(cp, &cp, 10);
    75         if (*cp != '\0')
    76                 return EINVAL;
    77 
    78         naddr->ipv4 = 0;
    79         for (i = 0; i < 4; i++) {
    80                 if (a[i] > 255)
    81                         return EINVAL;
    82                 naddr->ipv4 = (naddr->ipv4 << 8) | a[i];
    83         }
    84 
    85         if (bits > 31)
    86                 return EINVAL;
    87 
    88         naddr->bits = bits;
    89         return EOK;
    90 }
    91 
    92 static int addr_parse(const char *text, inet_addr_t *addr)
    93 {
    94         unsigned long a[4];
    95         char *cp = (char *)text;
    96         int i;
    97 
    98         for (i = 0; i < 3; i++) {
    99                 a[i] = strtoul(cp, &cp, 10);
    100                 if (*cp != '.')
    101                         return EINVAL;
    102                 ++cp;
    103         }
    104 
    105         a[3] = strtoul(cp, &cp, 10);
    106         if (*cp != '\0')
    107                 return EINVAL;
    108 
    109         addr->ipv4 = 0;
    110         for (i = 0; i < 4; i++) {
    111                 if (a[i] > 255)
    112                         return EINVAL;
    113                 addr->ipv4 = (addr->ipv4 << 8) | a[i];
    114         }
    115 
    116         return EOK;
    117 }
    118 
    119 static int naddr_format(inet_naddr_t *naddr, char **bufp)
    120 {
    121         int rc;
    122 
    123         rc = asprintf(bufp, "%d.%d.%d.%d/%d", naddr->ipv4 >> 24,
    124             (naddr->ipv4 >> 16) & 0xff, (naddr->ipv4 >> 8) & 0xff,
    125             naddr->ipv4 & 0xff, naddr->bits);
    126 
    127         if (rc < 0)
    128                 return ENOMEM;
    129 
    130         return EOK;
    131 }
    132 
    133 static int addr_format(inet_addr_t *addr, char **bufp)
    134 {
    135         int rc;
    136 
    137         rc = asprintf(bufp, "%d.%d.%d.%d", addr->ipv4 >> 24,
    138             (addr->ipv4 >> 16) & 0xff, (addr->ipv4 >> 8) & 0xff,
    139             addr->ipv4 & 0xff);
    140 
    141         if (rc < 0)
    142                 return ENOMEM;
    143 
    144         return EOK;
    145 }
    146 
    14757static int addr_create_static(int argc, char *argv[])
    14858{
     
    17888        }
    17989
    180         rc = naddr_parse(addr_spec, &naddr);
     90        rc = inet_naddr_parse(addr_spec, &naddr);
    18191        if (rc != EOK) {
    18292                printf(NAME ": Invalid network address format '%s'.\n",
     
    267177        route_name = argv[2];
    268178
    269         rc = naddr_parse(dest_str, &dest);
     179        rc = inet_naddr_parse(dest_str, &dest);
    270180        if (rc != EOK) {
    271181                printf(NAME ": Invalid network address format '%s'.\n",
     
    274184        }
    275185
    276         rc = addr_parse(router_str, &router);
     186        rc = inet_addr_parse(router_str, &router);
    277187        if (rc != EOK) {
    278188                printf(NAME ": Invalid address format '%s'.\n", router_str);
     
    366276                }
    367277
    368                 rc = naddr_format(&ainfo.naddr, &astr);
     278                rc = inet_naddr_format(&ainfo.naddr, &astr);
    369279                if (rc != EOK) {
    370280                        printf("Memory allocation failed.\n");
     
    430340                }
    431341
    432                 rc = naddr_format(&srinfo.dest, &dest_str);
     342                rc = inet_naddr_format(&srinfo.dest, &dest_str);
    433343                if (rc != EOK) {
    434344                        printf("Memory allocation failed.\n");
     
    437347                }
    438348
    439                 rc = addr_format(&srinfo.router, &router_str);
     349                rc = inet_addr_format(&srinfo.router, &router_str);
    440350                if (rc != EOK) {
    441351                        printf("Memory allocation failed.\n");
  • uspace/app/init/init.c

    rd120133 r192565b  
    359359        srv_start("/srv/tcp");
    360360        srv_start("/srv/udp");
     361        srv_start("/srv/dnsrsrv");
    361362       
    362363        srv_start("/srv/clipboard");
  • uspace/app/mkbd/main.c

    rd120133 r192565b  
    178178
    179179        while (1) {
    180                 kbd_event_t ev;
    181                 bool ok = console_get_kbd_event(con, &ev);
     180                cons_event_t ev;
     181                bool ok = console_get_event(con, &ev);
    182182                if (!ok) {
    183183                        printf("Connection with console broken: %s.\n",
     
    186186                }
    187187
    188                 if (ev.key == KC_ESCAPE) {
     188                if (ev.type == CEV_KEY && ev.ev.key.type == KEY_PRESS &&
     189                    ev.ev.key.key == KC_ESCAPE) {
    189190                        break;
    190191                }
  • uspace/app/msim/arch_helenos/input.c

    rd120133 r192565b  
    9191bool stdin_poll(char *key)
    9292{
    93         kbd_event_t ev;
     93        cons_event_t ev;
    9494        suseconds_t timeout = 0;
    9595        errno = EOK;
    9696        console_flush(input_prompt->console);
    97         bool has_input = console_get_kbd_event_timeout(input_prompt->console, &ev, &timeout);
     97        bool has_input = console_get_event_timeout(input_prompt->console, &ev, &timeout);
    9898        if (!has_input) {
    9999                return false;
    100100        }
    101101
    102         if (ev.type != KEY_PRESS)
     102        if (ev.type != CEV_KEY || ev.ev.key.type != KEY_PRESS)
    103103                return false;
    104104
    105         *key = ev.c;
     105        *key = ev.ev.key.c;
    106106
    107107        return true;
  • uspace/app/nettest1/nettest1.c

    rd120133 r192565b  
    4646#include <arg_parse.h>
    4747
     48#include <inet/dnsr.h>
    4849#include <net/in.h>
    4950#include <net/in6.h>
     
    7576        printf(
    7677            "Network Networking test 1 aplication - sockets\n"
    77             "Usage: echo [options] numeric_address\n"
     78            "Usage: nettest1 [options] host\n"
    7879            "Where options are:\n"
    7980            "-f protocol_family | --family=protocol_family\n"
     
    290291        struct sockaddr_in address_in;
    291292        struct sockaddr_in6 address_in6;
     293        dnsr_hostinfo_t *hinfo;
    292294        uint8_t *address_start;
    293295
     
    319321        }
    320322
    321         /* If not before the last argument containing the address */
     323        /* If not before the last argument containing the host */
    322324        if (index >= argc) {
    323                 printf("Command line error: missing address\n");
     325                printf("Command line error: missing host name\n");
    324326                nettest1_print_help();
    325327                return EINVAL;
     
    348350        }
    349351
    350         /* Parse the last argument which should contain the address */
     352        /* Parse the last argument which should contain the host/address */
    351353        rc = inet_pton(family, argv[argc - 1], address_start);
    352354        if (rc != EOK) {
    353                 fprintf(stderr, "Address parse error %d\n", rc);
    354                 return rc;
     355                /* Try interpreting as a host name */
     356                rc = dnsr_name2host(argv[argc - 1], &hinfo);
     357                if (rc != EOK) {
     358                        printf("Error resolving host '%s'.\n", argv[argc - 1]);
     359                        return rc;
     360                }
     361
     362                address_in.sin_addr.s_addr = host2uint32_t_be(hinfo->addr.ipv4);
    355363        }
    356364
  • uspace/app/nettest2/nettest2.c

    rd120133 r192565b  
    4747#include <stdbool.h>
    4848
     49#include <inet/dnsr.h>
    4950#include <net/in.h>
    5051#include <net/in6.h>
     
    7172        printf(
    7273            "Network Networking test 2 aplication - UDP transfer\n"
    73             "Usage: echo [options] address\n"
     74            "Usage: nettest2 [options] host\n"
    7475            "Where options are:\n"
    7576            "-f protocol_family | --family=protocol_family\n"
     
    227228        struct sockaddr_in address_in;
    228229        struct sockaddr_in6 address_in6;
     230        dnsr_hostinfo_t *hinfo;
    229231        socklen_t addrlen;
    230232        uint8_t *address_start;
     
    265267        }
    266268
    267         /* If not before the last argument containing the address */
     269        /* If not before the last argument containing the host */
    268270        if (index >= argc) {
    269                 printf("Command line error: missing address\n");
     271                printf("Command line error: missing host name\n");
    270272                nettest2_print_help();
    271273                return EINVAL;
     
    294296        }
    295297
    296         /* Parse the last argument which should contain the address. */
     298        /* Parse the last argument which should contain the host/address */
    297299        rc = inet_pton(family, argv[argc - 1], address_start);
    298300        if (rc != EOK) {
    299                 fprintf(stderr, "Address parse error %d\n", rc);
    300                 return rc;
     301                /* Try interpreting as a host name */
     302                rc = dnsr_name2host(argv[argc - 1], &hinfo);
     303                if (rc != EOK) {
     304                        printf("Error resolving host '%s'.\n", argv[argc - 1]);
     305                        return rc;
     306                }
     307
     308                address_in.sin_addr.s_addr = host2uint32_t_be(hinfo->addr.ipv4);
    301309        }
    302310
  • uspace/app/nettest3/nettest3.c

    rd120133 r192565b  
    3939#include <str.h>
    4040
     41#include <inet/dnsr.h>
    4142#include <net/in.h>
    4243#include <net/in6.h>
     
    6061        int fd;
    6162        char *endptr;
     63        dnsr_hostinfo_t *hinfo;
    6264
    6365        port = 7;
     
    7577                rc = inet_pton(AF_INET, argv[1], (uint8_t *)&addr.sin_addr.s_addr);
    7678                if (rc != EOK) {
    77                         fprintf(stderr, "Error parsing address\n");
    78                         return 1;
     79                        /* Try interpreting as a host name */
     80                        rc = dnsr_name2host(argv[1], &hinfo);
     81                        if (rc != EOK) {
     82                                printf("Error resolving host '%s'.\n", argv[1]);
     83                                return rc;
     84                        }
     85
     86                        addr.sin_addr.s_addr = host2uint32_t_be(hinfo->addr.ipv4);
     87                        addr.sin_family = AF_INET;
    7988                }
    8089                printf("result: rc=%d, family=%d, addr=%x\n", rc,
  • uspace/app/nterm/conn.c

    rd120133 r192565b  
    3333 */
    3434
     35#include <byteorder.h>
    3536#include <stdbool.h>
    3637#include <errno.h>
    3738#include <fibril.h>
     39#include <inet/dnsr.h>
    3840#include <net/socket.h>
    3941#include <stdio.h>
     
    7476{
    7577        struct sockaddr_in addr;
     78        dnsr_hostinfo_t *hinfo = NULL;
    7679        int rc;
    7780        char *endptr;
     
    8184        rc = inet_pton(addr.sin_family, addr_s, (uint8_t *)&addr.sin_addr);
    8285        if (rc != EOK) {
    83                 printf("Invalid addres %s\n", addr_s);
    84                 return EINVAL;
     86                /* Try interpreting as a host name */
     87                rc = dnsr_name2host(addr_s, &hinfo);
     88                if (rc != EOK) {
     89                        printf("Error resolving host '%s'.\n", addr_s);
     90                        goto error;
     91                }
     92
     93                addr.sin_addr.s_addr = host2uint32_t_be(hinfo->addr.ipv4);
    8594        }
    8695
     
    8897        if (*endptr != '\0') {
    8998                printf("Invalid port number %s\n", port_s);
    90                 return EINVAL;
     99                goto error;
    91100        }
    92101
     
    95104                goto error;
    96105
    97         printf("Connecting to address %s port %u\n", addr_s, ntohs(addr.sin_port));
     106        printf("Connecting to host %s port %u\n", addr_s, ntohs(addr.sin_port));
    98107
    99108        rc = connect(conn_fd, (struct sockaddr *)&addr, sizeof(addr));
  • uspace/app/nterm/nterm.c

    rd120133 r192565b  
    104104static void print_syntax(void)
    105105{
    106         printf("syntax: nterm <ip-address> <port>\n");
     106        printf("syntax: nterm <host> <port>\n");
    107107}
    108108
    109109int main(int argc, char *argv[])
    110110{
    111         kbd_event_t ev;
     111        cons_event_t ev;
    112112        int rc;
    113113
     
    129129        done = false;
    130130        while (!done) {
    131                 console_get_kbd_event(con, &ev);
    132                 if (ev.type == KEY_PRESS)
    133                         key_handle(&ev);
     131                console_get_event(con, &ev);
     132                if (ev.type == CEV_KEY && ev.ev.key.type == KEY_PRESS)
     133                        key_handle(&ev.ev.key);
    134134        }
    135135
  • uspace/app/ping/ping.c

    rd120133 r192565b  
    11/*
    2  * Copyright (c) 2012 Jiri Svoboda
     2 * Copyright (c) 2013 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    3737#include <errno.h>
    3838#include <fibril_synch.h>
     39#include <inet/dnsr.h>
     40#include <inet/addr.h>
    3941#include <inet/inetping.h>
    4042#include <io/console.h>
     
    6870static void print_syntax(void)
    6971{
    70         printf("syntax: " NAME " [-r] <addr>\n");
    71 }
    72 
    73 static int addr_parse(const char *text, inet_addr_t *addr)
    74 {
    75         unsigned long a[4];
    76         char *cp = (char *)text;
    77         int i;
    78 
    79         for (i = 0; i < 3; i++) {
    80                 a[i] = strtoul(cp, &cp, 10);
    81                 if (*cp != '.')
    82                         return EINVAL;
    83                 ++cp;
    84         }
    85 
    86         a[3] = strtoul(cp, &cp, 10);
    87         if (*cp != '\0')
    88                 return EINVAL;
    89 
    90         addr->ipv4 = 0;
    91         for (i = 0; i < 4; i++) {
    92                 if (a[i] > 255)
    93                         return EINVAL;
    94                 addr->ipv4 = (addr->ipv4 << 8) | a[i];
    95         }
    96 
    97         return EOK;
    98 }
    99 
    100 static int addr_format(inet_addr_t *addr, char **bufp)
    101 {
    102         int rc;
    103 
    104         rc = asprintf(bufp, "%d.%d.%d.%d", addr->ipv4 >> 24,
    105             (addr->ipv4 >> 16) & 0xff, (addr->ipv4 >> 8) & 0xff,
    106             addr->ipv4 & 0xff);
    107 
    108         if (rc < 0)
    109                 return ENOMEM;
    110 
    111         return EOK;
     72        printf("syntax: " NAME " [-r] <host>\n");
    11273}
    11374
     
    12586        int rc;
    12687
    127         rc = addr_format(&sdu->src, &asrc);
     88        rc = inet_addr_format(&sdu->src, &asrc);
    12889        if (rc != EOK)
    12990                return ENOMEM;
    13091
    131         rc = addr_format(&sdu->dest, &adest);
     92        rc = inet_addr_format(&sdu->dest, &adest);
    13293        if (rc != EOK) {
    13394                free(asrc);
     
    188149{
    189150        console_ctrl_t *con;
    190         kbd_event_t ev;
     151        cons_event_t ev;
    191152
    192153        con = console_init(stdin, stdout);
     
    194155
    195156        while (true) {
    196                 if (!console_get_kbd_event(con, &ev))
     157                if (!console_get_event(con, &ev))
    197158                        break;
    198159
    199                 if (ev.type == KEY_PRESS && (ev.mods & (KM_ALT | KM_SHIFT)) ==
    200                     0 && (ev.mods & KM_CTRL) != 0) {
     160                if (ev.type == CEV_KEY && ev.ev.key.type == KEY_PRESS &&
     161                    (ev.ev.key.mods & (KM_ALT | KM_SHIFT)) ==
     162                    0 && (ev.ev.key.mods & KM_CTRL) != 0) {
    201163                        /* Ctrl+key */
    202                         if (ev.key == KC_Q) {
     164                        if (ev.ev.key.key == KC_Q) {
    203165                                ping_signal_done();
    204166                                return 0;
     
    212174int main(int argc, char *argv[])
    213175{
     176        dnsr_hostinfo_t *hinfo = NULL;
     177        char *asrc = NULL;
     178        char *adest = NULL;
     179        char *sdest = NULL;
    214180        int rc;
    215181        int argi;
     
    219185                printf(NAME ": Failed connecting to internet ping service "
    220186                    "(%d).\n", rc);
    221                 return 1;
     187                goto error;
    222188        }
    223189
     
    232198        if (argc - argi != 1) {
    233199                print_syntax();
    234                 return 1;
     200                goto error;
    235201        }
    236202
    237203        /* Parse destination address */
    238         rc = addr_parse(argv[argi], &dest_addr);
    239         if (rc != EOK) {
    240                 printf(NAME ": Invalid address format.\n");
    241                 print_syntax();
    242                 return 1;
     204        rc = inet_addr_parse(argv[argi], &dest_addr);
     205        if (rc != EOK) {
     206                /* Try interpreting as a host name */
     207                rc = dnsr_name2host(argv[argi], &hinfo);
     208                if (rc != EOK) {
     209                        printf(NAME ": Error resolving host '%s'.\n", argv[argi]);
     210                        goto error;
     211                }
     212
     213                dest_addr = hinfo->addr;
    243214        }
    244215
     
    247218        if (rc != EOK) {
    248219                printf(NAME ": Failed determining source address.\n");
    249                 return 1;
    250         }
     220                goto error;
     221        }
     222
     223        rc = inet_addr_format(&src_addr, &asrc);
     224        if (rc != EOK) {
     225                printf(NAME ": Out of memory.\n");
     226                goto error;
     227        }
     228
     229        rc = inet_addr_format(&dest_addr, &adest);
     230        if (rc != EOK) {
     231                printf(NAME ": Out of memory.\n");
     232                goto error;
     233        }
     234
     235        if (hinfo != NULL) {
     236                rc = asprintf(&sdest, "%s (%s)", hinfo->cname, adest);
     237                if (rc < 0) {
     238                        printf(NAME ": Out of memory.\n");
     239                        goto error;
     240                }
     241        } else {
     242                sdest = adest;
     243                adest = NULL;
     244        }
     245
     246        printf("Sending ICMP echo request from %s to %s.\n",
     247            asrc, sdest);
    251248
    252249        fid_t fid;
     
    256253                if (fid == 0) {
    257254                        printf(NAME ": Failed creating transmit fibril.\n");
    258                         return 1;
     255                        goto error;
    259256                }
    260257
     
    264261                if (fid == 0) {
    265262                        printf(NAME ": Failed creating input fibril.\n");
    266                         return 1;
     263                        goto error;
    267264                }
    268265
     
    282279        if (rc == ETIMEOUT) {
    283280                printf(NAME ": Echo request timed out.\n");
    284                 return 1;
    285         }
    286 
     281                goto error;
     282        }
     283
     284        free(asrc);
     285        free(adest);
     286        free(sdest);
     287        dnsr_hostinfo_destroy(hinfo);
    287288        return 0;
     289error:
     290        free(asrc);
     291        free(adest);
     292        free(sdest);
     293        dnsr_hostinfo_destroy(hinfo);
     294        return 1;
    288295}
    289296
  • uspace/app/taskdump/symtab.c

    rd120133 r192565b  
    267267                        continue;
    268268
    269                 if (best_name == NULL || (saddr <= addr && saddr > best_addr)) {
     269                if (saddr <= addr && (best_name == NULL || saddr > best_addr)) {
    270270                        best_name = sname;
    271271                        best_addr = saddr;
  • uspace/app/tester/ipc/starve.c

    rd120133 r192565b  
    6262                        break;
    6363               
    64                 kbd_event_t ev;
     64                cons_event_t ev;
    6565                suseconds_t timeout = 0;
    66                 bool has_event = console_get_kbd_event_timeout(console, &ev, &timeout);
    67                 if (has_event && (ev.type == KEY_PRESS)) {
    68                         TPRINTF("Key %d pressed, terminating.\n", ev.key);
     66                bool has_event = console_get_event_timeout(console, &ev, &timeout);
     67                if (has_event && ev.type == CEV_KEY && ev.ev.key.type == KEY_PRESS) {
     68                        TPRINTF("Key %d pressed, terminating.\n", ev.ev.key.key);
    6969                        break;
    7070                }
  • uspace/app/tetris/scores.c

    rd120133 r192565b  
    125125        int j;
    126126        size_t off;
    127         kbd_event_t ev;
     127        cons_event_t ev;
     128        kbd_event_t *kev;
    128129       
    129130        clear_screen();
     
    141142        while (1) {
    142143                console_flush(console);
    143                 if (!console_get_kbd_event(console, &ev))
     144                if (!console_get_event(console, &ev))
    144145                        exit(1);
    145146               
    146                 if (ev.type == KEY_RELEASE)
     147                if (ev.type != CEV_KEY || ev.ev.key.type == KEY_RELEASE)
    147148                        continue;
    148149               
    149                 if (ev.key == KC_ENTER || ev.key == KC_NENTER)
     150                kev = &ev.ev.key;
     151               
     152                if (kev->key == KC_ENTER || kev->key == KC_NENTER)
    150153                        break;
    151154               
    152                 if (ev.key == KC_BACKSPACE) {
     155                if (kev->key == KC_BACKSPACE) {
    153156                        if (i > 0) {
    154157                                wchar_t uc;
     
    166169                                scores[NUMSPOTS - 1].hs_name[off] = '\0';
    167170                        }
    168                 } else if (ev.c != '\0') {
     171                } else if (kev->c != '\0') {
    169172                        if (i < (MAXLOGNAME - 1)) {
    170                                 if (chr_encode(ev.c, scores[NUMSPOTS - 1].hs_name,
     173                                if (chr_encode(kev->c, scores[NUMSPOTS - 1].hs_name,
    171174                                    &off, STR_BOUNDS(MAXLOGNAME) + 1) == EOK) {
    172175                                        ++i;
  • uspace/app/tetris/screen.c

    rd120133 r192565b  
    344344       
    345345        while (timeout > 0) {
    346                 kbd_event_t event;
    347                
    348                 if (!console_get_kbd_event_timeout(console, &event, &timeout))
     346                cons_event_t event;
     347               
     348                if (!console_get_event_timeout(console, &event, &timeout))
    349349                        break;
    350350        }
     
    376376       
    377377        while (c == 0) {
    378                 kbd_event_t event;
    379                
    380                 if (!console_get_kbd_event_timeout(console, &event, &timeleft)) {
     378                cons_event_t event;
     379               
     380                if (!console_get_event_timeout(console, &event, &timeleft)) {
    381381                        timeleft = 0;
    382382                        return -1;
    383383                }
    384384               
    385                 if (event.type == KEY_PRESS)
    386                         c = event.c;
     385                if (event.type == CEV_KEY && event.ev.key.type == KEY_PRESS)
     386                        c = event.ev.key.c;
    387387        }
    388388       
     
    398398       
    399399        while (c == 0) {
    400                 kbd_event_t event;
    401                
    402                 if (!console_get_kbd_event(console, &event))
     400                cons_event_t event;
     401               
     402                if (!console_get_event(console, &event))
    403403                        return -1;
    404404               
    405                 if (event.type == KEY_PRESS)
    406                         c = event.c;
     405                if (event.type == CEV_KEY && event.ev.key.type == KEY_PRESS)
     406                        c = event.ev.key.c;
    407407        }
    408408       
  • uspace/app/top/screen.c

    rd120133 r192565b  
    556556       
    557557        while (c == 0) {
    558                 kbd_event_t event;
     558                cons_event_t event;
    559559               
    560560                warning_timeleft -= timeleft;
    561                 if (!console_get_kbd_event_timeout(console, &event, &timeleft)) {
     561                if (!console_get_event_timeout(console, &event, &timeleft)) {
    562562                        timeleft = 0;
    563563                        return -1;
     
    565565                warning_timeleft += timeleft;
    566566               
    567                 if (event.type == KEY_PRESS)
    568                         c = event.c;
     567                if (event.type == CEV_KEY && event.ev.key.type == KEY_PRESS)
     568                        c = event.ev.key.c;
    569569        }
    570570       
  • uspace/app/trace/ipc_desc.c

    rd120133 r192565b  
    4949        { IPC_M_DATA_READ,        "DATA_READ" },
    5050        { IPC_M_DEBUG,            "DEBUG" },
    51        
    52         /* Terminating entry */
    53         { 0, NULL }
    5451};
     52
     53size_t ipc_methods_len = sizeof(ipc_methods) / sizeof(ipc_m_desc_t);
    5554
    5655/** @}
  • uspace/app/trace/ipc_desc.h

    rd120133 r192565b  
    4242
    4343extern ipc_m_desc_t ipc_methods[];
     44extern size_t ipc_methods_len;
    4445
    4546#endif
  • uspace/app/trace/ipcp.c

    rd120133 r192565b  
    140140void ipcp_init(void)
    141141{
    142         ipc_m_desc_t *desc;
    143         oper_t *oper;
    144 
    145142        val_type_t arg_def[OPER_MAX_ARGS] = {
    146143                V_INTEGER,
     
    162159        proto_system = proto_new("system");
    163160
    164         desc = ipc_methods;
    165         while (desc->number != 0) {
    166                 oper = oper_new(desc->name, OPER_MAX_ARGS, arg_def, V_INTEGER,
    167                         OPER_MAX_ARGS, arg_def);
    168                 proto_add_oper(proto_system, desc->number, oper);
    169 
    170                 ++desc;
     161        for (size_t i = 0; i < ipc_methods_len; i++) {
     162                oper_t *oper = oper_new(ipc_methods[i].name, OPER_MAX_ARGS,
     163                    arg_def, V_INTEGER, OPER_MAX_ARGS, arg_def);
     164                proto_add_oper(proto_system, ipc_methods[i].number, oper);
    171165        }
    172166
  • uspace/app/trace/syscalls.c

    rd120133 r192565b  
    4646
    4747    [SYS_TASK_GET_ID] = { "task_get_id",                1,      V_ERRNO },
     48    [SYS_TASK_SET_NAME] = { "task_set_name",            2,      V_ERRNO },
    4849    [SYS_FUTEX_SLEEP] = { "futex_sleep_timeout",        3,      V_ERRNO },
    4950    [SYS_FUTEX_WAKEUP] = { "futex_wakeup",              1,      V_ERRNO },
     
    8283};
    8384
     85const size_t syscall_desc_len = (sizeof(syscall_desc) / sizeof(sc_desc_t));
     86
    8487/** @}
    8588 */
  • uspace/app/trace/syscalls.h

    rd120133 r192565b  
    3636#define SYSCALLS_H_
    3737
     38#include <stdbool.h>
     39#include <unistd.h>
     40
    3841#include "trace.h"
    3942
     
    4548
    4649extern const sc_desc_t syscall_desc[];
     50extern const size_t syscall_desc_len;
     51
     52static inline bool syscall_desc_defined(unsigned sc_id)
     53{
     54        return (sc_id < syscall_desc_len && syscall_desc[sc_id].name != NULL);
     55}
    4756
    4857#endif
  • uspace/app/trace/trace.c

    rd120133 r192565b  
    136136        }
    137137
    138         free(task_ldr);
    139138        task_ldr = NULL;
    140139
     
    348347        if ((display_mask & DM_SYSCALL) != 0) {
    349348                /* Print syscall name and arguments */
    350                 printf("%s", syscall_desc[sc_id].name);
    351                 print_sc_args(sc_args, syscall_desc[sc_id].n_args);
     349                if (syscall_desc_defined(sc_id)) {
     350                        printf("%s", syscall_desc[sc_id].name);
     351                        print_sc_args(sc_args, syscall_desc[sc_id].n_args);
     352                }
     353                else {
     354                        printf("unknown_syscall<%d>", sc_id);
     355                        print_sc_args(sc_args, 6);
     356                }
    352357        }
    353358}
     
    372377        if ((display_mask & DM_SYSCALL) != 0) {
    373378                /* Print syscall return value */
    374                 rv_type = syscall_desc[sc_id].rv_type;
     379                if (syscall_desc_defined(sc_id))
     380                        rv_type = syscall_desc[sc_id].rv_type;
     381                else
     382                        rv_type = V_PTR;
    375383                print_sc_retval(sc_rc, rv_type);
    376384        }
     
    497505        ldr = loader_connect();
    498506        if (ldr == NULL)
    499                 return 0;
     507                return NULL;
    500508
    501509        /* Get task ID. */
     
    557565static int cev_fibril(void *arg)
    558566{
     567        cons_event_t event;
     568
    559569        (void) arg;
    560570       
     
    567577                fibril_mutex_unlock(&state_lock);
    568578               
    569                 if (!console_get_kbd_event(console, &cev))
     579                if (!console_get_event(console, &event))
    570580                        return -1;
    571581               
    572                 fibril_mutex_lock(&state_lock);
    573                 cev_valid = true;
    574                 fibril_condvar_broadcast(&state_cv);
    575                 fibril_mutex_unlock(&state_lock);
     582                if (event.type == CEV_KEY) {
     583                        fibril_mutex_lock(&state_lock);
     584                        cev = event.ev.key;
     585                        cev_valid = true;
     586                        fibril_condvar_broadcast(&state_cv);
     587                        fibril_mutex_unlock(&state_lock);
     588                }
    576589        }
    577590}
  • uspace/app/vdemo/vdemo.c

    rd120133 r192565b  
    141141                    lbl_action->cancel);
    142142
    143                 grid->add(grid, &lbl_action->label.widget, 0, 0, 1, 2);
    144                 grid->add(grid, &btn_confirm->widget, 1, 0, 1, 1);
     143                grid->add(grid, &lbl_action->label.widget, 0, 0, 2, 1);
     144                grid->add(grid, &btn_confirm->widget, 0, 1, 1, 1);
    145145                grid->add(grid, &btn_cancel->widget, 1, 1, 1, 1);
    146                 window_resize(main_window, 200, 70);
     146                window_resize(main_window, 200, 76);
    147147
    148148                window_exec(main_window);
  • uspace/app/vlaunch/Makefile

    rd120133 r192565b  
    3535
    3636SOURCES = \
    37         vlaunch.c
     37        vlaunch.c \
     38        images.c
     39
     40IMAGES = \
     41        gfx/helenos.tga
     42
     43PRE_DEPEND = images.c images.h
     44EXTRA_CLEAN = images.c images.h
    3845
    3946include $(USPACE_PREFIX)/Makefile.common
     47
     48images.c images.h: $(IMAGES)
     49        $(ROOT_PATH)/tools/mkarray.py images COMPOSITOR_IMAGES $^
  • uspace/app/vlaunch/vlaunch.c

    rd120133 r192565b  
    4646#include <button.h>
    4747#include <label.h>
     48#include <canvas.h>
    4849
    49 #define NAME "vlaunch"
     50#include <surface.h>
     51#include <source.h>
     52#include <drawctx.h>
     53#include <codec/tga.h>
     54
     55#include "images.h"
     56
     57#define NAME  "vlaunch"
     58
     59#define LOGO_WIDTH   196
     60#define LOGO_HEIGHT  66
    5061
    5162static char *winreg = NULL;
     
    97108        }
    98109       
     110        surface_t *logo = decode_tga((void *) helenos_tga, helenos_tga_size, 0);
     111        if (!logo) {
     112                printf("Unable to decode logo.\n");
     113                return 1;
     114        }
     115       
    99116        winreg = argv[1];
    100117        window_t *main_window = window_open(argv[1], true, true, "vlaunch", 0, 0);
     
    104121        }
    105122       
    106         pixel_t grd_bg = PIXEL(255, 240, 240, 240);
     123        pixel_t grd_bg = PIXEL(255, 255, 255, 255);
    107124        pixel_t btn_bg = PIXEL(255, 0, 0, 0);
    108125        pixel_t btn_fg = PIXEL(255, 240, 240, 240);
    109         pixel_t lbl_bg = PIXEL(255, 240, 240, 240);
     126        pixel_t lbl_bg = PIXEL(255, 255, 255, 255);
    110127        pixel_t lbl_fg = PIXEL(255, 0, 0, 0);
    111128       
     129        canvas_t *logo_canvas = create_canvas(NULL, LOGO_WIDTH, LOGO_HEIGHT,
     130            logo);
    112131        label_t *lbl_caption = create_label(NULL, "Launch application:", 16,
    113132            lbl_bg, lbl_fg);
     
    118137        button_t *btn_vlaunch = create_button(NULL, "vlaunch", 16, btn_bg,
    119138            btn_fg);
    120         grid_t *grid = create_grid(window_root(main_window), 4, 1, grd_bg);
     139        grid_t *grid = create_grid(window_root(main_window), 1, 5, grd_bg);
    121140       
    122         if ((!lbl_caption) || (!btn_vterm) || (!btn_vdemo) ||
    123             (!btn_vlaunch) || (!grid)) {
     141        if ((!logo_canvas) || (!lbl_caption) || (!btn_vterm) ||
     142            (!btn_vdemo) || (!btn_vlaunch) || (!grid)) {
    124143                window_close(main_window);
    125144                printf("Cannot create widgets.\n");
     
    131150        sig_connect(&btn_vlaunch->clicked, NULL, on_vlaunch);
    132151       
    133         grid->add(grid, &lbl_caption->widget, 0, 0, 1, 1);
    134         grid->add(grid, &btn_vterm->widget, 1, 0, 1, 1);
    135         grid->add(grid, &btn_vdemo->widget, 2, 0, 1, 1);
    136         grid->add(grid, &btn_vlaunch->widget, 3, 0, 1, 1);
     152        grid->add(grid, &logo_canvas->widget, 0, 0, 1, 1);
     153        grid->add(grid, &lbl_caption->widget, 0, 1, 1, 1);
     154        grid->add(grid, &btn_vterm->widget, 0, 2, 1, 1);
     155        grid->add(grid, &btn_vdemo->widget, 0, 3, 1, 1);
     156        grid->add(grid, &btn_vlaunch->widget, 0, 4, 1, 1);
    137157       
    138         window_resize(main_window, 180, 130);
     158        window_resize(main_window, 210, 130 + LOGO_HEIGHT);
    139159        window_exec(main_window);
     160       
    140161        task_retval(0);
    141162        async_manager();
Note: See TracChangeset for help on using the changeset viewer.