Changeset 6279151 in mainline for uspace/app/bdsh/README
- Timestamp:
- 2008-09-14T15:49:50Z (16 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 40cb3996
- Parents:
- 809813d
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/bdsh/README
r809813d r6279151 58 58 59 59 /* Types for module command entry and help */ 60 typedef int *(* mod_entry_t)(char **);61 typedef void *(* mod_help_t)(unsigned int);60 typedef int (* mod_entry_t)(char **); 61 typedef void (* mod_help_t)(unsigned int); 62 62 63 63 /* Built-in commands need to be able to modify cliuser_t */ 64 typedef int *(* builtin_entry_t)(char **, cliuser_t *);65 typedef void *(* builtin_help_t)(unsigned int);64 typedef int (* builtin_entry_t)(char **, cliuser_t *); 65 typedef void (* builtin_help_t)(unsigned int); 66 66 67 67 As you can see, both modular and builtin commands expect an array of … … 154 154 2: Change your "usage()" command as shown: 155 155 -- void usage(...) 156 ++ void * help_cmd_foo(unsigned int level) 157 -- return; 158 ++ retrn CMD_VOID; 156 ++ void help_cmd_foo(unsigned int level) 159 157 160 158 'level' is either 0 or 1, indicating the level of help requested. … … 164 162 3: Change the programs "main()" as shown: 165 163 -- int main(int argc, char **argv) 166 ++ int *cmd_foo(char **argv)164 ++ int cmd_foo(char **argv) 167 165 -- return 1; 168 166 ++ return CMD_FAILURE; … … 170 168 ++ return CMD_SUCCESS; 171 169 172 If main() returns an int that is not 1 or 0 (e.g. 127), cast it as173 such:174 175 -- return 127;176 ++ return (int *) 127;177 178 NOTE: _ONLY_ the main and help entry points need to return int * or179 void *, respectively. Also take note that argc has changed. The type180 for entry points may soon change.181 182 170 NOTE: If main is void, you'll need to change it and ensure that its 183 171 expecting an array of arguments, even if they'll never be read or … … 185 173 186 174 -- void main(void) 187 ++ int * cmd_foo(char **argv) 188 189 Similararly, do not try to return CMD_VOID within the modules main 190 entry point. If somehow you escape the compiler yelling at you, you 191 will surely see pretty blue and yellow fireworks once its reached. 175 ++ int cmd_foo(char **argv) 192 176 193 177 4: Don't expose more than the entry and help points:
Note:
See TracChangeset
for help on using the changeset viewer.