Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 3448 → Rev 3447

/branches/dynload/uspace/app/trace/errors.h
File deleted
/branches/dynload/uspace/app/trace/syscalls.h
File deleted
/branches/dynload/uspace/app/trace/proto.c
File deleted
/branches/dynload/uspace/app/trace/trace.h
File deleted
/branches/dynload/uspace/app/trace/proto.h
File deleted
/branches/dynload/uspace/app/trace/ipc_desc.c
File deleted
/branches/dynload/uspace/app/trace/ipcp.c
File deleted
/branches/dynload/uspace/app/trace/errors.c
File deleted
/branches/dynload/uspace/app/trace/Makefile
File deleted
/branches/dynload/uspace/app/trace/syscalls.c
File deleted
/branches/dynload/uspace/app/trace/trace.c
File deleted
/branches/dynload/uspace/app/trace/ipc_desc.h
File deleted
/branches/dynload/uspace/app/trace/ipcp.h
File deleted
/branches/dynload/uspace/app/bdsh/scli.c
53,8 → 53,8
const char *progname = PACKAGE_NAME;
 
/* These are not exposed, even to builtins */
static int cli_init(cliuser_t *);
static void cli_finit(cliuser_t *);
static int cli_init(cliuser_t *usr);
static void cli_finit(cliuser_t *usr);
 
/* Constructor */
static int cli_init(cliuser_t *usr)
/branches/dynload/uspace/app/bdsh/cmds/builtins/cd/cd.c
42,7 → 42,7
 
static char * cmdname = "cd";
 
void help_cmd_cd(unsigned int level)
void * help_cmd_cd(unsigned int level)
{
if (level == HELP_SHORT) {
printf("`%s' changes the current working directory.\n", cmdname);
53,12 → 53,12
cmdname, cmdname);
}
 
return;
return CMD_VOID;
}
 
/* This is a very rudamentary 'cd' command. It is not 'link smart' (yet) */
 
int cmd_cd(char **argv, cliuser_t *usr)
int * cmd_cd(char **argv, cliuser_t *usr)
{
int argc, rc = 0;
 
/branches/dynload/uspace/app/bdsh/cmds/builtins/cd/entry.h
4,8 → 4,8
#include "scli.h"
 
/* Entry points for the cd command */
extern void help_cmd_cd(unsigned int);
extern int cmd_cd(char **, cliuser_t *);
extern void * help_cmd_cd(unsigned int);
extern int * cmd_cd(char **, cliuser_t *);
 
#endif
 
/branches/dynload/uspace/app/bdsh/cmds/modules/cp/cp.c
File deleted
/branches/dynload/uspace/app/bdsh/cmds/modules/cp/cp_def.h
File deleted
/branches/dynload/uspace/app/bdsh/cmds/modules/cp/entry.h
File deleted
/branches/dynload/uspace/app/bdsh/cmds/modules/cp/cp.h
File deleted
/branches/dynload/uspace/app/bdsh/cmds/modules/sleep/entry.h
File deleted
/branches/dynload/uspace/app/bdsh/cmds/modules/sleep/sleep.c
File deleted
/branches/dynload/uspace/app/bdsh/cmds/modules/sleep/sleep_def.h
File deleted
/branches/dynload/uspace/app/bdsh/cmds/modules/sleep/sleep.h
File deleted
/branches/dynload/uspace/app/bdsh/cmds/modules/touch/touch.c
48,7 → 48,7
static char *cmdname = "touch";
 
/* Dispays help for touch in various levels */
void help_cmd_touch(unsigned int level)
void * help_cmd_touch(unsigned int level)
{
if (level == HELP_SHORT) {
printf("`%s' updates access times for files\n", cmdname);
58,11 → 58,11
"created\n", cmdname);
}
 
return;
return CMD_VOID;
}
 
