Changeset 6279151 in mainline
- 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
- Location:
- uspace/app/bdsh
- Files:
-
- 2 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: -
uspace/app/bdsh/cmds/mknewcmd
r809813d r6279151 171 171 172 172 /* Dispays help for ${CMDNAME} in various levels */ 173 void *${HELPENTRY}(unsigned int level)173 void ${HELPENTRY}(unsigned int level) 174 174 { 175 175 printf("This is the %s help for '%s'.\n", 176 176 level ? EXT_HELP : SHORT_HELP, cmdname); 177 return CMD_VOID;177 return; 178 178 } 179 179 … … 181 181 [ "${CMDTYPE}" = "module" ] && cat << EOF >> ${OUTDIR}/${CMDNAME}.c 182 182 /* Main entry point for ${CMDNAME}, accepts an array of arguments */ 183 int *${CMDENTRY}(char **argv)183 int ${CMDENTRY}(char **argv) 184 184 EOF 185 185 [ "${CMDTYPE}" = "builtin" ] && cat << EOF >> ${OUTDIR}/${CMDNAME}.c 186 186 /* Main entry point for ${CMDNAME}, accepts an array of arguments and a 187 187 * pointer to the cliuser_t structure */ 188 int *${CMDENTRY}(char **argv, cliuser_t *usr)188 int ${CMDENTRY}(char **argv, cliuser_t *usr) 189 189 EOF 190 190 cat << EOF >> ${OUTDIR}/${CMDNAME}.c
Note:
See TracChangeset
for help on using the changeset viewer.