aboutsummaryrefslogtreecommitdiff
path: root/kernel/test/kshell/priv.h
blob: 65c94936afccd20dcabf3853964d26f15bf34263 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#pragma once

#include "test/kshell/kshell.h"

#include "util/list.h"

#define dprintf(x, args...) dbg(DBG_TEST, x, ##args)

#define KSH_BUF_SIZE                                 \
    1024 /* This really just needs to be as large as \
          * the line discipline buffer */
#define KSH_CMD_NAME_LEN 16
#define KSH_MAX_ARGS 128
#define KSH_DESC_LEN 64

struct chardev;
struct kshell_command;

struct kshell
{
    /* If we have a filesystem, we can write to the file
     * descriptor. Otherwise, we need to write to a byte device */
#ifdef __VFS__
    int ksh_fd;

    /* Used for redirection */
    int ksh_out_fd;
    int ksh_in_fd;
#else
    struct chardev *ksh_cd;
#endif
};

extern list_t kshell_commands_list;

/**
 * Searches for a shell command with a specified name.
 *
 * @param name name of the command to search for
 * @param namelen length of name
 * @return the command, if it exists, or NULL
 */
struct kshell_command *kshell_lookup_command(const char *name, size_t namelen);