/* Main entry point for touch, accepts an array of arguments */
int cmd_touch(char **argv)
int * cmd_touch(char **argv)
{
unsigned int argc, i = 0, ret = 0;
int fd;
/branches/dynload/uspace/app/bdsh/cmds/modules/touch/entry.h
2,8 → 2,8
#define TOUCH_ENTRY_H
 
/* Entry points for the touch command */
extern int cmd_touch(char **);
extern void help_cmd_touch(unsigned int);
extern int * cmd_touch(char **);
extern void * help_cmd_touch(unsigned int);
 
#endif /* TOUCH_ENTRY_H */
 
/branches/dynload/uspace/app/bdsh/cmds/modules/mkdir/mkdir.c
60,7 → 60,7
};
 
 
void help_cmd_mkdir(unsigned int level)
void * help_cmd_mkdir(unsigned int level)
{
if (level == HELP_SHORT) {
printf("`%s' creates a new directory\n", cmdname);
79,7 → 79,7
cmdname, cmdname);
}
 
return;
return CMD_VOID;
}
 
/* This is kind of clunky, but effective for now */
181,7 → 181,7
return ret;
}
 
int cmd_mkdir(char **argv)
int * cmd_mkdir(char **argv)
{
unsigned int argc, create_parents = 0, i, ret = 0, follow = 0;
unsigned int verbose = 0;
/branches/dynload/uspace/app/bdsh/cmds/modules/mkdir/entry.h
2,8 → 2,8
#define MKDIR_ENTRY_H
 
/* Entry points for the mkdir command */
extern int cmd_mkdir(char **);
extern void help_cmd_mkdir(unsigned int);
extern int * cmd_mkdir(char **);
extern void * help_cmd_mkdir(unsigned int);
 
#endif /* MKDIR_ENTRY_H */
 
/branches/dynload/uspace/app/bdsh/cmds/modules/cat/cat.c
59,7 → 59,7
};
 
/* Dispays help for cat in various levels */
void help_cmd_cat(unsigned int level)
void * help_cmd_cat(unsigned int level)
{
if (level == HELP_SHORT) {
printf("`%s' shows the contents of files\n", cmdname);
78,7 → 78,7
cmdname, cmdname);
}
 
return;
return CMD_VOID;
}
 
static unsigned int cat_file(const char *fname, size_t blen)
121,6 → 121,12
return 1;
}
 
/* Debug stuff, newline not added purposefully */
printf("** %s is a file with the size of %ld bytes\n",
fname, total);
printf( "** %d bytes were read in a buffer of %d bytes in %d reads\n",
count, blen, reads);
printf("** Read %s\n", count == total ? "Succeeded" : "Failed");
free(buff);
 
return 0;
127,7 → 133,7
}
 
/* Main entry point for cat, accepts an array of arguments */
int cmd_cat(char **argv)
int * cmd_cat(char **argv)
{
unsigned int argc, i, ret = 0, buffer = 0;
int c, opt_ind;
/branches/dynload/uspace/app/bdsh/cmds/modules/cat/entry.h
2,8 → 2,8
#define CAT_ENTRY_H
 
/* Entry points for the cat command */
extern int cmd_cat(char **);
extern void help_cmd_cat(unsigned int);
extern int * cmd_cat(char **);
extern void * help_cmd_cat(unsigned int);
 
#endif /* CAT_ENTRY_H */
 
/branches/dynload/uspace/app/bdsh/cmds/modules/help/help.c
69,7 → 69,7
return HELP_IS_RUBBISH;
}
 
void help_cmd_help(unsigned int level)
void *help_cmd_help(unsigned int level)
{
if (level == HELP_SHORT) {
printf(
86,10 → 86,10
cmdname, cmdname, cmdname, cmdname);
}
 
return;
return CMD_VOID;
}
 
int cmd_help(char *argv[])
int *cmd_help(char *argv[])
{
module_t *mod;
builtin_t *cmd;
/branches/dynload/uspace/app/bdsh/cmds/modules/help/entry.h
2,7 → 2,7
#define HELP_ENTRY_H_
 
/* Entry points for the help command */
extern void help_cmd_help(unsigned int);
extern int cmd_help(char *[]);
extern void * help_cmd_help(unsigned int);
extern int * cmd_help(char *[]);
 
#endif
/branches/dynload/uspace/app/bdsh/cmds/modules/ls/ls.c
132,7 → 132,7
return;
}
 
