YASH 0.1
CLI written in C
Loading...
Searching...
No Matches
yash.h
Go to the documentation of this file.
1
10#pragma once
11
12// ============================================================================
13// Includes
14// ============================================================================
15
16#include <signal.h>
17#include <sys/stat.h>
18#include <sys/types.h>
19
20// ============================================================================
21// Configuration Constants
22// ============================================================================
23
25#define MAX_CMDLINE 2001
26
28#define MAX_TOKENS 2000
29
31#define MAX_TOKEN_LEN 30
32
34#define MAX_ARGS 64
35
37#define MAX_JOBS 20
38
40#define FILE_CREATE_MODE (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH)
41
42// ============================================================================
43// Globals
44// ============================================================================
45
47extern volatile sig_atomic_t child_status_changed;
48
50extern pid_t foreground_pgid;
51
52// ============================================================================
53// Enums
54// ============================================================================
55
65
66// ============================================================================
67// Data Structures
68// ============================================================================
69
82typedef struct Command {
83 char* argv[MAX_ARGS];
84 char* in_file;
85 char* out_file;
86 char* err_file;
89
106
107// ============================================================================
108// Helper Functions
109// ============================================================================
110
115void init_command(Command* cmd);
Represents one command with arguments and redirections.
Definition yash.h:82
char * out_file
Filename for output redirection.
Definition yash.h:85
char * in_file
Filename for input redirection.
Definition yash.h:84
char * argv[MAX_ARGS]
Null-terminated array of arguments.
Definition yash.h:83
char * err_file
Filename for error redirection.
Definition yash.h:86
int background
Background execution flag.
Definition yash.h:87
Represents a full line of user input.
Definition yash.h:100
Command left
Left command.
Definition yash.h:102
Command right
Right command.
Definition yash.h:103
int is_pipeline
Flag indicating if the line is a pipeline.
Definition yash.h:101
char original[MAX_CMDLINE]
Original command line string.
Definition yash.h:104
void init_command(Command *cmd)
Initialize a Command structure to NULL/0 values.
Definition parse.c:125
#define MAX_ARGS
Reasonable cap on arguments per command.
Definition yash.h:34
pid_t foreground_pgid
Process group ID of the current foreground process.
Definition signals.c:22
struct Command Command
Represents one command with arguments and redirections.
TokenKind
Token kinds.
Definition yash.h:57
@ TK_AMP
Identifies = &
Definition yash.h:63
@ TK_WORD
Identifies = Regular text
Definition yash.h:58
@ TK_REDIR_IN
Identifies = <
Definition yash.h:59
@ TK_REDIR_ERR
Identifies = 2>
Definition yash.h:61
@ TK_PIPE
Identifies = |
Definition yash.h:62
@ TK_REDIR_OUT
Identifies = >
Definition yash.h:60
#define MAX_CMDLINE
Maximum command line length including null terminator.
Definition yash.h:25
volatile sig_atomic_t child_status_changed
Flag indicating that a child process status has changed.
Definition signals.c:21
struct Line Line
Represents a full line of user input.