Changeset 68b5dd11 in mainline
- Timestamp:
- 2015-10-20T10:08:15Z (9 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- b598460a
- Parents:
- 44fe800
- Location:
- uspace
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/fdisk/fdisk.c
r44fe800 r68b5dd11 137 137 scap = NULL; 138 138 139 rc = nchoice_add(choice, dtext, info );139 rc = nchoice_add(choice, dtext, info, 0); 140 140 if (rc != EOK) { 141 141 assert(rc == ENOMEM); … … 156 156 } 157 157 158 rc = nchoice_add(choice, "Exit", NULL );158 rc = nchoice_add(choice, "Exit", NULL, 0); 159 159 if (rc != EOK) { 160 160 assert(rc == ENOMEM); … … 219 219 goto error; 220 220 221 rc = nchoice_add(choice, sltype, (void *)(uintptr_t)i); 221 rc = nchoice_add(choice, sltype, (void *)(uintptr_t)i, 222 i == LT_DEFAULT); 222 223 if (rc != EOK) { 223 224 assert(rc == ENOMEM); … … 304 305 goto error; 305 306 306 rc = nchoice_add(choice, sfstype, (void *)(uintptr_t)i); 307 rc = nchoice_add(choice, sfstype, (void *)(uintptr_t)i, 308 i == VOL_FSTYPE_DEFAULT); 307 309 if (rc != EOK) { 308 310 assert(rc == ENOMEM); … … 439 441 } 440 442 441 rc = nchoice_add(choice, sdesc, (void *)part );443 rc = nchoice_add(choice, sdesc, (void *)part, 0); 442 444 if (rc != EOK) { 443 445 assert(rc == ENOMEM); … … 634 636 rc = nchoice_add(choice, "Create primary " 635 637 "partition", 636 (void *)devac_create_pri_part );638 (void *)devac_create_pri_part, 0); 637 639 if (rc != EOK) { 638 640 assert(rc == ENOMEM); … … 645 647 rc = nchoice_add(choice, "Create extended " 646 648 "partition", 647 (void *)devac_create_ext_part );649 (void *)devac_create_ext_part, 0); 648 650 if (rc != EOK) { 649 651 assert(rc == ENOMEM); … … 656 658 rc = nchoice_add(choice, "Create logical " 657 659 "partition", 658 (void *)devac_create_log_part );660 (void *)devac_create_log_part, 0); 659 661 if (rc != EOK) { 660 662 assert(rc == ENOMEM); … … 666 668 if ((linfo.flags & lf_can_create_pri) != 0) { 667 669 rc = nchoice_add(choice, "Create partition", 668 (void *)devac_create_pri_part );670 (void *)devac_create_pri_part, 0); 669 671 if (rc != EOK) { 670 672 assert(rc == ENOMEM); … … 677 679 if ((linfo.flags & lf_can_delete_part) != 0) { 678 680 rc = nchoice_add(choice, "Delete partition", 679 (void *)devac_delete_part );681 (void *)devac_delete_part, 0); 680 682 if (rc != EOK) { 681 683 assert(rc == ENOMEM); … … 687 689 if ((dflags & fdf_can_create_label) != 0) { 688 690 rc = nchoice_add(choice, "Create label", 689 (void *)devac_create_label );691 (void *)devac_create_label, 0); 690 692 if (rc != EOK) { 691 693 assert(rc == ENOMEM); … … 697 699 if ((dflags & fdf_can_delete_label) != 0) { 698 700 rc = nchoice_add(choice, "Delete label", 699 (void *)devac_delete_label );701 (void *)devac_delete_label, 0); 700 702 if (rc != EOK) { 701 703 assert(rc == ENOMEM); … … 707 709 if ((dflags & fdf_can_erase_dev) != 0) { 708 710 rc = nchoice_add(choice, "Erase disk", 709 (void *)devac_erase_disk );710 if (rc != EOK) { 711 assert(rc == ENOMEM); 712 printf("Out of memory.\n"); 713 goto error; 714 } 715 } 716 717 rc = nchoice_add(choice, "Exit", (void *)devac_exit );711 (void *)devac_erase_disk, 0); 712 if (rc != EOK) { 713 assert(rc == ENOMEM); 714 printf("Out of memory.\n"); 715 goto error; 716 } 717 } 718 719 rc = nchoice_add(choice, "Exit", (void *)devac_exit, 0); 718 720 if (rc != EOK) { 719 721 assert(rc == ENOMEM); -
uspace/lib/c/include/types/label.h
r44fe800 r68b5dd11 58 58 } label_type_t; 59 59 60 #define LT_FIRST (lt_mbr)60 #define LT_FIRST lt_mbr 61 61 #define LT_LIMIT (lt_gpt + 1) 62 63 #define LT_DEFAULT lt_mbr 62 64 63 65 /** Partition kind */ -
uspace/lib/c/include/types/vol.h
r44fe800 r68b5dd11 56 56 57 57 #define VOL_FSTYPE_LIMIT (fs_ext4 + 1) 58 #define VOL_FSTYPE_DEFAULT fs_minix 58 59 59 60 /** Volume service */ -
uspace/lib/clui/nchoice.c
r44fe800 r68b5dd11 35 35 #include <errno.h> 36 36 #include <nchoice.h> 37 #include <stdio.h> 37 38 #include <stdlib.h> 38 39 #include <str.h> … … 94 95 } 95 96 96 #include <stdio.h>97 97 /** Add option to numerical choice */ 98 int nchoice_add(nchoice_t *choice, const char *opttext, void *arg) 98 int nchoice_add(nchoice_t *choice, const char *opttext, void *arg, 99 nchoice_flag_t flags) 99 100 { 100 101 nchoice_opt_t *opt; … … 114 115 opt->arg = arg; 115 116 list_append(&opt->lchoice, &choice->opts); 117 118 if ((flags & ncf_default) != 0) { 119 /* Set this option as the default */ 120 assert(choice->def_opt == NULL); 121 122 choice->def_opt = opt; 123 } 124 116 125 return EOK; 117 126 } … … 125 134 unsigned long c; 126 135 char *eptr; 136 char *istr; 137 int def_i; 127 138 128 139 again: 129 140 printf("%s\n", choice->prompt); 130 141 142 def_i = 0; 131 143 i = 1; 132 144 list_foreach(choice->opts, lchoice, nchoice_opt_t, opt) { 133 printf("%d: %s\n", i, opt->text); 145 printf("%d: %s%s\n", i, opt->text, opt == choice->def_opt ? 146 " [default]" : ""); 147 if (opt == choice->def_opt) 148 def_i = i; 134 149 ++i; 135 150 } 136 151 137 rc = tinput_read(choice->tinput, &str); 152 if (def_i > 0) { 153 rc = asprintf(&istr, "%d", def_i); 154 if (rc < 0) 155 return ENOMEM; 156 } else { 157 istr = str_dup(""); 158 if (istr == NULL) 159 return ENOMEM; 160 } 161 162 rc = tinput_read_i(choice->tinput, istr, &str); 163 free(istr); 164 138 165 if (rc != EOK) { 139 166 assert(rc == EIO || rc == ENOENT); -
uspace/lib/clui/nchoice.h
r44fe800 r68b5dd11 40 40 #include <tinput.h> 41 41 42 typedef enum { 43 /** This is the default option */ 44 ncf_default = 1 45 } nchoice_flag_t; 46 42 47 typedef struct { 43 48 /** Link to nchoice_t.opts */ … … 56 61 /** Text input */ 57 62 tinput_t *tinput; 63 /** Default option */ 64 nchoice_opt_t *def_opt; 58 65 } nchoice_t; 59 66 … … 61 68 extern void nchoice_destroy(nchoice_t *); 62 69 extern int nchoice_set_prompt(nchoice_t *, const char *); 63 extern int nchoice_add(nchoice_t *, const char *, void * );70 extern int nchoice_add(nchoice_t *, const char *, void *, nchoice_flag_t); 64 71 extern int nchoice_get(nchoice_t *, void **); 65 72 -
uspace/lib/clui/tinput.c
r44fe800 r68b5dd11 457 457 } 458 458 459 static void tinput_set_str(tinput_t *ti, c har *str)459 static void tinput_set_str(tinput_t *ti, const char *str) 460 460 { 461 461 str_to_wstr(ti->buffer, INPUT_MAX_SIZE, str); … … 853 853 } 854 854 855 /** Read in one line of input. 856 * 857 * @param ti Text input. 858 * @param dstr Place to save pointer to new string. 855 /** Read in one line of input with initial text provided. 856 * 857 * @param ti Text input 858 * @param istr Initial string 859 * @param dstr Place to save pointer to new string 859 860 * 860 861 * @return EOK on success … … 863 864 * 864 865 */ 865 int tinput_read (tinput_t *ti, char **dstr)866 int tinput_read_i(tinput_t *ti, const char *istr, char **dstr) 866 867 { 867 868 console_flush(ti->console); … … 869 870 return EIO; 870 871 871 ti->pos = 0; 872 tinput_set_str(ti, istr); 873 872 874 ti->sel_start = 0; 873 ti->nc = 0;874 ti->buffer[0] = '\0';875 875 ti->done = false; 876 876 ti->exit_clui = false; … … 916 916 } 917 917 918 /** Read in one line of input. 919 * 920 * @param ti Text input 921 * @param dstr Place to save pointer to new string. 922 * 923 * @return EOK on success 924 * @return ENOENT if user requested abort 925 * @return EIO if communication with console failed 926 * 927 */ 928 int tinput_read(tinput_t *ti, char **dstr) 929 { 930 return tinput_read_i(ti, "", dstr); 931 } 932 918 933 static void tinput_key_ctrl(tinput_t *ti, kbd_event_t *ev) 919 934 { -
uspace/lib/clui/tinput.h
r44fe800 r68b5dd11 159 159 extern void tinput_destroy(tinput_t *); 160 160 extern int tinput_read(tinput_t *, char **); 161 extern int tinput_read_i(tinput_t *, const char *, char **); 161 162 162 163 #endif
Note:
See TracChangeset
for help on using the changeset viewer.