void help_cmd_ls(unsigned int level)
void * help_cmd_ls(unsigned int level)
{
if (level == HELP_SHORT) {
printf("`%s' lists files and directories.\n", cmdname);
142,10 → 142,10
"working directory is used.\n", cmdname);
}
 
return;
return CMD_VOID;
}
 
int cmd_ls(char **argv)
int * cmd_ls(char **argv)
{
unsigned int argc;
unsigned int scope;
/branches/dynload/uspace/app/bdsh/cmds/modules/ls/entry.h
2,8 → 2,8
#define LS_ENTRY_H
 
/* Entry points for the ls command */
extern int cmd_ls(char **);
extern void help_cmd_ls(unsigned int);
extern int * cmd_ls(char **);
extern void * help_cmd_ls(unsigned int);
 
#endif /* LS_ENTRY_H */
 
/branches/dynload/uspace/app/bdsh/cmds/modules/rm/rm.c
144,7 → 144,7
}
 
/* Dispays help for rm in various levels */
void help_cmd_rm(unsigned int level)
void * help_cmd_rm(unsigned int level)
{
if (level == HELP_SHORT) {
printf("`%s' removes files and directories.\n", cmdname);
161,11 → 161,11
"Currently, %s is under development, some options don't work.\n",
cmdname, cmdname);
}
return;
return CMD_VOID;
}
 
