Changeset 229d114e in mainline
- Timestamp:
- 2018-11-30T04:42:42Z (6 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 598e3a7
- Parents:
- 55e35a22
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/bdsh/cmds/modules/alias/alias.c
r55e35a22 r229d114e 38 38 39 39 40 static intprint_alias(const char* name)40 static bool print_alias(const char* name) 41 41 { 42 42 odlink_t *alias_link = odict_find_eq(&alias_dict, (void*)name, NULL); … … 44 44 alias_t* data = odict_get_instance(alias_link, alias_t, odict); 45 45 printf(alias_format, data->name, data->value); 46 return CMD_SUCCESS;46 return true; 47 47 } 48 48 … … 50 50 51 51 printf("%s: No alias with the name '%s' exists\n", cmdname, name); 52 return CMD_FAILURE;52 return false; 53 53 } 54 54 … … 98 98 list_aliases(); 99 99 return CMD_SUCCESS; 100 }else if (argv[2] == NULL && str_chr(argv[1], '=') == NULL) {101 return print_alias(argv[1]);102 100 } 103 104 //concat all it together 105 char* str = (char*)malloc(INPUT_MAX * sizeof(char)); 106 str[0] = '\0'; 101 107 102 108 103 size_t i; 109 104 for (i = 1; argv[i] != NULL; i++) { 110 str_append(str, INPUT_MAX - 1, argv[i]); 105 char* pos; 106 if ((pos = str_chr(argv[i], '=')) != NULL) { 107 argv[i][pos - argv[i]] = '\0'; 108 set_alias(argv[i], pos + 1); 109 }else { 110 if(!print_alias(argv[i])) { 111 return CMD_FAILURE; 112 } 113 } 111 114 } 112 113 //split input 114 char* pos = str_chr(str, '='); 115 if(pos == NULL) { 116 printf("%s: bad formatted input\n", cmdname); 117 return CMD_FAILURE; 118 } 119 120 121 str[pos - str] = '\0'; 122 set_alias(str, pos + 1); 123 124 free(str); 115 125 116 return CMD_SUCCESS; 126 117 }
Note:
See TracChangeset
for help on using the changeset viewer.