Changeset 03362fbd in mainline for uspace/app
- Timestamp:
- 2013-02-09T23:14:45Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 22dfd38
- Parents:
- b5d2e57 (diff), 005b765 (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:
-
- 30 added
- 3 deleted
- 52 edited
- 4 moved
-
bdsh/Makefile (modified) (1 diff)
-
bdsh/cmds/modules/bdd/bdd.c (modified) (1 diff)
-
bdsh/cmds/modules/cmp/cmp.c (added)
-
bdsh/cmds/modules/cmp/cmp.h (added)
-
bdsh/cmds/modules/cmp/cmp_def.h (added)
-
bdsh/cmds/modules/cmp/entry.h (added)
-
bdsh/cmds/modules/modules.h (modified) (2 diffs)
-
bdsh/compl.c (modified) (1 diff)
-
bdsh/config.h (modified) (1 diff)
-
bdsh/errors.h (modified) (2 diffs)
-
bdsh/input.c (modified) (5 diffs)
-
bithenge/Makefile (moved) (moved from uspace/app/ext2info/Makefile ) (2 diffs)
-
bithenge/Makefile.linux (added)
-
bithenge/test.c (added)
-
blkdump/blkdump.c (modified) (1 diff)
-
date/Makefile (moved) (moved from uspace/lib/fb/Makefile ) (2 diffs)
-
date/date.c (added)
-
devctl/devctl.c (modified) (1 diff)
-
edit/Makefile (modified) (1 diff)
-
edit/edit.c (modified) (40 diffs)
-
edit/search.c (added)
-
edit/search.h (added)
-
edit/search_impl.h (added)
-
edit/sheet.c (modified) (4 diffs)
-
edit/sheet.h (modified) (4 diffs)
-
edit/sheet_impl.h (added)
-
ext2info/ext2info.c (deleted)
-
init/init.c (modified) (9 diffs)
-
klog/Makefile (modified) (1 diff)
-
klog/klog.c (modified) (2 diffs)
-
logset/Makefile (moved) (moved from uspace/app/lsusb/Makefile ) (2 diffs)
-
logset/main.c (added)
-
mkbd/main.c (modified) (1 diff)
-
mkexfat/exfat.h (modified) (1 diff)
-
mkexfat/mkexfat.c (modified) (3 diffs)
-
mkfat/mkfat.c (modified) (1 diff)
-
mkmfs/mkmfs.c (modified) (1 diff)
-
msim/arch_helenos/input.c (modified) (2 diffs)
-
msim/arch_helenos/misc.c (modified) (1 diff)
-
nettest2/nettest2.c (modified) (1 diff)
-
nterm/conn.c (modified) (1 diff)
-
nterm/nterm.c (modified) (1 diff)
-
ping/ping.c (modified) (1 diff)
-
sportdmp/sportdmp.c (modified) (3 diffs)
-
stats/stats.c (modified) (1 diff)
-
taskdump/taskdump.c (modified) (1 diff)
-
tester/Makefile (modified) (3 diffs)
-
tester/float/float1.c (added)
-
tester/float/float1.def (added)
-
tester/float/softfloat1.c (added)
-
tester/float/softfloat1.def (added)
-
tester/libext2/libext2_1.c (deleted)
-
tester/libext2/libext2_1.def (deleted)
-
tester/mm/common.c (modified) (1 diff)
-
tester/mm/common.h (modified) (1 diff)
-
tester/mm/mapping1.c (modified) (1 diff)
-
tester/print/print5.def (modified) (1 diff)
-
tester/print/print6.c (added)
-
tester/print/print6.def (added)
-
tester/stdio/logger1.c (added)
-
tester/stdio/logger1.def (added)
-
tester/stdio/logger2.c (added)
-
tester/stdio/logger2.def (added)
-
tester/tester.c (modified) (4 diffs)
-
tester/tester.h (modified) (3 diffs)
-
testwrit/Makefile (added)
-
testwrit/testwrit.c (added)
-
tetris/screen.c (modified) (1 diff)
-
tetris/screen.h (modified) (1 diff)
-
top/screen.h (modified) (2 diffs)
-
trace/ipcp.c (modified) (10 diffs)
-
trace/proto.c (modified) (3 diffs)
-
trace/proto.h (modified) (1 diff)
-
trace/syscalls.c (modified) (1 diff)
-
trace/trace.c (modified) (4 diffs)
-
usbinfo/Makefile (modified) (1 diff)
-
usbinfo/desctree.c (modified) (1 diff)
-
usbinfo/dump.c (modified) (1 diff)
-
usbinfo/list.c (moved) (moved from uspace/app/lsusb/main.c ) (6 diffs)
-
usbinfo/main.c (modified) (8 diffs)
-
usbinfo/usbinfo.h (modified) (1 diff)
-
vdemo/Makefile (added)
-
vdemo/vdemo.c (added)
-
vlaunch/Makefile (added)
-
vlaunch/vlaunch.c (added)
-
vterm/Makefile (added)
-
vterm/vterm.c (added)
-
vuhid/main.c (modified) (1 diff)
-
websrv/websrv.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/bdsh/Makefile
rb5d2e57 r03362fbd 53 53 cmds/modules/unmount/unmount.c \ 54 54 cmds/modules/kcon/kcon.c \ 55 cmds/modules/cmp/cmp.c \ 55 56 cmds/builtins/batch/batch.c \ 56 57 cmds/builtins/exit/exit.c \ -
uspace/app/bdsh/cmds/modules/bdd/bdd.c
rb5d2e57 r03362fbd 38 38 #include "cmds.h" 39 39 40 #include < libblock.h>40 #include <block.h> 41 41 #include <loc.h> 42 42 #include <errno.h> -
uspace/app/bdsh/cmds/modules/modules.h
rb5d2e57 r03362fbd 63 63 #include "printf/entry.h" 64 64 #include "echo/entry.h" 65 #include "cmp/entry.h" 65 66 66 67 /* Each .def function fills the module_t struct with the individual name, entry … … 86 87 #include "printf/printf_def.h" 87 88 #include "echo/echo_def.h" 89 #include "cmp/cmp_def.h" 88 90 89 91 {NULL, NULL, NULL, NULL} -
uspace/app/bdsh/compl.c
rb5d2e57 r03362fbd 28 28 */ 29 29 30 #include < bool.h>30 #include <stdbool.h> 31 31 #include <dirent.h> 32 32 #include <errno.h> -
uspace/app/bdsh/config.h
rb5d2e57 r03362fbd 55 55 #define PACKAGE_STRING "The brain dead shell" 56 56 #define PACKAGE_TARNAME "bdsh" 57 #define PACKAGE_VERSION "0.0.1" 58 59 60 57 #define PACKAGE_VERSION "0.1.0" -
uspace/app/bdsh/errors.h
rb5d2e57 r03362fbd 30 30 #define ERRORS_H 31 31 32 #include <io/verify.h> 33 32 34 /* Various error levels */ 33 35 #define CL_EFATAL -1 … … 46 48 extern volatile int cli_errno; 47 49 48 extern void cli_error(int, const char *, ...); 50 extern void cli_error(int, const char *, ...) 51 PRINTF_ATTRIBUTE(2, 3); 49 52 50 53 #endif -
uspace/app/bdsh/input.c
rb5d2e57 r03362fbd 41 41 #include <errno.h> 42 42 #include <assert.h> 43 #include < bool.h>43 #include <stdbool.h> 44 44 #include <tinput.h> 45 45 … … 67 67 int process_input(cliuser_t *usr) 68 68 { 69 token_t *tokens = calloc(WORD_MAX, sizeof(token_t));70 if (tokens == NULL)69 token_t *tokens_buf = calloc(WORD_MAX, sizeof(token_t)); 70 if (tokens_buf == NULL) 71 71 return ENOMEM; 72 token_t *tokens = tokens_buf; 72 73 73 74 char *cmd[WORD_MAX]; … … 80 81 81 82 if (usr->line == NULL) { 82 free(tokens );83 free(tokens_buf); 83 84 return CL_EFAIL; 84 85 } … … 213 214 } 214 215 tok_fini(&tok); 215 free(tokens );216 free(tokens_buf); 216 217 217 218 return rc; … … 268 269 if (rc != EOK) { 269 270 /* Error in communication with console */ 271 cli_quit = 1; 270 272 return; 271 273 } -
uspace/app/bithenge/Makefile
rb5d2e57 r03362fbd 1 1 # 2 # Copyright (c) 2005 Martin Decky 3 # Copyright (c) 2007 Jakub Jermar 2 # Copyright (c) 2012 Sean Bartell 4 3 # All rights reserved. 5 4 # … … 29 28 30 29 USPACE_PREFIX = ../.. 31 LIBS = $(LIBB LOCK_PREFIX)/libblock.a $(LIBEXT2_PREFIX)/libext2.a32 EXTRA_CFLAGS = -I$(LIBB LOCK_PREFIX) -I$(LIBEXT2_PREFIX)33 BINARY = ext2info30 LIBS = $(LIBBITHENGE_PREFIX)/libbithenge.a $(LIBBLOCK_PREFIX)/libblock.a 31 EXTRA_CFLAGS = -I$(LIBBITHENGE_PREFIX)/include -D__HELENOS__ 32 BINARY = bithenge 34 33 35 34 SOURCES = \ 36 ext2info.c35 test.c 37 36 38 37 include $(USPACE_PREFIX)/Makefile.common -
uspace/app/blkdump/blkdump.c
rb5d2e57 r03362fbd 40 40 #include <stdio.h> 41 41 #include <stdlib.h> 42 #include < libblock.h>42 #include <block.h> 43 43 #include <mem.h> 44 44 #include <loc.h> -
uspace/app/date/Makefile
rb5d2e57 r03362fbd 1 1 # 2 # Copyright (c) 201 1 Martin Decky2 # Copyright (c) 2012 Maurizio Lombardi 3 3 # All rights reserved. 4 4 # … … 28 28 29 29 USPACE_PREFIX = ../.. 30 LIBRARY = libfb 30 BINARY = date 31 31 32 32 SOURCES = \ 33 fb.c \ 34 imgmap.c \ 35 screenbuffer.c 33 date.c 36 34 37 35 include $(USPACE_PREFIX)/Makefile.common -
uspace/app/devctl/devctl.c
rb5d2e57 r03362fbd 151 151 rc = devman_fun_offline(funh); 152 152 if (rc != EOK) { 153 printf(NAME ": Failed to offline function '%s'.\n", path); 153 printf(NAME ": Failed to offline function '%s' (%s)\n", path, 154 str_error(rc)); 154 155 return rc; 155 156 } -
uspace/app/edit/Makefile
rb5d2e57 r03362fbd 33 33 SOURCES = \ 34 34 edit.c \ 35 sheet.c 35 sheet.c \ 36 search.c 36 37 37 38 include $(USPACE_PREFIX)/Makefile.common -
uspace/app/edit/edit.c
rb5d2e57 r03362fbd 1 1 /* 2 2 * Copyright (c) 2009 Jiri Svoboda 3 * Copyright (c) 2012 Martin Sucha 3 4 * All rights reserved. 4 5 * … … 46 47 #include <macros.h> 47 48 #include <clipboard.h> 48 #include < bool.h>49 #include <stdbool.h> 49 50 50 51 #include "sheet.h" 52 #include "search.h" 51 53 52 54 enum redraw_flags { … … 83 85 */ 84 86 int ideal_column; 87 88 char *previous_search; 89 bool previous_search_reverse; 85 90 } pane_t; 86 91 … … 91 96 typedef struct { 92 97 char *file_name; 93 sheet_t sh;98 sheet_t *sh; 94 99 } doc_t; 95 100 … … 106 111 #define BUF_SIZE 64 107 112 #define TAB_WIDTH 8 108 #define ED_INFTY 65536109 113 110 114 /** Maximum filename length that can be entered. */ … … 126 130 static int file_save_range(char const *fname, spt_t const *spos, 127 131 spt_t const *epos); 128 static char *filename_prompt(char const *prompt, char const *init_value);129 132 static char *range_get_str(spt_t const *spos, spt_t const *epos); 133 134 static char *prompt(char const *prompt, char const *init_value); 130 135 131 136 static void pane_text_display(void); … … 139 144 static void delete_char_after(void); 140 145 static void caret_update(void); 141 static void caret_move(int drow, int dcolumn, enum dir_spec align_dir); 142 static void caret_move_word_left(void); 143 static void caret_move_word_right(void); 146 static void caret_move_relative(int drow, int dcolumn, enum dir_spec align_dir, bool select); 147 static void caret_move_absolute(int row, int column, enum dir_spec align_dir, bool select); 148 static void caret_move(spt_t spt, bool select, bool update_ideal_column); 149 static void caret_move_word_left(bool select); 150 static void caret_move_word_right(bool select); 151 static void caret_go_to_line_ask(void); 144 152 145 153 static bool selection_active(void); 146 154 static void selection_sel_all(void); 147 155 static void selection_sel_range(spt_t pa, spt_t pb); 148 static void selection_sel_prev_word(void);149 static void selection_sel_next_word(void);150 156 static void selection_get_points(spt_t *pa, spt_t *pb); 151 157 static void selection_delete(void); 152 158 static void selection_copy(void); 153 159 static void insert_clipboard_data(void); 160 161 static void search(char *pattern, bool reverse); 162 static void search_prompt(bool reverse); 163 static void search_repeat(void); 154 164 155 165 static void pt_get_sof(spt_t *pt); … … 160 170 static bool pt_is_delimiter(spt_t *pt); 161 171 static bool pt_is_punctuation(spt_t *pt); 172 static spt_t pt_find_word_left(spt_t spt); 173 static spt_t pt_find_word_left(spt_t spt); 174 162 175 static int tag_cmp(tag_t const *a, tag_t const *b); 163 176 static int spt_cmp(spt_t const *a, spt_t const *b); … … 170 183 { 171 184 kbd_event_t ev; 172 coord_t coord;173 185 bool new_file; 174 175 spt_t pt; 186 int rc; 176 187 177 188 con = console_init(stdin, stdout); … … 186 197 187 198 /* Start with an empty sheet. */ 188 sheet_init(&doc.sh); 199 rc = sheet_create(&doc.sh); 200 if (rc != EOK) { 201 printf("Out of memory.\n"); 202 return -1; 203 } 189 204 190 205 /* Place caret at the beginning of file. */ 191 coord.row = coord.column = 1;192 sheet_get_cell_pt(&doc.sh, &coord, dir_before, &pt);193 sheet_place_tag( &doc.sh, &pt, &pane.caret_pos);194 pane.ideal_column = coord.column;206 spt_t sof; 207 pt_get_sof(&sof); 208 sheet_place_tag(doc.sh, &sof, &pane.caret_pos); 209 pane.ideal_column = 1; 195 210 196 211 if (argc == 2) { … … 208 223 new_file = true; 209 224 225 /* Place selection start tag. */ 226 sheet_place_tag(doc.sh, &sof, &pane.sel_start); 227 210 228 /* Move to beginning of file. */ 211 caret_move(-ED_INFTY, -ED_INFTY, dir_before); 212 213 /* Place selection start tag. */ 214 tag_get_pt(&pane.caret_pos, &pt); 215 sheet_place_tag(&doc.sh, &pt, &pane.sel_start); 229 pt_get_sof(&sof); 230 caret_move(sof, true, true); 216 231 217 232 /* Initial display */ … … 361 376 static void key_handle_ctrl(kbd_event_t const *ev) 362 377 { 378 spt_t pt; 363 379 switch (ev->key) { 364 380 case KC_Q: … … 392 408 selection_sel_all(); 393 409 break; 394 case KC_W:395 if (selection_active())396 break;397 selection_sel_prev_word();398 selection_delete();399 break;400 410 case KC_RIGHT: 401 caret_move_word_right( );411 caret_move_word_right(false); 402 412 break; 403 413 case KC_LEFT: 404 caret_move_word_left(); 414 caret_move_word_left(false); 415 break; 416 case KC_L: 417 caret_go_to_line_ask(); 418 break; 419 case KC_F: 420 search_prompt(false); 421 break; 422 case KC_N: 423 search_repeat(); 424 break; 425 case KC_HOME: 426 pt_get_sof(&pt); 427 caret_move(pt, false, true); 428 break; 429 case KC_END: 430 pt_get_eof(&pt); 431 caret_move(pt, false, true); 405 432 break; 406 433 default: … … 411 438 static void key_handle_shift_ctrl(kbd_event_t const *ev) 412 439 { 440 spt_t pt; 413 441 switch(ev->key) { 414 442 case KC_LEFT: 415 selection_sel_prev_word();443 caret_move_word_left(true); 416 444 break; 417 445 case KC_RIGHT: 418 selection_sel_next_word(); 446 caret_move_word_right(true); 447 break; 448 case KC_F: 449 search_prompt(true); 450 break; 451 case KC_HOME: 452 pt_get_sof(&pt); 453 caret_move(pt, true, true); 454 break; 455 case KC_END: 456 pt_get_eof(&pt); 457 caret_move(pt, true, true); 419 458 break; 420 459 default: … … 423 462 } 424 463 425 static void key_handle_movement(unsigned int key, bool select) 426 { 427 spt_t pt; 428 spt_t caret_pt;464 /** Move caret while preserving or resetting selection. */ 465 static void caret_move(spt_t new_caret_pt, bool select, bool update_ideal_column) 466 { 467 spt_t old_caret_pt, old_sel_pt; 429 468 coord_t c_old, c_new; 430 469 bool had_sel; 431 470 432 471 /* Check if we had selection before. */ 433 tag_get_pt(&pane.caret_pos, &caret_pt); 434 tag_get_pt(&pane.sel_start, &pt); 435 had_sel = !spt_equal(&caret_pt, &pt); 436 437 switch (key) { 438 case KC_LEFT: 439 caret_move(0, -1, dir_before); 440 break; 441 case KC_RIGHT: 442 caret_move(0, 0, dir_after); 443 break; 444 case KC_UP: 445 caret_move(-1, 0, dir_before); 446 break; 447 case KC_DOWN: 448 caret_move(+1, 0, dir_before); 449 break; 450 case KC_HOME: 451 caret_move(0, -ED_INFTY, dir_before); 452 break; 453 case KC_END: 454 caret_move(0, +ED_INFTY, dir_before); 455 break; 456 case KC_PAGE_UP: 457 caret_move(-pane.rows, 0, dir_before); 458 break; 459 case KC_PAGE_DOWN: 460 caret_move(+pane.rows, 0, dir_before); 461 break; 462 default: 463 break; 464 } 472 tag_get_pt(&pane.caret_pos, &old_caret_pt); 473 tag_get_pt(&pane.sel_start, &old_sel_pt); 474 had_sel = !spt_equal(&old_caret_pt, &old_sel_pt); 475 476 /* Place tag of the caret */ 477 sheet_remove_tag(doc.sh, &pane.caret_pos); 478 sheet_place_tag(doc.sh, &new_caret_pt, &pane.caret_pos); 465 479 466 480 if (select == false) { 467 481 /* Move sel_start to the same point as caret. */ 468 sheet_remove_tag( &doc.sh, &pane.sel_start);469 tag_get_pt(&pane.caret_pos, &pt);470 sheet_place_tag(&doc.sh, &pt, &pane.sel_start);471 } 472 482 sheet_remove_tag(doc.sh, &pane.sel_start); 483 sheet_place_tag(doc.sh, &new_caret_pt, &pane.sel_start); 484 } 485 486 spt_get_coord(&new_caret_pt, &c_new); 473 487 if (select) { 474 tag_get_pt(&pane.caret_pos, &pt); 475 spt_get_coord(&caret_pt, &c_old); 476 spt_get_coord(&pt, &c_new); 488 spt_get_coord(&old_caret_pt, &c_old); 477 489 478 490 if (c_old.row == c_new.row) … … 485 497 pane.rflags |= REDRAW_TEXT; 486 498 } 499 500 if (update_ideal_column) 501 pane.ideal_column = c_new.column; 502 503 caret_update(); 504 } 505 506 static void key_handle_movement(unsigned int key, bool select) 507 { 508 spt_t pt; 509 switch (key) { 510 case KC_LEFT: 511 caret_move_relative(0, -1, dir_before, select); 512 break; 513 case KC_RIGHT: 514 caret_move_relative(0, 0, dir_after, select); 515 break; 516 case KC_UP: 517 caret_move_relative(-1, 0, dir_before, select); 518 break; 519 case KC_DOWN: 520 caret_move_relative(+1, 0, dir_before, select); 521 break; 522 case KC_HOME: 523 tag_get_pt(&pane.caret_pos, &pt); 524 pt_get_sol(&pt, &pt); 525 caret_move(pt, select, true); 526 break; 527 case KC_END: 528 tag_get_pt(&pane.caret_pos, &pt); 529 pt_get_eol(&pt, &pt); 530 caret_move(pt, select, true); 531 break; 532 case KC_PAGE_UP: 533 caret_move_relative(-pane.rows, 0, dir_before, select); 534 break; 535 case KC_PAGE_DOWN: 536 caret_move_relative(+pane.rows, 0, dir_before, select); 537 break; 538 default: 539 break; 540 } 487 541 } 488 542 … … 520 574 char *fname; 521 575 522 fname = filename_prompt("Save As", old_fname);576 fname = prompt("Save As", old_fname); 523 577 if (fname == NULL) { 524 578 status_display("Save cancelled."); … … 535 589 } 536 590 537 /** Ask for a file name. */538 static char * filename_prompt(char const *prompt, char const *init_value)591 /** Ask for a string. */ 592 static char *prompt(char const *prompt, char const *init_value) 539 593 { 540 594 kbd_event_t ev; … … 657 711 658 712 do { 659 sheet_copy_out( &doc.sh, &sp, epos, buf, BUF_SIZE, &bep);713 sheet_copy_out(doc.sh, &sp, epos, buf, BUF_SIZE, &bep); 660 714 bytes = str_size(buf); 661 715 … … 692 746 693 747 while (true) { 694 sheet_copy_out( &doc.sh, &sp, epos, &buf[bpos], buf_size - bpos,748 sheet_copy_out(doc.sh, &sp, epos, &buf[bpos], buf_size - bpos, 695 749 &bep); 696 750 bytes = str_size(&buf[bpos]); … … 714 768 int sh_rows, rows; 715 769 716 sheet_get_num_rows( &doc.sh, &sh_rows);770 sheet_get_num_rows(doc.sh, &sh_rows); 717 771 rows = min(sh_rows - pane.sh_row + 1, pane.rows); 718 772 … … 784 838 rbc.row = pane.sh_row + i; 785 839 rbc.column = pane.sh_column; 786 sheet_get_cell_pt( &doc.sh, &rbc, dir_before, &rb);840 sheet_get_cell_pt(doc.sh, &rbc, dir_before, &rb); 787 841 788 842 /* Ending point for row display */ 789 843 rec.row = pane.sh_row + i; 790 844 rec.column = pane.sh_column + pane.columns; 791 sheet_get_cell_pt( &doc.sh, &rec, dir_before, &re);845 sheet_get_cell_pt(doc.sh, &rec, dir_before, &re); 792 846 793 847 /* Copy the text of the row to the buffer. */ 794 sheet_copy_out( &doc.sh, &rb, &re, row_buf, ROW_BUF_SIZE, &dep);848 sheet_copy_out(doc.sh, &rb, &re, row_buf, ROW_BUF_SIZE, &dep); 795 849 796 850 /* Display text from the buffer. */ … … 842 896 /* Fill until the end of display area. */ 843 897 844 if ( str_length(row_buf) < (unsigned)scr_columns)845 fill = scr_columns - str_length(row_buf);898 if ((unsigned)s_column - 1 < scr_columns) 899 fill = scr_columns - (s_column - 1); 846 900 else 847 901 fill = 0; … … 861 915 spt_t caret_pt; 862 916 coord_t coord; 917 int last_row; 863 918 864 919 tag_get_pt(&pane.caret_pos, &caret_pt); 865 920 spt_get_coord(&caret_pt, &coord); 866 921 922 sheet_get_num_rows(doc.sh, &last_row); 923 867 924 const char *fname = (doc.file_name != NULL) ? doc.file_name : "<unnamed>"; 868 925 869 926 console_set_pos(con, 0, scr_rows - 1); 870 927 console_set_style(con, STYLE_INVERTED); 871 int n = printf(" %d, %d : File '%s'. Ctrl-Q Quit Ctrl-S Save "872 "Ctrl-E Save As", coord.row, coord.column, fname);928 int n = printf(" %d, %d (%d): File '%s'. Ctrl-Q Quit Ctrl-S Save " 929 "Ctrl-E Save As", coord.row, coord.column, last_row, fname); 873 930 874 931 int pos = scr_columns - 1 - n; … … 906 963 cbuf[offs] = '\0'; 907 964 908 (void) sheet_insert( &doc.sh, &pt, dir_before, cbuf);965 (void) sheet_insert(doc.sh, &pt, dir_before, cbuf); 909 966 910 967 pane.rflags |= REDRAW_ROW; … … 923 980 924 981 coord.column -= 1; 925 sheet_get_cell_pt( &doc.sh, &coord, dir_before, &sp);926 927 (void) sheet_delete( &doc.sh, &sp, &ep);982 sheet_get_cell_pt(doc.sh, &coord, dir_before, &sp); 983 984 (void) sheet_delete(doc.sh, &sp, &ep); 928 985 929 986 pane.rflags |= REDRAW_ROW; … … 941 998 spt_get_coord(&sp, &sc); 942 999 943 sheet_get_cell_pt( &doc.sh, &sc, dir_after, &ep);1000 sheet_get_cell_pt(doc.sh, &sc, dir_after, &ep); 944 1001 spt_get_coord(&ep, &ec); 945 1002 946 (void) sheet_delete( &doc.sh, &sp, &ep);1003 (void) sheet_delete(doc.sh, &sp, &ep); 947 1004 948 1005 pane.rflags |= REDRAW_ROW; … … 991 1048 } 992 1049 993 /** Change the caret position.1050 /** Relatively move caret position. 994 1051 * 995 1052 * Moves caret relatively to the current position. Looking at the first … … 997 1054 * to a new character cell, and thus a new character. Then we either go to the 998 1055 * point before the the character or after it, depending on @a align_dir. 1056 * 1057 * @param select true if the selection tag should stay where it is 999 1058 */ 1000 static void caret_move(int drow, int dcolumn, enum dir_spec align_dir) 1059 static void caret_move_relative(int drow, int dcolumn, enum dir_spec align_dir, 1060 bool select) 1001 1061 { 1002 1062 spt_t pt; … … 1016 1076 else { 1017 1077 coord.row--; 1018 sheet_get_row_width( &doc.sh, coord.row, &coord.column);1078 sheet_get_row_width(doc.sh, coord.row, &coord.column); 1019 1079 } 1020 1080 } 1021 1081 if (drow > 0) { 1022 sheet_get_num_rows( &doc.sh, &num_rows);1082 sheet_get_num_rows(doc.sh, &num_rows); 1023 1083 if (coord.row > num_rows) coord.row = num_rows; 1024 1084 } … … 1033 1093 * coordinates. The character can be wider than one cell (e.g. tab). 1034 1094 */ 1035 sheet_get_cell_pt(&doc.sh, &coord, align_dir, &pt); 1036 sheet_remove_tag(&doc.sh, &pane.caret_pos); 1037 sheet_place_tag(&doc.sh, &pt, &pane.caret_pos); 1095 sheet_get_cell_pt(doc.sh, &coord, align_dir, &pt); 1038 1096 1039 1097 /* For non-vertical movement set the new value for @c ideal_column. */ 1040 if (!pure_vertical) { 1041 spt_get_coord(&pt, &coord); 1042 pane.ideal_column = coord.column; 1043 } 1044 1045 caret_update(); 1046 } 1047 1048 static void caret_move_word_left(void) 1049 { 1098 caret_move(pt, select, !pure_vertical); 1099 } 1100 1101 /** Absolutely move caret position. 1102 * 1103 * Moves caret to a specified position. We get to a new character cell, and 1104 * thus a new character. Then we either go to the point before the the character 1105 * or after it, depending on @a align_dir. 1106 * 1107 * @param select true if the selection tag should stay where it is 1108 */ 1109 static void caret_move_absolute(int row, int column, enum dir_spec align_dir, 1110 bool select) 1111 { 1112 coord_t coord; 1113 coord.row = row; 1114 coord.column = column; 1115 1050 1116 spt_t pt; 1051 1117 sheet_get_cell_pt(doc.sh, &coord, align_dir, &pt); 1118 1119 caret_move(pt, select, true); 1120 } 1121 1122 /** Find beginning of a word to the left of spt */ 1123 static spt_t pt_find_word_left(spt_t spt) 1124 { 1052 1125 do { 1053 caret_move(0, -1, dir_before); 1054 1055 tag_get_pt(&pane.caret_pos, &pt); 1056 1057 sheet_remove_tag(&doc.sh, &pane.sel_start); 1058 sheet_place_tag(&doc.sh, &pt, &pane.sel_start); 1059 } while (!pt_is_word_beginning(&pt)); 1060 1061 pane.rflags |= REDRAW_TEXT; 1062 } 1063 1064 static void caret_move_word_right(void) 1126 spt_prev_char(spt, &spt); 1127 } while (!pt_is_word_beginning(&spt)); 1128 return spt; 1129 } 1130 1131 /** Find beginning of a word to the right of spt */ 1132 static spt_t pt_find_word_right(spt_t spt) 1133 { 1134 do { 1135 spt_next_char(spt, &spt); 1136 } while (!pt_is_word_beginning(&spt)); 1137 return spt; 1138 } 1139 1140 static void caret_move_word_left(bool select) 1065 1141 { 1066 1142 spt_t pt; 1067 1068 do { 1069 caret_move(0, 0, dir_after); 1070 1071 tag_get_pt(&pane.caret_pos, &pt); 1072 1073 sheet_remove_tag(&doc.sh, &pane.sel_start); 1074 sheet_place_tag(&doc.sh, &pt, &pane.sel_start); 1075 } while (!pt_is_word_beginning(&pt)); 1076 1077 pane.rflags |= REDRAW_TEXT; 1143 tag_get_pt(&pane.caret_pos, &pt); 1144 spt_t word_left = pt_find_word_left(pt); 1145 caret_move(word_left, select, true); 1146 } 1147 1148 static void caret_move_word_right(bool select) 1149 { 1150 spt_t pt; 1151 tag_get_pt(&pane.caret_pos, &pt); 1152 spt_t word_right = pt_find_word_right(pt); 1153 caret_move(word_right, select, true); 1154 } 1155 1156 /** Ask for line and go to it. */ 1157 static void caret_go_to_line_ask(void) 1158 { 1159 char *sline; 1160 1161 sline = prompt("Go to line", ""); 1162 if (sline == NULL) { 1163 status_display("Go to line cancelled."); 1164 return; 1165 } 1166 1167 char *endptr; 1168 int line = strtol(sline, &endptr, 10); 1169 if (*endptr != '\0') { 1170 free(sline); 1171 status_display("Invalid number entered."); 1172 return; 1173 } 1174 free(sline); 1175 1176 caret_move_absolute(line, pane.ideal_column, dir_before, false); 1177 } 1178 1179 /* Search operations */ 1180 static int search_spt_producer(void *data, wchar_t *ret) 1181 { 1182 assert(data != NULL); 1183 assert(ret != NULL); 1184 spt_t *spt = data; 1185 *ret = spt_next_char(*spt, spt); 1186 return EOK; 1187 } 1188 1189 static int search_spt_reverse_producer(void *data, wchar_t *ret) 1190 { 1191 assert(data != NULL); 1192 assert(ret != NULL); 1193 spt_t *spt = data; 1194 *ret = spt_prev_char(*spt, spt); 1195 return EOK; 1196 } 1197 1198 static int search_spt_mark(void *data, void **mark) 1199 { 1200 assert(data != NULL); 1201 assert(mark != NULL); 1202 spt_t *spt = data; 1203 spt_t *new = calloc(1, sizeof(spt_t)); 1204 *mark = new; 1205 if (new == NULL) 1206 return ENOMEM; 1207 *new = *spt; 1208 return EOK; 1209 } 1210 1211 static void search_spt_mark_free(void *data) 1212 { 1213 free(data); 1214 } 1215 1216 static search_ops_t search_spt_ops = { 1217 .equals = char_exact_equals, 1218 .producer = search_spt_producer, 1219 .mark = search_spt_mark, 1220 .mark_free = search_spt_mark_free, 1221 }; 1222 1223 static search_ops_t search_spt_reverse_ops = { 1224 .equals = char_exact_equals, 1225 .producer = search_spt_reverse_producer, 1226 .mark = search_spt_mark, 1227 .mark_free = search_spt_mark_free, 1228 }; 1229 1230 /** Ask for line and go to it. */ 1231 static void search_prompt(bool reverse) 1232 { 1233 char *pattern; 1234 1235 const char *prompt_text = "Find next"; 1236 if (reverse) 1237 prompt_text = "Find previous"; 1238 1239 const char *default_value = ""; 1240 if (pane.previous_search) 1241 default_value = pane.previous_search; 1242 1243 pattern = prompt(prompt_text, default_value); 1244 if (pattern == NULL) { 1245 status_display("Search cancelled."); 1246 return; 1247 } 1248 1249 if (pane.previous_search) 1250 free(pane.previous_search); 1251 pane.previous_search = pattern; 1252 pane.previous_search_reverse = reverse; 1253 1254 search(pattern, reverse); 1255 } 1256 1257 static void search_repeat(void) 1258 { 1259 if (pane.previous_search == NULL) { 1260 status_display("No previous search to repeat."); 1261 return; 1262 } 1263 1264 search(pane.previous_search, pane.previous_search_reverse); 1265 } 1266 1267 static void search(char *pattern, bool reverse) 1268 { 1269 status_display("Searching..."); 1270 1271 spt_t sp, producer_pos; 1272 tag_get_pt(&pane.caret_pos, &sp); 1273 1274 /* Start searching on the position before/after caret */ 1275 if (!reverse) { 1276 spt_next_char(sp, &sp); 1277 } 1278 else { 1279 spt_prev_char(sp, &sp); 1280 } 1281 producer_pos = sp; 1282 1283 search_ops_t ops = search_spt_ops; 1284 if (reverse) 1285 ops = search_spt_reverse_ops; 1286 1287 search_t *search = search_init(pattern, &producer_pos, ops, reverse); 1288 if (search == NULL) { 1289 status_display("Failed initializing search."); 1290 return; 1291 } 1292 1293 match_t match; 1294 int rc = search_next_match(search, &match); 1295 if (rc != EOK) { 1296 status_display("Failed searching."); 1297 search_fini(search); 1298 } 1299 1300 if (match.end) { 1301 status_display("Match found."); 1302 assert(match.end != NULL); 1303 spt_t *end = match.end; 1304 caret_move(*end, false, true); 1305 while (match.length > 0) { 1306 match.length--; 1307 if (reverse) { 1308 spt_next_char(*end, end); 1309 } 1310 else { 1311 spt_prev_char(*end, end); 1312 } 1313 } 1314 caret_move(*end, true, true); 1315 free(end); 1316 } 1317 else { 1318 status_display("Not found."); 1319 } 1320 1321 search_fini(search); 1078 1322 } 1079 1323 … … 1115 1359 1116 1360 if (rel < 0) 1117 sheet_delete( &doc.sh, &pa, &pb);1361 sheet_delete(doc.sh, &pa, &pb); 1118 1362 else 1119 sheet_delete( &doc.sh, &pb, &pa);1363 sheet_delete(doc.sh, &pb, &pa); 1120 1364 1121 1365 if (ca.row == cb.row) … … 1139 1383 static void selection_sel_range(spt_t pa, spt_t pb) 1140 1384 { 1141 sheet_remove_tag( &doc.sh, &pane.sel_start);1142 sheet_place_tag( &doc.sh, &pa, &pane.sel_start);1143 sheet_remove_tag( &doc.sh, &pane.caret_pos);1144 sheet_place_tag( &doc.sh, &pb, &pane.caret_pos);1385 sheet_remove_tag(doc.sh, &pane.sel_start); 1386 sheet_place_tag(doc.sh, &pa, &pane.sel_start); 1387 sheet_remove_tag(doc.sh, &pane.caret_pos); 1388 sheet_place_tag(doc.sh, &pb, &pane.caret_pos); 1145 1389 1146 1390 pane.rflags |= REDRAW_TEXT; 1147 1391 caret_update(); 1148 }1149 1150 /** Add the previous word to the selection */1151 static void selection_sel_prev_word(void)1152 {1153 spt_t cpt, wpt, spt, ept;1154 1155 selection_get_points(&spt, &ept);1156 1157 tag_get_pt(&pane.caret_pos, &cpt);1158 caret_move_word_left();1159 tag_get_pt(&pane.caret_pos, &wpt);1160 1161 if (spt_cmp(&spt, &cpt) == 0)1162 selection_sel_range(ept, wpt);1163 else1164 selection_sel_range(spt, wpt);1165 }1166 1167 /** Add the next word to the selection */1168 static void selection_sel_next_word(void)1169 {1170 spt_t cpt, wpt, spt, ept;1171 1172 selection_get_points(&spt, &ept);1173 1174 tag_get_pt(&pane.caret_pos, &cpt);1175 caret_move_word_right();1176 tag_get_pt(&pane.caret_pos, &wpt);1177 1178 if (spt_cmp(&ept, &cpt) == 0)1179 selection_sel_range(spt, wpt);1180 else1181 selection_sel_range(ept, wpt);1182 1392 } 1183 1393 … … 1225 1435 1226 1436 coord.row = coord.column = 1; 1227 sheet_get_cell_pt( &doc.sh, &coord, dir_before, pt);1437 sheet_get_cell_pt(doc.sh, &coord, dir_before, pt); 1228 1438 } 1229 1439 … … 1234 1444 int num_rows; 1235 1445 1236 sheet_get_num_rows( &doc.sh, &num_rows);1446 sheet_get_num_rows(doc.sh, &num_rows); 1237 1447 coord.row = num_rows + 1; 1238 1448 coord.column = 1; 1239 1449 1240 sheet_get_cell_pt( &doc.sh, &coord, dir_after, pt);1450 sheet_get_cell_pt(doc.sh, &coord, dir_after, pt); 1241 1451 } 1242 1452 … … 1249 1459 coord.column = 1; 1250 1460 1251 sheet_get_cell_pt( &doc.sh, &coord, dir_before, spt);1461 sheet_get_cell_pt(doc.sh, &coord, dir_before, spt); 1252 1462 } 1253 1463 … … 1259 1469 1260 1470 spt_get_coord(cpt, &coord); 1261 sheet_get_row_width( &doc.sh, coord.row, &row_width);1471 sheet_get_row_width(doc.sh, coord.row, &row_width); 1262 1472 coord.column = row_width - 1; 1263 1473 1264 sheet_get_cell_pt( &doc.sh, &coord, dir_after, ept);1474 sheet_get_cell_pt(doc.sh, &coord, dir_after, ept); 1265 1475 } 1266 1476 … … 1288 1498 1289 1499 coord.column -= 1; 1290 sheet_get_cell_pt( &doc.sh, &coord, dir_before, &lp);1500 sheet_get_cell_pt(doc.sh, &coord, dir_before, &lp); 1291 1501 1292 1502 return pt_is_delimiter(&lp) … … 1310 1520 1311 1521 coord.column += 1; 1312 sheet_get_cell_pt( &doc.sh, &coord, dir_after, &rp);1522 sheet_get_cell_pt(doc.sh, &coord, dir_after, &rp); 1313 1523 1314 1524 ch = range_get_str(pt, &rp); … … 1336 1546 1337 1547 coord.column += 1; 1338 sheet_get_cell_pt( &doc.sh, &coord, dir_after, &rp);1548 sheet_get_cell_pt(doc.sh, &coord, dir_after, &rp); 1339 1549 1340 1550 ch = range_get_str(pt, &rp); -
uspace/app/edit/sheet.c
rb5d2e57 r03362fbd 57 57 58 58 #include "sheet.h" 59 #include "sheet_impl.h" 59 60 60 61 enum { … … 66 67 67 68 /** Initialize an empty sheet. */ 68 int sheet_init(sheet_t *sh) 69 { 69 int sheet_create(sheet_t **rsh) 70 { 71 sheet_t *sh; 72 73 sh = calloc(1, sizeof(sheet_t)); 74 if (sh == NULL) 75 return ENOMEM; 76 70 77 sh->dbuf_size = INITIAL_SIZE; 71 78 sh->text_size = 0; … … 77 84 list_initialize(&sh->tags); 78 85 86 *rsh = sh; 79 87 return EOK; 80 88 } … … 315 323 } 316 324 325 /** Get a character at spt and return next spt */ 326 wchar_t spt_next_char(spt_t spt, spt_t *next) 327 { 328 wchar_t ch = str_decode(spt.sh->data, &spt.b_off, spt.sh->text_size); 329 if (next) 330 *next = spt; 331 return ch; 332 } 333 334 wchar_t spt_prev_char(spt_t spt, spt_t *prev) 335 { 336 wchar_t ch = str_decode_reverse(spt.sh->data, &spt.b_off, spt.sh->text_size); 337 if (prev) 338 *prev = spt; 339 return ch; 340 } 341 317 342 /** Place a tag on the specified s-point. */ 318 343 void sheet_place_tag(sheet_t *sh, spt_t const *pt, tag_t *tag) -
uspace/app/edit/sheet.h
rb5d2e57 r03362fbd 39 39 #include <adt/list.h> 40 40 #include <sys/types.h> 41 #include < bool.h>41 #include <stdbool.h> 42 42 43 43 /** Direction (in linear space) */ … … 50 50 51 51 /** Sheet */ 52 typedef struct { 53 /* Note: This structure is opaque for the user. */ 54 55 size_t text_size; 56 size_t dbuf_size; 57 char *data; 58 59 list_t tags; 60 } sheet_t; 52 struct sheet; 53 typedef struct sheet sheet_t; 61 54 62 55 /** Character cell coordinates … … 97 90 } tag_t; 98 91 99 extern int sheet_ init(sheet_t*);92 extern int sheet_create(sheet_t **); 100 93 extern int sheet_insert(sheet_t *, spt_t *, enum dir_spec, char *); 101 94 extern int sheet_delete(sheet_t *, spt_t *, spt_t *); … … 108 101 extern void spt_get_coord(spt_t const *, coord_t *); 109 102 extern bool spt_equal(spt_t const *, spt_t const *); 103 extern wchar_t spt_next_char(spt_t, spt_t *); 104 extern wchar_t spt_prev_char(spt_t, spt_t *); 110 105 111 106 extern void sheet_place_tag(sheet_t *, spt_t const *, tag_t *); -
uspace/app/init/init.c
rb5d2e57 r03362fbd 37 37 #include <stdio.h> 38 38 #include <unistd.h> 39 #include <stdarg.h> 39 40 #include <vfs/vfs.h> 40 #include < bool.h>41 #include <stdbool.h> 41 42 #include <errno.h> 42 43 #include <fcntl.h> … … 65 66 #define SRV_CONSOLE "/srv/console" 66 67 #define APP_GETTERM "/app/getterm" 68 69 #define SRV_COMPOSITOR "/srv/compositor" 70 71 #define HID_INPUT "hid/input" 72 #define HID_OUTPUT "hid/output" 73 #define HID_COMPOSITOR_SERVER ":0" 74 75 #define srv_start(path, ...) \ 76 srv_startl(path, path, ##__VA_ARGS__, NULL) 67 77 68 78 /** Print banner */ … … 143 153 } 144 154 145 static void spawn(const char *fname) 146 { 147 int rc; 155 static int srv_startl(const char *path, ...) 156 { 148 157 struct stat s; 149 150 if (stat(fname, &s) == ENOENT) 151 return; 152 153 printf("%s: Spawning %s\n", NAME, fname); 154 rc = task_spawnl(NULL, fname, fname, NULL); 155 if (rc != EOK) { 156 printf("%s: Error spawning %s (%s)\n", NAME, fname, 157 str_error(rc)); 158 } 159 } 160 161 static void srv_start(const char *fname) 162 { 158 if (stat(path, &s) == ENOENT) { 159 printf("%s: Unable to stat %s\n", NAME, path); 160 return ENOENT; 161 } 162 163 printf("%s: Starting %s\n", NAME, path); 164 165 va_list ap; 166 const char *arg; 167 int cnt = 0; 168 169 va_start(ap, path); 170 do { 171 arg = va_arg(ap, const char *); 172 cnt++; 173 } while (arg != NULL); 174 va_end(ap); 175 176 va_start(ap, path); 163 177 task_id_t id; 178 int rc = task_spawn(&id, path, cnt, ap); 179 va_end(ap); 180 181 if (rc != EOK) { 182 printf("%s: Error spawning %s (%s)\n", NAME, path, 183 str_error(rc)); 184 return rc; 185 } 186 187 if (!id) { 188 printf("%s: Error spawning %s (invalid task id)\n", NAME, 189 path); 190 return EINVAL; 191 } 192 164 193 task_exit_t texit; 165 int rc, retval; 166 struct stat s; 167 168 if (stat(fname, &s) == ENOENT) 169 return; 170 171 printf("%s: Starting %s\n", NAME, fname); 172 rc = task_spawnl(&id, fname, fname, NULL); 173 if (!id) { 174 printf("%s: Error spawning %s (%s)\n", NAME, fname, 175 str_error(rc)); 176 return; 177 } 178 194 int retval; 179 195 rc = task_wait(id, &texit, &retval); 180 196 if (rc != EOK) { 181 printf("%s: Error waiting for %s (%s)\n", NAME, fname,182 str_error(rc)); 183 return ;197 printf("%s: Error waiting for %s (%s)\n", NAME, path, 198 str_error(rc)); 199 return rc; 184 200 } 185 201 186 202 if (texit != TASK_EXIT_NORMAL) { 187 203 printf("%s: Server %s failed to start (unexpectedly " 188 "terminated)\n", NAME, fname);189 return ;190 } 191 192 if (retval != 0) {204 "terminated)\n", NAME, path); 205 return EINVAL; 206 } 207 208 if (retval != 0) 193 209 printf("%s: Server %s failed to start (exit code %d)\n", NAME, 194 fname, retval); 195 } 196 } 197 198 static void console(const char *isvc, const char *fbsvc) 199 { 200 printf("%s: Spawning %s %s %s\n", NAME, SRV_CONSOLE, isvc, fbsvc); 201 210 path, retval); 211 212 return retval; 213 } 214 215 static int console(const char *isvc, const char *osvc) 216 { 202 217 /* Wait for the input service to be ready */ 203 218 service_id_t service_id; … … 206 221 printf("%s: Error waiting on %s (%s)\n", NAME, isvc, 207 222 str_error(rc)); 208 return; 209 } 210 211 /* Wait for the framebuffer service to be ready */ 212 rc = loc_service_get_id(fbsvc, &service_id, IPC_FLAG_BLOCKING); 213 if (rc != EOK) { 214 printf("%s: Error waiting on %s (%s)\n", NAME, fbsvc, 215 str_error(rc)); 216 return; 217 } 218 219 rc = task_spawnl(NULL, SRV_CONSOLE, SRV_CONSOLE, isvc, fbsvc, NULL); 220 if (rc != EOK) { 221 printf("%s: Error spawning %s %s %s (%s)\n", NAME, SRV_CONSOLE, 222 isvc, fbsvc, str_error(rc)); 223 } 223 return rc; 224 } 225 226 /* Wait for the output service to be ready */ 227 rc = loc_service_get_id(osvc, &service_id, IPC_FLAG_BLOCKING); 228 if (rc != EOK) { 229 printf("%s: Error waiting on %s (%s)\n", NAME, osvc, 230 str_error(rc)); 231 return rc; 232 } 233 234 return srv_start(SRV_CONSOLE, isvc, osvc); 235 } 236 237 static int compositor(const char *isvc, const char *name) 238 { 239 /* Wait for the input service to be ready */ 240 service_id_t service_id; 241 int rc = loc_service_get_id(isvc, &service_id, IPC_FLAG_BLOCKING); 242 if (rc != EOK) { 243 printf("%s: Error waiting on %s (%s)\n", NAME, isvc, 244 str_error(rc)); 245 return rc; 246 } 247 248 return srv_start(SRV_COMPOSITOR, isvc, name); 249 } 250 251 static int gui_start(const char *app, const char *srv_name) 252 { 253 char winreg[50]; 254 snprintf(winreg, sizeof(winreg), "%s%s%s", "comp", srv_name, "/winreg"); 255 256 printf("%s: Spawning %s %s\n", NAME, app, winreg); 257 258 task_id_t id; 259 int rc = task_spawnl(&id, app, app, winreg, NULL); 260 if (rc != EOK) { 261 printf("%s: Error spawning %s %s (%s)\n", NAME, app, 262 winreg, str_error(rc)); 263 return -1; 264 } 265 266 task_exit_t texit; 267 int retval; 268 rc = task_wait(id, &texit, &retval); 269 if ((rc != EOK) || (texit != TASK_EXIT_NORMAL)) { 270 printf("%s: Error retrieving retval from %s (%s)\n", NAME, 271 app, str_error(rc)); 272 return -1; 273 } 274 275 return retval; 224 276 } 225 277 … … 227 279 { 228 280 char term[LOC_NAME_MAXLEN]; 229 int rc;230 231 281 snprintf(term, LOC_NAME_MAXLEN, "%s/%s", LOCFS_MOUNT_POINT, svc); 232 282 … … 235 285 /* Wait for the terminal service to be ready */ 236 286 service_id_t service_id; 237 rc = loc_service_get_id(svc, &service_id, IPC_FLAG_BLOCKING);287 int rc = loc_service_get_id(svc, &service_id, IPC_FLAG_BLOCKING); 238 288 if (rc != EOK) { 239 289 printf("%s: Error waiting on %s (%s)\n", NAME, term, … … 279 329 if (!mount_root(STRING(RDFMT))) { 280 330 printf("%s: Exiting\n", NAME); 281 return -1;331 return 1; 282 332 } 283 333 284 334 /* Make sure tmpfs is running. */ 285 if (str_cmp(STRING(RDFMT), "tmpfs") != 0) { 286 spawn("/srv/tmpfs"); 287 } 288 289 spawn("/srv/locfs"); 290 spawn("/srv/taskmon"); 335 if (str_cmp(STRING(RDFMT), "tmpfs") != 0) 336 srv_start("/srv/tmpfs"); 337 338 srv_start("/srv/locfs"); 339 srv_start("/srv/taskmon"); 291 340 292 341 if (!mount_locfs()) { 293 342 printf("%s: Exiting\n", NAME); 294 return -2;343 return 2; 295 344 } 296 345 297 346 mount_tmpfs(); 298 347 299 s pawn("/srv/devman");300 s pawn("/srv/apic");301 s pawn("/srv/i8259");302 s pawn("/srv/obio");348 srv_start("/srv/devman"); 349 srv_start("/srv/apic"); 350 srv_start("/srv/i8259"); 351 srv_start("/srv/obio"); 303 352 srv_start("/srv/cuda_adb"); 304 353 srv_start("/srv/s3c24xx_uart"); 305 354 srv_start("/srv/s3c24xx_ts"); 306 355 307 spawn("/srv/loopip"); 308 spawn("/srv/ethip"); 309 spawn("/srv/inetsrv"); 310 spawn("/srv/tcp"); 311 spawn("/srv/udp"); 312 313 spawn("/srv/fb"); 314 spawn("/srv/input"); 315 console("hid/input", "hid/fb0"); 316 317 spawn("/srv/clipboard"); 318 spawn("/srv/remcons"); 356 srv_start("/srv/loopip"); 357 srv_start("/srv/ethip"); 358 srv_start("/srv/inetsrv"); 359 srv_start("/srv/tcp"); 360 srv_start("/srv/udp"); 361 362 srv_start("/srv/clipboard"); 363 srv_start("/srv/remcons"); 319 364 320 365 /* … … 325 370 srv_start("/srv/ata_bd"); 326 371 srv_start("/srv/gxe_bd"); 327 #else328 (void) srv_start;329 372 #endif 330 373 331 374 #ifdef CONFIG_MOUNT_DATA 332 375 /* Make sure fat is running. */ 333 if (str_cmp(STRING(RDFMT), "fat") != 0) {376 if (str_cmp(STRING(RDFMT), "fat") != 0) 334 377 srv_start("/srv/fat"); 335 }378 336 379 mount_data(); 337 380 #else … … 339 382 #endif 340 383 341 spawn("/srv/hound"); 342 switch((unsigned)CONFIG_VC_COUNT) { 343 default: 344 case 6: getterm("term/vc5", "/app/bdsh", false); 345 case 5: getterm("term/vc4", "/app/bdsh", false); 346 case 4: getterm("term/vc3", "/app/bdsh", false); 347 case 3: getterm("term/vc2", "/app/bdsh", false); 348 case 2: getterm("term/vc1", "/app/bdsh", false); 349 case 1: getterm("term/vc0", "/app/bdsh", true); 350 } 384 srv_start("/srv/hound"); 385 srv_start("/srv/input", HID_INPUT); 386 srv_start("/srv/output", HID_OUTPUT); 387 388 int rc = compositor(HID_INPUT, HID_COMPOSITOR_SERVER); 389 if (rc == EOK) { 390 gui_start("/app/vlaunch", HID_COMPOSITOR_SERVER); 391 gui_start("/app/vterm", HID_COMPOSITOR_SERVER); 392 } else { 393 rc = console(HID_INPUT, HID_OUTPUT); 394 if (rc == EOK) { 395 switch((unsigned)CONFIG_VC_COUNT) { 396 default: 397 case 6: getterm("term/vc5", "/app/bdsh", false); 398 case 5: getterm("term/vc4", "/app/bdsh", false); 399 case 4: getterm("term/vc3", "/app/bdsh", false); 400 case 3: getterm("term/vc2", "/app/bdsh", false); 401 case 2: getterm("term/vc1", "/app/bdsh", false); 402 case 1: getterm("term/vc0", "/app/bdsh", true); 403 } 351 404 #ifdef CONFIG_KERNEL_LOG_VC_6 352 getterm("term/vc6", "/app/klog", false);405 getterm("term/vc6", "/app/klog", false); 353 406 #endif 407 } 408 } 354 409 355 410 return 0; -
uspace/app/klog/Makefile
rb5d2e57 r03362fbd 29 29 30 30 USPACE_PREFIX = ../.. 31 LIBS = $(LIBCLUI_PREFIX)/libclui.a 32 EXTRA_CFLAGS = -I$(LIBCLUI_PREFIX) 31 33 BINARY = klog 32 34 -
uspace/app/klog/klog.c
rb5d2e57 r03362fbd 48 48 #include <adt/list.h> 49 49 #include <adt/prodcons.h> 50 #include <tinput.h> 50 51 51 52 #define NAME "klog" … … 228 229 } 229 230 231 tinput_t *input = tinput_new(); 232 if (!input) { 233 fprintf(stderr, "%s: Could not create input\n", NAME); 234 return ENOMEM; 235 } 236 230 237 fibril_add_ready(fid); 231 238 event_unmask(EVENT_KLOG); 232 239 klog_update(); 233 240 234 task_retval(0); 235 async_manager(); 236 237 return 0; 241 tinput_set_prompt(input, "klog> "); 242 243 char *str; 244 while ((rc = tinput_read(input, &str)) == EOK) { 245 if (str_cmp(str, "") == 0) { 246 free(str); 247 continue; 248 } 249 250 klog_command(str, str_size(str)); 251 free(str); 252 } 253 254 if (rc == ENOENT) 255 rc = EOK; 256 257 return EOK; 238 258 } 239 259 -
uspace/app/logset/Makefile
rb5d2e57 r03362fbd 1 1 # 2 # Copyright (c) 201 1Vojtech Horky2 # Copyright (c) 2012 Vojtech Horky 3 3 # All rights reserved. 4 4 # … … 28 28 29 29 USPACE_PREFIX = ../.. 30 BINARY = lsusb 31 32 LIBS = \ 33 $(LIBUSBDEV_PREFIX)/libusbdev.a \ 34 $(LIBUSB_PREFIX)/libusb.a \ 35 $(LIBDRV_PREFIX)/libdrv.a 36 EXTRA_CFLAGS = \ 37 -I$(LIBUSB_PREFIX)/include \ 38 -I$(LIBUSBDEV_PREFIX)/include \ 39 -I$(LIBDRV_PREFIX)/include 30 BINARY = logset 40 31 41 32 SOURCES = \ -
uspace/app/mkbd/main.c
rb5d2e57 r03362fbd 40 40 #include <errno.h> 41 41 #include <str_error.h> 42 #include < bool.h>42 #include <stdbool.h> 43 43 #include <getopt.h> 44 44 #include <devman.h> -
uspace/app/mkexfat/exfat.h
rb5d2e57 r03362fbd 34 34 #include <sys/types.h> 35 35 #include <stdint.h> 36 #include < bool.h>36 #include <stdbool.h> 37 37 38 38 #define EXFAT_FILENAME_LEN 255 -
uspace/app/mkexfat/mkexfat.c
rb5d2e57 r03362fbd 38 38 39 39 #include <stdio.h> 40 #include < libblock.h>40 #include <block.h> 41 41 #include <assert.h> 42 42 #include <errno.h> … … 46 46 #include <sys/types.h> 47 47 #include <sys/typefmt.h> 48 #include < bool.h>48 #include <stdbool.h> 49 49 #include <str.h> 50 50 #include <getopt.h> 51 #include <macros.h> 51 52 #include "exfat.h" 52 53 #include "upcase.h" … … 87 88 #define FIRST_FREE_CLUSTER 2 88 89 89 #define min(x, y) ((x) < (y) ? (x) : (y))90 90 91 91 typedef struct exfat_cfg { -
uspace/app/mkfat/mkfat.c
rb5d2e57 r03362fbd 40 40 #include <stdio.h> 41 41 #include <stdlib.h> 42 #include < libblock.h>42 #include <block.h> 43 43 #include <mem.h> 44 44 #include <loc.h> -
uspace/app/mkmfs/mkmfs.c
rb5d2e57 r03362fbd 39 39 #include <stdio.h> 40 40 #include <stdlib.h> 41 #include < libblock.h>41 #include <block.h> 42 42 #include <unistd.h> 43 43 #include <errno.h> -
uspace/app/msim/arch_helenos/input.c
rb5d2e57 r03362fbd 32 32 /** @file HelenOS specific functions for MSIM simulator. 33 33 */ 34 35 /* Because of asprintf. */ 36 #define _GNU_SOURCE 34 37 #include "../../io/input.h" 35 38 #include "../../io/output.h" … … 38 41 #include <tinput.h> 39 42 #include <errno.h> 43 #include <stdlib.h> 40 44 41 45 static tinput_t *input_prompt; -
uspace/app/msim/arch_helenos/misc.c
rb5d2e57 r03362fbd 44 44 #include <ctype.h> 45 45 #include <stdio.h> 46 #include <stdlib.h> 46 47 47 48 /* Define when the dprinter device shall try to filter -
uspace/app/nettest2/nettest2.c
rb5d2e57 r03362fbd 45 45 #include <time.h> 46 46 #include <arg_parse.h> 47 #include < bool.h>47 #include <stdbool.h> 48 48 49 49 #include <net/in.h> -
uspace/app/nterm/conn.c
rb5d2e57 r03362fbd 33 33 */ 34 34 35 #include < bool.h>35 #include <stdbool.h> 36 36 #include <errno.h> 37 37 #include <fibril.h> -
uspace/app/nterm/nterm.c
rb5d2e57 r03362fbd 33 33 */ 34 34 35 #include < bool.h>35 #include <stdbool.h> 36 36 #include <errno.h> 37 37 #include <io/console.h> -
uspace/app/ping/ping.c
rb5d2e57 r03362fbd 34 34 35 35 #include <async.h> 36 #include < bool.h>36 #include <stdbool.h> 37 37 #include <errno.h> 38 38 #include <fibril_synch.h> -
uspace/app/sportdmp/sportdmp.c
rb5d2e57 r03362fbd 37 37 static void syntax_print(void) 38 38 { 39 fprintf(stderr, "Usage: sportdmp <baud> <device_service>\n");39 fprintf(stderr, "Usage: sportdmp [--baud=<baud>] [device_service]\n"); 40 40 } 41 41 42 42 int main(int argc, char **argv) 43 43 { 44 const char* svc_path = "devices/\\hw\\pci0\\00:01.0\\com1\\a";45 44 sysarg_t baud = 9600; 45 service_id_t svc_id; 46 46 47 if (argc > 1) { 47 int arg = 1; 48 int rc; 49 50 if (argc > arg && str_test_prefix(argv[arg], "--baud=")) { 51 size_t arg_offset = str_lsize(argv[arg], 7); 52 char* arg_str = argv[arg] + arg_offset; 53 if (str_length(arg_str) == 0) { 54 fprintf(stderr, "--baud requires an argument\n"); 55 syntax_print(); 56 return 1; 57 } 48 58 char *endptr; 49 baud = strtol(arg v[1], &endptr, 10);59 baud = strtol(arg_str, &endptr, 10); 50 60 if (*endptr != '\0') { 51 61 fprintf(stderr, "Invalid value for baud\n"); … … 53 63 return 1; 54 64 } 65 arg++; 55 66 } 56 67 57 if (argc > 2) { 58 svc_path = argv[2]; 68 if (argc > arg) { 69 rc = loc_service_get_id(argv[arg], &svc_id, 0); 70 if (rc != EOK) { 71 fprintf(stderr, "Cannot find device service %s\n", 72 argv[arg]); 73 return 1; 74 } 75 arg++; 76 } 77 else { 78 category_id_t serial_cat_id; 79 80 rc = loc_category_get_id("serial", &serial_cat_id, 0); 81 if (rc != EOK) { 82 fprintf(stderr, "Failed getting id of category " 83 "'serial'\n"); 84 return 1; 85 } 86 87 service_id_t *svc_ids; 88 size_t svc_count; 89 90 rc = loc_category_get_svcs(serial_cat_id, &svc_ids, &svc_count); if (rc != EOK) { 91 fprintf(stderr, "Failed getting list of services\n"); 92 return 1; 93 } 94 95 if (svc_count == 0) { 96 fprintf(stderr, "No service in category 'serial'\n"); 97 free(svc_ids); 98 return 1; 99 } 100 101 svc_id = svc_ids[0]; 102 free(svc_ids); 59 103 } 60 104 61 if (argc > 3) { 105 if (argc > arg) { 106 fprintf(stderr, "Too many arguments\n"); 62 107 syntax_print(); 63 108 return 1; 64 109 } 65 110 66 service_id_t svc_id;67 int rc = loc_service_get_id(svc_path, &svc_id, IPC_FLAG_BLOCKING);68 if (rc != EOK) {69 fprintf(stderr, "Cannot find device service %s\n", svc_path);70 return 1;71 }72 111 73 112 async_sess_t *sess = loc_service_connect(EXCHANGE_SERIALIZE, svc_id, 74 113 IPC_FLAG_BLOCKING); 75 114 if (!sess) { 76 fprintf(stderr, "Failed connecting to service %s\n", svc_path);115 fprintf(stderr, "Failed connecting to service\n"); 77 116 } 78 117 … … 101 140 ssize_t i; 102 141 for (i = 0; i < read; i++) { 103 if ((buf[i] >= 32) && (buf[i] < 128)) 104 putchar((wchar_t) buf[i]); 105 else 106 putchar('.'); 107 fflush(stdout); 142 printf("%02hhx ", buf[i]); 108 143 } 144 fflush(stdout); 109 145 } 110 146 -
uspace/app/stats/stats.c
rb5d2e57 r03362fbd 44 44 #include <malloc.h> 45 45 #include <inttypes.h> 46 #include < bool.h>46 #include <stdbool.h> 47 47 #include <str.h> 48 48 #include <arg_parse.h> -
uspace/app/taskdump/taskdump.c
rb5d2e57 r03362fbd 47 47 #include <macros.h> 48 48 #include <assert.h> 49 #include < bool.h>49 #include <stdbool.h> 50 50 51 51 #include <symtab.h> -
uspace/app/tester/Makefile
rb5d2e57 r03362fbd 29 29 30 30 USPACE_PREFIX = ../.. 31 LIBS = $(LIB EXT2_PREFIX)/libext2.a $(LIBBLOCK_PREFIX)/libblock.a32 EXTRA_CFLAGS = -I$(LIBBLOCK_PREFIX) -I$(LIB EXT2_PREFIX)31 LIBS = $(LIBBLOCK_PREFIX)/libblock.a $(LIBSOFTFLOAT_PREFIX)/libsoftfloat.a 32 EXTRA_CFLAGS = -I$(LIBBLOCK_PREFIX) -I$(LIBSOFTFLOAT_PREFIX) 33 33 BINARY = tester 34 34 … … 42 42 print/print4.c \ 43 43 print/print5.c \ 44 print/print6.c \ 44 45 console/console1.c \ 45 46 stdio/stdio1.c \ 46 47 stdio/stdio2.c \ 48 stdio/logger1.c \ 49 stdio/logger2.c \ 47 50 fault/fault1.c \ 48 51 fault/fault2.c \ 49 52 fault/fault3.c \ 53 float/float1.c \ 54 float/softfloat1.c \ 50 55 vfs/vfs1.c \ 51 56 ipc/ping_pong.c \ … … 58 63 mm/mapping1.c \ 59 64 hw/misc/virtchar1.c \ 60 hw/serial/serial1.c \ 61 libext2/libext2_1.c 65 hw/serial/serial1.c 62 66 63 67 include $(USPACE_PREFIX)/Makefile.common -
uspace/app/tester/mm/common.c
rb5d2e57 r03362fbd 343 343 344 344 area->addr = as_area_create(AS_AREA_ANY, size, 345 AS_AREA_WRITE | AS_AREA_READ );345 AS_AREA_WRITE | AS_AREA_READ | AS_AREA_CACHEABLE); 346 346 if (area->addr == AS_MAP_FAILED) { 347 347 free(area); -
uspace/app/tester/mm/common.h
rb5d2e57 r03362fbd 37 37 38 38 #include <sys/types.h> 39 #include < bool.h>39 #include <stdbool.h> 40 40 #include <adt/list.h> 41 41 -
uspace/app/tester/mm/mapping1.c
rb5d2e57 r03362fbd 43 43 44 44 void *result = as_area_create(AS_AREA_ANY, size, 45 AS_AREA_READ | AS_AREA_WRITE );45 AS_AREA_READ | AS_AREA_WRITE | AS_AREA_CACHEABLE); 46 46 if (result == AS_MAP_FAILED) 47 47 return NULL; -
uspace/app/tester/print/print5.def
rb5d2e57 r03362fbd 1 1 { 2 "print 1",3 " Stringprintf test",4 &test_print 1,2 "print5", 3 "Char printf test", 4 &test_print5, 5 5 true 6 6 }, -
uspace/app/tester/tester.c
rb5d2e57 r03362fbd 39 39 #include <stdio.h> 40 40 #include <str.h> 41 #include <io/log.h> 41 42 #include "tester.h" 42 43 … … 52 53 #include "print/print4.def" 53 54 #include "print/print5.def" 55 #include "print/print6.def" 54 56 #include "console/console1.def" 55 57 #include "stdio/stdio1.def" 56 58 #include "stdio/stdio2.def" 59 #include "stdio/logger1.def" 60 #include "stdio/logger2.def" 57 61 #include "fault/fault1.def" 58 62 #include "fault/fault2.def" 59 63 #include "fault/fault3.def" 64 #include "float/float1.def" 65 #include "float/softfloat1.def" 60 66 #include "vfs/vfs1.def" 61 67 #include "ipc/ping_pong.def" … … 68 74 #include "hw/serial/serial1.def" 69 75 #include "hw/misc/virtchar1.def" 70 #include "libext2/libext2_1.def"71 76 {NULL, NULL, NULL, false} 72 77 }; … … 138 143 } 139 144 145 log_init("tester"); 146 140 147 test_quiet = false; 141 148 test_argc = argc - 2; -
uspace/app/tester/tester.h
rb5d2e57 r03362fbd 37 37 38 38 #include <sys/types.h> 39 #include < bool.h>39 #include <stdbool.h> 40 40 #include <stacktrace.h> 41 41 … … 85 85 extern const char *test_print4(void); 86 86 extern const char *test_print5(void); 87 extern const char *test_print6(void); 87 88 extern const char *test_console1(void); 88 89 extern const char *test_stdio1(void); 89 90 extern const char *test_stdio2(void); 91 extern const char *test_logger1(void); 92 extern const char *test_logger2(void); 90 93 extern const char *test_fault1(void); 91 94 extern const char *test_fault2(void); 92 95 extern const char *test_fault3(void); 96 extern const char *test_float1(void); 97 extern const char *test_softfloat1(void); 93 98 extern const char *test_vfs1(void); 94 99 extern const char *test_ping_pong(void); … … 101 106 extern const char *test_serial1(void); 102 107 extern const char *test_virtchar1(void); 103 extern const char *test_libext2_1(void);104 108 extern const char *test_devman1(void); 105 109 extern const char *test_devman2(void); -
uspace/app/tetris/screen.c
rb5d2e57 r03362fbd 61 61 #include <vfs/vfs.h> 62 62 #include <async.h> 63 #include < bool.h>63 #include <stdbool.h> 64 64 #include <io/console.h> 65 65 #include <io/style.h> -
uspace/app/tetris/screen.h
rb5d2e57 r03362fbd 58 58 #include <io/console.h> 59 59 #include <async.h> 60 #include < bool.h>60 #include <stdbool.h> 61 61 62 62 typedef struct { -
uspace/app/top/screen.h
rb5d2e57 r03362fbd 36 36 37 37 #include <io/console.h> 38 #include <io/verify.h> 38 39 #include "top.h" 39 40 … … 43 44 extern void screen_done(void); 44 45 extern void print_data(data_t *); 45 extern void show_warning(const char *, ...); 46 extern void show_warning(const char *, ...) 47 PRINTF_ATTRIBUTE(1, 2); 46 48 47 49 extern int tgetchar(unsigned int); -
uspace/app/trace/ipcp.c
rb5d2e57 r03362fbd 38 38 #include <sys/typefmt.h> 39 39 #include <abi/ipc/methods.h> 40 #include <macros.h> 40 41 #include "ipc_desc.h" 41 42 #include "proto.h" … … 52 53 ipc_callid_t call_hash; 53 54 54 link_t link;55 ht_link_t link; 55 56 } pending_call_t; 56 57 … … 64 65 int have_conn[MAX_PHONE]; 65 66 66 #define PCALL_TABLE_CHAINS 32 67 hash_table_t pending_calls; 67 static hash_table_t pending_calls; 68 68 69 69 /* … … 73 73 proto_t *proto_unknown; /**< Protocol with no known methods. */ 74 74 75 static hash_index_t pending_call_hash(unsigned long key[]); 76 static int pending_call_compare(unsigned long key[], hash_count_t keys, 77 link_t *item); 78 static void pending_call_remove_callback(link_t *item); 79 80 hash_table_operations_t pending_call_ops = { 75 76 static size_t pending_call_key_hash(void *key) 77 { 78 ipc_callid_t *call_id = (ipc_callid_t *)key; 79 return *call_id; 80 } 81 82 static size_t pending_call_hash(const ht_link_t *item) 83 { 84 pending_call_t *hs = hash_table_get_inst(item, pending_call_t, link); 85 return hs->call_hash; 86 } 87 88 static bool pending_call_key_equal(void *key, const ht_link_t *item) 89 { 90 ipc_callid_t *call_id = (ipc_callid_t *)key; 91 pending_call_t *hs = hash_table_get_inst(item, pending_call_t, link); 92 93 return *call_id == hs->call_hash; 94 } 95 96 static hash_table_ops_t pending_call_ops = { 81 97 .hash = pending_call_hash, 82 .compare = pending_call_compare, 83 .remove_callback = pending_call_remove_callback 98 .key_hash = pending_call_key_hash, 99 .key_equal = pending_call_key_equal, 100 .equal = NULL, 101 .remove_callback = NULL 84 102 }; 85 86 87 static hash_index_t pending_call_hash(unsigned long key[])88 {89 // printf("pending_call_hash\n");90 return key[0] % PCALL_TABLE_CHAINS;91 }92 93 static int pending_call_compare(unsigned long key[], hash_count_t keys,94 link_t *item)95 {96 pending_call_t *hs;97 98 // printf("pending_call_compare\n");99 hs = hash_table_get_instance(item, pending_call_t, link);100 101 // FIXME: this will fail if sizeof(long) < sizeof(void *).102 return key[0] == hs->call_hash;103 }104 105 static void pending_call_remove_callback(link_t *item)106 {107 // printf("pending_call_remove_callback\n");108 }109 103 110 104 … … 177 171 } 178 172 179 hash_table_create(&pending_calls, PCALL_TABLE_CHAINS, 1, &pending_call_ops); 173 bool ok = hash_table_create(&pending_calls, 0, 0, &pending_call_ops); 174 assert(ok); 180 175 } 181 176 … … 190 185 pending_call_t *pcall; 191 186 proto_t *proto; 192 unsigned long key[1];193 187 oper_t *oper; 194 188 sysarg_t *args; … … 254 248 pcall->oper = oper; 255 249 256 key[0] = hash; 257 258 hash_table_insert(&pending_calls, key, &pcall->link); 250 hash_table_insert(&pending_calls, &pcall->link); 259 251 } 260 252 … … 334 326 void ipcp_call_in(ipc_call_t *call, ipc_callid_t hash) 335 327 { 336 link_t *item;328 ht_link_t *item; 337 329 pending_call_t *pcall; 338 unsigned long key[1];339 330 340 331 if ((hash & IPC_CALLID_ANSWERED) == 0 && hash != IPCP_CALLID_SYNC) { … … 347 338 348 339 hash = hash & ~IPC_CALLID_ANSWERED; 349 key[0] = hash; 350 351 item = hash_table_find(&pending_calls, key); 340 341 item = hash_table_find(&pending_calls, &hash); 352 342 if (item == NULL) 353 343 return; /* No matching question found */ … … 357 347 */ 358 348 359 pcall = hash_table_get_inst ance(item, pending_call_t, link);360 hash_table_remove(&pending_calls, key, 1);349 pcall = hash_table_get_inst(item, pending_call_t, link); 350 hash_table_remove(&pending_calls, &hash); 361 351 362 352 parse_answer(hash, pcall, call); -
uspace/app/trace/proto.c
rb5d2e57 r03362fbd 40 40 #include "proto.h" 41 41 42 #define SRV_PROTO_TABLE_CHAINS 32 43 #define METHOD_OPER_TABLE_CHAINS 32 44 45 hash_table_t srv_proto; 42 43 /* Maps service number to protocol */ 44 static hash_table_t srv_proto; 46 45 47 46 typedef struct { 48 unsignedsrv;47 int srv; 49 48 proto_t *proto; 50 link_t link;49 ht_link_t link; 51 50 } srv_proto_t; 52 51 53 52 typedef struct { 54 sysarg_t method;53 int method; 55 54 oper_t *oper; 56 link_t link;55 ht_link_t link; 57 56 } method_oper_t; 58 57 59 static hash_index_t srv_proto_hash(unsigned long key[]); 60 static int srv_proto_compare(unsigned long key[], hash_count_t keys, 61 link_t *item); 62 static void srv_proto_remove_callback(link_t *item); 63 64 hash_table_operations_t srv_proto_ops = { 58 /* Hash table operations. */ 59 60 static size_t srv_proto_key_hash(void *key) 61 { 62 return *(int *)key; 63 } 64 65 static size_t srv_proto_hash(const ht_link_t *item) 66 { 67 srv_proto_t *sp = hash_table_get_inst(item, srv_proto_t, link); 68 return sp->srv; 69 } 70 71 static bool srv_proto_key_equal(void *key, const ht_link_t *item) 72 { 73 srv_proto_t *sp = hash_table_get_inst(item, srv_proto_t, link); 74 return sp->srv == *(int *)key; 75 } 76 77 static hash_table_ops_t srv_proto_ops = { 65 78 .hash = srv_proto_hash, 66 .compare = srv_proto_compare, 67 .remove_callback = srv_proto_remove_callback 79 .key_hash = srv_proto_key_hash, 80 .key_equal = srv_proto_key_equal, 81 .equal = NULL, 82 .remove_callback = NULL 68 83 }; 69 84 70 static hash_index_t method_oper_hash(unsigned long key[]); 71 static int method_oper_compare(unsigned long key[], hash_count_t keys, 72 link_t *item); 73 static void method_oper_remove_callback(link_t *item); 74 75 hash_table_operations_t method_oper_ops = { 85 86 static size_t method_oper_key_hash(void *key) 87 { 88 return *(int *)key; 89 } 90 91 static size_t method_oper_hash(const ht_link_t *item) 92 { 93 method_oper_t *mo = hash_table_get_inst(item, method_oper_t, link); 94 return mo->method; 95 } 96 97 static bool method_oper_key_equal(void *key, const ht_link_t *item) 98 { 99 method_oper_t *mo = hash_table_get_inst(item, method_oper_t, link); 100 return mo->method == *(int *)key; 101 } 102 103 static hash_table_ops_t method_oper_ops = { 76 104 .hash = method_oper_hash, 77 .compare = method_oper_compare, 78 .remove_callback = method_oper_remove_callback 105 .key_hash = method_oper_key_hash, 106 .key_equal = method_oper_key_equal, 107 .equal = NULL, 108 .remove_callback = NULL 79 109 }; 80 110 81 static hash_index_t srv_proto_hash(unsigned long key[]) 82 { 83 return key[0] % SRV_PROTO_TABLE_CHAINS; 84 } 85 86 static int srv_proto_compare(unsigned long key[], hash_count_t keys, 87 link_t *item) 111 112 void proto_init(void) 113 { 114 /* todo: check return value. */ 115 bool ok = hash_table_create(&srv_proto, 0, 0, &srv_proto_ops); 116 assert(ok); 117 } 118 119 void proto_cleanup(void) 120 { 121 hash_table_destroy(&srv_proto); 122 } 123 124 void proto_register(int srv, proto_t *proto) 88 125 { 89 126 srv_proto_t *sp; 90 91 sp = hash_table_get_instance(item, srv_proto_t, link);92 93 return key[0] == sp->srv;94 }95 96 static void srv_proto_remove_callback(link_t *item)97 {98 }99 100 static hash_index_t method_oper_hash(unsigned long key[])101 {102 return key[0] % METHOD_OPER_TABLE_CHAINS;103 }104 105 static int method_oper_compare(unsigned long key[], hash_count_t keys,106 link_t *item)107 {108 method_oper_t *mo;109 110 mo = hash_table_get_instance(item, method_oper_t, link);111 112 return key[0] == mo->method;113 }114 115 static void method_oper_remove_callback(link_t *item)116 {117 }118 119 120 void proto_init(void)121 {122 hash_table_create(&srv_proto, SRV_PROTO_TABLE_CHAINS, 1,123 &srv_proto_ops);124 }125 126 void proto_cleanup(void)127 {128 hash_table_destroy(&srv_proto);129 }130 131 void proto_register(int srv, proto_t *proto)132 {133 srv_proto_t *sp;134 unsigned long key;135 127 136 128 sp = malloc(sizeof(srv_proto_t)); 137 129 sp->srv = srv; 138 130 sp->proto = proto; 139 key = srv; 140 141 hash_table_insert(&srv_proto, &key, &sp->link); 131 132 hash_table_insert(&srv_proto, &sp->link); 142 133 } 143 134 144 135 proto_t *proto_get_by_srv(int srv) 145 136 { 146 unsigned long key; 147 link_t *item; 148 srv_proto_t *sp; 149 150 key = srv; 151 item = hash_table_find(&srv_proto, &key); 137 ht_link_t *item = hash_table_find(&srv_proto, &srv); 152 138 if (item == NULL) return NULL; 153 139 154 s p = hash_table_get_instance(item, srv_proto_t, link);140 srv_proto_t *sp = hash_table_get_inst(item, srv_proto_t, link); 155 141 return sp->proto; 156 142 } … … 159 145 { 160 146 proto->name = name; 161 hash_table_create(&proto->method_oper, SRV_PROTO_TABLE_CHAINS, 1, 162 &method_oper_ops); 147 /* todo: check return value. */ 148 bool ok = hash_table_create(&proto->method_oper, 0, 0, &method_oper_ops); 149 assert(ok); 163 150 } 164 151 … … 181 168 { 182 169 method_oper_t *mo; 183 unsigned long key;184 170 185 171 mo = malloc(sizeof(method_oper_t)); 186 172 mo->method = method; 187 173 mo->oper = oper; 188 key = method; 189 190 hash_table_insert(&proto->method_oper, &key, &mo->link); 174 175 hash_table_insert(&proto->method_oper, &mo->link); 191 176 } 192 177 193 178 oper_t *proto_get_oper(proto_t *proto, int method) 194 179 { 195 unsigned long key; 196 link_t *item; 197 method_oper_t *mo; 198 199 key = method; 200 item = hash_table_find(&proto->method_oper, &key); 180 ht_link_t *item = hash_table_find(&proto->method_oper, &method); 201 181 if (item == NULL) return NULL; 202 182 203 m o = hash_table_get_instance(item, method_oper_t, link);183 method_oper_t *mo = hash_table_get_inst(item, method_oper_t, link); 204 184 return mo->oper; 205 185 } -
uspace/app/trace/proto.h
rb5d2e57 r03362fbd 62 62 } proto_t; 63 63 64 /* Maps service number to protocol */65 extern hash_table_t srv_proto;66 64 67 65 extern void proto_init(void); -
uspace/app/trace/syscalls.c
rb5d2e57 r03362fbd 53 53 [SYS_AS_AREA_DESTROY] = { "as_area_destroy", 1, V_ERRNO }, 54 54 55 [SYS_IPC_CALL_SYNC_FAST] = { "ipc_call_sync_fast", 6, V_ERRNO },56 [SYS_IPC_CALL_SYNC_SLOW] = { "ipc_call_sync_slow", 3, V_ERRNO },57 55 [SYS_IPC_CALL_ASYNC_FAST] = { "ipc_call_async_fast", 6, V_HASH }, 58 56 [SYS_IPC_CALL_ASYNC_SLOW] = { "ipc_call_async_slow", 2, V_HASH }, -
uspace/app/trace/trace.c
rb5d2e57 r03362fbd 43 43 #include <mem.h> 44 44 #include <str.h> 45 #include < bool.h>45 #include <stdbool.h> 46 46 #include <loader/loader.h> 47 47 #include <io/console.h> … … 318 318 } 319 319 320 static void sc_ipc_call_sync_fast(sysarg_t *sc_args)321 {322 ipc_call_t question, reply;323 int rc;324 int phoneid;325 326 phoneid = sc_args[0];327 328 IPC_SET_IMETHOD(question, sc_args[1]);329 IPC_SET_ARG1(question, sc_args[2]);330 IPC_SET_ARG2(question, sc_args[3]);331 IPC_SET_ARG3(question, sc_args[4]);332 IPC_SET_ARG4(question, 0);333 IPC_SET_ARG5(question, 0);334 335 memset(&reply, 0, sizeof(reply));336 rc = udebug_mem_read(sess, &reply.args, sc_args[5], sizeof(reply.args));337 if (rc < 0)338 return;339 340 ipcp_call_sync(phoneid, &question, &reply);341 }342 343 static void sc_ipc_call_sync_slow_b(unsigned thread_id, sysarg_t *sc_args)344 {345 ipc_call_t question;346 int rc;347 348 memset(&question, 0, sizeof(question));349 rc = udebug_mem_read(sess, &question.args, sc_args[1],350 sizeof(question.args));351 352 if (rc < 0) {353 printf("Error: mem_read->%d\n", rc);354 return;355 }356 357 thread_ipc_req[thread_id] = question;358 }359 360 static void sc_ipc_call_sync_slow_e(unsigned thread_id, sysarg_t *sc_args)361 {362 ipc_call_t reply;363 int rc;364 365 memset(&reply, 0, sizeof(reply));366 rc = udebug_mem_read(sess, &reply.args, sc_args[2],367 sizeof(reply.args));368 369 if (rc < 0) {370 printf("Error: mem_read->%d\n", rc);371 return;372 }373 374 ipcp_call_sync(sc_args[0], &thread_ipc_req[thread_id], &reply);375 }376 377 320 static void sc_ipc_wait(sysarg_t *sc_args, int sc_rc) 378 321 { … … 408 351 print_sc_args(sc_args, syscall_desc[sc_id].n_args); 409 352 } 410 411 switch (sc_id) {412 case SYS_IPC_CALL_SYNC_SLOW:413 sc_ipc_call_sync_slow_b(thread_id, sc_args);414 break;415 default:416 break;417 }418 353 } 419 354 … … 447 382 case SYS_IPC_CALL_ASYNC_SLOW: 448 383 sc_ipc_call_async_slow(sc_args, sc_rc); 449 break;450 case SYS_IPC_CALL_SYNC_FAST:451 sc_ipc_call_sync_fast(sc_args);452 break;453 case SYS_IPC_CALL_SYNC_SLOW:454 sc_ipc_call_sync_slow_e(thread_id, sc_args);455 384 break; 456 385 case SYS_IPC_WAIT: -
uspace/app/usbinfo/Makefile
rb5d2e57 r03362fbd 47 47 hid.c \ 48 48 info.c \ 49 list.c \ 49 50 main.c 50 51 -
uspace/app/usbinfo/desctree.c
rb5d2e57 r03362fbd 39 39 #include <errno.h> 40 40 #include <str_error.h> 41 #include < bool.h>41 #include <stdbool.h> 42 42 43 43 #include <usb/usb.h> -
uspace/app/usbinfo/dump.c
rb5d2e57 r03362fbd 39 39 #include <errno.h> 40 40 #include <str_error.h> 41 #include < bool.h>41 #include <stdbool.h> 42 42 43 43 #include <usb/usb.h> -
uspace/app/usbinfo/list.c
rb5d2e57 r03362fbd 40 40 #include <errno.h> 41 41 #include <str_error.h> 42 #include < bool.h>42 #include <stdbool.h> 43 43 #include <getopt.h> 44 44 #include <devman.h> … … 47 47 #include <usb/hc.h> 48 48 49 # define NAME "lsusb"49 #include "usbinfo.h" 50 50 51 51 #define MAX_USB_ADDRESS USB11_ADDRESS_MAX … … 90 90 } 91 91 92 int main(int argc, char *argv[])92 void list(void) 93 93 { 94 94 category_id_t usbhc_cat; … … 102 102 printf(NAME ": Error resolving category '%s'", 103 103 USB_HC_CATEGORY); 104 return 1;104 return; 105 105 } 106 106 … … 108 108 if (rc != EOK) { 109 109 printf(NAME ": Error getting list of host controllers.\n"); 110 return 1;110 return; 111 111 } 112 112 … … 131 131 132 132 free(svcs); 133 134 return 0;135 133 } 136 134 -
uspace/app/usbinfo/main.c
rb5d2e57 r03362fbd 39 39 #include <errno.h> 40 40 #include <str_error.h> 41 #include < bool.h>41 #include <stdbool.h> 42 42 #include <getopt.h> 43 43 #include <devman.h> … … 62 62 63 63 _OPTION("-h --help", "Print this help and exit."); 64 _OPTION("-l --list", "Print a list of host controllers and devices."); 64 65 _OPTION("-i --identification", "Brief device identification."); 65 66 _OPTION("-m --match-ids", "Print match ids generated for the device."); … … 82 83 {"help", no_argument, NULL, 'h'}, 83 84 {"identification", no_argument, NULL, 'i'}, 85 {"list", no_argument, NULL, 'l'}, 84 86 {"match-ids", no_argument, NULL, 'm'}, 85 87 {"descriptor-tree", no_argument, NULL, 't'}, … … 91 93 {0, 0, NULL, 0} 92 94 }; 93 static const char *short_options = "hi mtTsSrR";95 static const char *short_options = "hilmtTsSrR"; 94 96 95 97 static usbinfo_action_t actions[] = { … … 146 148 } 147 149 150 bool something_active = false; 148 151 /* 149 152 * Process command-line options. They determine what shall be … … 156 159 switch (opt) { 157 160 case -1: 161 break; 162 case 'l': 163 list(); 158 164 break; 159 165 case '?': … … 168 174 if (actions[idx].opt == opt) { 169 175 actions[idx].active = true; 176 something_active = true; 170 177 break; 171 178 } … … 178 185 179 186 /* Set the default action. */ 180 int idx = 0;181 bool something_active = false;182 while (actions[idx].opt != 0) {183 if (actions[idx].active) {184 something_active = true;185 break;186 }187 idx++;188 }189 187 if (!something_active) { 190 188 actions[0].active = true; -
uspace/app/usbinfo/usbinfo.h
rb5d2e57 r03362fbd 79 79 dump_descriptor_in_tree_t, size_t, void *); 80 80 81 void list(void); 81 82 82 83 void dump_short_device_identification(usbinfo_device_t *); -
uspace/app/vuhid/main.c
rb5d2e57 r03362fbd 155 155 int rc; 156 156 157 usb_log_enable(USB_LOG_LEVEL_DEBUG2, "vusbhid");157 log_init("vuhid"); 158 158 159 159 fibril_mutex_initialize(&vuhid_data.iface_count_mutex); -
uspace/app/websrv/websrv.c
rb5d2e57 r03362fbd 34 34 */ 35 35 36 #include < bool.h>36 #include <stdbool.h> 37 37 #include <errno.h> 38 38 #include <assert.h>
Note:
See TracChangeset
for help on using the changeset viewer.