/* Main entry point for rm, accepts an array of arguments */
int cmd_rm(char **argv)
int * cmd_rm(char **argv)
{
unsigned int argc;
unsigned int i, scope, ret = 0;
/branches/dynload/uspace/app/bdsh/cmds/modules/rm/entry.h
2,8 → 2,8
#define RM_ENTRY_H
 
/* Entry points for the rm command */
extern int cmd_rm(char **);
extern void help_cmd_rm(unsigned int);
extern int * cmd_rm(char **);
extern void * help_cmd_rm(unsigned int);
 
#endif /* RM_ENTRY_H */
 
/branches/dynload/uspace/app/bdsh/cmds/modules/quit/quit.c
39,15 → 39,15
extern volatile unsigned int cli_quit;
extern const char *progname;
 
void help_cmd_quit(unsigned int level)
void * help_cmd_quit(unsigned int level)
{
printf("Type `%s' to exit %s\n", cmdname, progname);
return;
return CMD_VOID;
}
 
/* Quits the program and returns the status of whatever command
* came before invoking 'quit' */
int cmd_quit(char *argv[])
int * cmd_quit(char *argv[])
{
/* Inform that we're outta here */
cli_quit = 1;
/branches/dynload/uspace/app/bdsh/cmds/modules/quit/entry.h
2,8 → 2,8
#define QUIT_ENTRY_H_
 
/* Entry points for the quit command */
extern void help_cmd_quit(unsigned int);
extern int cmd_quit(char *[]);
extern void * help_cmd_quit(unsigned int);
extern int * cmd_quit(char *[]);
 
#endif
 
/branches/dynload/uspace/app/bdsh/cmds/modules/pwd/entry.h
4,8 → 4,8
#include "scli.h"
 
/* Entry points for the pwd command */
extern void help_cmd_pwd(unsigned int);
extern int cmd_pwd(char **);
extern void * help_cmd_pwd(unsigned int);
extern int * cmd_pwd(char **);
 
#endif
 
/branches/dynload/uspace/app/bdsh/cmds/modules/pwd/pwd.c
39,13 → 39,13
 
static char * cmdname = "pwd";
 
void help_cmd_pwd(unsigned int level)
void * help_cmd_pwd(unsigned int level)
{
printf("`%s' prints your current working directory.\n", cmdname);
return;
return CMD_VOID;
}
 
int cmd_pwd(char *argv[])
int * cmd_pwd(char *argv[])
{
char *buff;
 
/branches/dynload/uspace/app/bdsh/cmds/modules/modules.h
25,8 → 25,6
#include "touch/entry.h"
#include "ls/entry.h"
#include "pwd/entry.h"
#include "sleep/entry.h"
#include "cp/entry.h"
 
/* Each .def function fills the module_t struct with the individual name, entry
* point, help entry point, etc. You can use config.h to control what modules
41,8 → 39,6
#include "touch/touch_def.h"
#include "ls/ls_def.h"
#include "pwd/pwd_def.h"
#include "sleep/sleep_def.h"
#include "cp/cp_def.h"
{NULL, NULL, NULL, NULL}
};
 
/branches/dynload/uspace/app/bdsh/cmds/mknewcmd
120,8 → 120,8
EOF
[ "${CMDTYPE}" = "module" ] && cat << EOF >> ${OUTDIR}/entry.h
/* Entry points for the ${CMDNAME} command */
extern int ${CMDENTRY}(char **);
extern void ${HELPENTRY}(unsigned int);
extern int * ${CMDENTRY}(char **);
extern void * ${HELPENTRY}(unsigned int);
 
#endif /* ${defname}_ENTRY_H */
 
170,22 → 170,22
static char *cmdname = "${CMDNAME}";
 
/* Dispays help for ${CMDNAME} in various levels */
void ${HELPENTRY}(unsigned int level)
void * ${HELPENTRY}(unsigned int level)
{
printf("This is the %s help for '%s'.\n",
level ? EXT_HELP : SHORT_HELP, cmdname);
return;
return CMD_VOID;
}
 
EOF
[ "${CMDTYPE}" = "module" ] && cat << EOF >> ${OUTDIR}/${CMDNAME}.c
/* Main entry point for ${CMDNAME}, accepts an array of arguments */
int ${CMDENTRY}(char **argv)
int * ${CMDENTRY}(char **argv)
EOF
[ "${CMDTYPE}" = "builtin" ] && cat << EOF >> ${OUTDIR}/${CMDNAME}.c
/* Main entry point for ${CMDNAME}, accepts an array of arguments and a
* pointer to the cliuser_t structure */
int ${CMDENTRY}(char **argv, cliuser_t *usr)
int * ${CMDENTRY}(char **argv, cliuser_t *usr)
EOF
cat << EOF >> ${OUTDIR}/${CMDNAME}.c
{
/branches/dynload/uspace/app/bdsh/cmds/cmds.h
19,16 → 19,17
#define BUFF_SMALL 255
 
/* Return macros for int type entry points */
#define CMD_FAILURE 1
#define CMD_FAILURE (int*)1
#define CMD_SUCCESS 0
#define CMD_VOID (void *)NULL
 
/* Types for module command entry and help */
typedef int (* mod_entry_t)(char **);
typedef void (* mod_help_t)(unsigned int);
typedef int * (* mod_entry_t)(char **);
typedef void * (* mod_help_t)(unsigned int);
 
/* Built-in commands need to be able to modify cliuser_t */
typedef int (* builtin_entry_t)(char **, cliuser_t *);
typedef void (* builtin_help_t)(unsigned int);
typedef int * (* builtin_entry_t)(char **, cliuser_t *);
typedef void * (* builtin_help_t)(unsigned int);
 
/* Module structure */
typedef struct {
/branches/dynload/uspace/app/bdsh/util.c
273,7 → 273,7
if (NULL == usr->cwd)
snprintf(usr->cwd, PATH_MAX, "(unknown)");
 
if (1 < cli_psprintf(&usr->prompt, "%s ", usr->cwd)) {
if (1 < cli_psprintf(&usr->prompt, "%s # ", usr->cwd)) {
cli_error(cli_errno, "Failed to set prompt");
return 1;
}
/branches/dynload/uspace/app/bdsh/Makefile
64,8 → 64,6
cmds/modules/touch/ \
cmds/modules/ls/ \
cmds/modules/pwd/ \
cmds/modules/sleep/ \
cmds/modules/cp/ \
cmds/builtins/ \
cmds/builtins/cd/
 
78,8 → 76,6
cmds/modules/touch/touch.c \
cmds/modules/ls/ls.c \
cmds/modules/pwd/pwd.c \
cmds/modules/sleep/sleep.c \
cmds/modules/cp/cp.c \
cmds/builtins/cd/cd.c \
cmds/mod_cmds.c \
cmds/builtin_cmds.c \
/branches/dynload/uspace/app/bdsh/README
57,12 → 57,12
They are typed as such (from cmds.h):
 
/* Types for module command entry and help */
typedef int (* mod_entry_t)(char **);
typedef void (* mod_help_t)(unsigned int);
typedef int * (* mod_entry_t)(char **);
typedef void * (* mod_help_t)(unsigned int);
 
/* Built-in commands need to be able to modify cliuser_t */
typedef int (* builtin_entry_t)(char **, cliuser_t *);
typedef void (* builtin_help_t)(unsigned int);
typedef int * (* builtin_entry_t)(char **, cliuser_t *);
typedef void * (* builtin_help_t)(unsigned int);
 
As you can see, both modular and builtin commands expect an array of
arguments, however bulitins also expect to be pointed to cliuser_t.
153,7 → 153,9
 
2: Change your "usage()" command as shown:
-- void usage(...)
++ void help_cmd_foo(unsigned int level)
++ void * help_cmd_foo(unsigned int level)
-- return;
++ retrn CMD_VOID;
 
'level' is either 0 or 1, indicating the level of help requested.
If the help / usage function currently exits based on how it is
161,19 → 163,33
 
3: Change the programs "main()" as shown:
-- int main(int argc, char **argv)
++ int cmd_foo(char **argv)
++ int * cmd_foo(char **argv)
-- return 1;
++ return CMD_FAILURE;
-- return 0;
++ return CMD_SUCCESS;
 
If main() returns an int that is not 1 or 0 (e.g. 127), cast it as
such:
 
-- return 127;
++ return (int *) 127;
 
NOTE: _ONLY_ the main and help entry points need to return int * or
void *, respectively. Also take note that argc has changed. The type
for entry points may soon change.
 
NOTE: If main is void, you'll need to change it and ensure that its
expecting an array of arguments, even if they'll never be read or
used. I.e.:
 
-- void main(void)
++ int cmd_foo(char **argv)
++ int * cmd_foo(char **argv)
 
Similararly, do not try to return CMD_VOID within the modules main
entry point. If somehow you escape the compiler yelling at you, you
will surely see pretty blue and yellow fireworks once its reached.
 
4: Don't expose more than the entry and help points:
-- void my_function(int n)
++ static void my_function(int n)
/branches/dynload/uspace/app/bdsh/config.h
1,18 → 1,15
/* Various things that are used in many places including a few
* tidbits left over from autoconf prior to the HelenOS port */
/* Various things that are used in many files
* Various temporary port work-arounds are addressed in __HELENOS__ , this
* serves as a convenience and later as a guide to make "phony.h" for future
* ports */
 
/* Specific port work-arounds : */
#ifndef PATH_MAX
#define PATH_MAX 255
#endif
 
#ifndef EXIT_SUCCESS
#define EXIT_SUCCESS 0
#define EXIT_FAILURE 1
#endif
#define EXIT_FAILURE 0
 
/* Work around for getenv() */
#define PATH "/srv:/app"
#define PATH "/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin"
#define PATH_DELIM ":"
 
/* Used in many places */
29,7 → 26,7
#define PACKAGE_BUGREPORT "echo@echoreply.us"
#define PACKAGE_NAME "bdsh"
#define PACKAGE_STRING "The brain dead shell"
#define PACKAGE_TARNAME "bdsh"
#define PACKAGE_TARNAME "scli"
#define PACKAGE_VERSION "0.0.1"
 
 
/branches/dynload/uspace/app/init/init.c
108,15 → 108,17
return -1;
}
// FIXME: spawn("/srv/pci");
spawn("/srv/fb");
spawn("/srv/kbd");
spawn("/srv/console");
buf = malloc(BUF_SIZE);
// FIXME: spawn("/sbin/pci");
spawn("/sbin/fb");
spawn("/sbin/kbd");
spawn("/sbin/console");
console_wait();
version_print();
spawn("/app/bdsh");
spawn("/sbin/bdsh");
free(buf);
return 0;
/branches/dynload/uspace/app/tester/tester.c
133,7 → 133,7
if (c == 'a')
break;
if (test->name == NULL)
if (c > 'a')
printf("Unknown test\n\n");
else
run_test(test);