Changeset 0773396 in mainline for uspace/app
- Timestamp:
- 2013-12-25T13:05:25Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- bc54126c
- Parents:
- f4a47e52 (diff), 6946f23 (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:
-
- 14 added
- 1 deleted
- 25 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/bdsh/cmds/modules/mount/mount.c
rf4a47e52 r0773396 74 74 get_mtab_list(&mtab_list); 75 75 76 list_foreach(mtab_list, cur) { 77 mtab_ent_t *mtab_ent = list_get_instance(cur, mtab_ent_t, 78 link); 79 76 list_foreach(mtab_list, link, mtab_ent_t, mtab_ent) { 80 77 if (old_ent) 81 78 free(old_ent); -
uspace/app/corecfg/Makefile
rf4a47e52 r0773396 1 1 # 2 # Copyright (c) 2013 Antonin Steinhauser2 # Copyright (c) 2013 Jiri Svoboda 3 3 # All rights reserved. 4 4 # … … 28 28 29 29 USPACE_PREFIX = ../.. 30 BINARY = ping630 BINARY = corecfg 31 31 32 32 SOURCES = \ 33 ping6.c33 corecfg.c 34 34 35 35 include $(USPACE_PREFIX)/Makefile.common -
uspace/app/devctl/devctl.c
rf4a47e52 r0773396 35 35 #include <devman.h> 36 36 #include <errno.h> 37 #include <stdbool.h> 37 38 #include <stdio.h> 38 39 #include <stdlib.h> … … 44 45 #define MAX_NAME_LENGTH 1024 45 46 46 char name[MAX_NAME_LENGTH]; 47 char drv_name[MAX_NAME_LENGTH]; 47 static char name[MAX_NAME_LENGTH]; 48 static char drv_name[MAX_NAME_LENGTH]; 49 static bool verbose = false; 50 51 static const char *drv_state_str(driver_state_t state) 52 { 53 const char *sstate; 54 55 switch (state) { 56 case DRIVER_NOT_STARTED: 57 sstate = "not started"; 58 break; 59 case DRIVER_STARTING: 60 sstate = "starting"; 61 break; 62 case DRIVER_RUNNING: 63 sstate = "running"; 64 break; 65 default: 66 sstate = "unknown"; 67 } 68 69 return sstate; 70 } 48 71 49 72 static int fun_subtree_print(devman_handle_t funh, int lvl) … … 52 75 devman_handle_t *cfuns; 53 76 size_t count, i; 77 unsigned int score; 54 78 int rc; 55 79 int j; … … 74 98 printf("%s : %s\n", name, drv_name); 75 99 100 if (verbose) { 101 for (i = 0; true; i++) { 102 rc = devman_fun_get_match_id(funh, i, name, MAX_NAME_LENGTH, 103 &score); 104 if (rc != EOK) 105 break; 106 107 for (j = 0; j < lvl; j++) 108 printf(" "); 109 110 printf(" %u %s\n", score, name); 111 } 112 } 113 76 114 rc = devman_fun_get_child(funh, &devh); 77 115 if (rc == ENOENT) … … 159 197 } 160 198 199 static int drv_list(void) 200 { 201 devman_handle_t *devs; 202 devman_handle_t *drvs; 203 driver_state_t state; 204 const char *sstate; 205 size_t ndrvs; 206 size_t ndevs; 207 size_t i; 208 int rc; 209 210 rc = devman_get_drivers(&drvs, &ndrvs); 211 if (rc != EOK) 212 return rc; 213 214 for (i = 0; i < ndrvs; i++) { 215 devs = NULL; 216 217 rc = devman_driver_get_name(drvs[i], drv_name, MAX_NAME_LENGTH); 218 if (rc != EOK) 219 goto skip; 220 rc = devman_driver_get_state(drvs[i], &state); 221 if (rc != EOK) 222 goto skip; 223 rc = devman_driver_get_devices(drvs[i], &devs, &ndevs); 224 if (rc != EOK) 225 goto skip; 226 227 sstate = drv_state_str(state); 228 229 printf("%-11s %3zu %s\n", sstate, ndevs, drv_name); 230 skip: 231 free(devs); 232 } 233 free(drvs); 234 235 return EOK; 236 } 237 238 static int drv_show(char *drvname) 239 { 240 devman_handle_t *devs; 241 devman_handle_t drvh; 242 devman_handle_t funh; 243 driver_state_t state; 244 const char *sstate; 245 unsigned int score; 246 size_t ndevs; 247 size_t i; 248 int rc; 249 250 rc = devman_driver_get_handle(drvname, &drvh); 251 if (rc != EOK) 252 return rc; 253 254 devs = NULL; 255 256 rc = devman_driver_get_name(drvh, drv_name, MAX_NAME_LENGTH); 257 if (rc != EOK) 258 return rc; 259 260 rc = devman_driver_get_state(drvh, &state); 261 if (rc != EOK) 262 return rc; 263 264 rc = devman_driver_get_devices(drvh, &devs, &ndevs); 265 if (rc != EOK) 266 return rc; 267 268 sstate = drv_state_str(state); 269 270 printf("Driver: %s\n", drv_name); 271 printf("State: %s\n", sstate); 272 273 printf("Attached devices:\n"); 274 275 for (i = 0; i < ndevs; i++) { 276 rc = devman_dev_get_parent(devs[i], &funh); 277 if (rc != EOK) 278 goto error; 279 280 rc = devman_fun_get_path(funh, name, MAX_NAME_LENGTH); 281 if (rc != EOK) 282 goto error; 283 printf("\t%s\n", name); 284 } 285 286 printf("Match IDs:\n"); 287 288 for (i = 0; true; i++) { 289 rc = devman_driver_get_match_id(drvh, i, name, MAX_NAME_LENGTH, 290 &score); 291 if (rc != EOK) 292 break; 293 294 printf("\t%u %s\n", score, name); 295 } 296 297 error: 298 free(devs); 299 300 return EOK; 301 } 302 303 static int drv_load(const char *drvname) 304 { 305 int rc; 306 devman_handle_t drvh; 307 308 rc = devman_driver_get_handle(drvname, &drvh); 309 if (rc != EOK) { 310 printf("Failed resolving driver '%s' (%d).\n", drvname, rc); 311 return rc; 312 } 313 314 rc = devman_driver_load(drvh); 315 if (rc != EOK) { 316 printf("Failed loading driver '%s' (%d).\n", drvname, rc); 317 return rc; 318 } 319 320 return EOK; 321 } 322 161 323 static void print_syntax(void) 162 324 { 163 printf("syntax: devctl [(online|offline) <function>]\n"); 325 printf("syntax:\n"); 326 printf("\tdevctl\n"); 327 printf("\tdevctl online <function>]\n"); 328 printf("\tdevctl offline <function>]\n"); 329 printf("\tdevctl list-drv\n"); 330 printf("\tdevctl show-drv <driver-name>\n"); 331 printf("\tdevctl load-drv <driver-name>\n"); 164 332 } 165 333 … … 168 336 int rc; 169 337 170 if (argc == 1) { 338 if (argc == 1 || argv[1][0] == '-') { 339 if (argc > 1) { 340 if (str_cmp(argv[1], "-v") == 0) { 341 verbose = true; 342 } else { 343 printf(NAME ": Invalid argument '%s'\n", argv[1]); 344 print_syntax(); 345 return 1; 346 } 347 } 171 348 rc = fun_tree_print(); 172 349 if (rc != EOK) … … 194 371 return 2; 195 372 } 373 } else if (str_cmp(argv[1], "list-drv") == 0) { 374 rc = drv_list(); 375 if (rc != EOK) 376 return 2; 377 } else if (str_cmp(argv[1], "show-drv") == 0) { 378 if (argc < 3) { 379 printf(NAME ": Argument missing.\n"); 380 print_syntax(); 381 return 1; 382 } 383 384 rc = drv_show(argv[2]); 385 if (rc != EOK) { 386 return 2; 387 } 388 } else if (str_cmp(argv[1], "load-drv") == 0) { 389 if (argc < 3) { 390 printf(NAME ": Argument missing.\n"); 391 print_syntax(); 392 return 1; 393 } 394 395 rc = drv_load(argv[2]); 396 if (rc != EOK) 397 return 2; 196 398 } else { 197 399 printf(NAME ": Invalid argument '%s'.\n", argv[1]); -
uspace/app/df/Makefile
rf4a47e52 r0773396 1 1 # 2 # Copyright (c) 20 08 Josef Cejka2 # Copyright (c) 2013 Manuele Conti 3 3 # All rights reserved. 4 4 # … … 27 27 # 28 28 29 #include <libarch/context_offset.h> 29 USPACE_PREFIX = ../.. 30 BINARY = df 30 31 31 .text 32 .global setjmp 33 .global longjmp 32 SOURCES = \ 33 df.c 34 34 35 .type setjmp,@function 36 setjmp: 37 movl 0(%esp), %eax # save pc value into eax 38 movl 4(%esp), %edx # address of the jmp_buf structure to save context to 39 40 # save registers to the jmp_buf structure 41 CONTEXT_SAVE_ARCH_CORE %edx %eax 42 43 xorl %eax, %eax # set_jmp returns 0 44 ret 45 46 .type longjmp,@function 47 longjmp: 48 movl 4(%esp), %ecx # put address of jmp_buf into ecx 49 movl 8(%esp), %eax # put return value into eax 50 51 # restore registers from the jmp_buf structure 52 CONTEXT_RESTORE_ARCH_CORE %ecx %edx 53 54 movl %edx, 0(%esp) # put saved pc on stack 55 ret 35 include $(USPACE_PREFIX)/Makefile.common -
uspace/app/dnsres/dnsres.c
rf4a47e52 r0773396 36 36 #include <inet/addr.h> 37 37 #include <inet/dnsr.h> 38 #include <net/socket_codes.h>39 38 #include <stdio.h> 40 39 #include <stdlib.h> … … 54 53 } 55 54 56 uint16_t af;55 uint16_t ver; 57 56 char *hname; 58 57 … … 63 62 } 64 63 65 af = AF_INET;64 ver = ip_v4; 66 65 hname = argv[2]; 67 66 } else if (str_cmp(argv[1], "-6") == 0) { … … 71 70 } 72 71 73 af = AF_INET6;72 ver = ip_v6; 74 73 hname = argv[2]; 75 74 } else { 76 af = 0;75 ver = ip_any; 77 76 hname = argv[1]; 78 77 } 79 78 80 79 dnsr_hostinfo_t *hinfo; 81 int rc = dnsr_name2host(hname, &hinfo, af);80 int rc = dnsr_name2host(hname, &hinfo, ver); 82 81 if (rc != EOK) { 83 82 printf("%s: Error resolving '%s'.\n", NAME, hname); -
uspace/app/edit/sheet.c
rf4a47e52 r0773396 105 105 char *ipp; 106 106 size_t sz; 107 tag_t *tag;108 107 char *newp; 109 108 … … 128 127 /* Adjust tags. */ 129 128 130 list_foreach(sh->tags, link) { 131 tag = list_get_instance(link, tag_t, link); 132 129 list_foreach(sh->tags, link, tag_t, tag) { 133 130 if (tag->b_off > pos->b_off) 134 131 tag->b_off += sz; … … 154 151 char *spp; 155 152 size_t sz; 156 tag_t *tag;157 153 char *newp; 158 154 size_t shrink_size; … … 165 161 166 162 /* Adjust tags. */ 167 list_foreach(sh->tags, link) { 168 tag = list_get_instance(link, tag_t, link); 169 163 list_foreach(sh->tags, link, tag_t, tag) { 170 164 if (tag->b_off >= epos->b_off) 171 165 tag->b_off -= sz; -
uspace/app/getterm/getterm.c
rf4a47e52 r0773396 112 112 reopen(&stderr, 2, term, O_WRONLY, "w"); 113 113 114 /*115 * FIXME: fdopen() should actually detect that we are opening a console116 * and it should set line-buffering mode automatically.117 */118 setvbuf(stdout, NULL, _IOLBF, BUFSIZ);119 120 114 if (stdin == NULL) 121 115 return -2; … … 126 120 if (stderr == NULL) 127 121 return -4; 122 123 /* 124 * FIXME: fdopen() should actually detect that we are opening a console 125 * and it should set line-buffering mode automatically. 126 */ 127 setvbuf(stdout, NULL, _IOLBF, BUFSIZ); 128 128 129 129 version_print(term); -
uspace/app/inet/inet.c
rf4a47e52 r0773396 312 312 } 313 313 314 static int link_list(void) 315 { 316 sysarg_t *link_list; 317 inet_link_info_t linfo; 318 319 size_t count; 320 size_t i; 321 int rc; 322 323 rc = inetcfg_get_link_list(&link_list, &count); 324 if (rc != EOK) { 325 printf(NAME ": Failed getting link list.\n"); 326 return rc; 327 } 328 329 printf("IP links:\n"); 330 if (count > 0) 331 printf(" [Link-layer Address] [Link-Name] [Def-MTU]\n"); 332 333 for (i = 0; i < count; i++) { 334 rc = inetcfg_link_get(link_list[i], &linfo); 335 if (rc != EOK) { 336 printf("Failed getting properties of link %zu.\n", 337 (size_t)link_list[i]); 338 continue; 339 } 340 341 printf(" %02x:%02x:%02x:%02x:%02x:%02x %s %zu\n", 342 linfo.mac_addr[0], linfo.mac_addr[1], 343 linfo.mac_addr[2], linfo.mac_addr[3], 344 linfo.mac_addr[4], linfo.mac_addr[5], 345 linfo.name, linfo.def_mtu); 346 347 free(linfo.name); 348 349 linfo.name = NULL; 350 } 351 352 if (count == 0) 353 printf(" None\n"); 354 355 free(link_list); 356 357 return EOK; 358 } 359 314 360 static int sroute_list(void) 315 361 { … … 404 450 if (rc != EOK) 405 451 return 1; 452 rc = link_list(); 453 if (rc != EOK) 454 return 1; 406 455 return 0; 407 456 } -
uspace/app/init/init.c
rf4a47e52 r0773396 360 360 srv_start("/srv/udp"); 361 361 srv_start("/srv/dnsrsrv"); 362 srv_start("/srv/dhcp"); 363 srv_start("/srv/nconfsrv"); 362 364 363 365 srv_start("/srv/clipboard"); … … 384 386 srv_start("/srv/input", HID_INPUT); 385 387 srv_start("/srv/output", HID_OUTPUT); 388 srv_start("/srv/hound"); 386 389 387 390 int rc = compositor(HID_INPUT, HID_COMPOSITOR_SERVER); -
uspace/app/klog/klog.c
rf4a47e52 r0773396 206 206 klog_length = size / sizeof(wchar_t); 207 207 208 rc = physmem_map( (void *) faddr, pages,209 AS_AREA_READ | AS_AREA_CACHEABLE,(void *) &klog);208 rc = physmem_map(faddr, pages, AS_AREA_READ | AS_AREA_CACHEABLE, 209 (void *) &klog); 210 210 if (rc != EOK) { 211 211 fprintf(stderr, "%s: Unable to map klog\n", NAME); -
uspace/app/nettest1/nettest1.c
rf4a47e52 r0773396 38 38 #include "print_error.h" 39 39 40 #include <assert.h> 40 41 #include <malloc.h> 41 42 #include <stdio.h> … … 59 60 #define NETTEST1_TEXT "Networking test 1 - sockets" 60 61 61 static uint16_t family = AF_ INET;62 static uint16_t family = AF_NONE; 62 63 static sock_type_t type = SOCK_DGRAM; 63 64 static size_t size = 27; … … 326 327 } 327 328 328 char * addr_s= argv[argc - 1];329 char *host = argv[argc - 1]; 329 330 330 331 /* Interpret as address */ 331 inet_addr_t addr_addr;332 rc = inet_addr_parse( addr_s, &addr_addr);332 inet_addr_t iaddr; 333 rc = inet_addr_parse(host, &iaddr); 333 334 334 335 if (rc != EOK) { 335 336 /* Interpret as a host name */ 336 337 dnsr_hostinfo_t *hinfo = NULL; 337 rc = dnsr_name2host( addr_s, &hinfo, family);338 rc = dnsr_name2host(host, &hinfo, ipver_from_af(family)); 338 339 339 340 if (rc != EOK) { 340 printf("Error resolving host '%s'.\n", addr_s);341 printf("Error resolving host '%s'.\n", host); 341 342 return EINVAL; 342 343 } 343 344 344 addr_addr = hinfo->addr; 345 } 346 347 struct sockaddr_in addr; 348 struct sockaddr_in6 addr6; 349 uint16_t af = inet_addr_sockaddr_in(&addr_addr, &addr, &addr6); 350 351 if (af != family) { 345 iaddr = hinfo->addr; 346 } 347 348 rc = inet_addr_sockaddr(&iaddr, port, &address, &addrlen); 349 if (rc != EOK) { 350 assert(rc == ENOMEM); 351 printf("Out of memory.\n"); 352 return ENOMEM; 353 } 354 355 if (family == AF_NONE) 356 family = address->sa_family; 357 358 if (address->sa_family != family) { 352 359 printf("Address family does not match explicitly set family.\n"); 353 360 return EINVAL; 354 }355 356 /* Prepare the address buffer */357 358 switch (af) {359 case AF_INET:360 addr.sin_port = htons(port);361 address = (struct sockaddr *) &addr;362 addrlen = sizeof(addr);363 break;364 case AF_INET6:365 addr6.sin6_port = htons(port);366 address = (struct sockaddr *) &addr6;367 addrlen = sizeof(addr6);368 break;369 default:370 fprintf(stderr, "Address family is not supported\n");371 return EAFNOSUPPORT;372 361 } 373 362 … … 434 423 &time_before)); 435 424 425 free(address); 426 436 427 if (verbose) 437 428 printf("Exiting\n"); -
uspace/app/nettest2/nettest2.c
rf4a47e52 r0773396 38 38 #include "print_error.h" 39 39 40 #include <assert.h> 40 41 #include <malloc.h> 41 42 #include <stdio.h> … … 60 61 #define NETTEST2_TEXT "Networking test 2 - transfer" 61 62 62 static uint16_t family = PF_INET;63 static uint16_t family = AF_NONE; 63 64 static size_t size = 28; 64 65 static bool verbose = false; … … 271 272 /* Interpret as a host name */ 272 273 dnsr_hostinfo_t *hinfo = NULL; 273 rc = dnsr_name2host(addr_s, &hinfo, family);274 rc = dnsr_name2host(addr_s, &hinfo, ipver_from_af(family)); 274 275 275 276 if (rc != EOK) { … … 281 282 } 282 283 283 struct sockaddr_in addr; 284 struct sockaddr_in6 addr6; 285 uint16_t af = inet_addr_sockaddr_in(&addr_addr, &addr, &addr6); 286 287 if (af != family) { 284 struct sockaddr *address; 285 socklen_t addrlen; 286 rc = inet_addr_sockaddr(&addr_addr, port, &address, &addrlen); 287 if (rc != EOK) { 288 assert(rc == ENOMEM); 289 printf("Out of memory.\n"); 290 return ENOMEM; 291 } 292 293 if (family == AF_NONE) 294 family = address->sa_family; 295 296 if (address->sa_family != family) { 288 297 printf("Address family does not match explicitly set family.\n"); 289 298 return EINVAL; 290 }291 292 /* Prepare the address buffer */293 294 struct sockaddr *address;295 socklen_t addrlen;296 297 switch (af) {298 case AF_INET:299 addr.sin_port = htons(port);300 address = (struct sockaddr *) &addr;301 addrlen = sizeof(addr);302 break;303 case AF_INET6:304 addr6.sin6_port = htons(port);305 address = (struct sockaddr *) &addr6;306 addrlen = sizeof(addr6);307 break;308 default:309 fprintf(stderr, "Address family is not supported\n");310 return EAFNOSUPPORT;311 299 } 312 300 … … 424 412 return rc; 425 413 414 free(address); 415 426 416 if (verbose) 427 417 printf("\nExiting\n"); -
uspace/app/nettest3/nettest3.c
rf4a47e52 r0773396 37 37 #include <async.h> 38 38 #include <stdio.h> 39 #include <stdlib.h> 39 40 #include <str.h> 40 41 … … 52 53 static char buf[BUF_SIZE]; 53 54 54 static struct sockaddr_in addr; 55 static struct sockaddr *address; 56 static socklen_t addrlen; 55 57 56 58 static uint16_t port; … … 62 64 char *endptr; 63 65 dnsr_hostinfo_t *hinfo; 66 inet_addr_t addr; 67 char *addr_s; 64 68 65 69 port = 7; … … 69 73 70 74 /* Connect to local IP address by default */ 71 addr.sin_family = AF_INET; 72 addr.sin_port = htons(port); 73 addr.sin_addr.s_addr = htonl(0x7f000001); 75 inet_addr(&addr, 127, 0, 0, 1); 74 76 75 77 if (argc >= 2) { 76 78 printf("parsing address '%s'\n", argv[1]); 77 rc = inet_ pton(AF_INET, argv[1], (uint8_t *)&addr.sin_addr.s_addr);79 rc = inet_addr_parse(argv[1], &addr); 78 80 if (rc != EOK) { 79 81 /* Try interpreting as a host name */ 80 rc = dnsr_name2host(argv[1], &hinfo, AF_INET);82 rc = dnsr_name2host(argv[1], &hinfo, ip_v4); 81 83 if (rc != EOK) { 82 84 printf("Error resolving host '%s'.\n", argv[1]); 83 85 return rc; 84 86 } 85 86 uint16_t af = inet_addr_sockaddr_in(&hinfo->addr, &addr, NULL); 87 if (af != AF_INET) { 88 printf("Host '%s' not resolved as IPv4 address.\n", argv[1]); 89 return rc; 90 } 87 88 addr = hinfo->addr; 91 89 } 92 printf("result: rc=%d, family=%d, addr=%x\n", rc, 93 addr.sin_family, addr.sin_addr.s_addr); 90 rc = inet_addr_format(&addr, &addr_s); 91 if (rc != EOK) { 92 assert(rc == ENOMEM); 93 printf("Out of memory.\n"); 94 return rc; 95 } 96 printf("result: rc=%d, ver=%d, addr=%s\n", rc, 97 addr.version, addr_s); 98 free(addr_s); 94 99 } 95 100 96 101 if (argc >= 3) { 97 102 printf("parsing port '%s'\n", argv[2]); 98 addr.sin_port = htons(strtoul(argv[2], &endptr, 10));103 port = htons(strtoul(argv[2], &endptr, 10)); 99 104 if (*endptr != '\0') { 100 105 fprintf(stderr, "Error parsing port\n"); … … 103 108 } 104 109 110 rc = inet_addr_sockaddr(&hinfo->addr, port, &address, &addrlen); 111 if (rc != EOK) { 112 printf("Out of memory.\n"); 113 return rc; 114 } 115 105 116 printf("socket()\n"); 106 fd = socket( PF_INET, SOCK_STREAM, IPPROTO_TCP);117 fd = socket(address->sa_family, SOCK_STREAM, IPPROTO_TCP); 107 118 printf(" -> %d\n", fd); 108 119 if (fd < 0) … … 110 121 111 122 printf("connect()\n"); 112 rc = connect(fd, (struct sockaddr *) &addr, sizeof(addr));123 rc = connect(fd, address, addrlen); 113 124 printf(" -> %d\n", rc); 114 125 if (rc != 0) … … 133 144 printf(" -> %d\n", rc); 134 145 146 free(address); 147 135 148 return 0; 136 149 } -
uspace/app/nterm/conn.c
rf4a47e52 r0773396 38 38 #include <fibril.h> 39 39 #include <inet/dnsr.h> 40 #include <net/inet.h> 40 41 #include <net/socket.h> 41 42 #include <stdio.h> 43 #include <stdlib.h> 42 44 #include <str_error.h> 43 45 #include <sys/types.h> … … 73 75 } 74 76 75 int conn_open(const char * addr_s, const char *port_s)77 int conn_open(const char *host, const char *port_s) 76 78 { 77 79 int conn_fd = -1; 80 struct sockaddr *saddr = NULL; 81 socklen_t saddrlen; 78 82 79 83 /* Interpret as address */ 80 inet_addr_t addr_addr;81 int rc = inet_addr_parse( addr_s, &addr_addr);84 inet_addr_t iaddr; 85 int rc = inet_addr_parse(host, &iaddr); 82 86 83 87 if (rc != EOK) { 84 88 /* Interpret as a host name */ 85 89 dnsr_hostinfo_t *hinfo = NULL; 86 rc = dnsr_name2host( addr_s, &hinfo, 0);90 rc = dnsr_name2host(host, &hinfo, ip_any); 87 91 88 92 if (rc != EOK) { 89 printf("Error resolving host '%s'.\n", addr_s);93 printf("Error resolving host '%s'.\n", host); 90 94 goto error; 91 95 } 92 96 93 addr_addr = hinfo->addr;97 iaddr = hinfo->addr; 94 98 } 95 96 struct sockaddr_in addr;97 struct sockaddr_in6 addr6;98 uint16_t af = inet_addr_sockaddr_in(&addr_addr, &addr, &addr6);99 99 100 100 char *endptr; … … 105 105 } 106 106 107 printf("Connecting to host %s port %u\n", addr_s, port); 107 rc = inet_addr_sockaddr(&iaddr, port, &saddr, &saddrlen); 108 if (rc != EOK) { 109 assert(rc == ENOMEM); 110 printf("Out of memory.\n"); 111 return ENOMEM; 112 } 108 113 109 conn_fd = socket(PF_INET, SOCK_STREAM, 0); 114 printf("Connecting to host %s port %u\n", host, port); 115 116 conn_fd = socket(saddr->sa_family, SOCK_STREAM, 0); 110 117 if (conn_fd < 0) 111 118 goto error; 112 119 113 switch (af) { 114 case AF_INET: 115 addr.sin_port = htons(port); 116 rc = connect(conn_fd, (struct sockaddr *) &addr, sizeof(addr)); 117 break; 118 case AF_INET6: 119 addr6.sin6_port = htons(port); 120 rc = connect(conn_fd, (struct sockaddr *) &addr6, sizeof(addr6)); 121 break; 122 default: 123 printf("Unknown address family.\n"); 124 goto error; 125 } 126 120 rc = connect(conn_fd, saddr, saddrlen); 127 121 if (rc != EOK) 128 122 goto error; … … 134 128 fibril_add_ready(rcv_fid); 135 129 130 free(saddr); 136 131 return EOK; 137 138 132 error: 139 133 if (conn_fd >= 0) { … … 141 135 conn_fd = -1; 142 136 } 137 free(saddr); 143 138 144 139 return EIO; -
uspace/app/ping/ping.c
rf4a47e52 r0773396 37 37 #include <errno.h> 38 38 #include <fibril_synch.h> 39 #include <net/socket_codes.h>40 39 #include <inet/dnsr.h> 41 40 #include <inet/addr.h> … … 77 76 }; 78 77 79 static addr32_t src;80 static addr32_t dest;78 static inet_addr_t src_addr; 79 static inet_addr_t dest_addr; 81 80 82 81 static bool repeat_forever = false; 83 82 static size_t repeat_count = 1; 84 83 85 static const char *short_options = " rn:";84 static const char *short_options = "46rn:"; 86 85 87 86 static void print_syntax(void) 88 87 { 89 printf("Syntax: %s [-n <count>|-r] <host>\n", NAME); 88 printf("Syntax: %s [<options>] <host>\n", NAME); 89 printf("\t-n <count> Repeat the specified number of times\n"); 90 printf("\t-r Repeat forever\n"); 91 printf("\t-4|-6 Use IPv4 or IPv6 destination host address\n"); 90 92 } 91 93 … … 108 110 static int ping_ev_recv(inetping_sdu_t *sdu) 109 111 { 110 inet_addr_t src_addr;111 inet_addr_set(sdu->src, &src_addr);112 113 inet_addr_t dest_addr;114 inet_addr_set(sdu->dest, &dest_addr);115 116 112 char *asrc; 117 113 int rc = inet_addr_format(&src_addr, &asrc); … … 140 136 inetping_sdu_t sdu; 141 137 142 sdu.src = src ;143 sdu.dest = dest ;138 sdu.src = src_addr; 139 sdu.dest = dest_addr; 144 140 sdu.seq_no = seq_no; 145 141 sdu.data = (void *) "foo"; … … 222 218 char *adest = NULL; 223 219 char *sdest = NULL; 220 ip_ver_t ip_ver = ip_any; 224 221 225 222 int rc = inetping_init(&ev_ops); … … 244 241 } 245 242 break; 243 case '4': 244 ip_ver = ip_v4; 245 break; 246 case '6': 247 ip_ver = ip_v6; 248 break; 246 249 default: 247 250 printf("Unknown option passed.\n"); … … 258 261 259 262 /* Parse destination address */ 260 inet_addr_t dest_addr;261 263 rc = inet_addr_parse(argv[optind], &dest_addr); 262 264 if (rc != EOK) { 263 265 /* Try interpreting as a host name */ 264 rc = dnsr_name2host(argv[optind], &hinfo, AF_INET);266 rc = dnsr_name2host(argv[optind], &hinfo, ip_ver); 265 267 if (rc != EOK) { 266 268 printf("Error resolving host '%s'.\n", argv[optind]); … … 271 273 } 272 274 273 uint16_t af = inet_addr_get(&dest_addr, &dest, NULL);274 if (af != AF_INET) {275 printf("Destination '%s' is not an IPv4 address.\n",276 argv[optind]);277 goto error;278 }279 280 275 /* Determine source address */ 281 rc = inetping_get_srcaddr( dest, &src);276 rc = inetping_get_srcaddr(&dest_addr, &src_addr); 282 277 if (rc != EOK) { 283 278 printf("Failed determining source address.\n"); 284 279 goto error; 285 280 } 286 287 inet_addr_t src_addr;288 inet_addr_set(src, &src_addr);289 281 290 282 rc = inet_addr_format(&src_addr, &asrc); -
uspace/app/sportdmp/sportdmp.c
rf4a47e52 r0773396 44 44 sysarg_t baud = 9600; 45 45 service_id_t svc_id; 46 46 47 47 int arg = 1; 48 48 int rc; 49 49 50 50 if (argc > arg && str_test_prefix(argv[arg], "--baud=")) { 51 51 size_t arg_offset = str_lsize(argv[arg], 7); … … 65 65 arg++; 66 66 } 67 67 68 68 if (argc > arg) { 69 69 rc = loc_service_get_id(argv[arg], &svc_id, 0); … … 77 77 else { 78 78 category_id_t serial_cat_id; 79 79 80 80 rc = loc_category_get_id("serial", &serial_cat_id, 0); 81 81 if (rc != EOK) { … … 84 84 return 1; 85 85 } 86 86 87 87 service_id_t *svc_ids; 88 88 size_t svc_count; 89 90 rc = loc_category_get_svcs(serial_cat_id, &svc_ids, &svc_count); if (rc != EOK) { 89 90 rc = loc_category_get_svcs(serial_cat_id, &svc_ids, &svc_count); 91 if (rc != EOK) { 91 92 fprintf(stderr, "Failed getting list of services\n"); 92 93 return 1; 93 94 } 94 95 95 96 if (svc_count == 0) { 96 97 fprintf(stderr, "No service in category 'serial'\n"); … … 98 99 return 1; 99 100 } 100 101 101 102 svc_id = svc_ids[0]; 102 103 free(svc_ids); 103 104 } 104 105 105 106 if (argc > arg) { 106 107 fprintf(stderr, "Too many arguments\n"); … … 108 109 return 1; 109 110 } 110 111 111 112 112 113 async_sess_t *sess = loc_service_connect(EXCHANGE_SERIALIZE, svc_id, 113 114 IPC_FLAG_BLOCKING); … … 115 116 fprintf(stderr, "Failed connecting to service\n"); 116 117 } 117 118 118 119 async_exch_t *exch = async_exchange_begin(sess); 119 120 rc = async_req_4_0(exch, SERIAL_SET_COM_PROPS, baud, 120 121 SERIAL_NO_PARITY, 8, 1); 121 122 async_exchange_end(exch); 122 123 123 124 if (rc != EOK) { 124 125 fprintf(stderr, "Failed setting serial properties\n"); 125 126 return 2; 126 127 } 127 128 128 129 uint8_t *buf = (uint8_t *) malloc(BUF_SIZE); 129 130 if (buf == NULL) { … … 131 132 return 3; 132 133 } 133 134 134 135 while (true) { 135 136 ssize_t read = char_dev_read(sess, buf, BUF_SIZE); … … 144 145 fflush(stdout); 145 146 } 146 147 147 148 free(buf); 148 149 return 0; 149 150 } 151 -
uspace/app/tester/Makefile
rf4a47e52 r0773396 37 37 util.c \ 38 38 thread/thread1.c \ 39 thread/setjmp1.c \ 39 40 print/print1.c \ 40 41 print/print2.c \ -
uspace/app/tester/mm/common.c
rf4a47e52 r0773396 84 84 } 85 85 86 static bool overlap_match(link_t *link, void *addr, size_t size) 87 { 88 mem_block_t *block = list_get_instance(link, mem_block_t, link); 89 86 static bool overlap_match(mem_block_t *block, void *addr, size_t size) 87 { 90 88 /* Entry block control structure <mbeg, mend) */ 91 89 uint8_t *mbeg = (uint8_t *) block; … … 125 123 bool fnd = false; 126 124 127 list_foreach(mem_blocks, link ) {128 if (overlap_match( link, addr, size)) {125 list_foreach(mem_blocks, link, mem_block_t, block) { 126 if (overlap_match(block, addr, size)) { 129 127 fnd = true; 130 128 break; -
uspace/app/tester/tester.c
rf4a47e52 r0773396 48 48 test_t tests[] = { 49 49 #include "thread/thread1.def" 50 #include "thread/setjmp1.def" 50 51 #include "print/print1.def" 51 52 #include "print/print2.def" -
uspace/app/tester/tester.h
rf4a47e52 r0773396 39 39 #include <stdbool.h> 40 40 #include <stacktrace.h> 41 #include <stdio.h> 41 42 42 43 #define IPC_TEST_SERVICE 10240 … … 80 81 81 82 extern const char *test_thread1(void); 83 extern const char *test_setjmp1(void); 82 84 extern const char *test_print1(void); 83 85 extern const char *test_print2(void); -
uspace/app/trace/trace.c
rf4a47e52 r0773396 724 724 o = oper_new("stat", 0, arg_def, V_ERRNO, 0, resp_def); 725 725 proto_add_oper(p, VFS_IN_STAT, o); 726 o = oper_new("statfs", 0, arg_def, V_ERRNO, 0, resp_def); 727 proto_add_oper(p, VFS_IN_STATFS, o); 726 728 727 729 proto_register(SERVICE_VFS, p); -
uspace/app/usbinfo/dump.c
rf4a47e52 r0773396 103 103 void dump_match_ids(match_id_list_t *matches, const char *line_prefix) 104 104 { 105 list_foreach(matches->ids, link) { 106 match_id_t *match = list_get_instance(link, match_id_t, link); 107 105 list_foreach(matches->ids, link, match_id_t, match) { 108 106 printf("%s%3d %s\n", line_prefix, match->score, match->id); 109 107 } -
uspace/app/usbinfo/hid.c
rf4a47e52 r0773396 100 100 printf("%sParsed HID report descriptor for interface %d\n", 101 101 get_indent(0), iface_no); 102 list_foreach(report->reports, report_it) { 103 usb_hid_report_description_t *description = list_get_instance( 104 report_it, usb_hid_report_description_t, reports_link); 102 list_foreach(report->reports, reports_link, 103 usb_hid_report_description_t, description) { 105 104 printf("%sReport %d (type %d)\n", get_indent(1), 106 105 (int) description->report_id, 107 106 (int) description->type); 108 list_foreach(description->report_items, item_it) { 109 usb_hid_report_field_t *field = list_get_instance( 110 item_it, usb_hid_report_field_t, ritems_link); 107 list_foreach(description->report_items, ritems_link, 108 usb_hid_report_field_t, field) { 111 109 printf("%sUsage page = 0x%04x Usage = 0x%04x\n", 112 110 get_indent(2), -
uspace/app/wavplay/dplay.c
rf4a47e52 r0773396 151 151 device_event_callback, pb); 152 152 if (ret != EOK) { 153 printf("Failed to register event callback.\n"); 153 printf("Failed to register event callback: %s.\n", 154 str_error(ret)); 154 155 return; 155 156 } … … 285 286 pb->f.sample_format); 286 287 if (ret != EOK) { 287 printf("Failed to start playback\n"); 288 printf("Failed to start playback: %s\n", 289 str_error(ret)); 288 290 return; 289 291 } … … 291 293 ret = audio_pcm_get_buffer_pos(pb->device, &pos); 292 294 if (ret != EOK) { 293 printf("Failed to update position indicator\n"); 295 printf("Failed to update position indicator " 296 "%s\n", str_error(ret)); 294 297 } 295 298 } … … 308 311 const int ret = audio_pcm_get_buffer_pos(pb->device, &pos); 309 312 if (ret != EOK) { 310 printf("Failed to update position indicator\n"); 313 printf("Failed to update position indicator %s\n", 314 str_error(ret)); 311 315 } 312 316 getuptime(&time); … … 350 354 ret = audio_pcm_get_info_str(session, &info); 351 355 if (ret != EOK) { 352 printf("Failed to get PCM info .\n");356 printf("Failed to get PCM info: %s.\n", str_error(ret)); 353 357 goto close_session; 354 358 } -
uspace/app/wavplay/drec.c
rf4a47e52 r0773396 213 213 wave_header_t header; 214 214 fseek(rec.file, sizeof(header), SEEK_SET); 215 const char *error; 216 if (ret != EOK) { 217 printf("Error parsing wav header: %s.\n", error); 215 if (ret != EOK) { 216 printf("Error parsing wav header\n"); 218 217 goto cleanup; 219 218 } -
uspace/app/wavplay/main.c
rf4a47e52 r0773396 79 79 &format.sampling_rate, &format.sample_format, &error); 80 80 if (ret != EOK) { 81 printf("Error parsing wav header: %s.\n", error);81 printf("Error parsing `%s' wav header: %s.\n", filename, error); 82 82 fclose(source); 83 83 return EINVAL; 84 84 } 85 86 printf("File `%s' format: %u channel(s), %uHz, %s.\n", filename, 87 format.channels, format.sampling_rate, 88 pcm_sample_format_str(format.sample_format)); 85 89 86 90 /* Allocate buffer and create new context */ … … 136 140 &format.sampling_rate, &format.sample_format, &error); 137 141 if (ret != EOK) { 138 printf("Error parsing wav header: %s.\n", error);142 printf("Error parsing `%s' wav header: %s.\n", filename, error); 139 143 fclose(source); 140 144 return EINVAL; 141 145 } 146 printf("File `%s' format: %u channel(s), %uHz, %s.\n", filename, 147 format.channels, format.sampling_rate, 148 pcm_sample_format_str(format.sample_format)); 142 149 143 150 /* Connect new playback context */ -
uspace/app/wavplay/wave.c
rf4a47e52 r0773396 81 81 } 82 82 83 if (uint16_t_le2host(header->subchunk1_size) != PCM_SUBCHUNK1_SIZE) { 83 if (uint32_t_le2host(header->subchunk1_size) != PCM_SUBCHUNK1_SIZE) { 84 //TODO subchunk 1 sizes other than 16 are allowed ( 18, 40) 85 //http://www-mmsp.ece.mcgill.ca/documents/AudioFormats/WAVE/WAVE.html 84 86 if (error) 85 87 *error = "invalid subchunk1 size"; 86 return EINVAL;88 // return EINVAL; 87 89 } 88 90 … … 94 96 95 97 if (str_lcmp(header->subchunk2_id, SUBCHUNK2_ID, 4) != 0) { 98 //TODO basedd on subchunk1 size, we might be reading wrong 99 //offset 96 100 if (error) 97 101 *error = "invalid subchunk2 id"; 98 return EINVAL;102 // return EINVAL; 99 103 } 100 104 101 105 106 //TODO data and data_size are incorrect in extended wav formats 107 //pcm params are OK 102 108 if (data) 103 109 *data = header->data;
Note:
See TracChangeset
for help on using the changeset viewer.