Changeset 192565b in mainline for uspace/app
- Timestamp:
- 2013-05-27T13:18:13Z (13 years ago)
- 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. - Location:
- uspace/app
- Files:
-
- 5 added
- 31 edited
-
bdsh/cmds/modules/cat/cat.c (modified) (1 diff)
-
bdsh/cmds/modules/cmp/cmp.c (modified) (1 diff)
-
bdsh/cmds/modules/cp/cp.c (modified) (1 diff)
-
bdsh/cmds/modules/ls/ls.c (modified) (1 diff)
-
bdsh/cmds/modules/sleep/sleep.c (modified) (1 diff)
-
bnchmark/bnchmark.c (modified) (1 diff)
-
dnscfg/Makefile (added)
-
dnscfg/dnscfg.c (added)
-
dnsres/Makefile (added)
-
dnsres/dnsres.c (added)
-
edit/edit.c (modified) (10 diffs)
-
inet/inet.c (modified) (9 diffs)
-
init/init.c (modified) (1 diff)
-
mkbd/main.c (modified) (2 diffs)
-
msim/arch_helenos/input.c (modified) (1 diff)
-
nettest1/nettest1.c (modified) (5 diffs)
-
nettest2/nettest2.c (modified) (5 diffs)
-
nettest3/nettest3.c (modified) (3 diffs)
-
nterm/conn.c (modified) (5 diffs)
-
nterm/nterm.c (modified) (2 diffs)
-
ping/ping.c (modified) (13 diffs)
-
taskdump/symtab.c (modified) (1 diff)
-
tester/ipc/starve.c (modified) (1 diff)
-
tetris/scores.c (modified) (3 diffs)
-
tetris/screen.c (modified) (3 diffs)
-
top/screen.c (modified) (2 diffs)
-
trace/ipc_desc.c (modified) (1 diff)
-
trace/ipc_desc.h (modified) (1 diff)
-
trace/ipcp.c (modified) (2 diffs)
-
trace/syscalls.c (modified) (2 diffs)
-
trace/syscalls.h (modified) (2 diffs)
-
trace/trace.c (modified) (6 diffs)
-
vdemo/vdemo.c (modified) (1 diff)
-
vlaunch/Makefile (modified) (1 diff)
-
vlaunch/gfx/helenos.tga (added)
-
vlaunch/vlaunch.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/bdsh/cmds/modules/cat/cat.c
rd120133 r192565b 117 117 static void waitkey() 118 118 { 119 kbd_event_t ev; 119 cons_event_t ev; 120 kbd_event_t *kev; 120 121 121 122 while (true) { 122 if (!console_get_ kbd_event(console, &ev)) {123 if (!console_get_event(console, &ev)) { 123 124 return; 124 125 } 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) { 127 130 should_quit = true; 128 131 return; 129 132 } 130 if ( ev.key == KC_C) {133 if (kev->key == KC_C) { 131 134 paging_enabled = false; 132 135 return; 133 136 } 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) { 136 139 return; 137 140 } -
uspace/app/bdsh/cmds/modules/cmp/cmp.c
rd120133 r192565b 107 107 108 108 if (offset[0] != offset[1] || 109 bcmp(buffer[0], buffer[1], offset[0])) {109 memcmp(buffer[0], buffer[1], offset[0]) != 0) { 110 110 rc = 1; 111 111 goto end; -
uspace/app/bdsh/cmds/modules/cp/cp.c
rd120133 r192565b 152 152 153 153 while (true) { 154 kbd_event_t ev;154 cons_event_t ev; 155 155 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) { 159 159 continue; 160 160 } 161 161 162 switch(ev. key) {162 switch(ev.ev.key.key) { 163 163 case KC_Y: 164 164 printf("y\n"); -
uspace/app/bdsh/cmds/modules/ls/ls.c
rd120133 r192565b 315 315 { 316 316 if (stat(path, &de->s)) { 317 cli_error(CL_ENOENT, path);317 cli_error(CL_ENOENT, "%s", path); 318 318 return LS_BOGUS; 319 319 } -
uspace/app/bdsh/cmds/modules/sleep/sleep.c
rd120133 r192565b 114 114 int ret; 115 115 unsigned int argc; 116 useconds_t duration ;116 useconds_t duration = 0; 117 117 118 118 /* Count the arguments */ -
uspace/app/bnchmark/bnchmark.c
rd120133 r192565b 142 142 { 143 143 int rc; 144 umseconds_t milliseconds_taken ;144 umseconds_t milliseconds_taken = 0; 145 145 char *path = NULL; 146 146 measure_func_t fn = NULL; -
uspace/app/edit/edit.c
rd120133 r192565b 80 80 tag_t sel_start; 81 81 82 /** Active keyboard modifiers */ 83 keymod_t keymod; 84 82 85 /** 83 86 * Ideal column where the caret should try to get. This is used … … 119 122 static void cursor_setvis(bool visible); 120 123 124 static void key_handle_press(kbd_event_t *ev); 121 125 static void key_handle_unmod(kbd_event_t const *ev); 122 126 static void key_handle_ctrl(kbd_event_t const *ev); … … 124 128 static void key_handle_shift_ctrl(kbd_event_t const *ev); 125 129 static void key_handle_movement(unsigned int key, bool shift); 130 131 static void pos_handle(pos_event_t *ev); 126 132 127 133 static int file_save(char const *fname); … … 182 188 int main(int argc, char *argv[]) 183 189 { 184 kbd_event_t ev;190 cons_event_t ev; 185 191 bool new_file; 186 192 int rc; … … 245 251 246 252 while (!done) { 247 console_get_ kbd_event(con, &ev);253 console_get_event(con, &ev); 248 254 pane.rflags = 0; 249 255 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; 267 265 } 268 266 … … 286 284 287 285 return 0; 286 } 287 288 /* Handle key press. */ 289 static 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 } 288 306 } 289 307 … … 462 480 } 463 481 482 static 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 464 499 /** Move caret while preserving or resetting selection. */ 465 500 static void caret_move(spt_t new_caret_pt, bool select, bool update_ideal_column) … … 592 627 static char *prompt(char const *prompt, char const *init_value) 593 628 { 594 kbd_event_t ev; 629 cons_event_t ev; 630 kbd_event_t *kev; 595 631 char *str; 596 632 wchar_t buffer[INFNAME_MAX_LEN + 1]; … … 612 648 613 649 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 617 655 /* 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) { 620 658 ; 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) { 623 661 case KC_ESCAPE: 624 662 return NULL; … … 634 672 break; 635 673 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); 638 676 console_flush(con); 639 buffer[nc++] = ev.c;677 buffer[nc++] = kev->c; 640 678 } 641 679 break; -
uspace/app/inet/inet.c
rd120133 r192565b 1 1 /* 2 * Copyright (c) 201 2Jiri Svoboda2 * Copyright (c) 2013 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 36 36 37 37 #include <errno.h> 38 #include <inet/addr.h> 38 39 #include <inet/inetcfg.h> 39 40 #include <loc.h> … … 54 55 } 55 56 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 147 57 static int addr_create_static(int argc, char *argv[]) 148 58 { … … 178 88 } 179 89 180 rc = naddr_parse(addr_spec, &naddr);90 rc = inet_naddr_parse(addr_spec, &naddr); 181 91 if (rc != EOK) { 182 92 printf(NAME ": Invalid network address format '%s'.\n", … … 267 177 route_name = argv[2]; 268 178 269 rc = naddr_parse(dest_str, &dest);179 rc = inet_naddr_parse(dest_str, &dest); 270 180 if (rc != EOK) { 271 181 printf(NAME ": Invalid network address format '%s'.\n", … … 274 184 } 275 185 276 rc = addr_parse(router_str, &router);186 rc = inet_addr_parse(router_str, &router); 277 187 if (rc != EOK) { 278 188 printf(NAME ": Invalid address format '%s'.\n", router_str); … … 366 276 } 367 277 368 rc = naddr_format(&ainfo.naddr, &astr);278 rc = inet_naddr_format(&ainfo.naddr, &astr); 369 279 if (rc != EOK) { 370 280 printf("Memory allocation failed.\n"); … … 430 340 } 431 341 432 rc = naddr_format(&srinfo.dest, &dest_str);342 rc = inet_naddr_format(&srinfo.dest, &dest_str); 433 343 if (rc != EOK) { 434 344 printf("Memory allocation failed.\n"); … … 437 347 } 438 348 439 rc = addr_format(&srinfo.router, &router_str);349 rc = inet_addr_format(&srinfo.router, &router_str); 440 350 if (rc != EOK) { 441 351 printf("Memory allocation failed.\n"); -
uspace/app/init/init.c
rd120133 r192565b 359 359 srv_start("/srv/tcp"); 360 360 srv_start("/srv/udp"); 361 srv_start("/srv/dnsrsrv"); 361 362 362 363 srv_start("/srv/clipboard"); -
uspace/app/mkbd/main.c
rd120133 r192565b 178 178 179 179 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); 182 182 if (!ok) { 183 183 printf("Connection with console broken: %s.\n", … … 186 186 } 187 187 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) { 189 190 break; 190 191 } -
uspace/app/msim/arch_helenos/input.c
rd120133 r192565b 91 91 bool stdin_poll(char *key) 92 92 { 93 kbd_event_t ev;93 cons_event_t ev; 94 94 suseconds_t timeout = 0; 95 95 errno = EOK; 96 96 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); 98 98 if (!has_input) { 99 99 return false; 100 100 } 101 101 102 if (ev.type != KEY_PRESS)102 if (ev.type != CEV_KEY || ev.ev.key.type != KEY_PRESS) 103 103 return false; 104 104 105 *key = ev. c;105 *key = ev.ev.key.c; 106 106 107 107 return true; -
uspace/app/nettest1/nettest1.c
rd120133 r192565b 46 46 #include <arg_parse.h> 47 47 48 #include <inet/dnsr.h> 48 49 #include <net/in.h> 49 50 #include <net/in6.h> … … 75 76 printf( 76 77 "Network Networking test 1 aplication - sockets\n" 77 "Usage: echo [options] numeric_address\n"78 "Usage: nettest1 [options] host\n" 78 79 "Where options are:\n" 79 80 "-f protocol_family | --family=protocol_family\n" … … 290 291 struct sockaddr_in address_in; 291 292 struct sockaddr_in6 address_in6; 293 dnsr_hostinfo_t *hinfo; 292 294 uint8_t *address_start; 293 295 … … 319 321 } 320 322 321 /* If not before the last argument containing the address*/323 /* If not before the last argument containing the host */ 322 324 if (index >= argc) { 323 printf("Command line error: missing address\n");325 printf("Command line error: missing host name\n"); 324 326 nettest1_print_help(); 325 327 return EINVAL; … … 348 350 } 349 351 350 /* Parse the last argument which should contain the address */352 /* Parse the last argument which should contain the host/address */ 351 353 rc = inet_pton(family, argv[argc - 1], address_start); 352 354 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); 355 363 } 356 364 -
uspace/app/nettest2/nettest2.c
rd120133 r192565b 47 47 #include <stdbool.h> 48 48 49 #include <inet/dnsr.h> 49 50 #include <net/in.h> 50 51 #include <net/in6.h> … … 71 72 printf( 72 73 "Network Networking test 2 aplication - UDP transfer\n" 73 "Usage: echo [options] address\n"74 "Usage: nettest2 [options] host\n" 74 75 "Where options are:\n" 75 76 "-f protocol_family | --family=protocol_family\n" … … 227 228 struct sockaddr_in address_in; 228 229 struct sockaddr_in6 address_in6; 230 dnsr_hostinfo_t *hinfo; 229 231 socklen_t addrlen; 230 232 uint8_t *address_start; … … 265 267 } 266 268 267 /* If not before the last argument containing the address*/269 /* If not before the last argument containing the host */ 268 270 if (index >= argc) { 269 printf("Command line error: missing address\n");271 printf("Command line error: missing host name\n"); 270 272 nettest2_print_help(); 271 273 return EINVAL; … … 294 296 } 295 297 296 /* Parse the last argument which should contain the address.*/298 /* Parse the last argument which should contain the host/address */ 297 299 rc = inet_pton(family, argv[argc - 1], address_start); 298 300 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); 301 309 } 302 310 -
uspace/app/nettest3/nettest3.c
rd120133 r192565b 39 39 #include <str.h> 40 40 41 #include <inet/dnsr.h> 41 42 #include <net/in.h> 42 43 #include <net/in6.h> … … 60 61 int fd; 61 62 char *endptr; 63 dnsr_hostinfo_t *hinfo; 62 64 63 65 port = 7; … … 75 77 rc = inet_pton(AF_INET, argv[1], (uint8_t *)&addr.sin_addr.s_addr); 76 78 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; 79 88 } 80 89 printf("result: rc=%d, family=%d, addr=%x\n", rc, -
uspace/app/nterm/conn.c
rd120133 r192565b 33 33 */ 34 34 35 #include <byteorder.h> 35 36 #include <stdbool.h> 36 37 #include <errno.h> 37 38 #include <fibril.h> 39 #include <inet/dnsr.h> 38 40 #include <net/socket.h> 39 41 #include <stdio.h> … … 74 76 { 75 77 struct sockaddr_in addr; 78 dnsr_hostinfo_t *hinfo = NULL; 76 79 int rc; 77 80 char *endptr; … … 81 84 rc = inet_pton(addr.sin_family, addr_s, (uint8_t *)&addr.sin_addr); 82 85 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); 85 94 } 86 95 … … 88 97 if (*endptr != '\0') { 89 98 printf("Invalid port number %s\n", port_s); 90 return EINVAL;99 goto error; 91 100 } 92 101 … … 95 104 goto error; 96 105 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)); 98 107 99 108 rc = connect(conn_fd, (struct sockaddr *)&addr, sizeof(addr)); -
uspace/app/nterm/nterm.c
rd120133 r192565b 104 104 static void print_syntax(void) 105 105 { 106 printf("syntax: nterm < ip-address> <port>\n");106 printf("syntax: nterm <host> <port>\n"); 107 107 } 108 108 109 109 int main(int argc, char *argv[]) 110 110 { 111 kbd_event_t ev;111 cons_event_t ev; 112 112 int rc; 113 113 … … 129 129 done = false; 130 130 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); 134 134 } 135 135 -
uspace/app/ping/ping.c
rd120133 r192565b 1 1 /* 2 * Copyright (c) 201 2Jiri Svoboda2 * Copyright (c) 2013 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 37 37 #include <errno.h> 38 38 #include <fibril_synch.h> 39 #include <inet/dnsr.h> 40 #include <inet/addr.h> 39 41 #include <inet/inetping.h> 40 42 #include <io/console.h> … … 68 70 static void print_syntax(void) 69 71 { 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"); 112 73 } 113 74 … … 125 86 int rc; 126 87 127 rc = addr_format(&sdu->src, &asrc);88 rc = inet_addr_format(&sdu->src, &asrc); 128 89 if (rc != EOK) 129 90 return ENOMEM; 130 91 131 rc = addr_format(&sdu->dest, &adest);92 rc = inet_addr_format(&sdu->dest, &adest); 132 93 if (rc != EOK) { 133 94 free(asrc); … … 188 149 { 189 150 console_ctrl_t *con; 190 kbd_event_t ev;151 cons_event_t ev; 191 152 192 153 con = console_init(stdin, stdout); … … 194 155 195 156 while (true) { 196 if (!console_get_ kbd_event(con, &ev))157 if (!console_get_event(con, &ev)) 197 158 break; 198 159 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) { 201 163 /* Ctrl+key */ 202 if (ev. key == KC_Q) {164 if (ev.ev.key.key == KC_Q) { 203 165 ping_signal_done(); 204 166 return 0; … … 212 174 int main(int argc, char *argv[]) 213 175 { 176 dnsr_hostinfo_t *hinfo = NULL; 177 char *asrc = NULL; 178 char *adest = NULL; 179 char *sdest = NULL; 214 180 int rc; 215 181 int argi; … … 219 185 printf(NAME ": Failed connecting to internet ping service " 220 186 "(%d).\n", rc); 221 return 1;187 goto error; 222 188 } 223 189 … … 232 198 if (argc - argi != 1) { 233 199 print_syntax(); 234 return 1;200 goto error; 235 201 } 236 202 237 203 /* 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; 243 214 } 244 215 … … 247 218 if (rc != EOK) { 248 219 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); 251 248 252 249 fid_t fid; … … 256 253 if (fid == 0) { 257 254 printf(NAME ": Failed creating transmit fibril.\n"); 258 return 1;255 goto error; 259 256 } 260 257 … … 264 261 if (fid == 0) { 265 262 printf(NAME ": Failed creating input fibril.\n"); 266 return 1;263 goto error; 267 264 } 268 265 … … 282 279 if (rc == ETIMEOUT) { 283 280 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); 287 288 return 0; 289 error: 290 free(asrc); 291 free(adest); 292 free(sdest); 293 dnsr_hostinfo_destroy(hinfo); 294 return 1; 288 295 } 289 296 -
uspace/app/taskdump/symtab.c
rd120133 r192565b 267 267 continue; 268 268 269 if ( best_name == NULL || (saddr <= addr &&saddr > best_addr)) {269 if (saddr <= addr && (best_name == NULL || saddr > best_addr)) { 270 270 best_name = sname; 271 271 best_addr = saddr; -
uspace/app/tester/ipc/starve.c
rd120133 r192565b 62 62 break; 63 63 64 kbd_event_t ev;64 cons_event_t ev; 65 65 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); 69 69 break; 70 70 } -
uspace/app/tetris/scores.c
rd120133 r192565b 125 125 int j; 126 126 size_t off; 127 kbd_event_t ev; 127 cons_event_t ev; 128 kbd_event_t *kev; 128 129 129 130 clear_screen(); … … 141 142 while (1) { 142 143 console_flush(console); 143 if (!console_get_ kbd_event(console, &ev))144 if (!console_get_event(console, &ev)) 144 145 exit(1); 145 146 146 if (ev.type == KEY_RELEASE)147 if (ev.type != CEV_KEY || ev.ev.key.type == KEY_RELEASE) 147 148 continue; 148 149 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) 150 153 break; 151 154 152 if ( ev.key == KC_BACKSPACE) {155 if (kev->key == KC_BACKSPACE) { 153 156 if (i > 0) { 154 157 wchar_t uc; … … 166 169 scores[NUMSPOTS - 1].hs_name[off] = '\0'; 167 170 } 168 } else if ( ev.c != '\0') {171 } else if (kev->c != '\0') { 169 172 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, 171 174 &off, STR_BOUNDS(MAXLOGNAME) + 1) == EOK) { 172 175 ++i; -
uspace/app/tetris/screen.c
rd120133 r192565b 344 344 345 345 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)) 349 349 break; 350 350 } … … 376 376 377 377 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)) { 381 381 timeleft = 0; 382 382 return -1; 383 383 } 384 384 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; 387 387 } 388 388 … … 398 398 399 399 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)) 403 403 return -1; 404 404 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; 407 407 } 408 408 -
uspace/app/top/screen.c
rd120133 r192565b 556 556 557 557 while (c == 0) { 558 kbd_event_t event;558 cons_event_t event; 559 559 560 560 warning_timeleft -= timeleft; 561 if (!console_get_ kbd_event_timeout(console, &event, &timeleft)) {561 if (!console_get_event_timeout(console, &event, &timeleft)) { 562 562 timeleft = 0; 563 563 return -1; … … 565 565 warning_timeleft += timeleft; 566 566 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; 569 569 } 570 570 -
uspace/app/trace/ipc_desc.c
rd120133 r192565b 49 49 { IPC_M_DATA_READ, "DATA_READ" }, 50 50 { IPC_M_DEBUG, "DEBUG" }, 51 52 /* Terminating entry */53 { 0, NULL }54 51 }; 52 53 size_t ipc_methods_len = sizeof(ipc_methods) / sizeof(ipc_m_desc_t); 55 54 56 55 /** @} -
uspace/app/trace/ipc_desc.h
rd120133 r192565b 42 42 43 43 extern ipc_m_desc_t ipc_methods[]; 44 extern size_t ipc_methods_len; 44 45 45 46 #endif -
uspace/app/trace/ipcp.c
rd120133 r192565b 140 140 void ipcp_init(void) 141 141 { 142 ipc_m_desc_t *desc;143 oper_t *oper;144 145 142 val_type_t arg_def[OPER_MAX_ARGS] = { 146 143 V_INTEGER, … … 162 159 proto_system = proto_new("system"); 163 160 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); 171 165 } 172 166 -
uspace/app/trace/syscalls.c
rd120133 r192565b 46 46 47 47 [SYS_TASK_GET_ID] = { "task_get_id", 1, V_ERRNO }, 48 [SYS_TASK_SET_NAME] = { "task_set_name", 2, V_ERRNO }, 48 49 [SYS_FUTEX_SLEEP] = { "futex_sleep_timeout", 3, V_ERRNO }, 49 50 [SYS_FUTEX_WAKEUP] = { "futex_wakeup", 1, V_ERRNO }, … … 82 83 }; 83 84 85 const size_t syscall_desc_len = (sizeof(syscall_desc) / sizeof(sc_desc_t)); 86 84 87 /** @} 85 88 */ -
uspace/app/trace/syscalls.h
rd120133 r192565b 36 36 #define SYSCALLS_H_ 37 37 38 #include <stdbool.h> 39 #include <unistd.h> 40 38 41 #include "trace.h" 39 42 … … 45 48 46 49 extern const sc_desc_t syscall_desc[]; 50 extern const size_t syscall_desc_len; 51 52 static inline bool syscall_desc_defined(unsigned sc_id) 53 { 54 return (sc_id < syscall_desc_len && syscall_desc[sc_id].name != NULL); 55 } 47 56 48 57 #endif -
uspace/app/trace/trace.c
rd120133 r192565b 136 136 } 137 137 138 free(task_ldr);139 138 task_ldr = NULL; 140 139 … … 348 347 if ((display_mask & DM_SYSCALL) != 0) { 349 348 /* 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 } 352 357 } 353 358 } … … 372 377 if ((display_mask & DM_SYSCALL) != 0) { 373 378 /* 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; 375 383 print_sc_retval(sc_rc, rv_type); 376 384 } … … 497 505 ldr = loader_connect(); 498 506 if (ldr == NULL) 499 return 0;507 return NULL; 500 508 501 509 /* Get task ID. */ … … 557 565 static int cev_fibril(void *arg) 558 566 { 567 cons_event_t event; 568 559 569 (void) arg; 560 570 … … 567 577 fibril_mutex_unlock(&state_lock); 568 578 569 if (!console_get_ kbd_event(console, &cev))579 if (!console_get_event(console, &event)) 570 580 return -1; 571 581 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 } 576 589 } 577 590 } -
uspace/app/vdemo/vdemo.c
rd120133 r192565b 141 141 lbl_action->cancel); 142 142 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); 145 145 grid->add(grid, &btn_cancel->widget, 1, 1, 1, 1); 146 window_resize(main_window, 200, 7 0);146 window_resize(main_window, 200, 76); 147 147 148 148 window_exec(main_window); -
uspace/app/vlaunch/Makefile
rd120133 r192565b 35 35 36 36 SOURCES = \ 37 vlaunch.c 37 vlaunch.c \ 38 images.c 39 40 IMAGES = \ 41 gfx/helenos.tga 42 43 PRE_DEPEND = images.c images.h 44 EXTRA_CLEAN = images.c images.h 38 45 39 46 include $(USPACE_PREFIX)/Makefile.common 47 48 images.c images.h: $(IMAGES) 49 $(ROOT_PATH)/tools/mkarray.py images COMPOSITOR_IMAGES $^ -
uspace/app/vlaunch/vlaunch.c
rd120133 r192565b 46 46 #include <button.h> 47 47 #include <label.h> 48 #include <canvas.h> 48 49 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 50 61 51 62 static char *winreg = NULL; … … 97 108 } 98 109 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 99 116 winreg = argv[1]; 100 117 window_t *main_window = window_open(argv[1], true, true, "vlaunch", 0, 0); … … 104 121 } 105 122 106 pixel_t grd_bg = PIXEL(255, 2 40, 240, 240);123 pixel_t grd_bg = PIXEL(255, 255, 255, 255); 107 124 pixel_t btn_bg = PIXEL(255, 0, 0, 0); 108 125 pixel_t btn_fg = PIXEL(255, 240, 240, 240); 109 pixel_t lbl_bg = PIXEL(255, 2 40, 240, 240);126 pixel_t lbl_bg = PIXEL(255, 255, 255, 255); 110 127 pixel_t lbl_fg = PIXEL(255, 0, 0, 0); 111 128 129 canvas_t *logo_canvas = create_canvas(NULL, LOGO_WIDTH, LOGO_HEIGHT, 130 logo); 112 131 label_t *lbl_caption = create_label(NULL, "Launch application:", 16, 113 132 lbl_bg, lbl_fg); … … 118 137 button_t *btn_vlaunch = create_button(NULL, "vlaunch", 16, btn_bg, 119 138 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); 121 140 122 if ((!l bl_caption) || (!btn_vterm) || (!btn_vdemo) ||123 (!btn_v launch) || (!grid)) {141 if ((!logo_canvas) || (!lbl_caption) || (!btn_vterm) || 142 (!btn_vdemo) || (!btn_vlaunch) || (!grid)) { 124 143 window_close(main_window); 125 144 printf("Cannot create widgets.\n"); … … 131 150 sig_connect(&btn_vlaunch->clicked, NULL, on_vlaunch); 132 151 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); 137 157 138 window_resize(main_window, 180, 130);158 window_resize(main_window, 210, 130 + LOGO_HEIGHT); 139 159 window_exec(main_window); 160 140 161 task_retval(0); 141 162 async_manager();
Note:
See TracChangeset
for help on using the changeset viewer.
