OS2021_Project1.Shell
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 

59 řádky
1.8 KiB

#pragma once
#define CMDLINE_MAX_SIZE 1024 /* max length of a single command line */
#define ARGS_MAX_QUANTITY 128 /* max args on a command line */
#define BUFFER_MAX_SIZE 64 /* max size of a buffer which contains parsed arguments */
#define CMDLINE_DIV ' \t\r\n\a'
#define CMDLINE_HISTORY_MAX_QUANTITY 256
#define JOBS_MAX_QUANTITY 16
#define PATH_MAX_SIZE 256
#define FG 1 /* running in foreground */
#define BG 2 /* running in background */
#define ST 3 /* stopped */
/* job_t - The job struct */
struct job_t
{
pid_t pid; /* job PID */
int jid; /* job ID [1, 2, ...] */
int state; /* UNDEF, BG, FG, or ST */
char cmdline[CMDLINE_MAX_SIZE]; /* command line */
};
/* readline - Get the command line */
char *readline();
/* parseline - Evaluate the command line that the user has just typed in */
int parseline(char *cmdline, char **args);
/* execute - Execute the command line */
int execute(char *cmdline, char **args);
/* builtin functions - Handle built-in command */
int built_in(char **args);
int builtin_cd(char **args);
int builtin_ls(char **args);
int builtin_history(char **args);
int builtin_jobs(char **args);
int builtin_mytop(char **args);
/* do_bgfg - Execute background/foregroung tasks */
int do_bgfg(char **args);
/* addjob - Add jobs to joblist */
int addjob(struct job_t *jobs, pid_t pid, int state, char *cmdline);
/* pide2jid - Map process ID to job ID*/
int pid2jid(pid_t pid);
/* waitfg - Wait foreground jobs to finish */
void waitfg(pid_t pid);
/* fgpid - Return PID of current foreground job, 0 if no such job */
pid_t fgpid(struct job_t *jobs);
/* determine if a file is hidden */
int hide(const char *path);
/* */