Changeset 7c3fb9b in mainline for uspace/app/bdsh/cmds
- Timestamp:
- 2018-05-17T08:29:01Z (6 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 6ff23ff
- Parents:
- fac0ac7
- git-author:
- Jiri Svoboda <jiri@…> (2018-05-16 17:28:17)
- git-committer:
- Jiri Svoboda <jiri@…> (2018-05-17 08:29:01)
- Location:
- uspace/app/bdsh/cmds
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/bdsh/cmds/builtin_cmds.c
rfac0ac7 r7c3fb9b 27 27 */ 28 28 29 /* Almost identical (for now) to mod_cmds.c , however this will not be the case 30 * soon as builtin_t is going to grow way beyond module_t */ 29 /* 30 * Almost identical (for now) to mod_cmds.c, however this will not be the case 31 * soon as builtin_t is going to grow way beyond module_t 32 */ 31 33 32 34 #include <stdio.h> -
uspace/app/bdsh/cmds/builtins/batch/batch.c
rfac0ac7 r7c3fb9b 66 66 } 67 67 68 /* Main entry point for batch, accepts an array of arguments and a 69 * pointer to the cliuser_t structure */ 68 /** Main entry point for batch, accepts an array of arguments and a 69 * pointer to the cliuser_t structure 70 */ 70 71 int cmd_batch(char **argv, cliuser_t *usr) 71 72 { -
uspace/app/bdsh/cmds/builtins/cd/cd.c
rfac0ac7 r7c3fb9b 41 41 static const char *cmdname = "cd"; 42 42 43 /* Previous directory variables. 43 /* 44 * Previous directory variables. 44 45 * 45 46 * Declaring them static to avoid many "== NULL" checks. … … 101 102 } 102 103 103 /* We don't yet play nice with whitespace, a getopt implementation should 104 /* 105 * We don't yet play nice with whitespace, a getopt implementation should 104 106 * protect "quoted\ destination" as a single argument. Its not our job to 105 107 * look for && || or redirection as the tokenizer should have done that 106 * (currently, it does not) */ 108 * (currently, it does not) 109 */ 107 110 108 111 if (argc > 2) { -
uspace/app/bdsh/cmds/builtins/exit/exit.c
rfac0ac7 r7c3fb9b 44 44 } 45 45 46 /* Quits the program and returns the status of whatever command 47 * came before invoking 'quit' */ 46 /** Quits the program and returns the status of whatever command 47 * came before invoking 'quit' 48 */ 48 49 int cmd_exit(char *argv[], cliuser_t *usr) 49 50 { -
uspace/app/bdsh/cmds/cmds.h
rfac0ac7 r7c3fb9b 76 76 } builtin_t; 77 77 78 /* Declared in cmds/modules/modules.h and cmds/builtins/builtins.h 79 * respectively */ 78 /* 79 * Declared in cmds/modules/modules.h and cmds/builtins/builtins.h 80 * respectively 81 */ 80 82 extern module_t modules[]; 81 83 extern builtin_t builtins[]; -
uspace/app/bdsh/cmds/mod_cmds.c
rfac0ac7 r7c3fb9b 27 27 */ 28 28 29 /* NOTES: 29 /* 30 * NOTES: 30 31 * module_* functions are pretty much identical to builtin_* functions at this 31 32 * point. On the surface, it would appear that making each function dual purpose … … 37 38 * 38 39 * To keep things easy to hack, everything is separated. In reality this only adds 39 * 6 - 8 extra functions, but keeps each function very easy to read and modify. */ 40 * 6 - 8 extra functions, but keeps each function very easy to read and modify. 41 */ 40 42 41 /* TODO: 43 /* 44 * TODO: 42 45 * Many of these could be unsigned, provided the modules and builtins themselves 43 * can follow suit. Long term goal. */ 46 * can follow suit. Long term goal. 47 */ 44 48 45 49 #include <stdio.h> … … 53 57 extern volatile unsigned int cli_interactive; 54 58 55 /* Checks if an entry function matching command exists in modules[], if so 56 * its position in the array is returned */ 59 /** Checks if an entry function matching command exists in modules[] 60 * 61 * If so, its position in the array is returned 62 */ 57 63 int is_module(const char *command) 58 64 { … … 71 77 } 72 78 73 /* Checks if a module is an alias (sharing an entry point with another 74 * module). Returns 1 if so */ 79 /* 80 * Checks if a module is an alias (sharing an entry point with another 81 * module). Returns 1 if so 82 */ 75 83 int is_module_alias(const char *command) 76 84 { … … 105 113 106 114 107 /* Invokes the 'help' entry function for the module at position (int) module, 108 * which wants an unsigned int to determine brief or extended display. */ 115 /** Invokes the 'help' entry function for the module at position (int) module 116 * 117 * which wants an unsigned int to determine brief or extended display. 118 */ 109 119 int help_module(int module, unsigned int extended) 110 120 { … … 121 131 } 122 132 123 /* Invokes the module entry point modules[module], passing argv[] as an argument 124 * stack. */ 133 /** Invokes the module entry point modules[module] 134 * 135 * passing argv[] as an argument stack. 136 */ 125 137 int run_module(int module, char *argv[], iostate_t *new_iostate) 126 138 { -
uspace/app/bdsh/cmds/modules/cat/cat.c
rfac0ac7 r7c3fb9b 274 274 break; 275 275 } else if (c == U_SPECIAL && offset + 2 >= (size_t)bytes) { 276 /* If an extended character is cut off due to the size of the buffer, 277 we will copy it over to the next buffer so it can be read correctly. */ 276 /* 277 * If an extended character is cut off due to the size of the buffer, 278 * we will copy it over to the next buffer so it can be read correctly. 279 */ 278 280 copied_bytes = bytes - offset + 1; 279 281 memcpy(buff, buff + offset - 1, copied_bytes); -
uspace/app/bdsh/cmds/modules/cp/cp.c
rfac0ac7 r7c3fb9b 207 207 /* e.g. cp file_name /data/ */ 208 208 209 /* dest is a directory, 209 /* 210 * dest is a directory, 210 211 * append the src filename to it. 211 212 */ … … 231 232 /* e.g. cp file_name existing_file */ 232 233 233 /* dest already exists, 234 /* 235 * dest already exists, 234 236 * if force is set we will try to remove it. 235 237 * if interactive is set user input is required. … … 298 300 if (str_cmp(src_dirname, "..") && 299 301 str_cmp(src_dirname, ".")) { 300 /* The last component of src_path is 302 /* 303 * The last component of src_path is 301 304 * not '.' or '..' 302 305 */ … … 314 317 default: 315 318 case TYPE_NONE: 316 /* dest does not exists, this means the user wants 319 /* 320 * dest does not exists, this means the user wants 317 321 * to specify the name of the destination directory 318 322 * … … 336 340 } 337 341 338 /* Copy every single directory entry of src into the 342 /* 343 * Copy every single directory entry of src into the 339 344 * destination directory. 340 345 */ -
uspace/app/bdsh/cmds/modules/ls/ls.c
rfac0ac7 r7c3fb9b 27 27 */ 28 28 29 /* NOTE: 29 /* 30 * NOTE: 30 31 * This is a bit of an ugly hack, working around the absence of fstat / etc. 31 * As more stuff is completed and exposed in libc, this will improve */ 32 * As more stuff is completed and exposed in libc, this will improve 33 */ 32 34 33 35 #include <errno.h> -
uspace/app/bdsh/cmds/modules/module_aliases.h
rfac0ac7 r7c3fb9b 30 30 #define MODULE_ALIASES_H 31 31 32 /* Modules that declare multiple names for themselves but use the 32 /* 33 * Modules that declare multiple names for themselves but use the 33 34 * same entry functions are aliases. This array helps to determine if 34 35 * a module is an alias, as such it can be invoked differently. 35 * format is alias , real_name */ 36 * format is alias , real_name 37 */ 36 38 37 /* So far, this is only used in the help display but could be used to 39 /* 40 * So far, this is only used in the help display but could be used to 38 41 * handle a module differently even prior to reaching its entry code. 39 42 * For instance, 'exit' could behave differently than 'quit', prior to 40 * the entry point being reached. */ 43 * the entry point being reached. 44 */ 41 45 42 46 const char *mod_aliases[] = { -
uspace/app/bdsh/cmds/modules/modules.h
rfac0ac7 r7c3fb9b 30 30 #define MODULES_H 31 31 32 /* Each built in function has two files, one being an entry.h file which 32 /* 33 * Each built in function has two files, one being an entry.h file which 33 34 * prototypes the run/help entry functions, the other being a .def file 34 35 * which fills the modules[] array according to the cmd_t structure … … 40 41 * 41 42 * NOTE: See module_ aliases.h as well, this is where aliases (commands that 42 * share an entry point with others) are indexed */ 43 * share an entry point with others) are indexed 44 */ 43 45 44 46 #include "config.h" … … 64 66 #include "cmp/entry.h" 65 67 66 /* Each .def function fills the module_t struct with the individual name, entry 68 /* 69 * Each .def function fills the module_t struct with the individual name, entry 67 70 * point, help entry point, etc. You can use config.h to control what modules 68 * are loaded based on what libraries exist on the system. */ 71 * are loaded based on what libraries exist on the system. 72 */ 69 73 70 74 module_t modules[] = { -
uspace/app/bdsh/cmds/modules/rm/rm.c
rfac0ac7 r7c3fb9b 95 95 rm->safe = 0; 96 96 97 /* Make sure we can allocate enough memory to store 98 * what is needed in the job structure */ 97 /* 98 * Make sure we can allocate enough memory to store 99 * what is needed in the job structure 100 */ 99 101 if (NULL == (rm->nwd = (char *) malloc(PATH_MAX))) 100 102 return 0;
Note:
See TracChangeset
for help on using the changeset viewer.